iffyio commented on code in PR #2228:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2228#discussion_r2846926081
##########
src/parser/mod.rs:
##########
@@ -17258,6 +17268,14 @@ impl<'a> Parser<'a> {
Default::default()
};
+ // MSSQL OUTPUT clause appears between columns and source
+ //
https://learn.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql
Review Comment:
```suggestion
```
##########
src/parser/mod.rs:
##########
@@ -17475,6 +17501,15 @@ impl<'a> Parser<'a> {
};
self.expect_keyword(Keyword::SET)?;
let assignments =
self.parse_comma_separated(Parser::parse_assignment)?;
+
+ // MSSQL OUTPUT clause appears after SET, before FROM/WHERE
+ //
https://learn.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql
Review Comment:
```suggestion
```
maybe we can introduce a helper function `maybe_parse_output_clause()` that
can be called from the relevant statement parsing functions?
##########
src/ast/dml.rs:
##########
@@ -77,6 +77,8 @@ pub struct Insert {
pub on: Option<OnInsert>,
/// RETURNING
pub returning: Option<Vec<SelectItem>>,
+ /// OUTPUT (MSSQL)
Review Comment:
for these comments, could we include the link to the mssql docs describing
the syntax? it would help with nagivation when folks look at the struct
##########
src/parser/mod.rs:
##########
@@ -13288,6 +13288,15 @@ impl<'a> Parser<'a> {
};
let from = self.parse_comma_separated(Parser::parse_table_and_joins)?;
+
+ // MSSQL OUTPUT clause appears after FROM table, before USING/WHERE
+ //
https://learn.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql
Review Comment:
```suggestion
```
##########
tests/sqlparser_mssql.rs:
##########
@@ -2730,3 +2730,46 @@ fn parse_mssql_tran_shorthand() {
// ROLLBACK TRAN normalizes to ROLLBACK (same as ROLLBACK TRANSACTION)
ms().one_statement_parses_to("ROLLBACK TRAN", "ROLLBACK");
}
+
+// MSSQL OUTPUT clause on INSERT/UPDATE/DELETE
+//
https://learn.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql
+
Review Comment:
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]