如何将包含换行符的 Redshift 数据卸载到单行中?

How to unload Redshift data containing newline characters into single line?

我正在尝试卸载红移数据并使用 spark 读取它。但是与 Redshift table 中的原始记录相比,我在卸载数据中获得了更多行。发生这种情况是因为数据中有换行符。我怎样才能卸载数据,以便我可以使用 spark 安全地读取它(而不会遇到格式错误的记录问题)

一列样本数据-

5.7.1 [23.253.182.55      18] Our system has detected that this message is
5.7.1 likely suspicious due to the very low reputation of the sending IP
5.7.1 address. To best protect our users from spam, the message has been
5.7.1 blocked. Please visit
5.7.1  https://support.google.com/mail/answer/188131 for more information. o68-v6si2862477itg.128 - gsmtp

我在卸载时尝试了以下三种组合,但没有成功 -

ALLOWOVERWRITE delimiter '[=11=]1' escape;

ALLOWOVERWRITE delimiter '[=11=]1' escape addquotes;

ALLOWOVERWRITE delimiter '[=11=]1' addquotes;

unload syntax 需要 select 语句(任意查询)作为输入,而不仅仅是源 table 名称,因此您可以用空字符串或空格替换换行符在查询中:

replace(your_text_field,'\n',' ')