yuanlihan opened a new pull request #11987:
URL: https://github.com/apache/druid/pull/11987


   ### Description
   This PR adds two new array function to Druid.
   | function | description |
   | --- | --- |
   | array_contains_contiguous_subarray(arr,expr) | returns 1 if the array 
contains the element specified by expr, or contains contiguous subarray(see 
[substring](https://en.wikipedia.org/wiki/Substring)) specified by expr if expr 
is an array, else 0 |
   | array_contains_subsequence(arr,expr) | returns 1 if the array contains the 
element specified by expr, or contains 
[subsequence](https://en.wikipedia.org/wiki/Subsequence) specified by expr if 
expr is an array, else 0 |
   
   The two array functions can be typically used as filters on [multi-value 
dimensions](https://druid.apache.org/docs/latest/querying/multi-value-dimensions.html)
 to do funnel analysis for user behaviour analytics.
   Below is a simple example of user behaviour data
   ```json
   {"timestamp": "2011-01-12T00:00:00.000Z", "user": "id1", "events": 
["login","home","search"]} 
   {"timestamp": "2011-01-13T00:00:00.000Z", "user": "id2", "events": 
["home","search","shop"]} 
   {"timestamp": "2011-01-14T00:00:00.000Z", "user": "id3", "events": 
["home","product","cart"]}
   ```
   We can query how many users get through a series of steps
   ```sql
   select APPROX_COUNT_DISTINCT(user) from ds_name where 
MV_CONTAINS_SUBSEQUENCE(events, ARRAY['home', 'product'])
   ```
   
   
   ##### Key changed/added classes in this PR
    * `Function`
    * `ArrayContainsSubsequenceOperatorConversion`
    * `ArrayContainsContiguousSubarrayOperatorConversion`
    * `MultiValueStringOperatorConversions`
   
   <hr>
   
   <!-- Check the items by putting "x" in the brackets for the done things. Not 
all of these items apply to every PR. Remove the items which are not done or 
not relevant to the PR. None of the items from the checklist below are strictly 
necessary, but it would be very helpful if you at least self-review the PR. -->
   
   This PR has:
   - [X] been self-reviewed.(Remove this item if the PR doesn't have any 
relation to concurrency.)
   - [X] added documentation for new or modified features or behaviors.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in 
[licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [X] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [X] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [ ] added integration tests.
   - [X] been tested in a test Druid cluster.
   


-- 
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]

Reply via email to