diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 1ec530b7..d9a354df 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -8993,9 +8993,12 @@ impl<'a> Parser<'a> { let columns = self.parse_parenthesized_column_list(Optional, is_mysql)?; let partitioned = self.parse_insert_partition()?; - // Hive allows you to specify columns after partitions as well if you want. - let after_columns = self.parse_parenthesized_column_list(Optional, false)?; + let after_columns = if dialect_of!(self is HiveDialect) { + self.parse_parenthesized_column_list(Optional, false)? + } else { + vec![] + }; let source = Some(self.parse_boxed_query()?); @@ -10813,13 +10816,6 @@ mod tests { assert!(Parser::parse_sql(&GenericDialect {}, sql).is_err()); } - #[test] - fn test_replace_into_select() { - let sql = r#"REPLACE INTO t1 (a, b, c) (SELECT * FROM t2)"#; - - assert!(Parser::parse_sql(&GenericDialect {}, sql).is_err()); - } - #[test] fn test_replace_incomplete() { let sql = r#"REPLACE"#; diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs index e6081464..9fc020fd 100644 --- a/tests/sqlparser_common.rs +++ b/tests/sqlparser_common.rs @@ -9275,3 +9275,16 @@ fn parse_sized_list() { let sql = r#"SELECT data::FLOAT[1536] FROM embeddings"#; dialects.verified_stmt(sql); } + +#[test] +fn insert_into_with_parentheses() { + let dialects = TestedDialects { + dialects: vec![ + Box::new(SnowflakeDialect {}), + Box::new(RedshiftSqlDialect {}), + Box::new(GenericDialect {}), + ], + options: None, + }; + dialects.verified_stmt("INSERT INTO t1 (id, name) (SELECT t2.id, t2.name FROM t2)"); +}