findepi commented on code in PR #14474:
URL: https://github.com/apache/datafusion/pull/14474#discussion_r1942596627
##########
datafusion/optimizer/src/decorrelate_predicate_subquery.rs:
##########
@@ -1844,6 +1864,69 @@ mod tests {
assert_optimized_plan_equal(plan, expected)
}
+ #[test]
+ fn exists_uncorrelated_unnest() -> Result<()> {
+ let subquery_table_source = table_source(&Schema::new(vec![Field::new(
+ "arr",
+ DataType::List(Arc::new(Field::new_list_field(DataType::Int32,
true))),
+ true,
+ )]));
+ let subquery = LogicalPlanBuilder::scan_with_filters(
+ "sq",
+ subquery_table_source,
+ None,
+ vec![],
+ )?
+ .unnest_column("arr")?
+ .build()?;
+ let table_scan = test_table_scan()?;
+ let plan = LogicalPlanBuilder::from(table_scan)
+ .filter(exists(Arc::new(subquery)))?
+ .project(vec![col("test.b")])?
+ .build()?;
+
+ let expected = "Projection: test.b [b:UInt32]\
+ \n LeftSemi Join: Filter: Boolean(true) [a:UInt32,
b:UInt32, c:UInt32]\
+ \n TableScan: test [a:UInt32, b:UInt32, c:UInt32]\
+ \n SubqueryAlias: __correlated_sq_1 [arr:Int32;N]\
+ \n Unnest: lists[sq.arr|depth=1] structs[]
[arr:Int32;N]\
+ \n TableScan: sq [arr:List(Field { name:
\"item\", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false,
metadata: {} });N]";
+ assert_optimized_plan_equal(plan, expected)
+ }
+
+ #[test]
+ fn exists_correlated_unnest() -> Result<()> {
+ eprintln!("test start: exists_correlated_unnest");
Review Comment:
thanks for catching me
--
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]