john
john

Reputation: 11709

Invalid default for field warning message coming from Avro?

I have a avro schema like this in which I have is_userid_present decalred as boolean and I wanted to give default value as false to it so I came up with below avro schema.

{
   "type":"record",
   "name":"hello",
   "fields":[
      {
         "name":"u",
         "type":[
            "string",
            "null"
         ]
      },
      {
         "name":"p",
         "type":"string"
      },
      {
         "name":"bu",
         "type":"boolean"
      },
      {
         "name":"is_userid_present",
         "type":"boolean",
         "default":"false"
      }
   ]
}

But from Avro code, I am seeing this warning message -

[WARNING] Avro: Invalid default for field is_userid_present: "false" not a "boolean"

I am not sure what wrong I am doing here? If I have avro schema like this, then will it be of any problem for writing and reading the data?

Upvotes: 5

Views: 7184

Answers (1)

Todd
Todd

Reputation: 31720

According to the Avro Docs, if you specify a default boolean, you can't do it as a String like you have it.

Try this...

  {
     "name": "is_userid_present",
     "type": "boolean",
     "default": false
  }

Upvotes: 12

Related Questions