Uh oh!
There was an error while loading. Please reload this page.
Allow Logical expression ScalarVariable to represent an extension type or metadata - #18243
Conversation
batmnnn
commented
Oct 23, 2025
@paleolimbot can you review this sire |
paleolimbot
left a comment
There was a problem hiding this comment.
Thank you!
@alamb kindly added a helper to make the DataType -> FieldRef cleaner, which I think will be useful here.
I think this also needs at least one test to ensure that the metadata and nullability of a variable are inferred correctly by Expr::to_field()!
I don't have the power to make the CI run but perhaps a committer who comes across this can hit the button 🙂
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
alamb
commented
Oct 29, 2025
@batmnnn thank you for this PR. Do you have time to address @paleolimbot 's comments on this PR? |
Co-authored-by: Dewey Dunnington <dewey@dunnington.ca>
Co-authored-by: Dewey Dunnington <dewey@dunnington.ca>
Co-authored-by: Dewey Dunnington <dewey@dunnington.ca>
Co-authored-by: Dewey Dunnington <dewey@dunnington.ca>
Co-authored-by: Dewey Dunnington <dewey@dunnington.ca>
…n/T/.tmpU3MvU3/target.csv"
batmnnn
commented
Oct 29, 2025
@alamb sorry for the delay got caught up in exams, just addressed them. |
paleolimbot
left a comment
There was a problem hiding this comment.
Thank you!
This needs a committer to run CI...provided it's green, this looks good to me!
alamb
commented
Nov 3, 2025
I am so sorry I missed this -- I will check it out tomorrow |
paleolimbot
left a comment
There was a problem hiding this comment.
Apologies for missing this on the last round...in addition to bringing the trait into scope to fix the CI, this also could use a quick test to ensure that creating a variable with a field returns the correct information. You should be able to pretty much copy the placeholder test:
datafusion/datafusion/expr/src/expr_schema.rs
Lines 920 to 941 in e4f2b49
paleolimbot
commented
Dec 1, 2025
Thank you for writing the test! This seems reasonable to me although it needs CI to run to make sure 🙂. @alamb Can you hit the button to run CI here? |
paleolimbot
commented
Dec 1, 2025
@batmnnn I see I think the suggestion |
batmnnn
commented
Dec 1, 2025
@paleolimbot sorry my bad, can you check now :) |
batmnnn
commented
Dec 3, 2025
alamb
commented
Dec 3, 2025
I pushed some commits to this PR to help get the CI fixed. |
alamb
left a comment
There was a problem hiding this comment.
Makes sense to me -- thanks @batmnnn and @paleolimbot
I think it would be nice to add a note to the upgrading https://datafusion.apache.org/library-user-guide/upgrading.html
That helps people upgrade -- namely
paleolimbot
commented
Dec 3, 2025
I can add this to #18136 since it's related (two DataTypes became FieldRefs) |
alamb
commented
Dec 9, 2025
Thanks again @batmnnn and @paleolimbot |
Uh oh!
There was an error while loading. Please reload this page.
batmnnn
commented
Dec 9, 2025
thank you @paleolimbot and @alamb for all the guidance and help through this |
Which issue does this PR close?
Rationale for this change
Add richer variable metadata by switching Expr::ScalarVariable to store an Arrow Field, allowing planners to retain nullability and metadata when handling @var expressions.
What changes are included in this PR?
This PR updates ScalarVariable to use FieldRef so it can represent extension types and metadata in logical expressions.
Are these changes tested?
Yes
Are there any user-facing changes?
When planning queries with variables (e.g., @foo), the resulting logical expressions carry full field metadata instead of only a data type. This can affect downstream components that inspect nullability or custom metadata.