snowflake-cloud-data-platform - 使用分区 ADLS 复制到
问题描述
我有一个带有分区镶木地板文件的容器,我想将其与 copy into 命令一起使用。我的目录如下所示。
ABC_PARTITIONED_ID=1 (directory)
1-snappy.parquet
2-snappy.parquet
3-snappy.parquet
4-snappy.parquet
ABC_PARTITIONED_ID=2 (directory)
1-snappy.parquet
2-snappy.parquet
3-snappy.parquet
ABC_PARTITIONED_ID=3 (directory)
1-snappy.parquet
2-snappy.parquet
……
每个分区目录可以包含多个 parquet 文件。我没有与目录模式(ID1、ID2 等)匹配的配置单元分区列。
如何正确使用 copy into 命令中的模式参数从我的 ADLS 写入 SF 表?我以https://www.snowflake.com/blog/how-to-load-terabytes-into-snowflake-speeds-feeds-and-techniques/为例。
解决方案
如果目录/分区名称对您来说并不重要,那么您可以使用公共预览版中支持 Parquet 格式的一些较新的函数来创建表和摄取数据。您关于如何构建模式的问题将是 PATTERN='*.parquet' 因为所有子文件夹都将被读取。
//create file format , only required to create one time
create file format my_parquet_format
type = parquet;
//EXAMPLE CREATE AND COPY INTO FOR TABLE1
//create an empty table using this file format and location. name the table table1
create or replace table ABC
using template (
select array_agg(object_construct(*))
from table(
infer_schema(
location=>'@mystage/ABC_PARTITIONED_ROOT',
file_format=>'my_parquet_format'
)
));
//copy parquet files in folder /table1 into table TABLE1
copy into ABC from @mystage/ABC_PARTITIONED_ROOT pattern = '*.parquet' file_format=my_parquet_format match_by_column_name=case_insensitive;
推荐阅读
- react-native - React Native - 不会导航到新创建的文件
- html - 为什么带有 src 和 srcset 的图像在 Chrome 中会发出冗余网络请求?
- mysql - 将日期时间值分类为次日班次结束的班次
- blockchain - 如何在不运行runnodes的情况下单独运行corda节点?
- css - 带有bootstrap4的Angular 7粘性页脚
- javascript - 同时运行2个html视频JS
- java - Java-如何验证泰语字符是否从 UTF-8 正确编码到 TIS620
- json - 获取 JSON 对象的每个项目的最后 N 个元素
- java - 使用 Selenium (Java) 与 React 下拉菜单交互:“其他元素会收到点击”
- android - 为什么recyclerview比listview快