feniljain commented on issue #2547:
URL: https://github.com/apache/datafusion/issues/2547#issuecomment-3647768852
Hey @Jefffrey 👋🏻
I was trying to implement and understand steps you have listed, I added
`AllOp` in `datafusion/datafusion/sql/src/expr/mod.rs` and got to constructing
a `plan_all` equivalent to `plan_any`. After this, you mention above, one would
have to use `ArrayHasAll`. Documentation of `array_has_all` says:
```
returns true if each element of the second array appears in the first array;
otherwise, it returns false.
```
This seems to be expecting two arrays, but let's say for query like given in
parent message comment:
```sql
SELECT 1 = ALL(ARRAY[1,1,1,1]);
```
We don't have two arrays, instead one scalar and one array. We can't use
`ArrayHas` and `ArrayHasAny` as they don't seem to satisfy the exact condition
of all elements matching, or they expect both parameters as arrays.
I see two ways out of this:
- I expand a scalar like `1` in the case above to an array of the same size
as inside `ALL`
- I implement a different function for use in our case, something like
`ArrayHasAllElementsEqlTo` for scalar use
- And for cases where we have an array on the left, we use
`ArrayHasAll` and make sure both arrays have the same length
My understanding is derived from trying a few queries on these playgrounds:
- https://aiven.io/tools/pg-playground, and
- https://www.w3schools.com/sql/sql_any_all.asp
Do correct me if I am understanding this wrong 😅
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]