Skip to content

Fix(oracle): properly support table alias in the INSERT DML#6374

Merged
georgesittas merged 2 commits intotobymao:mainfrom
snovik75:issue_6371
Nov 21, 2025
Merged

Fix(oracle): properly support table alias in the INSERT DML#6374
georgesittas merged 2 commits intotobymao:mainfrom
snovik75:issue_6371

Conversation

@snovik75
Copy link
Contributor

@snovik75 snovik75 commented Nov 20, 2025

Fixes #6371

Copy link
Collaborator

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

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

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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we set parse_partition=True here? Are you sure it's irrelevant to Oracle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

_parse_table_parts does not have it as a parameter. I tried to add it manually

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, wait, I confused this with _parse_table. How come we're not reusing it and opted for parsing the parts instead?

Comment on lines 288 to 290
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))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we manually parsing the alias here, instead of reusing _parse_table_alias & passing in the allow-list for alias tokens?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that was the problem as I wrote in slack - _parse_table_alias took () as a function with alias name instead of schema.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the issue seems to to be here. I can look at it tomorrow

image

@georgesittas georgesittas changed the title fix issue 6371 Fix(oracle): properly support table alias in the INSERT DML Nov 20, 2025
@georgesittas
Copy link
Collaborator

I'll get this in and see if I can clean it up, thanks @snovik75

@georgesittas georgesittas merged commit 6f2459c into tobymao:main Nov 21, 2025
7 checks passed
georgesittas pushed a commit that referenced this pull request Nov 21, 2025
* fix

* comments

---------

Co-authored-by: Sergej Novik <[email protected]>
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.

Table in INSERT INTO can have alias without AS for Oracle

2 participants