mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-15 16:29:02 +00:00
BigQuery: Parse optional DELETE FROM
statement (#1120)
This commit is contained in:
parent
61089f977c
commit
df738f9b10
5 changed files with 120 additions and 27 deletions
|
@ -6324,12 +6324,18 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
pub fn parse_delete(&mut self) -> Result<Statement, ParserError> {
|
||||
let tables = if !self.parse_keyword(Keyword::FROM) {
|
||||
let tables = self.parse_comma_separated(|p| p.parse_object_name(false))?;
|
||||
self.expect_keyword(Keyword::FROM)?;
|
||||
tables
|
||||
let (tables, with_from_keyword) = if !self.parse_keyword(Keyword::FROM) {
|
||||
// `FROM` keyword is optional in BigQuery SQL.
|
||||
// https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#delete_statement
|
||||
if dialect_of!(self is BigQueryDialect | GenericDialect) {
|
||||
(vec![], false)
|
||||
} else {
|
||||
let tables = self.parse_comma_separated(|p| p.parse_object_name(false))?;
|
||||
self.expect_keyword(Keyword::FROM)?;
|
||||
(tables, true)
|
||||
}
|
||||
} else {
|
||||
vec![]
|
||||
(vec![], true)
|
||||
};
|
||||
|
||||
let from = self.parse_comma_separated(Parser::parse_table_and_joins)?;
|
||||
|
@ -6361,7 +6367,11 @@ impl<'a> Parser<'a> {
|
|||
|
||||
Ok(Statement::Delete {
|
||||
tables,
|
||||
from,
|
||||
from: if with_from_keyword {
|
||||
FromTable::WithFromKeyword(from)
|
||||
} else {
|
||||
FromTable::WithoutKeyword(from)
|
||||
},
|
||||
using,
|
||||
selection,
|
||||
returning,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue