goldmedal commented on code in PR #1541:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1541#discussion_r1855696643


##########
src/parser/mod.rs:
##########
@@ -2935,12 +2935,23 @@ impl<'a> Parser<'a> {
             })
         } else if Token::LBracket == tok {
             if dialect_of!(self is PostgreSqlDialect | DuckDbDialect | 
GenericDialect) {
-                self.parse_subscript(expr)
+                let expr = self.parse_multi_dim_subscript(expr)?;
+                if self.dialect.support_period_map_access_key() {
+                    self.parse_map_access(expr, vec![])
+                } else {
+                    Ok(expr)
+                }

Review Comment:
   Thank @iffyio. Indeed, if we merge them in this PR, we can fix many things. 
It could be a big refactor 🤔 
   I have two candidate proposals for it:
   
   ## Merge `Subscript` into `MapAcess` and rename `MapAccess`
   - Remove the `Expr::Subscript` and add a new `MapAccessSyntax::Slice` for 
`[1:5]` SQL
   - Rename `MapAcess` to `ElementAccess` for the elements access of `Map` and 
`Array`.
   
   ## Remove `MapAccess` and integrate with `CompositeAccess`
   `CompositeAccess` is a syntax structure for `expr1.expr2`. I think we can 
use it to represent the period map access. We can use `CompositeAccess` and 
`Subscript` to present the access chain like `expr1.expr2[1].expr3`
   ```
   CompositeAccess (
       CompositeAccess (expr1,
           CompositeAccess( expr2 ,
               Subscript(1))), Indent(expr3))
   ```
   Then, we don't need `MapAccess` for the chain.
   
   What do you think? Which one do you prefer?
   



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to