I am having trouble trying to use the THETA_SKETCH_INTERSECT Druid SQL function
Reading the docs, it seems straightforward:
Syntax:
THETA_SKETCH_INTERSECT([size], expr0, expr1, …)
Returns an intersection of theta sketches, where each input expression must return a theta sketch. The
size
can be optionally specified as the first parameter.
Having read that, I tried to create my SQL snippet, basically I am trying to get the number of common customers between two stores in my datasource my_table:
SELECT THETA_SKETCH_INTERSECT( ( SELECT DISTINCT_CUSTOMERS FROM my_table WHERE var1 = 'STORE_A' ), ( SELECT DISTINCT_CUSTOMERS FROM my_table WHERE var1 = 'STORE_B' ) )
Running that leads me to this error:
Unknown exception / Cannot build plan for query: SELECT THETA_SKETCH_INTERSECT( (SELECT DISTINCT_CUSTOMERS FROM tm_agg WHERE STORE = 'STOR_WATS'), (SELECT DISTINCT_CUSTOMERS FROM tm_agg WHERE STORE = 'STOR_ACEH') ) / org.apache.druid.java.util.common.ISE
Hope anyone can help me on this.
Note: I know that Native query is easier. But I have my limitations and would appreciate if I can make the THETA_SKETCH functions work via SQL. Thanks!