gaoqiangz commented on code in PR #1500:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1500#discussion_r1832131298
##########
src/parser/mod.rs:
##########
@@ -1269,6 +1269,50 @@ impl<'a> Parser<'a> {
_ => self.expected("an expression", next_token),
}?;
+ if dialect_of!(self is MsSqlDialect) {
+ // Convert `CompositeAccess` to `CompositeFunction` (MSSQL doesn't
support `CompositeAccess` syntax)
+ // ```sql
+ // SELECT (SELECT ',' + name FROM sys.objects FOR XML PATH(''),
TYPE).value('.','NVARCHAR(MAX)')
Review Comment:
`CompositeFunction` is similar to `CompositeAccess` but supports method call
syntax, that supports method calls on subquery results (must be `XML` data type
in MSSQL).
Maybe it would be better to make `CompositeFunction` a generic feature?
```rs
/// CompositeFunction
/// Syntax: `<arbitrary-expr>.<arbitrary-expr>.<arbitrary-expr>...`,
`arbitrary-expr` can be any expr including a function call.
/// Example:
/// ```sql
/// SELECT (SELECT ',' + name FROM sys.objects FOR XML PATH(''),
TYPE).value('.','NVARCHAR(MAX)')
/// SELECT
CONVERT(XML,'<Book>abc</Book>').value('.','NVARCHAR(MAX)').value('.','NVARCHAR(MAX)')
/// ```
CompositeFunction {
expr: Box<Expr>,
name: Ident,
args: Vec<Expr>,
},
```
--
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]