mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-12-23 11:12:51 +00:00
add support for with clauses (CTEs) in delete statements (#1764)
This commit is contained in:
parent
1e54a34acd
commit
3392623b00
4 changed files with 52 additions and 0 deletions
|
|
@ -10050,6 +10050,13 @@ impl<'a> Parser<'a> {
|
|||
Ok(parent_type(inside_type.into()))
|
||||
}
|
||||
|
||||
/// Parse a DELETE statement, returning a `Box`ed SetExpr
|
||||
///
|
||||
/// This is used to reduce the size of the stack frames in debug builds
|
||||
fn parse_delete_setexpr_boxed(&mut self) -> Result<Box<SetExpr>, ParserError> {
|
||||
Ok(Box::new(SetExpr::Delete(self.parse_delete()?)))
|
||||
}
|
||||
|
||||
pub fn parse_delete(&mut self) -> Result<Statement, ParserError> {
|
||||
let (tables, with_from_keyword) = if !self.parse_keyword(Keyword::FROM) {
|
||||
// `FROM` keyword is optional in BigQuery SQL.
|
||||
|
|
@ -10249,6 +10256,21 @@ impl<'a> Parser<'a> {
|
|||
format_clause: None,
|
||||
}
|
||||
.into())
|
||||
} else if self.parse_keyword(Keyword::DELETE) {
|
||||
Ok(Query {
|
||||
with,
|
||||
body: self.parse_delete_setexpr_boxed()?,
|
||||
limit: None,
|
||||
limit_by: vec![],
|
||||
order_by: None,
|
||||
offset: None,
|
||||
fetch: None,
|
||||
locks: vec![],
|
||||
for_clause: None,
|
||||
settings: None,
|
||||
format_clause: None,
|
||||
}
|
||||
.into())
|
||||
} else {
|
||||
let body = self.parse_query_body(self.dialect.prec_unknown())?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue