You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by al...@apache.org on 2024/11/24 22:40:34 UTC
(datafusion) branch main updated: Support Unnest in Subqueries (#13523)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new b122bab5c2 Support Unnest in Subqueries (#13523)
b122bab5c2 is described below
commit b122bab5c2830c0540b5f74adc3f4ec41b20b0c2
Author: kosiew <ko...@gmail.com>
AuthorDate: Mon Nov 25 06:40:29 2024 +0800
Support Unnest in Subqueries (#13523)
* Add test for subquery unnest
* Add support for Unnest logical plan in inner plan checks
---
datafusion/optimizer/src/analyzer/subquery.rs | 3 ++-
datafusion/sqllogictest/test_files/unnest.slt | 27 +++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/datafusion/optimizer/src/analyzer/subquery.rs b/datafusion/optimizer/src/analyzer/subquery.rs
index 0b54b302c2..fee06eeb9f 100644
--- a/datafusion/optimizer/src/analyzer/subquery.rs
+++ b/datafusion/optimizer/src/analyzer/subquery.rs
@@ -163,7 +163,8 @@ fn check_inner_plan(inner_plan: &LogicalPlan, can_contain_outer_ref: bool) -> Re
| LogicalPlan::Limit(_)
| LogicalPlan::Values(_)
| LogicalPlan::Subquery(_)
- | LogicalPlan::SubqueryAlias(_) => {
+ | LogicalPlan::SubqueryAlias(_)
+ | LogicalPlan::Unnest(_) => {
inner_plan.apply_children(|plan| {
check_inner_plan(plan, can_contain_outer_ref)?;
Ok(TreeNodeRecursion::Continue)
diff --git a/datafusion/sqllogictest/test_files/unnest.slt b/datafusion/sqllogictest/test_files/unnest.slt
index 2e1b8b87cc..d409e0902f 100644
--- a/datafusion/sqllogictest/test_files/unnest.slt
+++ b/datafusion/sqllogictest/test_files/unnest.slt
@@ -859,3 +859,30 @@ query I
select count(*) from (select unnest(range(0, 100000)) id) t inner join (select unnest(range(0, 100000)) id) t1 on t.id = t1.id;
----
100000
+
+
+## Unnest in subquery
+query IIII
+with t as (
+ select
+ left1,
+ width1,
+ min(column3) as min_height
+ from
+ unnest_table a
+ cross join unnest(ARRAY[1,2,3,4,5,6,7,8,9,10]) as t(left1)
+ cross join unnest(ARRAY[1,2,3,4,5,6,7,8,9,10]) as t1(width1)
+ where
+ left1 + width1 - 1 <= 10
+ and column3 between left1 and left1 + width1 - 1
+ group by
+ left1, width1
+)
+select
+ left1, width1, min_height, min_height * width1 as area
+from t
+where min_height * width1 = (
+ select max(min_height * width1) from t
+)
+----
+4 7 4 28
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org