@@ -18481,7 +18481,9 @@ impl<'a> Parser<'a> {
1848118481 let table = self.parse_keyword(Keyword::TABLE);
1848218482 let table_object = self.parse_table_object()?;
1848318483
18484+ // `BY NAME` is an INSERT clause, not a table alias.
1848418485 let table_alias = if self.dialect.supports_insert_table_alias()
18486+ && !self.peek_keywords(&[Keyword::BY, Keyword::NAME])
1848518487 && !self.peek_sub_query()
1848618488 && self
1848718489 .peek_one_of_keywords(&[Keyword::DEFAULT, Keyword::VALUES])
@@ -18505,6 +18507,7 @@ impl<'a> Parser<'a> {
1850518507
1850618508 let is_mysql = dialect_of!(self is MySqlDialect);
1850718509
18510+ let mut by_name = false;
1850818511 let (columns, partitioned, after_columns, output, source, assignments) = if self
1850918512 .parse_keywords(&[Keyword::DEFAULT, Keyword::VALUES])
1851018513 {
@@ -18515,6 +18518,7 @@ impl<'a> Parser<'a> {
1851518518 self.parse_parenthesized_qualified_column_list(Optional, is_mysql)?;
1851618519
1851718520 let partitioned = self.parse_insert_partition()?;
18521+ by_name = self.parse_keywords(&[Keyword::BY, Keyword::NAME]);
1851818522 // Hive allows you to specify columns after partitions as well if you want.
1851918523 let after_columns = if dialect_of!(self is HiveDialect) {
1852018524 self.parse_parenthesized_column_list(Optional, false)?
@@ -18639,6 +18643,7 @@ impl<'a> Parser<'a> {
1863918643 ignore,
1864018644 into,
1864118645 overwrite,
18646+ by_name,
1864218647 partitioned,
1864318648 columns,
1864418649 after_columns,
0 commit comments