@@ -27,8 +27,8 @@ use itertools::{Either, Itertools};
27
27
use serde_json:: { Number , Value } ;
28
28
29
29
use crate :: spec:: {
30
- ListType , MapType , NestedField , NestedFieldRef , PrimitiveType , RawLiteral , Schema ,
31
- SchemaVisitor , StructType , Type , visit_schema,
30
+ ListType , MapType , NestedField , NestedFieldRef , PrimitiveType , Schema , SchemaVisitor ,
31
+ StructType , Type , visit_schema,
32
32
} ;
33
33
use crate :: { Error , ErrorKind , Result , ensure_data_valid} ;
34
34
@@ -82,15 +82,7 @@ impl SchemaVisitor for SchemaToAvroSchema {
82
82
}
83
83
84
84
let default = if let Some ( literal) = & field. initial_default {
85
- let raw_literal = RawLiteral :: try_from ( literal. clone ( ) , & field. field_type ) ?;
86
- let json_value = serde_json:: to_value ( raw_literal) . map_err ( |e| {
87
- Error :: new (
88
- ErrorKind :: DataInvalid ,
89
- "Failed to serialize default value to json" ,
90
- )
91
- . with_source ( e)
92
- } ) ?;
93
- Some ( json_value)
85
+ Some ( literal. clone ( ) . try_into_json ( & field. field_type ) ?)
94
86
} else if !field. required {
95
87
Some ( Value :: Null )
96
88
} else {
0 commit comments