milenkovicm commented on code in PR #1912:
URL:
https://github.com/apache/datafusion-ballista/pull/1912#discussion_r3564696848
##########
ballista/client/tests/context_checks.rs:
##########
@@ -77,6 +77,40 @@ mod supported {
Ok(())
}
+ // An uncorrelated scalar subquery is executed first and its value inlined
+ // into the outer plan (rather than decorrelated to a join), so the outer
+ // query distributes without a `ScalarSubqueryExec`. See #1910.
+ #[rstest]
+ #[case::standalone(standalone_context())]
+ #[case::remote(remote_context())]
+ #[tokio::test]
+ async fn should_execute_uncorrelated_scalar_subquery(
+ #[future(awt)]
+ #[case]
+ ctx: SessionContext,
+ test_data: String,
+ ) -> datafusion::error::Result<()> {
+ ctx.register_parquet(
+ "test",
+ &format!("{test_data}/alltypes_plain.parquet"),
+ Default::default(),
+ )
+ .await?;
+
Review Comment:
can we explicitly disable `SET
datafusion.optimizer.enable_physical_uncorrelated_scalar_subquery = true`, it
would give additional context to the test.
##########
ballista/client/tests/context_checks.rs:
##########
@@ -77,6 +77,40 @@ mod supported {
Ok(())
}
+ // An uncorrelated scalar subquery is executed first and its value inlined
+ // into the outer plan (rather than decorrelated to a join), so the outer
+ // query distributes without a `ScalarSubqueryExec`. See #1910.
+ #[rstest]
+ #[case::standalone(standalone_context())]
+ #[case::remote(remote_context())]
+ #[tokio::test]
+ async fn should_execute_uncorrelated_scalar_subquery(
+ #[future(awt)]
+ #[case]
+ ctx: SessionContext,
+ test_data: String,
+ ) -> datafusion::error::Result<()> {
+ ctx.register_parquet(
+ "test",
+ &format!("{test_data}/alltypes_plain.parquet"),
+ Default::default(),
+ )
+ .await?;
+
+ // Exactly the row holding the maximum id matches the inlined subquery
+ // value, so the count is 1.
+ let result = ctx
+ .sql("select count(*) as cnt from test where id = (select max(id)
from test)")
+ .await?
+ .collect()
+ .await?;
+ let expected = ["+-----+", "| cnt |", "+-----+", "| 1 |", "+-----+"];
+
+ assert_batches_eq!(expected, &result);
+
+ Ok(())
+ }
+
Review Comment:
can we also add check with AQE enabled, if it works, if not a jira issue or
a test in "unsupported" file?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]