mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-07 17:04:59 +00:00
MSSQL: Add support for functionality MERGE
output clause (#1790)
This commit is contained in:
parent
3ed4ad9c66
commit
610096cad8
7 changed files with 109 additions and 16 deletions
|
@ -1921,3 +1921,19 @@ fn ms() -> TestedDialects {
|
|||
fn ms_and_generic() -> TestedDialects {
|
||||
TestedDialects::new(vec![Box::new(MsSqlDialect {}), Box::new(GenericDialect {})])
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_mssql_merge_with_output() {
|
||||
let stmt = "MERGE dso.products AS t \
|
||||
USING dsi.products AS \
|
||||
s ON s.ProductID = t.ProductID \
|
||||
WHEN MATCHED AND \
|
||||
NOT (t.ProductName = s.ProductName OR (ISNULL(t.ProductName, s.ProductName) IS NULL)) \
|
||||
THEN UPDATE SET t.ProductName = s.ProductName \
|
||||
WHEN NOT MATCHED BY TARGET \
|
||||
THEN INSERT (ProductID, ProductName) \
|
||||
VALUES (s.ProductID, s.ProductName) \
|
||||
WHEN NOT MATCHED BY SOURCE THEN DELETE \
|
||||
OUTPUT $action, deleted.ProductID INTO dsi.temp_products";
|
||||
ms_and_generic().verified_stmt(stmt);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue