martin-g commented on code in PR #1901:
URL: https://github.com/apache/avro/pull/1901#discussion_r991152897


##########
lang/rust/avro/src/schema.rs:
##########
@@ -1373,12 +1376,35 @@ impl Parser {
         &mut self,
         items: &[Value],
         enclosing_namespace: &Namespace,
+        default: Option<&Value>
     ) -> AvroResult<Schema> {
         items
             .iter()
             .map(|v| self.parse(v, enclosing_namespace))
             .collect::<Result<Vec<_>, _>>()
+            .and_then(|schemas| {
+                if let Some(default_value) = default {
+                    let avro_value = types::Value::from(default_value.clone());
+                    let first_schema = schemas.first().cloned();
+                    if let Some(schema) = first_schema {
+                        // Try to resolve the schema
+                        let resolved_value = 
avro_value.clone().resolve(&schema);
+                        let schema_kind = SchemaKind::from(schema);
+                        let value_kind = types::ValueKind::from(avro_value);

Review Comment:
   nit: The last two lines should be moved to line 1397.



##########
lang/rust/avro/src/error.rs:
##########
@@ -229,6 +229,9 @@ pub enum Error {
     #[error("Unions cannot contain duplicate types")]
     GetUnionDuplicate,
 
+    #[error("Unions first type {0:?} must match default value type {1:?}")]

Review Comment:
   ```suggestion
       #[error("Union's first type {0:?} must match the `default`'s value type 
{1:?}")]
   ```



-- 
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]

Reply via email to