Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance the nested type access for Generic and DuckDB dialect #1541

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

goldmedal
Copy link
Contributor

@goldmedal goldmedal commented Nov 21, 2024

Description

select c1[1].f1.f2[2] from t1
  • make support_period_map_access_key configurable.

TODO items

  • allow the SQL access the map element from a function call: SELECT named_struct('a', 1, 'b', 2).a

@goldmedal
Copy link
Contributor Author

We should refactor to integrate Subscript and MapAccessSyntax::Bracket, as they are similar and difficult to distinguish at the SQL layer.

For example, DuckDB allows the following SQL, which is currently invalid in our parser:

select [MAP {2:{a:1, b:[2,3,4]}}, MAP {2:{a:1, b:[2,3,4]}}][1][2][1].b[1:2] as result;
┌─────────┐
│ result  │
│ int32[] │
├─────────┤
│ [2, 3]  │
└─────────┘

The access pattern [1][2][1].b[1:2] includes both Subscript and MapAccess. We cannot parse all these as a MapAccessKey following the . token.

MapAccess {
column: Box<Expr>,
keys: Vec<MapAccessKey>,
},

@goldmedal goldmedal marked this pull request as ready for review November 21, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve CompositeAccess to enhance the struct type
1 participant