You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Zezeng Wang (Jira)" <ji...@apache.org> on 2020/04/16 07:06:00 UTC

[jira] [Updated] (AVRO-2804) Generated Avro schema from Thrift is missing default values

     [ https://issues.apache.org/jira/browse/AVRO-2804?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Zezeng Wang updated AVRO-2804:
------------------------------
    Description: 
Hi,

Currently, using the thrift class to generate Avro's schema, there is missing default values.

In our project, the business data will be transmitted through the Thrift framework and saved in the avro file, and then use *GenericRecord* to perform business delivery on various other business platforms, but use this schema for data deserialization, there is no default value for the field, resulting in Troublesome work.

Thrift's IDL:
{code:java}
namespace java org.apache.avro.thrift.test
struct SimpleDefault{

1: i16 im_default = 6;

2: required i16 im_required = 6;

3: optional i16 im_optional = 6;

}

{code}
Generated Schema for using ThriftData:
{code:java}
{
  "type":"record",
  "name":"SimpleDefault",
  "namespace":"org.apache.avro.thrift.test",
  "fields":[{
    "name":"im_default",
    "type":{
      "type":"int",
      "thrift":"short"
    }
  },{
    "name":"im_required",
    "type":{
      "type":"int",
      "thrift":"short"
    }
},{
    "name":"im_optional",
    "type":["null",{
      "type":"int",
      "thrift":"short"
    }]
}]
}
 {code}
Default value is missing.

Deserialization (GenericDatumReader):

{code:java}

{

  "im_default":6,

  "im_required":6,

  "im_optional":null

}

{code}
 I am trying to add a default value in ThriftData because I found that it is not set.
 [https://github.com/apache/avro/blob/9af218d3c060da103868cdc69d7b39fc8d50dcbc/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftData.java#L197]

  was:
Hi,

Currently, using the thrift class to generate Avro's schema, there is missing default values.

In our project, the business data will be transmitted through the Thrift framework and saved in the avro file, and then use *GenericRecord* to perform business delivery on various other business platforms, but use this schema for data deserialization, there is no default value for the field, resulting in Troublesome work.

Thrift's IDL:

{code}
namespace java org.apache.avro.thrift.test
struct SimpleDefault{

1: i16 im_default= 6;

2: required i16 im_required = 6;

3: optional i16 im_optional = 6;

}

{code}

Generated Schema for using ThriftData:

{code:java}
{
  "type":"record",
  "name":"SimpleDefault",
  "namespace":"org.apache.avro.thrift.test",
  "fields":[{
    "name":"im_default",
    "type":{
      "type":"int",
      "thrift":"short"
    }
  },{
    "name":"im_required",
    "type":{
      "type":"int",
      "thrift":"short"
    }
},{
    "name":"im_optional",
    "type":["null",{
      "type":"int",
      "thrift":"short"
    }]
}]
}
 {code}
Default value is missing.
I am trying to add a default value in ThriftData because I found that it is not set.
https://github.com/apache/avro/blob/9af218d3c060da103868cdc69d7b39fc8d50dcbc/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftData.java#L197


> Generated Avro schema from Thrift is missing default values
> -----------------------------------------------------------
>
>                 Key: AVRO-2804
>                 URL: https://issues.apache.org/jira/browse/AVRO-2804
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.8.2, 1.9.2
>            Reporter: Zezeng Wang
>            Priority: Major
>
> Hi,
> Currently, using the thrift class to generate Avro's schema, there is missing default values.
> In our project, the business data will be transmitted through the Thrift framework and saved in the avro file, and then use *GenericRecord* to perform business delivery on various other business platforms, but use this schema for data deserialization, there is no default value for the field, resulting in Troublesome work.
> Thrift's IDL:
> {code:java}
> namespace java org.apache.avro.thrift.test
> struct SimpleDefault{
> 1: i16 im_default = 6;
> 2: required i16 im_required = 6;
> 3: optional i16 im_optional = 6;
> }
> {code}
> Generated Schema for using ThriftData:
> {code:java}
> {
>   "type":"record",
>   "name":"SimpleDefault",
>   "namespace":"org.apache.avro.thrift.test",
>   "fields":[{
>     "name":"im_default",
>     "type":{
>       "type":"int",
>       "thrift":"short"
>     }
>   },{
>     "name":"im_required",
>     "type":{
>       "type":"int",
>       "thrift":"short"
>     }
> },{
>     "name":"im_optional",
>     "type":["null",{
>       "type":"int",
>       "thrift":"short"
>     }]
> }]
> }
>  {code}
> Default value is missing.
> Deserialization (GenericDatumReader):
> {code:java}
> {
>   "im_default":6,
>   "im_required":6,
>   "im_optional":null
> }
> {code}
>  I am trying to add a default value in ThriftData because I found that it is not set.
>  [https://github.com/apache/avro/blob/9af218d3c060da103868cdc69d7b39fc8d50dcbc/lang/java/thrift/src/main/java/org/apache/avro/thrift/ThriftData.java#L197]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)