()
| 2573 | |
| 2574 | #[test] |
| 2575 | fn test_unparse_left_mark_join() -> Result<()> { |
| 2576 | // select t1.d from t1 where t1.d < 0 OR exists (select 1 from t2 where t1.c = t2.c) |
| 2577 | let schema = Schema::new(vec![ |
| 2578 | Field::new("c", DataType::Int32, false), |
| 2579 | Field::new("d", DataType::Int32, false), |
| 2580 | ]); |
| 2581 | // Filter: __correlated_sq_1.mark OR t1.d < Int32(0) |
| 2582 | // Projection: t1.d |
| 2583 | // LeftMark Join: Filter: t1.c = __correlated_sq_1.c |
| 2584 | // TableScan: t1 projection=[c, d] |
| 2585 | // SubqueryAlias: __correlated_sq_1 |
| 2586 | // TableScan: t2 projection=[c] |
| 2587 | let table_scan1 = table_scan(Some("t1"), &schema, Some(vec![0, 1]))?.build()?; |
| 2588 | let table_scan2 = table_scan(Some("t2"), &schema, Some(vec![0]))?.build()?; |
| 2589 | let subquery = subquery_alias(table_scan2, "__correlated_sq_1")?; |
| 2590 | let plan = LogicalPlanBuilder::from(table_scan1) |
| 2591 | .join_on( |
| 2592 | subquery, |
| 2593 | datafusion_expr::JoinType::LeftMark, |
| 2594 | vec![col("t1.c").eq(col("__correlated_sq_1.c"))], |
| 2595 | )? |
| 2596 | .project(vec![col("t1.d")])? |
| 2597 | .filter(col("mark").or(col("t1.d").lt(lit(0))))? |
| 2598 | .build()?; |
| 2599 | |
| 2600 | let unparser = Unparser::new(&UnparserPostgreSqlDialect {}); |
| 2601 | let sql = unparser.plan_to_sql(&plan)?; |
| 2602 | assert_snapshot!( |
| 2603 | sql, |
| 2604 | @r#"SELECT "t1"."d" FROM "t1" WHERE (EXISTS (SELECT 1 FROM "t2" AS "__correlated_sq_1" WHERE ("t1"."c" = "__correlated_sq_1"."c")) OR ("t1"."d" < 0))"# |
| 2605 | ); |
| 2606 | Ok(()) |
| 2607 | } |
| 2608 | |
| 2609 | #[test] |
| 2610 | fn test_unparse_right_semi_join() -> Result<()> { |
nothing calls this directly
no test coverage detected
searching dependent graphs…