Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor: Add sql test for UNION / UNION ALL + plans #7787

Merged
merged 1 commit into from
Oct 11, 2023

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Oct 10, 2023

Which issue does this PR close?

Related to #7695 and #7786

Rationale for this change

Add test for #7786 as well as an end to end verification for #7695

What changes are included in this PR?

2 new tests

Are these changes tested?

Are there any user-facing changes?


# Plan is unnested
query TT
EXPLAIN SELECT name FROM t1 UNION ALL (SELECT name from t2 UNION ALL SELECT name || '_new' from t2)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test passes even without #7695 as the flattening happens in the SQL pass. #7695 move the flattening so it happens as part of the normal optimizer flow

Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I'm wrong but why we have 2 set of AggregateExecs....

I ran the similar query in PG
EXPLAIN verbose SELECT firstname FROM scientist UNION (SELECT firstname from scientist UNION SELECT firstname || '_new' from scientist2);


QUERY PLAN
--
HashAggregate (cost=44.45..49.55 rows=510 width=32)
Output: scientist.firstname
Group Key: scientist.firstname
-> Append (cost=0.00..43.17 rows=510 width=32)
-> Seq Scan on public.scientist (cost=0.00..11.70 rows=170 width=218)
Output: scientist.firstname
-> Seq Scan on public.scientist scientist_1 (cost=0.00..11.70 rows=170 width=218)
Output: scientist_1.firstname
-> Subquery Scan on "*SELECT* 3" (cost=0.00..13.82 rows=170 width=32)
Output: "*SELECT* 3"."?column?"
-> Seq Scan on public.scientist2 (cost=0.00..12.12 rows=170 width=32)
Output: ((scientist2.firstname)::text \|\| '_new'::text)

There is only 1 set of agregation

@alamb
Copy link
Contributor Author

alamb commented Oct 10, 2023

Perhaps I'm wrong but why we have 2 set of AggregateExecs....

Because we haven't implemented #7786 yet :) Though it appears that @maruschin is working on it in #7788

@alamb alamb merged commit 2a42175 into apache:main Oct 11, 2023
@alamb
Copy link
Contributor Author

alamb commented Oct 11, 2023

Thanks @comphead and @jackwener

@alamb alamb deleted the alamb/plans branch October 11, 2023 14:14
devinjdangelo pushed a commit to devinjdangelo/arrow-datafusion that referenced this pull request Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants