Skip to content

Conversation

@adriangb
Copy link
Contributor

@adriangb adriangb commented Dec 29, 2025

Closes #19387

The idea is to elevate the existing concept of a "trivial" expression from hardcoded in various places around the codebase to dynamically definable by expressions / functions. By default columns, literals and field accessor functions are considered trivial, but users can define their own (e.g. for variant).

This solves #19387 because then field accessors are treated the same as columns and thus get pushed down through projections, with the caveat of #19550

@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates optimizer Optimizer rules common Related to common crate functions Changes to functions implementation physical-plan Changes to the physical-plan crate labels Dec 29, 2025
@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Dec 29, 2025
@adriangb adriangb force-pushed the column-path-functions branch from 85890ee to aab1d3a Compare December 31, 2025 04:08
Comment on lines -594 to -597
// Check whether `expr` is trivial; i.e. it doesn't imply any computation.
fn is_expr_trivial(expr: &Expr) -> bool {
matches!(expr, Expr::Column(_) | Expr::Literal(_, _))
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As evidenced by the existing functions for both logical and physical expressions this was already a concept and implementation within the codebase, so all this PR is really doing is allowing arbitrary functions / expressions to declare themselves as trivial.

@github-actions github-actions bot added the core Core DataFusion crate label Dec 31, 2025
@adriangb adriangb marked this pull request as ready for review December 31, 2025 06:22
@adriangb adriangb requested a review from alamb December 31, 2025 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate core Core DataFusion crate functions Changes to functions implementation logical-expr Logical plan and expressions optimizer Optimizer rules physical-expr Changes to the physical-expr crates physical-plan Changes to the physical-plan crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Projection pushdown for column narrowing expressions

1 participant