mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-31 11:17:23 +00:00
Support Snowflake Update-From-Select (#1604)
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
This commit is contained in:
parent
14cefc47ed
commit
024a878ee7
6 changed files with 59 additions and 16 deletions
|
@ -366,7 +366,7 @@ fn parse_update_set_from() {
|
|||
target: AssignmentTarget::ColumnName(ObjectName(vec![Ident::new("name")])),
|
||||
value: Expr::CompoundIdentifier(vec![Ident::new("t2"), Ident::new("name")])
|
||||
}],
|
||||
from: Some(TableWithJoins {
|
||||
from: Some(UpdateTableFromKind::AfterSet(TableWithJoins {
|
||||
relation: TableFactor::Derived {
|
||||
lateral: false,
|
||||
subquery: Box::new(Query {
|
||||
|
@ -417,8 +417,8 @@ fn parse_update_set_from() {
|
|||
columns: vec![],
|
||||
})
|
||||
},
|
||||
joins: vec![],
|
||||
}),
|
||||
joins: vec![]
|
||||
})),
|
||||
selection: Some(Expr::BinaryOp {
|
||||
left: Box::new(Expr::CompoundIdentifier(vec![
|
||||
Ident::new("t1"),
|
||||
|
@ -12577,9 +12577,21 @@ fn overflow() {
|
|||
let statement = statements.pop().unwrap();
|
||||
assert_eq!(statement.to_string(), sql);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_select_without_projection() {
|
||||
let dialects = all_dialects_where(|d| d.supports_empty_projections());
|
||||
dialects.verified_stmt("SELECT FROM users");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_update_from_before_select() {
|
||||
all_dialects()
|
||||
.verified_stmt("UPDATE t1 FROM (SELECT name, id FROM t1 GROUP BY id) AS t2 SET name = t2.name WHERE t1.id = t2.id");
|
||||
|
||||
let query =
|
||||
"UPDATE t1 FROM (SELECT name, id FROM t1 GROUP BY id) AS t2 SET name = t2.name FROM (SELECT name from t2) AS t2";
|
||||
assert_eq!(
|
||||
ParserError::ParserError("Expected: end of statement, found: FROM".to_string()),
|
||||
parse_sql_statements(query).unwrap_err()
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue