Fix(oracle): properly support table alias in the INSERT DML#6374
Fix(oracle): properly support table alias in the INSERT DML#6374georgesittas merged 2 commits intotobymao:mainfrom
INSERT DML#6374Conversation
georgesittas
left a comment
There was a problem hiding this comment.
Thanks for the PR!
| # Oracle does not use AS for INSERT INTO alias | ||
| # https://docs.oracle.com/en/database/oracle/oracle-database/18/sqlrf/INSERT.html | ||
| # Parse table parts without schema to avoid parsing the alias with its columns | ||
| this = self._parse_table_parts(schema=True) |
There was a problem hiding this comment.
Should we set parse_partition=True here? Are you sure it's irrelevant to Oracle?
There was a problem hiding this comment.
_parse_table_parts does not have it as a parameter. I tried to add it manually
There was a problem hiding this comment.
Ah, wait, I confused this with _parse_table. How come we're not reusing it and opted for parsing the parts instead?
sqlglot/dialects/oracle.py
Outdated
| alias_name = self._parse_id_var(any_token=False, tokens=self.INSERT_ALIAS_TOKENS) | ||
| if alias_name: | ||
| this.set("alias", exp.TableAlias(this=alias_name)) |
There was a problem hiding this comment.
Why are we manually parsing the alias here, instead of reusing _parse_table_alias & passing in the allow-list for alias tokens?
There was a problem hiding this comment.
that was the problem as I wrote in slack - _parse_table_alias took () as a function with alias name instead of schema.
INSERT DML
|
I'll get this in and see if I can clean it up, thanks @snovik75 |
* fix * comments --------- Co-authored-by: Sergej Novik <[email protected]>

Fixes #6371