-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix: preserve expression names when replacing placeholders #12126
Conversation
|
||
// Test issue: https://github.com/apache/datafusion/issues/12065 | ||
#[tokio::test] | ||
async fn filtered_aggr_with_param_values() -> Result<()> { |
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 test on the main branch gave the following error
Error: Context("type_coercion", SchemaError(FieldNotFound { field:
Column { relation: None, name: "count(table1.c2) FILTER (WHERE table1.c3 > $1)" },
valid_fields: [
Column { relation: None, name: "count(table1.c2) FILTER (WHERE table1.c3 > UInt64(10))" }
] }, Some("")))
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.
@@ -28,6 +28,10 @@ use datafusion_expr::{logical_plan::LogicalPlan, Expr, Operator}; | |||
|
|||
use log::{debug, trace}; | |||
|
|||
/// Re-export of `NamesPreserver` for backwards compatibility, | |||
/// as it was initially placed here and then moved elsewhere. |
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.
👍
@@ -279,6 +279,57 @@ where | |||
expr.alias_if_changed(original_name) | |||
} | |||
|
|||
/// Handles ensuring the name of rewritten expressions is not changed. |
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.
FYI @findepi here is an example of using Expr::Alias as described in #1468 (comment)
Thanks again @jonahgao |
Which issue does this PR close?
Closes #12065.
Rationale for this change
When replacing placeholders with literal values, the names of the expressions might change, but there are references to the old names in the parent plan.
What changes are included in this PR?
NamePreserver
todatafusion-expr
package because it is needed there.Are these changes tested?
Yes
Are there any user-facing changes?
After replacing the parameters, the logical plan might differ from before because aliases have been added.