[ 
https://issues.apache.org/jira/browse/AVRO-3448?focusedWorklogId=741331&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-741331
 ]

ASF GitHub Bot logged work on AVRO-3448:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 14/Mar/22 23:09
            Start Date: 14/Mar/22 23:09
    Worklog Time Spent: 10m 
      Work Description: jklamer commented on a change in pull request #1602:
URL: https://github.com/apache/avro/pull/1602#discussion_r826451117



##########
File path: lang/rust/avro/src/encode.rs
##########
@@ -496,4 +495,268 @@ mod tests {
         encode(&outer_value2, &schema, &mut buf);
         assert!(!buf.is_empty());
     }
+
+    #[test]
+    fn test_avro_3448_proper_multi_level_encoding_outer_namespace() {
+        let schema = r#"
+        {
+          "name": "record_name",
+          "namespace": "space",
+          "type": "record",
+          "fields": [
+            {
+              "name": "outer_field_1",
+              "type": [
+                        "null",
+                        {
+                            "type": "record",
+                            "name": "middle_record_name",
+                            "fields":[
+                                {
+                                    "name":"middle_field_1",
+                                    "type":[
+                                        "null",
+                                        {
+                                            "type":"record",
+                                            "name":"inner_record_name",
+                                            "fields":[
+                                                {
+                                                    "name":"inner_field_1",
+                                                    "type":"double"
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                }
+                            ]
+                        }
+                    ]
+            },
+            {
+                "name": "outer_field_2",
+                "type" : "space.inner_record_name"
+            }
+          ]
+        }
+        "#;
+        let schema = Schema::parse_str(schema).unwrap();
+        let inner_record = Value::Record(vec![("inner_field_1".into(), 
Value::Double(5.4))]);
+        let middle_record_variation_1 = Value::Record(vec![(
+            "middle_field_1".into(),
+            Value::Union(0, Box::new(Value::Null)),
+        )]);
+        let middle_record_variation_2 = Value::Record(vec![(
+            "middle_field_1".into(),
+            Value::Union(1, Box::new(inner_record.clone())),
+        )]);
+        let outer_record_variation_1 = Value::Record(vec![
+            (
+                "outer_field_1".into(),
+                Value::Union(0, Box::new(Value::Null)),
+            ),
+            ("outer_field_2".into(), inner_record.clone()),
+        ]);
+        let outer_record_variation_2 = Value::Record(vec![
+            (
+                "outer_field_1".into(),
+                Value::Union(1, Box::new(middle_record_variation_1)),
+            ),
+            ("outer_field_2".into(), inner_record.clone()),
+        ]);
+        let outer_record_variation_3 = Value::Record(vec![
+            (
+                "outer_field_1".into(),
+                Value::Union(1, Box::new(middle_record_variation_2)),
+            ),
+            ("outer_field_2".into(), inner_record),
+        ]);
+
+        // TODO add in error result wrapping to encoding flow

Review comment:
       We could have it return usize of encoded size?




-- 
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: issues-unsubscr...@avro.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 741331)
    Time Spent: 2h  (was: 1h 50m)

> Rust: Encoding Panic with valid schema and input 
> -------------------------------------------------
>
>                 Key: AVRO-3448
>                 URL: https://issues.apache.org/jira/browse/AVRO-3448
>             Project: Apache Avro
>          Issue Type: Bug
>            Reporter: Jack Klamer
>            Assignee: Jack Klamer
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 2h
>  Remaining Estimate: 0h
>
> After a recent bug regarding Rust Avro's schema ref was fixed to help 
> preserve the parsing form of schema 
> (https://issues.apache.org/jira/browse/AVRO-3433). This exposed an issue 
> where named schemas defined with the rules of the spec (depth first, left to 
> right), are not available to the encoding workflow because it indexes schemas 
> as it traverses the data. This is a problem for the common use case of 
> defining a record within an optional field and it being encoded as Null, and 
> not having that type then available during encoding for the next field. 
>  
> This was patched for level + 1 schema definitions but was not solved within 
> the fullness of the spec 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to