fix redundant brackets in Hive/Snowflake/Redshift (#1229)

This commit is contained in:
Yuval Shkolar 2024-04-24 14:56:09 +03:00 committed by GitHub
parent ce85084deb
commit 547c5cde14
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 9 deletions

View file

@ -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"#;

View file

@ -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)");
}