Skip to content

Add support for arbitrary map access expr#1179

Merged
alamb merged 1 commit intoapache:mainfrom
validio-io:map-expr
Apr 9, 2024
Merged

Add support for arbitrary map access expr#1179
alamb merged 1 commit intoapache:mainfrom
validio-io:map-expr

Conversation

@iffyio
Copy link
Copy Markdown
Contributor

@iffyio iffyio commented Mar 14, 2024

Unlike array access, the current logic for
accessing maps had custom handling and didn't
support cases like negative numbers or function
calls.
This fixes the issue by allowing the key access to be parsed as an arbitrary expression.

Also includes support on BigQuery where both dot and
bracket notations are allowed in the same expression
https://cloud.google.com/bigquery/docs/nested-repeated#query_nested_and_repeated_columns

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 14, 2024

Pull Request Test Coverage Report for Build 8407761282

Details

  • 86 of 90 (95.56%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 87.923%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/parser/mod.rs 17 19 89.47%
tests/sqlparser_bigquery.rs 29 31 93.55%
Totals Coverage Status
Change from base Build 8266982631: 0.05%
Covered Lines: 20508
Relevant Lines: 23325

💛 - Coveralls

Unlike array access, the current logic for
accessing maps had custom handling and didn't
support cases like negative numbers or function
calls.
This fixes the issue by allowing the key access to
be parsed as an arbitrary expression.

Also includes support on BigQuery where both dot and
bracket notations are allowed in the same expression
https://cloud.google.com/bigquery/docs/nested-repeated#query_nested_and_repeated_columns
Copy link
Copy Markdown
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much @iffyio -- this looks really nice. I had a small suggestion but it may not make sense.

Also, in general thank you for your work on this (and the other related PRs) and the reviews. Is there any chance you are interested in helping be a maintainer of this crate? As is probably obvious I do not have a huge amount of time and I think it is suffering because of that.

Comment thread src/parser/mod.rs
// Access on BigQuery nested and repeated expressions can
// mix notations in the same expression.
// https://cloud.google.com/bigquery/docs/nested-repeated#query_nested_and_repeated_columns
Token::Period if dialect_of!(self is BigQueryDialect) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding GenericDialect here too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I suspect it would be valid to include Generic here without conflicting (from an entry point pov I remember with the current setup Generic doesn't fall into this function today because together with Postgres it parses the expression as an Array instead - but that could change in the future)

@alamb alamb merged commit eda86d8 into apache:main Apr 9, 2024
@iffyio
Copy link
Copy Markdown
Contributor Author

iffyio commented Apr 10, 2024

@alamb Thanks a lot for the reviews 🙏

Regarding maintainership, sure I'm happy to help out in this regard and can allocate more time to reviews and tracking issues etc. Do let me know how to effectively help out here

@iffyio iffyio deleted the map-expr branch April 10, 2024 17:44
@alamb
Copy link
Copy Markdown
Contributor

alamb commented Apr 10, 2024

Regarding maintainership, sure I'm happy to help out in this regard and can allocate more time to reviews and tracking issues etc. Do let me know how to effectively help out here

Thank you @iffyio -- that is great news.

Basically the work is reviewing other PRs and getting them ready for merge (which means doing what you already do well -- make sure they are tested, documented, and don't cause overly painful changes for downstream crates)

There is more documentation on https://github.com/sqlparser-rs/sqlparser-rs/discussions/940

Let me know if you want to learn more or have a video call to discuss the possibility

@iffyio
Copy link
Copy Markdown
Contributor Author

iffyio commented Apr 10, 2024

That sounds good to me! Will look to help out further in that case 👍

@alamb
Copy link
Copy Markdown
Contributor

alamb commented Apr 12, 2024

That sounds good to me! Will look to help out further in that case 👍

BTW if you see a PR that is ready to go in your opinion please just mention (@alamb) me and I'll take a look. Otherwise I likely won't see it as I don't monitor all alerts from this repo

@iffyio
Copy link
Copy Markdown
Contributor Author

iffyio commented Apr 12, 2024

BTW if you see a PR that is ready to go in your opinion please just mention (@alamb) me and I'll take a look. Otherwise I likely won't see it as I don't monitor all alerts from this repo

Ah good to know, will do!

JichaoS pushed a commit to luabase/sqlparser-rs that referenced this pull request May 7, 2024
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.

3 participants