You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2022/02/09 21:08:06 UTC

[avro] branch branch-1.11 updated: AVRO-3374: Fully qualified type reference "ns.int" loses namespace.

This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch branch-1.11
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/branch-1.11 by this push:
     new f126908  AVRO-3374: Fully qualified type reference "ns.int" loses namespace.
f126908 is described below

commit f126908aa18a2874512067bfc41f14cd8b6f55c4
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Wed Feb 9 23:04:06 2022 +0200

    AVRO-3374: Fully qualified type reference "ns.int" loses namespace.
    
    Add a unit test showing that the Rust impl behaves as desired.
    
    Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
    (cherry picked from commit 8988196545a17e76a984b07313dd4a86497c9e02)
---
 lang/rust/src/schema.rs | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/lang/rust/src/schema.rs b/lang/rust/src/schema.rs
index ab5fd04..075e8ca 100644
--- a/lang/rust/src/schema.rs
+++ b/lang/rust/src/schema.rs
@@ -1914,4 +1914,28 @@ mod tests {
         );
         assert!(RecordFieldOrder::from_str("not an ordering").is_err());
     }
+
+    /// AVRO-3374
+    #[test]
+    fn test_avro_3374_preserve_namespace_for_primitive() {
+        let schema = Schema::parse_str(
+            r#"
+            {
+              "type" : "record",
+              "name" : "ns.int",
+              "fields" : [
+                {"name" : "value", "type" : "int"},
+                {"name" : "next", "type" : [ "null", "ns.int" ]}
+              ]
+            }
+            "#,
+        )
+        .unwrap();
+
+        let json = schema.canonical_form();
+        assert_eq!(
+            json,
+            r#"{"name":"ns.int","type":"record","fields":[{"name":"value","type":"int"},{"name":"next","type":["null","ns.int"]}]}"#
+        );
+    }
 }