Skip to content

Commit 547c5cd

Browse files
fix redundant brackets in Hive/Snowflake/Redshift (apache#1229)
1 parent ce85084 commit 547c5cd

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/parser/mod.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8993,9 +8993,12 @@ impl<'a> Parser<'a> {
89938993
let columns = self.parse_parenthesized_column_list(Optional, is_mysql)?;
89948994

89958995
let partitioned = self.parse_insert_partition()?;
8996-
89978996
// Hive allows you to specify columns after partitions as well if you want.
8998-
let after_columns = self.parse_parenthesized_column_list(Optional, false)?;
8997+
let after_columns = if dialect_of!(self is HiveDialect) {
8998+
self.parse_parenthesized_column_list(Optional, false)?
8999+
} else {
9000+
vec![]
9001+
};
89999002

90009003
let source = Some(self.parse_boxed_query()?);
90019004

@@ -10813,13 +10816,6 @@ mod tests {
1081310816
assert!(Parser::parse_sql(&GenericDialect {}, sql).is_err());
1081410817
}
1081510818

10816-
#[test]
10817-
fn test_replace_into_select() {
10818-
let sql = r#"REPLACE INTO t1 (a, b, c) (SELECT * FROM t2)"#;
10819-
10820-
assert!(Parser::parse_sql(&GenericDialect {}, sql).is_err());
10821-
}
10822-
1082310819
#[test]
1082410820
fn test_replace_incomplete() {
1082510821
let sql = r#"REPLACE"#;

tests/sqlparser_common.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9275,3 +9275,16 @@ fn parse_sized_list() {
92759275
let sql = r#"SELECT data::FLOAT[1536] FROM embeddings"#;
92769276
dialects.verified_stmt(sql);
92779277
}
9278+
9279+
#[test]
9280+
fn insert_into_with_parentheses() {
9281+
let dialects = TestedDialects {
9282+
dialects: vec![
9283+
Box::new(SnowflakeDialect {}),
9284+
Box::new(RedshiftSqlDialect {}),
9285+
Box::new(GenericDialect {}),
9286+
],
9287+
options: None,
9288+
};
9289+
dialects.verified_stmt("INSERT INTO t1 (id, name) (SELECT t2.id, t2.name FROM t2)");
9290+
}

0 commit comments

Comments
 (0)