Skip to content

fix: union schema#2334

Merged
andygrove merged 4 commits intoapache:masterfrom
cube-js:union-fixes
May 4, 2022
Merged

fix: union schema#2334
andygrove merged 4 commits intoapache:masterfrom
cube-js:union-fixes

Conversation

@gandronchik
Copy link
Copy Markdown
Contributor

@gandronchik gandronchik commented Apr 25, 2022

fix UNION schema

example:
SELECT 1 a UNION ALL SELECT 2;

Closes #2083

Comment thread datafusion/core/src/execution/context.rs
@jackwener
Copy link
Copy Markdown
Member

It's better to link the related issue if it exists.

If it doesn't exist, I think it would be better to create it and link it.

Copy link
Copy Markdown
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @gandronchik I tried this out locally and it seems to have worked well 👍

Nice work

SELECT 1 a UNION ALL SELECT 2;
+---------+
| column0 |
+---------+
| 2       |
| 1       |
+---------+
2 rows in set. Query took 0.048 seconds.

I also verified that this behavior (taking the left schema as the output schema) is consistent with postgres:

alamb=# SELECT 1 as a UNION ALL SELECT 2;
 a 
---
 1
 2
(2 rows)

alamb=# SELECT 1 as a UNION ALL SELECT 2 as b;
 a 
---
 1
 2
(2 rows)

The only thing I would like to see is a specific test. The other comments are just suggestions for improvements but not required in my opinion.

Comment thread datafusion/core/src/execution/context.rs
Comment thread datafusion/core/src/logical_plan/builder.rs
@andygrove
Copy link
Copy Markdown
Member

Hi @gandronchik Do you have time to address the PR feedback here so that we can get your change approved + merged?

@gandronchik gandronchik requested a review from alamb May 4, 2022 04:55
Copy link
Copy Markdown
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @gandronchik -- looks good now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error occurs when using union in query

4 participants