-
Notifications
You must be signed in to change notification settings - Fork 842
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
Add Field Constructors for Complex Fields #3992
Add Field Constructors for Complex Fields #3992
Conversation
Self::new( | ||
name, | ||
DataType::Union(UnionFields::new(type_ids, fields), mode), | ||
false, // Unions cannot be nullable |
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 potentially worth highlighting, these constructors allow us to help ensure schema invariants
@@ -145,6 +147,104 @@ impl Field { | |||
} | |||
} | |||
|
|||
/// Create a new [`Field`] with [`DataType::Dictionary`] | |||
/// | |||
/// Use [`Self::new_dict`] for more advanced dictionary options |
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.
IPC dictionary IDs being the most obvious example
@@ -7104,12 +7104,12 @@ mod tests { | |||
fn test_cast_null_from_and_to_nested_type() { | |||
// Cast null from and to map | |||
let data_type = DataType::Map( | |||
Arc::new(Field::new( | |||
Arc::new(Field::new_struct( |
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.
❤️
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.
😍
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Which issue does this PR close?
Closes #.
Rationale for this change
Declaring nested schema is incredibly verbose, and for some types, especially MapArray and UnionArray, it isn't immediately obvious what constitutes a valid field.
What changes are included in this PR?
Adds various additional constructors to facilitate declaring fields of complex types.
Are there any user-facing changes?