iffyio commented on code in PR #1500:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1500#discussion_r1831422229


##########
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:
   is it possible to represent this syntax as the existing `Expr::JsonAccess`? 
I'm assuming that isn't the case since otherwise the the feature will be 
already be supported. If not its not super clear to me what exactly is the 
composite access we're introducing with this PR - My assumption is that its 
adding support for syntax like 
`<arbitrary-expr>.<arbitrary-expr>.<arbitrary-expr>...` and so on where 
`arbitrary-expr` can be any expr including a function call. Like in the example 
`SELECT CONVERT(XML,'<Book>abc</Book>').value('.','NVARCHAR(MAX)')`



##########
src/ast/mod.rs:
##########
@@ -560,6 +560,13 @@ pub enum Expr {
         expr: Box<Expr>,
         key: Ident,
     },
+    /// CompositeFunction (mssql) e.g. SELECT (SELECT ',' + name FROM 
sys.objects  FOR XML PATH(''), TYPE).value('.','NVARCHAR(MAX)')   
+    /// 
<https://learn.microsoft.com/en-us/sql/t-sql/xml/xml-data-type-methods?view=sql-server-ver16>

Review Comment:
   ```suggestion
       /// CompositeFunction [mssql]
       /// Example:
       /// ```sql
       /// SELECT (SELECT ',' + name FROM sys.objects  FOR XML PATH(''), 
TYPE).value('.','NVARCHAR(MAX)')   
       /// ```
       /// [mssql]: 
https://learn.microsoft.com/en-us/sql/t-sql/xml/xml-data-type-methods?view=sql-server-ver16
   ```
   Something similar regarding doc formatting I'm thinking.
   
   Also double checking: is the link correct, the doc on the link describes the 
xml data type and its not super obvious to me if/how it relates to the 
composite function feature



-- 
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]

Reply via email to