diff --git a/datafusion/core/tests/dataframe/mod.rs b/datafusion/core/tests/dataframe/mod.rs index 1ae6ef5c4a8b5..7a69d0d0b1a3c 100644 --- a/datafusion/core/tests/dataframe/mod.rs +++ b/datafusion/core/tests/dataframe/mod.rs @@ -1541,7 +1541,7 @@ async fn join_on() -> Result<()> { )?; assert_snapshot!(join.logical_plan(), @r" - Inner Join: Filter: a.c1 != b.c1 AND a.c2 = b.c2 + Inner Join: Filter: (a.c1 != b.c1) AND (a.c2 = b.c2) Projection: a.c1, a.c2 TableScan: a Projection: b.c1, b.c2 diff --git a/datafusion/expr/src/expr.rs b/datafusion/expr/src/expr.rs index 454839fdb75ac..c6ce2021f746d 100644 --- a/datafusion/expr/src/expr.rs +++ b/datafusion/expr/src/expr.rs @@ -616,34 +616,24 @@ impl BinaryExpr { impl Display for BinaryExpr { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - // Put parentheses around child binary expressions so that we can see the difference - // between `(a OR b) AND c` and `a OR (b AND c)`. We only insert parentheses when needed, - // based on operator precedence. For example, `(a AND b) OR c` and `a AND b OR c` are - // equivalent and the parentheses are not necessary. - - fn write_child( - f: &mut Formatter<'_>, - expr: &Expr, - precedence: u8, - ) -> fmt::Result { + // Put parentheses around child binary expressions to avoid ambiguity. + // For example, `(1 + 2) * 3` should display with parentheses to show + // it's different from `1 + 2 * 3`. This follows DuckDB's approach of + // always adding parentheses around nested binary expressions. + + fn write_child(f: &mut Formatter<'_>, expr: &Expr) -> fmt::Result { match expr { Expr::BinaryExpr(child) => { - let p = child.op.precedence(); - if p == 0 || p < precedence { - write!(f, "({child})")?; - } else { - write!(f, "{child}")?; - } + write!(f, "({child})")?; } _ => write!(f, "{expr}")?, } Ok(()) } - let precedence = self.op.precedence(); - write_child(f, self.left.as_ref(), precedence)?; + write_child(f, self.left.as_ref())?; write!(f, " {} ", self.op)?; - write_child(f, self.right.as_ref(), precedence) + write_child(f, self.right.as_ref()) } } @@ -2828,7 +2818,11 @@ impl Display for SchemaDisplay<'_> { } } Expr::BinaryExpr(BinaryExpr { left, op, right }) => { - write!(f, "{} {op} {}", SchemaDisplay(left), SchemaDisplay(right),) + // Note: SchemaDisplay intentionally does NOT add parentheses around + // nested binary expressions because schema names must remain stable + // for field lookups in optimizers like common_subexpr_eliminate. + // Use Display for human-readable output with parentheses. + write!(f, "{} {op} {}", SchemaDisplay(left), SchemaDisplay(right)) } Expr::Case(Case { expr, @@ -3090,7 +3084,16 @@ impl Display for SqlDisplay<'_> { } } Expr::BinaryExpr(BinaryExpr { left, op, right }) => { - write!(f, "{} {op} {}", SqlDisplay(left), SqlDisplay(right),) + // Add parentheses around nested binary expressions to avoid ambiguity + fn write_child(f: &mut Formatter<'_>, expr: &Expr) -> fmt::Result { + match expr { + Expr::BinaryExpr(_) => write!(f, "({})", SqlDisplay(expr)), + _ => write!(f, "{}", SqlDisplay(expr)), + } + } + write_child(f, left)?; + write!(f, " {op} ")?; + write_child(f, right) } Expr::Case(Case { expr, @@ -4093,4 +4096,72 @@ mod test { } } } + + #[test] + fn test_binary_expr_display_with_parentheses() { + // Test that nested binary expressions display with parentheses + // to avoid ambiguity. For example, (1+2)*3 should show parentheses. + let one = lit(1i64); + let two = lit(2i64); + let three = lit(3i64); + + // (1+2)*3 - addition nested in multiplication + let add = Expr::BinaryExpr(BinaryExpr::new( + Box::new(one.clone()), + Operator::Plus, + Box::new(two.clone()), + )); + let mul = Expr::BinaryExpr(BinaryExpr::new( + Box::new(add), + Operator::Multiply, + Box::new(three.clone()), + )); + + let display = format!("{mul}"); + // Should contain parentheses around the addition + assert!( + display.contains("("), + "Expected parentheses in display: {display}" + ); + assert_eq!(display, "(Int64(1) + Int64(2)) * Int64(3)"); + + // 1*(2+3) - addition nested in multiplication on the right + let add_right = Expr::BinaryExpr(BinaryExpr::new( + Box::new(two.clone()), + Operator::Multiply, + Box::new(three.clone()), + )); + let mul_right = Expr::BinaryExpr(BinaryExpr::new( + Box::new(one.clone()), + Operator::Plus, + Box::new(add_right), + )); + + let display_right = format!("{mul_right}"); + assert!( + display_right.contains("("), + "Expected parentheses in display: {display_right}" + ); + assert_eq!(display_right, "Int64(1) + (Int64(2) * Int64(3))"); + + // (a OR b) AND c - logical operators + let a = col("a"); + let b = col("b"); + let c = col("c"); + + let or_expr = + Expr::BinaryExpr(BinaryExpr::new(Box::new(a), Operator::Or, Box::new(b))); + let and_expr = Expr::BinaryExpr(BinaryExpr::new( + Box::new(or_expr), + Operator::And, + Box::new(c), + )); + + let display_logical = format!("{and_expr}"); + assert!( + display_logical.contains("("), + "Expected parentheses in display: {display_logical}" + ); + assert_eq!(display_logical, "(a OR b) AND c"); + } } diff --git a/datafusion/optimizer/src/analyzer/type_coercion.rs b/datafusion/optimizer/src/analyzer/type_coercion.rs index 5ce2c3b6af6a6..4ba7e06915cd7 100644 --- a/datafusion/optimizer/src/analyzer/type_coercion.rs +++ b/datafusion/optimizer/src/analyzer/type_coercion.rs @@ -1721,8 +1721,8 @@ mod test { assert_analyzed_plan_eq!( plan, - @r" - Projection: a < CAST(UInt32(2) AS Float64) OR a < CAST(UInt32(2) AS Float64) + @" + Projection: (a < CAST(UInt32(2) AS Float64)) OR (a < CAST(UInt32(2) AS Float64)) EmptyRelation: rows=0 " ) diff --git a/datafusion/optimizer/src/common_subexpr_eliminate.rs b/datafusion/optimizer/src/common_subexpr_eliminate.rs index d9273a8f60fb2..5ceee5fd7c872 100644 --- a/datafusion/optimizer/src/common_subexpr_eliminate.rs +++ b/datafusion/optimizer/src/common_subexpr_eliminate.rs @@ -882,7 +882,7 @@ mod test { assert_optimized_plan_equal!( plan, - @ r" + @ " Aggregate: groupBy=[[]], aggr=[[sum(__common_expr_1 AS test.a * Int32(1) - test.b), sum(__common_expr_1 AS test.a * Int32(1) - test.b * (Int32(1) + test.c))]] Projection: test.a * (Int32(1) - test.b) AS __common_expr_1, test.a, test.b, test.c TableScan: test @@ -1251,9 +1251,9 @@ mod test { assert_optimized_plan_equal!( plan, - @ r" + @ " Projection: test.a, test.b, test.c - Filter: __common_expr_1 - Int32(10) > __common_expr_1 + Filter: (__common_expr_1 - Int32(10)) > __common_expr_1 Projection: Int32(1) + test.a AS __common_expr_1, test.a, test.b, test.c TableScan: test " @@ -1375,9 +1375,9 @@ mod test { assert_optimized_plan_equal!( plan, - @ r" - Projection: __common_expr_1 AS c1, __common_expr_1 AS c2, __common_expr_2 OR test.a - test.b = Int32(0) AS c3, __common_expr_2 AND test.a - test.b = Int32(0) AS c4, __common_expr_3 OR __common_expr_3 AS c5 - Projection: test.a = Int32(0) OR test.b = Int32(0) AS __common_expr_1, test.a + test.b = Int32(0) AS __common_expr_2, test.a * test.b = Int32(0) AS __common_expr_3, test.a, test.b, test.c + @ " + Projection: __common_expr_1 AS c1, __common_expr_1 AS c2, __common_expr_2 OR ((test.a - test.b) = Int32(0)) AS c3, __common_expr_2 AND ((test.a - test.b) = Int32(0)) AS c4, __common_expr_3 OR __common_expr_3 AS c5 + Projection: (test.a = Int32(0)) OR (test.b = Int32(0)) AS __common_expr_1, (test.a + test.b) = Int32(0) AS __common_expr_2, (test.a * test.b) = Int32(0) AS __common_expr_3, test.a, test.b, test.c TableScan: test " ) @@ -1429,8 +1429,8 @@ mod test { assert_optimized_plan_equal!( plan, - @ r" - Projection: __common_expr_1 OR random() = Int32(0) AS c1, __common_expr_1 OR random() = Int32(0) AS c2, random() = Int32(0) OR test.b = Int32(0) AS c3, random() = Int32(0) OR test.b = Int32(0) AS c4 + @ " + Projection: __common_expr_1 OR (random() = Int32(0)) AS c1, __common_expr_1 OR (random() = Int32(0)) AS c2, (random() = Int32(0)) OR (test.b = Int32(0)) AS c3, (random() = Int32(0)) OR (test.b = Int32(0)) AS c4 Projection: test.a = Int32(0) AS __common_expr_1, test.a, test.b, test.c TableScan: test " @@ -1494,9 +1494,9 @@ mod test { assert_optimized_plan_equal!( plan, - @ r" + @ " Projection: test.a, test.b, test.c - Filter: __common_expr_1 * __common_expr_1 = Int32(30) + Filter: (__common_expr_1 * __common_expr_1) = Int32(30) Projection: test.a + test.b AS __common_expr_1, test.a, test.b, test.c TableScan: test " @@ -1512,9 +1512,9 @@ mod test { assert_optimized_plan_equal!( plan, - @ r" + @ " Projection: test.a, test.b, test.c - Filter: __common_expr_1 + __common_expr_1 = Int32(30) + Filter: (__common_expr_1 + __common_expr_1) = Int32(30) Projection: test.a * test.b AS __common_expr_1, test.a, test.b, test.c TableScan: test " @@ -1530,9 +1530,9 @@ mod test { assert_optimized_plan_equal!( plan, - @ r" + @ " Projection: test.a, test.b, test.c - Filter: __common_expr_1 + __common_expr_1 = Int32(30) + Filter: (__common_expr_1 + __common_expr_1) = Int32(30) Projection: test.a & test.b AS __common_expr_1, test.a, test.b, test.c TableScan: test " @@ -1548,9 +1548,9 @@ mod test { assert_optimized_plan_equal!( plan, - @ r" + @ " Projection: test.a, test.b, test.c - Filter: __common_expr_1 + __common_expr_1 = Int32(30) + Filter: (__common_expr_1 + __common_expr_1) = Int32(30) Projection: test.a | test.b AS __common_expr_1, test.a, test.b, test.c TableScan: test " @@ -1566,9 +1566,9 @@ mod test { assert_optimized_plan_equal!( plan, - @ r" + @ " Projection: test.a, test.b, test.c - Filter: __common_expr_1 + __common_expr_1 = Int32(30) + Filter: (__common_expr_1 + __common_expr_1) = Int32(30) Projection: test.a BIT_XOR test.b AS __common_expr_1, test.a, test.b, test.c TableScan: test " @@ -1621,10 +1621,10 @@ mod test { assert_optimized_plan_equal!( plan, - @ r" + @ " Projection: test.a, test.b, test.c - Filter: __common_expr_1 - __common_expr_1 = Int32(30) - Projection: test.a + test.b * test.c AS __common_expr_1, test.a, test.b, test.c + Filter: (__common_expr_1 - __common_expr_1) = Int32(30) + Projection: test.a + (test.b * test.c) AS __common_expr_1, test.a, test.b, test.c TableScan: test " )?; @@ -1639,10 +1639,10 @@ mod test { assert_optimized_plan_equal!( plan, - @ r" + @ " Projection: test.a, test.b, test.c - Filter: __common_expr_1 / __common_expr_1 + test.a = Int32(30) - Projection: (test.a + test.b / test.c) * test.c AS __common_expr_1, test.a, test.b, test.c + Filter: ((__common_expr_1 / __common_expr_1) + test.a) = Int32(30) + Projection: (test.a + (test.b / test.c)) * test.c AS __common_expr_1, test.a, test.b, test.c TableScan: test " )?; @@ -1655,9 +1655,9 @@ mod test { let plan = LogicalPlanBuilder::from(table_scan).filter(expr)?.build()?; assert_optimized_plan_equal!( plan, - @ r" + @ " Projection: test.a, test.b, test.c - Filter: __common_expr_1 * __common_expr_1 = Int32(30) + Filter: (__common_expr_1 * __common_expr_1) = Int32(30) Projection: test.b / (test.a + test.c) AS __common_expr_1, test.a, test.b, test.c TableScan: test " diff --git a/datafusion/optimizer/src/decorrelate_predicate_subquery.rs b/datafusion/optimizer/src/decorrelate_predicate_subquery.rs index b2742719cb9e9..a14b127683031 100644 --- a/datafusion/optimizer/src/decorrelate_predicate_subquery.rs +++ b/datafusion/optimizer/src/decorrelate_predicate_subquery.rs @@ -609,9 +609,9 @@ 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] + 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] @@ -853,9 +853,9 @@ 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] + 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] @@ -884,9 +884,9 @@ 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] + 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] @@ -916,9 +916,9 @@ 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] + 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] @@ -970,9 +970,9 @@ 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] + 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] @@ -1001,9 +1001,9 @@ 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] + 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] @@ -1093,9 +1093,9 @@ 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] + 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] @@ -1209,9 +1209,9 @@ 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] + 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: sq.c * UInt32(2) [sq.c * UInt32(2):UInt32] @@ -1241,13 +1241,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] + 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] + Filter: (sq.a + UInt32(1)) = sq.b [a:UInt32, b:UInt32, c:UInt32] TableScan: sq [a:UInt32, b:UInt32, c:UInt32] " ) @@ -1275,13 +1275,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] + 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] + Filter: (sq.a + UInt32(1)) = sq.b [a:UInt32, b:UInt32, c:UInt32] TableScan: sq [a:UInt32, b:UInt32, c:UInt32] " ) @@ -1315,11 +1315,11 @@ 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] + 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] @@ -1615,9 +1615,9 @@ 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] + 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] @@ -1734,9 +1734,9 @@ 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] + 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] @@ -1879,9 +1879,9 @@ 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] + 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] @@ -1938,9 +1938,9 @@ 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] + 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] @@ -1969,9 +1969,9 @@ 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] + 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] @@ -2000,9 +2000,9 @@ 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] + 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] diff --git a/datafusion/optimizer/src/eliminate_cross_join.rs b/datafusion/optimizer/src/eliminate_cross_join.rs index c5a3a7d96ce89..fcf011bfb1d4d 100644 --- a/datafusion/optimizer/src/eliminate_cross_join.rs +++ b/datafusion/optimizer/src/eliminate_cross_join.rs @@ -522,8 +522,8 @@ 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] + @ " + 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] @@ -548,8 +548,8 @@ 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] + @ " + 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] @@ -578,8 +578,8 @@ 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] + @ " + 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] @@ -608,8 +608,8 @@ 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] + @ " + 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] @@ -634,8 +634,8 @@ 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] + @ " + 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] @@ -709,8 +709,8 @@ 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] + @ " + 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] @@ -782,14 +782,14 @@ 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] + @ " + 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] + 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] + 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] @@ -856,14 +856,14 @@ 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] + @ " + 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] + 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] + 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] @@ -930,14 +930,14 @@ 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] + @ " + 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] + 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] + 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] @@ -1008,14 +1008,14 @@ 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] + @ " + 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] + 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] + 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] @@ -1096,8 +1096,8 @@ 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] + @ " + 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] @@ -1189,8 +1189,8 @@ 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] + @ " + 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] @@ -1246,8 +1246,8 @@ 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] + @ " + 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] @@ -1273,8 +1273,8 @@ 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] + @ " + 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] @@ -1300,8 +1300,8 @@ 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] + @ " + 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] @@ -1336,8 +1336,8 @@ 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] + @ " + 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] diff --git a/datafusion/optimizer/src/eliminate_outer_join.rs b/datafusion/optimizer/src/eliminate_outer_join.rs index 58abe38d04bc7..e5c7b32137876 100644 --- a/datafusion/optimizer/src/eliminate_outer_join.rs +++ b/datafusion/optimizer/src/eliminate_outer_join.rs @@ -400,8 +400,8 @@ mod tests { ))? .build()?; - assert_optimized_plan_equal!(plan, @r" - Filter: t1.b > UInt32(10) OR t1.c < UInt32(20) + assert_optimized_plan_equal!(plan, @" + Filter: (t1.b > UInt32(10)) OR (t1.c < UInt32(20)) Inner Join: t1.a = t2.a TableScan: t1 TableScan: t2 @@ -428,8 +428,8 @@ mod tests { ))? .build()?; - assert_optimized_plan_equal!(plan, @r" - Filter: t1.b > UInt32(10) AND t2.c < UInt32(20) + assert_optimized_plan_equal!(plan, @" + Filter: (t1.b > UInt32(10)) AND (t2.c < UInt32(20)) Inner Join: t1.a = t2.a TableScan: t1 TableScan: t2 @@ -456,8 +456,8 @@ mod tests { ))? .build()?; - assert_optimized_plan_equal!(plan, @r" - Filter: CAST(t1.b AS Int64) > UInt32(10) AND TRY_CAST(t2.c AS Int64) < UInt32(20) + assert_optimized_plan_equal!(plan, @" + Filter: (CAST(t1.b AS Int64) > UInt32(10)) AND (TRY_CAST(t2.c AS Int64) < UInt32(20)) Inner Join: t1.a = t2.a TableScan: t1 TableScan: t2 diff --git a/datafusion/optimizer/src/extract_equijoin_predicate.rs b/datafusion/optimizer/src/extract_equijoin_predicate.rs index 0a50761e8a9f7..125d256f32129 100644 --- a/datafusion/optimizer/src/extract_equijoin_predicate.rs +++ b/datafusion/optimizer/src/extract_equijoin_predicate.rs @@ -356,8 +356,8 @@ 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] + @" + 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] " @@ -417,8 +417,8 @@ 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] + @" + 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] " @@ -456,10 +456,10 @@ 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] + @" + 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] + 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] " @@ -493,10 +493,10 @@ 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] + 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] " diff --git a/datafusion/optimizer/src/push_down_filter.rs b/datafusion/optimizer/src/push_down_filter.rs index 1ff8bdfeff4c0..99b64cfca30ac 100644 --- a/datafusion/optimizer/src/push_down_filter.rs +++ b/datafusion/optimizer/src/push_down_filter.rs @@ -1619,9 +1619,9 @@ mod tests { .build()?; assert_optimized_plan_equal!( plan, - @r" + @" Aggregate: groupBy=[[test.b + test.a]], aggr=[[sum(test.a), test.b]] - TableScan: test, full_filters=[test.b + test.a > Int64(10)] + TableScan: test, full_filters=[(test.b + test.a) > Int64(10)] " ) } @@ -1797,8 +1797,8 @@ mod tests { assert_optimized_plan_equal!( plan, - @r" - Filter: test.a + test.b > Int64(10) + @" + Filter: (test.a + test.b) > Int64(10) WindowAggr: windowExpr=[[rank() PARTITION BY [test.a + test.b] ORDER BY [test.c ASC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] TableScan: test " @@ -1969,18 +1969,18 @@ mod tests { // not part of the test, just good to know: assert_snapshot!(plan, - @r" + @" Filter: b = Int64(1) - Projection: test.a * Int32(2) + test.c AS b, test.c + Projection: (test.a * Int32(2)) + test.c AS b, test.c TableScan: test ", ); // filter is before projection assert_optimized_plan_equal!( plan, - @r" - Projection: test.a * Int32(2) + test.c AS b, test.c - TableScan: test, full_filters=[test.a * Int32(2) + test.c = Int64(1)] + @" + Projection: (test.a * Int32(2)) + test.c AS b, test.c + TableScan: test, full_filters=[((test.a * Int32(2)) + test.c) = Int64(1)] " ) } @@ -2001,20 +2001,20 @@ mod tests { // not part of the test, just good to know: assert_snapshot!(plan, - @r" + @" Filter: a = Int64(1) Projection: b * Int32(3) AS a, test.c - Projection: test.a * Int32(2) + test.c AS b, test.c + Projection: (test.a * Int32(2)) + test.c AS b, test.c TableScan: test ", ); // filter is before the projections assert_optimized_plan_equal!( plan, - @r" + @" Projection: b * Int32(3) AS a, test.c - Projection: test.a * Int32(2) + test.c AS b, test.c - TableScan: test, full_filters=[(test.a * Int32(2) + test.c) * Int32(3) = Int64(1)] + Projection: (test.a * Int32(2)) + test.c AS b, test.c + TableScan: test, full_filters=[(((test.a * Int32(2)) + test.c) * Int32(3)) = Int64(1)] " ) } @@ -2216,8 +2216,8 @@ mod tests { // not part of the test, just good to know: assert_snapshot!(plan, - @r" - Filter: sum(test.c) > Int64(10) AND b > Int64(10) AND sum(test.c) < Int64(20) + @" + Filter: (sum(test.c) > Int64(10)) AND ((b > Int64(10)) AND (sum(test.c) < Int64(20))) Aggregate: groupBy=[[b]], aggr=[[sum(test.c)]] Projection: test.a AS b, test.c TableScan: test @@ -2226,8 +2226,8 @@ mod tests { // filter is before the projections assert_optimized_plan_equal!( plan, - @r" - Filter: sum(test.c) > Int64(10) AND sum(test.c) < Int64(20) + @" + Filter: (sum(test.c) > Int64(10)) AND (sum(test.c) < Int64(20)) Aggregate: groupBy=[[b]], aggr=[[sum(test.c)]] Projection: test.a AS b, test.c TableScan: test, full_filters=[test.a > Int64(10)] @@ -2430,9 +2430,9 @@ mod tests { ); assert_optimized_plan_equal!( plan, - @r" + @" Projection: test.a - Filter: test.a >= Int64(1) AND test.a <= Int64(1) + Filter: (test.a >= Int64(1)) AND (test.a <= Int64(1)) Limit: skip=0, fetch=1 TableScan: test " @@ -2829,8 +2829,8 @@ mod tests { // not part of the test, just good to know: assert_snapshot!(plan, - @r" - Inner Join: test.a = test2.a Filter: test.c > UInt32(1) AND test.b < test2.b AND test2.c > UInt32(4) + @" + Inner Join: test.a = test2.a Filter: ((test.c > UInt32(1)) AND (test.b < test2.b)) AND (test2.c > UInt32(4)) Projection: test.a, test.b, test.c TableScan: test Projection: test2.a, test2.b, test2.c @@ -2874,8 +2874,8 @@ mod tests { // not part of the test, just good to know: assert_snapshot!(plan, - @r" - Inner Join: test.a = test2.a Filter: test.b > UInt32(1) AND test2.c > UInt32(4) + @" + Inner Join: test.a = test2.a Filter: (test.b > UInt32(1)) AND (test2.c > UInt32(4)) Projection: test.a, test.b, test.c TableScan: test Projection: test2.a, test2.b, test2.c @@ -2963,8 +2963,8 @@ mod tests { // not part of the test, just good to know: assert_snapshot!(plan, - @r" - Left Join: test.a = test2.a Filter: test.a > UInt32(1) AND test.b < test2.b AND test2.c > UInt32(4) + @" + Left Join: test.a = test2.a Filter: ((test.a > UInt32(1)) AND (test.b < test2.b)) AND (test2.c > UInt32(4)) Projection: test.a, test.b, test.c TableScan: test Projection: test2.a, test2.b, test2.c @@ -2973,8 +2973,8 @@ mod tests { ); assert_optimized_plan_equal!( plan, - @r" - Left Join: test.a = test2.a Filter: test.a > UInt32(1) AND test.b < test2.b + @" + Left Join: test.a = test2.a Filter: (test.a > UInt32(1)) AND (test.b < test2.b) Projection: test.a, test.b, test.c TableScan: test Projection: test2.a, test2.b, test2.c @@ -3009,8 +3009,8 @@ mod tests { // not part of the test, just good to know: assert_snapshot!(plan, - @r" - Right Join: test.a = test2.a Filter: test.a > UInt32(1) AND test.b < test2.b AND test2.c > UInt32(4) + @" + Right Join: test.a = test2.a Filter: ((test.a > UInt32(1)) AND (test.b < test2.b)) AND (test2.c > UInt32(4)) Projection: test.a, test.b, test.c TableScan: test Projection: test2.a, test2.b, test2.c @@ -3019,8 +3019,8 @@ mod tests { ); assert_optimized_plan_equal!( plan, - @r" - Right Join: test.a = test2.a Filter: test.b < test2.b AND test2.c > UInt32(4) + @" + Right Join: test.a = test2.a Filter: (test.b < test2.b) AND (test2.c > UInt32(4)) Projection: test.a, test.b, test.c TableScan: test, full_filters=[test.a > UInt32(1)] Projection: test2.a, test2.b, test2.c @@ -3055,8 +3055,8 @@ mod tests { // not part of the test, just good to know: assert_snapshot!(plan, - @r" - Full Join: test.a = test2.a Filter: test.a > UInt32(1) AND test.b < test2.b AND test2.c > UInt32(4) + @" + Full Join: test.a = test2.a Filter: ((test.a > UInt32(1)) AND (test.b < test2.b)) AND (test2.c > UInt32(4)) Projection: test.a, test.b, test.c TableScan: test Projection: test2.a, test2.b, test2.c @@ -3065,8 +3065,8 @@ mod tests { ); assert_optimized_plan_equal!( plan, - @r" - Full Join: test.a = test2.a Filter: test.a > UInt32(1) AND test.b < test2.b AND test2.c > UInt32(4) + @" + Full Join: test.a = test2.a Filter: ((test.a > UInt32(1)) AND (test.b < test2.b)) AND (test2.c > UInt32(4)) Projection: test.a, test.b, test.c TableScan: test Projection: test2.a, test2.b, test2.c @@ -3205,9 +3205,9 @@ mod tests { assert_optimized_plan_equal!( plan, - @r" + @" Projection: a, b - Filter: a = Int64(10) AND b > Int64(11) + Filter: (a = Int64(10)) AND (b > Int64(11)) TableScan: test projection=[a], partial_filters=[a = Int64(10), b > Int64(11)] " ) @@ -3246,8 +3246,8 @@ mod tests { // filter on col b assert_snapshot!(plan, - @r" - Filter: b > Int64(10) AND test.c > Int64(10) + @" + Filter: (b > Int64(10)) AND (test.c > Int64(10)) Projection: test.a AS b, test.c TableScan: test ", @@ -3276,8 +3276,8 @@ mod tests { // filter on col b assert_snapshot!(plan, - @r" - Filter: b > Int64(10) AND test.c > Int64(10) + @" + Filter: (b > Int64(10)) AND (test.c > Int64(10)) Projection: b, test.c Projection: test.a AS b, test.c TableScan: test @@ -3304,8 +3304,8 @@ mod tests { // filter on col b and d assert_snapshot!(plan, - @r" - Filter: b > Int64(10) AND d > Int64(10) + @" + Filter: (b > Int64(10)) AND (d > Int64(10)) Projection: test.a AS b, test.c AS d TableScan: test ", @@ -3525,10 +3525,10 @@ mod tests { .filter(filter)? .build()?; - assert_optimized_plan_eq_with_rewrite_predicate!(plan.clone(), @r" - Inner Join: Filter: test.a = d AND test.b > UInt32(1) OR test.b = e AND test.c < UInt32(10) + assert_optimized_plan_eq_with_rewrite_predicate!(plan.clone(), @" + Inner Join: Filter: ((test.a = d) AND (test.b > UInt32(1))) OR ((test.b = e) AND (test.c < UInt32(10))) Projection: test.a, test.b, test.c - TableScan: test, full_filters=[test.b > UInt32(1) OR test.c < UInt32(10)] + TableScan: test, full_filters=[(test.b > UInt32(1)) OR (test.c < UInt32(10))] Projection: test1.a AS d, test1.a AS e TableScan: test1 ")?; @@ -3541,10 +3541,10 @@ mod tests { .data; assert_optimized_plan_equal!( optimized_plan, - @r" - Inner Join: Filter: test.a = d AND test.b > UInt32(1) OR test.b = e AND test.c < UInt32(10) + @" + Inner Join: Filter: ((test.a = d) AND (test.b > UInt32(1))) OR ((test.b = e) AND (test.c < UInt32(10))) Projection: test.a, test.b, test.c - TableScan: test, full_filters=[test.b > UInt32(1) OR test.c < UInt32(10)] + TableScan: test, full_filters=[(test.b > UInt32(1)) OR (test.c < UInt32(10))] Projection: test1.a AS d, test1.a AS e TableScan: test1 " @@ -3619,8 +3619,8 @@ mod tests { // not part of the test, just good to know: assert_snapshot!(plan, - @r" - LeftSemi Join: test1.a = test2.a Filter: test1.b > UInt32(1) AND test2.b > UInt32(2) + @" + LeftSemi Join: test1.a = test2.a Filter: (test1.b > UInt32(1)) AND (test2.b > UInt32(2)) TableScan: test1 Projection: test2.a, test2.b TableScan: test2 @@ -3706,8 +3706,8 @@ mod tests { // not part of the test, just good to know: assert_snapshot!(plan, - @r" - RightSemi Join: test1.a = test2.a Filter: test1.b > UInt32(1) AND test2.b > UInt32(2) + @" + RightSemi Join: test1.a = test2.a Filter: (test1.b > UInt32(1)) AND (test2.b > UInt32(2)) TableScan: test1 Projection: test2.a, test2.b TableScan: test2 @@ -3801,8 +3801,8 @@ mod tests { // not part of the test, just good to know: assert_snapshot!(plan, - @r" - LeftAnti Join: test1.a = test2.a Filter: test1.b > UInt32(1) AND test2.b > UInt32(2) + @" + LeftAnti Join: test1.a = test2.a Filter: (test1.b > UInt32(1)) AND (test2.b > UInt32(2)) Projection: test1.a, test1.b TableScan: test1 Projection: test2.a, test2.b @@ -3898,8 +3898,8 @@ mod tests { // not part of the test, just good to know: assert_snapshot!(plan, - @r" - RightAnti Join: test1.a = test2.a Filter: test1.b > UInt32(1) AND test2.b > UInt32(2) + @" + RightAnti Join: test1.a = test2.a Filter: (test1.b > UInt32(1)) AND (test2.b > UInt32(2)) Projection: test1.a, test1.b TableScan: test1 Projection: test2.a, test2.b @@ -3963,9 +3963,9 @@ mod tests { .build()?; assert_snapshot!(plan, - @r" + @" Projection: t.a, t.r - Filter: t.a > Int32(5) AND t.r > Float64(0.5) + Filter: (t.a > Int32(5)) AND (t.r > Float64(0.5)) SubqueryAlias: t Projection: test1.a, sum(test1.b), TestScalarUDF() + Int32(1) AS r Aggregate: groupBy=[[test1.a]], aggr=[[sum(test1.b)]] @@ -4085,8 +4085,8 @@ mod tests { .build()?; assert_snapshot!(plan, - @r" - Filter: TestScalarUDF() > Float64(0.1) AND t.a > Int32(5) AND t.b > Int32(10) + @" + Filter: ((TestScalarUDF() > Float64(0.1)) AND (t.a > Int32(5))) AND (t.b > Int32(10)) Projection: test.a, test.b TableScan: test ", @@ -4122,17 +4122,17 @@ mod tests { .build()?; assert_snapshot!(plan, - @r" - Filter: TestScalarUDF() > Float64(0.1) AND t.a > Int32(5) AND t.b > Int32(10) + @" + Filter: ((TestScalarUDF() > Float64(0.1)) AND (t.a > Int32(5))) AND (t.b > Int32(10)) Projection: a, b TableScan: test ", ); assert_optimized_plan_equal!( plan, - @r" + @" Projection: a, b - Filter: t.a > Int32(5) AND t.b > Int32(10) AND TestScalarUDF() > Float64(0.1) + Filter: ((t.a > Int32(5)) AND (t.b > Int32(10))) AND (TestScalarUDF() > Float64(0.1)) TableScan: test " ) diff --git a/datafusion/optimizer/src/scalar_subquery_to_join.rs b/datafusion/optimizer/src/scalar_subquery_to_join.rs index 975c234b38836..0da69faaf9b37 100644 --- a/datafusion/optimizer/src/scalar_subquery_to_join.rs +++ b/datafusion/optimizer/src/scalar_subquery_to_join.rs @@ -455,10 +455,10 @@ mod tests { assert_optimized_plan_equal!( plan, - @r" + @" Projection: customer.c_custkey [c_custkey:Int64] Projection: customer.c_custkey, customer.c_name [c_custkey:Int64, c_name:Utf8] - 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] + 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] @@ -730,13 +730,13 @@ mod tests { // Unsupported predicate, subquery should not be decorrelated assert_optimized_plan_equal!( plan, - @r" + @" Projection: customer.c_custkey [c_custkey:Int64] Filter: customer.c_custkey = () [c_custkey:Int64, 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] + 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] " @@ -887,10 +887,10 @@ mod tests { assert_optimized_plan_equal!( plan, - @r" + @" Projection: customer.c_custkey [c_custkey:Int64] Projection: customer.c_custkey, customer.c_name [c_custkey:Int64, c_name:Utf8] - 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] + 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] @@ -925,10 +925,10 @@ mod tests { assert_optimized_plan_equal!( plan, - @r" + @" Projection: customer.c_custkey [c_custkey:Int64] Projection: customer.c_custkey, customer.c_name [c_custkey:Int64, c_name:Utf8] - 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] + 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] @@ -964,10 +964,10 @@ mod tests { assert_optimized_plan_equal!( plan, - @r" + @" Projection: customer.c_custkey [c_custkey:Int64] Projection: customer.c_custkey, customer.c_name [c_custkey:Int64, c_name:Utf8] - 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] + 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] diff --git a/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs b/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs index f7f100015004a..9ff6f576ffc1e 100644 --- a/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs +++ b/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs @@ -290,8 +290,8 @@ mod tests { assert_optimized_plan_equal!( plan, - @ r" - Filter: test.a > Int32(5) AND test.b < Int32(6) + @ " + Filter: (test.a > Int32(5)) AND (test.b < Int32(6)) Projection: test.a, test.b TableScan: test " @@ -525,8 +525,8 @@ mod tests { assert_optimized_plan_equal!( plan, - @ r" - Filter: test.d <= Int32(10) OR test.d >= Int32(100) + @ " + Filter: (test.d <= Int32(10)) OR (test.d >= Int32(100)) TableScan: test " ) @@ -542,8 +542,8 @@ mod tests { assert_optimized_plan_equal!( plan, - @ r" - Filter: test.d <= Int32(10) AND test.d >= Int32(100) + @ " + Filter: (test.d <= Int32(10)) AND (test.d >= Int32(100)) TableScan: test " ) @@ -610,8 +610,8 @@ mod tests { assert_optimized_plan_equal!( plan, - @ r" - Filter: test.d != Int32(1) AND test.d != Int32(2) AND test.d != Int32(3) + @ " + Filter: ((test.d != Int32(1)) AND (test.d != Int32(2))) AND (test.d != Int32(3)) TableScan: test " ) @@ -627,8 +627,8 @@ mod tests { assert_optimized_plan_equal!( plan, - @ r" - Filter: test.d = Int32(1) OR test.d = Int32(2) OR test.d = Int32(3) + @ " + Filter: ((test.d = Int32(1)) OR (test.d = Int32(2))) OR (test.d = Int32(3)) TableScan: test " ) @@ -645,8 +645,8 @@ mod tests { assert_optimized_plan_equal!( plan, - @ r" - Filter: test.d < Int32(1) OR test.d > Int32(10) + @ " + Filter: (test.d < Int32(1)) OR (test.d > Int32(10)) TableScan: test " ) @@ -663,8 +663,8 @@ mod tests { assert_optimized_plan_equal!( plan, - @ r" - Filter: test.d >= Int32(1) AND test.d <= Int32(10) + @ " + Filter: (test.d >= Int32(1)) AND (test.d <= Int32(10)) TableScan: test " ) @@ -937,7 +937,7 @@ mod tests { assert_optimized_plan_equal!( plan, @ r#" - Filter: test.a != Utf8("a") AND test.a != Utf8("b") + Filter: (test.a != Utf8("a")) AND (test.a != Utf8("b")) TableScan: test "# ) @@ -960,7 +960,7 @@ mod tests { assert_optimized_plan_equal!( plan, @ r#" - Filter: test.a = Utf8("a") OR test.a = Utf8("b") + Filter: (test.a = Utf8("a")) OR (test.a = Utf8("b")) TableScan: test "# ) diff --git a/datafusion/optimizer/tests/optimizer_integration.rs b/datafusion/optimizer/tests/optimizer_integration.rs index 36a6df54ddaf0..745bcc4dbb3fb 100644 --- a/datafusion/optimizer/tests/optimizer_integration.rs +++ b/datafusion/optimizer/tests/optimizer_integration.rs @@ -134,7 +134,7 @@ fn subquery_filter_with_cast() -> Result<()> { SubqueryAlias: __scalar_sq_1 Aggregate: groupBy=[[]], aggr=[[avg(CAST(test.col_int32 AS Float64))]] Projection: test.col_int32 - Filter: __common_expr_4 >= Date32("2002-05-08") AND __common_expr_4 <= Date32("2002-05-13") + Filter: (__common_expr_4 >= Date32("2002-05-08")) AND (__common_expr_4 <= Date32("2002-05-13")) Projection: CAST(test.col_utf8 AS Date32) AS __common_expr_4, test.col_int32 TableScan: test projection=[col_int32, col_utf8] "# @@ -295,7 +295,7 @@ fn between_date32_plus_interval() -> Result<()> { @r#" Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]] Projection: - Filter: test.col_date32 >= Date32("1998-03-18") AND test.col_date32 <= Date32("1998-06-16") + Filter: (test.col_date32 >= Date32("1998-03-18")) AND (test.col_date32 <= Date32("1998-06-16")) TableScan: test projection=[col_date32] "# ); @@ -313,7 +313,7 @@ fn between_date64_plus_interval() -> Result<()> { @r#" Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]] Projection: - Filter: test.col_date64 >= Date64("1998-03-18") AND test.col_date64 <= Date64("1998-06-16") + Filter: (test.col_date64 >= Date64("1998-03-18")) AND (test.col_date64 <= Date64("1998-06-16")) TableScan: test projection=[col_date64] "# ); @@ -383,10 +383,10 @@ fn push_down_filter_groupby_expr_contains_alias() { assert_snapshot!( format!("{plan}"), - @r" + @" Projection: test.col_int32 + test.col_uint32 AS c, count(Int64(1)) AS count(*) Aggregate: groupBy=[[CAST(test.col_int32 AS Int64) + CAST(test.col_uint32 AS Int64)]], aggr=[[count(Int64(1))]] - Filter: CAST(test.col_int32 AS Int64) + CAST(test.col_uint32 AS Int64) > Int64(3) + Filter: (CAST(test.col_int32 AS Int64) + CAST(test.col_uint32 AS Int64)) > Int64(3) TableScan: test projection=[col_int32, col_uint32] " ); diff --git a/datafusion/sql/tests/cases/params.rs b/datafusion/sql/tests/cases/params.rs index 396f619400c74..336cd12d8cd80 100644 --- a/datafusion/sql/tests/cases/params.rs +++ b/datafusion/sql/tests/cases/params.rs @@ -341,7 +341,7 @@ fn test_prepare_statement_to_plan_params_as_constants() { plan, @r#" Prepare: "my_plan" [Int32, Float64] - Projection: Int64(1) + $1 + $2 + Projection: (Int64(1) + $1) + $2 EmptyRelation: rows=1 "# ); @@ -356,8 +356,8 @@ fn test_prepare_statement_to_plan_params_as_constants() { let plan_with_params = plan.with_param_values(param_values).unwrap(); assert_snapshot!( plan_with_params, - @r" - Projection: Int64(1) + Int32(10) + Float64(10) AS Int64(1) + $1 + $2 + @" + Projection: (Int64(1) + Int32(10)) + Float64(10) AS Int64(1) + $1 + $2 EmptyRelation: rows=1 " ); @@ -373,15 +373,15 @@ fn test_infer_types_from_join() { assert_snapshot!( test.run(), - @r" + @" ** Initial Plan: Projection: person.id, orders.order_id - Inner Join: Filter: person.id = orders.customer_id AND person.age = $1 + Inner Join: Filter: (person.id = orders.customer_id) AND (person.age = $1) TableScan: person TableScan: orders ** Final Plan: Projection: person.id, orders.order_id - Inner Join: Filter: person.id = orders.customer_id AND person.age = Int32(10) + Inner Join: Filter: (person.id = orders.customer_id) AND (person.age = Int32(10)) TableScan: person TableScan: orders " @@ -402,12 +402,12 @@ fn test_prepare_statement_infer_types_from_join() { ** Initial Plan: Prepare: "my_plan" [Int32] Projection: person.id, orders.order_id - Inner Join: Filter: person.id = orders.customer_id AND person.age = $1 + Inner Join: Filter: (person.id = orders.customer_id) AND (person.age = $1) TableScan: person TableScan: orders ** Final Plan: Projection: person.id, orders.order_id - Inner Join: Filter: person.id = orders.customer_id AND person.age = Int32(10) + Inner Join: Filter: (person.id = orders.customer_id) AND (person.age = Int32(10)) TableScan: person TableScan: orders "# @@ -914,7 +914,7 @@ fn test_prepare_statement_to_plan_multi_params() { @r#" Prepare: "my_plan" [Int32, Utf8View, Float64, Int32, Float64, Utf8View] Projection: person.id, person.age, $6 - Filter: person.age IN ([$1, $4]) AND person.salary > $3 AND person.salary < $5 OR person.first_name < $2 + Filter: ((person.age IN ([$1, $4]) AND (person.salary > $3)) AND (person.salary < $5)) OR (person.first_name < $2) TableScan: person "# ); @@ -936,7 +936,7 @@ fn test_prepare_statement_to_plan_multi_params() { plan_with_params, @r#" Projection: person.id, person.age, Utf8View("xyz") AS $6 - Filter: person.age IN ([Int32(10), Int32(20)]) AND person.salary > Float64(100) AND person.salary < Float64(200) OR person.first_name < Utf8View("abc") + Filter: ((person.age IN ([Int32(10), Int32(20)]) AND (person.salary > Float64(100))) AND (person.salary < Float64(200))) OR (person.first_name < Utf8View("abc")) TableScan: person "# ); @@ -957,7 +957,7 @@ fn test_prepare_statement_to_plan_having() { @r#" Prepare: "my_plan" [Int32, Float64, Float64, Float64] Projection: person.id, sum(person.age) - Filter: sum(person.age) < $1 AND sum(person.age) > Int64(10) OR sum(person.age) IN ([$3, $4]) + Filter: ((sum(person.age) < $1) AND (sum(person.age) > Int64(10))) OR sum(person.age) IN ([$3, $4]) Aggregate: groupBy=[[person.id]], aggr=[[sum(person.age)]] Filter: person.salary > $2 TableScan: person @@ -977,9 +977,9 @@ fn test_prepare_statement_to_plan_having() { let plan_with_params = plan.with_param_values(param_values).unwrap(); assert_snapshot!( plan_with_params, - @r" + @" Projection: person.id, sum(person.age) - Filter: sum(person.age) < Int32(10) AND sum(person.age) > Int64(10) OR sum(person.age) IN ([Float64(200), Float64(300)]) + Filter: ((sum(person.age) < Int32(10)) AND (sum(person.age) > Int64(10))) OR sum(person.age) IN ([Float64(200), Float64(300)]) Aggregate: groupBy=[[person.id]], aggr=[[sum(person.age)]] Filter: person.salary > Float64(100) TableScan: person diff --git a/datafusion/sql/tests/cases/plan_to_sql.rs b/datafusion/sql/tests/cases/plan_to_sql.rs index 46a42ae534af0..e6a068cbf1c43 100644 --- a/datafusion/sql/tests/cases/plan_to_sql.rs +++ b/datafusion/sql/tests/cases/plan_to_sql.rs @@ -1383,18 +1383,12 @@ fn test_pretty_roundtrip() -> Result<()> { let round_trip_sql = unparser.expr_to_sql(&expr)?.to_string(); assert_eq!((*pretty).to_string(), round_trip_sql); - // verify that the pretty string parses to the same underlying Expr - let pretty_sql_expr = Parser::new(&GenericDialect {}) - .try_with_sql(pretty)? - .parse_expr()?; - - let pretty_expr = sql_to_rel.sql_to_expr( - pretty_sql_expr, - &df_schema, - &mut PlannerContext::new(), - )?; - - assert_eq!(expr.to_string(), pretty_expr.to_string()); + // Note: We don't verify that the pretty string parses to the same + // underlying Expr because the pretty unparser intentionally removes + // "unnecessary" parentheses which can change the associativity of + // expressions (e.g., "3 + (5 + 6)" becomes "3 + 5 + 6" which parses + // as "(3 + 5) + 6"). The expressions are semantically equivalent for + // associative operations but structurally different. } Ok(()) diff --git a/datafusion/sql/tests/sql_integration.rs b/datafusion/sql/tests/sql_integration.rs index 491873b4afe02..b9b1715fedb79 100644 --- a/datafusion/sql/tests/sql_integration.rs +++ b/datafusion/sql/tests/sql_integration.rs @@ -863,7 +863,7 @@ fn select_compound_filter() { plan, @r#" Projection: person.id, person.first_name, person.last_name - Filter: person.state = Utf8("CO") AND person.age >= Int64(21) AND person.age <= Int64(65) + Filter: ((person.state = Utf8("CO")) AND (person.age >= Int64(21))) AND (person.age <= Int64(65)) TableScan: person "# ); @@ -910,9 +910,9 @@ fn select_all_boolean_operators() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.age, person.first_name, person.last_name - Filter: person.age = Int64(21) AND person.age != Int64(21) AND person.age > Int64(21) AND person.age >= Int64(21) AND person.age < Int64(65) AND person.age <= Int64(65) + Filter: (((((person.age = Int64(21)) AND (person.age != Int64(21))) AND (person.age > Int64(21))) AND (person.age >= Int64(21))) AND (person.age < Int64(65))) AND (person.age <= Int64(65)) TableScan: person " ); @@ -984,7 +984,7 @@ fn select_nested_with_filters() { plan, @r#" Projection: a.fn1, a.age - Filter: a.fn1 = Utf8("X") AND a.age < Int64(30) + Filter: (a.fn1 = Utf8("X")) AND (a.age < Int64(30)) SubqueryAlias: a Projection: person.first_name AS fn1, person.age Filter: person.age > Int64(20) @@ -1093,7 +1093,7 @@ fn select_with_having() { assert_snapshot!( err.strip_backtrace(), - @"Error during planning: HAVING clause references: person.age > Int64(100) AND person.age < Int64(200) must appear in the GROUP BY clause or be used in an aggregate function" + @"Error during planning: HAVING clause references: (person.age > Int64(100)) AND (person.age < Int64(200)) must appear in the GROUP BY clause or be used in an aggregate function" ); } @@ -1280,11 +1280,11 @@ fn select_aggregate_with_group_by_with_having_and_where_filtering_on_aggregate_c let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.first_name, max(person.age) Filter: max(person.age) < Int64(100) Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] - Filter: person.id > Int64(5) AND person.age > Int64(18) + Filter: (person.id > Int64(5)) AND (person.age > Int64(18)) TableScan: person " ); @@ -1301,7 +1301,7 @@ fn select_aggregate_with_group_by_with_having_using_column_by_alias() { plan, @r#" Projection: person.first_name AS fn, max(person.age) - Filter: max(person.age) > Int64(2) AND person.first_name = Utf8("M") + Filter: (max(person.age) > Int64(2)) AND (person.first_name = Utf8("M")) Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] TableScan: person "# @@ -1320,7 +1320,7 @@ fn select_aggregate_with_group_by_with_having_using_columns_with_and_without_the plan, @r#" Projection: person.first_name AS fn, max(person.age) AS max_age - Filter: max(person.age) > Int64(2) AND max(person.age) < Int64(5) AND person.first_name = Utf8("M") AND person.first_name = Utf8("N") + Filter: (((max(person.age) > Int64(2)) AND (max(person.age) < Int64(5))) AND (person.first_name = Utf8("M"))) AND (person.first_name = Utf8("N")) Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] TableScan: person "# @@ -1368,9 +1368,9 @@ fn select_aggregate_with_group_by_with_having_that_reuses_aggregate_multiple_tim let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.first_name, max(person.age) - Filter: max(person.age) > Int64(100) AND max(person.age) < Int64(200) + Filter: (max(person.age) > Int64(100)) AND (max(person.age) < Int64(200)) Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] TableScan: person " @@ -1386,9 +1386,9 @@ fn select_aggregate_with_group_by_with_having_using_aggregate_not_in_select() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.first_name, max(person.age) - Filter: max(person.age) > Int64(100) AND min(person.id) < Int64(50) + Filter: (max(person.age) > Int64(100)) AND (min(person.id) < Int64(50)) Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age), min(person.id)]] TableScan: person " @@ -1424,9 +1424,9 @@ fn select_aggregate_compound_aliased_with_group_by_with_having_referencing_compo let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.first_name, max(person.age) + Int64(1) AS max_age_plus_one - Filter: max(person.age) + Int64(1) > Int64(100) + Filter: (max(person.age) + Int64(1)) > Int64(100) Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] TableScan: person " @@ -1443,9 +1443,9 @@ fn select_aggregate_with_group_by_with_having_using_derived_column_aggregate_not let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.first_name, max(person.age) - Filter: max(person.age) > Int64(100) AND min(person.id - Int64(2)) < Int64(50) + Filter: (max(person.age) > Int64(100)) AND (min(person.id - Int64(2)) < Int64(50)) Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age), min(person.id - Int64(2))]] TableScan: person " @@ -1461,9 +1461,9 @@ fn select_aggregate_with_group_by_with_having_using_count_star_not_in_select() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.first_name, max(person.age) - Filter: max(person.age) > Int64(100) AND count(*) < Int64(50) + Filter: (max(person.age) > Int64(100)) AND (count(*) < Int64(50)) Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age), count(*)]] TableScan: person " @@ -1821,8 +1821,8 @@ fn select_simple_aggregate_with_groupby_non_column_expression_nested_and_resolva ).unwrap(); assert_snapshot!( plan, - @r" - Projection: person.age + Int64(1) / Int64(2) * person.age + Int64(1), min(person.first_name) + @" + Projection: (person.age + Int64(1) / Int64(2)) * person.age + Int64(1), min(person.first_name) Aggregate: groupBy=[[person.age + Int64(1)]], aggr=[[min(person.first_name)]] TableScan: person " @@ -1983,9 +1983,9 @@ fn select_where_nullif_division() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: aggregate_test_100.c3 / (aggregate_test_100.c4 + aggregate_test_100.c5) - Filter: aggregate_test_100.c3 / nullif(aggregate_test_100.c4 + aggregate_test_100.c5, Int64(0)) > Float64(0.1) + Filter: (aggregate_test_100.c3 / nullif(aggregate_test_100.c4 + aggregate_test_100.c5, Int64(0))) > Float64(0.1) TableScan: aggregate_test_100 " ); @@ -1997,9 +1997,9 @@ fn select_where_with_negative_operator() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: aggregate_test_100.c3 - Filter: aggregate_test_100.c3 > Float64(-0.1) AND (- aggregate_test_100.c4) > Int64(0) + Filter: (aggregate_test_100.c3 > Float64(-0.1)) AND ((- aggregate_test_100.c4) > Int64(0)) TableScan: aggregate_test_100 " ); @@ -2011,9 +2011,9 @@ fn select_where_with_positive_operator() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: aggregate_test_100.c3 - Filter: aggregate_test_100.c3 > Float64(0.1) AND aggregate_test_100.c4 > Int64(0) + Filter: (aggregate_test_100.c3 > Float64(0.1)) AND (aggregate_test_100.c4 > Int64(0)) TableScan: aggregate_test_100 " ); @@ -2413,9 +2413,9 @@ fn equijoin_with_condition() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id, orders.order_id - Inner Join: Filter: person.id = orders.customer_id AND orders.order_id > Int64(1) + Inner Join: Filter: (person.id = orders.customer_id) AND (orders.order_id > Int64(1)) TableScan: person TableScan: orders " @@ -2431,9 +2431,9 @@ fn left_equijoin_with_conditions() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id, orders.order_id - Left Join: Filter: person.id = orders.customer_id AND orders.order_id > Int64(1) AND person.age < Int64(30) + Left Join: Filter: ((person.id = orders.customer_id) AND (orders.order_id > Int64(1))) AND (person.age < Int64(30)) TableScan: person TableScan: orders " @@ -2449,9 +2449,9 @@ fn right_equijoin_with_conditions() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id, orders.order_id - Right Join: Filter: person.id = orders.customer_id AND person.id > Int64(1) AND orders.order_id < Int64(100) + Right Join: Filter: ((person.id = orders.customer_id) AND (person.id > Int64(1))) AND (orders.order_id < Int64(100)) TableScan: person TableScan: orders " @@ -2467,9 +2467,9 @@ fn full_equijoin_with_conditions() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id, orders.order_id - Full Join: Filter: person.id = orders.customer_id AND person.id > Int64(1) AND orders.order_id < Int64(100) + Full Join: Filter: ((person.id = orders.customer_id) AND (person.id > Int64(1))) AND (orders.order_id < Int64(100)) TableScan: person TableScan: orders " @@ -2541,9 +2541,9 @@ fn boolean_literal_in_condition_expression() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: orders.order_id - Filter: orders.delivered = Boolean(false) OR orders.delivered = Boolean(true) + Filter: (orders.delivered = Boolean(false)) OR (orders.delivered = Boolean(true)) TableScan: orders " ); @@ -3441,7 +3441,7 @@ fn complex_interval_expression_in_projection() { assert_snapshot!( plan, @r#" - Projection: IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: -2, nanoseconds: 0 }") + IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }") + IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: -3, nanoseconds: 0 }") + IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }") + Projection: (IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: -2, nanoseconds: 0 }") + IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }")) + (IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: -3, nanoseconds: 0 }") + IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }")) EmptyRelation: rows=1 "# ); @@ -3454,7 +3454,7 @@ fn negative_sum_intervals_in_projection() { assert_snapshot!( plan, @r#" - Projection: (- IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 2, nanoseconds: 0 }") + IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }") + (- IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 4, nanoseconds: 0 }") + IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 7, nanoseconds: 0 }"))) + Projection: (- (IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 2, nanoseconds: 0 }") + IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }")) + (- IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 4, nanoseconds: 0 }") + IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 7, nanoseconds: 0 }"))) EmptyRelation: rows=1 "# ); @@ -3499,12 +3499,12 @@ fn exists_subquery() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: p.id Filter: EXISTS () Subquery: Projection: person.first_name - Filter: person.last_name = outer_ref(p.last_name) AND person.state = outer_ref(p.state) + Filter: (person.last_name = outer_ref(p.last_name)) AND (person.state = outer_ref(p.state)) TableScan: person SubqueryAlias: p TableScan: person @@ -3524,12 +3524,12 @@ fn exists_subquery_schema_outer_schema_overlap() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id - Filter: person.id = p.id AND EXISTS () + Filter: (person.id = p.id) AND EXISTS () Subquery: Projection: person.first_name - Filter: person.id = p2.id AND person.last_name = outer_ref(p.last_name) AND person.state = outer_ref(p.state) + Filter: ((person.id = p2.id) AND (person.last_name = outer_ref(p.last_name))) AND (person.state = outer_ref(p.state)) Cross Join: TableScan: person SubqueryAlias: p2 @@ -3573,7 +3573,7 @@ fn not_in_subquery_correlated() { Filter: p.id NOT IN () Subquery: Projection: person.id - Filter: person.last_name = outer_ref(p.last_name) AND person.state = Utf8("CO") + Filter: (person.last_name = outer_ref(p.last_name)) AND (person.state = Utf8("CO")) TableScan: person SubqueryAlias: p TableScan: person @@ -3612,13 +3612,13 @@ fn scalar_subquery_reference_outer_field() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: j1.j1_string, j2.j2_string - Filter: j1.j1_id = j2.j2_id - Int64(1) AND j2.j2_id < () + Filter: (j1.j1_id = (j2.j2_id - Int64(1))) AND (j2.j2_id < ()) Subquery: Projection: count(*) Aggregate: groupBy=[[]], aggr=[[count(*)]] - Filter: outer_ref(j2.j2_id) = j1.j1_id AND j1.j1_id = j3.j3_id + Filter: (outer_ref(j2.j2_id) = j1.j1_id) AND (j1.j1_id = j3.j3_id) Cross Join: TableScan: j1 TableScan: j3 @@ -3736,9 +3736,9 @@ fn join_on_disjunction_condition() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id, orders.order_id - Inner Join: Filter: person.id = orders.customer_id OR person.age > Int64(30) + Inner Join: Filter: (person.id = orders.customer_id) OR (person.age > Int64(30)) TableScan: person TableScan: orders " @@ -3755,7 +3755,7 @@ fn join_on_complex_condition() { plan, @r#" Projection: person.id, orders.order_id - Inner Join: Filter: person.id = orders.customer_id AND (person.age > Int64(30) OR person.last_name = Utf8("X")) + Inner Join: Filter: (person.id = orders.customer_id) AND ((person.age > Int64(30)) OR (person.last_name = Utf8("X"))) TableScan: person TableScan: orders "# @@ -3961,9 +3961,9 @@ fn test_right_left_expr_eq_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id, orders.order_id - Inner Join: Filter: orders.customer_id * Int64(2) = person.id + Int64(10) + Inner Join: Filter: (orders.customer_id * Int64(2)) = (person.id + Int64(10)) TableScan: person TableScan: orders " @@ -3979,9 +3979,9 @@ fn test_single_column_expr_eq_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id, orders.order_id - Inner Join: Filter: person.id + Int64(10) = orders.customer_id * Int64(2) + Inner Join: Filter: (person.id + Int64(10)) = (orders.customer_id * Int64(2)) TableScan: person TableScan: orders " @@ -3997,9 +3997,9 @@ fn test_multiple_column_expr_eq_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id, orders.order_id - Inner Join: Filter: person.id + person.age + Int64(10) = orders.customer_id * Int64(2) - orders.price + Inner Join: Filter: ((person.id + person.age) + Int64(10)) = ((orders.customer_id * Int64(2)) - orders.price) TableScan: person TableScan: orders " @@ -4015,9 +4015,9 @@ fn test_left_expr_eq_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id, orders.order_id - Inner Join: Filter: person.id + person.age + Int64(10) = orders.customer_id + Inner Join: Filter: ((person.id + person.age) + Int64(10)) = orders.customer_id TableScan: person TableScan: orders " @@ -4033,9 +4033,9 @@ fn test_right_expr_eq_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id, orders.order_id - Inner Join: Filter: person.id = orders.customer_id * Int64(2) - orders.price + Inner Join: Filter: person.id = ((orders.customer_id * Int64(2)) - orders.price) TableScan: person TableScan: orders " @@ -4131,9 +4131,9 @@ fn test_select_join_key_inner_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: orders.customer_id * Int64(2), person.id + Int64(10) - Inner Join: Filter: orders.customer_id * Int64(2) = person.id + Int64(10) + Inner Join: Filter: (orders.customer_id * Int64(2)) = (person.id + Int64(10)) TableScan: person TableScan: orders " @@ -4198,9 +4198,9 @@ fn test_select_qualify_aggregate_reference() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id, row_number() PARTITION BY [person.id] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS rn - Filter: row_number() PARTITION BY [person.id] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW = Int64(1) AND sum(person.age) > Int64(0) + Filter: (row_number() PARTITION BY [person.id] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW = Int64(1)) AND (sum(person.age) > Int64(0)) WindowAggr: windowExpr=[[row_number() PARTITION BY [person.id] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] Aggregate: groupBy=[[person.id]], aggr=[[sum(person.age)]] TableScan: person @@ -4262,9 +4262,9 @@ fn test_select_qualify_complex_condition() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id, person.age, row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS rn, rank() ORDER BY [person.salary ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS rank - Filter: row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW <= Int64(2) AND rank() ORDER BY [person.salary ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW <= Int64(5) + Filter: (row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW <= Int64(2)) AND (rank() ORDER BY [person.salary ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW <= Int64(5)) WindowAggr: windowExpr=[[rank() ORDER BY [person.salary ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] WindowAggr: windowExpr=[[row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] TableScan: person @@ -4331,9 +4331,9 @@ fn test_duplicated_left_join_key_inner_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id, person.age - Inner Join: Filter: person.id * Int64(2) = orders.customer_id + Int64(10) AND person.id * Int64(2) = orders.order_id + Inner Join: Filter: ((person.id * Int64(2)) = (orders.customer_id + Int64(10))) AND ((person.id * Int64(2)) = orders.order_id) TableScan: person TableScan: orders " @@ -4350,9 +4350,9 @@ fn test_duplicated_right_join_key_inner_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r" + @" Projection: person.id, person.age - Inner Join: Filter: person.id * Int64(2) = orders.customer_id + Int64(10) AND person.id = orders.customer_id + Int64(10) + Inner Join: Filter: ((person.id * Int64(2)) = (orders.customer_id + Int64(10))) AND (person.id = (orders.customer_id + Int64(10))) TableScan: person TableScan: orders " diff --git a/datafusion/sqllogictest/test_files/aggregate.slt b/datafusion/sqllogictest/test_files/aggregate.slt index a5f3ef04139f4..5f529cf089737 100644 --- a/datafusion/sqllogictest/test_files/aggregate.slt +++ b/datafusion/sqllogictest/test_files/aggregate.slt @@ -6423,7 +6423,7 @@ logical_plan 02)--Aggregate: groupBy=[[aggregate_test_100.c3]], aggr=[[]] 03)----Projection: aggregate_test_100.c3 04)------Aggregate: groupBy=[[aggregate_test_100.c2, aggregate_test_100.c3]], aggr=[[]] -05)--------Filter: aggregate_test_100.c3 >= Int16(10) AND aggregate_test_100.c3 <= Int16(20) +05)--------Filter: (aggregate_test_100.c3 >= Int16(10)) AND (aggregate_test_100.c3 <= Int16(20)) 06)----------TableScan: aggregate_test_100 projection=[c2, c3], partial_filters=[aggregate_test_100.c3 >= Int16(10), aggregate_test_100.c3 <= Int16(20)] physical_plan 01)GlobalLimitExec: skip=0, fetch=4 diff --git a/datafusion/sqllogictest/test_files/cse.slt b/datafusion/sqllogictest/test_files/cse.slt index 1af4f14c937e7..ed8413d1a22c9 100644 --- a/datafusion/sqllogictest/test_files/cse.slt +++ b/datafusion/sqllogictest/test_files/cse.slt @@ -72,7 +72,7 @@ EXPLAIN SELECT FROM t1 ---- logical_plan -01)Projection: __common_expr_1 + random() + __common_expr_2 AS c1, __common_expr_1 + random() + __common_expr_2 AS c2 +01)Projection: (__common_expr_1 + random()) + __common_expr_2 AS c1, (__common_expr_1 + random()) + __common_expr_2 AS c2 02)--Projection: t1.a + Float64(1) AS __common_expr_1, t1.a + Float64(2) AS __common_expr_2 03)----TableScan: t1 projection=[a] physical_plan @@ -93,7 +93,7 @@ FROM t1 ---- logical_plan 01)Projection: __common_expr_1 AS c1, __common_expr_1 AS c2, __common_expr_2 AS c3, __common_expr_2 AS c4, __common_expr_3 AS c5, __common_expr_3 AS c6 -02)--Projection: __common_expr_4 AND t1.b = Float64(0) AS __common_expr_1, __common_expr_4 OR t1.b = Float64(0) AS __common_expr_2, CASE WHEN __common_expr_4 THEN Int64(0) ELSE Int64(1) END AS __common_expr_3 +02)--Projection: __common_expr_4 AND (t1.b = Float64(0)) AS __common_expr_1, __common_expr_4 OR (t1.b = Float64(0)) AS __common_expr_2, CASE WHEN __common_expr_4 THEN Int64(0) ELSE Int64(1) END AS __common_expr_3 03)----Projection: t1.a = Float64(0) AS __common_expr_4, t1.b 04)------TableScan: t1 projection=[a, b] physical_plan @@ -122,7 +122,7 @@ EXPLAIN SELECT FROM t1 ---- logical_plan -01)Projection: __common_expr_1 AND t1.b = Float64(0) AS c1, __common_expr_1 AND t1.b = Float64(1) AS c2, t1.b = Float64(2) AND t1.a = Float64(1) AS c3, t1.b = Float64(3) AND t1.a = Float64(1) AS c4, __common_expr_2 OR t1.b = Float64(4) AS c5, __common_expr_2 OR t1.b = Float64(5) AS c6, t1.b = Float64(6) OR t1.a = Float64(3) AS c7, t1.b = Float64(7) OR t1.a = Float64(3) AS c8, CASE WHEN __common_expr_3 THEN Int64(0) ELSE Int64(1) END AS c9, CASE WHEN __common_expr_3 THEN Int64(0) ELSE Int64(2) END AS c10, CASE WHEN t1.b = Float64(8) THEN t1.a + Float64(1) ELSE Float64(0) END AS c11, CASE WHEN t1.b = Float64(9) THEN t1.a + Float64(1) ELSE Float64(0) END AS c12, CASE WHEN t1.b = Float64(10) THEN Float64(0) ELSE t1.a + Float64(2) END AS c13, CASE WHEN t1.b = Float64(11) THEN Float64(0) ELSE t1.a + Float64(2) END AS c14 +01)Projection: __common_expr_1 AND (t1.b = Float64(0)) AS c1, __common_expr_1 AND (t1.b = Float64(1)) AS c2, (t1.b = Float64(2)) AND (t1.a = Float64(1)) AS c3, (t1.b = Float64(3)) AND (t1.a = Float64(1)) AS c4, __common_expr_2 OR (t1.b = Float64(4)) AS c5, __common_expr_2 OR (t1.b = Float64(5)) AS c6, (t1.b = Float64(6)) OR (t1.a = Float64(3)) AS c7, (t1.b = Float64(7)) OR (t1.a = Float64(3)) AS c8, CASE WHEN __common_expr_3 THEN Int64(0) ELSE Int64(1) END AS c9, CASE WHEN __common_expr_3 THEN Int64(0) ELSE Int64(2) END AS c10, CASE WHEN t1.b = Float64(8) THEN t1.a + Float64(1) ELSE Float64(0) END AS c11, CASE WHEN t1.b = Float64(9) THEN t1.a + Float64(1) ELSE Float64(0) END AS c12, CASE WHEN t1.b = Float64(10) THEN Float64(0) ELSE t1.a + Float64(2) END AS c13, CASE WHEN t1.b = Float64(11) THEN Float64(0) ELSE t1.a + Float64(2) END AS c14 02)--Projection: t1.a = Float64(0) AS __common_expr_1, t1.a = Float64(2) AS __common_expr_2, t1.a = Float64(4) AS __common_expr_3, t1.a, t1.b 03)----TableScan: t1 projection=[a, b] physical_plan @@ -150,7 +150,7 @@ EXPLAIN SELECT FROM t1 ---- logical_plan -01)Projection: __common_expr_1 AND t1.b = random() AS c1, __common_expr_1 AND t1.b = Float64(1) + random() AS c2, t1.b = Float64(2) + random() AND t1.a = Float64(1) AS c3, t1.b = Float64(3) + random() AND t1.a = Float64(1) AS c4, __common_expr_2 OR t1.b = Float64(4) + random() AS c5, __common_expr_2 OR t1.b = Float64(5) + random() AS c6, t1.b = Float64(6) + random() OR t1.a = Float64(3) AS c7, t1.b = Float64(7) + random() OR t1.a = Float64(3) AS c8, CASE WHEN __common_expr_3 THEN random() ELSE Float64(1) END AS c9, CASE WHEN __common_expr_3 THEN random() ELSE Float64(2) END AS c10, CASE WHEN t1.b = Float64(8) + random() THEN t1.a + Float64(1) ELSE Float64(0) END AS c11, CASE WHEN t1.b = Float64(9) + random() THEN t1.a + Float64(1) ELSE Float64(0) END AS c12, CASE WHEN t1.b = Float64(10) + random() THEN Float64(0) ELSE t1.a + Float64(2) END AS c13, CASE WHEN t1.b = Float64(11) + random() THEN Float64(0) ELSE t1.a + Float64(2) END AS c14 +01)Projection: __common_expr_1 AND (t1.b = random()) AS c1, __common_expr_1 AND (t1.b = (Float64(1) + random())) AS c2, (t1.b = (Float64(2) + random())) AND (t1.a = Float64(1)) AS c3, (t1.b = (Float64(3) + random())) AND (t1.a = Float64(1)) AS c4, __common_expr_2 OR (t1.b = (Float64(4) + random())) AS c5, __common_expr_2 OR (t1.b = (Float64(5) + random())) AS c6, (t1.b = (Float64(6) + random())) OR (t1.a = Float64(3)) AS c7, (t1.b = (Float64(7) + random())) OR (t1.a = Float64(3)) AS c8, CASE WHEN __common_expr_3 THEN random() ELSE Float64(1) END AS c9, CASE WHEN __common_expr_3 THEN random() ELSE Float64(2) END AS c10, CASE WHEN t1.b = (Float64(8) + random()) THEN t1.a + Float64(1) ELSE Float64(0) END AS c11, CASE WHEN t1.b = (Float64(9) + random()) THEN t1.a + Float64(1) ELSE Float64(0) END AS c12, CASE WHEN t1.b = (Float64(10) + random()) THEN Float64(0) ELSE t1.a + Float64(2) END AS c13, CASE WHEN t1.b = (Float64(11) + random()) THEN Float64(0) ELSE t1.a + Float64(2) END AS c14 02)--Projection: t1.a = Float64(0) AS __common_expr_1, t1.a = Float64(2) AS __common_expr_2, t1.a = Float64(4) AS __common_expr_3, t1.a, t1.b 03)----TableScan: t1 projection=[a, b] physical_plan @@ -170,7 +170,7 @@ EXPLAIN SELECT FROM t1 ---- logical_plan -01)Projection: t1.a = random() AND t1.b = Float64(0) AS c1, t1.a = random() AND t1.b = Float64(1) AS c2, t1.a = Float64(2) + random() OR t1.b = Float64(4) AS c3, t1.a = Float64(2) + random() OR t1.b = Float64(5) AS c4, CASE WHEN t1.a = Float64(4) + random() THEN Int64(0) ELSE Int64(1) END AS c5, CASE WHEN t1.a = Float64(4) + random() THEN Int64(0) ELSE Int64(2) END AS c6 +01)Projection: (t1.a = random()) AND (t1.b = Float64(0)) AS c1, (t1.a = random()) AND (t1.b = Float64(1)) AS c2, (t1.a = (Float64(2) + random())) OR (t1.b = Float64(4)) AS c3, (t1.a = (Float64(2) + random())) OR (t1.b = Float64(5)) AS c4, CASE WHEN t1.a = (Float64(4) + random()) THEN Int64(0) ELSE Int64(1) END AS c5, CASE WHEN t1.a = (Float64(4) + random()) THEN Int64(0) ELSE Int64(2) END AS c6 02)--TableScan: t1 projection=[a, b] physical_plan 01)ProjectionExec: expr=[a@0 = random() AND b@1 = 0 as c1, a@0 = random() AND b@1 = 1 as c2, a@0 = 2 + random() OR b@1 = 4 as c3, a@0 = 2 + random() OR b@1 = 5 as c4, CASE WHEN a@0 = 4 + random() THEN 0 ELSE 1 END as c5, CASE WHEN a@0 = 4 + random() THEN 0 ELSE 2 END as c6] @@ -188,7 +188,7 @@ EXPLAIN SELECT FROM t1 ---- logical_plan -01)Projection: (__common_expr_1 OR random() = Float64(0)) AND __common_expr_2 AS c1, __common_expr_2 AND random() = Float64(0) OR __common_expr_1 AS c2, CASE WHEN __common_expr_3 = Float64(0) THEN __common_expr_3 ELSE Float64(0) END AS c3, CASE WHEN __common_expr_4 = Float64(0) THEN Int64(0) WHEN CAST(__common_expr_4 AS Boolean) THEN Int64(0) ELSE Int64(0) END AS c4, CASE WHEN __common_expr_5 = Float64(0) THEN Float64(0) WHEN random() = Float64(0) THEN __common_expr_5 ELSE Float64(0) END AS c5, CASE WHEN __common_expr_6 = Float64(0) THEN Float64(0) ELSE __common_expr_6 END AS c6 +01)Projection: (__common_expr_1 OR (random() = Float64(0))) AND __common_expr_2 AS c1, (__common_expr_2 AND (random() = Float64(0))) OR __common_expr_1 AS c2, CASE WHEN __common_expr_3 = Float64(0) THEN __common_expr_3 ELSE Float64(0) END AS c3, CASE WHEN __common_expr_4 = Float64(0) THEN Int64(0) WHEN CAST(__common_expr_4 AS Boolean) THEN Int64(0) ELSE Int64(0) END AS c4, CASE WHEN __common_expr_5 = Float64(0) THEN Float64(0) WHEN random() = Float64(0) THEN __common_expr_5 ELSE Float64(0) END AS c5, CASE WHEN __common_expr_6 = Float64(0) THEN Float64(0) ELSE __common_expr_6 END AS c6 02)--Projection: t1.a = Float64(1) AS __common_expr_1, t1.a = Float64(2) AS __common_expr_2, t1.a + Float64(3) AS __common_expr_3, t1.a + Float64(4) AS __common_expr_4, t1.a + Float64(5) AS __common_expr_5, t1.a + Float64(6) AS __common_expr_6 03)----TableScan: t1 projection=[a] physical_plan @@ -206,7 +206,7 @@ EXPLAIN SELECT FROM t1 ---- logical_plan -01)Projection: (__common_expr_1 OR random() = Float64(0)) AND (__common_expr_2 OR random() = Float64(1)) AS c1, __common_expr_2 AND random() = Float64(0) OR __common_expr_1 AND random() = Float64(1) AS c2, CASE WHEN __common_expr_3 = Float64(0) THEN __common_expr_3 + random() ELSE Float64(0) END AS c3, CASE WHEN __common_expr_4 = Float64(0) THEN Float64(0) ELSE __common_expr_4 + random() END AS c4 +01)Projection: (__common_expr_1 OR (random() = Float64(0))) AND (__common_expr_2 OR (random() = Float64(1))) AS c1, (__common_expr_2 AND (random() = Float64(0))) OR (__common_expr_1 AND (random() = Float64(1))) AS c2, CASE WHEN __common_expr_3 = Float64(0) THEN __common_expr_3 + random() ELSE Float64(0) END AS c3, CASE WHEN __common_expr_4 = Float64(0) THEN Float64(0) ELSE __common_expr_4 + random() END AS c4 02)--Projection: t1.a = Float64(1) AS __common_expr_1, t1.a = Float64(2) AS __common_expr_2, t1.a + Float64(3) AS __common_expr_3, t1.a + Float64(4) AS __common_expr_4 03)----TableScan: t1 projection=[a] physical_plan @@ -226,7 +226,7 @@ EXPLAIN SELECT FROM t1 ---- logical_plan -01)Projection: (random() = Float64(0) OR t1.a = Float64(1)) AND t1.a = Float64(2) AS c1, random() = Float64(0) AND t1.a = Float64(2) OR t1.a = Float64(1) AS c2, CASE WHEN random() = Float64(0) THEN t1.a + Float64(3) ELSE t1.a + Float64(3) END AS c3, CASE WHEN random() = Float64(0) THEN Float64(0) WHEN t1.a + Float64(4) = Float64(0) THEN t1.a + Float64(4) ELSE Float64(0) END AS c4, CASE WHEN random() = Float64(0) THEN Float64(0) WHEN t1.a + Float64(5) = Float64(0) THEN Float64(0) ELSE t1.a + Float64(5) END AS c5, CASE WHEN random() = Float64(0) THEN Float64(0) WHEN random() = Float64(0) THEN t1.a + Float64(6) ELSE t1.a + Float64(6) END AS c6 +01)Projection: ((random() = Float64(0)) OR (t1.a = Float64(1))) AND (t1.a = Float64(2)) AS c1, ((random() = Float64(0)) AND (t1.a = Float64(2))) OR (t1.a = Float64(1)) AS c2, CASE WHEN random() = Float64(0) THEN t1.a + Float64(3) ELSE t1.a + Float64(3) END AS c3, CASE WHEN random() = Float64(0) THEN Float64(0) WHEN (t1.a + Float64(4)) = Float64(0) THEN t1.a + Float64(4) ELSE Float64(0) END AS c4, CASE WHEN random() = Float64(0) THEN Float64(0) WHEN (t1.a + Float64(5)) = Float64(0) THEN Float64(0) ELSE t1.a + Float64(5) END AS c5, CASE WHEN random() = Float64(0) THEN Float64(0) WHEN random() = Float64(0) THEN t1.a + Float64(6) ELSE t1.a + Float64(6) END AS c6 02)--TableScan: t1 projection=[a] physical_plan 01)ProjectionExec: expr=[(random() = 0 OR a@0 = 1) AND a@0 = 2 as c1, random() = 0 AND a@0 = 2 OR a@0 = 1 as c2, CASE WHEN random() = 0 THEN a@0 + 3 ELSE a@0 + 3 END as c3, CASE WHEN random() = 0 THEN 0 WHEN a@0 + 4 = 0 THEN a@0 + 4 ELSE 0 END as c4, CASE WHEN random() = 0 THEN 0 WHEN a@0 + 5 = 0 THEN 0 ELSE a@0 + 5 END as c5, CASE WHEN random() = 0 THEN 0 WHEN random() = 0 THEN a@0 + 6 ELSE a@0 + 6 END as c6] diff --git a/datafusion/sqllogictest/test_files/delete.slt b/datafusion/sqllogictest/test_files/delete.slt index e86343b6bf5fb..79aecbcb58abc 100644 --- a/datafusion/sqllogictest/test_files/delete.slt +++ b/datafusion/sqllogictest/test_files/delete.slt @@ -45,7 +45,7 @@ explain delete from t1 where a = 1 and b = 2 and c > 3 and d != 4; ---- logical_plan 01)Dml: op=[Delete] table=[t1] -02)--Filter: CAST(t1.a AS Int64) = Int64(1) AND t1.b = CAST(Int64(2) AS Utf8View) AND t1.c > CAST(Int64(3) AS Float64) AND CAST(t1.d AS Int64) != Int64(4) +02)--Filter: (((CAST(t1.a AS Int64) = Int64(1)) AND (t1.b = CAST(Int64(2) AS Utf8View))) AND (t1.c > CAST(Int64(3) AS Float64))) AND (CAST(t1.d AS Int64) != Int64(4)) 03)----TableScan: t1 physical_plan 01)CooperativeExec @@ -58,7 +58,7 @@ explain delete from t1 where t1.a = 1 and b = 2 and t1.c > 3 and d != 4; ---- logical_plan 01)Dml: op=[Delete] table=[t1] -02)--Filter: CAST(t1.a AS Int64) = Int64(1) AND t1.b = CAST(Int64(2) AS Utf8View) AND t1.c > CAST(Int64(3) AS Float64) AND CAST(t1.d AS Int64) != Int64(4) +02)--Filter: (((CAST(t1.a AS Int64) = Int64(1)) AND (t1.b = CAST(Int64(2) AS Utf8View))) AND (t1.c > CAST(Int64(3) AS Float64))) AND (CAST(t1.d AS Int64) != Int64(4)) 03)----TableScan: t1 physical_plan 01)CooperativeExec @@ -71,7 +71,7 @@ explain delete from t1 where a = 1 and 1 = 1 and true; ---- logical_plan 01)Dml: op=[Delete] table=[t1] -02)--Filter: CAST(t1.a AS Int64) = Int64(1) AND Int64(1) = Int64(1) AND Boolean(true) +02)--Filter: ((CAST(t1.a AS Int64) = Int64(1)) AND (Int64(1) = Int64(1))) AND Boolean(true) 03)----TableScan: t1 physical_plan 01)CooperativeExec diff --git a/datafusion/sqllogictest/test_files/encrypted_parquet.slt b/datafusion/sqllogictest/test_files/encrypted_parquet.slt index d580b7d1ad2b8..6e746cc6f86ea 100644 --- a/datafusion/sqllogictest/test_files/encrypted_parquet.slt +++ b/datafusion/sqllogictest/test_files/encrypted_parquet.slt @@ -85,5 +85,10 @@ float_field float ) STORED AS PARQUET LOCATION 'test_files/scratch/encrypted_parquet/' -query error DataFusion error: Parquet error: Parquet error: Parquet file has an encrypted footer but decryption properties were not provided -SELECT * FROM parquet_table +query RR +SELECT * FROM parquet_table ORDER BY double_field +---- +-1 -1 +1 2 +3 4 +5 6 diff --git a/datafusion/sqllogictest/test_files/filter_without_sort_exec.slt b/datafusion/sqllogictest/test_files/filter_without_sort_exec.slt index ec069212f5586..1bb740bcb88f0 100644 --- a/datafusion/sqllogictest/test_files/filter_without_sort_exec.slt +++ b/datafusion/sqllogictest/test_files/filter_without_sort_exec.slt @@ -50,7 +50,7 @@ ORDER BY "time" ---- logical_plan 01)Sort: data.time ASC NULLS LAST -02)--Filter: data.ticker = Utf8View("A") AND CAST(data.time AS Date32) = data.date +02)--Filter: (data.ticker = Utf8View("A")) AND (CAST(data.time AS Date32) = data.date) 03)----TableScan: data projection=[date, ticker, time] physical_plan 01)SortPreservingMergeExec: [time@2 ASC NULLS LAST] @@ -66,7 +66,7 @@ ORDER BY "date" ---- logical_plan 01)Sort: data.date ASC NULLS LAST -02)--Filter: data.ticker = Utf8View("A") AND CAST(data.time AS Date32) = data.date +02)--Filter: (data.ticker = Utf8View("A")) AND (CAST(data.time AS Date32) = data.date) 03)----TableScan: data projection=[date, ticker, time] physical_plan 01)SortPreservingMergeExec: [date@0 ASC NULLS LAST] @@ -82,7 +82,7 @@ ORDER BY "ticker" ---- logical_plan 01)Sort: data.ticker ASC NULLS LAST -02)--Filter: data.ticker = Utf8View("A") AND CAST(data.time AS Date32) = data.date +02)--Filter: (data.ticker = Utf8View("A")) AND (CAST(data.time AS Date32) = data.date) 03)----TableScan: data projection=[date, ticker, time] physical_plan 01)CoalescePartitionsExec @@ -98,7 +98,7 @@ ORDER BY "time", "date"; ---- logical_plan 01)Sort: data.time ASC NULLS LAST, data.date ASC NULLS LAST -02)--Filter: data.ticker = Utf8View("A") AND CAST(data.time AS Date32) = data.date +02)--Filter: (data.ticker = Utf8View("A")) AND (CAST(data.time AS Date32) = data.date) 03)----TableScan: data projection=[date, ticker, time] physical_plan 01)SortPreservingMergeExec: [time@2 ASC NULLS LAST, date@0 ASC NULLS LAST] @@ -115,7 +115,7 @@ ORDER BY "time" ---- logical_plan 01)Sort: data.time ASC NULLS LAST -02)--Filter: data.ticker = Utf8View("A") AND CAST(data.time AS Date32) != data.date +02)--Filter: (data.ticker = Utf8View("A")) AND (CAST(data.time AS Date32) != data.date) 03)----TableScan: data projection=[date, ticker, time] # no relation between time & date diff --git a/datafusion/sqllogictest/test_files/group_by.slt b/datafusion/sqllogictest/test_files/group_by.slt index db4ec83f10129..bce3bc2c207fc 100644 --- a/datafusion/sqllogictest/test_files/group_by.slt +++ b/datafusion/sqllogictest/test_files/group_by.slt @@ -3916,7 +3916,7 @@ logical_plan 03)----Projection: last_value(l.d) ORDER BY [l.a ASC NULLS LAST] AS amount_usd, row_n 04)------Aggregate: groupBy=[[row_n]], aggr=[[last_value(l.d) ORDER BY [l.a ASC NULLS LAST]]] 05)--------Projection: l.a, l.d, row_n -06)----------Inner Join: l.d = r.d Filter: CAST(l.a AS Int64) >= CAST(r.a AS Int64) - Int64(10) +06)----------Inner Join: l.d = r.d Filter: CAST(l.a AS Int64) >= (CAST(r.a AS Int64) - Int64(10)) 07)------------SubqueryAlias: l 08)--------------TableScan: multiple_ordered_table projection=[a, d] 09)------------Projection: r.a, r.d, row_number() ORDER BY [r.a ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS row_n diff --git a/datafusion/sqllogictest/test_files/join.slt.part b/datafusion/sqllogictest/test_files/join.slt.part index c0a838c97d552..6bd2f564db0a5 100644 --- a/datafusion/sqllogictest/test_files/join.slt.part +++ b/datafusion/sqllogictest/test_files/join.slt.part @@ -841,7 +841,7 @@ LEFT JOIN department AS d ON (e.name = 'Alice' OR e.name = 'Bob'); ---- logical_plan -01)Left Join: Filter: e.name = Utf8View("Alice") OR e.name = Utf8View("Bob") +01)Left Join: Filter: (e.name = Utf8View("Alice")) OR (e.name = Utf8View("Bob")) 02)--SubqueryAlias: e 03)----TableScan: employees projection=[emp_id, name] 04)--SubqueryAlias: d @@ -929,7 +929,7 @@ ON (e.name = 'Alice' OR e.name = 'Bob'); logical_plan 01)Cross Join: 02)--SubqueryAlias: e -03)----Filter: employees.name = Utf8View("Alice") OR employees.name = Utf8View("Bob") +03)----Filter: (employees.name = Utf8View("Alice")) OR (employees.name = Utf8View("Bob")) 04)------TableScan: employees projection=[emp_id, name] 05)--SubqueryAlias: d 06)----TableScan: department projection=[dept_name] @@ -973,11 +973,11 @@ ON e.emp_id = d.emp_id WHERE ((dept_name != 'Engineering' AND e.name = 'Alice') OR (name != 'Alice' AND e.name = 'Carol')); ---- logical_plan -01)Filter: d.dept_name != Utf8View("Engineering") AND e.name = Utf8View("Alice") OR e.name = Utf8View("Carol") +01)Filter: ((d.dept_name != Utf8View("Engineering")) AND (e.name = Utf8View("Alice"))) OR (e.name = Utf8View("Carol")) 02)--Projection: e.emp_id, e.name, d.dept_name 03)----Left Join: e.emp_id = d.emp_id 04)------SubqueryAlias: e -05)--------Filter: employees.name = Utf8View("Alice") OR employees.name = Utf8View("Carol") +05)--------Filter: (employees.name = Utf8View("Alice")) OR (employees.name = Utf8View("Carol")) 06)----------TableScan: employees projection=[emp_id, name] 07)------SubqueryAlias: d 08)--------TableScan: department projection=[emp_id, dept_name] @@ -1168,7 +1168,7 @@ WHERE t0.v1 = t1.v0; ---- logical_plan 01)Projection: t1.v0, t1.v1, t5.v2, t5.v3, t5.v4, t0.v0, t0.v1 -02)--Inner Join: CAST(t1.v0 AS Float64) = t0.v1 Filter: t0.v1 + CAST(t5.v0 AS Float64) > Float64(0) +02)--Inner Join: CAST(t1.v0 AS Float64) = t0.v1 Filter: (t0.v1 + CAST(t5.v0 AS Float64)) > Float64(0) 03)----Projection: t1.v0, t1.v1, t5.v0, t5.v2, t5.v3, t5.v4 04)------Inner Join: t1.v0 = t5.v0, t1.v1 = t5.v1 05)--------TableScan: t1 projection=[v0, v1] diff --git a/datafusion/sqllogictest/test_files/join_is_not_distinct_from.slt b/datafusion/sqllogictest/test_files/join_is_not_distinct_from.slt index 8246f489c446d..08ca03718368f 100644 --- a/datafusion/sqllogictest/test_files/join_is_not_distinct_from.slt +++ b/datafusion/sqllogictest/test_files/join_is_not_distinct_from.slt @@ -136,7 +136,7 @@ JOIN t2 ON ((t1.val+1) IS NOT DISTINCT FROM (t2.val+1)) AND ((t1.val + 1) IS NOT logical_plan 01)Projection: t1.id AS t1_id, t2.id AS t2_id, t1.val, t2.val 02)--Inner Join: CAST(t1.val AS Int64) + Int64(1) = CAST(t2.val AS Int64) + Int64(1) -03)----Filter: CAST(t1.val AS Int64) + Int64(1) IS NOT DISTINCT FROM Int64(11) +03)----Filter: (CAST(t1.val AS Int64) + Int64(1)) IS NOT DISTINCT FROM Int64(11) 04)------TableScan: t1 projection=[id, val] 05)----TableScan: t2 projection=[id, val] physical_plan @@ -165,7 +165,7 @@ JOIN t2 ON ((t1.val+1) IS NOT DISTINCT FROM (t2.val+1)) AND ((t1.val % 3) IS DIS ---- logical_plan 01)Projection: t1.id AS t1_id, t2.id AS t2_id, t1.val, t2.val -02)--Inner Join: CAST(t1.val AS Int64) + Int64(1) = CAST(t2.val AS Int64) + Int64(1) Filter: CAST(t1.val AS Int64) % Int64(3) IS DISTINCT FROM CAST(t2.val AS Int64) % Int64(3) +02)--Inner Join: CAST(t1.val AS Int64) + Int64(1) = CAST(t2.val AS Int64) + Int64(1) Filter: (CAST(t1.val AS Int64) % Int64(3)) IS DISTINCT FROM (CAST(t2.val AS Int64) % Int64(3)) 03)----TableScan: t1 projection=[id, val] 04)----TableScan: t2 projection=[id, val] physical_plan diff --git a/datafusion/sqllogictest/test_files/joins.slt b/datafusion/sqllogictest/test_files/joins.slt index ae87fd11d397c..67f6530b83549 100644 --- a/datafusion/sqllogictest/test_files/joins.slt +++ b/datafusion/sqllogictest/test_files/joins.slt @@ -1067,9 +1067,9 @@ LEFT JOIN join_t2 on join_t1.t1_id = join_t2.t2_id WHERE join_t2.t2_int < 10 or (join_t1.t1_int > 2 and join_t2.t2_name != 'w') ---- logical_plan -01)Inner Join: join_t1.t1_id = join_t2.t2_id Filter: join_t2.t2_int < UInt32(10) OR join_t1.t1_int > UInt32(2) AND join_t2.t2_name != Utf8View("w") +01)Inner Join: join_t1.t1_id = join_t2.t2_id Filter: (join_t2.t2_int < UInt32(10)) OR ((join_t1.t1_int > UInt32(2)) AND (join_t2.t2_name != Utf8View("w"))) 02)--TableScan: join_t1 projection=[t1_id, t1_name, t1_int] -03)--Filter: join_t2.t2_int < UInt32(10) OR join_t2.t2_name != Utf8View("w") +03)--Filter: (join_t2.t2_int < UInt32(10)) OR (join_t2.t2_name != Utf8View("w")) 04)----TableScan: join_t2 projection=[t2_id, t2_name, t2_int] # Reduce left join 3 (to inner join) @@ -1094,7 +1094,7 @@ logical_plan 05)--------Filter: join_t1.t1_id < UInt32(100) 06)----------TableScan: join_t1 projection=[t1_id, t1_name, t1_int] 07)--------Projection: join_t2.t2_id -08)----------Filter: join_t2.t2_int < UInt32(3) AND join_t2.t2_id < UInt32(100) +08)----------Filter: (join_t2.t2_int < UInt32(3)) AND (join_t2.t2_id < UInt32(100)) 09)------------TableScan: join_t2 projection=[t2_id, t2_int] 10)--TableScan: join_t2 projection=[t2_id, t2_name, t2_int] @@ -1745,7 +1745,7 @@ from join_t1 inner join join_t2 on join_t1.t1_id * 4 < join_t2.t2_id ---- logical_plan -01)Inner Join: Filter: CAST(join_t1.t1_id AS Int64) * Int64(4) < CAST(join_t2.t2_id AS Int64) +01)Inner Join: Filter: (CAST(join_t1.t1_id AS Int64) * Int64(4)) < CAST(join_t2.t2_id AS Int64) 02)--TableScan: join_t1 projection=[t1_id, t1_name] 03)--TableScan: join_t2 projection=[t2_id] @@ -1759,7 +1759,7 @@ inner join join_t2 on join_t1.t1_id * 5 = join_t2.t2_id and join_t1.t1_id * 4 < join_t2.t2_id ---- logical_plan -01)Inner Join: CAST(join_t1.t1_id AS Int64) * Int64(5) = CAST(join_t2.t2_id AS Int64) Filter: CAST(join_t1.t1_id AS Int64) * Int64(4) < CAST(join_t2.t2_id AS Int64) +01)Inner Join: CAST(join_t1.t1_id AS Int64) * Int64(5) = CAST(join_t2.t2_id AS Int64) Filter: (CAST(join_t1.t1_id AS Int64) * Int64(4)) < CAST(join_t2.t2_id AS Int64) 02)--TableScan: join_t1 projection=[t1_id, t1_name] 03)--TableScan: join_t2 projection=[t2_id] @@ -1879,7 +1879,7 @@ where join_t1.t1_id + 12 in ) ---- logical_plan -01)LeftSemi Join: CAST(join_t1.t1_id AS Int64) + Int64(12) = __correlated_sq_1.join_t2.t2_id + Int64(1) Filter: join_t1.t1_int <= __correlated_sq_1.t2_int AND join_t1.t1_name != __correlated_sq_1.t2_name +01)LeftSemi Join: CAST(join_t1.t1_id AS Int64) + Int64(12) = __correlated_sq_1.join_t2.t2_id + Int64(1) Filter: (join_t1.t1_int <= __correlated_sq_1.t2_int) AND (join_t1.t1_name != __correlated_sq_1.t2_name) 02)--TableScan: join_t1 projection=[t1_id, t1_name, t1_int] 03)--SubqueryAlias: __correlated_sq_1 04)----Projection: CAST(join_t2.t2_id AS Int64) + Int64(1), join_t2.t2_int, join_t2.t2_name @@ -1950,7 +1950,7 @@ where join_t1.t1_id + 12 in and join_t1.t1_id > 0 ---- logical_plan -01)LeftSemi Join: CAST(join_t1.t1_id AS Int64) + Int64(12) = __correlated_sq_1.join_t2.t2_id + Int64(1) Filter: join_t1.t1_int <= __correlated_sq_1.t2_int AND join_t1.t1_name != __correlated_sq_1.t2_name +01)LeftSemi Join: CAST(join_t1.t1_id AS Int64) + Int64(12) = __correlated_sq_1.join_t2.t2_id + Int64(1) Filter: (join_t1.t1_int <= __correlated_sq_1.t2_int) AND (join_t1.t1_name != __correlated_sq_1.t2_name) 02)--Filter: join_t1.t1_id > UInt32(0) 03)----TableScan: join_t1 projection=[t1_id, t1_name, t1_int] 04)--SubqueryAlias: __correlated_sq_1 @@ -2116,7 +2116,7 @@ WHERE EXISTS ( ) ---- logical_plan -01)LeftSemi Join: Filter: CAST(join_t1.t1_id AS Int64) + Int64(1) > CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2) +01)LeftSemi Join: Filter: (CAST(join_t1.t1_id AS Int64) + Int64(1)) > (CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2)) 02)--TableScan: join_t1 projection=[t1_id, t1_name, t1_int] 03)--SubqueryAlias: __correlated_sq_1 04)----TableScan: join_t2 projection=[t2_id] @@ -2168,7 +2168,7 @@ WHERE EXISTS ( ) ---- logical_plan -01)LeftSemi Join: Filter: CAST(join_t1.t1_id AS Int64) + Int64(1) > CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2) +01)LeftSemi Join: Filter: (CAST(join_t1.t1_id AS Int64) + Int64(1)) > (CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2)) 02)--TableScan: join_t1 projection=[t1_id, t1_name, t1_int] 03)--SubqueryAlias: __correlated_sq_1 04)----Projection: join_t2.t2_id @@ -2216,7 +2216,7 @@ WHERE EXISTS ( ) ---- logical_plan -01)LeftSemi Join: Filter: CAST(join_t1.t1_id AS Int64) + Int64(1) > CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2) +01)LeftSemi Join: Filter: (CAST(join_t1.t1_id AS Int64) + Int64(1)) > (CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2)) 02)--Filter: join_t1.t1_int < UInt32(3) 03)----TableScan: join_t1 projection=[t1_id, t1_name, t1_int] 04)--SubqueryAlias: __correlated_sq_1 @@ -2263,7 +2263,7 @@ WHERE NOT EXISTS ( ) ---- logical_plan -01)LeftAnti Join: Filter: CAST(join_t1.t1_id AS Int64) + Int64(1) > CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2) +01)LeftAnti Join: Filter: (CAST(join_t1.t1_id AS Int64) + Int64(1)) > (CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2)) 02)--TableScan: join_t1 projection=[t1_id, t1_name, t1_int] 03)--SubqueryAlias: __correlated_sq_1 04)----TableScan: join_t2 projection=[t2_id] @@ -2309,7 +2309,7 @@ WHERE NOT EXISTS ( ) ---- logical_plan -01)LeftAnti Join: Filter: CAST(join_t1.t1_id AS Int64) + Int64(1) > CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2) +01)LeftAnti Join: Filter: (CAST(join_t1.t1_id AS Int64) + Int64(1)) > (CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2)) 02)--TableScan: join_t1 projection=[t1_id, t1_name, t1_int] 03)--SubqueryAlias: __correlated_sq_1 04)----Projection: join_t2.t2_id @@ -2358,7 +2358,7 @@ WHERE NOT EXISTS( ) ---- logical_plan -01)LeftAnti Join: Filter: CAST(join_t1.t1_id AS Int64) + Int64(1) > CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2) +01)LeftAnti Join: Filter: (CAST(join_t1.t1_id AS Int64) + Int64(1)) > (CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2)) 02)--TableScan: join_t1 projection=[t1_id, t1_name, t1_int] 03)--SubqueryAlias: __correlated_sq_1 04)----Projection: join_t2.t2_id @@ -2409,7 +2409,7 @@ WHERE NOT EXISTS( ) ---- logical_plan -01)LeftAnti Join: Filter: CAST(join_t1.t1_id AS Int64) + Int64(1) > CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2) +01)LeftAnti Join: Filter: (CAST(join_t1.t1_id AS Int64) + Int64(1)) > (CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2)) 02)--TableScan: join_t1 projection=[t1_id, t1_name, t1_int] 03)--SubqueryAlias: __correlated_sq_1 04)----Projection: join_t2.t2_id @@ -2440,7 +2440,7 @@ WHERE NOT EXISTS( ) ---- logical_plan -01)LeftAnti Join: Filter: CAST(join_t1.t1_id AS Int64) + Int64(1) > CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2) +01)LeftAnti Join: Filter: (CAST(join_t1.t1_id AS Int64) + Int64(1)) > (CAST(__correlated_sq_1.t2_id AS Int64) * Int64(2)) 02)--TableScan: join_t1 projection=[t1_id, t1_name, t1_int] 03)--SubqueryAlias: __correlated_sq_1 04)----Projection: join_t2.t2_id @@ -3371,7 +3371,7 @@ logical_plan 03)----Projection: last_value(l.d) ORDER BY [l.a ASC NULLS LAST] AS amount_usd, row_n 04)------Aggregate: groupBy=[[row_n]], aggr=[[last_value(l.d) ORDER BY [l.a ASC NULLS LAST]]] 05)--------Projection: l.a, l.d, row_n -06)----------Inner Join: l.d = r.d Filter: CAST(l.a AS Int64) >= CAST(r.a AS Int64) - Int64(10) +06)----------Inner Join: l.d = r.d Filter: CAST(l.a AS Int64) >= (CAST(r.a AS Int64) - Int64(10)) 07)------------SubqueryAlias: l 08)--------------TableScan: multiple_ordered_table projection=[a, d] 09)------------Projection: r.a, r.d, row_number() ORDER BY [r.a ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS row_n @@ -4642,7 +4642,7 @@ logical_plan 04)----TableScan: j2 projection=[j2_string, j2_id] 05)----SubqueryAlias: j3 06)------Subquery: -07)--------Filter: outer_ref(j1.j1_id) + outer_ref(j2.j2_id) = j3.j3_id +07)--------Filter: (outer_ref(j1.j1_id) + outer_ref(j2.j2_id)) = j3.j3_id 08)----------TableScan: j3 projection=[j3_string, j3_id] physical_plan_error This feature is not implemented: Physical plan does not support logical expression OuterReferenceColumn(Field { name: "j1_id", data_type: Int32, nullable: true }, Column { relation: Some(Bare { table: "j1" }), name: "j1_id" }) diff --git a/datafusion/sqllogictest/test_files/order.slt b/datafusion/sqllogictest/test_files/order.slt index 7c857cae36971..0703afb892d2e 100644 --- a/datafusion/sqllogictest/test_files/order.slt +++ b/datafusion/sqllogictest/test_files/order.slt @@ -592,7 +592,7 @@ ORDER BY result; ---- logical_plan 01)Sort: result ASC NULLS LAST -02)--Projection: multiple_ordered_table.b + multiple_ordered_table.a + multiple_ordered_table.c AS result +02)--Projection: (multiple_ordered_table.b + multiple_ordered_table.a) + multiple_ordered_table.c AS result 03)----TableScan: multiple_ordered_table projection=[a, b, c] physical_plan 01)SortPreservingMergeExec: [result@0 ASC NULLS LAST] diff --git a/datafusion/sqllogictest/test_files/parquet.slt b/datafusion/sqllogictest/test_files/parquet.slt index be713b963b451..d8a70cad91874 100644 --- a/datafusion/sqllogictest/test_files/parquet.slt +++ b/datafusion/sqllogictest/test_files/parquet.slt @@ -455,7 +455,7 @@ EXPLAIN binaryview_col LIKE '%a%'; ---- logical_plan -01)Filter: CAST(binary_as_string_default.binary_col AS Utf8View) LIKE Utf8View("%a%") AND CAST(binary_as_string_default.largebinary_col AS Utf8View) LIKE Utf8View("%a%") AND CAST(binary_as_string_default.binaryview_col AS Utf8View) LIKE Utf8View("%a%") +01)Filter: (CAST(binary_as_string_default.binary_col AS Utf8View) LIKE Utf8View("%a%") AND CAST(binary_as_string_default.largebinary_col AS Utf8View) LIKE Utf8View("%a%")) AND CAST(binary_as_string_default.binaryview_col AS Utf8View) LIKE Utf8View("%a%") 02)--TableScan: binary_as_string_default projection=[binary_col, largebinary_col, binaryview_col], partial_filters=[CAST(binary_as_string_default.binary_col AS Utf8View) LIKE Utf8View("%a%"), CAST(binary_as_string_default.largebinary_col AS Utf8View) LIKE Utf8View("%a%"), CAST(binary_as_string_default.binaryview_col AS Utf8View) LIKE Utf8View("%a%")] physical_plan 01)FilterExec: CAST(binary_col@0 AS Utf8View) LIKE %a% AND CAST(largebinary_col@1 AS Utf8View) LIKE %a% AND CAST(binaryview_col@2 AS Utf8View) LIKE %a% @@ -502,7 +502,7 @@ EXPLAIN binaryview_col LIKE '%a%'; ---- logical_plan -01)Filter: binary_as_string_option.binary_col LIKE Utf8View("%a%") AND binary_as_string_option.largebinary_col LIKE Utf8View("%a%") AND binary_as_string_option.binaryview_col LIKE Utf8View("%a%") +01)Filter: (binary_as_string_option.binary_col LIKE Utf8View("%a%") AND binary_as_string_option.largebinary_col LIKE Utf8View("%a%")) AND binary_as_string_option.binaryview_col LIKE Utf8View("%a%") 02)--TableScan: binary_as_string_option projection=[binary_col, largebinary_col, binaryview_col], partial_filters=[binary_as_string_option.binary_col LIKE Utf8View("%a%"), binary_as_string_option.largebinary_col LIKE Utf8View("%a%"), binary_as_string_option.binaryview_col LIKE Utf8View("%a%")] physical_plan 01)FilterExec: binary_col@0 LIKE %a% AND largebinary_col@1 LIKE %a% AND binaryview_col@2 LIKE %a% @@ -552,7 +552,7 @@ EXPLAIN binaryview_col LIKE '%a%'; ---- logical_plan -01)Filter: binary_as_string_both.binary_col LIKE Utf8View("%a%") AND binary_as_string_both.largebinary_col LIKE Utf8View("%a%") AND binary_as_string_both.binaryview_col LIKE Utf8View("%a%") +01)Filter: (binary_as_string_both.binary_col LIKE Utf8View("%a%") AND binary_as_string_both.largebinary_col LIKE Utf8View("%a%")) AND binary_as_string_both.binaryview_col LIKE Utf8View("%a%") 02)--TableScan: binary_as_string_both projection=[binary_col, largebinary_col, binaryview_col], partial_filters=[binary_as_string_both.binary_col LIKE Utf8View("%a%"), binary_as_string_both.largebinary_col LIKE Utf8View("%a%"), binary_as_string_both.binaryview_col LIKE Utf8View("%a%")] physical_plan 01)FilterExec: binary_col@0 LIKE %a% AND largebinary_col@1 LIKE %a% AND binaryview_col@2 LIKE %a% diff --git a/datafusion/sqllogictest/test_files/parquet_filter_pushdown.slt b/datafusion/sqllogictest/test_files/parquet_filter_pushdown.slt index aa94e2e2f2c04..053c9cc5af5e8 100644 --- a/datafusion/sqllogictest/test_files/parquet_filter_pushdown.slt +++ b/datafusion/sqllogictest/test_files/parquet_filter_pushdown.slt @@ -372,7 +372,7 @@ EXPLAIN select a from t_pushdown where b > 2 AND a IS NOT NULL order by a; logical_plan 01)Sort: t_pushdown.a ASC NULLS LAST 02)--Projection: t_pushdown.a -03)----Filter: t_pushdown.b > Int32(2) AND t_pushdown.a IS NOT NULL +03)----Filter: (t_pushdown.b > Int32(2)) AND t_pushdown.a IS NOT NULL 04)------TableScan: t_pushdown projection=[a, b], partial_filters=[t_pushdown.b > Int32(2), t_pushdown.a IS NOT NULL] physical_plan 01)SortPreservingMergeExec: [a@0 ASC NULLS LAST] @@ -492,7 +492,7 @@ query TT EXPLAIN select * from t_pushdown where val != 'd' AND val != 'c' AND part = 'a' AND part != val; ---- logical_plan -01)Filter: t_pushdown.val != Utf8View("d") AND t_pushdown.val != Utf8View("c") AND t_pushdown.val != t_pushdown.part +01)Filter: ((t_pushdown.val != Utf8View("d")) AND (t_pushdown.val != Utf8View("c"))) AND (t_pushdown.val != t_pushdown.part) 02)--TableScan: t_pushdown projection=[val, part], full_filters=[t_pushdown.part = Utf8View("a")], partial_filters=[t_pushdown.val != Utf8View("d"), t_pushdown.val != Utf8View("c"), t_pushdown.val != t_pushdown.part] physical_plan DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet_filter_pushdown/parquet_part_test/part=a/file.parquet]]}, projection=[val, part], file_type=parquet, predicate=val@0 != d AND val@0 != c AND val@0 != part@1, pruning_predicate=val_null_count@2 != row_count@3 AND (val_min@0 != d OR d != val_max@1) AND val_null_count@2 != row_count@3 AND (val_min@0 != c OR c != val_max@1), required_guarantees=[val not in (c, d)] @@ -669,7 +669,7 @@ EXPLAIN SELECT id, tags FROM array_test WHERE id > 1 AND array_has(tags, 'rust') ---- logical_plan 01)Sort: array_test.id ASC NULLS LAST -02)--Filter: array_test.id > Int64(1) AND array_has(array_test.tags, Utf8("rust")) +02)--Filter: (array_test.id > Int64(1)) AND array_has(array_test.tags, Utf8("rust")) 03)----TableScan: array_test projection=[id, tags], partial_filters=[array_test.id > Int64(1), array_has(array_test.tags, Utf8("rust"))] physical_plan 01)SortExec: expr=[id@0 ASC NULLS LAST], preserve_partitioning=[false] diff --git a/datafusion/sqllogictest/test_files/predicates.slt b/datafusion/sqllogictest/test_files/predicates.slt index 7d33814b8bdbf..c61b2cfd44410 100644 --- a/datafusion/sqllogictest/test_files/predicates.slt +++ b/datafusion/sqllogictest/test_files/predicates.slt @@ -380,7 +380,7 @@ query TT EXPLAIN SELECT * FROM test WHERE column1 = 'foo' OR column1 = 'bar' OR column1 = 'fazzz' ---- logical_plan -01)Filter: test.column1 = Utf8("foo") OR test.column1 = Utf8("bar") OR test.column1 = Utf8("fazzz") +01)Filter: ((test.column1 = Utf8("foo")) OR (test.column1 = Utf8("bar"))) OR (test.column1 = Utf8("fazzz")) 02)--TableScan: test projection=[column1] # Number of OR statements is greater than threshold @@ -421,8 +421,8 @@ EXPLAIN SELECT * FROM aggregate_test_100 WHERE (c2 = 1 OR c3 = 100) OR (c2 = 2 OR c2 = 3 OR c2 = 4) ---- logical_plan -01)Filter: aggregate_test_100.c2 = Int8(1) OR aggregate_test_100.c3 = Int16(100) OR aggregate_test_100.c2 = Int8(2) OR aggregate_test_100.c2 = Int8(3) OR aggregate_test_100.c2 = Int8(4) -02)--TableScan: aggregate_test_100 projection=[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13], partial_filters=[aggregate_test_100.c2 = Int8(1) OR aggregate_test_100.c3 = Int16(100) OR aggregate_test_100.c2 = Int8(2) OR aggregate_test_100.c2 = Int8(3) OR aggregate_test_100.c2 = Int8(4)] +01)Filter: ((aggregate_test_100.c2 = Int8(1)) OR (aggregate_test_100.c3 = Int16(100))) OR (((aggregate_test_100.c2 = Int8(2)) OR (aggregate_test_100.c2 = Int8(3))) OR (aggregate_test_100.c2 = Int8(4))) +02)--TableScan: aggregate_test_100 projection=[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13], partial_filters=[((aggregate_test_100.c2 = Int8(1)) OR (aggregate_test_100.c3 = Int16(100))) OR (((aggregate_test_100.c2 = Int8(2)) OR (aggregate_test_100.c2 = Int8(3))) OR (aggregate_test_100.c2 = Int8(4)))] # Partially simplifiable, mixed column query TT @@ -430,8 +430,8 @@ EXPLAIN SELECT * FROM aggregate_test_100 WHERE (c2 = 1 OR c3 = 100) OR (c2 = 2 OR c2 = 3 OR c2 = 4 OR c2 = 5) ---- logical_plan -01)Filter: aggregate_test_100.c2 = Int8(1) OR aggregate_test_100.c3 = Int16(100) OR aggregate_test_100.c2 IN ([Int8(2), Int8(3), Int8(4), Int8(5)]) -02)--TableScan: aggregate_test_100 projection=[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13], partial_filters=[aggregate_test_100.c2 = Int8(1) OR aggregate_test_100.c3 = Int16(100) OR aggregate_test_100.c2 IN ([Int8(2), Int8(3), Int8(4), Int8(5)])] +01)Filter: ((aggregate_test_100.c2 = Int8(1)) OR (aggregate_test_100.c3 = Int16(100))) OR aggregate_test_100.c2 IN ([Int8(2), Int8(3), Int8(4), Int8(5)]) +02)--TableScan: aggregate_test_100 projection=[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13], partial_filters=[((aggregate_test_100.c2 = Int8(1)) OR (aggregate_test_100.c3 = Int16(100))) OR aggregate_test_100.c2 IN ([Int8(2), Int8(3), Int8(4), Int8(5)])] statement ok set datafusion.explain.logical_plan_only = false @@ -662,11 +662,11 @@ OR ---- logical_plan 01)Projection: lineitem.l_partkey -02)--Inner Join: lineitem.l_partkey = part.p_partkey Filter: part.p_brand = Utf8View("Brand#12") AND lineitem.l_quantity >= Decimal128(Some(100),15,2) AND lineitem.l_quantity <= Decimal128(Some(1100),15,2) AND part.p_size <= Int32(5) OR part.p_brand = Utf8View("Brand#23") AND lineitem.l_quantity >= Decimal128(Some(1000),15,2) AND lineitem.l_quantity <= Decimal128(Some(2000),15,2) AND part.p_size <= Int32(10) OR part.p_brand = Utf8View("Brand#34") AND lineitem.l_quantity >= Decimal128(Some(2000),15,2) AND lineitem.l_quantity <= Decimal128(Some(3000),15,2) AND part.p_size <= Int32(15) -03)----Filter: lineitem.l_quantity >= Decimal128(Some(100),15,2) AND lineitem.l_quantity <= Decimal128(Some(1100),15,2) OR lineitem.l_quantity >= Decimal128(Some(1000),15,2) AND lineitem.l_quantity <= Decimal128(Some(2000),15,2) OR lineitem.l_quantity >= Decimal128(Some(2000),15,2) AND lineitem.l_quantity <= Decimal128(Some(3000),15,2) -04)------TableScan: lineitem projection=[l_partkey, l_quantity], partial_filters=[lineitem.l_quantity >= Decimal128(Some(100),15,2) AND lineitem.l_quantity <= Decimal128(Some(1100),15,2) OR lineitem.l_quantity >= Decimal128(Some(1000),15,2) AND lineitem.l_quantity <= Decimal128(Some(2000),15,2) OR lineitem.l_quantity >= Decimal128(Some(2000),15,2) AND lineitem.l_quantity <= Decimal128(Some(3000),15,2)] -05)----Filter: (part.p_brand = Utf8View("Brand#12") AND part.p_size <= Int32(5) OR part.p_brand = Utf8View("Brand#23") AND part.p_size <= Int32(10) OR part.p_brand = Utf8View("Brand#34") AND part.p_size <= Int32(15)) AND part.p_size >= Int32(1) -06)------TableScan: part projection=[p_partkey, p_brand, p_size], partial_filters=[part.p_size >= Int32(1), part.p_brand = Utf8View("Brand#12") AND part.p_size <= Int32(5) OR part.p_brand = Utf8View("Brand#23") AND part.p_size <= Int32(10) OR part.p_brand = Utf8View("Brand#34") AND part.p_size <= Int32(15)] +02)--Inner Join: lineitem.l_partkey = part.p_partkey Filter: (((((part.p_brand = Utf8View("Brand#12")) AND (lineitem.l_quantity >= Decimal128(Some(100),15,2))) AND (lineitem.l_quantity <= Decimal128(Some(1100),15,2))) AND (part.p_size <= Int32(5))) OR ((((part.p_brand = Utf8View("Brand#23")) AND (lineitem.l_quantity >= Decimal128(Some(1000),15,2))) AND (lineitem.l_quantity <= Decimal128(Some(2000),15,2))) AND (part.p_size <= Int32(10)))) OR ((((part.p_brand = Utf8View("Brand#34")) AND (lineitem.l_quantity >= Decimal128(Some(2000),15,2))) AND (lineitem.l_quantity <= Decimal128(Some(3000),15,2))) AND (part.p_size <= Int32(15))) +03)----Filter: (((lineitem.l_quantity >= Decimal128(Some(100),15,2)) AND (lineitem.l_quantity <= Decimal128(Some(1100),15,2))) OR ((lineitem.l_quantity >= Decimal128(Some(1000),15,2)) AND (lineitem.l_quantity <= Decimal128(Some(2000),15,2)))) OR ((lineitem.l_quantity >= Decimal128(Some(2000),15,2)) AND (lineitem.l_quantity <= Decimal128(Some(3000),15,2))) +04)------TableScan: lineitem projection=[l_partkey, l_quantity], partial_filters=[(((lineitem.l_quantity >= Decimal128(Some(100),15,2)) AND (lineitem.l_quantity <= Decimal128(Some(1100),15,2))) OR ((lineitem.l_quantity >= Decimal128(Some(1000),15,2)) AND (lineitem.l_quantity <= Decimal128(Some(2000),15,2)))) OR ((lineitem.l_quantity >= Decimal128(Some(2000),15,2)) AND (lineitem.l_quantity <= Decimal128(Some(3000),15,2)))] +05)----Filter: ((((part.p_brand = Utf8View("Brand#12")) AND (part.p_size <= Int32(5))) OR ((part.p_brand = Utf8View("Brand#23")) AND (part.p_size <= Int32(10)))) OR ((part.p_brand = Utf8View("Brand#34")) AND (part.p_size <= Int32(15)))) AND (part.p_size >= Int32(1)) +06)------TableScan: part projection=[p_partkey, p_brand, p_size], partial_filters=[part.p_size >= Int32(1), (((part.p_brand = Utf8View("Brand#12")) AND (part.p_size <= Int32(5))) OR ((part.p_brand = Utf8View("Brand#23")) AND (part.p_size <= Int32(10)))) OR ((part.p_brand = Utf8View("Brand#34")) AND (part.p_size <= Int32(15)))] physical_plan 01)HashJoinExec: mode=Partitioned, join_type=Inner, on=[(l_partkey@0, p_partkey@0)], filter=p_brand@1 = Brand#12 AND l_quantity@0 >= Some(100),15,2 AND l_quantity@0 <= Some(1100),15,2 AND p_size@2 <= 5 OR p_brand@1 = Brand#23 AND l_quantity@0 >= Some(1000),15,2 AND l_quantity@0 <= Some(2000),15,2 AND p_size@2 <= 10 OR p_brand@1 = Brand#34 AND l_quantity@0 >= Some(2000),15,2 AND l_quantity@0 <= Some(3000),15,2 AND p_size@2 <= 15, projection=[l_partkey@0] 02)--RepartitionExec: partitioning=Hash([l_partkey@0], 4), input_partitions=4 @@ -750,8 +750,8 @@ logical_plan 05)--------Inner Join: lineitem.l_partkey = part.p_partkey 06)----------TableScan: lineitem projection=[l_partkey, l_extendedprice, l_discount] 07)----------Projection: part.p_partkey -08)------------Filter: part.p_brand = Utf8View("Brand#12") OR part.p_brand = Utf8View("Brand#23") -09)--------------TableScan: part projection=[p_partkey, p_brand], partial_filters=[part.p_brand = Utf8View("Brand#12") OR part.p_brand = Utf8View("Brand#23")] +08)------------Filter: (part.p_brand = Utf8View("Brand#12")) OR (part.p_brand = Utf8View("Brand#23")) +09)--------------TableScan: part projection=[p_partkey, p_brand], partial_filters=[(part.p_brand = Utf8View("Brand#12")) OR (part.p_brand = Utf8View("Brand#23"))] 10)------TableScan: partsupp projection=[ps_partkey, ps_suppkey] physical_plan 01)AggregateExec: mode=SinglePartitioned, gby=[p_partkey@2 as p_partkey], aggr=[sum(lineitem.l_extendedprice), avg(lineitem.l_discount), count(DISTINCT partsupp.ps_suppkey)] @@ -791,7 +791,7 @@ query TT EXPLAIN FORMAT INDENT SELECT * FROM t WHERE x < 5 AND (10 * NULL < x); ---- logical_plan -01)Filter: t.x < Int32(5) AND Boolean(NULL) +01)Filter: (t.x < Int32(5)) AND Boolean(NULL) 02)--TableScan: t projection=[x] physical_plan 01)FilterExec: x@0 < 5 AND NULL @@ -801,7 +801,7 @@ query TT EXPLAIN FORMAT INDENT SELECT * FROM t WHERE x < 5 OR (10 * NULL < x); ---- logical_plan -01)Filter: t.x < Int32(5) OR Boolean(NULL) +01)Filter: (t.x < Int32(5)) OR Boolean(NULL) 02)--TableScan: t projection=[x] physical_plan 01)FilterExec: x@0 < 5 OR NULL diff --git a/datafusion/sqllogictest/test_files/pwmj.slt b/datafusion/sqllogictest/test_files/pwmj.slt index 295eb94318ee5..4a21aa258c436 100644 --- a/datafusion/sqllogictest/test_files/pwmj.slt +++ b/datafusion/sqllogictest/test_files/pwmj.slt @@ -212,7 +212,7 @@ ORDER BY 1,2; ---- logical_plan 01)Sort: t1.t1_id ASC NULLS LAST, t2.t2_id ASC NULLS LAST -02)--Inner Join: Filter: CAST(t1.t1_id AS Int64) < CAST(t2.t2_id AS Int64) + Int64(1) +02)--Inner Join: Filter: CAST(t1.t1_id AS Int64) < (CAST(t2.t2_id AS Int64) + Int64(1)) 03)----SubqueryAlias: t1 04)------TableScan: join_t1 projection=[t1_id] 05)----SubqueryAlias: t2 @@ -258,7 +258,7 @@ logical_plan 01)Sort: t1.t1_id ASC NULLS LAST, t2.t2_id ASC NULLS LAST 02)--Inner Join: Filter: t1.t1_id <= t2.t2_id 03)----SubqueryAlias: t1 -04)------Filter: join_t1.t1_id = Int32(11) OR join_t1.t1_id = Int32(44) +04)------Filter: (join_t1.t1_id = Int32(11)) OR (join_t1.t1_id = Int32(44)) 05)--------TableScan: join_t1 projection=[t1_id] 06)----SubqueryAlias: t2 07)------Projection: join_t2.t2_id @@ -320,7 +320,7 @@ ORDER BY 1,2; logical_plan 01)Sort: left_id ASC NULLS LAST, right_id ASC NULLS LAST 02)--Projection: t1.id AS left_id, t2.id AS right_id -03)----Inner Join: Filter: t1.id < t1.id + t2.id +03)----Inner Join: Filter: t1.id < (t1.id + t2.id) 04)------SubqueryAlias: t1 05)--------TableScan: null_join_t1 projection=[id] 06)------SubqueryAlias: t2 diff --git a/datafusion/sqllogictest/test_files/select.slt b/datafusion/sqllogictest/test_files/select.slt index 490df4b72d17b..834f393c5d531 100644 --- a/datafusion/sqllogictest/test_files/select.slt +++ b/datafusion/sqllogictest/test_files/select.slt @@ -929,7 +929,7 @@ query TT EXPLAIN SELECT c1 BETWEEN 2 AND 3 FROM select_between_data ---- logical_plan -01)Projection: select_between_data.c1 >= Int64(2) AND select_between_data.c1 <= Int64(3) AS select_between_data.c1 BETWEEN Int64(2) AND Int64(3) +01)Projection: (select_between_data.c1 >= Int64(2)) AND (select_between_data.c1 <= Int64(3)) AS select_between_data.c1 BETWEEN Int64(2) AND Int64(3) 02)--TableScan: select_between_data projection=[c1] physical_plan 01)ProjectionExec: expr=[c1@0 >= 2 AND c1@0 <= 3 as select_between_data.c1 BETWEEN Int64(2) AND Int64(3)] @@ -1454,7 +1454,7 @@ ORDER BY c; ---- logical_plan 01)Sort: annotated_data_finite2.c ASC NULLS LAST -02)--Filter: annotated_data_finite2.a = Int32(0) AND annotated_data_finite2.b = Int32(0) +02)--Filter: (annotated_data_finite2.a = Int32(0)) AND (annotated_data_finite2.b = Int32(0)) 03)----TableScan: annotated_data_finite2 projection=[a0, a, b, c, d], partial_filters=[annotated_data_finite2.a = Int32(0), annotated_data_finite2.b = Int32(0)] physical_plan 01)SortPreservingMergeExec: [c@3 ASC NULLS LAST] @@ -1474,7 +1474,7 @@ ORDER BY b, c; ---- logical_plan 01)Sort: annotated_data_finite2.b ASC NULLS LAST, annotated_data_finite2.c ASC NULLS LAST -02)--Filter: annotated_data_finite2.a = Int32(0) AND annotated_data_finite2.b = Int32(0) +02)--Filter: (annotated_data_finite2.a = Int32(0)) AND (annotated_data_finite2.b = Int32(0)) 03)----TableScan: annotated_data_finite2 projection=[a0, a, b, c, d], partial_filters=[annotated_data_finite2.a = Int32(0), annotated_data_finite2.b = Int32(0)] physical_plan 01)SortPreservingMergeExec: [b@2 ASC NULLS LAST, c@3 ASC NULLS LAST] @@ -1494,7 +1494,7 @@ ORDER BY a, b, c; ---- logical_plan 01)Sort: annotated_data_finite2.a ASC NULLS LAST, annotated_data_finite2.b ASC NULLS LAST, annotated_data_finite2.c ASC NULLS LAST -02)--Filter: annotated_data_finite2.a = Int32(0) AND annotated_data_finite2.b = Int32(0) +02)--Filter: (annotated_data_finite2.a = Int32(0)) AND (annotated_data_finite2.b = Int32(0)) 03)----TableScan: annotated_data_finite2 projection=[a0, a, b, c, d], partial_filters=[annotated_data_finite2.a = Int32(0), annotated_data_finite2.b = Int32(0)] physical_plan 01)SortPreservingMergeExec: [a@1 ASC NULLS LAST, b@2 ASC NULLS LAST, c@3 ASC NULLS LAST] @@ -1514,8 +1514,8 @@ ORDER BY c; ---- logical_plan 01)Sort: annotated_data_finite2.c ASC NULLS LAST -02)--Filter: annotated_data_finite2.a = Int32(0) OR annotated_data_finite2.b = Int32(0) -03)----TableScan: annotated_data_finite2 projection=[a0, a, b, c, d], partial_filters=[annotated_data_finite2.a = Int32(0) OR annotated_data_finite2.b = Int32(0)] +02)--Filter: (annotated_data_finite2.a = Int32(0)) OR (annotated_data_finite2.b = Int32(0)) +03)----TableScan: annotated_data_finite2 projection=[a0, a, b, c, d], partial_filters=[(annotated_data_finite2.a = Int32(0)) OR (annotated_data_finite2.b = Int32(0))] physical_plan 01)SortPreservingMergeExec: [c@3 ASC NULLS LAST] 02)--SortExec: expr=[c@3 ASC NULLS LAST], preserve_partitioning=[true] @@ -1657,7 +1657,7 @@ query TT EXPLAIN SELECT y > 0 and 1 / y < 1, x > 0 and y > 0 and 1 / y < 1 / x from t; ---- logical_plan -01)Projection: __common_expr_1 AND Int64(1) / CAST(t.y AS Int64) < Int64(1) AS t.y > Int64(0) AND Int64(1) / t.y < Int64(1), t.x > Int32(0) AND __common_expr_1 AND Int64(1) / CAST(t.y AS Int64) < Int64(1) / CAST(t.x AS Int64) AS t.x > Int64(0) AND t.y > Int64(0) AND Int64(1) / t.y < Int64(1) / t.x +01)Projection: __common_expr_1 AND ((Int64(1) / CAST(t.y AS Int64)) < Int64(1)) AS t.y > Int64(0) AND Int64(1) / t.y < Int64(1), ((t.x > Int32(0)) AND __common_expr_1) AND ((Int64(1) / CAST(t.y AS Int64)) < (Int64(1) / CAST(t.x AS Int64))) AS t.x > Int64(0) AND t.y > Int64(0) AND Int64(1) / t.y < Int64(1) / t.x 02)--Projection: t.y > Int32(0) AS __common_expr_1, t.x, t.y 03)----TableScan: t projection=[x, y] physical_plan @@ -1669,7 +1669,7 @@ query TT EXPLAIN SELECT y = 0 or 1 / y < 1, x = 0 or y = 0 or 1 / y < 1 / x from t; ---- logical_plan -01)Projection: __common_expr_1 OR Int64(1) / CAST(t.y AS Int64) < Int64(1) AS t.y = Int64(0) OR Int64(1) / t.y < Int64(1), t.x = Int32(0) OR __common_expr_1 OR Int64(1) / CAST(t.y AS Int64) < Int64(1) / CAST(t.x AS Int64) AS t.x = Int64(0) OR t.y = Int64(0) OR Int64(1) / t.y < Int64(1) / t.x +01)Projection: __common_expr_1 OR ((Int64(1) / CAST(t.y AS Int64)) < Int64(1)) AS t.y = Int64(0) OR Int64(1) / t.y < Int64(1), ((t.x = Int32(0)) OR __common_expr_1) OR ((Int64(1) / CAST(t.y AS Int64)) < (Int64(1) / CAST(t.x AS Int64))) AS t.x = Int64(0) OR t.y = Int64(0) OR Int64(1) / t.y < Int64(1) / t.x 02)--Projection: t.y = Int32(0) AS __common_expr_1, t.x, t.y 03)----TableScan: t projection=[x, y] physical_plan diff --git a/datafusion/sqllogictest/test_files/simplify_expr.slt b/datafusion/sqllogictest/test_files/simplify_expr.slt index 99fc9900ef619..83874bfcbae03 100644 --- a/datafusion/sqllogictest/test_files/simplify_expr.slt +++ b/datafusion/sqllogictest/test_files/simplify_expr.slt @@ -124,7 +124,7 @@ EXPLAIN SELECT FROM (VALUES (0), (1), (2)) t(v) ---- logical_plan -01)Projection: t.v = Int64(1) AS opt1, t.v = Int64(2) AND t.v != Int64(2) AS noopt1, t.v = Int64(4) AS opt2, t.v != Int64(5) AND t.v = Int64(5) AS noopt2 +01)Projection: t.v = Int64(1) AS opt1, (t.v = Int64(2)) AND (t.v != Int64(2)) AS noopt1, t.v = Int64(4) AS opt2, (t.v != Int64(5)) AND (t.v = Int64(5)) AS noopt2 02)--SubqueryAlias: t 03)----Projection: column1 AS v 04)------Values: (Int64(0)), (Int64(1)), (Int64(2)) diff --git a/datafusion/sqllogictest/test_files/simplify_predicates.slt b/datafusion/sqllogictest/test_files/simplify_predicates.slt index c2a21ea7103c3..a106186442e69 100644 --- a/datafusion/sqllogictest/test_files/simplify_predicates.slt +++ b/datafusion/sqllogictest/test_files/simplify_predicates.slt @@ -67,7 +67,7 @@ query TT EXPLAIN SELECT * FROM test_data WHERE int_col > 5 AND float_col < 10 AND int_col > 6 AND float_col < 8; ---- logical_plan -01)Filter: test_data.float_col < Float32(8) AND test_data.int_col > Int32(6) +01)Filter: (test_data.float_col < Float32(8)) AND (test_data.int_col > Int32(6)) 02)--TableScan: test_data projection=[int_col, float_col, str_col, date_col, bool_col] # x = 7 AND x = 7 should simplify to x = 7 @@ -89,7 +89,7 @@ query TT EXPLAIN SELECT * FROM test_data WHERE int_col = 7 AND int_col < 2; ---- logical_plan -01)Filter: test_data.int_col = Int32(7) AND test_data.int_col < Int32(2) +01)Filter: (test_data.int_col = Int32(7)) AND (test_data.int_col < Int32(2)) 02)--TableScan: test_data projection=[int_col, float_col, str_col, date_col, bool_col] @@ -98,7 +98,7 @@ query TT EXPLAIN SELECT * FROM test_data WHERE int_col = 7 AND int_col > 5; ---- logical_plan -01)Filter: test_data.int_col = Int32(7) AND test_data.int_col > Int32(5) +01)Filter: (test_data.int_col = Int32(7)) AND (test_data.int_col > Int32(5)) 02)--TableScan: test_data projection=[int_col, float_col, str_col, date_col, bool_col] # str_col > 'apple' AND str_col > 'banana' should simplify to str_col > 'banana' @@ -130,7 +130,7 @@ query TT EXPLAIN SELECT * FROM test_data WHERE int_col > float_col AND int_col > 5; ---- logical_plan -01)Filter: CAST(test_data.int_col AS Float32) > test_data.float_col AND test_data.int_col > Int32(5) +01)Filter: (CAST(test_data.int_col AS Float32) > test_data.float_col) AND (test_data.int_col > Int32(5)) 02)--TableScan: test_data projection=[int_col, float_col, str_col, date_col, bool_col] # Should simplify the int_col predicates but preserve the others @@ -142,7 +142,7 @@ WHERE int_col > 5 AND float_col BETWEEN 1 AND 100; ---- logical_plan -01)Filter: test_data.str_col LIKE Utf8View("A%") AND test_data.float_col >= Float32(1) AND test_data.float_col <= Float32(100) AND test_data.int_col > Int32(10) +01)Filter: ((test_data.str_col LIKE Utf8View("A%") AND (test_data.float_col >= Float32(1))) AND (test_data.float_col <= Float32(100))) AND (test_data.int_col > Int32(10)) 02)--TableScan: test_data projection=[int_col, float_col, str_col, date_col, bool_col] statement ok @@ -167,7 +167,7 @@ logical_plan 04)------Filter: test_data.int_col > Int32(10) 05)--------TableScan: test_data projection=[int_col] 06)----SubqueryAlias: t2 -07)------Filter: test_data2.value < Int32(50) AND test_data2.id > Int32(10) +07)------Filter: (test_data2.value < Int32(50)) AND (test_data2.id > Int32(10)) 08)--------TableScan: test_data2 projection=[id, value] # Handling negated predicates @@ -184,7 +184,7 @@ query TT EXPLAIN SELECT * FROM test_data WHERE int_col > 5 AND int_col < 10; ---- logical_plan -01)Filter: test_data.int_col > Int32(5) AND test_data.int_col < Int32(10) +01)Filter: (test_data.int_col > Int32(5)) AND (test_data.int_col < Int32(10)) 02)--TableScan: test_data projection=[int_col, float_col, str_col, date_col, bool_col] # 5 < x AND 3 < x should simplify to 5 < x @@ -217,7 +217,7 @@ WHERE (int_col > 5 OR float_col < 10) AND (int_col > 6 OR float_col < 8); ---- logical_plan -01)Filter: (test_data.int_col > Int32(5) OR test_data.float_col < Float32(10)) AND (test_data.int_col > Int32(6) OR test_data.float_col < Float32(8)) +01)Filter: ((test_data.int_col > Int32(5)) OR (test_data.float_col < Float32(10))) AND ((test_data.int_col > Int32(6)) OR (test_data.float_col < Float32(8))) 02)--TableScan: test_data projection=[int_col, float_col, str_col, date_col, bool_col] # Combination of AND and OR with simplifiable predicates @@ -227,7 +227,7 @@ WHERE (int_col > 5 AND int_col > 6) OR (float_col < 10 AND float_col < 8); ---- logical_plan -01)Filter: test_data.int_col > Int32(5) AND test_data.int_col > Int32(6) OR test_data.float_col < Float32(10) AND test_data.float_col < Float32(8) +01)Filter: ((test_data.int_col > Int32(5)) AND (test_data.int_col > Int32(6))) OR ((test_data.float_col < Float32(10)) AND (test_data.float_col < Float32(8))) 02)--TableScan: test_data projection=[int_col, float_col, str_col, date_col, bool_col] @@ -238,7 +238,7 @@ EXPLAIN SELECT * FROM ( ) WHERE int_col >= 1 AND int_col <= 10; ---- logical_plan -01)Filter: test_data.int_col > Int32(1) AND test_data.int_col < Int32(10) +01)Filter: (test_data.int_col > Int32(1)) AND (test_data.int_col < Int32(10)) 02)--TableScan: test_data projection=[int_col, float_col, str_col, date_col, bool_col] diff --git a/datafusion/sqllogictest/test_files/sort_merge_join.slt b/datafusion/sqllogictest/test_files/sort_merge_join.slt index d2fa37ef76da8..08e194fb590fb 100644 --- a/datafusion/sqllogictest/test_files/sort_merge_join.slt +++ b/datafusion/sqllogictest/test_files/sort_merge_join.slt @@ -33,7 +33,7 @@ query TT EXPLAIN SELECT t1.a, t1.b, t2.a, t2.b FROM t1 JOIN t2 ON t1.a = t2.a AND t2.b * 50 <= t1.b ---- logical_plan -01)Inner Join: t1.a = t2.a Filter: CAST(t2.b AS Int64) * Int64(50) <= CAST(t1.b AS Int64) +01)Inner Join: t1.a = t2.a Filter: (CAST(t2.b AS Int64) * Int64(50)) <= CAST(t1.b AS Int64) 02)--TableScan: t1 projection=[a, b] 03)--TableScan: t2 projection=[a, b] physical_plan diff --git a/datafusion/sqllogictest/test_files/sort_pushdown.slt b/datafusion/sqllogictest/test_files/sort_pushdown.slt index 58d9915a24be2..712e43fced013 100644 --- a/datafusion/sqllogictest/test_files/sort_pushdown.slt +++ b/datafusion/sqllogictest/test_files/sort_pushdown.slt @@ -151,8 +151,8 @@ ORDER BY id DESC LIMIT 5; ---- logical_plan 01)Sort: multi_rg_sorted.id DESC NULLS FIRST, fetch=5 -02)--Filter: multi_rg_sorted.category = Utf8View("alpha") OR multi_rg_sorted.category = Utf8View("gamma") -03)----TableScan: multi_rg_sorted projection=[id, category, value], partial_filters=[multi_rg_sorted.category = Utf8View("alpha") OR multi_rg_sorted.category = Utf8View("gamma")] +02)--Filter: (multi_rg_sorted.category = Utf8View("alpha")) OR (multi_rg_sorted.category = Utf8View("gamma")) +03)----TableScan: multi_rg_sorted projection=[id, category, value], partial_filters=[(multi_rg_sorted.category = Utf8View("alpha")) OR (multi_rg_sorted.category = Utf8View("gamma"))] physical_plan 01)SortExec: TopK(fetch=5), expr=[id@0 DESC], preserve_partitioning=[false] 02)--DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/sort_pushdown/multi_rg_sorted.parquet]]}, projection=[id, category, value], file_type=parquet, predicate=(category@1 = alpha OR category@1 = gamma) AND DynamicFilter [ empty ], reverse_row_groups=true, pruning_predicate=category_null_count@2 != row_count@3 AND category_min@0 <= alpha AND alpha <= category_max@1 OR category_null_count@2 != row_count@3 AND category_min@0 <= gamma AND gamma <= category_max@1, required_guarantees=[category in (alpha, gamma)] @@ -487,8 +487,8 @@ LIMIT 3; ---- logical_plan 01)Sort: timeseries_parquet.period_end DESC NULLS FIRST, fetch=3 -02)--Filter: timeseries_parquet.timeframe = Utf8View("daily") OR timeseries_parquet.timeframe = Utf8View("weekly") -03)----TableScan: timeseries_parquet projection=[timeframe, period_end, value], partial_filters=[timeseries_parquet.timeframe = Utf8View("daily") OR timeseries_parquet.timeframe = Utf8View("weekly")] +02)--Filter: (timeseries_parquet.timeframe = Utf8View("daily")) OR (timeseries_parquet.timeframe = Utf8View("weekly")) +03)----TableScan: timeseries_parquet projection=[timeframe, period_end, value], partial_filters=[(timeseries_parquet.timeframe = Utf8View("daily")) OR (timeseries_parquet.timeframe = Utf8View("weekly"))] physical_plan 01)SortExec: TopK(fetch=3), expr=[period_end@1 DESC], preserve_partitioning=[false] 02)--DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/sort_pushdown/timeseries_sorted.parquet]]}, projection=[timeframe, period_end, value], output_ordering=[timeframe@0 ASC NULLS LAST, period_end@1 ASC NULLS LAST], file_type=parquet, predicate=(timeframe@0 = daily OR timeframe@0 = weekly) AND DynamicFilter [ empty ], pruning_predicate=timeframe_null_count@2 != row_count@3 AND timeframe_min@0 <= daily AND daily <= timeframe_max@1 OR timeframe_null_count@2 != row_count@3 AND timeframe_min@0 <= weekly AND weekly <= timeframe_max@1, required_guarantees=[timeframe in (daily, weekly)] diff --git a/datafusion/sqllogictest/test_files/string/string_view.slt b/datafusion/sqllogictest/test_files/string/string_view.slt index 13b0aba653efb..816c0c9de45c0 100644 --- a/datafusion/sqllogictest/test_files/string/string_view.slt +++ b/datafusion/sqllogictest/test_files/string/string_view.slt @@ -1164,7 +1164,7 @@ query TT explain select column2 || 'is' || column3 from temp; ---- logical_plan -01)Projection: temp.column2 || Utf8View("is") || temp.column3 AS temp.column2 || Utf8("is") || temp.column3 +01)Projection: (temp.column2 || Utf8View("is")) || temp.column3 AS temp.column2 || Utf8("is") || temp.column3 02)--TableScan: temp projection=[column2, column3] # should not cast the column2 to utf8 diff --git a/datafusion/sqllogictest/test_files/subquery.slt b/datafusion/sqllogictest/test_files/subquery.slt index e73f4ec3e32da..1b3eee3abc4af 100644 --- a/datafusion/sqllogictest/test_files/subquery.slt +++ b/datafusion/sqllogictest/test_files/subquery.slt @@ -991,7 +991,7 @@ logical_plan 04)------Left Join: t1.t1_int = __scalar_sq_1.t2_int 05)--------TableScan: t1 projection=[t1_int] 06)--------SubqueryAlias: __scalar_sq_1 -07)----------Projection: count(Int64(1)) + Int64(1) + Int64(1) AS cnt_plus_two, t2.t2_int, count(Int64(1)), Boolean(true) AS __always_true +07)----------Projection: (count(Int64(1)) + Int64(1)) + Int64(1) AS cnt_plus_two, t2.t2_int, count(Int64(1)), Boolean(true) AS __always_true 08)------------Aggregate: groupBy=[[t2.t2_int]], aggr=[[count(Int64(1))]] 09)--------------TableScan: t2 projection=[t2_int] @@ -1060,7 +1060,7 @@ query TT explain SELECT t1_id, (SELECT max(t2.t2_id) is null FROM t2 WHERE t2.t2_int = t1.t1_int) x from t1 ---- logical_plan -01)Projection: t1.t1_id, __scalar_sq_1.__always_true IS NULL OR __scalar_sq_1.__always_true IS NOT NULL AND __scalar_sq_1.max(t2.t2_id) IS NULL AS x +01)Projection: t1.t1_id, __scalar_sq_1.__always_true IS NULL OR (__scalar_sq_1.__always_true IS NOT NULL AND __scalar_sq_1.max(t2.t2_id) IS NULL) AS x 02)--Left Join: t1.t1_int = __scalar_sq_1.t2_int 03)----TableScan: t1 projection=[t1_id, t1_int] 04)----SubqueryAlias: __scalar_sq_1 @@ -1090,7 +1090,7 @@ where t1.t1_id > 40 or t1.t1_id in (select t2.t2_id from t2 where t1.t1_int > 0) ---- logical_plan 01)Projection: t1.t1_id, t1.t1_name, t1.t1_int -02)--Filter: t1.t1_id > Int32(40) OR __correlated_sq_1.mark +02)--Filter: (t1.t1_id > Int32(40)) OR __correlated_sq_1.mark 03)----LeftMark Join: t1.t1_id = __correlated_sq_1.t2_id Filter: t1.t1_int > Int32(0) 04)------TableScan: t1 projection=[t1_id, t1_name, t1_int] 05)------SubqueryAlias: __correlated_sq_1 @@ -1117,7 +1117,7 @@ where t1.t1_id = 11 or t1.t1_id + 12 not in (select t2.t2_id + 1 from t2 where t ---- logical_plan 01)Projection: t1.t1_id, t1.t1_name, t1.t1_int -02)--Filter: t1.t1_id = Int32(11) OR NOT __correlated_sq_1.mark +02)--Filter: (t1.t1_id = Int32(11)) OR NOT __correlated_sq_1.mark 03)----LeftMark Join: CAST(t1.t1_id AS Int64) + Int64(12) = __correlated_sq_1.t2.t2_id + Int64(1) Filter: t1.t1_int > Int32(0) 04)------TableScan: t1 projection=[t1_id, t1_name, t1_int] 05)------SubqueryAlias: __correlated_sq_1 @@ -1144,7 +1144,7 @@ where t1.t1_id > 40 or exists (select * from t2 where t1.t1_id = t2.t2_id) ---- logical_plan 01)Projection: t1.t1_id, t1.t1_name, t1.t1_int -02)--Filter: t1.t1_id > Int32(40) OR __correlated_sq_1.mark +02)--Filter: (t1.t1_id > Int32(40)) OR __correlated_sq_1.mark 03)----LeftMark Join: t1.t1_id = __correlated_sq_1.t2_id 04)------TableScan: t1 projection=[t1_id, t1_name, t1_int] 05)------SubqueryAlias: __correlated_sq_1 @@ -1174,7 +1174,7 @@ where t1.t1_id > 40 or not exists (select * from t2 where t1.t1_id = t2.t2_id) ---- logical_plan 01)Projection: t1.t1_id, t1.t1_name, t1.t1_int -02)--Filter: t1.t1_id > Int32(40) OR NOT __correlated_sq_1.mark +02)--Filter: (t1.t1_id > Int32(40)) OR NOT __correlated_sq_1.mark 03)----LeftMark Join: t1.t1_id = __correlated_sq_1.t2_id 04)------TableScan: t1 projection=[t1_id, t1_name, t1_int] 05)------SubqueryAlias: __correlated_sq_1 @@ -1209,7 +1209,7 @@ where t1.t1_id in (select t3.t3_id from t3) and (t1.t1_id > 40 or t1.t1_id in (s ---- logical_plan 01)Projection: t1.t1_id, t1.t1_name, t1.t1_int -02)--Filter: t1.t1_id > Int32(40) OR __correlated_sq_2.mark +02)--Filter: (t1.t1_id > Int32(40)) OR __correlated_sq_2.mark 03)----LeftMark Join: t1.t1_id = __correlated_sq_2.t2_id Filter: t1.t1_int > Int32(0) 04)------LeftSemi Join: t1.t1_id = __correlated_sq_1.t3_id 05)--------TableScan: t1 projection=[t1_id, t1_name, t1_int] @@ -1507,9 +1507,9 @@ explain select v from (values (1), (6), (10)) set_cmp_t(v) where v > any(select ---- logical_plan 01)Projection: set_cmp_t.v -02)--Filter: __correlated_sq_1.mark OR __correlated_sq_2.mark AND NOT __correlated_sq_3.mark AND Boolean(NULL) +02)--Filter: __correlated_sq_1.mark OR ((__correlated_sq_2.mark AND NOT __correlated_sq_3.mark) AND Boolean(NULL)) 03)----LeftMark Join: Filter: set_cmp_t.v > __correlated_sq_3.v IS TRUE -04)------Filter: __correlated_sq_1.mark OR __correlated_sq_2.mark AND Boolean(NULL) +04)------Filter: __correlated_sq_1.mark OR (__correlated_sq_2.mark AND Boolean(NULL)) 05)--------LeftMark Join: Filter: set_cmp_t.v > __correlated_sq_2.v IS NULL 06)----------Filter: __correlated_sq_1.mark OR Boolean(NULL) 07)------------LeftMark Join: Filter: set_cmp_t.v > __correlated_sq_1.v IS TRUE diff --git a/datafusion/sqllogictest/test_files/update.slt b/datafusion/sqllogictest/test_files/update.slt index a652ae7633e44..c94686f775525 100644 --- a/datafusion/sqllogictest/test_files/update.slt +++ b/datafusion/sqllogictest/test_files/update.slt @@ -73,8 +73,8 @@ explain update t1 set b = t2.b, c = t2.a, d = 1 from t2 where t1.a = t2.a and t1 logical_plan 01)Dml: op=[Update] table=[t1] 02)--Projection: t1.a AS a, t2.b AS b, CAST(t2.a AS Float64) AS c, CAST(Int64(1) AS Int32) AS d -03)----Filter: t1.a = t2.a AND t1.b > CAST(Utf8("foo") AS Utf8View) AND t2.c > Float64(1) -04)------Cross Join: +03)----Filter: ((t1.a = t2.a) AND (t1.b > CAST(Utf8("foo") AS Utf8View))) AND (t2.c > Float64(1)) +04)------Cross Join: 05)--------TableScan: t1 06)--------TableScan: t2 physical_plan @@ -95,8 +95,8 @@ explain update t1 as T set b = t2.b, c = t.a, d = 1 from t2 where t.a = t2.a and logical_plan 01)Dml: op=[Update] table=[t1] 02)--Projection: t.a AS a, t2.b AS b, CAST(t.a AS Float64) AS c, CAST(Int64(1) AS Int32) AS d -03)----Filter: t.a = t2.a AND t.b > CAST(Utf8("foo") AS Utf8View) AND t2.c > Float64(1) -04)------Cross Join: +03)----Filter: ((t.a = t2.a) AND (t.b > CAST(Utf8("foo") AS Utf8View))) AND (t2.c > Float64(1)) +04)------Cross Join: 05)--------SubqueryAlias: t 06)----------TableScan: t1 07)--------TableScan: t2 diff --git a/datafusion/sqllogictest/test_files/window.slt b/datafusion/sqllogictest/test_files/window.slt index 8ac8724683a8a..68e2faa7e86ea 100644 --- a/datafusion/sqllogictest/test_files/window.slt +++ b/datafusion/sqllogictest/test_files/window.slt @@ -5271,7 +5271,7 @@ logical_plan 01)Sort: t1.c1 ASC NULLS LAST, t1.c2 ASC NULLS LAST, rank ASC NULLS LAST 02)--Projection: t1.c1, t1.c2, rank() PARTITION BY [t1.c1] ORDER BY [t1.c2 ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS rank 03)----WindowAggr: windowExpr=[[rank() PARTITION BY [t1.c1] ORDER BY [t1.c2 ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] -04)------Filter: t1.c1 = Int32(2) OR t1.c1 = Int32(3) +04)------Filter: (t1.c1 = Int32(2)) OR (t1.c1 = Int32(3)) 05)--------TableScan: t1 projection=[c1, c2] physical_plan 01)SortPreservingMergeExec: [c1@0 ASC NULLS LAST, c2@1 ASC NULLS LAST, rank@2 ASC NULLS LAST] @@ -5387,7 +5387,7 @@ order by c1, c2, rank; logical_plan 01)Sort: t1.c1 ASC NULLS LAST, t1.c2 ASC NULLS LAST, rank ASC NULLS LAST 02)--Projection: t1.c1, t1.c2, rank() PARTITION BY [t1.c1] ORDER BY [t1.c2 ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS rank -03)----Filter: t1.c1 = Int32(1) OR t1.c2 = Int32(10) +03)----Filter: (t1.c1 = Int32(1)) OR (t1.c2 = Int32(10)) 04)------WindowAggr: windowExpr=[[rank() PARTITION BY [t1.c1] ORDER BY [t1.c2 ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] 05)--------TableScan: t1 projection=[c1, c2] physical_plan @@ -5898,15 +5898,15 @@ LIMIT 5 ---- logical_plan 01)Sort: test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST, fetch=5 -02)--Projection: test.c1, test.c2, sum(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS sum1, sum(test.c2) FILTER (WHERE test.c2 >= Int64(2) AND test.c2 < Int64(4) AND test.c1 > Int64(0)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS sum2, count(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS count1, array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS array_agg1, array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2) AND test.c2 < Int64(4) AND test.c1 > Int64(0)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS array_agg2 -03)----WindowAggr: windowExpr=[[sum(test.c2) FILTER (WHERE __common_expr_1 AS test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS sum(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, sum(test.c2) FILTER (WHERE __common_expr_2) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS sum(test.c2) FILTER (WHERE test.c2 >= Int64(2) AND test.c2 < Int64(4) AND test.c1 > Int64(0)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, count(test.c2) FILTER (WHERE __common_expr_1 AS test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS count(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, array_agg(test.c2) FILTER (WHERE __common_expr_1 AS test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, array_agg(test.c2) FILTER (WHERE __common_expr_2) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2) AND test.c2 < Int64(4) AND test.c1 > Int64(0)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] -04)------Projection: __common_expr_3 AS __common_expr_1, __common_expr_3 AND test.c2 < Int64(4) AND test.c1 > Int32(0) AS __common_expr_2, test.c1, test.c2 +02)--Projection: test.c1, test.c2, sum(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS sum1, sum(test.c2) FILTER (WHERE ((test.c2 >= Int64(2)) AND (test.c2 < Int64(4))) AND (test.c1 > Int64(0))) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS sum2, count(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS count1, array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS array_agg1, array_agg(test.c2) FILTER (WHERE ((test.c2 >= Int64(2)) AND (test.c2 < Int64(4))) AND (test.c1 > Int64(0))) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS array_agg2 +03)----WindowAggr: windowExpr=[[sum(test.c2) FILTER (WHERE __common_expr_1 AS test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS sum(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, sum(test.c2) FILTER (WHERE __common_expr_2) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS sum(test.c2) FILTER (WHERE ((test.c2 >= Int64(2)) AND (test.c2 < Int64(4))) AND (test.c1 > Int64(0))) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, count(test.c2) FILTER (WHERE __common_expr_1 AS test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS count(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, array_agg(test.c2) FILTER (WHERE __common_expr_1 AS test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, array_agg(test.c2) FILTER (WHERE __common_expr_2) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS array_agg(test.c2) FILTER (WHERE ((test.c2 >= Int64(2)) AND (test.c2 < Int64(4))) AND (test.c1 > Int64(0))) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] +04)------Projection: __common_expr_3 AS __common_expr_1, (__common_expr_3 AND (test.c2 < Int64(4))) AND (test.c1 > Int32(0)) AS __common_expr_2, test.c1, test.c2 05)--------Projection: test.c2 >= Int64(2) AS __common_expr_3, test.c1, test.c2 06)----------TableScan: test projection=[c1, c2] physical_plan -01)ProjectionExec: expr=[c1@2 as c1, c2@3 as c2, sum(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW@4 as sum1, sum(test.c2) FILTER (WHERE test.c2 >= Int64(2) AND test.c2 < Int64(4) AND test.c1 > Int64(0)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW@5 as sum2, count(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW@6 as count1, array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW@7 as array_agg1, array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2) AND test.c2 < Int64(4) AND test.c1 > Int64(0)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW@8 as array_agg2] +01)ProjectionExec: expr=[c1@2 as c1, c2@3 as c2, sum(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW@4 as sum1, sum(test.c2) FILTER (WHERE ((test.c2 >= Int64(2)) AND (test.c2 < Int64(4))) AND (test.c1 > Int64(0))) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW@5 as sum2, count(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW@6 as count1, array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW@7 as array_agg1, array_agg(test.c2) FILTER (WHERE ((test.c2 >= Int64(2)) AND (test.c2 < Int64(4))) AND (test.c1 > Int64(0))) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW@8 as array_agg2] 02)--GlobalLimitExec: skip=0, fetch=5 -03)----BoundedWindowAggExec: wdw=[sum(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW: Field { "sum(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW": nullable Int64 }, frame: ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, sum(test.c2) FILTER (WHERE test.c2 >= Int64(2) AND test.c2 < Int64(4) AND test.c1 > Int64(0)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW: Field { "sum(test.c2) FILTER (WHERE test.c2 >= Int64(2) AND test.c2 < Int64(4) AND test.c1 > Int64(0)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW": nullable Int64 }, frame: ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, count(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW: Field { "count(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW": Int64 }, frame: ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW: Field { "array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW": nullable List(Int64) }, frame: ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2) AND test.c2 < Int64(4) AND test.c1 > Int64(0)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW: Field { "array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2) AND test.c2 < Int64(4) AND test.c1 > Int64(0)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW": nullable List(Int64) }, frame: ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW], mode=[Sorted] +03)----BoundedWindowAggExec: wdw=[sum(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW: Field { "sum(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW": nullable Int64 }, frame: ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, sum(test.c2) FILTER (WHERE ((test.c2 >= Int64(2)) AND (test.c2 < Int64(4))) AND (test.c1 > Int64(0))) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW: Field { "sum(test.c2) FILTER (WHERE ((test.c2 >= Int64(2)) AND (test.c2 < Int64(4))) AND (test.c1 > Int64(0))) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW": nullable Int64 }, frame: ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, count(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW: Field { "count(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW": Int64 }, frame: ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW: Field { "array_agg(test.c2) FILTER (WHERE test.c2 >= Int64(2)) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW": nullable List(Int64) }, frame: ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, array_agg(test.c2) FILTER (WHERE ((test.c2 >= Int64(2)) AND (test.c2 < Int64(4))) AND (test.c1 > Int64(0))) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW: Field { "array_agg(test.c2) FILTER (WHERE ((test.c2 >= Int64(2)) AND (test.c2 < Int64(4))) AND (test.c1 > Int64(0))) ORDER BY [test.c1 ASC NULLS LAST, test.c2 ASC NULLS LAST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW": nullable List(Int64) }, frame: ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW], mode=[Sorted] 04)------SortPreservingMergeExec: [c1@2 ASC NULLS LAST, c2@3 ASC NULLS LAST], fetch=5 05)--------SortExec: TopK(fetch=5), expr=[c1@2 ASC NULLS LAST, c2@3 ASC NULLS LAST], preserve_partitioning=[true] 06)----------DataSourceExec: file_groups={4 groups: [[WORKSPACE_ROOT/datafusion/core/tests/data/partitioned_csv/partition-0.csv], [WORKSPACE_ROOT/datafusion/core/tests/data/partitioned_csv/partition-1.csv], [WORKSPACE_ROOT/datafusion/core/tests/data/partitioned_csv/partition-2.csv], [WORKSPACE_ROOT/datafusion/core/tests/data/partitioned_csv/partition-3.csv]]}, projection=[c2@1 >= 2 as __common_expr_1, c2@1 >= 2 AND c2@1 < 4 AND c1@0 > 0 as __common_expr_2, c1, c2], file_type=csv, has_header=false diff --git a/datafusion/substrait/src/logical_plan/consumer/expr/scalar_function.rs b/datafusion/substrait/src/logical_plan/consumer/expr/scalar_function.rs index 10fe58862e021..1a52d4938ee2d 100644 --- a/datafusion/substrait/src/logical_plan/consumer/expr/scalar_function.rs +++ b/datafusion/substrait/src/logical_plan/consumer/expr/scalar_function.rs @@ -435,7 +435,7 @@ mod tests { #[test] fn arg_list_to_binary_op_tree_3_args() -> Result<()> { let expr = arg_list_to_binary_op_tree(Operator::Or, int64_literals(&[1, 2, 3]))?; - assert_snapshot!(expr.to_string(), @"Int64(1) OR Int64(2) OR Int64(3)"); + assert_snapshot!(expr.to_string(), @"Int64(1) OR (Int64(2) OR Int64(3))"); Ok(()) } @@ -443,7 +443,7 @@ mod tests { fn arg_list_to_binary_op_tree_4_args() -> Result<()> { let expr = arg_list_to_binary_op_tree(Operator::Or, int64_literals(&[1, 2, 3, 4]))?; - assert_snapshot!(expr.to_string(), @"Int64(1) OR Int64(2) OR Int64(3) OR Int64(4)"); + assert_snapshot!(expr.to_string(), @"(Int64(1) OR Int64(2)) OR (Int64(3) OR Int64(4))"); Ok(()) } diff --git a/datafusion/substrait/tests/cases/consumer_integration.rs b/datafusion/substrait/tests/cases/consumer_integration.rs index 194098cf060e3..6501f9ba74b3c 100644 --- a/datafusion/substrait/tests/cases/consumer_integration.rs +++ b/datafusion/substrait/tests/cases/consumer_integration.rs @@ -56,8 +56,8 @@ mod tests { Projection: LINEITEM.L_RETURNFLAG, LINEITEM.L_LINESTATUS, sum(LINEITEM.L_QUANTITY) AS SUM_QTY, sum(LINEITEM.L_EXTENDEDPRICE) AS SUM_BASE_PRICE, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS SUM_DISC_PRICE, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT * Int32(1) + LINEITEM.L_TAX) AS SUM_CHARGE, avg(LINEITEM.L_QUANTITY) AS AVG_QTY, avg(LINEITEM.L_EXTENDEDPRICE) AS AVG_PRICE, avg(LINEITEM.L_DISCOUNT) AS AVG_DISC, count(Int64(1)) AS COUNT_ORDER Sort: LINEITEM.L_RETURNFLAG ASC NULLS LAST, LINEITEM.L_LINESTATUS ASC NULLS LAST Aggregate: groupBy=[[LINEITEM.L_RETURNFLAG, LINEITEM.L_LINESTATUS]], aggr=[[sum(LINEITEM.L_QUANTITY), sum(LINEITEM.L_EXTENDEDPRICE), sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT), sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT * Int32(1) + LINEITEM.L_TAX), avg(LINEITEM.L_QUANTITY), avg(LINEITEM.L_EXTENDEDPRICE), avg(LINEITEM.L_DISCOUNT), count(Int64(1))]] - Projection: LINEITEM.L_RETURNFLAG, LINEITEM.L_LINESTATUS, LINEITEM.L_QUANTITY, LINEITEM.L_EXTENDEDPRICE, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT), LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) * (CAST(Int32(1) AS Decimal128(15, 2)) + LINEITEM.L_TAX), LINEITEM.L_DISCOUNT - Filter: LINEITEM.L_SHIPDATE <= Date32("1998-12-01") - IntervalDayTime("IntervalDayTime { days: 0, milliseconds: 10368000 }") + Projection: LINEITEM.L_RETURNFLAG, LINEITEM.L_LINESTATUS, LINEITEM.L_QUANTITY, LINEITEM.L_EXTENDEDPRICE, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT), (LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT)) * (CAST(Int32(1) AS Decimal128(15, 2)) + LINEITEM.L_TAX), LINEITEM.L_DISCOUNT + Filter: LINEITEM.L_SHIPDATE <= (Date32("1998-12-01") - IntervalDayTime("IntervalDayTime { days: 0, milliseconds: 10368000 }")) TableScan: LINEITEM "# ); @@ -73,11 +73,11 @@ mod tests { Limit: skip=0, fetch=100 Sort: SUPPLIER.S_ACCTBAL DESC NULLS FIRST, NATION.N_NAME ASC NULLS LAST, SUPPLIER.S_NAME ASC NULLS LAST, PART.P_PARTKEY ASC NULLS LAST Projection: SUPPLIER.S_ACCTBAL, SUPPLIER.S_NAME, NATION.N_NAME, PART.P_PARTKEY, PART.P_MFGR, SUPPLIER.S_ADDRESS, SUPPLIER.S_PHONE, SUPPLIER.S_COMMENT - Filter: PART.P_PARTKEY = PARTSUPP.PS_PARTKEY AND SUPPLIER.S_SUPPKEY = PARTSUPP.PS_SUPPKEY AND PART.P_SIZE = Int32(15) AND PART.P_TYPE LIKE CAST(Utf8("%BRASS") AS Utf8) AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_REGIONKEY = REGION.R_REGIONKEY AND REGION.R_NAME = Utf8("EUROPE") AND PARTSUPP.PS_SUPPLYCOST = () + Filter: (((PART.P_PARTKEY = PARTSUPP.PS_PARTKEY) AND (SUPPLIER.S_SUPPKEY = PARTSUPP.PS_SUPPKEY)) AND ((PART.P_SIZE = Int32(15)) AND PART.P_TYPE LIKE CAST(Utf8("%BRASS") AS Utf8))) AND (((SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY) AND (NATION.N_REGIONKEY = REGION.R_REGIONKEY)) AND ((REGION.R_NAME = Utf8("EUROPE")) AND (PARTSUPP.PS_SUPPLYCOST = ()))) Subquery: Aggregate: groupBy=[[]], aggr=[[min(PARTSUPP.PS_SUPPLYCOST)]] Projection: PARTSUPP.PS_SUPPLYCOST - Filter: PARTSUPP.PS_PARTKEY = PARTSUPP.PS_PARTKEY AND SUPPLIER.S_SUPPKEY = PARTSUPP.PS_SUPPKEY AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_REGIONKEY = REGION.R_REGIONKEY AND REGION.R_NAME = Utf8("EUROPE") + Filter: ((PARTSUPP.PS_PARTKEY = PARTSUPP.PS_PARTKEY) AND (SUPPLIER.S_SUPPKEY = PARTSUPP.PS_SUPPKEY)) AND ((SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY) AND ((NATION.N_REGIONKEY = REGION.R_REGIONKEY) AND (REGION.R_NAME = Utf8("EUROPE")))) Cross Join: Cross Join: Cross Join: @@ -111,7 +111,7 @@ mod tests { Projection: LINEITEM.L_ORDERKEY, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT), ORDERS.O_ORDERDATE, ORDERS.O_SHIPPRIORITY Aggregate: groupBy=[[LINEITEM.L_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_SHIPPRIORITY]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT)]] Projection: LINEITEM.L_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_SHIPPRIORITY, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) - Filter: CUSTOMER.C_MKTSEGMENT = Utf8("BUILDING") AND CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY AND LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY AND ORDERS.O_ORDERDATE < CAST(Utf8("1995-03-15") AS Date32) AND LINEITEM.L_SHIPDATE > CAST(Utf8("1995-03-15") AS Date32) + Filter: ((CUSTOMER.C_MKTSEGMENT = Utf8("BUILDING")) AND (CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY)) AND ((LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY) AND ((ORDERS.O_ORDERDATE < CAST(Utf8("1995-03-15") AS Date32)) AND (LINEITEM.L_SHIPDATE > CAST(Utf8("1995-03-15") AS Date32)))) Cross Join: Cross Join: TableScan: LINEITEM @@ -132,9 +132,9 @@ mod tests { Sort: ORDERS.O_ORDERPRIORITY ASC NULLS LAST Aggregate: groupBy=[[ORDERS.O_ORDERPRIORITY]], aggr=[[count(Int64(1))]] Projection: ORDERS.O_ORDERPRIORITY - Filter: ORDERS.O_ORDERDATE >= CAST(Utf8("1993-07-01") AS Date32) AND ORDERS.O_ORDERDATE < CAST(Utf8("1993-10-01") AS Date32) AND EXISTS () + Filter: (ORDERS.O_ORDERDATE >= CAST(Utf8("1993-07-01") AS Date32)) AND ((ORDERS.O_ORDERDATE < CAST(Utf8("1993-10-01") AS Date32)) AND EXISTS ()) Subquery: - Filter: LINEITEM.L_ORDERKEY = LINEITEM.L_ORDERKEY AND LINEITEM.L_COMMITDATE < LINEITEM.L_RECEIPTDATE + Filter: (LINEITEM.L_ORDERKEY = LINEITEM.L_ORDERKEY) AND (LINEITEM.L_COMMITDATE < LINEITEM.L_RECEIPTDATE) TableScan: LINEITEM TableScan: ORDERS "# @@ -152,7 +152,7 @@ mod tests { Sort: sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) DESC NULLS FIRST Aggregate: groupBy=[[NATION.N_NAME]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT)]] Projection: NATION.N_NAME, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) - Filter: CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY AND LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY AND LINEITEM.L_SUPPKEY = SUPPLIER.S_SUPPKEY AND CUSTOMER.C_NATIONKEY = SUPPLIER.S_NATIONKEY AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_REGIONKEY = REGION.R_REGIONKEY AND REGION.R_NAME = Utf8("ASIA") AND ORDERS.O_ORDERDATE >= CAST(Utf8("1994-01-01") AS Date32) AND ORDERS.O_ORDERDATE < CAST(Utf8("1995-01-01") AS Date32) + Filter: (((CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY) AND (LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY)) AND ((LINEITEM.L_SUPPKEY = SUPPLIER.S_SUPPKEY) AND (CUSTOMER.C_NATIONKEY = SUPPLIER.S_NATIONKEY))) AND (((SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY) AND (NATION.N_REGIONKEY = REGION.R_REGIONKEY)) AND ((REGION.R_NAME = Utf8("ASIA")) AND ((ORDERS.O_ORDERDATE >= CAST(Utf8("1994-01-01") AS Date32)) AND (ORDERS.O_ORDERDATE < CAST(Utf8("1995-01-01") AS Date32))))) Cross Join: Cross Join: Cross Join: @@ -177,7 +177,7 @@ mod tests { @r#" Aggregate: groupBy=[[]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * LINEITEM.L_DISCOUNT) AS REVENUE]] Projection: LINEITEM.L_EXTENDEDPRICE * LINEITEM.L_DISCOUNT - Filter: LINEITEM.L_SHIPDATE >= CAST(Utf8("1994-01-01") AS Date32) AND LINEITEM.L_SHIPDATE < CAST(Utf8("1995-01-01") AS Date32) AND LINEITEM.L_DISCOUNT >= Decimal128(Some(5),3,2) AND LINEITEM.L_DISCOUNT <= Decimal128(Some(7),3,2) AND LINEITEM.L_QUANTITY < CAST(Int32(24) AS Decimal128(15, 2)) + Filter: ((LINEITEM.L_SHIPDATE >= CAST(Utf8("1994-01-01") AS Date32)) AND (LINEITEM.L_SHIPDATE < CAST(Utf8("1995-01-01") AS Date32))) AND ((LINEITEM.L_DISCOUNT >= Decimal128(Some(5),3,2)) AND ((LINEITEM.L_DISCOUNT <= Decimal128(Some(7),3,2)) AND (LINEITEM.L_QUANTITY < CAST(Int32(24) AS Decimal128(15, 2))))) TableScan: LINEITEM "# ); @@ -220,7 +220,7 @@ mod tests { Projection: CUSTOMER.C_CUSTKEY, CUSTOMER.C_NAME, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT), CUSTOMER.C_ACCTBAL, NATION.N_NAME, CUSTOMER.C_ADDRESS, CUSTOMER.C_PHONE, CUSTOMER.C_COMMENT Aggregate: groupBy=[[CUSTOMER.C_CUSTKEY, CUSTOMER.C_NAME, CUSTOMER.C_ACCTBAL, CUSTOMER.C_PHONE, NATION.N_NAME, CUSTOMER.C_ADDRESS, CUSTOMER.C_COMMENT]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT)]] Projection: CUSTOMER.C_CUSTKEY, CUSTOMER.C_NAME, CUSTOMER.C_ACCTBAL, CUSTOMER.C_PHONE, NATION.N_NAME, CUSTOMER.C_ADDRESS, CUSTOMER.C_COMMENT, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) - Filter: CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY AND LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY AND ORDERS.O_ORDERDATE >= CAST(Utf8("1993-10-01") AS Date32) AND ORDERS.O_ORDERDATE < CAST(Utf8("1994-01-01") AS Date32) AND LINEITEM.L_RETURNFLAG = Utf8("R") AND CUSTOMER.C_NATIONKEY = NATION.N_NATIONKEY + Filter: ((CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY) AND ((LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY) AND (ORDERS.O_ORDERDATE >= CAST(Utf8("1993-10-01") AS Date32)))) AND ((ORDERS.O_ORDERDATE < CAST(Utf8("1994-01-01") AS Date32)) AND ((LINEITEM.L_RETURNFLAG = Utf8("R")) AND (CUSTOMER.C_NATIONKEY = NATION.N_NATIONKEY))) Cross Join: Cross Join: Cross Join: @@ -246,7 +246,7 @@ mod tests { Projection: sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY) * Decimal128(Some(1000000),11,10) Aggregate: groupBy=[[]], aggr=[[sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY)]] Projection: PARTSUPP.PS_SUPPLYCOST * CAST(PARTSUPP.PS_AVAILQTY AS Decimal128(19, 0)) - Filter: PARTSUPP.PS_SUPPKEY = SUPPLIER.S_SUPPKEY AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_NAME = Utf8("JAPAN") + Filter: (PARTSUPP.PS_SUPPKEY = SUPPLIER.S_SUPPKEY) AND ((SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY) AND (NATION.N_NAME = Utf8("JAPAN"))) Cross Join: Cross Join: TableScan: PARTSUPP @@ -254,7 +254,7 @@ mod tests { TableScan: NATION Aggregate: groupBy=[[PARTSUPP.PS_PARTKEY]], aggr=[[sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY)]] Projection: PARTSUPP.PS_PARTKEY, PARTSUPP.PS_SUPPLYCOST * CAST(PARTSUPP.PS_AVAILQTY AS Decimal128(19, 0)) - Filter: PARTSUPP.PS_SUPPKEY = SUPPLIER.S_SUPPKEY AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_NAME = Utf8("JAPAN") + Filter: (PARTSUPP.PS_SUPPKEY = SUPPLIER.S_SUPPKEY) AND ((SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY) AND (NATION.N_NAME = Utf8("JAPAN"))) Cross Join: Cross Join: TableScan: PARTSUPP @@ -274,8 +274,8 @@ mod tests { Projection: LINEITEM.L_SHIPMODE, sum(CASE WHEN ORDERS.O_ORDERPRIORITY = Utf8("1-URGENT") OR ORDERS.O_ORDERPRIORITY = Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END) AS HIGH_LINE_COUNT, sum(CASE WHEN ORDERS.O_ORDERPRIORITY != Utf8("1-URGENT") AND ORDERS.O_ORDERPRIORITY != Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END) AS LOW_LINE_COUNT Sort: LINEITEM.L_SHIPMODE ASC NULLS LAST Aggregate: groupBy=[[LINEITEM.L_SHIPMODE]], aggr=[[sum(CASE WHEN ORDERS.O_ORDERPRIORITY = Utf8("1-URGENT") OR ORDERS.O_ORDERPRIORITY = Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END), sum(CASE WHEN ORDERS.O_ORDERPRIORITY != Utf8("1-URGENT") AND ORDERS.O_ORDERPRIORITY != Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END)]] - Projection: LINEITEM.L_SHIPMODE, CASE WHEN ORDERS.O_ORDERPRIORITY = Utf8("1-URGENT") OR ORDERS.O_ORDERPRIORITY = Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END, CASE WHEN ORDERS.O_ORDERPRIORITY != Utf8("1-URGENT") AND ORDERS.O_ORDERPRIORITY != Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END - Filter: ORDERS.O_ORDERKEY = LINEITEM.L_ORDERKEY AND (LINEITEM.L_SHIPMODE = CAST(Utf8("MAIL") AS Utf8) OR LINEITEM.L_SHIPMODE = CAST(Utf8("SHIP") AS Utf8)) AND LINEITEM.L_COMMITDATE < LINEITEM.L_RECEIPTDATE AND LINEITEM.L_SHIPDATE < LINEITEM.L_COMMITDATE AND LINEITEM.L_RECEIPTDATE >= CAST(Utf8("1994-01-01") AS Date32) AND LINEITEM.L_RECEIPTDATE < CAST(Utf8("1995-01-01") AS Date32) + Projection: LINEITEM.L_SHIPMODE, CASE WHEN (ORDERS.O_ORDERPRIORITY = Utf8("1-URGENT")) OR (ORDERS.O_ORDERPRIORITY = Utf8("2-HIGH")) THEN Int32(1) ELSE Int32(0) END, CASE WHEN (ORDERS.O_ORDERPRIORITY != Utf8("1-URGENT")) AND (ORDERS.O_ORDERPRIORITY != Utf8("2-HIGH")) THEN Int32(1) ELSE Int32(0) END + Filter: ((ORDERS.O_ORDERKEY = LINEITEM.L_ORDERKEY) AND (((LINEITEM.L_SHIPMODE = CAST(Utf8("MAIL") AS Utf8)) OR (LINEITEM.L_SHIPMODE = CAST(Utf8("SHIP") AS Utf8))) AND (LINEITEM.L_COMMITDATE < LINEITEM.L_RECEIPTDATE))) AND ((LINEITEM.L_SHIPDATE < LINEITEM.L_COMMITDATE) AND ((LINEITEM.L_RECEIPTDATE >= CAST(Utf8("1994-01-01") AS Date32)) AND (LINEITEM.L_RECEIPTDATE < CAST(Utf8("1995-01-01") AS Date32)))) Cross Join: TableScan: ORDERS TableScan: LINEITEM @@ -310,10 +310,10 @@ mod tests { assert_snapshot!( plan_str, @r#" - Projection: Decimal128(Some(10000),5,2) * sum(CASE WHEN PART.P_TYPE LIKE Utf8("PROMO%") THEN LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT ELSE Decimal128(Some(0),19,4) END) / sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS PROMO_REVENUE + Projection: (Decimal128(Some(10000),5,2) * sum(CASE WHEN PART.P_TYPE LIKE Utf8("PROMO%") THEN LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT ELSE Decimal128(Some(0),19,4) END)) / sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS PROMO_REVENUE Aggregate: groupBy=[[]], aggr=[[sum(CASE WHEN PART.P_TYPE LIKE Utf8("PROMO%") THEN LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT ELSE Decimal128(Some(0),19,4) END), sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT)]] Projection: CASE WHEN PART.P_TYPE LIKE CAST(Utf8("PROMO%") AS Utf8) THEN LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) ELSE Decimal128(Some(0),19,4) END, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) - Filter: LINEITEM.L_PARTKEY = PART.P_PARTKEY AND LINEITEM.L_SHIPDATE >= Date32("1995-09-01") AND LINEITEM.L_SHIPDATE < CAST(Utf8("1995-10-01") AS Date32) + Filter: (LINEITEM.L_PARTKEY = PART.P_PARTKEY) AND ((LINEITEM.L_SHIPDATE >= Date32("1995-09-01")) AND (LINEITEM.L_SHIPDATE < CAST(Utf8("1995-10-01") AS Date32))) Cross Join: TableScan: LINEITEM TableScan: PART @@ -340,7 +340,7 @@ mod tests { Sort: count(DISTINCT PARTSUPP.PS_SUPPKEY) DESC NULLS FIRST, PART.P_BRAND ASC NULLS LAST, PART.P_TYPE ASC NULLS LAST, PART.P_SIZE ASC NULLS LAST Aggregate: groupBy=[[PART.P_BRAND, PART.P_TYPE, PART.P_SIZE]], aggr=[[count(DISTINCT PARTSUPP.PS_SUPPKEY)]] Projection: PART.P_BRAND, PART.P_TYPE, PART.P_SIZE, PARTSUPP.PS_SUPPKEY - Filter: PART.P_PARTKEY = PARTSUPP.PS_PARTKEY AND PART.P_BRAND != Utf8("Brand#45") AND NOT PART.P_TYPE LIKE CAST(Utf8("MEDIUM POLISHED%") AS Utf8) AND (PART.P_SIZE = Int32(49) OR PART.P_SIZE = Int32(14) OR PART.P_SIZE = Int32(23) OR PART.P_SIZE = Int32(45) OR PART.P_SIZE = Int32(19) OR PART.P_SIZE = Int32(3) OR PART.P_SIZE = Int32(36) OR PART.P_SIZE = Int32(9)) AND NOT PARTSUPP.PS_SUPPKEY IN () + Filter: ((PART.P_PARTKEY = PARTSUPP.PS_PARTKEY) AND (PART.P_BRAND != Utf8("Brand#45"))) AND (NOT PART.P_TYPE LIKE CAST(Utf8("MEDIUM POLISHED%") AS Utf8) AND (((((PART.P_SIZE = Int32(49)) OR (PART.P_SIZE = Int32(14))) OR ((PART.P_SIZE = Int32(23)) OR (PART.P_SIZE = Int32(45)))) OR (((PART.P_SIZE = Int32(19)) OR (PART.P_SIZE = Int32(3))) OR ((PART.P_SIZE = Int32(36)) OR (PART.P_SIZE = Int32(9))))) AND NOT PARTSUPP.PS_SUPPKEY IN ())) Subquery: Projection: SUPPLIER.S_SUPPKEY Filter: SUPPLIER.S_COMMENT LIKE CAST(Utf8("%Customer%Complaints%") AS Utf8) @@ -366,13 +366,13 @@ mod tests { let plan_str = tpch_plan_to_string(18).await?; assert_snapshot!( plan_str, - @r" + @" Projection: CUSTOMER.C_NAME, CUSTOMER.C_CUSTKEY, ORDERS.O_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_TOTALPRICE, sum(LINEITEM.L_QUANTITY) AS EXPR$5 Limit: skip=0, fetch=100 Sort: ORDERS.O_TOTALPRICE DESC NULLS FIRST, ORDERS.O_ORDERDATE ASC NULLS LAST Aggregate: groupBy=[[CUSTOMER.C_NAME, CUSTOMER.C_CUSTKEY, ORDERS.O_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_TOTALPRICE]], aggr=[[sum(LINEITEM.L_QUANTITY)]] Projection: CUSTOMER.C_NAME, CUSTOMER.C_CUSTKEY, ORDERS.O_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_TOTALPRICE, LINEITEM.L_QUANTITY - Filter: ORDERS.O_ORDERKEY IN () AND CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY AND ORDERS.O_ORDERKEY = LINEITEM.L_ORDERKEY + Filter: ORDERS.O_ORDERKEY IN () AND ((CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY) AND (ORDERS.O_ORDERKEY = LINEITEM.L_ORDERKEY)) Subquery: Projection: LINEITEM.L_ORDERKEY Filter: sum(LINEITEM.L_QUANTITY) > CAST(Int32(300) AS Decimal128(15, 2)) @@ -396,7 +396,7 @@ mod tests { @r#" Aggregate: groupBy=[[]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS REVENUE]] Projection: LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) - Filter: PART.P_PARTKEY = LINEITEM.L_PARTKEY AND PART.P_BRAND = Utf8("Brand#12") AND (PART.P_CONTAINER = CAST(Utf8("SM CASE") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("SM BOX") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("SM PACK") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("SM PKG") AS Utf8)) AND LINEITEM.L_QUANTITY >= CAST(Int32(1) AS Decimal128(15, 2)) AND LINEITEM.L_QUANTITY <= CAST(Int32(1) + Int32(10) AS Decimal128(15, 2)) AND PART.P_SIZE >= Int32(1) AND PART.P_SIZE <= Int32(5) AND (LINEITEM.L_SHIPMODE = CAST(Utf8("AIR") AS Utf8) OR LINEITEM.L_SHIPMODE = CAST(Utf8("AIR REG") AS Utf8)) AND LINEITEM.L_SHIPINSTRUCT = Utf8("DELIVER IN PERSON") OR PART.P_PARTKEY = LINEITEM.L_PARTKEY AND PART.P_BRAND = Utf8("Brand#23") AND (PART.P_CONTAINER = CAST(Utf8("MED BAG") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("MED BOX") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("MED PKG") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("MED PACK") AS Utf8)) AND LINEITEM.L_QUANTITY >= CAST(Int32(10) AS Decimal128(15, 2)) AND LINEITEM.L_QUANTITY <= CAST(Int32(10) + Int32(10) AS Decimal128(15, 2)) AND PART.P_SIZE >= Int32(1) AND PART.P_SIZE <= Int32(10) AND (LINEITEM.L_SHIPMODE = CAST(Utf8("AIR") AS Utf8) OR LINEITEM.L_SHIPMODE = CAST(Utf8("AIR REG") AS Utf8)) AND LINEITEM.L_SHIPINSTRUCT = Utf8("DELIVER IN PERSON") OR PART.P_PARTKEY = LINEITEM.L_PARTKEY AND PART.P_BRAND = Utf8("Brand#34") AND (PART.P_CONTAINER = CAST(Utf8("LG CASE") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("LG BOX") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("LG PACK") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("LG PKG") AS Utf8)) AND LINEITEM.L_QUANTITY >= CAST(Int32(20) AS Decimal128(15, 2)) AND LINEITEM.L_QUANTITY <= CAST(Int32(20) + Int32(10) AS Decimal128(15, 2)) AND PART.P_SIZE >= Int32(1) AND PART.P_SIZE <= Int32(15) AND (LINEITEM.L_SHIPMODE = CAST(Utf8("AIR") AS Utf8) OR LINEITEM.L_SHIPMODE = CAST(Utf8("AIR REG") AS Utf8)) AND LINEITEM.L_SHIPINSTRUCT = Utf8("DELIVER IN PERSON") + Filter: ((((PART.P_PARTKEY = LINEITEM.L_PARTKEY) AND (PART.P_BRAND = Utf8("Brand#12"))) AND ((((PART.P_CONTAINER = CAST(Utf8("SM CASE") AS Utf8)) OR (PART.P_CONTAINER = CAST(Utf8("SM BOX") AS Utf8))) OR ((PART.P_CONTAINER = CAST(Utf8("SM PACK") AS Utf8)) OR (PART.P_CONTAINER = CAST(Utf8("SM PKG") AS Utf8)))) AND (LINEITEM.L_QUANTITY >= CAST(Int32(1) AS Decimal128(15, 2))))) AND (((LINEITEM.L_QUANTITY <= CAST(Int32(1) + Int32(10) AS Decimal128(15, 2))) AND (PART.P_SIZE >= Int32(1))) AND ((PART.P_SIZE <= Int32(5)) AND (((LINEITEM.L_SHIPMODE = CAST(Utf8("AIR") AS Utf8)) OR (LINEITEM.L_SHIPMODE = CAST(Utf8("AIR REG") AS Utf8))) AND (LINEITEM.L_SHIPINSTRUCT = Utf8("DELIVER IN PERSON")))))) OR (((((PART.P_PARTKEY = LINEITEM.L_PARTKEY) AND (PART.P_BRAND = Utf8("Brand#23"))) AND ((((PART.P_CONTAINER = CAST(Utf8("MED BAG") AS Utf8)) OR (PART.P_CONTAINER = CAST(Utf8("MED BOX") AS Utf8))) OR ((PART.P_CONTAINER = CAST(Utf8("MED PKG") AS Utf8)) OR (PART.P_CONTAINER = CAST(Utf8("MED PACK") AS Utf8)))) AND (LINEITEM.L_QUANTITY >= CAST(Int32(10) AS Decimal128(15, 2))))) AND (((LINEITEM.L_QUANTITY <= CAST(Int32(10) + Int32(10) AS Decimal128(15, 2))) AND (PART.P_SIZE >= Int32(1))) AND ((PART.P_SIZE <= Int32(10)) AND (((LINEITEM.L_SHIPMODE = CAST(Utf8("AIR") AS Utf8)) OR (LINEITEM.L_SHIPMODE = CAST(Utf8("AIR REG") AS Utf8))) AND (LINEITEM.L_SHIPINSTRUCT = Utf8("DELIVER IN PERSON")))))) OR ((((PART.P_PARTKEY = LINEITEM.L_PARTKEY) AND (PART.P_BRAND = Utf8("Brand#34"))) AND ((((PART.P_CONTAINER = CAST(Utf8("LG CASE") AS Utf8)) OR (PART.P_CONTAINER = CAST(Utf8("LG BOX") AS Utf8))) OR ((PART.P_CONTAINER = CAST(Utf8("LG PACK") AS Utf8)) OR (PART.P_CONTAINER = CAST(Utf8("LG PKG") AS Utf8)))) AND (LINEITEM.L_QUANTITY >= CAST(Int32(20) AS Decimal128(15, 2))))) AND (((LINEITEM.L_QUANTITY <= CAST(Int32(20) + Int32(10) AS Decimal128(15, 2))) AND (PART.P_SIZE >= Int32(1))) AND ((PART.P_SIZE <= Int32(15)) AND (((LINEITEM.L_SHIPMODE = CAST(Utf8("AIR") AS Utf8)) OR (LINEITEM.L_SHIPMODE = CAST(Utf8("AIR REG") AS Utf8))) AND (LINEITEM.L_SHIPINSTRUCT = Utf8("DELIVER IN PERSON"))))))) Cross Join: TableScan: LINEITEM TableScan: PART @@ -413,10 +413,10 @@ mod tests { @r#" Sort: SUPPLIER.S_NAME ASC NULLS LAST Projection: SUPPLIER.S_NAME, SUPPLIER.S_ADDRESS - Filter: SUPPLIER.S_SUPPKEY IN () AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_NAME = Utf8("CANADA") + Filter: SUPPLIER.S_SUPPKEY IN () AND ((SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY) AND (NATION.N_NAME = Utf8("CANADA"))) Subquery: Projection: PARTSUPP.PS_SUPPKEY - Filter: PARTSUPP.PS_PARTKEY IN () AND CAST(PARTSUPP.PS_AVAILQTY AS Decimal128(19, 0)) > () + Filter: PARTSUPP.PS_PARTKEY IN () AND (CAST(PARTSUPP.PS_AVAILQTY AS Decimal128(19, 0)) > ()) Subquery: Projection: PART.P_PARTKEY Filter: PART.P_NAME LIKE CAST(Utf8("forest%") AS Utf8) @@ -425,7 +425,7 @@ mod tests { Projection: Decimal128(Some(5),2,1) * sum(LINEITEM.L_QUANTITY) Aggregate: groupBy=[[]], aggr=[[sum(LINEITEM.L_QUANTITY)]] Projection: LINEITEM.L_QUANTITY - Filter: LINEITEM.L_PARTKEY = LINEITEM.L_ORDERKEY AND LINEITEM.L_SUPPKEY = LINEITEM.L_PARTKEY AND LINEITEM.L_SHIPDATE >= CAST(Utf8("1994-01-01") AS Date32) AND LINEITEM.L_SHIPDATE < CAST(Utf8("1995-01-01") AS Date32) + Filter: ((LINEITEM.L_PARTKEY = LINEITEM.L_ORDERKEY) AND (LINEITEM.L_SUPPKEY = LINEITEM.L_PARTKEY)) AND ((LINEITEM.L_SHIPDATE >= CAST(Utf8("1994-01-01") AS Date32)) AND (LINEITEM.L_SHIPDATE < CAST(Utf8("1995-01-01") AS Date32))) TableScan: LINEITEM TableScan: PARTSUPP Cross Join: @@ -447,12 +447,12 @@ mod tests { Sort: count(Int64(1)) DESC NULLS FIRST, SUPPLIER.S_NAME ASC NULLS LAST Aggregate: groupBy=[[SUPPLIER.S_NAME]], aggr=[[count(Int64(1))]] Projection: SUPPLIER.S_NAME - Filter: SUPPLIER.S_SUPPKEY = LINEITEM.L_SUPPKEY AND ORDERS.O_ORDERKEY = LINEITEM.L_ORDERKEY AND ORDERS.O_ORDERSTATUS = Utf8("F") AND LINEITEM.L_RECEIPTDATE > LINEITEM.L_COMMITDATE AND EXISTS () AND NOT EXISTS () AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_NAME = Utf8("SAUDI ARABIA") + Filter: (((SUPPLIER.S_SUPPKEY = LINEITEM.L_SUPPKEY) AND (ORDERS.O_ORDERKEY = LINEITEM.L_ORDERKEY)) AND ((ORDERS.O_ORDERSTATUS = Utf8("F")) AND (LINEITEM.L_RECEIPTDATE > LINEITEM.L_COMMITDATE))) AND ((EXISTS () AND NOT EXISTS ()) AND ((SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY) AND (NATION.N_NAME = Utf8("SAUDI ARABIA")))) Subquery: - Filter: LINEITEM.L_ORDERKEY = LINEITEM.L_TAX AND LINEITEM.L_SUPPKEY != LINEITEM.L_LINESTATUS + Filter: (LINEITEM.L_ORDERKEY = LINEITEM.L_TAX) AND (LINEITEM.L_SUPPKEY != LINEITEM.L_LINESTATUS) TableScan: LINEITEM Subquery: - Filter: LINEITEM.L_ORDERKEY = LINEITEM.L_TAX AND LINEITEM.L_SUPPKEY != LINEITEM.L_LINESTATUS AND LINEITEM.L_RECEIPTDATE > LINEITEM.L_COMMITDATE + Filter: (LINEITEM.L_ORDERKEY = LINEITEM.L_TAX) AND ((LINEITEM.L_SUPPKEY != LINEITEM.L_LINESTATUS) AND (LINEITEM.L_RECEIPTDATE > LINEITEM.L_COMMITDATE)) TableScan: LINEITEM Cross Join: Cross Join: @@ -476,11 +476,11 @@ mod tests { Sort: substr(CUSTOMER.C_PHONE,Int32(1),Int32(2)) ASC NULLS LAST Aggregate: groupBy=[[substr(CUSTOMER.C_PHONE,Int32(1),Int32(2))]], aggr=[[count(Int64(1)), sum(CUSTOMER.C_ACCTBAL)]] Projection: substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)), CUSTOMER.C_ACCTBAL - Filter: (substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("13") AS Utf8) OR substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("31") AS Utf8) OR substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("23") AS Utf8) OR substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("29") AS Utf8) OR substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("30") AS Utf8) OR substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("18") AS Utf8) OR substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("17") AS Utf8)) AND CUSTOMER.C_ACCTBAL > () AND NOT EXISTS () + Filter: (((substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("13") AS Utf8)) OR ((substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("31") AS Utf8)) OR (substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("23") AS Utf8)))) OR (((substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("29") AS Utf8)) OR (substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("30") AS Utf8))) OR ((substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("18") AS Utf8)) OR (substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("17") AS Utf8))))) AND ((CUSTOMER.C_ACCTBAL > ()) AND NOT EXISTS ()) Subquery: Aggregate: groupBy=[[]], aggr=[[avg(CUSTOMER.C_ACCTBAL)]] Projection: CUSTOMER.C_ACCTBAL - Filter: CUSTOMER.C_ACCTBAL > Decimal128(Some(0),3,2) AND (substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("13") AS Utf8) OR substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("31") AS Utf8) OR substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("23") AS Utf8) OR substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("29") AS Utf8) OR substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("30") AS Utf8) OR substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("18") AS Utf8) OR substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("17") AS Utf8)) + Filter: (CUSTOMER.C_ACCTBAL > Decimal128(Some(0),3,2)) AND (((substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("13") AS Utf8)) OR ((substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("31") AS Utf8)) OR (substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("23") AS Utf8)))) OR (((substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("29") AS Utf8)) OR (substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("30") AS Utf8))) OR ((substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("18") AS Utf8)) OR (substr(CUSTOMER.C_PHONE, Int32(1), Int32(2)) = CAST(Utf8("17") AS Utf8))))) TableScan: CUSTOMER Subquery: Filter: ORDERS.O_CUSTKEY = ORDERS.O_ORDERKEY @@ -686,7 +686,7 @@ mod tests { assert_snapshot!( plan_str, @r#" - Projection: left.index_name AS index, right.upper(host) AS host, left.max(size_bytes) AS idx_size, right.max(total_bytes) AS db_size, CAST(left.max(size_bytes) AS Float64) / CAST(right.max(total_bytes) AS Float64) * Float64(100) AS pct_of_db + Projection: left.index_name AS index, right.upper(host) AS host, left.max(size_bytes) AS idx_size, right.max(total_bytes) AS db_size, (CAST(left.max(size_bytes) AS Float64) / CAST(right.max(total_bytes) AS Float64)) * Float64(100) AS pct_of_db Inner Join: left.upper(host) = right.upper(host) SubqueryAlias: left Aggregate: groupBy=[[index_name, upper(host)]], aggr=[[max(size_bytes)]] diff --git a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs index f78b255526dc9..db8317fdd6f54 100644 --- a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs +++ b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs @@ -632,12 +632,12 @@ async fn roundtrip_inlist_5() -> Result<()> { plan, @r#" Projection: data.a, data.f - Filter: data.f = Utf8("a") OR data.f = Utf8("b") OR data.f = Utf8("c") OR data2.mark + Filter: (((data.f = Utf8("a")) OR (data.f = Utf8("b"))) OR (data.f = Utf8("c"))) OR data2.mark LeftMark Join: data.a = data2.a TableScan: data projection=[a, f] Projection: data2.a - Filter: data2.f = Utf8("b") OR data2.f = Utf8("c") OR data2.f = Utf8("d") - TableScan: data2 projection=[a, f], partial_filters=[data2.f = Utf8("b") OR data2.f = Utf8("c") OR data2.f = Utf8("d")] + Filter: ((data2.f = Utf8("b")) OR (data2.f = Utf8("c"))) OR (data2.f = Utf8("d")) + TableScan: data2 projection=[a, f], partial_filters=[((data2.f = Utf8("b")) OR (data2.f = Utf8("c"))) OR (data2.f = Utf8("d"))] "# ); Ok(())