【问题标题】:Error- invalid char between token and delimiter using ConvertRecord in NiFi错误-在 NiFi 中使用 ConvertRecord 的令牌和分隔符之间的字符无效
【发布时间】:2018-12-19 00:15:44
【问题描述】:

我正在使用如下流程(基本上是从 s3 获取文件,然后从主 CSV 文件转换少量记录,然后将其推送到 Elasticsearch): GetSQS->UpdateAtttribute->SplitJson->EvaluateJsonPath->UpdateAttribute->convertRecord->其他处理器...

我能够正确地从 s3 获取文件,但 ConvertRecord 处理器抛出错误:封装的标记和分隔符之间的字符无效

请在下方找到 ConvertRecord 配置:

**CSVRecordReader** : Schema Access strategy as "Use 'Schema Text' Property

Schema Text: 


{
  "type": "record",
  "name": "AVLRecord0",
  "fields" : [
    {"name": "TimeOfDay","type": "string", "logicalType":"timestamp-millis"},
    {"name": "Field_0", "type": "double"},
    {"name": "Field_1", "type": "double"},
    {"name": "Field_2", "type": "double"},
    {"name": "Field_3", "type": "double"}}
]
}
**CSVRecordWritter**: 

Schema Write Strategy : Set 'Avro. schema' Attribute

Schema Access Strategy: Use Schema Text Property

请告诉我为什么我从 S3 成功获取后看不到转换后的记录。

所需的输出仅为 CSV 格式。请找到在 s3 上上传的附加示例文件,我只想转换为 field_5。

附上控制器服务截图:

谢谢!

【问题讨论】:

  • @Shu 我已经更新了这个问题。谢谢你!请帮助解决这个问题。
  • 它按预期工作 xml 在这里:github.com/shureddy/NiFiTemplates/blob/master/…,请检查 1.您输入文件中的数据,是否有任何 extra quote/comma characters 嵌入(或不是有效的 csv 格式)2。在 csv 阅读器控制器服务中将 ignore csv Header column names 属性更改为 True (因为您没有使用 csv 文件头)。请告诉我们您的发现
  • @Shu 我修好了。它是 ConvertRecord 处理器中的一个额外逗号。谢谢。
  • @Shu 我已经发布了我的发现和结果。谢谢你的帮助。

标签: apache amazon-s3 apache-nifi


【解决方案1】:

我发现了我的错误: 1. EvaluateJsonPath 后忘记添加 FetchS3Object Processor 2. 我的架构文本属性中多了一个逗号。

【讨论】:

    【解决方案2】:

    您能说出转换记录处理器中多余的逗号到底在哪里吗? 因为我面临同样的问题。 据我了解,由于 size_dimension 字段而出现问题 以下是我的 csv 数据:

    id,project,name,depth,parentid,description,createdtime,lastupdatedtime,metadata,path,source,sourceid
    75125,abcd,P200184,4,74861,"WIRELINE RUNNING / RETRIEVING TOOL, SUPP",2002-06-04 00:00:00.0,2019-04-26 00:00:00.0,"{""material_group"":""group"",""weight_unit"":""LB"",""laboratory"":""PMC"",""object_type"":""material"",""pyspark_generated_time"":""2019-06-07, 13:32:20.287657"",""size_dimension"":""3'5\""L X 3'5\""W X 1'H"",""gross_weight"":""100.000"",""net_weight"":""100.000"",""valid_from_date"":""20031219""}","[59941,64249,74859,74861,75125]",RPA_SAA.MRA,P200184
    

    我使用的 avro 架构是:

    {
        "name":"abc",
        "namespace":"nifi",
        "type":"record",
        "fields": [
        {"name":"id", "type": ["long", "null"], "default": null},
        {"name":"project", "type": ["string", "null"], "default": null},
        {"name":"name", "type": ["string", "null"], "default": null},
        {"name":"depth", "type": ["int", "null"], "default": null},
        {"name":"parentid", "type": ["long", "null"], "default": null},
        {"name":"description", "type": ["string", "null"], "default": null},
        {"name":"createdtime","type": ["null",{ "type":"long", "logicalType":"timestamp-millis"}], "default":null},
        {"name":"lastupdatedtime","type": ["null",{ "type":"long", "logicalType":"timestamp-millis"}], "default":null},
        {"name":"metadata","type": ["string", "null"], "default": null},
        {"name":"path","type": ["string", "null"], "default": null},
        {"name":"source", "type": ["string", "null"], "default": null},
        {"name":"sourceid", "type": ["string", "null"], "default": null}
        ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-21
      • 2012-06-23
      相关资源
      最近更新 更多