-
Notifications
You must be signed in to change notification settings - Fork 566
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
Enable map access for numbers, multiple nesting levels #356
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Igosuki !
Looks good to me. FYI @hntd187 as MapAccess
seems to have been introduced in #235
Broadly speaking looks compatible with https://www.postgresql.org/docs/9.1/arrays.html too
tests/sqlparser_postgres.rs
Outdated
@@ -669,6 +672,26 @@ fn parse_pg_regex_match_ops() { | |||
} | |||
} | |||
|
|||
#[test] | |||
fn parse_map_access_expr() { | |||
//let sql = "SELECT foo[0] as foozero, bar[\"baz\"] as barbaz FROM foos"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if you meant to leave this commented out
@@ -251,7 +251,7 @@ pub enum Expr { | |||
}, | |||
MapAccess { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can improve the docstrings here while we are modifying this file?
This PR also adds support for multiple levels of map access as well, right? Like not just ["foo"] also ["foo"]["bar"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @Igosuki !
@alamb yeah the point is to enable infinite levels of nesting, I should probably add a test for that with arbitrary nesting of n |
looks like there are some CI tests to clean up as well @Igosuki FYI |
Looks good to me, I remember map access being something I was not entirely confident in for my initial work, but perhaps if one was able to extend it then it wasn't as bad as my own perception was of it. |
Well, there will be occasions to expand upon this. For instance to support ranges, which are in the pg dialect (e.g. |
It breaks the hive test for map_access, since we don't differentiate between double and single quoted strings, I think this needs further fixing |
…d strings for map access
Since map access belongs into the OLAP world and there is already the hive dialect, I went and enforced double quoted strings for map access in the display. |
So now MapAccess is an infinite depth path access to nested values. I think allowing compound field selection within this should be a separate addition as it requires patching the tokenization so that '.' is allowed after brackets |
Pull Request Test Coverage Report for Build 1269308355Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
src/ast/mod.rs
Outdated
.map(|k| { | ||
match k { | ||
k @ Value::Number(_, _) => format!("[{}]", k), | ||
Value::SingleQuotedString(s) => format!("[\"{}\"]", s), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is odd to me that a SingleQuotedString
is emitted with double quotes ("
) but it is consistent with the existing implementation
makes sense to me |
FYI @Igosuki I fixed a CI failure with c9e3cfb |
Thanks, now to enable this in data fusion
Le ven. 24 sept. 2021 à 20:22, Andrew Lamb ***@***.***> a
écrit :
… Merged #356 <#356> into
main.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#356 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADDFBWH2KRMP5NBKSK5EYDUDS6WBANCNFSM5EEDJNZA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Thank you for your work on this @Igosuki ! |
Thanks for merging
Le sam. 25 sept. 2021 à 22:22, QP Hou ***@***.***> a écrit :
… Thank you for your work on this @Igosuki <https://github.com/Igosuki> !
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#356 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADDFBWIW6OOXHUYOUX6NALUDYVQTANCNFSM5EEDJNZA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
|
This enables number based map access in the AST. I am unsure if this required a new type rather than just patching MapAccess but here goes.