【问题标题】:COPY INTO: is there a way to show number of records skipped during loading data into Snowflake?COPY INTO:有没有办法显示在将数据加载到 Snowflake 期间跳过的记录数?
【发布时间】:2020-10-26 00:07:29
【问题描述】:

我正在从外部位置使用copy-into-table,并且可以选择continue loading 数据,以防该行的数据损坏。是否有一个选项可以显示加载时跳过了多少行,就像 Teradata TPT 中有一个选项一样。

【问题讨论】:

    标签: snowflake-cloud-data-platform snowflake-schema


    【解决方案1】:

    假设您没有在 COPY INTO 命令中进行转换,您可以在加载后利用 VALIDATE() 函数并获取跳过的记录以及未加载它们的原因:

    https://docs.snowflake.com/en/sql-reference/functions/validate.html

    示例其中 t1 是您正在加载的表。如果你知道,你也可以指定一个特定的 query_id:

    select * from table(validate(t1, job_id => '_last'));
    

    【讨论】:

      【解决方案2】:

      COPY INTO outputs the following columns:

      ROWS_PARSED: Number of rows parsed from the source file
      ROWS_LOADED: Number of rows loaded from the source file
      ERROR_LIMIT: If the number of errors reaches this limit, then abort
      ERRORS_SEEN: Number of error rows in the source file
      

      跳过的行数可以计算为ROWS_PARSED - ROWS_LOADED。我正在使用pyodbc,这些列的解析可能与您编写脚本的方式不同。

      【讨论】:

        猜你喜欢
        • 2021-11-23
        • 2022-09-29
        • 1970-01-01
        • 1970-01-01
        • 2020-04-09
        • 2018-03-23
        • 2023-03-23
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多