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

feat: nested list access #2966

Merged
merged 5 commits into from
Oct 2, 2024
Merged

Conversation

wjones127
Copy link
Contributor

@wjones127 wjones127 commented Oct 1, 2024

Adds support for accessing list items and struct fields with subscripting: x[0] and x['field_name']. These can be chained.

Unfortunately there is an issue with our SQL parser related to using . I wasn't able to figure out. Follow up issue here: #2967

@github-actions github-actions bot added enhancement New feature or request python labels Oct 1, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 57.14286% with 33 lines in your changes missing coverage. Please review.

Project coverage is 78.93%. Comparing base (6e042ac) to head (056aa10).

Files with missing lines Patch % Lines
rust/lance-datafusion/src/planner.rs 57.14% 28 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2966      +/-   ##
==========================================
- Coverage   78.97%   78.93%   -0.05%     
==========================================
  Files         234      234              
  Lines       72916    72990      +74     
  Branches    72916    72990      +74     
==========================================
+ Hits        57589    57614      +25     
- Misses      12354    12383      +29     
- Partials     2973     2993      +20     
Flag Coverage Δ
unittests 78.93% <57.14%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +705 to +706
let key = Box::new(self.parse_sql_expr(key)?);
GetFieldAccess::ListIndex { key }
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to verify this is an integer at some point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think in theory it could be an expression that resolves to an integer. I'm kind of trusting that it will be verified somewhere down the chain.


Ok(expr)
}
SQLExpr::Subscript { expr, subscript } => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Somewhat annoying that both Subscript and MapAccess exist 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah and which path is triggered depends on the dialect. Implemented both for now.

@wjones127 wjones127 merged commit c213413 into lancedb:main Oct 2, 2024
27 of 29 checks passed
@wjones127 wjones127 deleted the feat/nested-list-access branch October 2, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants