Skip to content

Conversation

@batmnnn
Copy link

@batmnnn batmnnn commented Oct 23, 2025

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.

@github-actions github-actions bot added sql SQL Planner logical-expr Logical plan and expressions labels Oct 23, 2025
@github-actions github-actions bot added the core Core DataFusion crate label Oct 23, 2025
@batmnnn
Copy link
Author

batmnnn commented Oct 23, 2025

@paleolimbot can you review this sire

Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🙂

@alamb
Copy link
Contributor

alamb commented Oct 29, 2025

@batmnnn thank you for this PR. Do you have time to address @paleolimbot 's comments on this PR?

@github-actions github-actions bot removed the core Core DataFusion crate label Oct 29, 2025
@batmnnn
Copy link
Author

batmnnn commented Oct 29, 2025

@alamb sorry for the delay got caught up in exams, just addressed them.

Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

This needs a committer to run CI...provided it's green, this looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-expr Logical plan and expressions sql SQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logical expression ScalarVariable cannot represent an extension type or metadata

3 participants