如何在Snowflake中使用模式自动检测将Parquet/AVRO加载到多个列中



当试图将Parquet/AVRO文件加载到Snowflake表中时,我得到错误:

PARQUET文件格式只能生成一列类型变量、对象或数组。如果要加载多个列,请使用CSV文件格式。

但我不想将这些文件加载到新的单列表中——我需要COPY命令来匹配现有表的列。

我可以做些什么来获得架构自动检测?

好消息,该错误消息已经过时,因为现在Snowflake支持模式检测和COPY INTO多列。

再现错误:

create or replace table hits3 (
WatchID BIGINT,
JavaEnable SMALLINT,
Title TEXT
);
copy into hits3
from @temp.public.my_ext_stage/files/
file_format = (type = parquet);
-- PARQUET file format can produce one and only one column of type variant or object or array.
-- Use CSV file format if you want to load more than one column.

要修复错误并使Snowflake与表和Parquet/AVRO文件中的列匹配,只需添加选项MATCH_BY_COLUMN_NAME=CASE_INSENSITIVE(或MATCH_BY_COLUMN_NAME=CASE_SENSITIVE(:

copy into hits3
from @temp.public.my_ext_stage/files/
file_format = (type = parquet)
match_by_column_name = case_insensitive;

文件:

  • https://docs.snowflake.com/en/sql-reference/sql/copy-into-table.html
  • https://docs.snowflake.com/en/user-guide/data-load-overview.html?#detection-暂存的半结构化数据文件中的列定义

最新更新