【发布时间】:2021-04-25 00:58:09
【问题描述】:
我正在使用 Snowflake 和一些我需要上传到暂存区域的 JSON 文件。 由于 Snowflake 不允许大小超过 1GB 的文件,我不得不使用 7zip 将它们拆分成更小的文件。
I ended up with 4 files like the ones below
Files were uploaded to the Staging area 带有您在附图中看到的图案。
我正在尝试使用以下命令将暂存区域中的这些文件复制到另一个表中
copy into yelp_user from @staging/yelp_academic_dataset_user.json.gz file_format
=(format_name=yelp_user) on_error='skip_file';
这让我遇到了这个错误:
002019 (0A000): SQL compilation error:JSON 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.
然后我尝试创建一个 JSON 表:
CREATE OR REPLACE TABLE json_table_user(json_data variant);
copy into JSON_TABLE_USER file_format =(format_name = 'yelp_user') files=('yelp_academic_dataset_user.json.001.gz','yelp_academic_dataset_user.json.002.gz','yelp_academic_dataset_user.json.003.gz','yelp_academic_dataset_user.json.004.gz') on_error = 'skip_file';
我收到错误提示
Remote file 'https://gcpuscentral1-ncxq405-stage.storage.googleapis.com/tables/2807681033/yelp_academic_dataset_user.json.004.gz' was not found. There are several potential causes. The file might not exist. The required credentials may be missing or invalid. If you are running a copy command, please make sure files are not deleted when they are being loaded or files are not being loaded into two different tables concurrently with auto purge option.
这让我发疯了,因为以下 Snowflake 网站上的教程对我没有帮助。
有谁知道如何按照我需要的方式将这些拆分文件复制到表中?
【问题讨论】:
-
为什么Snowflake 无法加载> 1gb 的文件?在您给出的最后一个 COPY 语句中,所需的 FROM 子句在哪里?
-
因为我尝试在 Web 客户端上执行此操作,但我收到有关允许的最大大小的错误。在另一个 Copy 语句中,我没有包含它,因为默认情况下,Snowflake 将放置我正在处理的最后一个位置,该位置是暂存模式以及我拥有这些文件的位置。
-
您不应该尝试使用 WebUI 来加载大文件。如果您的文件在本地 PC 上,那么您需要使用 Snowsql 运行 put 命令将它们加载到内部阶段;如果您的文件在 AWS/Azure/GCP 上,那么您使用外部阶段。我建议您始终使用 FROM 子句,而不是假设 Snowflake 将在哪里查找文件
-
您也可以使用github.com/Mitch-Wheat/FileSplitter分割文件
-
请参阅stackoverflow.com/a/68718176/132438 轻松将文件拆分成更小的文件。
标签: json snowflake-cloud-data-platform