Add support for PostgreSQL Insert table aliases (#1069) (#1084)

This commit is contained in:
Boyd Johnson 2024-01-14 12:52:31 -06:00 committed by GitHub
parent ce498864dc
commit a71b3f5e82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 217 additions and 0 deletions

View file

@ -7678,6 +7678,14 @@ impl<'a> Parser<'a> {
// Hive lets you put table here regardless
let table = self.parse_keyword(Keyword::TABLE);
let table_name = self.parse_object_name()?;
let table_alias =
if dialect_of!(self is PostgreSqlDialect) && self.parse_keyword(Keyword::AS) {
Some(self.parse_identifier()?)
} else {
None
};
let is_mysql = dialect_of!(self is MySqlDialect);
let (columns, partitioned, after_columns, source) =
@ -7752,6 +7760,7 @@ impl<'a> Parser<'a> {
Ok(Statement::Insert {
or,
table_name,
table_alias,
ignore,
into,
overwrite,