You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "mingmwang (via GitHub)" <gi...@apache.org> on 2023/06/16 13:06:17 UTC

[GitHub] [arrow-datafusion] mingmwang commented on a diff in pull request #6675: Port test in subqueries.rs from rust to sqllogictest

mingmwang commented on code in PR #6675:
URL: https://github.com/apache/arrow-datafusion/pull/6675#discussion_r1232228962


##########
datafusion/core/tests/sql/subqueries.rs:
##########
@@ -21,91 +21,6 @@ use datafusion::assert_batches_eq;
 use datafusion::prelude::SessionContext;
 use log::debug;
 
-#[tokio::test]
-async fn non_aggregated_correlated_scalar_subquery_with_single_row() -> Result<()> {
-    let ctx = create_join_context("t1_id", "t2_id", true)?;
-
-    let sql = "SELECT t1_id, (SELECT t2_int FROM t2 WHERE t2.t2_int = t1.t1_int limit 1) as t2_int from t1";
-    let msg = format!("Creating logical plan for '{sql}'");
-    let dataframe = ctx.sql(sql).await.expect(&msg);
-    let plan = dataframe.into_optimized_plan()?;
-
-    let expected = vec![
-        "Projection: t1.t1_id, (<subquery>) AS t2_int [t1_id:UInt32;N, t2_int:UInt32;N]",
-        "  Subquery: [t2_int:UInt32;N]",
-        "    Limit: skip=0, fetch=1 [t2_int:UInt32;N]",
-        "      Projection: t2.t2_int [t2_int:UInt32;N]",
-        "        Filter: t2.t2_int = outer_ref(t1.t1_int) [t2_id:UInt32;N, t2_name:Utf8;N, t2_int:UInt32;N]",
-        "          TableScan: t2 [t2_id:UInt32;N, t2_name:Utf8;N, t2_int:UInt32;N]",
-        "  TableScan: t1 projection=[t1_id] [t1_id:UInt32;N]",
-    ];
-    let formatted = plan.display_indent_schema().to_string();
-    let actual: Vec<&str> = formatted.trim().lines().collect();
-    assert_eq!(
-        expected, actual,
-        "\n\nexpected:\n\n{expected:#?}\nactual:\n\n{actual:#?}\n\n"
-    );
-
-    let sql = "SELECT t1_id from t1 where t1_int = (SELECT t2_int FROM t2 WHERE t2.t2_int = t1.t1_int limit 1)";
-    let msg = format!("Creating logical plan for '{sql}'");
-    let dataframe = ctx.sql(sql).await.expect(&msg);
-    let plan = dataframe.into_optimized_plan()?;
-
-    let expected = vec![
-        "Projection: t1.t1_id [t1_id:UInt32;N]",
-        "  Filter: t1.t1_int = (<subquery>) [t1_id:UInt32;N, t1_int:UInt32;N]",
-        "    Subquery: [t2_int:UInt32;N]",
-        "      Limit: skip=0, fetch=1 [t2_int:UInt32;N]",
-        "        Projection: t2.t2_int [t2_int:UInt32;N]",
-        "          Filter: t2.t2_int = outer_ref(t1.t1_int) [t2_id:UInt32;N, t2_name:Utf8;N, t2_int:UInt32;N]",
-        "            TableScan: t2 [t2_id:UInt32;N, t2_name:Utf8;N, t2_int:UInt32;N]",
-        "    TableScan: t1 projection=[t1_id, t1_int] [t1_id:UInt32;N, t1_int:UInt32;N]",
-    ];
-    let formatted = plan.display_indent_schema().to_string();
-    let actual: Vec<&str> = formatted.trim().lines().collect();
-    assert_eq!(
-        expected, actual,
-        "\n\nexpected:\n\n{expected:#?}\nactual:\n\n{actual:#?}\n\n"
-    );
-
-    let sql = "SELECT t1_id, (SELECT a FROM (select 1 as a) WHERE a = t1.t1_int) as t2_int from t1";
-    let msg = format!("Creating logical plan for '{sql}'");
-    let dataframe = ctx.sql(sql).await.expect(&msg);
-    let plan = dataframe.into_optimized_plan()?;
-
-    let expected = vec![
-        "Projection: t1.t1_id, __scalar_sq_5.a AS t2_int [t1_id:UInt32;N, t2_int:Int64;N]",
-        "  Left Join: CAST(t1.t1_int AS Int64) = __scalar_sq_5.a [t1_id:UInt32;N, t1_int:UInt32;N, a:Int64;N]",
-        "    TableScan: t1 projection=[t1_id, t1_int] [t1_id:UInt32;N, t1_int:UInt32;N]",
-        "    SubqueryAlias: __scalar_sq_5 [a:Int64]",
-        "      Projection: Int64(1) AS a [a:Int64]",
-        "        EmptyRelation []",
-    ];
-    let formatted = plan.display_indent_schema().to_string();
-    let actual: Vec<&str> = formatted.trim().lines().collect();
-    assert_eq!(
-        expected, actual,
-        "\n\nexpected:\n\n{expected:#?}\nactual:\n\n{actual:#?}\n\n"
-    );
-
-    // TODO infer nullability in the schema has bug
-    // // assert data
-    // let results = execute_to_batches(&ctx, sql).await;
-    // let expected = vec![
-    //     "+-------+--------+",
-    //     "| t1_id | t2_int |",
-    //     "+-------+--------+",
-    //     "| 22    |        |",
-    //     "| 33    |        |",
-    //     "| 11    | 1      |",
-    //     "| 44    |        |",
-    //     "+-------+--------+",
-    // ];
-    // assert_batches_eq!(expected, &results);

Review Comment:
   I remember this was because the infer nullablity has bug causing the physical plan schema check failed. 
   I will take a closer look tomorrow, maybe it was already fixed recently.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org