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

document arrayContainsElement filter #15455

Merged

Conversation

clintropolis
Copy link
Member

Adds docs for new native filter added in #15366

@@ -450,6 +450,43 @@ Note that it is often more optimal to use a like filter instead of a regex for s
{ "type": "regex", "dimension": "someColumn", "pattern": ^50.* }
```

## Array contains element filter

The `arrayContainsElement` filter is for checking if an `ARRAY` contains a specific element, but can match against any type of column with scalar columns being treated as single element arrays.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The `arrayContainsElement` filter is for checking if an `ARRAY` contains a specific element, but can match against any type of column with scalar columns being treated as single element arrays.
The `arrayContainsElement` filter is for checking if an `ARRAY` contains a specific element, but can also match against any type of column. When matching against scalar columns, scalar columns are treated as single-element arrays.

Copy link
Contributor

Choose a reason for hiding this comment

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

Includes Abhishek's suggestions:

Suggested change
The `arrayContainsElement` filter is for checking if an `ARRAY` contains a specific element, but can match against any type of column with scalar columns being treated as single element arrays.
The `arrayContainsElement` filter checks if an `ARRAY` contains a specific element but can also match against any type of column. When matching against scalar columns, scalar columns are treated as single-element arrays.

| Property | Description | Required |
| -------- | ----------- | -------- |
| `type` | Must be "arrayContainsElement".| Yes |
| `column` | Input column or virtual column name to filter. | Yes |
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| `column` | Input column or virtual column name to filter. | Yes |
| `column` | Input column or virtual column name to filter on. | Yes |

Copy link
Member Author

Choose a reason for hiding this comment

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

this matches all of the other tables in the page.. i guess i can update all of the tables... again :p

Copy link
Contributor

Choose a reason for hiding this comment

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

its ok even if we make an exception here :)

| `type` | Must be "arrayContainsElement".| Yes |
| `column` | Input column or virtual column name to filter. | Yes |
| `elementMatchValueType` | String specifying the type of element value to match. For example `STRING`, `LONG`, `DOUBLE`, `FLOAT`, `ARRAY<STRING>`, `ARRAY<LONG>`, or any other Druid type. The `elementMatchValueType` determines how Druid interprets the `elementMatchValue` to assist in converting to the type of elements contained in the matched `column`. | Yes |
| `elementMatchValue` | Array element value to match, including null. | Yes |
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| `elementMatchValue` | Array element value to match, including null. | Yes |
| `elementMatchValue` | The value to is matched against the elements of `column`. This value can be null. | Yes |

my phrasing might not be best here.

Copy link
Contributor

Choose a reason for hiding this comment

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

The original wording is mostly ok imo, but the explicit can be null is helpful.

Suggested change
| `elementMatchValue` | Array element value to match, including null. | Yes |
| `elementMatchValue` | Array element value to match. This value can be null. | Yes |

| `elementMatchValueType` | String specifying the type of element value to match. For example `STRING`, `LONG`, `DOUBLE`, `FLOAT`, `ARRAY<STRING>`, `ARRAY<LONG>`, or any other Druid type. The `elementMatchValueType` determines how Druid interprets the `elementMatchValue` to assist in converting to the type of elements contained in the matched `column`. | Yes |
| `elementMatchValue` | Array element value to match, including null. | Yes |

### Example: equivalent of `WHERE ARRAY_CONTAINS(someArrayColumn, 'hello')`
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel a language like below is better

Suggested change
### Example: equivalent of `WHERE ARRAY_CONTAINS(someArrayColumn, 'hello')`
### Example: to filter rows where someArrayColumn has any element that is equal to 'hello'

Copy link
Member Author

Choose a reason for hiding this comment

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

all of the other examples on this page are framed in terms of equivalent SQL queries, am going to leave it as is

Copy link
Contributor

Choose a reason for hiding this comment

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

hehe. that's what I thought but was too lazy to look beyond the surrounding functions.

Copy link
Contributor

@317brian 317brian left a comment

Choose a reason for hiding this comment

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

LGTM, just some minor suggestions on top of Abhishek's suggestions.

@@ -450,6 +450,43 @@ Note that it is often more optimal to use a like filter instead of a regex for s
{ "type": "regex", "dimension": "someColumn", "pattern": ^50.* }
```

## Array contains element filter

The `arrayContainsElement` filter is for checking if an `ARRAY` contains a specific element, but can match against any type of column with scalar columns being treated as single element arrays.
Copy link
Contributor

Choose a reason for hiding this comment

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

Includes Abhishek's suggestions:

Suggested change
The `arrayContainsElement` filter is for checking if an `ARRAY` contains a specific element, but can match against any type of column with scalar columns being treated as single element arrays.
The `arrayContainsElement` filter checks if an `ARRAY` contains a specific element but can also match against any type of column. When matching against scalar columns, scalar columns are treated as single-element arrays.

| `type` | Must be "arrayContainsElement".| Yes |
| `column` | Input column or virtual column name to filter. | Yes |
| `elementMatchValueType` | String specifying the type of element value to match. For example `STRING`, `LONG`, `DOUBLE`, `FLOAT`, `ARRAY<STRING>`, `ARRAY<LONG>`, or any other Druid type. The `elementMatchValueType` determines how Druid interprets the `elementMatchValue` to assist in converting to the type of elements contained in the matched `column`. | Yes |
| `elementMatchValue` | Array element value to match, including null. | Yes |
Copy link
Contributor

Choose a reason for hiding this comment

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

The original wording is mostly ok imo, but the explicit can be null is helpful.

Suggested change
| `elementMatchValue` | Array element value to match, including null. | Yes |
| `elementMatchValue` | Array element value to match. This value can be null. | Yes |

@clintropolis clintropolis merged commit 82ac487 into apache:master Dec 7, 2023
11 checks passed
@clintropolis clintropolis deleted the array-contains-element-docs branch December 7, 2023 08:14
@LakshSingla LakshSingla added this to the 29.0.0 milestone Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants