-
Notifications
You must be signed in to change notification settings - Fork 30
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
[SQL] implement ARRAY_CONTAINS function #1499
Conversation
docs/sql/array.md
Outdated
@@ -40,6 +40,7 @@ as `CREATE TABLE data AS (CITIES VARCHAR ARRAY, COUNTRY VARCHAR)`. | |||
|----------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------| | |||
| _array_`[`_index_`]` | where _index_ is an expression that evaluates to an integer, and _array_ is an expression that evaluates to an array. Returns the element at the specified position. If the index is out of bounds, the result is `NULL`. | `ARRAY[2,3][2]` => 3 | | |||
| `ARRAY_APPEND(` _array_ `, ` _element_ `)` | Appends an element to the end of the array and returns the result. If the array is `NULL`, the function will return `NULL`. If the _element_ is `NULL`, the `NULL` element will be added to the end of the array. | `ARRAY_APPEND(ARRAY [1, 2], 3)` => `[1, 2, 3]` | | |||
| `ARRAY_CONTAINS(` _array_ `, ` _element_ `)` | Returns true if the _array_ contains the _element_ | `ARRAY_CONTAINS(ARRAY [1, 2, 3], 2)` => true | |
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.
this also behaves strange for nulls
Signed-off-by: Abhinav Gyawali <22275402+abhizer@users.noreply.github.com> update changelog.md Signed-off-by: Abhinav Gyawali <22275402+abhizer@users.noreply.github.com> update docs Signed-off-by: Abhinav Gyawali <22275402+abhizer@users.noreply.github.com>
docs/sql/array.md
Outdated
@@ -41,6 +41,7 @@ as `CREATE TABLE data AS (CITIES VARCHAR ARRAY, COUNTRY VARCHAR)`. | |||
| _array_`[`_index_`]` | where _index_ is an expression that evaluates to an integer, and _array_ is an expression that evaluates to an array. Returns the element at the specified position. If the index is out of bounds, the result is `NULL`. | `ARRAY[2,3][2]` => 3 | | |||
| `ARRAY_APPEND(` _array_ `, ` _element_ `)` | Appends an element to the end of the array and returns the result. If the array is `NULL`, the function will return `NULL`. If the _element_ is `NULL`, the `NULL` element will be added to the end of the array. | `ARRAY_APPEND(ARRAY [1, 2], 3)` => `[1, 2, 3]` | | |||
| `ARRAY_COMPACT(` _array_ `)` | Returns a new array by removing all the `NULL` values from the _array_ | `ARRAY_COMPACT(ARRAY [1, 2, 3, NULL])` => `[1, 2, 3]` | | |||
| `ARRAY_CONTAINS(` _array_ `, ` _element_ `)` | Returns true if the _array_ contains the _element_. If _element_ is `NULL`, `NULL` is returned. | `ARRAY_CONTAINS(ARRAY [1, 2, 3], 2)` => true | |
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 would swap these two in the description, because the second one takes priority.
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.
btw, please review the other descriptions to see if this change should be applied to them as well.
Signed-off-by: Abhinav Gyawali <22275402+abhizer@users.noreply.github.com>
Signed-off-by: Mihai Budiu <mbudiu@gmail.com>
Is this a user-visible change (yes/no): yes