-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Encapsulate metadata for literals on to a FieldMetadata
structure
#16317
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
9752ed6
to
a916b4c
Compare
FieldMetadata
structure
I also found we can further unify the metadata handling for Expr::Alias as well, but would like to propose doing that as a follow on PR: |
/// A constant value along with associated metadata | ||
Literal(ScalarValue, Option<BTreeMap<String, String>>), | ||
/// A constant value along with associated [`FieldMetadata`]. | ||
Literal(ScalarValue, Option<FieldMetadata>), |
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.
The point of this PR is to put all metadata handling in a Struct to make it easier to work with (and more efficient)
metadata | ||
.map(|m| m.into_iter().collect::<HashMap<String, String>>()), | ||
))) | ||
Ok(Transformed::yes(lit_with_metadata(utf8_val, 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.
this is a pretty good example of the kind of simplification this PR allows (don't have to translate back/forth between HashMap / BTreeMap in various places)
false => Some(new_metadata), | ||
}; | ||
|
||
let metadata = metadata.as_ref().map(|m| FieldMetadata::from(m.clone())); |
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 remove this clone in a follow on PR:
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. This is a very nice cleanup of the prior code.
Here is a follow on PR to also use the same structure in |
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 this!
Which issue does this PR close?
Related to Support metadata on literal values #15797
Follow on to feat: add metadata to literal expressions #16170
This is an updated version of Encapsulate FieldMetadata timsaucer/datafusion#2
Rationale for this change
As discussed on #16170 (comment), we made an initial PR to add metadata to Expr::Literal as part of DataFusion 48, but the API could use a bit of fine tuning to:
What changes are included in this PR?
FieldMetadata
Arc
to make it fast to cloneAre these changes tested?
Are there any user-facing changes?