You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@r#"SELECT * FROM left_table AS "left" INNER JOIN right_table ON "left".id = right_table.id AND (("left".id > 5) AND ("left"."name" LIKE 'some_name' AND (age > 10)))"#
1831
+
@r#"SELECT * FROM left_table AS "left" INNER JOIN right_table ON "left".id = right_table.id AND ("left".id > 5) WHERE "left"."name" LIKE 'some_name' AND (age > 10)"#
1832
1832
);
1833
1833
1834
1834
let join_plan_no_filter = LogicalPlanBuilder::from(left_plan.clone())
let sql = plan_to_sql(&join_plan_multiple_filters)?;
1869
1869
assert_snapshot!(
1870
1870
sql,
1871
-
@r#"SELECT * FROM left_table AS "left" INNER JOIN right_table ON "left".id = right_table.id AND (("left".id > 5) AND (("left"."name" LIKE 'some_name' AND (right_table."name" = 'before_join_filter_val')) AND (age > 10))) WHERE ("left"."name" = 'after_join_filter_val')"#
1871
+
@r#"SELECT * FROM left_table AS "left" INNER JOIN right_table ON "left".id = right_table.id AND ("left".id > 5) WHERE ("left"."name" = 'after_join_filter_val') AND "left"."name" LIKE 'some_name' AND (right_table."name" = 'before_join_filter_val') AND (age > 10)"#
1872
1872
);
1873
1873
1874
1874
let right_plan_with_filter_schema = table_scan_with_filters(
let sql = plan_to_sql(&join_plan_duplicated_filter)?;
1899
1899
assert_snapshot!(
1900
1900
sql,
1901
-
@r#"SELECT * FROM left_table AS "left" INNER JOIN right_table ON "left".id = right_table.id AND (("left".id > 5) AND (("left"."name" LIKE 'some_name' AND (right_table.age > 10)) AND (right_table.age < 11)))"#
1901
+
@r#"SELECT * FROM left_table AS "left" INNER JOIN right_table ON "left".id = right_table.id AND ("left".id > 5) WHERE "left"."name" LIKE 'some_name' AND (right_table.age > 10) AND (right_table.age < 11)"#
1902
+
);
1903
+
1904
+
// Inner join with a scalar subquery in table_scan_filters. The subquery filter should appear in WHERE, not in JOIN ON,
1905
+
// since dialects like BigQuery reject subqueries in join predicates.
1906
+
let schema_subquery = Schema::new(vec![Field::new("id",DataType::Utf8,false)]);
1907
+
let subquery_plan = table_scan(Some("subquery_table"),&schema_subquery,None)?
let join_plan_subquery_filter = LogicalPlanBuilder::from(left_plan)
1922
+
.join(
1923
+
right_plan_with_subquery,
1924
+
datafusion_expr::JoinType::Inner,
1925
+
(vec!["left_table.id"],vec!["right_table.id"]),
1926
+
None,
1927
+
)?
1928
+
.build()?;
1929
+
1930
+
let sql = plan_to_sql(&join_plan_subquery_filter)?;
1931
+
assert_snapshot!(
1932
+
sql,
1933
+
@r#"SELECT left_table.id, left_table."name" FROM left_table INNER JOIN right_table ON left_table.id = right_table.id WHERE (right_table.id = (SELECT max(subquery_table.id) FROM subquery_table))"#
0 commit comments