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/04/18 19:44:30 UTC
[avro] branch branch-1.11 updated: AVRO-3494: Uncomment a test for recursive types (#1648)
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 724d85bca AVRO-3494: Uncomment a test for recursive types (#1648)
724d85bca is described below
commit 724d85bcaa8a71f63d2bf99dcecb6722e23c1f9d
Author: Martin Grigorov <ma...@users.noreply.github.com>
AuthorDate: Mon Apr 18 22:43:57 2022 +0300
AVRO-3494: Uncomment a test for recursive types (#1648)
Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
(cherry picked from commit 5bdebfdc53f1c0ff62af9f84942f2519946fa3fb)
---
lang/rust/avro/tests/schema.rs | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/lang/rust/avro/tests/schema.rs b/lang/rust/avro/tests/schema.rs
index 1410424ba..f58b62f9e 100644
--- a/lang/rust/avro/tests/schema.rs
+++ b/lang/rust/avro/tests/schema.rs
@@ -565,12 +565,6 @@ lazy_static! {
EXAMPLES.iter().copied().filter(|s| s.1).collect();
}
-/*
-// TODO: (#92) properly support recursive types and uncomment
-
-This test is failing unwrapping the outer schema with ParseSchemaError("Unknown type: X"). It seems
-that recursive types are not properly supported.
-
#[test]
fn test_correct_recursive_extraction() {
init();
@@ -594,21 +588,31 @@ fn test_correct_recursive_extraction() {
]
}"#;
let outer_schema = Schema::parse_str(raw_outer_schema).unwrap();
- if let Schema::Record { fields: outer_fields, .. } = outer_schema {
- let raw_inner_schema = outer_fields[0].schema.canonical_form();
- let inner_schema = Schema::parse_str(raw_inner_schema.as_str()).unwrap();
- if let Schema::Record { fields: inner_fields, .. } = inner_schema {
- if let Schema::Record {name: recursive_type, .. } = &inner_fields[0].schema {
+ if let Schema::Record {
+ fields: outer_fields,
+ ..
+ } = outer_schema
+ {
+ let inner_schema = &outer_fields[0].schema;
+ if let Schema::Record {
+ fields: inner_fields,
+ ..
+ } = inner_schema
+ {
+ if let Schema::Record {
+ name: recursive_type,
+ ..
+ } = &inner_fields[0].schema
+ {
assert_eq!("X", recursive_type.name.as_str());
}
} else {
- panic!("inner schema {} should have been a record", raw_inner_schema)
+ panic!("inner schema {:?} should have been a record", inner_schema)
}
} else {
- panic!("outer schema {} should have been a record", raw_outer_schema)
+ panic!("outer schema {:?} should have been a record", outer_schema)
}
}
-*/
#[test]
fn test_parse() {