alamb commented on issue #7892:
URL:
https://github.com/apache/arrow-datafusion/issues/7892#issuecomment-1977579412
I don't think SQL aligns on field name, but instead only on position
I think the two cases are
1. `INSERT INTO bar SELECT ....` in which case the columns of the select
list should be inserted into the table columns by position. If there are more
columns in the table than in the select list, the remaining ones should be null
padded
2. `INSERT INTO bar(cols) SELECT ...` in which case the columns of the
select list should be inserted into the list of columns by position. If there
are more columns in the table than in the select list, the remaining ones
should be null padded
Does that makes sense? Maybe we can simply add ProjectionExec that does the
alignment correctly?
Here is an example showing that position is used
```sql
postgres=# create table foo(x int, y int);
CREATE TABLE
postgres=# insert into foo values (1, 100);
INSERT 0 1
```
Now, insert into bar via select * from foo, and position is used:
```sql
postgres=# create table bar (y int, x int);
CREATE TABLE
postgres=# insert into bar select * from foo;
INSERT 0 1
postgres=# select * from bar;
y | x
---+-----
1 | 100
(1 row)
```
Insert too few columns into foo, then pad rest with null but don't align by
column name:
```sql
postgres=# insert into bar select x from foo;
INSERT 0 1
postgres=# select * from bar;
y | x
---+-----
1 | 100
1 |
(2 rows)
--
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]