diff --git a/datafusion/core/tests/dataframe/dataframe_functions.rs b/datafusion/core/tests/dataframe/dataframe_functions.rs index b664fccdfa80..559c9433b90e 100644 --- a/datafusion/core/tests/dataframe/dataframe_functions.rs +++ b/datafusion/core/tests/dataframe/dataframe_functions.rs @@ -1310,8 +1310,8 @@ async fn test_count_wildcard() -> Result<()> { @r" Sort: count(*) ASC NULLS LAST [count(*):Int64] Projection: count(*) [count(*):Int64] - Aggregate: groupBy=[[test.b]], aggr=[[count(Int64(1)) AS count(*)]] [b:UInt32, count(*):Int64] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Aggregate: groupBy=[[test.b]], aggr=[[count(Int64(1)) AS count(*)]] [test.b:UInt32, count(*):Int64] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] "); Ok(()) diff --git a/datafusion/core/tests/dataframe/mod.rs b/datafusion/core/tests/dataframe/mod.rs index aa984775e457..6ba0e676c9d3 100644 --- a/datafusion/core/tests/dataframe/mod.rs +++ b/datafusion/core/tests/dataframe/mod.rs @@ -1863,7 +1863,7 @@ async fn with_column_renamed_join() -> Result<()> { assert_snapshot!( df_renamed.logical_plan(), @r" - Projection: t1.c1 AS AAA, t1.c2, t1.c3, t2.c1, t2.c2, t2.c3 + Projection: t1.c1 AS t1.AAA, t1.c2, t1.c3, t2.c1, t2.c2, t2.c3 Limit: skip=0, fetch=1 Sort: t1.c1 ASC NULLS FIRST, t1.c2 ASC NULLS FIRST, t1.c3 ASC NULLS FIRST, t2.c1 ASC NULLS FIRST, t2.c2 ASC NULLS FIRST, t2.c3 ASC NULLS FIRST Inner Join: t1.c1 = t2.c1 @@ -1878,15 +1878,15 @@ async fn with_column_renamed_join() -> Result<()> { assert_snapshot!( df_renamed.clone().into_optimized_plan().unwrap(), - @r###" - Projection: t1.c1 AS AAA, t1.c2, t1.c3, t2.c1, t2.c2, t2.c3 + @r" + Projection: t1.c1 AS t1.AAA, t1.c2, t1.c3, t2.c1, t2.c2, t2.c3 Sort: t1.c1 ASC NULLS FIRST, t1.c2 ASC NULLS FIRST, t1.c3 ASC NULLS FIRST, t2.c1 ASC NULLS FIRST, t2.c2 ASC NULLS FIRST, t2.c3 ASC NULLS FIRST, fetch=1 Inner Join: t1.c1 = t2.c1 SubqueryAlias: t1 TableScan: aggregate_test_100 projection=[c1, c2, c3] SubqueryAlias: t2 TableScan: aggregate_test_100 projection=[c1, c2, c3] - "### + " ); let df_results = df_renamed.collect().await?; @@ -3606,12 +3606,12 @@ async fn join_with_alias_filter() -> Result<()> { let actual = formatted.trim(); assert_snapshot!( actual, - @r###" - Projection: t1.a, t2.a, t1.b, t1.c, t2.b, t2.c [a:UInt32, a:UInt32, b:Utf8, c:Int32, b:Utf8, c:Int32] - Inner Join: t1.a + UInt32(3) = t2.a + UInt32(1) [a:UInt32, b:Utf8, c:Int32, a:UInt32, b:Utf8, c:Int32] - TableScan: t1 projection=[a, b, c] [a:UInt32, b:Utf8, c:Int32] - TableScan: t2 projection=[a, b, c] [a:UInt32, b:Utf8, c:Int32] - "### + @r" + Projection: t1.a, t2.a, t1.b, t1.c, t2.b, t2.c [t1.a:UInt32, t2.a:UInt32, t1.b:Utf8, t1.c:Int32, t2.b:Utf8, t2.c:Int32] + Inner Join: t1.a + UInt32(3) = t2.a + UInt32(1) [t1.a:UInt32, t1.b:Utf8, t1.c:Int32, t2.a:UInt32, t2.b:Utf8, t2.c:Int32] + TableScan: t1 projection=[a, b, c] [t1.a:UInt32, t1.b:Utf8, t1.c:Int32] + TableScan: t2 projection=[a, b, c] [t2.a:UInt32, t2.b:Utf8, t2.c:Int32] + " ); let results = df.collect().await?; @@ -3651,14 +3651,14 @@ async fn right_semi_with_alias_filter() -> Result<()> { let actual = formatted.trim(); assert_snapshot!( actual, - @r###" - RightSemi Join: t1.a = t2.a [a:UInt32, b:Utf8, c:Int32] - Projection: t1.a [a:UInt32] - Filter: t1.c > Int32(1) [a:UInt32, c:Int32] - TableScan: t1 projection=[a, c] [a:UInt32, c:Int32] - Filter: t2.c > Int32(1) [a:UInt32, b:Utf8, c:Int32] - TableScan: t2 projection=[a, b, c] [a:UInt32, b:Utf8, c:Int32] - "### + @r" + RightSemi Join: t1.a = t2.a [t2.a:UInt32, t2.b:Utf8, t2.c:Int32] + Projection: t1.a [t1.a:UInt32] + Filter: t1.c > Int32(1) [t1.a:UInt32, t1.c:Int32] + TableScan: t1 projection=[a, c] [t1.a:UInt32, t1.c:Int32] + Filter: t2.c > Int32(1) [t2.a:UInt32, t2.b:Utf8, t2.c:Int32] + TableScan: t2 projection=[a, b, c] [t2.a:UInt32, t2.b:Utf8, t2.c:Int32] + " ); let results = df.collect().await?; @@ -3698,13 +3698,13 @@ async fn right_anti_filter_push_down() -> Result<()> { let actual = formatted.trim(); assert_snapshot!( actual, - @r###" - RightAnti Join: t1.a = t2.a Filter: t2.c > Int32(1) [a:UInt32, b:Utf8, c:Int32] - Projection: t1.a [a:UInt32] - Filter: t1.c > Int32(1) [a:UInt32, c:Int32] - TableScan: t1 projection=[a, c] [a:UInt32, c:Int32] - TableScan: t2 projection=[a, b, c] [a:UInt32, b:Utf8, c:Int32] - "### + @r" + RightAnti Join: t1.a = t2.a Filter: t2.c > Int32(1) [t2.a:UInt32, t2.b:Utf8, t2.c:Int32] + Projection: t1.a [t1.a:UInt32] + Filter: t1.c > Int32(1) [t1.a:UInt32, t1.c:Int32] + TableScan: t1 projection=[a, c] [t1.a:UInt32, t1.c:Int32] + TableScan: t2 projection=[a, b, c] [t2.a:UInt32, t2.b:Utf8, t2.c:Int32] + " ); let results = df.collect().await?; @@ -4382,12 +4382,12 @@ async fn unnest_with_redundant_columns() -> Result<()> { let actual = formatted.trim(); assert_snapshot!( actual, - @r###" - Projection: shapes.shape_id [shape_id:UInt32] - Unnest: lists[shape_id2|depth=1] structs[] [shape_id:UInt32, shape_id2:UInt32;N] - Aggregate: groupBy=[[shapes.shape_id]], aggr=[[array_agg(shapes.shape_id) AS shape_id2]] [shape_id:UInt32, shape_id2:List(Field { name: "item", data_type: UInt32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} });N] - TableScan: shapes projection=[shape_id] [shape_id:UInt32] - "### + @r#" + Projection: shapes.shape_id [shapes.shape_id:UInt32] + Unnest: lists[shape_id2|depth=1] structs[] [shapes.shape_id:UInt32, shape_id2:UInt32;N] + Aggregate: groupBy=[[shapes.shape_id]], aggr=[[array_agg(shapes.shape_id) AS shape_id2]] [shapes.shape_id:UInt32, shape_id2:List(Field { name: "item", data_type: UInt32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} });N] + TableScan: shapes projection=[shape_id] [shapes.shape_id:UInt32] + "# ); let results = df.collect().await?; @@ -5748,11 +5748,11 @@ async fn test_alias() -> Result<()> { .into_unoptimized_plan() .display_indent_schema() .to_string(); - assert_snapshot!(plan, @r###" - SubqueryAlias: table_alias [a:Utf8, b:Int32, one:Int32] - Projection: test.a, test.b, Int32(1) AS one [a:Utf8, b:Int32, one:Int32] - TableScan: test [a:Utf8, b:Int32] - "###); + assert_snapshot!(plan, @r" + SubqueryAlias: table_alias [table_alias.a:Utf8, table_alias.b:Int32, table_alias.one:Int32] + Projection: test.a, test.b, Int32(1) AS one [test.a:Utf8, test.b:Int32, one:Int32] + TableScan: test [test.a:Utf8, test.b:Int32] + "); // Select over the aliased DataFrame let df = df.select(vec![ @@ -5822,10 +5822,10 @@ async fn test_alias_empty() -> Result<()> { .into_unoptimized_plan() .display_indent_schema() .to_string(); - assert_snapshot!(plan, @r###" - SubqueryAlias: [a:Utf8, b:Int32] - TableScan: test [a:Utf8, b:Int32] - "###); + assert_snapshot!(plan, @r" + SubqueryAlias: [.a:Utf8, .b:Int32] + TableScan: test [test.a:Utf8, test.b:Int32] + "); assert_snapshot!( batches_to_sort_string(&df.select(vec![col("a"), col("b")])?.collect().await.unwrap()), @@ -5857,12 +5857,12 @@ async fn test_alias_nested() -> Result<()> { .into_optimized_plan()? .display_indent_schema() .to_string(); - assert_snapshot!(plan, @r###" - SubqueryAlias: alias2 [a:Utf8, b:Int32, one:Int32] - SubqueryAlias: alias1 [a:Utf8, b:Int32, one:Int32] - Projection: test.a, test.b, Int32(1) AS one [a:Utf8, b:Int32, one:Int32] - TableScan: test projection=[a, b] [a:Utf8, b:Int32] - "###); + assert_snapshot!(plan, @r" + SubqueryAlias: alias2 [alias2.a:Utf8, alias2.b:Int32, alias2.one:Int32] + SubqueryAlias: alias1 [alias1.a:Utf8, alias1.b:Int32, alias1.one:Int32] + Projection: test.a, test.b, Int32(1) AS one [test.a:Utf8, test.b:Int32, one:Int32] + TableScan: test projection=[a, b] [test.a:Utf8, test.b:Int32] + "); // Select over the aliased DataFrame let select1 = df diff --git a/datafusion/core/tests/sql/explain_analyze.rs b/datafusion/core/tests/sql/explain_analyze.rs index 852b350b27df..b9cc988df0b6 100644 --- a/datafusion/core/tests/sql/explain_analyze.rs +++ b/datafusion/core/tests/sql/explain_analyze.rs @@ -182,9 +182,9 @@ async fn csv_explain_plans() { actual, @r" Explain [plan_type:Utf8, plan:Utf8] - Projection: aggregate_test_100.c1 [c1:Utf8View] - Filter: aggregate_test_100.c2 > Int64(10) [c1:Utf8View, c2:Int8, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:UInt32, c10:UInt64, c11:Float32, c12:Float64, c13:Utf8View] - TableScan: aggregate_test_100 [c1:Utf8View, c2:Int8, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:UInt32, c10:UInt64, c11:Float32, c12:Float64, c13:Utf8View] + Projection: aggregate_test_100.c1 [aggregate_test_100.c1:Utf8View] + Filter: aggregate_test_100.c2 > Int64(10) [aggregate_test_100.c1:Utf8View, aggregate_test_100.c2:Int8, aggregate_test_100.c3:Int16, aggregate_test_100.c4:Int16, aggregate_test_100.c5:Int32, aggregate_test_100.c6:Int64, aggregate_test_100.c7:Int16, aggregate_test_100.c8:Int32, aggregate_test_100.c9:UInt32, aggregate_test_100.c10:UInt64, aggregate_test_100.c11:Float32, aggregate_test_100.c12:Float64, aggregate_test_100.c13:Utf8View] + TableScan: aggregate_test_100 [aggregate_test_100.c1:Utf8View, aggregate_test_100.c2:Int8, aggregate_test_100.c3:Int16, aggregate_test_100.c4:Int16, aggregate_test_100.c5:Int32, aggregate_test_100.c6:Int64, aggregate_test_100.c7:Int16, aggregate_test_100.c8:Int32, aggregate_test_100.c9:UInt32, aggregate_test_100.c10:UInt64, aggregate_test_100.c11:Float32, aggregate_test_100.c12:Float64, aggregate_test_100.c13:Utf8View] " ); // @@ -253,9 +253,9 @@ async fn csv_explain_plans() { actual, @r" Explain [plan_type:Utf8, plan:Utf8] - Projection: aggregate_test_100.c1 [c1:Utf8View] - Filter: aggregate_test_100.c2 > Int8(10) [c1:Utf8View, c2:Int8] - TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[aggregate_test_100.c2 > Int8(10)] [c1:Utf8View, c2:Int8] + Projection: aggregate_test_100.c1 [aggregate_test_100.c1:Utf8View] + Filter: aggregate_test_100.c2 > Int8(10) [aggregate_test_100.c1:Utf8View, aggregate_test_100.c2:Int8] + TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[aggregate_test_100.c2 > Int8(10)] [aggregate_test_100.c1:Utf8View, aggregate_test_100.c2:Int8] " ); // @@ -399,9 +399,9 @@ async fn csv_explain_verbose_plans() { actual, @r" Explain [plan_type:Utf8, plan:Utf8] - Projection: aggregate_test_100.c1 [c1:Utf8View] - Filter: aggregate_test_100.c2 > Int64(10) [c1:Utf8View, c2:Int8, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:UInt32, c10:UInt64, c11:Float32, c12:Float64, c13:Utf8View] - TableScan: aggregate_test_100 [c1:Utf8View, c2:Int8, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:UInt32, c10:UInt64, c11:Float32, c12:Float64, c13:Utf8View] + Projection: aggregate_test_100.c1 [aggregate_test_100.c1:Utf8View] + Filter: aggregate_test_100.c2 > Int64(10) [aggregate_test_100.c1:Utf8View, aggregate_test_100.c2:Int8, aggregate_test_100.c3:Int16, aggregate_test_100.c4:Int16, aggregate_test_100.c5:Int32, aggregate_test_100.c6:Int64, aggregate_test_100.c7:Int16, aggregate_test_100.c8:Int32, aggregate_test_100.c9:UInt32, aggregate_test_100.c10:UInt64, aggregate_test_100.c11:Float32, aggregate_test_100.c12:Float64, aggregate_test_100.c13:Utf8View] + TableScan: aggregate_test_100 [aggregate_test_100.c1:Utf8View, aggregate_test_100.c2:Int8, aggregate_test_100.c3:Int16, aggregate_test_100.c4:Int16, aggregate_test_100.c5:Int32, aggregate_test_100.c6:Int64, aggregate_test_100.c7:Int16, aggregate_test_100.c8:Int32, aggregate_test_100.c9:UInt32, aggregate_test_100.c10:UInt64, aggregate_test_100.c11:Float32, aggregate_test_100.c12:Float64, aggregate_test_100.c13:Utf8View] " ); // @@ -470,9 +470,9 @@ async fn csv_explain_verbose_plans() { actual, @r" Explain [plan_type:Utf8, plan:Utf8] - Projection: aggregate_test_100.c1 [c1:Utf8View] - Filter: aggregate_test_100.c2 > Int8(10) [c1:Utf8View, c2:Int8] - TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[aggregate_test_100.c2 > Int8(10)] [c1:Utf8View, c2:Int8] + Projection: aggregate_test_100.c1 [aggregate_test_100.c1:Utf8View] + Filter: aggregate_test_100.c2 > Int8(10) [aggregate_test_100.c1:Utf8View, aggregate_test_100.c2:Int8] + TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[aggregate_test_100.c2 > Int8(10)] [aggregate_test_100.c1:Utf8View, aggregate_test_100.c2:Int8] " ); // diff --git a/datafusion/expr/src/expr.rs b/datafusion/expr/src/expr.rs index 406a1abe42b9..d3b4234be020 100644 --- a/datafusion/expr/src/expr.rs +++ b/datafusion/expr/src/expr.rs @@ -3456,7 +3456,15 @@ pub const UNNEST_COLUMN_PREFIX: &str = "UNNEST"; impl Display for Expr { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match self { - Expr::Alias(Alias { expr, name, .. }) => write!(f, "{expr} AS {name}"), + Expr::Alias(Alias { + expr, + relation, + name, + .. + }) => match relation { + None => write!(f, "{expr} AS {name}"), + Some(relation) => write!(f, "{expr} AS {relation}.{name}"), + }, Expr::Column(c) => write!(f, "{c}"), Expr::OuterReferenceColumn(_, c) => { write!(f, "{OUTER_REFERENCE_COLUMN_PREFIX}({c})") diff --git a/datafusion/expr/src/logical_plan/display.rs b/datafusion/expr/src/logical_plan/display.rs index cc3fbad7b0c2..88e993f2b773 100644 --- a/datafusion/expr/src/logical_plan/display.rs +++ b/datafusion/expr/src/logical_plan/display.rs @@ -31,7 +31,7 @@ use crate::dml::CopyTo; use arrow::datatypes::Schema; use datafusion_common::display::GraphvizBuilder; use datafusion_common::tree_node::{TreeNodeRecursion, TreeNodeVisitor}; -use datafusion_common::{Column, DataFusionError}; +use datafusion_common::{Column, DFSchema, DataFusionError}; use serde_json::json; /// Formats plans with a single line per node. For example: @@ -72,11 +72,7 @@ impl<'n> TreeNodeVisitor<'n> for IndentVisitor<'_, '_> { write!(self.f, "{:indent$}", "", indent = self.indent * 2)?; write!(self.f, "{}", plan.display())?; if self.with_schema { - write!( - self.f, - " {}", - display_schema(&plan.schema().as_ref().to_owned().into()) - )?; + write!(self.f, " {}", display_df_schema(plan.schema().as_ref()))?; } self.indent += 1; @@ -92,7 +88,7 @@ impl<'n> TreeNodeVisitor<'n> for IndentVisitor<'_, '_> { } } -/// Print the schema in a compact representation to `buf` +/// Print the schema in a compact representation /// /// For example: `foo:Utf8` if `foo` can not be null, and /// `foo:Utf8;N` if `foo` is nullable. @@ -135,6 +131,38 @@ pub fn display_schema(schema: &Schema) -> impl fmt::Display + '_ { Wrapper(schema) } +/// Print the schema in a compact representation. +/// Similar to `display_schema`, but includes field qualifiers if any. +pub fn display_df_schema(schema: &DFSchema) -> impl fmt::Display + '_ { + struct Wrapper<'a>(&'a DFSchema); + + impl fmt::Display for Wrapper<'_> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "[")?; + for (idx, (qualifier, field)) in self.0.iter().enumerate() { + if idx > 0 { + write!(f, ", ")?; + } + let nullable_str = if field.is_nullable() { ";N" } else { "" }; + write!( + f, + "{}{}:{:?}{}", + if let Some(q) = qualifier { + format!("{q}.") + } else { + "".to_string() + }, + field.name(), + field.data_type(), + nullable_str + )?; + } + write!(f, "]") + } + } + Wrapper(schema) +} + /// Formats plans for graphical display using the `DOT` language. This /// format can be visualized using software from /// [`graphviz`](https://graphviz.org/) diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs index c271e48a01f7..025390c5a46e 100644 --- a/datafusion/expr/src/logical_plan/plan.rs +++ b/datafusion/expr/src/logical_plan/plan.rs @@ -1595,8 +1595,8 @@ impl LogicalPlan { /// // Format using display_indent_schema /// let display_string = format!("{}", plan.display_indent_schema()); /// - /// assert_eq!("Filter: t1.id = Int32(5) [id:Int32]\ - /// \n TableScan: t1 [id:Int32]", + /// assert_eq!("Filter: t1.id = Int32(5) [t1.id:Int32]\ + /// \n TableScan: t1 [t1.id:Int32]", /// display_string); /// ``` pub fn display_indent_schema(&self) -> impl Display + '_ { @@ -4270,11 +4270,11 @@ mod tests { let plan = display_plan()?; assert_snapshot!(plan.display_indent_schema(), @r" - Projection: employee_csv.id [id:Int32] - Filter: employee_csv.state IN () [id:Int32, state:Utf8] - Subquery: [state:Utf8] - TableScan: employee_csv projection=[state] [state:Utf8] - TableScan: employee_csv projection=[id, state] [id:Int32, state:Utf8] + Projection: employee_csv.id [employee_csv.id:Int32] + Filter: employee_csv.state IN () [employee_csv.id:Int32, employee_csv.state:Utf8] + Subquery: [employee_csv.state:Utf8] + TableScan: employee_csv projection=[state] [employee_csv.state:Utf8] + TableScan: employee_csv projection=[id, state] [employee_csv.id:Int32, employee_csv.state:Utf8] "); Ok(()) } diff --git a/datafusion/optimizer/src/decorrelate_predicate_subquery.rs b/datafusion/optimizer/src/decorrelate_predicate_subquery.rs index a72657bf689d..42b2df9e84a3 100644 --- a/datafusion/optimizer/src/decorrelate_predicate_subquery.rs +++ b/datafusion/optimizer/src/decorrelate_predicate_subquery.rs @@ -470,16 +470,16 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: test.b = __correlated_sq_2.c [a:UInt32, b:UInt32, c:UInt32] - LeftSemi Join: Filter: test.c = __correlated_sq_1.c [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32] - Projection: sq_1.c [c:UInt32] - TableScan: sq_1 [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_2 [c:UInt32] - Projection: sq_2.c [c:UInt32] - TableScan: sq_2 [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: test.b = __correlated_sq_2.c [test.a:UInt32, test.b:UInt32, test.c:UInt32] + LeftSemi Join: Filter: test.c = __correlated_sq_1.c [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32] + Projection: sq_1.c [sq_1.c:UInt32] + TableScan: sq_1 [sq_1.a:UInt32, sq_1.b:UInt32, sq_1.c:UInt32] + SubqueryAlias: __correlated_sq_2 [__correlated_sq_2.c:UInt32] + Projection: sq_2.c [sq_2.c:UInt32] + TableScan: sq_2 [sq_2.a:UInt32, sq_2.b:UInt32, sq_2.c:UInt32] " ) } @@ -502,13 +502,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - Filter: test.a = UInt32(1) AND test.b < UInt32(30) [a:UInt32, b:UInt32, c:UInt32] - LeftSemi Join: Filter: test.c = __correlated_sq_1.c [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32] - Projection: sq.c [c:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + Filter: test.a = UInt32(1) AND test.b < UInt32(30) [test.a:UInt32, test.b:UInt32, test.c:UInt32] + LeftSemi Join: Filter: test.c = __correlated_sq_1.c [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32] + Projection: sq.c [sq.c:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -531,16 +531,16 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: test.b = __correlated_sq_2.a [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_2 [a:UInt32] - Projection: sq.a [a:UInt32] - LeftSemi Join: Filter: sq.a = __correlated_sq_1.c [a:UInt32, b:UInt32, c:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32] - Projection: sq_nested.c [c:UInt32] - TableScan: sq_nested [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: test.b = __correlated_sq_2.a [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_2 [__correlated_sq_2.a:UInt32] + Projection: sq.a [sq.a:UInt32] + LeftSemi Join: Filter: sq.a = __correlated_sq_1.c [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32] + Projection: sq_nested.c [sq_nested.c:UInt32] + TableScan: sq_nested [sq_nested.a:UInt32, sq_nested.b:UInt32, sq_nested.c:UInt32] " ) } @@ -569,18 +569,18 @@ mod tests { assert_optimized_plan_equal!( plan, - @r###" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_2.o_custkey [c_custkey:Int64, c_name:Utf8] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - SubqueryAlias: __correlated_sq_2 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - "### + @r" + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_2.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + SubqueryAlias: __correlated_sq_2 [__correlated_sq_2.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + " ) } @@ -618,16 +618,16 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_2.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_2 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - LeftSemi Join: Filter: orders.o_orderkey = __correlated_sq_1.l_orderkey [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - SubqueryAlias: __correlated_sq_1 [l_orderkey:Int64] - Projection: lineitem.l_orderkey [l_orderkey:Int64] - TableScan: lineitem [l_orderkey:Int64, l_partkey:Int64, l_suppkey:Int64, l_linenumber:Int32, l_quantity:Float64, l_extendedprice:Float64] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_2.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_2 [__correlated_sq_2.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + LeftSemi Join: Filter: orders.o_orderkey = __correlated_sq_1.l_orderkey [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.l_orderkey:Int64] + Projection: lineitem.l_orderkey [lineitem.l_orderkey:Int64] + TableScan: lineitem [lineitem.l_orderkey:Int64, lineitem.l_partkey:Int64, lineitem.l_suppkey:Int64, lineitem.l_linenumber:Int32, lineitem.l_quantity:Float64, lineitem.l_extendedprice:Float64] " ) } @@ -654,13 +654,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - Filter: orders.o_orderkey = Int32(1) [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + Filter: orders.o_orderkey = Int32(1) [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -686,12 +686,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -714,13 +714,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - Filter: orders.o_custkey = orders.o_custkey [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + Filter: orders.o_custkey = orders.o_custkey [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -746,12 +746,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey AND customer.c_custkey != __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey AND customer.c_custkey != __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -777,12 +777,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey AND customer.c_custkey < __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey AND customer.c_custkey < __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -809,12 +809,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey AND (customer.c_custkey = __correlated_sq_1.o_custkey OR __correlated_sq_1.o_orderkey = Int32(1)) [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64, o_orderkey:Int64] - Projection: orders.o_custkey, orders.o_orderkey [o_custkey:Int64, o_orderkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey AND (customer.c_custkey = __correlated_sq_1.o_custkey OR __correlated_sq_1.o_orderkey = Int32(1)) [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64, __correlated_sq_1.o_orderkey:Int64] + Projection: orders.o_custkey, orders.o_orderkey [orders.o_custkey:Int64, orders.o_orderkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -863,12 +863,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey + Int32(1) = __correlated_sq_1.o_custkey AND customer.c_custkey = __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey + Int32(1) = __correlated_sq_1.o_custkey AND customer.c_custkey = __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -894,12 +894,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.orders.o_custkey + Int32(1) AND customer.c_custkey = __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [orders.o_custkey + Int32(1):Int64, o_custkey:Int64] - Projection: orders.o_custkey + Int32(1), orders.o_custkey [orders.o_custkey + Int32(1):Int64, o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.orders.o_custkey + Int32(1) AND customer.c_custkey = __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.orders.o_custkey + Int32(1):Int64, __correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey + Int32(1), orders.o_custkey [orders.o_custkey + Int32(1):Int64, orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -957,13 +957,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey = Int32(1) [c_custkey:Int64, c_name:Utf8] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey = Int32(1) [customer.c_custkey:Int64, customer.c_name:Utf8] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -986,12 +986,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: test.c = __correlated_sq_1.c AND test.a = __correlated_sq_1.a [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32, a:UInt32] - Projection: sq.c, sq.a [c:UInt32, a:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: test.c = __correlated_sq_1.c AND test.a = __correlated_sq_1.a [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32, __correlated_sq_1.a:UInt32] + Projection: sq.c, sq.a [sq.c:UInt32, sq.a:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1008,12 +1008,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: test.c = __correlated_sq_1.c [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32] - Projection: sq.c [c:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: test.c = __correlated_sq_1.c [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32] + Projection: sq.c [sq.c:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1030,12 +1030,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftAnti Join: Filter: test.c = __correlated_sq_1.c [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32] - Projection: sq.c [c:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftAnti Join: Filter: test.c = __correlated_sq_1.c [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32] + Projection: sq.c [sq.c:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1051,12 +1051,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftAnti Join: Filter: test.c = __correlated_sq_1.c [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32] - Projection: sq.c [c:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftAnti Join: Filter: test.c = __correlated_sq_1.c [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32] + Projection: sq.c [sq.c:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1075,12 +1075,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: test.c = __correlated_sq_1.c [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32] - Projection: sq.c [c:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: test.c = __correlated_sq_1.c [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32] + Projection: sq.c [sq.c:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1102,12 +1102,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: test.c + UInt32(1) = __correlated_sq_1.sq.c * UInt32(2) [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [sq.c * UInt32(2):UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: test.c + UInt32(1) = __correlated_sq_1.sq.c * UInt32(2) [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.sq.c * UInt32(2):UInt32] Projection: sq.c * UInt32(2) [sq.c * UInt32(2):UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1134,13 +1134,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: test.c + UInt32(1) = __correlated_sq_1.sq.c * UInt32(2) AND test.a = __correlated_sq_1.a [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [sq.c * UInt32(2):UInt32, a:UInt32] - Projection: sq.c * UInt32(2), sq.a [sq.c * UInt32(2):UInt32, a:UInt32] - Filter: sq.a + UInt32(1) = sq.b [a:UInt32, b:UInt32, c:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: test.c + UInt32(1) = __correlated_sq_1.sq.c * UInt32(2) AND test.a = __correlated_sq_1.a [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.sq.c * UInt32(2):UInt32, __correlated_sq_1.a:UInt32] + Projection: sq.c * UInt32(2), sq.a [sq.c * UInt32(2):UInt32, sq.a:UInt32] + Filter: sq.a + UInt32(1) = sq.b [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1168,13 +1168,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: test.c + UInt32(1) = __correlated_sq_1.sq.c * UInt32(2) AND test.a + test.b = __correlated_sq_1.a + __correlated_sq_1.b [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [sq.c * UInt32(2):UInt32, a:UInt32, b:UInt32] - Projection: sq.c * UInt32(2), sq.a, sq.b [sq.c * UInt32(2):UInt32, a:UInt32, b:UInt32] - Filter: sq.a + UInt32(1) = sq.b [a:UInt32, b:UInt32, c:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: test.c + UInt32(1) = __correlated_sq_1.sq.c * UInt32(2) AND test.a + test.b = __correlated_sq_1.a + __correlated_sq_1.b [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.sq.c * UInt32(2):UInt32, __correlated_sq_1.a:UInt32, __correlated_sq_1.b:UInt32] + Projection: sq.c * UInt32(2), sq.a, sq.b [sq.c * UInt32(2):UInt32, sq.a:UInt32, sq.b:UInt32] + Filter: sq.a + UInt32(1) = sq.b [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1208,17 +1208,17 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - Filter: test.c > UInt32(1) [a:UInt32, b:UInt32, c:UInt32] - LeftSemi Join: Filter: test.c * UInt32(2) = __correlated_sq_2.sq2.c * UInt32(2) AND test.a > __correlated_sq_2.a [a:UInt32, b:UInt32, c:UInt32] - LeftSemi Join: Filter: test.c + UInt32(1) = __correlated_sq_1.sq1.c * UInt32(2) AND test.a > __correlated_sq_1.a [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [sq1.c * UInt32(2):UInt32, a:UInt32] - Projection: sq1.c * UInt32(2), sq1.a [sq1.c * UInt32(2):UInt32, a:UInt32] - TableScan: sq1 [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_2 [sq2.c * UInt32(2):UInt32, a:UInt32] - Projection: sq2.c * UInt32(2), sq2.a [sq2.c * UInt32(2):UInt32, a:UInt32] - TableScan: sq2 [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + Filter: test.c > UInt32(1) [test.a:UInt32, test.b:UInt32, test.c:UInt32] + LeftSemi Join: Filter: test.c * UInt32(2) = __correlated_sq_2.sq2.c * UInt32(2) AND test.a > __correlated_sq_2.a [test.a:UInt32, test.b:UInt32, test.c:UInt32] + LeftSemi Join: Filter: test.c + UInt32(1) = __correlated_sq_1.sq1.c * UInt32(2) AND test.a > __correlated_sq_1.a [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.sq1.c * UInt32(2):UInt32, __correlated_sq_1.a:UInt32] + Projection: sq1.c * UInt32(2), sq1.a [sq1.c * UInt32(2):UInt32, sq1.a:UInt32] + TableScan: sq1 [sq1.a:UInt32, sq1.b:UInt32, sq1.c:UInt32] + SubqueryAlias: __correlated_sq_2 [__correlated_sq_2.sq2.c * UInt32(2):UInt32, __correlated_sq_2.a:UInt32] + Projection: sq2.c * UInt32(2), sq2.a [sq2.c * UInt32(2):UInt32, sq2.a:UInt32] + TableScan: sq2 [sq2.a:UInt32, sq2.b:UInt32, sq2.c:UInt32] " ) } @@ -1241,13 +1241,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: test.a = __correlated_sq_1.c [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32] - Projection: test.c [c:UInt32] - Filter: test.a > test.b [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: test.a = __correlated_sq_1.c [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32] + Projection: test.c [test.c:UInt32] + Filter: test.a > test.b [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -1273,16 +1273,16 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: __correlated_sq_2.o_custkey = customer.c_custkey [c_custkey:Int64, c_name:Utf8] - LeftSemi Join: Filter: __correlated_sq_1.o_custkey = customer.c_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - SubqueryAlias: __correlated_sq_2 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: __correlated_sq_2.o_custkey = customer.c_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + LeftSemi Join: Filter: __correlated_sq_1.o_custkey = customer.c_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + SubqueryAlias: __correlated_sq_2 [__correlated_sq_2.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -1320,16 +1320,16 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: __correlated_sq_2.o_custkey = customer.c_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_2 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - LeftSemi Join: Filter: __correlated_sq_1.l_orderkey = orders.o_orderkey [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - SubqueryAlias: __correlated_sq_1 [l_orderkey:Int64] - Projection: lineitem.l_orderkey [l_orderkey:Int64] - TableScan: lineitem [l_orderkey:Int64, l_partkey:Int64, l_suppkey:Int64, l_linenumber:Int32, l_quantity:Float64, l_extendedprice:Float64] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: __correlated_sq_2.o_custkey = customer.c_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_2 [__correlated_sq_2.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + LeftSemi Join: Filter: __correlated_sq_1.l_orderkey = orders.o_orderkey [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.l_orderkey:Int64] + Projection: lineitem.l_orderkey [lineitem.l_orderkey:Int64] + TableScan: lineitem [lineitem.l_orderkey:Int64, lineitem.l_partkey:Int64, lineitem.l_suppkey:Int64, lineitem.l_linenumber:Int32, lineitem.l_quantity:Float64, lineitem.l_extendedprice:Float64] " ) } @@ -1356,13 +1356,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - Filter: orders.o_orderkey = Int32(1) [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + Filter: orders.o_orderkey = Int32(1) [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -1385,12 +1385,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey = UInt32(1) [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey = UInt32(1) [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -1413,13 +1413,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: Boolean(true) [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - Filter: orders.o_custkey = orders.o_custkey [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: Boolean(true) [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + Filter: orders.o_custkey = orders.o_custkey [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -1445,12 +1445,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey != __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey != __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -1476,12 +1476,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey < __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey < __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -1508,12 +1508,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey OR __correlated_sq_1.o_orderkey = Int32(1) [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64, o_orderkey:Int64] - Projection: orders.o_custkey, orders.o_orderkey [o_custkey:Int64, o_orderkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey OR __correlated_sq_1.o_orderkey = Int32(1) [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64, __correlated_sq_1.o_orderkey:Int64] + Projection: orders.o_custkey, orders.o_orderkey [orders.o_custkey:Int64, orders.o_orderkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -1538,11 +1538,11 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_orderkey:Int64, __correlated_sq_1.o_custkey:Int64, __correlated_sq_1.o_orderstatus:Utf8, __correlated_sq_1.o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -1568,12 +1568,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [orders.o_custkey + Int32(1):Int64, o_custkey:Int64] - Projection: orders.o_custkey + Int32(1), orders.o_custkey [orders.o_custkey + Int32(1):Int64, o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.orders.o_custkey + Int32(1):Int64, __correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey + Int32(1), orders.o_custkey [orders.o_custkey + Int32(1):Int64, orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -1598,13 +1598,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey = Int32(1) [c_custkey:Int64, c_name:Utf8] - LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey = Int32(1) [customer.c_custkey:Int64, customer.c_name:Utf8] + LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -1627,14 +1627,14 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: __correlated_sq_1.mark OR customer.c_custkey = Int32(1) [c_custkey:Int64, c_name:Utf8, mark:Boolean] - LeftMark Join: Filter: Boolean(true) [c_custkey:Int64, c_name:Utf8, mark:Boolean] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __correlated_sq_1 [o_custkey:Int64] - Projection: orders.o_custkey [o_custkey:Int64] - Filter: customer.c_custkey = orders.o_custkey [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: __correlated_sq_1.mark OR customer.c_custkey = Int32(1) [customer.c_custkey:Int64, customer.c_name:Utf8, __correlated_sq_1.mark:Boolean] + LeftMark Join: Filter: Boolean(true) [customer.c_custkey:Int64, customer.c_name:Utf8, __correlated_sq_1.mark:Boolean] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.o_custkey:Int64] + Projection: orders.o_custkey [orders.o_custkey:Int64] + Filter: customer.c_custkey = orders.o_custkey [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -1657,12 +1657,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.c [c:UInt32] - LeftSemi Join: Filter: test.a = __correlated_sq_1.a [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32, a:UInt32] - Projection: sq.c, sq.a [c:UInt32, a:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.c [test.c:UInt32] + LeftSemi Join: Filter: test.a = __correlated_sq_1.a [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32, __correlated_sq_1.a:UInt32] + Projection: sq.c, sq.a [sq.c:UInt32, sq.a:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1679,12 +1679,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: Boolean(true) [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32] - Projection: sq.c [c:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: Boolean(true) [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32] + Projection: sq.c [sq.c:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1701,12 +1701,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftAnti Join: Filter: Boolean(true) [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32] - Projection: sq.c [c:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftAnti Join: Filter: Boolean(true) [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32] + Projection: sq.c [sq.c:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1738,17 +1738,17 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - Filter: test.c > UInt32(1) [a:UInt32, b:UInt32, c:UInt32] - LeftSemi Join: Filter: test.a = __correlated_sq_2.a [a:UInt32, b:UInt32, c:UInt32] - LeftSemi Join: Filter: test.a = __correlated_sq_1.a [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32, a:UInt32] - Projection: sq1.c, sq1.a [c:UInt32, a:UInt32] - TableScan: sq1 [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_2 [c:UInt32, a:UInt32] - Projection: sq2.c, sq2.a [c:UInt32, a:UInt32] - TableScan: sq2 [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + Filter: test.c > UInt32(1) [test.a:UInt32, test.b:UInt32, test.c:UInt32] + LeftSemi Join: Filter: test.a = __correlated_sq_2.a [test.a:UInt32, test.b:UInt32, test.c:UInt32] + LeftSemi Join: Filter: test.a = __correlated_sq_1.a [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32, __correlated_sq_1.a:UInt32] + Projection: sq1.c, sq1.a [sq1.c:UInt32, sq1.a:UInt32] + TableScan: sq1 [sq1.a:UInt32, sq1.b:UInt32, sq1.c:UInt32] + SubqueryAlias: __correlated_sq_2 [__correlated_sq_2.c:UInt32, __correlated_sq_2.a:UInt32] + Projection: sq2.c, sq2.a [sq2.c:UInt32, sq2.a:UInt32] + TableScan: sq2 [sq2.a:UInt32, sq2.b:UInt32, sq2.c:UInt32] " ) } @@ -1772,12 +1772,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: UInt32(1) + __correlated_sq_1.a > test.a * UInt32(2) [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [UInt32(1):UInt32, a:UInt32] - Projection: UInt32(1), sq.a [UInt32(1):UInt32, a:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: UInt32(1) + __correlated_sq_1.a > test.a * UInt32(2) [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.UInt32(1):UInt32, __correlated_sq_1.a:UInt32] + Projection: UInt32(1), sq.a [UInt32(1):UInt32, sq.a:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1800,13 +1800,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: Boolean(true) [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32] - Projection: test.c [c:UInt32] - Filter: test.a > test.b [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: Boolean(true) [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32] + Projection: test.c [test.c:UInt32] + Filter: test.a > test.b [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -1831,13 +1831,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: UInt32(1) + __correlated_sq_1.a > test.a * UInt32(2) [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [c:UInt32, a:UInt32] - Distinct: [c:UInt32, a:UInt32] - Projection: sq.c, sq.a [c:UInt32, a:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: UInt32(1) + __correlated_sq_1.a > test.a * UInt32(2) [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.c:UInt32, __correlated_sq_1.a:UInt32] + Distinct: [sq.c:UInt32, sq.a:UInt32] + Projection: sq.c, sq.a [sq.c:UInt32, sq.a:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1862,13 +1862,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: UInt32(1) + __correlated_sq_1.a > test.a * UInt32(2) [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [sq.b + sq.c:UInt32, a:UInt32] - Distinct: [sq.b + sq.c:UInt32, a:UInt32] - Projection: sq.b + sq.c, sq.a [sq.b + sq.c:UInt32, a:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: UInt32(1) + __correlated_sq_1.a > test.a * UInt32(2) [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.sq.b + sq.c:UInt32, __correlated_sq_1.a:UInt32] + Distinct: [sq.b + sq.c:UInt32, sq.a:UInt32] + Projection: sq.b + sq.c, sq.a [sq.b + sq.c:UInt32, sq.a:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1893,13 +1893,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: UInt32(1) + __correlated_sq_1.a > test.a * UInt32(2) [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [UInt32(1):UInt32, c:UInt32, a:UInt32] - Distinct: [UInt32(1):UInt32, c:UInt32, a:UInt32] - Projection: UInt32(1), sq.c, sq.a [UInt32(1):UInt32, c:UInt32, a:UInt32] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: UInt32(1) + __correlated_sq_1.a > test.a * UInt32(2) [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.UInt32(1):UInt32, __correlated_sq_1.c:UInt32, __correlated_sq_1.a:UInt32] + Distinct: [UInt32(1):UInt32, sq.c:UInt32, sq.a:UInt32] + Projection: UInt32(1), sq.c, sq.a [UInt32(1):UInt32, sq.c:UInt32, sq.a:UInt32] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1928,12 +1928,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r#" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: Boolean(true) [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [arr:Int32;N] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: Boolean(true) [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.arr:Int32;N] Unnest: lists[sq.arr|depth=1] structs[] [arr:Int32;N] - TableScan: sq [arr:List(Field { name: "item", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} });N] + TableScan: sq [sq.arr:List(Field { name: "item", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} });N] "# ) } @@ -1963,12 +1963,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r#" - Projection: test.b [b:UInt32] - LeftSemi Join: Filter: __correlated_sq_1.a = test.b [a:UInt32, b:UInt32, c:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __correlated_sq_1 [a:UInt32;N] + Projection: test.b [test.b:UInt32] + LeftSemi Join: Filter: __correlated_sq_1.a = test.b [test.a:UInt32, test.b:UInt32, test.c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.a:UInt32;N] Unnest: lists[sq.a|depth=1] structs[] [a:UInt32;N] - TableScan: sq [a:List(Field { name: "item", data_type: UInt32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} });N] + TableScan: sq [sq.a:List(Field { name: "item", data_type: UInt32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} });N] "# ) } @@ -1997,12 +1997,12 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: TEST_A.B [B:UInt32] - LeftSemi Join: Filter: __correlated_sq_1.A = TEST_A.A [A:UInt32, B:UInt32] - TableScan: TEST_A [A:UInt32, B:UInt32] - SubqueryAlias: __correlated_sq_1 [Int32(1):Int32, A:UInt32] - Projection: Int32(1), TEST_B.A [Int32(1):Int32, A:UInt32] - TableScan: TEST_B [A:UInt32, B:UInt32] + Projection: TEST_A.B [TEST_A.B:UInt32] + LeftSemi Join: Filter: __correlated_sq_1.A = TEST_A.A [TEST_A.A:UInt32, TEST_A.B:UInt32] + TableScan: TEST_A [TEST_A.A:UInt32, TEST_A.B:UInt32] + SubqueryAlias: __correlated_sq_1 [__correlated_sq_1.Int32(1):Int32, __correlated_sq_1.A:UInt32] + Projection: Int32(1), TEST_B.A [Int32(1):Int32, TEST_B.A:UInt32] + TableScan: TEST_B [TEST_B.A:UInt32, TEST_B.B:UInt32] " ) } diff --git a/datafusion/optimizer/src/eliminate_cross_join.rs b/datafusion/optimizer/src/eliminate_cross_join.rs index ae1d7df46d52..c1b645143cc4 100644 --- a/datafusion/optimizer/src/eliminate_cross_join.rs +++ b/datafusion/optimizer/src/eliminate_cross_join.rs @@ -495,10 +495,10 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t2.c < UInt32(20) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t2.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Filter: t2.c < UInt32(20) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Inner Join: t1.a = t2.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -522,10 +522,10 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t1.a = t2.a OR t2.b = t1.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Cross Join: [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Filter: t1.a = t2.a OR t2.b = t1.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Cross Join: [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -548,10 +548,10 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t2.c < UInt32(20) AND t2.c = UInt32(10) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t2.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Filter: t2.c < UInt32(20) AND t2.c = UInt32(10) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Inner Join: t1.a = t2.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -578,10 +578,10 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t2.c < UInt32(15) OR t2.c = UInt32(688) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t2.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Filter: t2.c < UInt32(15) OR t2.c = UInt32(688) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Inner Join: t1.a = t2.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -608,10 +608,10 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t1.a = t2.a AND t2.c < UInt32(15) OR t1.b = t2.b AND t2.c = UInt32(688) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Cross Join: [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Filter: t1.a = t2.a AND t2.c < UInt32(15) OR t1.b = t2.b AND t2.c = UInt32(688) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Cross Join: [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -634,10 +634,10 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t1.a = t2.a AND t2.c < UInt32(15) OR t1.a = t2.a OR t2.c = UInt32(688) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Cross Join: [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Filter: t1.a = t2.a AND t2.c < UInt32(15) OR t1.a = t2.a OR t2.c = UInt32(688) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Cross Join: [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -663,13 +663,13 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t1.a > UInt32(15) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Filter: t1.a > UInt32(20) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t2.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t3.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t3 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Filter: t1.a > UInt32(15) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Filter: t1.a > UInt32(20) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Inner Join: t1.a = t2.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Inner Join: t1.a = t3.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t3 [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -709,13 +709,13 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t3.c < UInt32(15) AND t3.b < UInt32(15) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Projection: t1.a, t1.b, t1.c, t2.a, t2.b, t2.c, t3.a, t3.b, t3.c [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t3.a = t2.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t3.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t3 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Filter: t3.c < UInt32(15) AND t3.b < UInt32(15) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + Projection: t1.a, t1.b, t1.c, t2.a, t2.b, t2.c, t3.a, t3.b, t3.c [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + Inner Join: t3.a = t2.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Inner Join: t1.a = t3.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t3 [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -782,16 +782,16 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t4.c < UInt32(15) OR t4.c = UInt32(688) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t3.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Filter: t2.c < UInt32(15) OR t2.c = UInt32(688) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t2.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] - Filter: t4.c < UInt32(15) OR t3.c = UInt32(688) OR t3.b = t4.b [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t3.a = t4.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t3 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t4 [a:UInt32, b:UInt32, c:UInt32] + Filter: t4.c < UInt32(15) OR t4.c = UInt32(688) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Inner Join: t1.a = t3.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Filter: t2.c < UInt32(15) OR t2.c = UInt32(688) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Inner Join: t1.a = t2.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Filter: t4.c < UInt32(15) OR t3.c = UInt32(688) OR t3.b = t4.b [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Inner Join: t3.a = t4.a [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + TableScan: t3 [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + TableScan: t4 [t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] " ) } @@ -856,16 +856,16 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t3.a = t1.a AND t4.c < UInt32(15) OR t3.a = t1.a OR t4.c = UInt32(688) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Cross Join: [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Filter: t2.c < UInt32(15) OR t2.c = UInt32(688) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t2.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] - Filter: t4.c < UInt32(15) OR t3.c = UInt32(688) OR t3.b = t4.b [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t3.a = t4.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t3 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t4 [a:UInt32, b:UInt32, c:UInt32] + Filter: t3.a = t1.a AND t4.c < UInt32(15) OR t3.a = t1.a OR t4.c = UInt32(688) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Cross Join: [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Filter: t2.c < UInt32(15) OR t2.c = UInt32(688) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Inner Join: t1.a = t2.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Filter: t4.c < UInt32(15) OR t3.c = UInt32(688) OR t3.b = t4.b [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Inner Join: t3.a = t4.a [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + TableScan: t3 [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + TableScan: t4 [t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] " ) } @@ -930,16 +930,16 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t4.c < UInt32(15) OR t4.c = UInt32(688) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t3.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Filter: t2.c < UInt32(15) OR t2.c = UInt32(688) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t2.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] - Filter: t3.a = t4.a AND t4.c < UInt32(15) OR t3.a = t4.a AND t3.c = UInt32(688) OR t3.a = t4.a OR t3.b = t4.b [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Cross Join: [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t3 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t4 [a:UInt32, b:UInt32, c:UInt32] + Filter: t4.c < UInt32(15) OR t4.c = UInt32(688) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Inner Join: t1.a = t3.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Filter: t2.c < UInt32(15) OR t2.c = UInt32(688) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Inner Join: t1.a = t2.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Filter: t3.a = t4.a AND t4.c < UInt32(15) OR t3.a = t4.a AND t3.c = UInt32(688) OR t3.a = t4.a OR t3.b = t4.b [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Cross Join: [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + TableScan: t3 [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + TableScan: t4 [t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] " ) } @@ -1008,16 +1008,16 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t4.c < UInt32(15) OR t4.c = UInt32(688) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t3.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Filter: t1.a = t2.a OR t2.c < UInt32(15) OR t1.a = t2.a AND t2.c = UInt32(688) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Cross Join: [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] - Filter: t4.c < UInt32(15) OR t3.c = UInt32(688) OR t3.b = t4.b [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t3.a = t4.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t3 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t4 [a:UInt32, b:UInt32, c:UInt32] + Filter: t4.c < UInt32(15) OR t4.c = UInt32(688) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Inner Join: t1.a = t3.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Filter: t1.a = t2.a OR t2.c < UInt32(15) OR t1.a = t2.a AND t2.c = UInt32(688) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Cross Join: [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Filter: t4.c < UInt32(15) OR t3.c = UInt32(688) OR t3.b = t4.b [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Inner Join: t3.a = t4.a [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + TableScan: t3 [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + TableScan: t4 [t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] " ) } @@ -1096,15 +1096,15 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: (t4.c < UInt32(15) OR t4.c = UInt32(688)) AND (t4.c < UInt32(15) OR t3.c = UInt32(688) OR t3.b = t4.b) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t3.a = t4.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t3.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Filter: t2.c = UInt32(688) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t2.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t3 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t4 [a:UInt32, b:UInt32, c:UInt32] + Filter: (t4.c < UInt32(15) OR t4.c = UInt32(688)) AND (t4.c < UInt32(15) OR t3.c = UInt32(688) OR t3.b = t4.b) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Inner Join: t3.a = t4.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Inner Join: t1.a = t3.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + Filter: t2.c = UInt32(688) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Inner Join: t1.a = t2.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t3 [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + TableScan: t4 [t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] " ) } @@ -1189,14 +1189,14 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: (t4.c < UInt32(15) OR t4.c = UInt32(688)) AND (t4.c < UInt32(15) OR t3.c = UInt32(688) OR t3.b = t4.b) AND t2.c = UInt32(688) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t3.a = t4.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t3.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a = t2.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t3 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t4 [a:UInt32, b:UInt32, c:UInt32] + Filter: (t4.c < UInt32(15) OR t4.c = UInt32(688)) AND (t4.c < UInt32(15) OR t3.c = UInt32(688) OR t3.b = t4.b) AND t2.c = UInt32(688) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Inner Join: t3.a = t4.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] + Inner Join: t1.a = t3.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + Inner Join: t1.a = t2.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t3 [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + TableScan: t4 [t4.a:UInt32, t4.b:UInt32, t4.c:UInt32] " ) } @@ -1219,10 +1219,10 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t2.c < UInt32(20) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a + UInt32(100) = t2.a * UInt32(2) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Filter: t2.c < UInt32(20) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Inner Join: t1.a + UInt32(100) = t2.a * UInt32(2) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -1246,10 +1246,10 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t1.a + UInt32(100) = t2.a * UInt32(2) OR t2.b = t1.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Cross Join: [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Filter: t1.a + UInt32(100) = t2.a * UInt32(2) OR t2.b = t1.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Cross Join: [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -1273,10 +1273,10 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t2.c < UInt32(20) AND t2.c = UInt32(10) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a + UInt32(100) = t2.a * UInt32(2) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Filter: t2.c < UInt32(20) AND t2.c = UInt32(10) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Inner Join: t1.a + UInt32(100) = t2.a * UInt32(2) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -1300,10 +1300,10 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t2.c < UInt32(15) OR t2.c = UInt32(688) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a + UInt32(100) = t2.a * UInt32(2) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Filter: t2.c < UInt32(15) OR t2.c = UInt32(688) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Inner Join: t1.a + UInt32(100) = t2.a * UInt32(2) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -1336,13 +1336,13 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: t3.c < UInt32(15) AND t3.b < UInt32(15) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Projection: t1.a, t1.b, t1.c, t2.a, t2.b, t2.c, t3.a, t3.b, t3.c [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t3.a + UInt32(100) = t2.a * UInt32(2) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - Inner Join: t1.a * UInt32(2) = t3.a + UInt32(100) [a:UInt32, b:UInt32, c:UInt32, a:UInt32, b:UInt32, c:UInt32] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t3 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Filter: t3.c < UInt32(15) AND t3.b < UInt32(15) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + Projection: t1.a, t1.b, t1.c, t2.a, t2.b, t2.c, t3.a, t3.b, t3.c [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + Inner Join: t3.a + UInt32(100) = t2.a * UInt32(2) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32, t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + Inner Join: t1.a * UInt32(2) = t3.a + UInt32(100) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t3 [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } diff --git a/datafusion/optimizer/src/extract_equijoin_predicate.rs b/datafusion/optimizer/src/extract_equijoin_predicate.rs index c76de942de80..dc0dc4ab0391 100644 --- a/datafusion/optimizer/src/extract_equijoin_predicate.rs +++ b/datafusion/optimizer/src/extract_equijoin_predicate.rs @@ -304,9 +304,9 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Left Join: t1.a = t2.a [a:UInt32, b:UInt32, c:UInt32, a:UInt32;N, b:UInt32;N, c:UInt32;N] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Left Join: t1.a = t2.a [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32;N, t2.b:UInt32;N, t2.c:UInt32;N] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -327,9 +327,9 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Left Join: t1.a + Int64(10) = t2.a * UInt32(2) [a:UInt32, b:UInt32, c:UInt32, a:UInt32;N, b:UInt32;N, c:UInt32;N] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Left Join: t1.a + Int64(10) = t2.a * UInt32(2) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32;N, t2.b:UInt32;N, t2.c:UInt32;N] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -354,9 +354,9 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Left Join: Filter: t1.a + Int64(10) >= t2.a * UInt32(2) AND t1.b < Int32(100) [a:UInt32, b:UInt32, c:UInt32, a:UInt32;N, b:UInt32;N, c:UInt32;N] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Left Join: Filter: t1.a + Int64(10) >= t2.a * UInt32(2) AND t1.b < Int32(100) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32;N, t2.b:UInt32;N, t2.c:UInt32;N] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -385,9 +385,9 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Left Join: t1.a + UInt32(11) = t2.a * UInt32(2), t1.a + Int64(10) = t2.a * UInt32(2) Filter: t1.b < Int32(100) [a:UInt32, b:UInt32, c:UInt32, a:UInt32;N, b:UInt32;N, c:UInt32;N] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Left Join: t1.a + UInt32(11) = t2.a * UInt32(2), t1.a + Int64(10) = t2.a * UInt32(2) Filter: t1.b < Int32(100) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32;N, t2.b:UInt32;N, t2.c:UInt32;N] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -415,9 +415,9 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Left Join: t1.a = t2.a, t1.b = t2.b Filter: t1.c = t2.c OR t1.a + t1.b > t2.b + t2.c [a:UInt32, b:UInt32, c:UInt32, a:UInt32;N, b:UInt32;N, c:UInt32;N] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Left Join: t1.a = t2.a, t1.b = t2.b Filter: t1.c = t2.c OR t1.a + t1.b > t2.b + t2.c [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32;N, t2.b:UInt32;N, t2.c:UInt32;N] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } @@ -454,11 +454,11 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Left Join: t1.a = t2.a Filter: t1.c + t2.c + t3.c < UInt32(100) [a:UInt32, b:UInt32, c:UInt32, a:UInt32;N, b:UInt32;N, c:UInt32;N, a:UInt32;N, b:UInt32;N, c:UInt32;N] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - Left Join: t2.a = t3.a Filter: t2.a + t3.b > UInt32(100) [a:UInt32, b:UInt32, c:UInt32, a:UInt32;N, b:UInt32;N, c:UInt32;N] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t3 [a:UInt32, b:UInt32, c:UInt32] + Left Join: t1.a = t2.a Filter: t1.c + t2.c + t3.c < UInt32(100) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32;N, t2.b:UInt32;N, t2.c:UInt32;N, t3.a:UInt32;N, t3.b:UInt32;N, t3.c:UInt32;N] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + Left Join: t2.a = t3.a Filter: t2.a + t3.b > UInt32(100) [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32;N, t3.b:UInt32;N, t3.c:UInt32;N] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t3 [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] " ) } @@ -491,11 +491,11 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Left Join: t1.a = t2.a Filter: t2.c = t3.c [a:UInt32, b:UInt32, c:UInt32, a:UInt32;N, b:UInt32;N, c:UInt32;N, a:UInt32;N, b:UInt32;N, c:UInt32;N] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - Left Join: t2.a = t3.a Filter: t2.a + t3.b > UInt32(100) [a:UInt32, b:UInt32, c:UInt32, a:UInt32;N, b:UInt32;N, c:UInt32;N] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t3 [a:UInt32, b:UInt32, c:UInt32] + Left Join: t1.a = t2.a Filter: t2.c = t3.c [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32;N, t2.b:UInt32;N, t2.c:UInt32;N, t3.a:UInt32;N, t3.b:UInt32;N, t3.c:UInt32;N] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + Left Join: t2.a = t3.a Filter: t2.a + t3.b > UInt32(100) [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32, t3.a:UInt32;N, t3.b:UInt32;N, t3.c:UInt32;N] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] + TableScan: t3 [t3.a:UInt32, t3.b:UInt32, t3.c:UInt32] " ) } @@ -521,9 +521,9 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Left Join: t1.a + CAST(Int64(1) AS UInt32) = t2.a + CAST(Int32(2) AS UInt32) [a:UInt32, b:UInt32, c:UInt32, a:UInt32;N, b:UInt32;N, c:UInt32;N] - TableScan: t1 [a:UInt32, b:UInt32, c:UInt32] - TableScan: t2 [a:UInt32, b:UInt32, c:UInt32] + Left Join: t1.a + CAST(Int64(1) AS UInt32) = t2.a + CAST(Int32(2) AS UInt32) [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32, t2.a:UInt32;N, t2.b:UInt32;N, t2.c:UInt32;N] + TableScan: t1 [t1.a:UInt32, t1.b:UInt32, t1.c:UInt32] + TableScan: t2 [t2.a:UInt32, t2.b:UInt32, t2.c:UInt32] " ) } diff --git a/datafusion/optimizer/src/scalar_subquery_to_join.rs b/datafusion/optimizer/src/scalar_subquery_to_join.rs index 2f9a2f6bb9ed..ed9f4dd03856 100644 --- a/datafusion/optimizer/src/scalar_subquery_to_join.rs +++ b/datafusion/optimizer/src/scalar_subquery_to_join.rs @@ -451,19 +451,19 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: Int32(1) < __scalar_sq_1.max(orders.o_custkey) AND Int32(1) < __scalar_sq_2.max(orders.o_custkey) [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - Left Join: Filter: __scalar_sq_2.o_custkey = customer.c_custkey [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - Left Join: Filter: __scalar_sq_1.o_custkey = customer.c_custkey [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __scalar_sq_1 [max(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Projection: max(orders.o_custkey), orders.o_custkey, __always_true [max(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - SubqueryAlias: __scalar_sq_2 [max(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Projection: max(orders.o_custkey), orders.o_custkey, __always_true [max(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: Int32(1) < __scalar_sq_1.max(orders.o_custkey) AND Int32(1) < __scalar_sq_2.max(orders.o_custkey) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N, __scalar_sq_2.max(orders.o_custkey):Int64;N, __scalar_sq_2.o_custkey:Int64;N, __scalar_sq_2.__always_true:Boolean;N] + Left Join: Filter: __scalar_sq_2.o_custkey = customer.c_custkey [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N, __scalar_sq_2.max(orders.o_custkey):Int64;N, __scalar_sq_2.o_custkey:Int64;N, __scalar_sq_2.__always_true:Boolean;N] + Left Join: Filter: __scalar_sq_1.o_custkey = customer.c_custkey [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64, __scalar_sq_1.__always_true:Boolean] + Projection: max(orders.o_custkey), orders.o_custkey, __always_true [max(orders.o_custkey):Int64;N, orders.o_custkey:Int64, __always_true:Boolean] + Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [orders.o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + SubqueryAlias: __scalar_sq_2 [__scalar_sq_2.max(orders.o_custkey):Int64;N, __scalar_sq_2.o_custkey:Int64, __scalar_sq_2.__always_true:Boolean] + Projection: max(orders.o_custkey), orders.o_custkey, __always_true [max(orders.o_custkey):Int64;N, orders.o_custkey:Int64, __always_true:Boolean] + Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [orders.o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -505,20 +505,20 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_acctbal < __scalar_sq_1.sum(orders.o_totalprice) [c_custkey:Int64, c_name:Utf8, sum(orders.o_totalprice):Float64;N, o_custkey:Int64;N, __always_true:Boolean;N] - Left Join: Filter: __scalar_sq_1.o_custkey = customer.c_custkey [c_custkey:Int64, c_name:Utf8, sum(orders.o_totalprice):Float64;N, o_custkey:Int64;N, __always_true:Boolean;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __scalar_sq_1 [sum(orders.o_totalprice):Float64;N, o_custkey:Int64, __always_true:Boolean] - Projection: sum(orders.o_totalprice), orders.o_custkey, __always_true [sum(orders.o_totalprice):Float64;N, o_custkey:Int64, __always_true:Boolean] - Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[sum(orders.o_totalprice)]] [o_custkey:Int64, __always_true:Boolean, sum(orders.o_totalprice):Float64;N] - Filter: orders.o_totalprice < __scalar_sq_2.sum(lineitem.l_extendedprice) [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N, sum(lineitem.l_extendedprice):Float64;N, l_orderkey:Int64;N, __always_true:Boolean;N] - Left Join: Filter: __scalar_sq_2.l_orderkey = orders.o_orderkey [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N, sum(lineitem.l_extendedprice):Float64;N, l_orderkey:Int64;N, __always_true:Boolean;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - SubqueryAlias: __scalar_sq_2 [sum(lineitem.l_extendedprice):Float64;N, l_orderkey:Int64, __always_true:Boolean] - Projection: sum(lineitem.l_extendedprice), lineitem.l_orderkey, __always_true [sum(lineitem.l_extendedprice):Float64;N, l_orderkey:Int64, __always_true:Boolean] - Aggregate: groupBy=[[lineitem.l_orderkey, Boolean(true) AS __always_true]], aggr=[[sum(lineitem.l_extendedprice)]] [l_orderkey:Int64, __always_true:Boolean, sum(lineitem.l_extendedprice):Float64;N] - TableScan: lineitem [l_orderkey:Int64, l_partkey:Int64, l_suppkey:Int64, l_linenumber:Int32, l_quantity:Float64, l_extendedprice:Float64] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_acctbal < __scalar_sq_1.sum(orders.o_totalprice) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.sum(orders.o_totalprice):Float64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + Left Join: Filter: __scalar_sq_1.o_custkey = customer.c_custkey [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.sum(orders.o_totalprice):Float64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.sum(orders.o_totalprice):Float64;N, __scalar_sq_1.o_custkey:Int64, __scalar_sq_1.__always_true:Boolean] + Projection: sum(orders.o_totalprice), orders.o_custkey, __always_true [sum(orders.o_totalprice):Float64;N, orders.o_custkey:Int64, __always_true:Boolean] + Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[sum(orders.o_totalprice)]] [orders.o_custkey:Int64, __always_true:Boolean, sum(orders.o_totalprice):Float64;N] + Filter: orders.o_totalprice < __scalar_sq_2.sum(lineitem.l_extendedprice) [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N, __scalar_sq_2.sum(lineitem.l_extendedprice):Float64;N, __scalar_sq_2.l_orderkey:Int64;N, __scalar_sq_2.__always_true:Boolean;N] + Left Join: Filter: __scalar_sq_2.l_orderkey = orders.o_orderkey [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N, __scalar_sq_2.sum(lineitem.l_extendedprice):Float64;N, __scalar_sq_2.l_orderkey:Int64;N, __scalar_sq_2.__always_true:Boolean;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + SubqueryAlias: __scalar_sq_2 [__scalar_sq_2.sum(lineitem.l_extendedprice):Float64;N, __scalar_sq_2.l_orderkey:Int64, __scalar_sq_2.__always_true:Boolean] + Projection: sum(lineitem.l_extendedprice), lineitem.l_orderkey, __always_true [sum(lineitem.l_extendedprice):Float64;N, lineitem.l_orderkey:Int64, __always_true:Boolean] + Aggregate: groupBy=[[lineitem.l_orderkey, Boolean(true) AS __always_true]], aggr=[[sum(lineitem.l_extendedprice)]] [lineitem.l_orderkey:Int64, __always_true:Boolean, sum(lineitem.l_extendedprice):Float64;N] + TableScan: lineitem [lineitem.l_orderkey:Int64, lineitem.l_partkey:Int64, lineitem.l_suppkey:Int64, lineitem.l_linenumber:Int32, lineitem.l_quantity:Float64, lineitem.l_extendedprice:Float64] " ) } @@ -546,15 +546,15 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey = __scalar_sq_1.max(orders.o_custkey) [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - Left Join: Filter: customer.c_custkey = __scalar_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __scalar_sq_1 [max(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Projection: max(orders.o_custkey), orders.o_custkey, __always_true [max(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] - Filter: orders.o_orderkey = Int32(1) [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey = __scalar_sq_1.max(orders.o_custkey) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + Left Join: Filter: customer.c_custkey = __scalar_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64, __scalar_sq_1.__always_true:Boolean] + Projection: max(orders.o_custkey), orders.o_custkey, __always_true [max(orders.o_custkey):Int64;N, orders.o_custkey:Int64, __always_true:Boolean] + Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [orders.o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] + Filter: orders.o_orderkey = Int32(1) [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -582,14 +582,14 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey = __scalar_sq_1.max(orders.o_custkey) [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N] - Left Join: Filter: Boolean(true) [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __scalar_sq_1 [max(orders.o_custkey):Int64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey = __scalar_sq_1.max(orders.o_custkey) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N] + Left Join: Filter: Boolean(true) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.max(orders.o_custkey):Int64;N] Projection: max(orders.o_custkey) [max(orders.o_custkey):Int64;N] Aggregate: groupBy=[[]], aggr=[[max(orders.o_custkey)]] [max(orders.o_custkey):Int64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -613,15 +613,15 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey = __scalar_sq_1.max(orders.o_custkey) [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N] - Left Join: Filter: Boolean(true) [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __scalar_sq_1 [max(orders.o_custkey):Int64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey = __scalar_sq_1.max(orders.o_custkey) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N] + Left Join: Filter: Boolean(true) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.max(orders.o_custkey):Int64;N] Projection: max(orders.o_custkey) [max(orders.o_custkey):Int64;N] Aggregate: groupBy=[[]], aggr=[[max(orders.o_custkey)]] [max(orders.o_custkey):Int64;N] - Filter: orders.o_custkey = orders.o_custkey [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Filter: orders.o_custkey = orders.o_custkey [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -649,14 +649,14 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey = () [c_custkey:Int64, c_name:Utf8] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey = () [customer.c_custkey:Int64, customer.c_name:Utf8] Subquery: [max(orders.o_custkey):Int64;N] Projection: max(orders.o_custkey) [max(orders.o_custkey):Int64;N] Aggregate: groupBy=[[]], aggr=[[max(orders.o_custkey)]] [max(orders.o_custkey):Int64;N] - Filter: outer_ref(customer.c_custkey) != orders.o_custkey [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] + Filter: outer_ref(customer.c_custkey) != orders.o_custkey [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] " ) } @@ -684,14 +684,14 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey = () [c_custkey:Int64, c_name:Utf8] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey = () [customer.c_custkey:Int64, customer.c_name:Utf8] Subquery: [max(orders.o_custkey):Int64;N] Projection: max(orders.o_custkey) [max(orders.o_custkey):Int64;N] Aggregate: groupBy=[[]], aggr=[[max(orders.o_custkey)]] [max(orders.o_custkey):Int64;N] - Filter: outer_ref(customer.c_custkey) < orders.o_custkey [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] + Filter: outer_ref(customer.c_custkey) < orders.o_custkey [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] " ) } @@ -720,14 +720,14 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey = () [c_custkey:Int64, c_name:Utf8] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey = () [customer.c_custkey:Int64, customer.c_name:Utf8] Subquery: [max(orders.o_custkey):Int64;N] Projection: max(orders.o_custkey) [max(orders.o_custkey):Int64;N] Aggregate: groupBy=[[]], aggr=[[max(orders.o_custkey)]] [max(orders.o_custkey):Int64;N] - Filter: outer_ref(customer.c_custkey) = orders.o_custkey OR orders.o_orderkey = Int32(1) [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] + Filter: outer_ref(customer.c_custkey) = orders.o_custkey OR orders.o_orderkey = Int32(1) [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] " ) } @@ -773,14 +773,14 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey = __scalar_sq_1.max(orders.o_custkey) + Int32(1) [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey) + Int32(1):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - Left Join: Filter: customer.c_custkey = __scalar_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey) + Int32(1):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __scalar_sq_1 [max(orders.o_custkey) + Int32(1):Int64;N, o_custkey:Int64, __always_true:Boolean] - Projection: max(orders.o_custkey) + Int32(1), orders.o_custkey, __always_true [max(orders.o_custkey) + Int32(1):Int64;N, o_custkey:Int64, __always_true:Boolean] - Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey = __scalar_sq_1.max(orders.o_custkey) + Int32(1) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey) + Int32(1):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + Left Join: Filter: customer.c_custkey = __scalar_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey) + Int32(1):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.max(orders.o_custkey) + Int32(1):Int64;N, __scalar_sq_1.o_custkey:Int64, __scalar_sq_1.__always_true:Boolean] + Projection: max(orders.o_custkey) + Int32(1), orders.o_custkey, __always_true [max(orders.o_custkey) + Int32(1):Int64;N, orders.o_custkey:Int64, __always_true:Boolean] + Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [orders.o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -815,13 +815,13 @@ mod tests { assert_optimized_plan_equal!( plan, @r#" - Projection: customer.c_custkey, CASE WHEN __scalar_sq_1.__always_true IS NULL THEN CASE WHEN CAST(NULL AS Boolean) THEN Utf8("a") ELSE Utf8("b") END ELSE __scalar_sq_1.CASE WHEN max(orders.o_totalprice) THEN Utf8("a") ELSE Utf8("b") END END AS CASE WHEN max(orders.o_totalprice) THEN Utf8("a") ELSE Utf8("b") END [c_custkey:Int64, CASE WHEN max(orders.o_totalprice) THEN Utf8("a") ELSE Utf8("b") END:Utf8;N] - Left Join: Filter: customer.c_custkey = __scalar_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8, CASE WHEN max(orders.o_totalprice) THEN Utf8("a") ELSE Utf8("b") END:Utf8;N, o_custkey:Int64;N, __always_true:Boolean;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __scalar_sq_1 [CASE WHEN max(orders.o_totalprice) THEN Utf8("a") ELSE Utf8("b") END:Utf8, o_custkey:Int64, __always_true:Boolean] - Projection: CASE WHEN max(orders.o_totalprice) THEN Utf8("a") ELSE Utf8("b") END, orders.o_custkey, __always_true [CASE WHEN max(orders.o_totalprice) THEN Utf8("a") ELSE Utf8("b") END:Utf8, o_custkey:Int64, __always_true:Boolean] - Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_totalprice)]] [o_custkey:Int64, __always_true:Boolean, max(orders.o_totalprice):Float64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey, CASE WHEN __scalar_sq_1.__always_true IS NULL THEN CASE WHEN CAST(NULL AS Boolean) THEN Utf8("a") ELSE Utf8("b") END ELSE __scalar_sq_1.CASE WHEN max(orders.o_totalprice) THEN Utf8("a") ELSE Utf8("b") END END AS CASE WHEN max(orders.o_totalprice) THEN Utf8("a") ELSE Utf8("b") END [customer.c_custkey:Int64, CASE WHEN max(orders.o_totalprice) THEN Utf8("a") ELSE Utf8("b") END:Utf8;N] + Left Join: Filter: customer.c_custkey = __scalar_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.CASE WHEN max(orders.o_totalprice) THEN Utf8("a") ELSE Utf8("b") END:Utf8;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.CASE WHEN max(orders.o_totalprice) THEN Utf8("a") ELSE Utf8("b") END:Utf8, __scalar_sq_1.o_custkey:Int64, __scalar_sq_1.__always_true:Boolean] + Projection: CASE WHEN max(orders.o_totalprice) THEN Utf8("a") ELSE Utf8("b") END, orders.o_custkey, __always_true [CASE WHEN max(orders.o_totalprice) THEN Utf8("a") ELSE Utf8("b") END:Utf8, orders.o_custkey:Int64, __always_true:Boolean] + Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_totalprice)]] [orders.o_custkey:Int64, __always_true:Boolean, max(orders.o_totalprice):Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] "# ) } @@ -876,14 +876,14 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey >= __scalar_sq_1.max(orders.o_custkey) AND customer.c_custkey = Int32(1) [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - Left Join: Filter: customer.c_custkey = __scalar_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __scalar_sq_1 [max(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Projection: max(orders.o_custkey), orders.o_custkey, __always_true [max(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey >= __scalar_sq_1.max(orders.o_custkey) AND customer.c_custkey = Int32(1) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + Left Join: Filter: customer.c_custkey = __scalar_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64, __scalar_sq_1.__always_true:Boolean] + Projection: max(orders.o_custkey), orders.o_custkey, __always_true [max(orders.o_custkey):Int64;N, orders.o_custkey:Int64, __always_true:Boolean] + Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [orders.o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -913,14 +913,14 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey = __scalar_sq_1.max(orders.o_custkey) AND customer.c_custkey = Int32(1) [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - Left Join: Filter: customer.c_custkey = __scalar_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __scalar_sq_1 [max(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Projection: max(orders.o_custkey), orders.o_custkey, __always_true [max(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey = __scalar_sq_1.max(orders.o_custkey) AND customer.c_custkey = Int32(1) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + Left Join: Filter: customer.c_custkey = __scalar_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64, __scalar_sq_1.__always_true:Boolean] + Projection: max(orders.o_custkey), orders.o_custkey, __always_true [max(orders.o_custkey):Int64;N, orders.o_custkey:Int64, __always_true:Boolean] + Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [orders.o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -951,14 +951,14 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey = __scalar_sq_1.max(orders.o_custkey) OR customer.c_custkey = Int32(1) [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - Left Join: Filter: customer.c_custkey = __scalar_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __scalar_sq_1 [max(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Projection: max(orders.o_custkey), orders.o_custkey, __always_true [max(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey = __scalar_sq_1.max(orders.o_custkey) OR customer.c_custkey = Int32(1) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + Left Join: Filter: customer.c_custkey = __scalar_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.max(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64, __scalar_sq_1.__always_true:Boolean] + Projection: max(orders.o_custkey), orders.o_custkey, __always_true [max(orders.o_custkey):Int64;N, orders.o_custkey:Int64, __always_true:Boolean] + Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [orders.o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -982,14 +982,14 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.c [c:UInt32] - Filter: test.c < __scalar_sq_1.min(sq.c) [a:UInt32, b:UInt32, c:UInt32, min(sq.c):UInt32;N, a:UInt32;N, __always_true:Boolean;N] - Left Join: Filter: test.a = __scalar_sq_1.a [a:UInt32, b:UInt32, c:UInt32, min(sq.c):UInt32;N, a:UInt32;N, __always_true:Boolean;N] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] - SubqueryAlias: __scalar_sq_1 [min(sq.c):UInt32;N, a:UInt32, __always_true:Boolean] - Projection: min(sq.c), sq.a, __always_true [min(sq.c):UInt32;N, a:UInt32, __always_true:Boolean] - Aggregate: groupBy=[[sq.a, Boolean(true) AS __always_true]], aggr=[[min(sq.c)]] [a:UInt32, __always_true:Boolean, min(sq.c):UInt32;N] - TableScan: sq [a:UInt32, b:UInt32, c:UInt32] + Projection: test.c [test.c:UInt32] + Filter: test.c < __scalar_sq_1.min(sq.c) [test.a:UInt32, test.b:UInt32, test.c:UInt32, __scalar_sq_1.min(sq.c):UInt32;N, __scalar_sq_1.a:UInt32;N, __scalar_sq_1.__always_true:Boolean;N] + Left Join: Filter: test.a = __scalar_sq_1.a [test.a:UInt32, test.b:UInt32, test.c:UInt32, __scalar_sq_1.min(sq.c):UInt32;N, __scalar_sq_1.a:UInt32;N, __scalar_sq_1.__always_true:Boolean;N] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.min(sq.c):UInt32;N, __scalar_sq_1.a:UInt32, __scalar_sq_1.__always_true:Boolean] + Projection: min(sq.c), sq.a, __always_true [min(sq.c):UInt32;N, sq.a:UInt32, __always_true:Boolean] + Aggregate: groupBy=[[sq.a, Boolean(true) AS __always_true]], aggr=[[min(sq.c)]] [sq.a:UInt32, __always_true:Boolean, min(sq.c):UInt32;N] + TableScan: sq [sq.a:UInt32, sq.b:UInt32, sq.c:UInt32] " ) } @@ -1012,14 +1012,14 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey < __scalar_sq_1.max(orders.o_custkey) [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N] - Left Join: Filter: Boolean(true) [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __scalar_sq_1 [max(orders.o_custkey):Int64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey < __scalar_sq_1.max(orders.o_custkey) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N] + Left Join: Filter: Boolean(true) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.max(orders.o_custkey):Int64;N] Projection: max(orders.o_custkey) [max(orders.o_custkey):Int64;N] Aggregate: groupBy=[[]], aggr=[[max(orders.o_custkey)]] [max(orders.o_custkey):Int64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -1041,14 +1041,14 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey = __scalar_sq_1.max(orders.o_custkey) [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N] - Left Join: Filter: Boolean(true) [c_custkey:Int64, c_name:Utf8, max(orders.o_custkey):Int64;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __scalar_sq_1 [max(orders.o_custkey):Int64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey = __scalar_sq_1.max(orders.o_custkey) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N] + Left Join: Filter: Boolean(true) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.max(orders.o_custkey):Int64;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.max(orders.o_custkey):Int64;N] Projection: max(orders.o_custkey) [max(orders.o_custkey):Int64;N] Aggregate: groupBy=[[]], aggr=[[max(orders.o_custkey)]] [max(orders.o_custkey):Int64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -1091,19 +1091,19 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey BETWEEN __scalar_sq_1.min(orders.o_custkey) AND __scalar_sq_2.max(orders.o_custkey) [c_custkey:Int64, c_name:Utf8, min(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - Left Join: Filter: customer.c_custkey = __scalar_sq_2.o_custkey [c_custkey:Int64, c_name:Utf8, min(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N, max(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - Left Join: Filter: customer.c_custkey = __scalar_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8, min(orders.o_custkey):Int64;N, o_custkey:Int64;N, __always_true:Boolean;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __scalar_sq_1 [min(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Projection: min(orders.o_custkey), orders.o_custkey, __always_true [min(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[min(orders.o_custkey)]] [o_custkey:Int64, __always_true:Boolean, min(orders.o_custkey):Int64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - SubqueryAlias: __scalar_sq_2 [max(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Projection: max(orders.o_custkey), orders.o_custkey, __always_true [max(orders.o_custkey):Int64;N, o_custkey:Int64, __always_true:Boolean] - Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey BETWEEN __scalar_sq_1.min(orders.o_custkey) AND __scalar_sq_2.max(orders.o_custkey) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.min(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N, __scalar_sq_2.max(orders.o_custkey):Int64;N, __scalar_sq_2.o_custkey:Int64;N, __scalar_sq_2.__always_true:Boolean;N] + Left Join: Filter: customer.c_custkey = __scalar_sq_2.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.min(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N, __scalar_sq_2.max(orders.o_custkey):Int64;N, __scalar_sq_2.o_custkey:Int64;N, __scalar_sq_2.__always_true:Boolean;N] + Left Join: Filter: customer.c_custkey = __scalar_sq_1.o_custkey [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.min(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64;N, __scalar_sq_1.__always_true:Boolean;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.min(orders.o_custkey):Int64;N, __scalar_sq_1.o_custkey:Int64, __scalar_sq_1.__always_true:Boolean] + Projection: min(orders.o_custkey), orders.o_custkey, __always_true [min(orders.o_custkey):Int64;N, orders.o_custkey:Int64, __always_true:Boolean] + Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[min(orders.o_custkey)]] [orders.o_custkey:Int64, __always_true:Boolean, min(orders.o_custkey):Int64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + SubqueryAlias: __scalar_sq_2 [__scalar_sq_2.max(orders.o_custkey):Int64;N, __scalar_sq_2.o_custkey:Int64, __scalar_sq_2.__always_true:Boolean] + Projection: max(orders.o_custkey), orders.o_custkey, __always_true [max(orders.o_custkey):Int64;N, orders.o_custkey:Int64, __always_true:Boolean] + Aggregate: groupBy=[[orders.o_custkey, Boolean(true) AS __always_true]], aggr=[[max(orders.o_custkey)]] [orders.o_custkey:Int64, __always_true:Boolean, max(orders.o_custkey):Int64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } @@ -1138,19 +1138,19 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: customer.c_custkey [c_custkey:Int64] - Filter: customer.c_custkey BETWEEN __scalar_sq_1.min(orders.o_custkey) AND __scalar_sq_2.max(orders.o_custkey) [c_custkey:Int64, c_name:Utf8, min(orders.o_custkey):Int64;N, max(orders.o_custkey):Int64;N] - Left Join: Filter: Boolean(true) [c_custkey:Int64, c_name:Utf8, min(orders.o_custkey):Int64;N, max(orders.o_custkey):Int64;N] - Left Join: Filter: Boolean(true) [c_custkey:Int64, c_name:Utf8, min(orders.o_custkey):Int64;N] - TableScan: customer [c_custkey:Int64, c_name:Utf8] - SubqueryAlias: __scalar_sq_1 [min(orders.o_custkey):Int64;N] + Projection: customer.c_custkey [customer.c_custkey:Int64] + Filter: customer.c_custkey BETWEEN __scalar_sq_1.min(orders.o_custkey) AND __scalar_sq_2.max(orders.o_custkey) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.min(orders.o_custkey):Int64;N, __scalar_sq_2.max(orders.o_custkey):Int64;N] + Left Join: Filter: Boolean(true) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.min(orders.o_custkey):Int64;N, __scalar_sq_2.max(orders.o_custkey):Int64;N] + Left Join: Filter: Boolean(true) [customer.c_custkey:Int64, customer.c_name:Utf8, __scalar_sq_1.min(orders.o_custkey):Int64;N] + TableScan: customer [customer.c_custkey:Int64, customer.c_name:Utf8] + SubqueryAlias: __scalar_sq_1 [__scalar_sq_1.min(orders.o_custkey):Int64;N] Projection: min(orders.o_custkey) [min(orders.o_custkey):Int64;N] Aggregate: groupBy=[[]], aggr=[[min(orders.o_custkey)]] [min(orders.o_custkey):Int64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - SubqueryAlias: __scalar_sq_2 [max(orders.o_custkey):Int64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] + SubqueryAlias: __scalar_sq_2 [__scalar_sq_2.max(orders.o_custkey):Int64;N] Projection: max(orders.o_custkey) [max(orders.o_custkey):Int64;N] Aggregate: groupBy=[[]], aggr=[[max(orders.o_custkey)]] [max(orders.o_custkey):Int64;N] - TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] + TableScan: orders [orders.o_orderkey:Int64, orders.o_custkey:Int64, orders.o_orderstatus:Utf8, orders.o_totalprice:Float64;N] " ) } diff --git a/datafusion/optimizer/src/single_distinct_to_groupby.rs b/datafusion/optimizer/src/single_distinct_to_groupby.rs index e9a23c7c4dc5..b0692239941a 100644 --- a/datafusion/optimizer/src/single_distinct_to_groupby.rs +++ b/datafusion/optimizer/src/single_distinct_to_groupby.rs @@ -328,7 +328,7 @@ mod tests { plan, @r" Aggregate: groupBy=[[]], aggr=[[max(test.b)]] [max(test.b):UInt32;N] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -348,7 +348,7 @@ mod tests { Projection: count(alias1) AS count(DISTINCT test.b) [count(DISTINCT test.b):Int64] Aggregate: groupBy=[[]], aggr=[[count(alias1)]] [count(alias1):Int64] Aggregate: groupBy=[[test.b AS alias1]], aggr=[[]] [alias1:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -371,8 +371,8 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Aggregate: groupBy=[[GROUPING SETS ((test.a), (test.b))]], aggr=[[count(DISTINCT test.c)]] [a:UInt32;N, b:UInt32;N, __grouping_id:UInt8, count(DISTINCT test.c):Int64] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Aggregate: groupBy=[[GROUPING SETS ((test.a), (test.b))]], aggr=[[count(DISTINCT test.c)]] [test.a:UInt32;N, test.b:UInt32;N, __grouping_id:UInt8, count(DISTINCT test.c):Int64] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -392,8 +392,8 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Aggregate: groupBy=[[CUBE (test.a, test.b)]], aggr=[[count(DISTINCT test.c)]] [a:UInt32;N, b:UInt32;N, __grouping_id:UInt8, count(DISTINCT test.c):Int64] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Aggregate: groupBy=[[CUBE (test.a, test.b)]], aggr=[[count(DISTINCT test.c)]] [test.a:UInt32;N, test.b:UInt32;N, __grouping_id:UInt8, count(DISTINCT test.c):Int64] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -414,8 +414,8 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Aggregate: groupBy=[[ROLLUP (test.a, test.b)]], aggr=[[count(DISTINCT test.c)]] [a:UInt32;N, b:UInt32;N, __grouping_id:UInt8, count(DISTINCT test.c):Int64] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Aggregate: groupBy=[[ROLLUP (test.a, test.b)]], aggr=[[count(DISTINCT test.c)]] [test.a:UInt32;N, test.b:UInt32;N, __grouping_id:UInt8, count(DISTINCT test.c):Int64] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -434,7 +434,7 @@ mod tests { Projection: count(alias1) AS count(DISTINCT Int32(2) * test.b) [count(DISTINCT Int32(2) * test.b):Int64] Aggregate: groupBy=[[]], aggr=[[count(alias1)]] [count(alias1):Int64] Aggregate: groupBy=[[Int32(2) * test.b AS alias1]], aggr=[[]] [alias1:Int64] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -451,10 +451,10 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.a, count(alias1) AS count(DISTINCT test.b) [a:UInt32, count(DISTINCT test.b):Int64] - Aggregate: groupBy=[[test.a]], aggr=[[count(alias1)]] [a:UInt32, count(alias1):Int64] - Aggregate: groupBy=[[test.a, test.b AS alias1]], aggr=[[]] [a:UInt32, alias1:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Projection: test.a, count(alias1) AS count(DISTINCT test.b) [test.a:UInt32, count(DISTINCT test.b):Int64] + Aggregate: groupBy=[[test.a]], aggr=[[count(alias1)]] [test.a:UInt32, count(alias1):Int64] + Aggregate: groupBy=[[test.a, test.b AS alias1]], aggr=[[]] [test.a:UInt32, alias1:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -474,8 +474,8 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Aggregate: groupBy=[[test.a]], aggr=[[count(DISTINCT test.b), count(DISTINCT test.c)]] [a:UInt32, count(DISTINCT test.b):Int64, count(DISTINCT test.c):Int64] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Aggregate: groupBy=[[test.a]], aggr=[[count(DISTINCT test.b), count(DISTINCT test.c)]] [test.a:UInt32, count(DISTINCT test.b):Int64, count(DISTINCT test.c):Int64] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -495,10 +495,10 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.a, count(alias1) AS count(DISTINCT test.b), max(alias1) AS max(DISTINCT test.b) [a:UInt32, count(DISTINCT test.b):Int64, max(DISTINCT test.b):UInt32;N] - Aggregate: groupBy=[[test.a]], aggr=[[count(alias1), max(alias1)]] [a:UInt32, count(alias1):Int64, max(alias1):UInt32;N] - Aggregate: groupBy=[[test.a, test.b AS alias1]], aggr=[[]] [a:UInt32, alias1:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Projection: test.a, count(alias1) AS count(DISTINCT test.b), max(alias1) AS max(DISTINCT test.b) [test.a:UInt32, count(DISTINCT test.b):Int64, max(DISTINCT test.b):UInt32;N] + Aggregate: groupBy=[[test.a]], aggr=[[count(alias1), max(alias1)]] [test.a:UInt32, count(alias1):Int64, max(alias1):UInt32;N] + Aggregate: groupBy=[[test.a, test.b AS alias1]], aggr=[[]] [test.a:UInt32, alias1:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -518,8 +518,8 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Aggregate: groupBy=[[test.a]], aggr=[[count(DISTINCT test.b), count(test.c)]] [a:UInt32, count(DISTINCT test.b):Int64, count(test.c):Int64] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Aggregate: groupBy=[[test.a]], aggr=[[count(DISTINCT test.b), count(test.c)]] [test.a:UInt32, count(DISTINCT test.b):Int64, count(test.c):Int64] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -539,7 +539,7 @@ mod tests { Projection: group_alias_0 AS test.a + Int32(1), count(alias1) AS count(DISTINCT test.c) [test.a + Int32(1):Int64, count(DISTINCT test.c):Int64] Aggregate: groupBy=[[group_alias_0]], aggr=[[count(alias1)]] [group_alias_0:Int64, count(alias1):Int64] Aggregate: groupBy=[[test.a + Int32(1) AS group_alias_0, test.c AS alias1]], aggr=[[]] [group_alias_0:Int64, alias1:UInt32] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -563,10 +563,10 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.a, sum(alias2) AS sum(test.c), count(alias1) AS count(DISTINCT test.b), max(alias1) AS max(DISTINCT test.b) [a:UInt32, sum(test.c):UInt64;N, count(DISTINCT test.b):Int64, max(DISTINCT test.b):UInt32;N] - Aggregate: groupBy=[[test.a]], aggr=[[sum(alias2), count(alias1), max(alias1)]] [a:UInt32, sum(alias2):UInt64;N, count(alias1):Int64, max(alias1):UInt32;N] - Aggregate: groupBy=[[test.a, test.b AS alias1]], aggr=[[sum(test.c) AS alias2]] [a:UInt32, alias1:UInt32, alias2:UInt64;N] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Projection: test.a, sum(alias2) AS sum(test.c), count(alias1) AS count(DISTINCT test.b), max(alias1) AS max(DISTINCT test.b) [test.a:UInt32, sum(test.c):UInt64;N, count(DISTINCT test.b):Int64, max(DISTINCT test.b):UInt32;N] + Aggregate: groupBy=[[test.a]], aggr=[[sum(alias2), count(alias1), max(alias1)]] [test.a:UInt32, sum(alias2):UInt64;N, count(alias1):Int64, max(alias1):UInt32;N] + Aggregate: groupBy=[[test.a, test.b AS alias1]], aggr=[[sum(test.c) AS alias2]] [test.a:UInt32, alias1:UInt32, alias2:UInt64;N] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -586,10 +586,10 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.a, sum(alias2) AS sum(test.c), max(alias3) AS max(test.c), count(alias1) AS count(DISTINCT test.b) [a:UInt32, sum(test.c):UInt64;N, max(test.c):UInt32;N, count(DISTINCT test.b):Int64] - Aggregate: groupBy=[[test.a]], aggr=[[sum(alias2), max(alias3), count(alias1)]] [a:UInt32, sum(alias2):UInt64;N, max(alias3):UInt32;N, count(alias1):Int64] - Aggregate: groupBy=[[test.a, test.b AS alias1]], aggr=[[sum(test.c) AS alias2, max(test.c) AS alias3]] [a:UInt32, alias1:UInt32, alias2:UInt64;N, alias3:UInt32;N] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Projection: test.a, sum(alias2) AS sum(test.c), max(alias3) AS max(test.c), count(alias1) AS count(DISTINCT test.b) [test.a:UInt32, sum(test.c):UInt64;N, max(test.c):UInt32;N, count(DISTINCT test.b):Int64] + Aggregate: groupBy=[[test.a]], aggr=[[sum(alias2), max(alias3), count(alias1)]] [test.a:UInt32, sum(alias2):UInt64;N, max(alias3):UInt32;N, count(alias1):Int64] + Aggregate: groupBy=[[test.a, test.b AS alias1]], aggr=[[sum(test.c) AS alias2, max(test.c) AS alias3]] [test.a:UInt32, alias1:UInt32, alias2:UInt64;N, alias3:UInt32;N] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -609,10 +609,10 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Projection: test.c, min(alias2) AS min(test.a), count(alias1) AS count(DISTINCT test.b) [c:UInt32, min(test.a):UInt32;N, count(DISTINCT test.b):Int64] - Aggregate: groupBy=[[test.c]], aggr=[[min(alias2), count(alias1)]] [c:UInt32, min(alias2):UInt32;N, count(alias1):Int64] - Aggregate: groupBy=[[test.c, test.b AS alias1]], aggr=[[min(test.a) AS alias2]] [c:UInt32, alias1:UInt32, alias2:UInt32;N] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Projection: test.c, min(alias2) AS min(test.a), count(alias1) AS count(DISTINCT test.b) [test.c:UInt32, min(test.a):UInt32;N, count(DISTINCT test.b):Int64] + Aggregate: groupBy=[[test.c]], aggr=[[min(alias2), count(alias1)]] [test.c:UInt32, min(alias2):UInt32;N, count(alias1):Int64] + Aggregate: groupBy=[[test.c, test.b AS alias1]], aggr=[[min(test.a) AS alias2]] [test.c:UInt32, alias1:UInt32, alias2:UInt32;N] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -638,8 +638,8 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Aggregate: groupBy=[[test.c]], aggr=[[sum(test.a) FILTER (WHERE test.a > Int32(5)), count(DISTINCT test.b)]] [c:UInt32, sum(test.a) FILTER (WHERE test.a > Int32(5)):UInt64;N, count(DISTINCT test.b):Int64] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Aggregate: groupBy=[[test.c]], aggr=[[sum(test.a) FILTER (WHERE test.a > Int32(5)), count(DISTINCT test.b)]] [test.c:UInt32, sum(test.a) FILTER (WHERE test.a > Int32(5)):UInt64;N, count(DISTINCT test.b):Int64] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -662,8 +662,8 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Aggregate: groupBy=[[test.c]], aggr=[[sum(test.a), count(DISTINCT test.a) FILTER (WHERE test.a > Int32(5))]] [c:UInt32, sum(test.a):UInt64;N, count(DISTINCT test.a) FILTER (WHERE test.a > Int32(5)):Int64] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Aggregate: groupBy=[[test.c]], aggr=[[sum(test.a), count(DISTINCT test.a) FILTER (WHERE test.a > Int32(5))]] [test.c:UInt32, sum(test.a):UInt64;N, count(DISTINCT test.a) FILTER (WHERE test.a > Int32(5)):Int64] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -689,8 +689,8 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Aggregate: groupBy=[[test.c]], aggr=[[sum(test.a) ORDER BY [test.a ASC NULLS LAST], count(DISTINCT test.b)]] [c:UInt32, sum(test.a) ORDER BY [test.a ASC NULLS LAST]:UInt64;N, count(DISTINCT test.b):Int64] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Aggregate: groupBy=[[test.c]], aggr=[[sum(test.a) ORDER BY [test.a ASC NULLS LAST], count(DISTINCT test.b)]] [test.c:UInt32, sum(test.a) ORDER BY [test.a ASC NULLS LAST]:UInt64;N, count(DISTINCT test.b):Int64] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -713,8 +713,8 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Aggregate: groupBy=[[test.c]], aggr=[[sum(test.a), count(DISTINCT test.a) ORDER BY [test.a ASC NULLS LAST]]] [c:UInt32, sum(test.a):UInt64;N, count(DISTINCT test.a) ORDER BY [test.a ASC NULLS LAST]:Int64] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Aggregate: groupBy=[[test.c]], aggr=[[sum(test.a), count(DISTINCT test.a) ORDER BY [test.a ASC NULLS LAST]]] [test.c:UInt32, sum(test.a):UInt64;N, count(DISTINCT test.a) ORDER BY [test.a ASC NULLS LAST]:Int64] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } @@ -738,8 +738,8 @@ mod tests { assert_optimized_plan_equal!( plan, @r" - Aggregate: groupBy=[[test.c]], aggr=[[sum(test.a), count(DISTINCT test.a) FILTER (WHERE test.a > Int32(5)) ORDER BY [test.a ASC NULLS LAST]]] [c:UInt32, sum(test.a):UInt64;N, count(DISTINCT test.a) FILTER (WHERE test.a > Int32(5)) ORDER BY [test.a ASC NULLS LAST]:Int64] - TableScan: test [a:UInt32, b:UInt32, c:UInt32] + Aggregate: groupBy=[[test.c]], aggr=[[sum(test.a), count(DISTINCT test.a) FILTER (WHERE test.a > Int32(5)) ORDER BY [test.a ASC NULLS LAST]]] [test.c:UInt32, sum(test.a):UInt64;N, count(DISTINCT test.a) FILTER (WHERE test.a > Int32(5)) ORDER BY [test.a ASC NULLS LAST]:Int64] + TableScan: test [test.a:UInt32, test.b:UInt32, test.c:UInt32] " ) } diff --git a/datafusion/sqllogictest/test_files/distinct_on.slt b/datafusion/sqllogictest/test_files/distinct_on.slt index b4a491619e89..9ad900c40f9b 100644 --- a/datafusion/sqllogictest/test_files/distinct_on.slt +++ b/datafusion/sqllogictest/test_files/distinct_on.slt @@ -89,7 +89,7 @@ query TT EXPLAIN SELECT DISTINCT ON (c1) c3, c2 FROM aggregate_test_100 ORDER BY c1, c3; ---- logical_plan -01)Projection: first_value(aggregate_test_100.c3) ORDER BY [aggregate_test_100.c1 ASC NULLS LAST, aggregate_test_100.c3 ASC NULLS LAST] AS c3, first_value(aggregate_test_100.c2) ORDER BY [aggregate_test_100.c1 ASC NULLS LAST, aggregate_test_100.c3 ASC NULLS LAST] AS c2 +01)Projection: first_value(aggregate_test_100.c3) ORDER BY [aggregate_test_100.c1 ASC NULLS LAST, aggregate_test_100.c3 ASC NULLS LAST] AS aggregate_test_100.c3, first_value(aggregate_test_100.c2) ORDER BY [aggregate_test_100.c1 ASC NULLS LAST, aggregate_test_100.c3 ASC NULLS LAST] AS aggregate_test_100.c2 02)--Sort: aggregate_test_100.c1 ASC NULLS LAST 03)----Aggregate: groupBy=[[aggregate_test_100.c1]], aggr=[[first_value(aggregate_test_100.c3) ORDER BY [aggregate_test_100.c1 ASC NULLS LAST, aggregate_test_100.c3 ASC NULLS LAST], first_value(aggregate_test_100.c2) ORDER BY [aggregate_test_100.c1 ASC NULLS LAST, aggregate_test_100.c3 ASC NULLS LAST]]] 04)------TableScan: aggregate_test_100 projection=[c1, c2, c3] @@ -168,7 +168,7 @@ query TT explain select distinct on (a) b from t order by a desc, c; ---- logical_plan -01)Projection: first_value(t.b) ORDER BY [t.a DESC NULLS FIRST, t.c ASC NULLS LAST] AS b +01)Projection: first_value(t.b) ORDER BY [t.a DESC NULLS FIRST, t.c ASC NULLS LAST] AS t.b 02)--Sort: t.a DESC NULLS FIRST 03)----Aggregate: groupBy=[[t.a]], aggr=[[first_value(t.b) ORDER BY [t.a DESC NULLS FIRST, t.c ASC NULLS LAST]]] 04)------TableScan: t projection=[a, b, c] diff --git a/datafusion/sqllogictest/test_files/subquery_sort.slt b/datafusion/sqllogictest/test_files/subquery_sort.slt index 1e5a3c8f526a..56685b71ae1c 100644 --- a/datafusion/sqllogictest/test_files/subquery_sort.slt +++ b/datafusion/sqllogictest/test_files/subquery_sort.slt @@ -140,7 +140,7 @@ logical_plan 01)Projection: t2.c1, t2.c2 02)--Sort: t2.c1 ASC NULLS LAST, t2.c3 DESC NULLS FIRST, t2.c9 ASC NULLS LAST 03)----SubqueryAlias: t2 -04)------Projection: first_value(sink_table.c1) ORDER BY [sink_table.c1 ASC NULLS LAST, sink_table.c3 DESC NULLS FIRST, sink_table.c9 ASC NULLS LAST] AS c1, first_value(sink_table.c2) ORDER BY [sink_table.c1 ASC NULLS LAST, sink_table.c3 DESC NULLS FIRST, sink_table.c9 ASC NULLS LAST] AS c2, first_value(sink_table.c3) ORDER BY [sink_table.c1 ASC NULLS LAST, sink_table.c3 DESC NULLS FIRST, sink_table.c9 ASC NULLS LAST] AS c3, first_value(sink_table.c9) ORDER BY [sink_table.c1 ASC NULLS LAST, sink_table.c3 DESC NULLS FIRST, sink_table.c9 ASC NULLS LAST] AS c9 +04)------Projection: first_value(sink_table.c1) ORDER BY [sink_table.c1 ASC NULLS LAST, sink_table.c3 DESC NULLS FIRST, sink_table.c9 ASC NULLS LAST] AS sink_table.c1, first_value(sink_table.c2) ORDER BY [sink_table.c1 ASC NULLS LAST, sink_table.c3 DESC NULLS FIRST, sink_table.c9 ASC NULLS LAST] AS sink_table.c2, first_value(sink_table.c3) ORDER BY [sink_table.c1 ASC NULLS LAST, sink_table.c3 DESC NULLS FIRST, sink_table.c9 ASC NULLS LAST] AS sink_table.c3, first_value(sink_table.c9) ORDER BY [sink_table.c1 ASC NULLS LAST, sink_table.c3 DESC NULLS FIRST, sink_table.c9 ASC NULLS LAST] AS sink_table.c9 05)--------Sort: sink_table.c1 ASC NULLS LAST 06)----------Aggregate: groupBy=[[sink_table.c1]], aggr=[[first_value(sink_table.c1) ORDER BY [sink_table.c1 ASC NULLS LAST, sink_table.c3 DESC NULLS FIRST, sink_table.c9 ASC NULLS LAST], first_value(sink_table.c2) ORDER BY [sink_table.c1 ASC NULLS LAST, sink_table.c3 DESC NULLS FIRST, sink_table.c9 ASC NULLS LAST], first_value(sink_table.c3) ORDER BY [sink_table.c1 ASC NULLS LAST, sink_table.c3 DESC NULLS FIRST, sink_table.c9 ASC NULLS LAST], first_value(sink_table.c9) ORDER BY [sink_table.c1 ASC NULLS LAST, sink_table.c3 DESC NULLS FIRST, sink_table.c9 ASC NULLS LAST]]] 07)------------TableScan: sink_table projection=[c1, c2, c3, c9] diff --git a/datafusion/substrait/tests/cases/consumer_integration.rs b/datafusion/substrait/tests/cases/consumer_integration.rs index a92fc2957cae..2fa603d3e45a 100644 --- a/datafusion/substrait/tests/cases/consumer_integration.rs +++ b/datafusion/substrait/tests/cases/consumer_integration.rs @@ -611,10 +611,10 @@ mod tests { Projection: left.count(Int64(1)) AS count_first, left.category, left.count(Int64(1)):1 AS count_second, right.count(Int64(1)) AS count_third Left Join: left.id = right.id SubqueryAlias: left - Projection: left.id, left.count(Int64(1)), left.id:1, left.category, right.id AS id:2, right.count(Int64(1)) AS count(Int64(1)):1 + Projection: left.id, left.count(Int64(1)), left.id:1, left.category, right.id AS right.id:2, right.count(Int64(1)) AS right.count(Int64(1)):1 Left Join: left.id = right.id SubqueryAlias: left - Projection: left.id, left.count(Int64(1)), right.id AS id:1, right.category + Projection: left.id, left.count(Int64(1)), right.id AS right.id:1, right.category Left Join: left.id = right.id SubqueryAlias: left Aggregate: groupBy=[[id]], aggr=[[count(Int64(1))]]