-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: Preserves field metadata when creating logical plan for VALUES expression #17525
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
Conversation
4de7c9f
to
ecb5971
Compare
CC @paleolimbot |
1b2cda5
to
8eb5b21
Compare
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.
Thank you for looking into this!
common_metadata = FieldMetadata::merge_options( | ||
common_metadata.as_ref(), | ||
Some(&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.
I am not sure this is the exact merge operation we want here, since it will happily merge two completely unrelated extensions (I think) by overwriting the metadata of the first with whatever was encountered last.
It is not perfect, but a potentially safer solution might be to error for any mismatched metadata (i.e., if there's any metadata on these expressions, it has to be identical here or it will error).
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 agree that we should ensure that all the metadata in VALUES must be identical. This has the most unambiguous semantics and does not pose too many restrictions to typical use cases of VALUES. I'll submit commits to fix this 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.
I have updated LogicalPlanBuilder::values
to require that all metadata should be identical. I'm not sure if a more permissive approach, such as computing the intersection of metadata, would work, but this more strict rule is a good start anyway.
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.
Thank you @Kontinuation and @paleolimbot -- this looks good to me.
1fa9ae0
to
34fd36f
Compare
I merged up to resolve a conflict |
And there is now another one! I resolved it and merged up |
🚀 |
Which issue does this PR close?
Rationale for this change
The metadata of fields created by
VALUES
SQL expression were lost during the creation ofLogicalPlan::Values
logical plan node. This patch tries to preserve the field metadata.What changes are included in this PR?
This patch takes the metadata of fields in
VALUES
expression into consideration. The schema ofVALUES
expression will contain field with proper metadata.Are these changes tested?
user_defined_scalar_functions
testAre there any user-facing changes?
No public API changes.