Skip to content

Conversation

joroKr21
Copy link
Contributor

@joroKr21 joroKr21 commented Feb 17, 2025

Not sure why they are not supported. It seems that if we're not careful, some transformations can introduce aliases nested inside other expressions.

Which issue does this PR close?

Didn't create an issue, because it's more of an internal change and mostly relevant when using DataFusion as a library.

Rationale for this change

Having Expr::Alias as part of the expression AST is a trade-off. It makes the AST uniform and simpler but it allows representing trees that are not really valid SQL such as having aliases nested in function arguments and generally makes them legal in any position of the AST. Therefore I think it would be a desirable property if all transformations can handle aliases wherever they appear.

What changes are included in this PR?

Simply changing the can_evaluate predicate is enough, alias expressions can already be evaluated.

Are these changes tested?

Yes, added a unit test and a couple explain tests had to be updated (I think the output makes more sense now).

Are there any user-facing changes?

No breaking changes or end-user visible changes. For users that use DataFusion as a library, more expressions can be constant-folded.

@github-actions github-actions bot added the optimizer Optimizer rules label Feb 17, 2025
@github-actions github-actions bot added the core Core DataFusion crate label Feb 18, 2025
@joroKr21 joroKr21 force-pushed the const-eval-alias branch 2 times, most recently from 356deb7 to f8fd349 Compare February 18, 2025 09:35
@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Feb 18, 2025
Not sure why they are not supported. It seems that if we're not careful,
some transformations can introduce aliases nested inside other expressions.
@joroKr21 joroKr21 marked this pull request as ready for review February 18, 2025 11:37
Copy link
Contributor

@jayzhan211 jayzhan211 left a comment

Choose a reason for hiding this comment

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

👍🏻

@jayzhan211 jayzhan211 merged commit c176533 into apache:main Feb 19, 2025
25 checks passed
@jayzhan211
Copy link
Contributor

Thanks @joroKr21 @Dandandan

@joroKr21 joroKr21 deleted the const-eval-alias branch February 19, 2025 06:16
joroKr21 added a commit to coralogix/arrow-datafusion that referenced this pull request Feb 19, 2025
Not sure why they are not supported. It seems that if we're not careful,
some transformations can introduce aliases nested inside other expressions.
joroKr21 added a commit to coralogix/arrow-datafusion that referenced this pull request Feb 19, 2025
Not sure why they are not supported. It seems that if we're not careful,
some transformations can introduce aliases nested inside other expressions.
joroKr21 added a commit to coralogix/arrow-datafusion that referenced this pull request Feb 19, 2025
Not sure why they are not supported. It seems that if we're not careful,
some transformations can introduce aliases nested inside other expressions.
joroKr21 added a commit to coralogix/arrow-datafusion that referenced this pull request Feb 20, 2025
Not sure why they are not supported. It seems that if we're not careful,
some transformations can introduce aliases nested inside other expressions.
joroKr21 added a commit to coralogix/arrow-datafusion that referenced this pull request Feb 20, 2025
* Support aliases in ConstEvaluator (apache#14734)

Not sure why they are not supported. It seems that if we're not careful,
some transformations can introduce aliases nested inside other expressions.

* Format Cargo.toml
avantgardnerio pushed a commit to coralogix/arrow-datafusion that referenced this pull request Sep 22, 2025
* Support aliases in ConstEvaluator (apache#14734)

Not sure why they are not supported. It seems that if we're not careful,
some transformations can introduce aliases nested inside other expressions.

* Format Cargo.toml
avantgardnerio pushed a commit to coralogix/arrow-datafusion that referenced this pull request Oct 1, 2025
* Support aliases in ConstEvaluator (apache#14734)

Not sure why they are not supported. It seems that if we're not careful,
some transformations can introduce aliases nested inside other expressions.

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

Labels

core Core DataFusion crate optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants