vvazza
vvazza

Reputation: 397

Unloading data from Snowflake to txt format file

I am trying to extract data from Snowflake and external S3 stage the data in txt file format that can be sent over to vendor using SFTP. But I am facing SQL compilation error -

File format script:

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

Please advise how can we unload data to txt format in S3 external stage.

Upvotes: 0

Views: 2554

Answers (1)

Greg Pavlik
Greg Pavlik

Reputation: 11046

Just change the txt to csv and the file_extension to 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'

Although it shows CSV, it's actually text with delimited fields and your pipe (vertical bar) overrides use of the comma as a column delimiter.

Upvotes: 3

Related Questions