Skip to content

Commit 14d75b7

Browse files
committed
revert: from_plan keep same schema Agg/Window in #6820
1 parent a08ea21 commit 14d75b7

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

datafusion/core/tests/sqllogictests/test_files/pg_compat/pg_compat_null.slt

+6-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ WITH HEADER ROW
7070
LOCATION '../../testing/data/csv/aggregate_test_100.csv'
7171

7272

73-
statement error DataFusion error: Error during planning: Mismatch between schema and batches
73+
statement ok
7474
CREATE TABLE aggregate_test_100_nullable_by_sql AS
7575
SELECT
7676
*,
@@ -82,13 +82,15 @@ SELECT
8282
WHEN c3 % 3 != 0 THEN c9
8383
ELSE NULL
8484
END AS n9
85-
FROM aggregate_test_100_by_sql;
85+
FROM aggregate_test_100_by_sql
8686

8787

88-
query error DataFusion error: Error during planning: table 'datafusion\.public\.aggregate_test_100_nullable_by_sql' not found
88+
query III
8989
SELECT
9090
COUNT(*), COUNT(n5), COUNT(n9)
9191
FROM aggregate_test_100_nullable_by_sql
92+
----
93+
100 66 72
9294

9395

9496
########
@@ -97,5 +99,5 @@ FROM aggregate_test_100_nullable_by_sql
9799
statement ok
98100
DROP TABLE aggregate_test_100_by_sql
99101

100-
statement error DataFusion error: Execution error: Table 'aggregate_test_100_nullable_by_sql' doesn't exist\.
102+
statement ok
101103
DROP TABLE aggregate_test_100_nullable_by_sql

datafusion/expr/src/utils.rs

+17-13
Original file line numberDiff line numberDiff line change
@@ -821,19 +821,23 @@ pub fn from_plan(
821821
input: Arc::new(inputs[0].clone()),
822822
})),
823823
},
824-
LogicalPlan::Window(Window { window_expr, .. }) => {
825-
Ok(LogicalPlan::Window(Window::try_new(
826-
expr[0..window_expr.len()].to_vec(),
827-
Arc::new(inputs[0].clone()),
828-
)?))
829-
}
830-
LogicalPlan::Aggregate(Aggregate { group_expr, .. }) => {
831-
Ok(LogicalPlan::Aggregate(Aggregate::try_new(
832-
Arc::new(inputs[0].clone()),
833-
expr[0..group_expr.len()].to_vec(),
834-
expr[group_expr.len()..].to_vec(),
835-
)?))
836-
}
824+
LogicalPlan::Window(Window {
825+
window_expr,
826+
schema,
827+
..
828+
}) => Ok(LogicalPlan::Window(Window {
829+
input: Arc::new(inputs[0].clone()),
830+
window_expr: expr[0..window_expr.len()].to_vec(),
831+
schema: schema.clone(),
832+
})),
833+
LogicalPlan::Aggregate(Aggregate {
834+
group_expr, schema, ..
835+
}) => Ok(LogicalPlan::Aggregate(Aggregate::try_new_with_schema(
836+
Arc::new(inputs[0].clone()),
837+
expr[0..group_expr.len()].to_vec(),
838+
expr[group_expr.len()..].to_vec(),
839+
schema.clone(),
840+
)?)),
837841
LogicalPlan::Sort(SortPlan { fetch, .. }) => Ok(LogicalPlan::Sort(SortPlan {
838842
expr: expr.to_vec(),
839843
input: Arc::new(inputs[0].clone()),

0 commit comments

Comments
 (0)