jecsand838 commented on code in PR #8274:
URL: https://github.com/apache/arrow-rs/pull/8274#discussion_r2322694024
##########
arrow-avro/src/schema.rs:
##########
@@ -790,12 +856,35 @@ fn merge_extras(schema: Value, mut extras:
JsonMap<String, Value>) -> Value {
}
}
-// Convert an Arrow `DataType` into an Avro schema `Value`.
+fn wrap_nullable(inner: Value, order: Nullability) -> Value {
+ match order {
+ Nullability::NullFirst =>
Value::Array(vec![Value::String("null".into()), inner]),
+ Nullability::NullSecond => Value::Array(vec![inner,
Value::String("null".into())]),
+ }
+}
+
fn datatype_to_avro(
dt: &DataType,
field_name: &str,
metadata: &HashMap<String, String>,
name_gen: &mut NameGenerator,
+) -> Result<(Value, JsonMap<String, Value>), ArrowError> {
+ datatype_to_avro_with_order(dt, field_name, metadata, name_gen,
Nullability::NullFirst)
+}
+
+fn arrow_field_to_avro(
+ field: &ArrowField,
+ name_gen: &mut NameGenerator,
+) -> Result<Value, ArrowError> {
+ arrow_field_to_avro_with_order(field, name_gen, Nullability::NullFirst)
+}
+
+fn datatype_to_avro_with_order(
+ dt: &DataType,
+ field_name: &str,
+ metadata: &HashMap<String, String>,
+ name_gen: &mut NameGenerator,
+ order: Nullability,
Review Comment:
Thats also a very valid call out. I'll clean this up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]