2017-12-15 14 views
0

は、私は以下の目的を持っています。私はこのためのスキーマを考案しようとしています。しかし、:(動作していないようアブロスキーマ障害

私は、次の2つを試してみました:。。

{ 
    "name": "ProductsOrNull", 
    "type": ["null", { 
     "type": "array", 
     "name": "Products", 
     "items": { 
     "type":"record", 
     "name": "Product", 
     "fields": [{ 
      "name":"ProductId", 
      "type":"long" 
      }, { 
      "name":"ProductName", 
      "type":"string" 
      } 
     ] 
     } 
    }], 
    "default": null 
} 

しかしjava -jar avro-tools-1.8.2.jar fromjson --schema-file prod.avsc prod.json > lol.avroを実行しているとき、それはException in thread "main" org.apache.avro.SchemaParseException: No type: <...>で失敗

私も同じエラーでこれをトライ:

{ 
    "type": ["null", "array"], 
    "name": "Products", 
    "items": { 
    "type":"record", 
    "name": "Product", 
    "namespace": "{{ dataModelSchema }}", 
    "fields": [{ 
     "name":"ProductId", 
     "type":"long" 
     }, { 
     "name":"ProductName", 
     "type":"string" 
     } 
    ] 
    } 
} 

問題があり、2つの違いは何です私は本当に理解していない。

答えて

1

あなたのスキーマのベース、あなたのJSONオブジェクトは

{ 
"ProductsOrNull" : 
[ 
{"ProductId":10,"ProductName":"some name"} 
] 
} 

フィールド名を指定せずに配列してスキーマを定義し、アブロする方法はありませんようになるはずです。