-
Notifications
You must be signed in to change notification settings - Fork 590
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
fix(ddl): use column names, not position, for insertion order #9264
Conversation
Hmm, I'm going to have to rethink this -- moving this to draft for the moment |
Ok, this is ready for a look, but I'll be OOO for the next while, so feel free to fix it up or nuke it as necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems good!
We should probably start to do some consolidation of backend DDL code, even if we don't get to the point of having something like a set of internal DDL op classes.
Consolidate the implementation under a new private backend on |
If we have an
ir.Table
(or something that will be converted to amemtable
before insertion), we now generate the column list for thesge.Insert
using the column ordering of the to-be-inserted-table, not the parent table. This is technically still positional ordering, but the ordering matches up with the target table.So if we have
t
and
t2
then we will generate something like
INSERT INTO t (y, x) (SELECT * FROM t2)
which will yieldThe other case is where a user passes in records directly, which we will convert into an intermediate memtable, something like:
We definitely cannot use those column names to handle insertion, so in this case, we revert back to using the parent tables columns, which results in using positional ordering for the insert, which seems like the only reasonable thing to do in this scenario.
That SQL will look something like
INSERT INTO t (x,y) (SELECT * FROM some_memtable)
Resolves #9249