我如何创建一个附加列并使用interschma synatx中的子句使用分区

发布于 2025-02-11 05:13:43 字数 454 浏览 0 评论 0原文

我正在阅读S3的数据,以使用Inferschmea在雪花上创建外部表格。我正在从“表达式”列中获取所有列,但想在分区中使用其他列日期。如何使用Inferschmea实现这一目标?

create or replace external table people_test1
  using template (
    select expression,filenames, substr(filenames,24,10) DATE_PART
 
      from table(
        infer_schema(
          location=>'@ITCHBOD.COMPANY_STAGE/cre/invets/',
          file_format=>'CRUPARQUET',
          partition by (DATE_PART)
        )
      ) 
  )

I am reading data from s3 to create an external table in snowflake using inferschmea. I am getting all columns from the expression column but want to additional columns date to use it in the partition by. How can I achieve this using inferschmea?

create or replace external table people_test1
  using template (
    select expression,filenames, substr(filenames,24,10) DATE_PART
 
      from table(
        infer_schema(
          location=>'@ITCHBOD.COMPANY_STAGE/cre/invets/',
          file_format=>'CRUPARQUET',
          partition by (DATE_PART)
        )
      ) 
  )

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲影 2025-02-18 05:13:43

也有同样的问题。用SnowsQL:

1:创建像您做的

2:手动添加datePart

alter table people_test1 add date_part date as some_extraction_logic(metadata$filename);

3:从表中生成ddl,并通过语句通过语句添加A替换

select replace(get_ddl('table', 'people_test1'),'location=','partition by (date_part)\nlocation=');

4:执行生成的DDL

我希望 ,我希望将其添加DDDL:有一天雪花提供更好的解决方案

Had the same issue. Solved it with a hacky workaround with snowsql:

1: Create the external table like you did

2: Manually add the datepart

alter table people_test1 add date_part date as some_extraction_logic(metadata$filename);

3: Generate the DDL from the table and put the partition by statement in via a replace

select replace(get_ddl('table', 'people_test1'),'location=','partition by (date_part)\nlocation=');

4: execute the generated ddl

I hope Snowflake provides a better solution one day

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文