You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Check Peck <co...@gmail.com> on 2015/01/06 01:46:19 UTC
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?
Re: Invalid default for field warning message coming from Avro?
Posted by Joey Echeverria <jo...@cloudera.com>.
The default should be specified using the JSON type. So for boolean,
you want false without the quotes. As is, it thinks you're trying to
set the default to a string.
This is described under the definition of record schemas in the spec:
http://avro.apache.org/docs/current/spec.html#schema_record
The table with example defaults should help as well.
-Joey
On Mon, Jan 5, 2015 at 4:46 PM, Check Peck <co...@gmail.com> wrote:
> 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?
--
Joey Echeverria