2017-12-15 4 views
0

나는 다음과 같은 목적이 있습니다아 브로 스키마 실패

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

니어 가끔 난 그냥 null해야합니다. 나는 이것을위한 스키마를 생각해 내고있다. 그러나 :(작동하지 않는 것

나는 다음과 같은 두 가지 시도 :..

{ 
    "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" 
     } 
    ] 
    } 
} 

문제이며 둘 사이의 차이는 무엇이고 난 정말 이해가 안 돼요.

필드 이름없는 배열에는 정의하는 방법과 브로 스키마가 없습니다

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

처럼 스키마에

답변

1

자료, 당신의 JSON 객체가 보일 것입니다.

관련 문제