goldmedal commented on code in PR #1541: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1541#discussion_r1858938729
########## 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: > One thing I think if we keep subscript is we should likely change its format, iirc it uses a nested representation which I don't think is necessary given we only need to encode a linear field access chain? i.e. that it uses a list similar to mapaccess I prefer to keep the nested representation for the following reasons: - It preserves the original syntax for arrays (`a[1]`) and maps (`a['field']`). - By combining `Subscript` and `CompositeAccess` (and possibly `Method`, if needed 🤔), we can cover the entire syntax of access chains without requiring users to introduce additional `Expr`. This makes the SQL syntax more stable. Some examples include: ```sql a.b.c # may duplicate with CompoundIdentifier a[1].b.c a.b[1:5].c a.b['f1'].c a[1][2].b[3].c array_func()[1].a.b struct_func().a[1].b # if Expr::Method is enabled struct_func().method1().method2() ``` -- 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