简体   繁体   English

雪花 - 列默认值对 COPY 命令无效?

[英]Snowflake - Column default values not effective with COPY command?

I'm using Matillion to load data into Snowflake, both on Azure.我正在使用 Matillion 将数据加载到 Snowflake 中,两者都在 Azure 上。 When I create tables I specify default values for the columns, I don't like having NULLs in the warehouse.当我创建表时,我为列指定默认值,我不喜欢在仓库中有 NULL。

From what I've read, the Database Query orchestration component in Matillion for Snowflake will put the retrieved data set into an Azure blob and use the Snowflake COPY command to move the data from the blob to the target table.根据我的阅读,Matillion for Snowflake 中的数据库查询编排组件会将检索到的数据集放入 Azure blob 并使用 Snowflake COPY 命令将数据从 blob 移动到目标表。

The result is that NULL values are still there in the target table.结果是 NULL 值仍然存在于目标表中。

Can someone confirm that the COPY command does some kind of bulk data copy and that the default values are effective only with INSERT statements?有人可以确认 COPY 命令会进行某种批量数据复制,并且默认值仅对 INSERT 语句有效吗?

If so I'll just use trap the NULL values at the source.如果是这样,我将在源头使用陷阱 NULL 值。

Thanks.谢谢。

JFS. JFS。

It isn't mentioned in a straight-forward way but the COPY INTO … TABLE statement documentation does specify that it will use the default only for skipped column names (and not in other scenarios):它没有以直接的方式提及,但COPY INTO … TABLE语句文档确实指定它将仅对跳过的列名使用默认值(而不是在其他情况下):

( col_name [, col_name... ] )

[ … ] […]

Any columns excluded from this column list are populated by their default value从此列列表中排除的任何列均由其默认值填充

Additionally, the NULL-use behaviour is mentioned for another scenario where data may be missing, making no note of the use of defaults:此外,在另一种可能丢失数据的情况下提到了使用 NULL 的行为,没有注意使用默认值:

ERROR_ON_COLUMN_COUNT_MISMATCH = TRUE | FALSE

[ … ] […]

If the input file contains records with fewer fields than columns in the table, the non-matching columns in the table are loaded with NULL values .如果输入文件包含的记录的字段少于表中的列,则表中不匹配的列将加载 NULL 值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM