Zezeng Wang created AVRO-2804:
---------------------------------
Summary: 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.9.2, 1.8.2
Reporter: Zezeng Wang
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
--
This message was sent by Atlassian Jira
(v8.3.4#803005)