-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: array containment operator @> and <@
#6885
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
Conversation
|
|
||
| ## array containment operator | ||
|
|
||
| # array containment operator with scalars #1 (at arrow) |
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.
The feature supports now only scalars as input, but in the production users prefer to work with columns.
I created the ticket dedicated to that issue: #7119.
|
@alamb @jayzhan211 Can you review this little feature if you have time. |
datafusion/sql/src/expr/mod.rs
Outdated
| right, | ||
| } => { | ||
| // Note the order that we push the entries to the stack | ||
| // is important. We want to visit the left node first. |
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.
why should we visit the left node first?
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 think this is a copy/paste comment from above.
I believe the rationale is that this code is using an explicit stack (rather than local variables on the call stack) to avoid stack overflows with deeply nested queries.
To be consistent the planner did a depth first search (always following the first / left child first) and thus to replicate that behavior the left child must be put on the stack
jayzhan211
left a comment
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!
|
@alamb can you review that change if you have time? |
|
On my list |
@> and <@
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.
Looks great to me -- thanks @izveigor - I am happy to merge this as is of can wait for you to address any comments you would like
It would also be great to add these new operators to the SQL documentation, but given a quick look at the user guide suggests we don't have any docs for supported operators yet. https://arrow.apache.org/datafusion/user-guide/sql/index.html
I will file a follow on ticket to add some
| } | ||
| Operator::AtArrow | ||
| | Operator::ArrowAt => { | ||
| arrow_coercion(lhs, rhs).map(Signature::uniform).ok_or_else(|| { |
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 why the name arrow_ (and not, array_) here
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.
Agree, with array_ it would be more consistent.
datafusion/sql/src/expr/mod.rs
Outdated
| right, | ||
| } => { | ||
| // Note the order that we push the entries to the stack | ||
| // is important. We want to visit the left node first. |
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 think this is a copy/paste comment from above.
I believe the rationale is that this code is using an explicit stack (rather than local variables on the call stack) to avoid stack overflows with deeply nested queries.
To be consistent the planner did a depth first search (always following the first / left child first) and thus to replicate that behavior the left child must be put on the stack
|
Filed #7153 for documentation |
|
@alamb I fixed all nitpicks which you mentioned in your comments. Thank you for review, @alamb and @jayzhan211! |
|
Thanks again @izveigor |
Which issue does this PR close?
Closes #6884
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?