代码之家  ›  专栏  ›  技术社区  ›  Sauron J.Vassallo

Talend S3 CSV到Redshift处理丢失的数据

  •  1
  • Sauron J.Vassallo  · 技术社区  · 7 年前

    我在S3中加载了一个CSV平面文件,偶尔在用逗号分隔的列中会有一个空值,例如: "ColumnValue1,,ColumnValue3,...etc" 注意到 ",," 例如CSV中缺少的值。下面是使用tDBBulkExec组件在Talend中从S3到Redshift设置的基本步骤:

    enter image description here

    在按以下方式映射列并运行时:

    enter image description here

    Exception in component tDBBulkExec_1 (tncretail_opportunity)
    java.sql.SQLException: [Amazon](500310) Invalid operation: syntax error at or near "," 
    Position: 100;
        at com.amazon.redshift.client.messages.inbound.ErrorResponse.toErrorException(Unknown Source)
        at com.amazon.redshift.client.PGMessagingContext.handleErrorResponse(Unknown Source)
        at com.amazon.redshift.client.PGMessagingContext.handleMessage(Unknown Source)
        at com.amazon.jdbc.communications.InboundMessagesPipeline.getNextMessageOfClass(Unknown Source)
        at com.amazon.redshift.client.PGMessagingContext.doMoveToNextClass(Unknown Source)
        at com.amazon.redshift.client.PGMessagingContext.getBindComplete(Unknown Source)
        at com.amazon.redshift.client.PGClient.handleErrorsScenario1(Unknown Source)
        at com.amazon.redshift.client.PGClient.handleErrors(Unknown Source)
        at com.amazon.redshift.client.PGClient.directExecuteExtraMetadata(Unknown Source)
        at com.amazon.redshift.dataengine.PGQueryExecutor.execute(Unknown Source)
        at com.amazon.jdbc.common.SStatement.executeNoParams(Unknown Source)
        at com.amazon.jdbc.common.SStatement.execute(Unknown Source)
    Caused by: com.amazon.support.exceptions.ErrorException: [Amazon](500310) Invalid operation: syntax error at or near "," 
    Position: 100;
    

    我怎样才能修改它来工作?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Dillon Wright    7 年前

    我一直在使用Talend一段时间来做你所做的事情我所做的和我推荐的模式有一些关键的区别。

    1. 您的问题很可能是您没有指定db列名,这些列名需要指定并且是唯一的(数据库使用这些来关联回模式)

    2. 除非您有使用TdB组件的特定原因,否则不要使用它们,而是使用预先构建的特定连接器,即tRedshiftBulkExec。

    3. 据我所知,红移大容量文件是以csv分隔的,但可能不一定符合该文件的确切规范,因此您使用该组件可能是错误的。

    我给你的建议是

    1. 从s3中提取CSV转换成一个大容量文件,然后上传到Redshift(您可以使用

    2. 或者,可以使用TRedshiftRow发出copy命令 https://docs.aws.amazon.com/redshift/latest/dg/r_COPY.html

    推荐文章