2016-07-26 125 views
0

我正在面臨的問題 - 減少具有字符串和數組值的avro文件。Avro Mapreduce作業失敗org.apache.avro.AvroTypeException

org.apache.avro.AvroTypeException:

  `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]記錄值,提示以下例外情況的取找到Event_DA在org.apache.avro.io.ResolvingDecoder.doAction(ResolvingDecoder.java:231)預計Event_DA

它看起來問題出在輸入模式文件組合這兩個字符串類型和記錄陣列時。

請爲這些類型的avro文件提供有關示例架構文件的寶貴建議。

回答

0

根據您的模式定義,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"}, 
        ....... 
       ] 
     } 
    } 
]}