如何通过模式自动检测将 Parquet/AVRO 加载到 Snowflake 中的多个列中?

问题描述 投票:0回答:2

尝试将 Parquet/AVRO 文件加载到 Snowflake 表中时出现错误:

PARQUET 文件格式可以生成一且仅一列类型变体或对象或数组。如果您想加载多列,请使用 CSV 文件格式。

但我不想将这些文件加载到新的单列表中 - 我需要

COPY
命令来匹配现有表的列。

我该怎么做才能获得架构自动检测?

snowflake-cloud-data-platform avro parquet
2个回答
3
投票

好消息,该错误消息已过时,因为现在 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;

文档:


0
投票

对于

parquet
文件格式,我使用了以下命令:

--COPY into table
copy into dbo.Table_name
FROM '@AZURE_STAGE/File_Name.parquet'
file_format=(type='parquet')
MATCH_BY_COLUMN_NAME ='CASE_INSENSITIVE'
;
© www.soinside.com 2019 - 2024. All rights reserved.