0

我正在尝试从 Snowflake 和外部 S3 阶段提取数据,以 txt 文件格式存储可以使用 SFTP 发送给供应商的数据。但我面临 SQL 编译错误 -

文件格式脚本:

create or replace file format my_format
  type = txt
  field_delimiter = '|'
  skip_header = 0
  null_if = ('NULL', 'null')
  empty_field_as_null = true

请告知我们如何在 S3 外部阶段将数据卸载为 txt 格式。

4

1 回答 1

2

只需将 txt 更改为 csv 并将 file_extension 更改为 txt:

create or replace file format my_format
  type = csv
  field_delimiter = '|'
  skip_header = 0
  null_if = ('NULL', 'null')
  empty_field_as_null = true
  file_extension = 'txt'

尽管它显示的是 CSV,但它实际上是带有分隔字段的文本,并且您的竖线(竖线)会覆盖使用逗号作为列分隔符。

于 2020-09-01T21:28:13.970 回答