Omega359 commented on issue #13287:
URL: https://github.com/apache/datafusion/issues/13287#issuecomment-2462404200
I think this is actually working correctly and the docs might need to be
updated. I do not think union requires the fields to be the same nor have the
same names. It just requires the same number of fields and each corresponding
field to be coercible to a common type.
```
create table t1 (a, b) AS
VALUES
('a'::varchar, 'b'::varchar),
('c', 'd') ;
create table t2 (c, d) AS select b, a from t1;
select a, b from t1;
select c, d from t2;
select a, b from t1 union select c, d from t2;
```
output:
```
SELECT 2
SELECT 2
a | b
---+---
a | b
c | d
(2 rows)
c | d
---+---
b | a
d | c
(2 rows)
a | b
---+---
d | c
a | b
b | a
c | d
```
https://onecompiler.com/postgresql/42xehmfuu
https://www.postgresql.org/docs/current/typeconv-union-case.html
--
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]