【问题标题】:unload Snowflake data to s3 without the extension/file_format将雪花数据卸载到不带扩展名/文件格式的 s3
【发布时间】:2021-12-24 16:41:34
【问题描述】:

如何在不使用任何文件格式的情况下将雪花数据卸载到 s3?

为了将数据卸载到特定的扩展中,我们使用雪花文件格式。

例如代码

  copy into 's3://mybucket/unload/'
  from mytable
  storage_integration = myint
  file_format = (format_name = my_csv_format);

但我想要的是存储数据而不需要任何扩展。

【问题讨论】:

    标签: snowflake-cloud-data-platform file-format


    【解决方案1】:

    您可以将参数 FILE_EXTENSION = NONE 添加到您的文件格式中。使用此参数,Snowflake 不会根据您的文件格式(在本例中为 .csv)添加文件扩展名,而是使用传递的扩展名(NONE 或任何其他)。

    copy into 's3://mybucket/unload/'
    from mytable
    storage_integration = myint
    file_format = (format_name = my_csv_format file_extension = NONE);
    

    https://docs.snowflake.com/en/sql-reference/sql/copy-into-location.html

    【讨论】:

      【解决方案2】:

      SINGLE 是我要找的。它是我们可以与COPY 命令一起使用的参数之一,它创建没有扩展名的文件。

      代码:

      copy into 's3://mybucket/unload/'
      from mytable
      storage_integration = myint
      file_format = (format_name = my_csv_format)
      SINGLE = TRUE;
      

      查看以下链接的注释以更好地理解:

      https://docs.snowflake.com/en/sql-reference/sql/create-file-format.html#:~:text=comma%20(%2C)-,FILE_EXTENSION,-%3D%20%27string%27%20%7C%20NONE

      【讨论】:

        猜你喜欢
        • 2020-04-21
        • 2021-03-17
        • 1970-01-01
        • 2020-05-09
        • 1970-01-01
        • 2020-11-13
        • 1970-01-01
        • 2020-06-10
        • 1970-01-01
        相关资源
        最近更新 更多