Quote escaped quotes in Redshift external tables

旧巷老猫 提交于 2020-07-21 06:14:12

问题


I'm trying to create an external table in Redshift from a csv that has quote escaped quotes in it, as documented in rfc4180:

If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be escaped by preceding it with another double quote.

For example: "aaa","b""bb","ccc"

I get no errors but the final table has a null value where my string should be.

Is there a way to tell Redshift to understand this csv format when creating an external table?

I do not want to change the formatting of the csv file.


Example csv:

"some ""text""",some more text,"more, text",and more

Example external table creation:

create external table spectrum.spectrum_test_quote(
  a varchar(32),
  b varchar(32),
  c varchar(32),
  d varchar(32)
)
row format serde 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
with serdeproperties (
  'separatorChar' = ',',
  'quoteChar' = '\"',
  'escapeChar' = '\\'
)
stored as textfile
location 's3://';

Expected results:

  • field a: some "text"
  • field b: some more text
  • field c: more, text
  • field d: and more

Actual result:

  • field a: null
  • field b: some more text
  • field c: more, text
  • field d: and more

来源:https://stackoverflow.com/questions/54446531/quote-escaped-quotes-in-redshift-external-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!