【问题标题】:How to unload Redshift data containing newline characters into single line?如何将包含换行符的 Redshift 数据卸载到单行中?
【发布时间】:2019-03-12 12:40:14
【问题描述】:

我正在尝试卸载红移数据并使用 spark 读取它。但是与 Redshift 表中的原始记录相比,我在卸载数据中获得了更多行。发生这种情况是因为数据中有换行符。如何卸载数据以便我可以使用 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 分隔符 '\001' 转义;

ALLOWOVERWRITE 分隔符 '\001' 转义加引号;

ALLOWOVERWRITE 分隔符 '\001' 添加引号;

【问题讨论】:

    标签: amazon-web-services apache-spark amazon-s3 amazon-redshift amazon-redshift-spectrum


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢。就这么简单:)
    猜你喜欢
    • 2020-02-11
    • 2016-10-15
    • 1970-01-01
    • 1970-01-01
    • 2018-11-25
    • 1970-01-01
    • 2019-07-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多