Skip to content
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 "Projection references non-aggregate values" by updating rebase_expr to use transform_down #8890

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datafusion/sql/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub(crate) fn rebase_expr(
base_exprs: &[Expr],
plan: &LogicalPlan,
) -> Result<Expr> {
expr.clone().transform_up(&|nested_expr| {
expr.clone().transform_down(&|nested_expr| {
if base_exprs.contains(&nested_expr) {
Ok(Transformed::Yes(expr_as_column_expr(&nested_expr, plan)?))
} else {
Expand Down
7 changes: 6 additions & 1 deletion datafusion/sqllogictest/test_files/group_by.slt
Original file line number Diff line number Diff line change
Expand Up @@ -4853,4 +4853,9 @@ statement error DataFusion error: This feature is not implemented: Conflicting o
SELECT a, b, NTH_VALUE(c, 2 ORDER BY c ASC), NTH_VALUE(c, 3 ORDER BY d ASC)
FROM multiple_ordered_table
GROUP BY a, b
ORDER BY a, b;
ORDER BY a, b;

query II
SELECT a + 1 AS d, a + 1 + b AS c FROM (SELECT 1 AS a, 2 AS b) GROUP BY a + 1, a + 1 + b;
----
2 4
Loading