【问题标题】:Avro Mapreduce job failing org.apache.avro.AvroTypeExceptionAvro Mapreduce 作业失败 org.apache.avro.AvroTypeException
【发布时间】:2016-07-26 22:05:06
【问题描述】:

我在减少同时具有字符串和数组值的 avro 文件时遇到问题。

           `Describe hdfs:/test/test.avro                                       
           number                      STRING
           totalProductFee            STRING
           productID                   STRING
           otherPartyId               STRING
           module                     STRING
           client                     STRING
           Event_DA                ARRAY
           Event_DA.recType           STRING
           Event_DA.AccountID         STRING
           Event_DA.Identifier        STRING
           Event_DA.ValueBefore       STRING
           Event_DA.ValueAfter        STRING
           Event_DA.Change            STRING
           Event_DA.ExpiryDate         STRING

但是,当我尝试运行作业以获取记录值的数组 [Event_DA] 时,会出现以下异常:

org.apache.avro.AvroTypeException: 找到 Event_DA,在 org.apache.avro.io.ResolvingDecoder.doAction(ResolvingDecoder.java:231) 期待 Event_DA

在结合字符串类型和记录数组时,问题似乎出在输入架构文件上。

请为这些类型的 avro 文件提供示例架构文件的宝贵建议。

【问题讨论】:

    标签: hadoop mapreduce avro avro4s


    【解决方案1】:

    根据您的架构定义,Event_DA 将是“记录”类型,而不是“数组”类型。 您的 Avro 架构如下所示:

    {
    "type":"record",
    "name":"myrecordname"
    "fields": [
       {"name": "number", "type": "string"},
       {"name": "totalProductFee", "type": "string"},
       .......
       {"name": "Event_DA", "type": {"type":"record, "name":"Event_DA",
           "fields": [{"name":"recType", "type":"string"},
                      {"name":"AccountID", "type":"string"},
                      .......
                     ]
            }
       }
    ]}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-22
      • 2015-08-26
      • 2014-02-06
      • 1970-01-01
      相关资源
      最近更新 更多