Avro field default values

后端 未结 3 1037
野性不改
野性不改 2020-12-24 11:10

I am running into some issues setting up default values for Avro fields. I have a simple schema as given below:

data.avsc:

{
 \"name         


        
相关标签:
3条回答
  • 2020-12-24 11:29

    Its a bug at Avro's end which is marked as Not A Problem . You need to add default attribute to mention default value.

    {"name": "xxx", "type": ["null", "boolean"], "default": null}
    

    Please refer AVRO-1803.

    0 讨论(0)
  • 2020-12-24 11:41

    You must provide "default": null not "default": "null" in the schema to get the builder method working

    0 讨论(0)
  • 2020-12-24 11:42

    The default value of a union corresponds to the first schema of the union (Source). Your union is defined as ["long", "null"] therefor the default value must be a long number. null is not a long number that is why you are getting an error.

    If you still want to define null as a default value then put null schema first, i.e. change the union to ["null", "long"] instead.

    0 讨论(0)
提交回复
热议问题