avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kamesh Kompella <kam...@chooxy.com>
Subject Is this a valid Avro schema?
Date Fri, 02 Sep 2016 22:01:29 GMT
Hi there,
             First, please look at the following schema 

{"name": "user_record",
  "namespace": "com.user",
  "type": "record",
  "fields" : [ 
    {"name": "name", "type": "string"},
    {"name": "id", "type": "long"}
  ]}

and the following JSON:  

{"name": “Foo", “id": 42}

When I run avro-tools with the option fromjson, I get a .avro file. Stuff works.

If I enclose the schema above into array as shown below (I bolded the array begin and end
in red for clarity), avro-tools (version 1.8.1) throws the following exception and dies. 


[{"name": "user_record",
  "namespace": "com.user",
  "type": "record",
  "fields" : [ 
    {"name": "name", "type": "string"},
    {"name": "id", "type": "long"}
  ]}]

I get the following exception: 

Exception in thread "main" org.apache.avro.AvroTypeException: Unknown union branch name at
org.apache.avro.io.JsonDecoder.readIndex(JsonDecoder.java:445)

Does it make sense to enclose a schema into array? Is this a bug in avro-tools or is this
an invalid schema? The exception above seems to indicate that a schema file may not begin
with a JSON array of schemas. 

The documentation seems to indicate schema may be defined as union of other other schemas.

I cloned the code base and I could not locate a single instance of avsc file in it that defined
its schema as a JSON array. Hence, the question.

I appreciate your response.

Regards
Kamesh
Mime
View raw message