Skip to content

Apache DataFusion SQL Query Engine

feat: analyze/optimize plan in `CREATE TABLE AS SELECT` (#6610)

jakevin95c4681baf2a
diff --git a/datafusion/core/src/execution/context.rs b/datafusion/core/src/execution/context.rs
index 7f74e28511..22e6ca42ee 100644
--- a/datafusion/core/src/execution/context.rs
+++ b/datafusion/core/src/execution/context.rs
@@ -495,6 +495,7 @@ impl SessionContext {
}
let input = Arc::try_unwrap(input).unwrap_or_else(|e| e.as_ref().clone());
+ let input = self.state().optimize(&input)?;
let table = self.table(&name).await;
match (if_not_exists, or_replace, table) {
diff --git a/datafusion/core/tests/sqllogictests/test_files/groupby.slt b/datafusion/core/tests/sqllogictests/test_files/groupby.slt
index 9868e684ca..ca400e0ef4 100644
--- a/datafusion/core/tests/sqllogictests/test_files/groupby.slt
+++ b/datafusion/core/tests/sqllogictests/test_files/groupby.slt
@@ -2351,7 +2351,7 @@ GRC [80.0, 30.0] 110
TUR [100.0, 75.0] 175
# test_ordering_sensitive_aggregation7
-# Lexicographical ordering requirement can be given as
+# Lexicographical ordering requirement can be given as
# argument to the aggregate functions
query TT
EXPLAIN SELECT s.country, ARRAY_AGG(s.amount ORDER BY s.country DESC, s.amount DESC) AS amounts,