-
Notifications
You must be signed in to change notification settings - Fork 786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix generate_unions_case for Rust case #1677
Conversation
4896e43
to
2883adc
Compare
Codecov Report
@@ Coverage Diff @@
## master #1677 +/- ##
==========================================
- Coverage 83.10% 83.01% -0.10%
==========================================
Files 193 193
Lines 55881 55940 +59
==========================================
- Hits 46439 46436 -3
- Misses 9442 9504 +62
Continue to review full report at Codecov.
|
2883adc
to
4372037
Compare
@@ -499,6 +499,52 @@ impl DataType { | |||
)) | |||
} | |||
} | |||
Some(s) if s == "union" => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't parse union type from json before.
@@ -392,6 +392,70 @@ mod tests { | |||
assert_eq!(expected, dt); | |||
} | |||
|
|||
#[test] | |||
fn parse_union_from_json() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will work on union to json in another PR later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM -- thanks @viirya
let default_fields = type_ids | ||
.iter() | ||
.map(|t| { | ||
Field::new("", DataType::Boolean, true).with_metadata( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it cool to have a field without a name 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only a placeholder, as above other nested types (list, map, etc) do. The actual fields will replace them (Field::from
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because, type
(union, map, list, etc) is defined in "type" of the Json map, fields are defined in "children" of the map. We parse "type" to get the nested type and parse "children" to get actual fields after that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation
Merged, thanks @alamb ! |
Which issue does this PR close?
Closes #1676.
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?