mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-20 02:37:15 +00:00
fix redundant brackets in Hive/Snowflake/Redshift (#1229)
This commit is contained in:
parent
ce85084deb
commit
547c5cde14
2 changed files with 18 additions and 9 deletions
|
@ -8993,9 +8993,12 @@ impl<'a> Parser<'a> {
|
||||||
let columns = self.parse_parenthesized_column_list(Optional, is_mysql)?;
|
let columns = self.parse_parenthesized_column_list(Optional, is_mysql)?;
|
||||||
|
|
||||||
let partitioned = self.parse_insert_partition()?;
|
let partitioned = self.parse_insert_partition()?;
|
||||||
|
|
||||||
// Hive allows you to specify columns after partitions as well if you want.
|
// 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()?);
|
let source = Some(self.parse_boxed_query()?);
|
||||||
|
|
||||||
|
@ -10813,13 +10816,6 @@ mod tests {
|
||||||
assert!(Parser::parse_sql(&GenericDialect {}, sql).is_err());
|
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]
|
#[test]
|
||||||
fn test_replace_incomplete() {
|
fn test_replace_incomplete() {
|
||||||
let sql = r#"REPLACE"#;
|
let sql = r#"REPLACE"#;
|
||||||
|
|
|
@ -9275,3 +9275,16 @@ fn parse_sized_list() {
|
||||||
let sql = r#"SELECT data::FLOAT[1536] FROM embeddings"#;
|
let sql = r#"SELECT data::FLOAT[1536] FROM embeddings"#;
|
||||||
dialects.verified_stmt(sql);
|
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)");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue