COPY INTO:有没有办法显示在将数据加载到 Snowflake 期间跳过的记录数?

COPY INTO: is there a way to show number of records skipped during loading data into Snowflake?

我正在使用 copy-into-table from an external location and there is an option to continue loading 数据以防该行数据损坏。是否有显示加载时跳过了多少行的选项,就像 Teradata TPT 中的选项一样。

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

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

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

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

复制到 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 这些列的解析可能与您编写脚本的方式不同。