diff --git a/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_aggr_general.iq b/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_aggr_general.iq new file mode 100644 index 00000000000..d05f8b7b839 --- /dev/null +++ b/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_aggr_general.iq @@ -0,0 +1,1146 @@ +!set useApproximateCountDistinct false +!use druidtest:///?componentSupplier=KttmNestedComponentSupplier +!set outputformat mysql +SELECT count(DISTINCT time_floor(__time, 'PT1H')) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00'; ++-----+ +| cnt | ++-----+ +| 7 | ++-----+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A1: count_star +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + count(*)+1 c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND (count(*)+1 IS NULL + OR (count(*)+1 = count(*)+1 + AND count(*)+1 IS NOT DISTINCT + FROM count(*)+1 + AND count(*)+1 <> count(*) + AND (count(*)+1 IS DISTINCT + FROM count(*)) + AND count(*)+1 > count(*) + AND count(*)+1 >= count(*) + AND count(*)+1 < count(*)+2 + AND count(*)+1 <= count(*)+2 + AND (count(*)+1 <> count(*)) IS TRUE + AND (count(*)+1 = count(*)) IS NOT TRUE + AND (count(*)+1 = count(*)) IS FALSE + AND (count(*)+1 <> count(*)) IS NOT FALSE + AND count(*)+1 BETWEEN count(*) AND count(*)+2 + AND count(*)+1 NOT BETWEEN count(*)+1 AND count(*) + AND count(*)+1 like '%' + AND count(*)+1 not like '__DOES_NOT_EXIST__%' + AND count(*)+1 IN (count(*), + count(*)+1, + count(*)+2) + AND count(*)+1 NOT IN (count(*), + count(*)+2))) ; ++-------------------------+-------+ +| t | c | ++-------------------------+-------+ +| 2019-08-25 00:00:00.000 | 13588 | +| 2019-08-25 01:00:00.000 | 13442 | +| 2019-08-25 02:00:00.000 | 15006 | +| 2019-08-25 03:00:00.000 | 12879 | +| 2019-08-25 04:00:00.000 | 9084 | +| 2019-08-25 05:00:00.000 | 8057 | +| 2019-08-25 06:00:00.000 | 6148 | ++-------------------------+-------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A2: count_expr +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + count(agent)+1 c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND (count(agent)+1 IS NULL + OR (count(agent)+1 = count(agent)+1 + AND count(agent)+1 IS NOT DISTINCT + FROM count(agent)+1 + AND count(agent)+1 <> count(agent) + AND (count(agent)+1 IS DISTINCT + FROM count(agent)) + AND count(agent)+1 > count(agent) + AND count(agent)+1 >= count(agent) + AND count(agent)+1 < count(agent)+2 + AND count(agent)+1 <= count(agent)+2 + AND (count(agent)+1 <> count(agent)) IS TRUE + AND (count(agent)+1 = count(agent)) IS NOT TRUE + AND (count(agent)+1 = count(agent)) IS FALSE + AND (count(agent)+1 <> count(agent)) IS NOT FALSE + AND count(agent)+1 BETWEEN count(agent) AND count(agent)+2 + AND count(agent)+1 NOT BETWEEN count(agent)+1 AND count(agent) + AND count(agent)+1 like '%' + AND count(agent)+1 not like '__DOES_NOT_EXIST__%' + AND count(agent)+1 IN (count(agent), + count(agent)+1, + count(agent)+2) + AND count(agent)+1 NOT IN (count(agent), + count(agent)+2))) ; ++-------------------------+-------+ +| t | c | ++-------------------------+-------+ +| 2019-08-25 00:00:00.000 | 13588 | +| 2019-08-25 01:00:00.000 | 13442 | +| 2019-08-25 02:00:00.000 | 15006 | +| 2019-08-25 03:00:00.000 | 12879 | +| 2019-08-25 04:00:00.000 | 9084 | +| 2019-08-25 05:00:00.000 | 8057 | +| 2019-08-25 06:00:00.000 | 6148 | ++-------------------------+-------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A3: count_distinct +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + count(DISTINCT agent)+1 c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND (count(DISTINCT agent)+1 IS NULL + OR (count(DISTINCT agent)+1 = count(DISTINCT agent)+1 + AND count(DISTINCT agent)+1 IS NOT DISTINCT + FROM count(DISTINCT agent)+1 + AND count(DISTINCT agent)+1 <> count(DISTINCT agent) + AND (count(DISTINCT agent)+1 IS DISTINCT + FROM count(DISTINCT agent)) + AND count(DISTINCT agent)+1 > count(DISTINCT agent) + AND count(DISTINCT agent)+1 >= count(DISTINCT agent) + AND count(DISTINCT agent)+1 < count(DISTINCT agent)+2 + AND count(DISTINCT agent)+1 <= count(DISTINCT agent)+2 + AND (count(DISTINCT agent)+1 <> count(DISTINCT agent)) IS TRUE + AND (count(DISTINCT agent)+1 = count(DISTINCT agent)) IS NOT TRUE + AND (count(DISTINCT agent)+1 = count(DISTINCT agent)) IS FALSE + AND (count(DISTINCT agent)+1 <> count(DISTINCT agent)) IS NOT FALSE + AND count(DISTINCT agent)+1 BETWEEN count(DISTINCT agent) AND count(DISTINCT agent)+2 + AND count(DISTINCT agent)+1 NOT BETWEEN count(DISTINCT agent)+1 AND count(DISTINCT agent) + AND count(DISTINCT agent)+1 like '%' + AND count(DISTINCT agent)+1 not like '__DOES_NOT_EXIST__%' + AND count(DISTINCT agent)+1 IN (count(DISTINCT agent), + count(DISTINCT agent)+1, + count(DISTINCT agent)+2) + AND count(DISTINCT agent)+1 NOT IN (count(DISTINCT agent), + count(DISTINCT agent)+2))) ; ++-------------------------+-----+ +| t | c | ++-------------------------+-----+ +| 2019-08-25 00:00:00.000 | 118 | +| 2019-08-25 01:00:00.000 | 114 | +| 2019-08-25 02:00:00.000 | 114 | +| 2019-08-25 03:00:00.000 | 120 | +| 2019-08-25 04:00:00.000 | 97 | +| 2019-08-25 05:00:00.000 | 88 | +| 2019-08-25 06:00:00.000 | 85 | ++-------------------------+-----+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A4: sum +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + sum(session_length)+1 c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND (sum(session_length)+1 IS NULL + OR (sum(session_length)+1 = sum(session_length)+1 + AND sum(session_length)+1 IS NOT DISTINCT + FROM sum(session_length)+1 + AND sum(session_length)+1 <> sum(session_length) + AND (sum(session_length)+1 IS DISTINCT + FROM sum(session_length)) + AND sum(session_length)+1 > sum(session_length) + AND sum(session_length)+1 >= sum(session_length) + AND sum(session_length)+1 < sum(session_length)+2 + AND sum(session_length)+1 <= sum(session_length)+2 + AND (sum(session_length)+1 <> sum(session_length)) IS TRUE + AND (sum(session_length)+1 = sum(session_length)) IS NOT TRUE + AND (sum(session_length)+1 = sum(session_length)) IS FALSE + AND (sum(session_length)+1 <> sum(session_length)) IS NOT FALSE + AND sum(session_length)+1 BETWEEN sum(session_length) AND sum(session_length)+2 + AND sum(session_length)+1 NOT BETWEEN sum(session_length)+1 AND sum(session_length) + AND sum(session_length)+1 like '%' + AND sum(session_length)+1 not like '__DOES_NOT_EXIST__%' + AND sum(session_length)+1 IN (sum(session_length), + sum(session_length)+1, + sum(session_length)+2) + AND sum(session_length)+1 NOT IN (sum(session_length), + sum(session_length)+2))) ; ++-------------------------+------------+ +| t | c | ++-------------------------+------------+ +| 2019-08-25 00:00:00.000 | 6285177784 | +| 2019-08-25 01:00:00.000 | 1983213622 | +| 2019-08-25 02:00:00.000 | 2149033768 | +| 2019-08-25 03:00:00.000 | 2764093084 | +| 2019-08-25 04:00:00.000 | 5181690410 | +| 2019-08-25 05:00:00.000 | 2010439102 | +| 2019-08-25 06:00:00.000 | 4873692912 | ++-------------------------+------------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A5: min_numeric +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + min(session_length)+1 c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND (min(session_length)+1 IS NULL + OR (min(session_length)+1 = min(session_length)+1 + AND min(session_length)+1 IS NOT DISTINCT + FROM min(session_length)+1 + AND min(session_length)+1 <> min(session_length) + AND (min(session_length)+1 IS DISTINCT + FROM min(session_length)) + AND min(session_length)+1 > min(session_length) + AND min(session_length)+1 >= min(session_length) + AND min(session_length)+1 < min(session_length)+2 + AND min(session_length)+1 <= min(session_length)+2 + AND (min(session_length)+1 <> min(session_length)) IS TRUE + AND (min(session_length)+1 = min(session_length)) IS NOT TRUE + AND (min(session_length)+1 = min(session_length)) IS FALSE + AND (min(session_length)+1 <> min(session_length)) IS NOT FALSE + AND min(session_length)+1 BETWEEN min(session_length) AND min(session_length)+2 + AND min(session_length)+1 NOT BETWEEN min(session_length)+1 AND min(session_length) + AND min(session_length)+1 like '%' + AND min(session_length)+1 not like '__DOES_NOT_EXIST__%' + AND min(session_length)+1 IN (min(session_length), + min(session_length)+1, + min(session_length)+2) + AND min(session_length)+1 NOT IN (min(session_length), + min(session_length)+2))) ; ++-------------------------+----+ +| t | c | ++-------------------------+----+ +| 2019-08-25 00:00:00.000 | 16 | +| 2019-08-25 01:00:00.000 | 21 | +| 2019-08-25 02:00:00.000 | 15 | +| 2019-08-25 03:00:00.000 | 5 | +| 2019-08-25 04:00:00.000 | 4 | +| 2019-08-25 05:00:00.000 | 16 | +| 2019-08-25 06:00:00.000 | 16 | ++-------------------------+----+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A6: min_timestamp +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + min(time_floor(__time, 'PT1H'))+interval '1' YEAR c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND (min(time_floor(__time, 'PT1H'))+interval '1' YEAR IS NULL + OR (min(time_floor(__time, 'PT1H'))+interval '1' YEAR = min(time_floor(__time, 'PT1H'))+interval '1' YEAR + AND min(time_floor(__time, 'PT1H'))+interval '1' YEAR IS NOT DISTINCT + FROM min(time_floor(__time, 'PT1H'))+interval '1' YEAR + AND min(time_floor(__time, 'PT1H'))+interval '1' YEAR <> min(time_floor(__time, 'PT1H')) + AND (min(time_floor(__time, 'PT1H'))+interval '1' YEAR IS DISTINCT + FROM min(time_floor(__time, 'PT1H'))) + AND min(time_floor(__time, 'PT1H'))+interval '1' YEAR > min(time_floor(__time, 'PT1H')) + AND min(time_floor(__time, 'PT1H'))+interval '1' YEAR >= min(time_floor(__time, 'PT1H')) + AND min(time_floor(__time, 'PT1H'))+interval '1' YEAR < min(time_floor(__time, 'PT1H'))+interval '2' YEAR + AND min(time_floor(__time, 'PT1H'))+interval '1' YEAR <= min(time_floor(__time, 'PT1H'))+interval '2' YEAR + AND (min(time_floor(__time, 'PT1H'))+interval '1' YEAR <> min(time_floor(__time, 'PT1H'))) IS TRUE + AND (min(time_floor(__time, 'PT1H'))+interval '1' YEAR = min(time_floor(__time, 'PT1H'))) IS NOT TRUE + AND (min(time_floor(__time, 'PT1H'))+interval '1' YEAR = min(time_floor(__time, 'PT1H'))) IS FALSE + AND (min(time_floor(__time, 'PT1H'))+interval '1' YEAR <> min(time_floor(__time, 'PT1H'))) IS NOT FALSE + AND min(time_floor(__time, 'PT1H'))+interval '1' YEAR BETWEEN min(time_floor(__time, 'PT1H')) AND min(time_floor(__time, 'PT1H'))+interval '2' YEAR + AND min(time_floor(__time, 'PT1H'))+interval '1' YEAR NOT BETWEEN min(time_floor(__time, 'PT1H'))+interval '1' YEAR AND min(time_floor(__time, 'PT1H')) + AND min(time_floor(__time, 'PT1H'))+interval '1' YEAR like '%' + AND min(time_floor(__time, 'PT1H'))+interval '1' YEAR not like '__DOES_NOT_EXIST__%' + AND min(time_floor(__time, 'PT1H'))+interval '1' YEAR IN (min(time_floor(__time, 'PT1H')), + min(time_floor(__time, 'PT1H'))+interval '1' YEAR, + min(time_floor(__time, 'PT1H'))+interval '2' YEAR) + AND min(time_floor(__time, 'PT1H'))+interval '1' YEAR NOT IN (min(time_floor(__time, 'PT1H')), + min(time_floor(__time, 'PT1H'))+interval '2' YEAR))) ; ++-------------------------+-------------------------+ +| t | c | ++-------------------------+-------------------------+ +| 2019-08-25 00:00:00.000 | 2020-08-25 00:00:00.000 | +| 2019-08-25 01:00:00.000 | 2020-08-25 01:00:00.000 | +| 2019-08-25 02:00:00.000 | 2020-08-25 02:00:00.000 | +| 2019-08-25 03:00:00.000 | 2020-08-25 03:00:00.000 | +| 2019-08-25 04:00:00.000 | 2020-08-25 04:00:00.000 | +| 2019-08-25 05:00:00.000 | 2020-08-25 05:00:00.000 | +| 2019-08-25 06:00:00.000 | 2020-08-25 06:00:00.000 | ++-------------------------+-------------------------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A7: max_numeric +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + max(session_length)+1 c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND (max(session_length)+1 IS NULL + OR (max(session_length)+1 = max(session_length)+1 + AND max(session_length)+1 IS NOT DISTINCT + FROM max(session_length)+1 + AND max(session_length)+1 <> max(session_length) + AND (max(session_length)+1 IS DISTINCT + FROM max(session_length)) + AND max(session_length)+1 > max(session_length) + AND max(session_length)+1 >= max(session_length) + AND max(session_length)+1 < max(session_length)+2 + AND max(session_length)+1 <= max(session_length)+2 + AND (max(session_length)+1 <> max(session_length)) IS TRUE + AND (max(session_length)+1 = max(session_length)) IS NOT TRUE + AND (max(session_length)+1 = max(session_length)) IS FALSE + AND (max(session_length)+1 <> max(session_length)) IS NOT FALSE + AND max(session_length)+1 BETWEEN max(session_length) AND max(session_length)+2 + AND max(session_length)+1 NOT BETWEEN max(session_length)+1 AND max(session_length) + AND max(session_length)+1 like '%' + AND max(session_length)+1 not like '__DOES_NOT_EXIST__%' + AND max(session_length)+1 IN (max(session_length), + max(session_length)+1, + max(session_length)+2) + AND max(session_length)+1 NOT IN (max(session_length), + max(session_length)+2))) ; ++-------------------------+-----------+ +| t | c | ++-------------------------+-----------+ +| 2019-08-25 00:00:00.000 | 160820137 | +| 2019-08-25 01:00:00.000 | 85049999 | +| 2019-08-25 02:00:00.000 | 133242163 | +| 2019-08-25 03:00:00.000 | 169648384 | +| 2019-08-25 04:00:00.000 | 189948466 | +| 2019-08-25 05:00:00.000 | 740328869 | +| 2019-08-25 06:00:00.000 | 679295139 | ++-------------------------+-----------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A8: max_timestamp +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + max(time_floor(__time, 'PT1H'))+interval '1' YEAR c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND (max(time_floor(__time, 'PT1H'))+interval '1' YEAR IS NULL + OR (max(time_floor(__time, 'PT1H'))+interval '1' YEAR = max(time_floor(__time, 'PT1H'))+interval '1' YEAR + AND max(time_floor(__time, 'PT1H'))+interval '1' YEAR IS NOT DISTINCT + FROM max(time_floor(__time, 'PT1H'))+interval '1' YEAR + AND max(time_floor(__time, 'PT1H'))+interval '1' YEAR <> max(time_floor(__time, 'PT1H')) + AND (max(time_floor(__time, 'PT1H'))+interval '1' YEAR IS DISTINCT + FROM max(time_floor(__time, 'PT1H'))) + AND max(time_floor(__time, 'PT1H'))+interval '1' YEAR > max(time_floor(__time, 'PT1H')) + AND max(time_floor(__time, 'PT1H'))+interval '1' YEAR >= max(time_floor(__time, 'PT1H')) + AND max(time_floor(__time, 'PT1H'))+interval '1' YEAR < max(time_floor(__time, 'PT1H'))+interval '2' YEAR + AND max(time_floor(__time, 'PT1H'))+interval '1' YEAR <= max(time_floor(__time, 'PT1H'))+interval '2' YEAR + AND (max(time_floor(__time, 'PT1H'))+interval '1' YEAR <> max(time_floor(__time, 'PT1H'))) IS TRUE + AND (max(time_floor(__time, 'PT1H'))+interval '1' YEAR = max(time_floor(__time, 'PT1H'))) IS NOT TRUE + AND (max(time_floor(__time, 'PT1H'))+interval '1' YEAR = max(time_floor(__time, 'PT1H'))) IS FALSE + AND (max(time_floor(__time, 'PT1H'))+interval '1' YEAR <> max(time_floor(__time, 'PT1H'))) IS NOT FALSE + AND max(time_floor(__time, 'PT1H'))+interval '1' YEAR BETWEEN max(time_floor(__time, 'PT1H')) AND max(time_floor(__time, 'PT1H'))+interval '2' YEAR + AND max(time_floor(__time, 'PT1H'))+interval '1' YEAR NOT BETWEEN max(time_floor(__time, 'PT1H'))+interval '1' YEAR AND max(time_floor(__time, 'PT1H')) + AND max(time_floor(__time, 'PT1H'))+interval '1' YEAR like '%' + AND max(time_floor(__time, 'PT1H'))+interval '1' YEAR not like '__DOES_NOT_EXIST__%' + AND max(time_floor(__time, 'PT1H'))+interval '1' YEAR IN (max(time_floor(__time, 'PT1H')), + max(time_floor(__time, 'PT1H'))+interval '1' YEAR, + max(time_floor(__time, 'PT1H'))+interval '2' YEAR) + AND max(time_floor(__time, 'PT1H'))+interval '1' YEAR NOT IN (max(time_floor(__time, 'PT1H')), + max(time_floor(__time, 'PT1H'))+interval '2' YEAR))) ; ++-------------------------+-------------------------+ +| t | c | ++-------------------------+-------------------------+ +| 2019-08-25 00:00:00.000 | 2020-08-25 00:00:00.000 | +| 2019-08-25 01:00:00.000 | 2020-08-25 01:00:00.000 | +| 2019-08-25 02:00:00.000 | 2020-08-25 02:00:00.000 | +| 2019-08-25 03:00:00.000 | 2020-08-25 03:00:00.000 | +| 2019-08-25 04:00:00.000 | 2020-08-25 04:00:00.000 | +| 2019-08-25 05:00:00.000 | 2020-08-25 05:00:00.000 | +| 2019-08-25 06:00:00.000 | 2020-08-25 06:00:00.000 | ++-------------------------+-------------------------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A9: avg +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + cast(avg(session_length)+1 AS bigint) c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND (cast(avg(session_length)+1 AS bigint) IS NULL + OR (cast(avg(session_length)+1 AS bigint) = cast(avg(session_length)+1 AS bigint) + AND cast(avg(session_length)+1 AS bigint) IS NOT DISTINCT + FROM cast(avg(session_length)+1 AS bigint) + AND cast(avg(session_length)+1 AS bigint) <> cast(avg(session_length) AS bigint) + AND (cast(avg(session_length)+1 AS bigint) IS DISTINCT + FROM cast(avg(session_length) AS bigint)) + AND cast(avg(session_length)+1 AS bigint) > cast(avg(session_length) AS bigint) + AND cast(avg(session_length)+1 AS bigint) >= cast(avg(session_length) AS bigint) + AND cast(avg(session_length)+1 AS bigint) < cast(avg(session_length)+2 AS bigint) + AND cast(avg(session_length)+1 AS bigint) <= cast(avg(session_length)+2 AS bigint) + AND (cast(avg(session_length)+1 AS bigint) <> cast(avg(session_length) AS bigint)) IS TRUE + AND (cast(avg(session_length)+1 AS bigint) = cast(avg(session_length) AS bigint)) IS NOT TRUE + AND (cast(avg(session_length)+1 AS bigint) = cast(avg(session_length) AS bigint)) IS FALSE + AND (cast(avg(session_length)+1 AS bigint) <> cast(avg(session_length) AS bigint)) IS NOT FALSE + AND cast(avg(session_length)+1 AS bigint) BETWEEN cast(avg(session_length) AS bigint) AND cast(avg(session_length)+2 AS bigint) + AND cast(avg(session_length)+1 AS bigint) NOT BETWEEN cast(avg(session_length)+1 AS bigint) AND cast(avg(session_length) AS bigint) + AND cast(avg(session_length)+1 AS bigint) like '%' + AND cast(avg(session_length)+1 AS bigint) not like '__DOES_NOT_EXIST__%' + AND cast(avg(session_length)+1 AS bigint) IN (cast(avg(session_length) AS bigint), + cast(avg(session_length)+1 AS bigint), + cast(avg(session_length)+2 AS bigint)) + AND cast(avg(session_length)+1 AS bigint) NOT IN (cast(avg(session_length) AS bigint), + cast(avg(session_length)+2 AS bigint)))) ; ++-------------------------+--------+ +| t | c | ++-------------------------+--------+ +| 2019-08-25 00:00:00.000 | 462588 | +| 2019-08-25 01:00:00.000 | 147550 | +| 2019-08-25 02:00:00.000 | 143222 | +| 2019-08-25 03:00:00.000 | 214637 | +| 2019-08-25 04:00:00.000 | 570483 | +| 2019-08-25 05:00:00.000 | 249558 | +| 2019-08-25 06:00:00.000 | 792858 | ++-------------------------+--------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A10: approx_count_distinct +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + approx_count_distinct(client_ip)+1000 c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND (approx_count_distinct(client_ip)+1000 IS NULL + OR (approx_count_distinct(client_ip)+1000 = approx_count_distinct(client_ip)+1000 + AND approx_count_distinct(client_ip)+1000 IS NOT DISTINCT + FROM approx_count_distinct(client_ip)+1000 + AND approx_count_distinct(client_ip)+1000 <> approx_count_distinct(client_ip) + AND (approx_count_distinct(client_ip)+1000 IS DISTINCT + FROM approx_count_distinct(client_ip)) + AND approx_count_distinct(client_ip)+1000 > approx_count_distinct(client_ip) + AND approx_count_distinct(client_ip)+1000 >= approx_count_distinct(client_ip) + AND approx_count_distinct(client_ip)+1000 < approx_count_distinct(client_ip)+2000 + AND approx_count_distinct(client_ip)+1000 <= approx_count_distinct(client_ip)+2000 + AND (approx_count_distinct(client_ip)+1000 <> approx_count_distinct(client_ip)) IS TRUE + AND (approx_count_distinct(client_ip)+1000 = approx_count_distinct(client_ip)) IS NOT TRUE + AND (approx_count_distinct(client_ip)+1000 = approx_count_distinct(client_ip)) IS FALSE + AND (approx_count_distinct(client_ip)+1000 <> approx_count_distinct(client_ip)) IS NOT FALSE + AND approx_count_distinct(client_ip)+1000 BETWEEN approx_count_distinct(client_ip) AND approx_count_distinct(client_ip)+2000 + AND approx_count_distinct(client_ip)+1000 NOT BETWEEN approx_count_distinct(client_ip)+1000 AND approx_count_distinct(client_ip) + AND approx_count_distinct(client_ip)+1000 like '%' + AND approx_count_distinct(client_ip)+1000 not like '__DOES_NOT_EXIST__%' + AND approx_count_distinct(client_ip)+1000 IN (approx_count_distinct(client_ip), + approx_count_distinct(client_ip)+1000, + approx_count_distinct(client_ip)+2000) + AND approx_count_distinct(client_ip)+1000 NOT IN (approx_count_distinct(client_ip), + approx_count_distinct(client_ip)+2000))) ; ++-------------------------+------+ +| t | c | ++-------------------------+------+ +| 2019-08-25 00:00:00.000 | 1825 | +| 2019-08-25 01:00:00.000 | 1870 | +| 2019-08-25 02:00:00.000 | 1925 | +| 2019-08-25 03:00:00.000 | 1727 | +| 2019-08-25 04:00:00.000 | 1539 | +| 2019-08-25 05:00:00.000 | 1500 | +| 2019-08-25 06:00:00.000 | 1360 | ++-------------------------+------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A11: approx_count_distinct_builtin +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + approx_count_distinct_builtin(client_ip)+1000 c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND (approx_count_distinct_builtin(client_ip)+1000 IS NULL + OR (approx_count_distinct_builtin(client_ip)+1000 = approx_count_distinct_builtin(client_ip)+1000 + AND approx_count_distinct_builtin(client_ip)+1000 IS NOT DISTINCT + FROM approx_count_distinct_builtin(client_ip)+1000 + AND approx_count_distinct_builtin(client_ip)+1000 <> approx_count_distinct_builtin(client_ip) + AND (approx_count_distinct_builtin(client_ip)+1000 IS DISTINCT + FROM approx_count_distinct_builtin(client_ip)) + AND approx_count_distinct_builtin(client_ip)+1000 > approx_count_distinct_builtin(client_ip) + AND approx_count_distinct_builtin(client_ip)+1000 >= approx_count_distinct_builtin(client_ip) + AND approx_count_distinct_builtin(client_ip)+1000 < approx_count_distinct_builtin(client_ip)+2000 + AND approx_count_distinct_builtin(client_ip)+1000 <= approx_count_distinct_builtin(client_ip)+2000 + AND (approx_count_distinct_builtin(client_ip)+1000 <> approx_count_distinct_builtin(client_ip)) IS TRUE + AND (approx_count_distinct_builtin(client_ip)+1000 = approx_count_distinct_builtin(client_ip)) IS NOT TRUE + AND (approx_count_distinct_builtin(client_ip)+1000 = approx_count_distinct_builtin(client_ip)) IS FALSE + AND (approx_count_distinct_builtin(client_ip)+1000 <> approx_count_distinct_builtin(client_ip)) IS NOT FALSE + AND approx_count_distinct_builtin(client_ip)+1000 BETWEEN approx_count_distinct_builtin(client_ip) AND approx_count_distinct_builtin(client_ip)+2000 + AND approx_count_distinct_builtin(client_ip)+1000 NOT BETWEEN approx_count_distinct_builtin(client_ip)+1000 AND approx_count_distinct_builtin(client_ip) + AND approx_count_distinct_builtin(client_ip)+1000 like '%' + AND approx_count_distinct_builtin(client_ip)+1000 not like '__DOES_NOT_EXIST__%' + AND approx_count_distinct_builtin(client_ip)+1000 IN (approx_count_distinct_builtin(client_ip), + approx_count_distinct_builtin(client_ip)+1000, + approx_count_distinct_builtin(client_ip)+2000) + AND approx_count_distinct_builtin(client_ip)+1000 NOT IN (approx_count_distinct_builtin(client_ip), + approx_count_distinct_builtin(client_ip)+2000))) ; ++-------------------------+------+ +| t | c | ++-------------------------+------+ +| 2019-08-25 00:00:00.000 | 1825 | +| 2019-08-25 01:00:00.000 | 1870 | +| 2019-08-25 02:00:00.000 | 1925 | +| 2019-08-25 03:00:00.000 | 1727 | +| 2019-08-25 04:00:00.000 | 1539 | +| 2019-08-25 05:00:00.000 | 1500 | +| 2019-08-25 06:00:00.000 | 1360 | ++-------------------------+------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A20: earliest_scalar +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + '1'||earliest(client_ip) c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND ('1'||earliest(client_ip) IS NULL + OR ('1'||earliest(client_ip) = 1||earliest(client_ip) + AND '1'||earliest(client_ip) IS NOT DISTINCT + FROM 1||earliest(client_ip) + AND '1'||earliest(client_ip) <> '0'||earliest(client_ip) + AND ('1'||earliest(client_ip) IS DISTINCT + FROM '0'||earliest(client_ip)) + AND '1'||earliest(client_ip) > '0'||earliest(client_ip) + AND '1'||earliest(client_ip) >= '0'||earliest(client_ip) + AND '1'||earliest(client_ip) < 2||earliest(client_ip) + AND '1'||earliest(client_ip) <= 2||earliest(client_ip) + AND ('1'||earliest(client_ip) <> '0'||earliest(client_ip)) IS TRUE + AND ('1'||earliest(client_ip) = '0'||earliest(client_ip)) IS NOT TRUE + AND ('1'||earliest(client_ip) = '0'||earliest(client_ip)) IS FALSE + AND ('1'||earliest(client_ip) <> '0'||earliest(client_ip)) IS NOT FALSE + AND '1'||earliest(client_ip) BETWEEN '0'||earliest(client_ip) AND 2||earliest(client_ip) + AND '1'||earliest(client_ip) NOT BETWEEN '1'||earliest(client_ip) AND '0'||earliest(client_ip) + AND '1'||earliest(client_ip) like '%' + AND '1'||earliest(client_ip) not like '__DOES_NOT_EXIST__%' + AND '1'||earliest(client_ip) IN ('0'||earliest(client_ip), + 1||earliest(client_ip), + 2||earliest(client_ip)) + AND '1'||earliest(client_ip) NOT IN ('0'||earliest(client_ip), + 2||earliest(client_ip)))) ; ++-------------------------+-----------------+ +| t | c | ++-------------------------+-----------------+ +| 2019-08-25 00:00:00.000 | 1181.13.41.82 | +| 2019-08-25 01:00:00.000 | 199.253.86.170 | +| 2019-08-25 02:00:00.000 | 1190.62.251.216 | +| 2019-08-25 03:00:00.000 | 1184.96.197.148 | +| 2019-08-25 04:00:00.000 | 1186.65.90.120 | +| 2019-08-25 05:00:00.000 | 1174.45.230.138 | +| 2019-08-25 06:00:00.000 | 149.178.15.174 | ++-------------------------+-----------------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A21: earliest_complex +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + '1'||json_value(earliest(agent), '$.type') c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND ('1'||json_value(earliest(agent), '$.type') IS NULL + OR ('1'||json_value(earliest(agent), '$.type') = 1||json_value(earliest(agent), '$.type') + AND '1'||json_value(earliest(agent), '$.type') IS NOT DISTINCT + FROM 1||json_value(earliest(agent), '$.type') + AND '1'||json_value(earliest(agent), '$.type') <> '0'||json_value(earliest(agent), '$.type') + AND ('1'||json_value(earliest(agent), '$.type') IS DISTINCT + FROM '0'||json_value(earliest(agent), '$.type')) + AND '1'||json_value(earliest(agent), '$.type') > '0'||json_value(earliest(agent), '$.type') + AND '1'||json_value(earliest(agent), '$.type') >= '0'||json_value(earliest(agent), '$.type') + AND '1'||json_value(earliest(agent), '$.type') < 2||json_value(earliest(agent), '$.type') + AND '1'||json_value(earliest(agent), '$.type') <= 2||json_value(earliest(agent), '$.type') + AND ('1'||json_value(earliest(agent), '$.type') <> '0'||json_value(earliest(agent), '$.type')) IS TRUE + AND ('1'||json_value(earliest(agent), '$.type') = '0'||json_value(earliest(agent), '$.type')) IS NOT TRUE + AND ('1'||json_value(earliest(agent), '$.type') = '0'||json_value(earliest(agent), '$.type')) IS FALSE + AND ('1'||json_value(earliest(agent), '$.type') <> '0'||json_value(earliest(agent), '$.type')) IS NOT FALSE + AND '1'||json_value(earliest(agent), '$.type') BETWEEN '0'||json_value(earliest(agent), '$.type') AND 2||json_value(earliest(agent), '$.type') + AND '1'||json_value(earliest(agent), '$.type') NOT BETWEEN '1'||json_value(earliest(agent), '$.type') AND '0'||json_value(earliest(agent), '$.type') + AND '1'||json_value(earliest(agent), '$.type') like '%' + AND '1'||json_value(earliest(agent), '$.type') not like '__DOES_NOT_EXIST__%' + AND '1'||json_value(earliest(agent), '$.type') IN ('0'||json_value(earliest(agent), '$.type'), + 1||json_value(earliest(agent), '$.type'), + 2||json_value(earliest(agent), '$.type')) + AND '1'||json_value(earliest(agent), '$.type') NOT IN ('0'||json_value(earliest(agent), '$.type'), + 2||json_value(earliest(agent), '$.type')))) ; ++-------------------------+---+ +| t | c | ++-------------------------+---+ +| 2019-08-25 00:00:00.000 | | +| 2019-08-25 01:00:00.000 | | +| 2019-08-25 02:00:00.000 | | +| 2019-08-25 03:00:00.000 | | +| 2019-08-25 04:00:00.000 | | +| 2019-08-25 05:00:00.000 | | +| 2019-08-25 06:00:00.000 | | ++-------------------------+---+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A22: earliest_by_scalar +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + '1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND ('1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') IS NULL + OR ('1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') = 1||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND '1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') IS NOT DISTINCT + FROM 1||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND '1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') <> '0'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND ('1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') IS DISTINCT + FROM '0'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00')) + AND '1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') > '0'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND '1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') >= '0'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND '1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') < 2||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND '1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') <= 2||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND ('1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') <> '0'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00')) IS TRUE + AND ('1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') = '0'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00')) IS NOT TRUE + AND ('1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') = '0'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00')) IS FALSE + AND ('1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') <> '0'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00')) IS NOT FALSE + AND '1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') BETWEEN '0'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') AND 2||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND '1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') NOT BETWEEN '1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') AND '0'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND '1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') like '%' + AND '1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') not like '__DOES_NOT_EXIST__%' + AND '1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') IN ('0'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), + 1||earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), + 2||earliest_by(client_ip, timestamp '2019-08-25 04:00:00')) + AND '1'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00') NOT IN ('0'||earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), + 2||earliest_by(client_ip, timestamp '2019-08-25 04:00:00')))) ; ++-------------------------+-----------------+ +| t | c | ++-------------------------+-----------------+ +| 2019-08-25 00:00:00.000 | 1181.13.41.82 | +| 2019-08-25 01:00:00.000 | 199.253.86.170 | +| 2019-08-25 02:00:00.000 | 1190.62.251.216 | +| 2019-08-25 03:00:00.000 | 1184.96.197.148 | +| 2019-08-25 04:00:00.000 | 1186.65.90.120 | +| 2019-08-25 05:00:00.000 | 1174.45.230.138 | +| 2019-08-25 06:00:00.000 | 149.178.15.174 | ++-------------------------+-----------------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A23: earliest_by_complex +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + '1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND ('1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') IS NULL + OR ('1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') = 1||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND '1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') IS NOT DISTINCT + FROM 1||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND '1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') <> '0'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND ('1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') IS DISTINCT + FROM '0'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type')) + AND '1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') > '0'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND '1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') >= '0'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND '1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') < 2||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND '1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') <= 2||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND ('1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') <> '0'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type')) IS TRUE + AND ('1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') = '0'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type')) IS NOT TRUE + AND ('1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') = '0'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type')) IS FALSE + AND ('1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') <> '0'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type')) IS NOT FALSE + AND '1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') BETWEEN '0'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') AND 2||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND '1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') NOT BETWEEN '1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') AND '0'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND '1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') like '%' + AND '1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') not like '__DOES_NOT_EXIST__%' + AND '1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') IN ('0'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type'), + 1||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type'), + 2||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type')) + AND '1'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') NOT IN ('0'||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type'), + 2||json_value(earliest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type')))) ; ++-------------------------+---+ +| t | c | ++-------------------------+---+ +| 2019-08-25 00:00:00.000 | | +| 2019-08-25 01:00:00.000 | | +| 2019-08-25 02:00:00.000 | | +| 2019-08-25 03:00:00.000 | | +| 2019-08-25 04:00:00.000 | | +| 2019-08-25 05:00:00.000 | | +| 2019-08-25 06:00:00.000 | | ++-------------------------+---+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A24: latest_scalar +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + '1'||latest(client_ip) c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND ('1'||latest(client_ip) IS NULL + OR ('1'||latest(client_ip) = 1||latest(client_ip) + AND '1'||latest(client_ip) IS NOT DISTINCT + FROM 1||latest(client_ip) + AND '1'||latest(client_ip) <> '0'||latest(client_ip) + AND ('1'||latest(client_ip) IS DISTINCT + FROM '0'||latest(client_ip)) + AND '1'||latest(client_ip) > '0'||latest(client_ip) + AND '1'||latest(client_ip) >= '0'||latest(client_ip) + AND '1'||latest(client_ip) < 2||latest(client_ip) + AND '1'||latest(client_ip) <= 2||latest(client_ip) + AND ('1'||latest(client_ip) <> '0'||latest(client_ip)) IS TRUE + AND ('1'||latest(client_ip) = '0'||latest(client_ip)) IS NOT TRUE + AND ('1'||latest(client_ip) = '0'||latest(client_ip)) IS FALSE + AND ('1'||latest(client_ip) <> '0'||latest(client_ip)) IS NOT FALSE + AND '1'||latest(client_ip) BETWEEN '0'||latest(client_ip) AND 2||latest(client_ip) + AND '1'||latest(client_ip) NOT BETWEEN '1'||latest(client_ip) AND '0'||latest(client_ip) + AND '1'||latest(client_ip) like '%' + AND '1'||latest(client_ip) not like '__DOES_NOT_EXIST__%' + AND '1'||latest(client_ip) IN ('0'||latest(client_ip), + 1||latest(client_ip), + 2||latest(client_ip)) + AND '1'||latest(client_ip) NOT IN ('0'||latest(client_ip), + 2||latest(client_ip)))) ; ++-------------------------+-----------------+ +| t | c | ++-------------------------+-----------------+ +| 2019-08-25 00:00:00.000 | 1162.225.88.161 | +| 2019-08-25 01:00:00.000 | 168.7.15.214 | +| 2019-08-25 02:00:00.000 | 1108.242.161.77 | +| 2019-08-25 03:00:00.000 | 147.24.19.134 | +| 2019-08-25 04:00:00.000 | 124.1.163.114 | +| 2019-08-25 05:00:00.000 | 1172.58.139.180 | +| 2019-08-25 06:00:00.000 | 192.35.126.102 | ++-------------------------+-----------------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A25: latest_complex +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + '1'||json_value(latest(agent), '$.type') c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND ('1'||json_value(latest(agent), '$.type') IS NULL + OR ('1'||json_value(latest(agent), '$.type') = 1||json_value(latest(agent), '$.type') + AND '1'||json_value(latest(agent), '$.type') IS NOT DISTINCT + FROM 1||json_value(latest(agent), '$.type') + AND '1'||json_value(latest(agent), '$.type') <> '0'||json_value(latest(agent), '$.type') + AND ('1'||json_value(latest(agent), '$.type') IS DISTINCT + FROM '0'||json_value(latest(agent), '$.type')) + AND '1'||json_value(latest(agent), '$.type') > '0'||json_value(latest(agent), '$.type') + AND '1'||json_value(latest(agent), '$.type') >= '0'||json_value(latest(agent), '$.type') + AND '1'||json_value(latest(agent), '$.type') < 2||json_value(latest(agent), '$.type') + AND '1'||json_value(latest(agent), '$.type') <= 2||json_value(latest(agent), '$.type') + AND ('1'||json_value(latest(agent), '$.type') <> '0'||json_value(latest(agent), '$.type')) IS TRUE + AND ('1'||json_value(latest(agent), '$.type') = '0'||json_value(latest(agent), '$.type')) IS NOT TRUE + AND ('1'||json_value(latest(agent), '$.type') = '0'||json_value(latest(agent), '$.type')) IS FALSE + AND ('1'||json_value(latest(agent), '$.type') <> '0'||json_value(latest(agent), '$.type')) IS NOT FALSE + AND '1'||json_value(latest(agent), '$.type') BETWEEN '0'||json_value(latest(agent), '$.type') AND 2||json_value(latest(agent), '$.type') + AND '1'||json_value(latest(agent), '$.type') NOT BETWEEN '1'||json_value(latest(agent), '$.type') AND '0'||json_value(latest(agent), '$.type') + AND '1'||json_value(latest(agent), '$.type') like '%' + AND '1'||json_value(latest(agent), '$.type') not like '__DOES_NOT_EXIST__%' + AND '1'||json_value(latest(agent), '$.type') IN ('0'||json_value(latest(agent), '$.type'), + 1||json_value(latest(agent), '$.type'), + 2||json_value(latest(agent), '$.type')) + AND '1'||json_value(latest(agent), '$.type') NOT IN ('0'||json_value(latest(agent), '$.type'), + 2||json_value(latest(agent), '$.type')))) ; ++-------------------------+---+ +| t | c | ++-------------------------+---+ +| 2019-08-25 00:00:00.000 | | +| 2019-08-25 01:00:00.000 | | +| 2019-08-25 02:00:00.000 | | +| 2019-08-25 03:00:00.000 | | +| 2019-08-25 04:00:00.000 | | +| 2019-08-25 05:00:00.000 | | +| 2019-08-25 06:00:00.000 | | ++-------------------------+---+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A26: latest_by_scalar +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + '1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND ('1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') IS NULL + OR ('1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') = 1||latest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND '1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') IS NOT DISTINCT + FROM 1||latest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND '1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') <> '0'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND ('1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') IS DISTINCT + FROM '0'||latest_by(client_ip, timestamp '2019-08-25 04:00:00')) + AND '1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') > '0'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND '1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') >= '0'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND '1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') < 2||latest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND '1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') <= 2||latest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND ('1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') <> '0'||latest_by(client_ip, timestamp '2019-08-25 04:00:00')) IS TRUE + AND ('1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') = '0'||latest_by(client_ip, timestamp '2019-08-25 04:00:00')) IS NOT TRUE + AND ('1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') = '0'||latest_by(client_ip, timestamp '2019-08-25 04:00:00')) IS FALSE + AND ('1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') <> '0'||latest_by(client_ip, timestamp '2019-08-25 04:00:00')) IS NOT FALSE + AND '1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') BETWEEN '0'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') AND 2||latest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND '1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') NOT BETWEEN '1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') AND '0'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') + AND '1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') like '%' + AND '1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') not like '__DOES_NOT_EXIST__%' + AND '1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') IN ('0'||latest_by(client_ip, timestamp '2019-08-25 04:00:00'), + 1||latest_by(client_ip, timestamp '2019-08-25 04:00:00'), + 2||latest_by(client_ip, timestamp '2019-08-25 04:00:00')) + AND '1'||latest_by(client_ip, timestamp '2019-08-25 04:00:00') NOT IN ('0'||latest_by(client_ip, timestamp '2019-08-25 04:00:00'), + 2||latest_by(client_ip, timestamp '2019-08-25 04:00:00')))) ; ++-------------------------+-----------------+ +| t | c | ++-------------------------+-----------------+ +| 2019-08-25 00:00:00.000 | 1162.225.88.161 | +| 2019-08-25 01:00:00.000 | 168.7.15.214 | +| 2019-08-25 02:00:00.000 | 1108.242.161.77 | +| 2019-08-25 03:00:00.000 | 147.24.19.134 | +| 2019-08-25 04:00:00.000 | 124.1.163.114 | +| 2019-08-25 05:00:00.000 | 1172.58.139.180 | +| 2019-08-25 06:00:00.000 | 192.35.126.102 | ++-------------------------+-----------------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A27: latest_by_complex +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + '1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND ('1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') IS NULL + OR ('1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') = 1||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND '1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') IS NOT DISTINCT + FROM 1||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND '1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') <> '0'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND ('1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') IS DISTINCT + FROM '0'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type')) + AND '1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') > '0'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND '1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') >= '0'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND '1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') < 2||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND '1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') <= 2||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND ('1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') <> '0'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type')) IS TRUE + AND ('1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') = '0'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type')) IS NOT TRUE + AND ('1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') = '0'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type')) IS FALSE + AND ('1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') <> '0'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type')) IS NOT FALSE + AND '1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') BETWEEN '0'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') AND 2||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND '1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') NOT BETWEEN '1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') AND '0'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') + AND '1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') like '%' + AND '1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') not like '__DOES_NOT_EXIST__%' + AND '1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') IN ('0'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type'), + 1||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type'), + 2||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type')) + AND '1'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type') NOT IN ('0'||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type'), + 2||json_value(latest_by(client_ip, timestamp '2019-08-25 04:00:00'), '$.type')))) ; ++-------------------------+---+ +| t | c | ++-------------------------+---+ +| 2019-08-25 00:00:00.000 | | +| 2019-08-25 01:00:00.000 | | +| 2019-08-25 02:00:00.000 | | +| 2019-08-25 03:00:00.000 | | +| 2019-08-25 04:00:00.000 | | +| 2019-08-25 05:00:00.000 | | +| 2019-08-25 06:00:00.000 | | ++-------------------------+---+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A28: any_value_scalar +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + '1'||any_value(client_ip) c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND ('1'||any_value(client_ip) IS NULL + OR ('1'||any_value(client_ip) = 1||any_value(client_ip) + AND '1'||any_value(client_ip) IS NOT DISTINCT + FROM 1||any_value(client_ip) + AND '1'||any_value(client_ip) <> '0'||any_value(client_ip) + AND ('1'||any_value(client_ip) IS DISTINCT + FROM '0'||any_value(client_ip)) + AND '1'||any_value(client_ip) > '0'||any_value(client_ip) + AND '1'||any_value(client_ip) >= '0'||any_value(client_ip) + AND '1'||any_value(client_ip) < 2||any_value(client_ip) + AND '1'||any_value(client_ip) <= 2||any_value(client_ip) + AND ('1'||any_value(client_ip) <> '0'||any_value(client_ip)) IS TRUE + AND ('1'||any_value(client_ip) = '0'||any_value(client_ip)) IS NOT TRUE + AND ('1'||any_value(client_ip) = '0'||any_value(client_ip)) IS FALSE + AND ('1'||any_value(client_ip) <> '0'||any_value(client_ip)) IS NOT FALSE + AND '1'||any_value(client_ip) BETWEEN '0'||any_value(client_ip) AND 2||any_value(client_ip) + AND '1'||any_value(client_ip) NOT BETWEEN '1'||any_value(client_ip) AND '0'||any_value(client_ip) + AND '1'||any_value(client_ip) like '%' + AND '1'||any_value(client_ip) not like '__DOES_NOT_EXIST__%' + AND '1'||any_value(client_ip) IN ('0'||any_value(client_ip), + 1||any_value(client_ip), + 2||any_value(client_ip)) + AND '1'||any_value(client_ip) NOT IN ('0'||any_value(client_ip), + 2||any_value(client_ip)))) ; ++-------------------------+-----------------+ +| t | c | ++-------------------------+-----------------+ +| 2019-08-25 00:00:00.000 | 1181.13.41.82 | +| 2019-08-25 01:00:00.000 | 199.253.86.170 | +| 2019-08-25 02:00:00.000 | 1190.62.251.216 | +| 2019-08-25 03:00:00.000 | 1184.96.197.148 | +| 2019-08-25 04:00:00.000 | 1186.65.90.120 | +| 2019-08-25 05:00:00.000 | 1174.45.230.138 | +| 2019-08-25 06:00:00.000 | 149.178.15.174 | ++-------------------------+-----------------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A29: any_value_complex +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + '1'||json_value(any_value(agent), '$.type') c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND ('1'||json_value(any_value(agent), '$.type') IS NULL + OR ('1'||json_value(any_value(agent), '$.type') = 1||json_value(any_value(agent), '$.type') + AND '1'||json_value(any_value(agent), '$.type') IS NOT DISTINCT + FROM 1||json_value(any_value(agent), '$.type') + AND '1'||json_value(any_value(agent), '$.type') <> '0'||json_value(any_value(agent), '$.type') + AND ('1'||json_value(any_value(agent), '$.type') IS DISTINCT + FROM '0'||json_value(any_value(agent), '$.type')) + AND '1'||json_value(any_value(agent), '$.type') > '0'||json_value(any_value(agent), '$.type') + AND '1'||json_value(any_value(agent), '$.type') >= '0'||json_value(any_value(agent), '$.type') + AND '1'||json_value(any_value(agent), '$.type') < 2||json_value(any_value(agent), '$.type') + AND '1'||json_value(any_value(agent), '$.type') <= 2||json_value(any_value(agent), '$.type') + AND ('1'||json_value(any_value(agent), '$.type') <> '0'||json_value(any_value(agent), '$.type')) IS TRUE + AND ('1'||json_value(any_value(agent), '$.type') = '0'||json_value(any_value(agent), '$.type')) IS NOT TRUE + AND ('1'||json_value(any_value(agent), '$.type') = '0'||json_value(any_value(agent), '$.type')) IS FALSE + AND ('1'||json_value(any_value(agent), '$.type') <> '0'||json_value(any_value(agent), '$.type')) IS NOT FALSE + AND '1'||json_value(any_value(agent), '$.type') BETWEEN '0'||json_value(any_value(agent), '$.type') AND 2||json_value(any_value(agent), '$.type') + AND '1'||json_value(any_value(agent), '$.type') NOT BETWEEN '1'||json_value(any_value(agent), '$.type') AND '0'||json_value(any_value(agent), '$.type') + AND '1'||json_value(any_value(agent), '$.type') like '%' + AND '1'||json_value(any_value(agent), '$.type') not like '__DOES_NOT_EXIST__%' + AND '1'||json_value(any_value(agent), '$.type') IN ('0'||json_value(any_value(agent), '$.type'), + 1||json_value(any_value(agent), '$.type'), + 2||json_value(any_value(agent), '$.type')) + AND '1'||json_value(any_value(agent), '$.type') NOT IN ('0'||json_value(any_value(agent), '$.type'), + 2||json_value(any_value(agent), '$.type')))) ; ++-------------------------+---+ +| t | c | ++-------------------------+---+ +| 2019-08-25 00:00:00.000 | | +| 2019-08-25 01:00:00.000 | | +| 2019-08-25 02:00:00.000 | | +| 2019-08-25 03:00:00.000 | | +| 2019-08-25 04:00:00.000 | | +| 2019-08-25 05:00:00.000 | | +| 2019-08-25 06:00:00.000 | | ++-------------------------+---+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A39: bit_and +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + bit_and(session_length) c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND (bit_and(session_length) IS NULL + OR (bit_and(session_length) = bit_and(session_length)+0 + AND bit_and(session_length) IS NOT DISTINCT + FROM bit_and(session_length)+0 + AND bit_and(session_length) <> bit_and(session_length)-1 + AND (bit_and(session_length) IS DISTINCT + FROM bit_and(session_length)-1) + AND bit_and(session_length) > bit_and(session_length)-1 + AND bit_and(session_length) >= bit_and(session_length)-1 + AND bit_and(session_length) < bit_and(session_length)+1 + AND bit_and(session_length) <= bit_and(session_length)+1 + AND (bit_and(session_length) <> bit_and(session_length)-1) IS TRUE + AND (bit_and(session_length) = bit_and(session_length)-1) IS NOT TRUE + AND (bit_and(session_length) = bit_and(session_length)-1) IS FALSE + AND (bit_and(session_length) <> bit_and(session_length)-1) IS NOT FALSE + AND bit_and(session_length) BETWEEN bit_and(session_length)-1 AND bit_and(session_length)+1 + AND bit_and(session_length) NOT BETWEEN bit_and(session_length) AND bit_and(session_length)-1 + AND bit_and(session_length) like '%' + AND bit_and(session_length) not like '__DOES_NOT_EXIST__%' + AND bit_and(session_length) IN (bit_and(session_length)-1, + bit_and(session_length)+0, + bit_and(session_length)+1) + AND bit_and(session_length) NOT IN (bit_and(session_length)-1, + bit_and(session_length)+1))) ; ++-------------------------+---+ +| t | c | ++-------------------------+---+ +| 2019-08-25 00:00:00.000 | 0 | +| 2019-08-25 01:00:00.000 | 0 | +| 2019-08-25 02:00:00.000 | 0 | +| 2019-08-25 03:00:00.000 | 0 | +| 2019-08-25 04:00:00.000 | 0 | +| 2019-08-25 05:00:00.000 | 0 | +| 2019-08-25 06:00:00.000 | 0 | ++-------------------------+---+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A40: bit_or +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + bit_or(session_length) c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND (bit_or(session_length) IS NULL + OR (bit_or(session_length) = bit_or(session_length)+0 + AND bit_or(session_length) IS NOT DISTINCT + FROM bit_or(session_length)+0 + AND bit_or(session_length) <> bit_or(session_length)-1 + AND (bit_or(session_length) IS DISTINCT + FROM bit_or(session_length)-1) + AND bit_or(session_length) > bit_or(session_length)-1 + AND bit_or(session_length) >= bit_or(session_length)-1 + AND bit_or(session_length) < bit_or(session_length)+1 + AND bit_or(session_length) <= bit_or(session_length)+1 + AND (bit_or(session_length) <> bit_or(session_length)-1) IS TRUE + AND (bit_or(session_length) = bit_or(session_length)-1) IS NOT TRUE + AND (bit_or(session_length) = bit_or(session_length)-1) IS FALSE + AND (bit_or(session_length) <> bit_or(session_length)-1) IS NOT FALSE + AND bit_or(session_length) BETWEEN bit_or(session_length)-1 AND bit_or(session_length)+1 + AND bit_or(session_length) NOT BETWEEN bit_or(session_length) AND bit_or(session_length)-1 + AND bit_or(session_length) like '%' + AND bit_or(session_length) not like '__DOES_NOT_EXIST__%' + AND bit_or(session_length) IN (bit_or(session_length)-1, + bit_or(session_length)+0, + bit_or(session_length)+1) + AND bit_or(session_length) NOT IN (bit_or(session_length)-1, + bit_or(session_length)+1))) ; ++-------------------------+-----------+ +| t | c | ++-------------------------+-----------+ +| 2019-08-25 00:00:00.000 | 268435455 | +| 2019-08-25 01:00:00.000 | 100663295 | +| 2019-08-25 02:00:00.000 | 134217727 | +| 2019-08-25 03:00:00.000 | 201326591 | +| 2019-08-25 04:00:00.000 | 201326591 | +| 2019-08-25 05:00:00.000 | 805306367 | +| 2019-08-25 06:00:00.000 | 704643071 | ++-------------------------+-----------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A41: bit_xor +#------------------------------------------------------------------------- +SELECT time_floor(__time, 'PT1H') t, + bit_xor(session_length) c +FROM kttm_nested +GROUP BY 1 +HAVING time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' +AND (bit_xor(session_length) IS NULL + OR (bit_xor(session_length) = bit_xor(session_length)+0 + AND bit_xor(session_length) IS NOT DISTINCT + FROM bit_xor(session_length)+0 + AND bit_xor(session_length) <> bit_xor(session_length)-1 + AND (bit_xor(session_length) IS DISTINCT + FROM bit_xor(session_length)-1) + AND bit_xor(session_length) > bit_xor(session_length)-1 + AND bit_xor(session_length) >= bit_xor(session_length)-1 + AND bit_xor(session_length) < bit_xor(session_length)+1 + AND bit_xor(session_length) <= bit_xor(session_length)+1 + AND (bit_xor(session_length) <> bit_xor(session_length)-1) IS TRUE + AND (bit_xor(session_length) = bit_xor(session_length)-1) IS NOT TRUE + AND (bit_xor(session_length) = bit_xor(session_length)-1) IS FALSE + AND (bit_xor(session_length) <> bit_xor(session_length)-1) IS NOT FALSE + AND bit_xor(session_length) BETWEEN bit_xor(session_length)-1 AND bit_xor(session_length)+1 + AND bit_xor(session_length) NOT BETWEEN bit_xor(session_length) AND bit_xor(session_length)-1 + AND bit_xor(session_length) like '%' + AND bit_xor(session_length) not like '__DOES_NOT_EXIST__%' + AND bit_xor(session_length) IN (bit_xor(session_length)-1, + bit_xor(session_length)+0, + bit_xor(session_length)+1) + AND bit_xor(session_length) NOT IN (bit_xor(session_length)-1, + bit_xor(session_length)+1))) ; ++-------------------------+-----------+ +| t | c | ++-------------------------+-----------+ +| 2019-08-25 00:00:00.000 | 234315927 | +| 2019-08-25 01:00:00.000 | 95944477 | +| 2019-08-25 02:00:00.000 | 111843809 | +| 2019-08-25 03:00:00.000 | 177632213 | +| 2019-08-25 04:00:00.000 | 163411073 | +| 2019-08-25 05:00:00.000 | 775476257 | +| 2019-08-25 06:00:00.000 | 695627807 | ++-------------------------+-----------+ +(7 rows) + +!ok + +#------------------------------------------------------------------------- +# Total query count 25 +#------------------------------------------------------------------------- diff --git a/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_array.iq b/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_array.iq new file mode 100644 index 00000000000..ef42b66ae9b --- /dev/null +++ b/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_array.iq @@ -0,0 +1,2848 @@ +!set useApproximateCountDistinct false +!use druidtest:///?componentSupplier=KttmNestedComponentSupplier +!set outputformat mysql +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00'; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A1: array +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', mv_to_array("language")) IS NULL + OR (array_prepend('1', mv_to_array("language")) = array_prepend('1', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) IS NOT DISTINCT + FROM array_prepend('1', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) <> array_prepend('0', mv_to_array("language")) + AND (array_prepend('1', mv_to_array("language")) IS DISTINCT + FROM array_prepend('0', mv_to_array("language"))) + AND array_prepend('1', mv_to_array("language")) > array_prepend('0', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) >= array_prepend('0', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) < array_prepend('2', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) <= array_prepend('2', mv_to_array("language")) + AND (array_prepend('1', mv_to_array("language")) <> array_prepend('0', mv_to_array("language"))) IS TRUE + AND (array_prepend('1', mv_to_array("language")) = array_prepend('0', mv_to_array("language"))) IS NOT TRUE + AND (array_prepend('1', mv_to_array("language")) = array_prepend('0', mv_to_array("language"))) IS FALSE + AND (array_prepend('1', mv_to_array("language")) <> array_prepend('0', mv_to_array("language"))) IS NOT FALSE + AND array_prepend('1', mv_to_array("language")) BETWEEN array_prepend('0', mv_to_array("language")) AND array_prepend('2', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) NOT BETWEEN array_prepend('1', mv_to_array("language")) AND array_prepend('0', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) IN (array_prepend('0', mv_to_array("language")), + array_prepend('1', mv_to_array("language")), + array_prepend('2', mv_to_array("language"))) + AND array_prepend('1', mv_to_array("language")) NOT IN (array_prepend('0', mv_to_array("language")), + array_prepend('2', mv_to_array("language"))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + array_prepend('1', mv_to_array("language")), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', mv_to_array("language")) IS NULL + OR (array_prepend('1', mv_to_array("language")) = array_prepend('1', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) IS NOT DISTINCT + FROM array_prepend('1', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) <> array_prepend('0', mv_to_array("language")) + AND (array_prepend('1', mv_to_array("language")) IS DISTINCT + FROM array_prepend('0', mv_to_array("language"))) + AND array_prepend('1', mv_to_array("language")) > array_prepend('0', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) >= array_prepend('0', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) < array_prepend('2', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) <= array_prepend('2', mv_to_array("language")) + AND (array_prepend('1', mv_to_array("language")) <> array_prepend('0', mv_to_array("language"))) IS TRUE + AND (array_prepend('1', mv_to_array("language")) = array_prepend('0', mv_to_array("language"))) IS NOT TRUE + AND (array_prepend('1', mv_to_array("language")) = array_prepend('0', mv_to_array("language"))) IS FALSE + AND (array_prepend('1', mv_to_array("language")) <> array_prepend('0', mv_to_array("language"))) IS NOT FALSE + AND array_prepend('1', mv_to_array("language")) BETWEEN array_prepend('0', mv_to_array("language")) AND array_prepend('2', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) NOT BETWEEN array_prepend('1', mv_to_array("language")) AND array_prepend('0', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) IN (array_prepend('0', mv_to_array("language")), + array_prepend('1', mv_to_array("language")), + array_prepend('2', mv_to_array("language"))) + AND array_prepend('1', mv_to_array("language")) NOT IN (array_prepend('0', mv_to_array("language")), + array_prepend('2', mv_to_array("language"))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A2: array_length +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_length(mv_to_array("language")) IS NULL + OR (array_length(mv_to_array("language")) = array_length(mv_to_array("language"))+0 + AND array_length(mv_to_array("language")) IS NOT DISTINCT + FROM array_length(mv_to_array("language"))+0 + AND array_length(mv_to_array("language")) <> array_length(mv_to_array("language"))-1 + AND (array_length(mv_to_array("language")) IS DISTINCT + FROM array_length(mv_to_array("language"))-1) + AND array_length(mv_to_array("language")) > array_length(mv_to_array("language"))-1 + AND array_length(mv_to_array("language")) >= array_length(mv_to_array("language"))-1 + AND array_length(mv_to_array("language")) < array_length(mv_to_array("language"))+1 + AND array_length(mv_to_array("language")) <= array_length(mv_to_array("language"))+1 + AND (array_length(mv_to_array("language")) <> array_length(mv_to_array("language"))-1) IS TRUE + AND (array_length(mv_to_array("language")) = array_length(mv_to_array("language"))-1) IS NOT TRUE + AND (array_length(mv_to_array("language")) = array_length(mv_to_array("language"))-1) IS FALSE + AND (array_length(mv_to_array("language")) <> array_length(mv_to_array("language"))-1) IS NOT FALSE + AND array_length(mv_to_array("language")) BETWEEN array_length(mv_to_array("language"))-1 AND array_length(mv_to_array("language"))+1 + AND array_length(mv_to_array("language")) NOT BETWEEN array_length(mv_to_array("language")) AND array_length(mv_to_array("language"))-1 + AND array_length(mv_to_array("language")) like '%' + AND array_length(mv_to_array("language")) not like '__DOES_NOT_EXIST__%' + AND array_length(mv_to_array("language")) IN (array_length(mv_to_array("language"))-1, + array_length(mv_to_array("language"))+0, + array_length(mv_to_array("language"))+1) + AND array_length(mv_to_array("language")) NOT IN (array_length(mv_to_array("language"))-1, + array_length(mv_to_array("language"))+1))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_length(mv_to_array("language")) IS NULL + OR array_length(mv_to_array("language")) IN + (SELECT array_length(mv_to_array("language")) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_length(mv_to_array("language")) IS NULL + OR (array_length(mv_to_array("language")) = array_length(mv_to_array("language"))+0 + AND array_length(mv_to_array("language")) IS NOT DISTINCT + FROM array_length(mv_to_array("language"))+0 + AND array_length(mv_to_array("language")) <> array_length(mv_to_array("language"))-1 + AND (array_length(mv_to_array("language")) IS DISTINCT + FROM array_length(mv_to_array("language"))-1) + AND array_length(mv_to_array("language")) > array_length(mv_to_array("language"))-1 + AND array_length(mv_to_array("language")) >= array_length(mv_to_array("language"))-1 + AND array_length(mv_to_array("language")) < array_length(mv_to_array("language"))+1 + AND array_length(mv_to_array("language")) <= array_length(mv_to_array("language"))+1 + AND (array_length(mv_to_array("language")) <> array_length(mv_to_array("language"))-1) IS TRUE + AND (array_length(mv_to_array("language")) = array_length(mv_to_array("language"))-1) IS NOT TRUE + AND (array_length(mv_to_array("language")) = array_length(mv_to_array("language"))-1) IS FALSE + AND (array_length(mv_to_array("language")) <> array_length(mv_to_array("language"))-1) IS NOT FALSE + AND array_length(mv_to_array("language")) BETWEEN array_length(mv_to_array("language"))-1 AND array_length(mv_to_array("language"))+1 + AND array_length(mv_to_array("language")) NOT BETWEEN array_length(mv_to_array("language")) AND array_length(mv_to_array("language"))-1 + AND array_length(mv_to_array("language")) like '%' + AND array_length(mv_to_array("language")) not like '__DOES_NOT_EXIST__%' + AND array_length(mv_to_array("language")) IN (array_length(mv_to_array("language"))-1, + array_length(mv_to_array("language"))+0, + array_length(mv_to_array("language"))+1) + AND array_length(mv_to_array("language")) NOT IN (array_length(mv_to_array("language"))-1, + array_length(mv_to_array("language"))+1))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + array_length(mv_to_array("language")), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_length(mv_to_array("language")) IS NULL + OR (array_length(mv_to_array("language")) = array_length(mv_to_array("language"))+0 + AND array_length(mv_to_array("language")) IS NOT DISTINCT + FROM array_length(mv_to_array("language"))+0 + AND array_length(mv_to_array("language")) <> array_length(mv_to_array("language"))-1 + AND (array_length(mv_to_array("language")) IS DISTINCT + FROM array_length(mv_to_array("language"))-1) + AND array_length(mv_to_array("language")) > array_length(mv_to_array("language"))-1 + AND array_length(mv_to_array("language")) >= array_length(mv_to_array("language"))-1 + AND array_length(mv_to_array("language")) < array_length(mv_to_array("language"))+1 + AND array_length(mv_to_array("language")) <= array_length(mv_to_array("language"))+1 + AND (array_length(mv_to_array("language")) <> array_length(mv_to_array("language"))-1) IS TRUE + AND (array_length(mv_to_array("language")) = array_length(mv_to_array("language"))-1) IS NOT TRUE + AND (array_length(mv_to_array("language")) = array_length(mv_to_array("language"))-1) IS FALSE + AND (array_length(mv_to_array("language")) <> array_length(mv_to_array("language"))-1) IS NOT FALSE + AND array_length(mv_to_array("language")) BETWEEN array_length(mv_to_array("language"))-1 AND array_length(mv_to_array("language"))+1 + AND array_length(mv_to_array("language")) NOT BETWEEN array_length(mv_to_array("language")) AND array_length(mv_to_array("language"))-1 + AND array_length(mv_to_array("language")) like '%' + AND array_length(mv_to_array("language")) not like '__DOES_NOT_EXIST__%' + AND array_length(mv_to_array("language")) IN (array_length(mv_to_array("language"))-1, + array_length(mv_to_array("language"))+0, + array_length(mv_to_array("language"))+1) + AND array_length(mv_to_array("language")) NOT IN (array_length(mv_to_array("language"))-1, + array_length(mv_to_array("language"))+1))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A3: array_offset +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_offset(mv_to_array("language"), 0) IS NULL + OR ('1'||array_offset(mv_to_array("language"), 0) = 1||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) IS NOT DISTINCT + FROM 1||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0) + AND ('1'||array_offset(mv_to_array("language"), 0) IS DISTINCT + FROM 0||array_offset(mv_to_array("language"), 0)) + AND '1'||array_offset(mv_to_array("language"), 0) > 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) >= 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) < 2||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) <= 2||array_offset(mv_to_array("language"), 0) + AND ('1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0)) IS TRUE + AND ('1'||array_offset(mv_to_array("language"), 0) = 0||array_offset(mv_to_array("language"), 0)) IS NOT TRUE + AND ('1'||array_offset(mv_to_array("language"), 0) = 0||array_offset(mv_to_array("language"), 0)) IS FALSE + AND ('1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0)) IS NOT FALSE + AND '1'||array_offset(mv_to_array("language"), 0) BETWEEN 0||array_offset(mv_to_array("language"), 0) AND 2||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) NOT BETWEEN '1'||array_offset(mv_to_array("language"), 0) AND 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) like '%' + AND '1'||array_offset(mv_to_array("language"), 0) not like '__DOES_NOT_EXIST__%' + AND '1'||array_offset(mv_to_array("language"), 0) IN (0||array_offset(mv_to_array("language"), 0), + 1||array_offset(mv_to_array("language"), 0), + 2||array_offset(mv_to_array("language"), 0)) + AND '1'||array_offset(mv_to_array("language"), 0) NOT IN (0||array_offset(mv_to_array("language"), 0), + 2||array_offset(mv_to_array("language"), 0)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_offset(mv_to_array("language"), 0) IS NULL + OR '1'||array_offset(mv_to_array("language"), 0) IN + (SELECT '1'||array_offset(mv_to_array("language"), 0) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_offset(mv_to_array("language"), 0) IS NULL + OR ('1'||array_offset(mv_to_array("language"), 0) = 1||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) IS NOT DISTINCT + FROM 1||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0) + AND ('1'||array_offset(mv_to_array("language"), 0) IS DISTINCT + FROM 0||array_offset(mv_to_array("language"), 0)) + AND '1'||array_offset(mv_to_array("language"), 0) > 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) >= 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) < 2||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) <= 2||array_offset(mv_to_array("language"), 0) + AND ('1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0)) IS TRUE + AND ('1'||array_offset(mv_to_array("language"), 0) = 0||array_offset(mv_to_array("language"), 0)) IS NOT TRUE + AND ('1'||array_offset(mv_to_array("language"), 0) = 0||array_offset(mv_to_array("language"), 0)) IS FALSE + AND ('1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0)) IS NOT FALSE + AND '1'||array_offset(mv_to_array("language"), 0) BETWEEN 0||array_offset(mv_to_array("language"), 0) AND 2||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) NOT BETWEEN '1'||array_offset(mv_to_array("language"), 0) AND 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) like '%' + AND '1'||array_offset(mv_to_array("language"), 0) not like '__DOES_NOT_EXIST__%' + AND '1'||array_offset(mv_to_array("language"), 0) IN (0||array_offset(mv_to_array("language"), 0), + 1||array_offset(mv_to_array("language"), 0), + 2||array_offset(mv_to_array("language"), 0)) + AND '1'||array_offset(mv_to_array("language"), 0) NOT IN (0||array_offset(mv_to_array("language"), 0), + 2||array_offset(mv_to_array("language"), 0)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||array_offset(mv_to_array("language"), 0), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_offset(mv_to_array("language"), 0) IS NULL + OR ('1'||array_offset(mv_to_array("language"), 0) = 1||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) IS NOT DISTINCT + FROM 1||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0) + AND ('1'||array_offset(mv_to_array("language"), 0) IS DISTINCT + FROM 0||array_offset(mv_to_array("language"), 0)) + AND '1'||array_offset(mv_to_array("language"), 0) > 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) >= 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) < 2||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) <= 2||array_offset(mv_to_array("language"), 0) + AND ('1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0)) IS TRUE + AND ('1'||array_offset(mv_to_array("language"), 0) = 0||array_offset(mv_to_array("language"), 0)) IS NOT TRUE + AND ('1'||array_offset(mv_to_array("language"), 0) = 0||array_offset(mv_to_array("language"), 0)) IS FALSE + AND ('1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0)) IS NOT FALSE + AND '1'||array_offset(mv_to_array("language"), 0) BETWEEN 0||array_offset(mv_to_array("language"), 0) AND 2||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) NOT BETWEEN '1'||array_offset(mv_to_array("language"), 0) AND 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) like '%' + AND '1'||array_offset(mv_to_array("language"), 0) not like '__DOES_NOT_EXIST__%' + AND '1'||array_offset(mv_to_array("language"), 0) IN (0||array_offset(mv_to_array("language"), 0), + 1||array_offset(mv_to_array("language"), 0), + 2||array_offset(mv_to_array("language"), 0)) + AND '1'||array_offset(mv_to_array("language"), 0) NOT IN (0||array_offset(mv_to_array("language"), 0), + 2||array_offset(mv_to_array("language"), 0)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A4: array_ordinal +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_ordinal(mv_to_array("language"), 1) IS NULL + OR ('1'||array_ordinal(mv_to_array("language"), 1) = 1||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) IS NOT DISTINCT + FROM 1||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) <> 0||array_ordinal(mv_to_array("language"), 1) + AND ('1'||array_ordinal(mv_to_array("language"), 1) IS DISTINCT + FROM 0||array_ordinal(mv_to_array("language"), 1)) + AND '1'||array_ordinal(mv_to_array("language"), 1) > 0||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) >= 0||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) < 2||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) <= 2||array_ordinal(mv_to_array("language"), 1) + AND ('1'||array_ordinal(mv_to_array("language"), 1) <> 0||array_ordinal(mv_to_array("language"), 1)) IS TRUE + AND ('1'||array_ordinal(mv_to_array("language"), 1) = 0||array_ordinal(mv_to_array("language"), 1)) IS NOT TRUE + AND ('1'||array_ordinal(mv_to_array("language"), 1) = 0||array_ordinal(mv_to_array("language"), 1)) IS FALSE + AND ('1'||array_ordinal(mv_to_array("language"), 1) <> 0||array_ordinal(mv_to_array("language"), 1)) IS NOT FALSE + AND '1'||array_ordinal(mv_to_array("language"), 1) BETWEEN 0||array_ordinal(mv_to_array("language"), 1) AND 2||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) NOT BETWEEN '1'||array_ordinal(mv_to_array("language"), 1) AND 0||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) like '%' + AND '1'||array_ordinal(mv_to_array("language"), 1) not like '__DOES_NOT_EXIST__%' + AND '1'||array_ordinal(mv_to_array("language"), 1) IN (0||array_ordinal(mv_to_array("language"), 1), + 1||array_ordinal(mv_to_array("language"), 1), + 2||array_ordinal(mv_to_array("language"), 1)) + AND '1'||array_ordinal(mv_to_array("language"), 1) NOT IN (0||array_ordinal(mv_to_array("language"), 1), + 2||array_ordinal(mv_to_array("language"), 1)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_ordinal(mv_to_array("language"), 1) IS NULL + OR '1'||array_ordinal(mv_to_array("language"), 1) IN + (SELECT '1'||array_ordinal(mv_to_array("language"), 1) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_ordinal(mv_to_array("language"), 1) IS NULL + OR ('1'||array_ordinal(mv_to_array("language"), 1) = 1||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) IS NOT DISTINCT + FROM 1||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) <> 0||array_ordinal(mv_to_array("language"), 1) + AND ('1'||array_ordinal(mv_to_array("language"), 1) IS DISTINCT + FROM 0||array_ordinal(mv_to_array("language"), 1)) + AND '1'||array_ordinal(mv_to_array("language"), 1) > 0||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) >= 0||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) < 2||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) <= 2||array_ordinal(mv_to_array("language"), 1) + AND ('1'||array_ordinal(mv_to_array("language"), 1) <> 0||array_ordinal(mv_to_array("language"), 1)) IS TRUE + AND ('1'||array_ordinal(mv_to_array("language"), 1) = 0||array_ordinal(mv_to_array("language"), 1)) IS NOT TRUE + AND ('1'||array_ordinal(mv_to_array("language"), 1) = 0||array_ordinal(mv_to_array("language"), 1)) IS FALSE + AND ('1'||array_ordinal(mv_to_array("language"), 1) <> 0||array_ordinal(mv_to_array("language"), 1)) IS NOT FALSE + AND '1'||array_ordinal(mv_to_array("language"), 1) BETWEEN 0||array_ordinal(mv_to_array("language"), 1) AND 2||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) NOT BETWEEN '1'||array_ordinal(mv_to_array("language"), 1) AND 0||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) like '%' + AND '1'||array_ordinal(mv_to_array("language"), 1) not like '__DOES_NOT_EXIST__%' + AND '1'||array_ordinal(mv_to_array("language"), 1) IN (0||array_ordinal(mv_to_array("language"), 1), + 1||array_ordinal(mv_to_array("language"), 1), + 2||array_ordinal(mv_to_array("language"), 1)) + AND '1'||array_ordinal(mv_to_array("language"), 1) NOT IN (0||array_ordinal(mv_to_array("language"), 1), + 2||array_ordinal(mv_to_array("language"), 1)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||array_ordinal(mv_to_array("language"), 1), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_ordinal(mv_to_array("language"), 1) IS NULL + OR ('1'||array_ordinal(mv_to_array("language"), 1) = 1||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) IS NOT DISTINCT + FROM 1||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) <> 0||array_ordinal(mv_to_array("language"), 1) + AND ('1'||array_ordinal(mv_to_array("language"), 1) IS DISTINCT + FROM 0||array_ordinal(mv_to_array("language"), 1)) + AND '1'||array_ordinal(mv_to_array("language"), 1) > 0||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) >= 0||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) < 2||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) <= 2||array_ordinal(mv_to_array("language"), 1) + AND ('1'||array_ordinal(mv_to_array("language"), 1) <> 0||array_ordinal(mv_to_array("language"), 1)) IS TRUE + AND ('1'||array_ordinal(mv_to_array("language"), 1) = 0||array_ordinal(mv_to_array("language"), 1)) IS NOT TRUE + AND ('1'||array_ordinal(mv_to_array("language"), 1) = 0||array_ordinal(mv_to_array("language"), 1)) IS FALSE + AND ('1'||array_ordinal(mv_to_array("language"), 1) <> 0||array_ordinal(mv_to_array("language"), 1)) IS NOT FALSE + AND '1'||array_ordinal(mv_to_array("language"), 1) BETWEEN 0||array_ordinal(mv_to_array("language"), 1) AND 2||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) NOT BETWEEN '1'||array_ordinal(mv_to_array("language"), 1) AND 0||array_ordinal(mv_to_array("language"), 1) + AND '1'||array_ordinal(mv_to_array("language"), 1) like '%' + AND '1'||array_ordinal(mv_to_array("language"), 1) not like '__DOES_NOT_EXIST__%' + AND '1'||array_ordinal(mv_to_array("language"), 1) IN (0||array_ordinal(mv_to_array("language"), 1), + 1||array_ordinal(mv_to_array("language"), 1), + 2||array_ordinal(mv_to_array("language"), 1)) + AND '1'||array_ordinal(mv_to_array("language"), 1) NOT IN (0||array_ordinal(mv_to_array("language"), 1), + 2||array_ordinal(mv_to_array("language"), 1)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A5: array_contains +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS NULL + OR (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS NOT DISTINCT + FROM CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS DISTINCT + FROM CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END > CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END >= CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END < CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <= CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS TRUE + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT TRUE + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS FALSE + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT FALSE + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END BETWEEN CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END NOT BETWEEN CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END like '%' + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IN (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END, + CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END) + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END NOT IN (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS NULL + OR CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IN + (SELECT CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS NULL + OR (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS NOT DISTINCT + FROM CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS DISTINCT + FROM CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END > CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END >= CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END < CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <= CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS TRUE + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT TRUE + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS FALSE + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT FALSE + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END BETWEEN CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END NOT BETWEEN CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END like '%' + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IN (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END, + CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END) + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END NOT IN (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END, + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS NULL + OR (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS NOT DISTINCT + FROM CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS DISTINCT + FROM CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END > CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END >= CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END < CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <= CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS TRUE + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT TRUE + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS FALSE + AND (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT FALSE + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END BETWEEN CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END NOT BETWEEN CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END like '%' + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IN (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END, + CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END) + AND CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END NOT IN (CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN array_contains(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A6: array_overlap +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS NULL + OR (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS NOT DISTINCT + FROM CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS DISTINCT + FROM CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END > CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END >= CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END < CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <= CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS TRUE + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT TRUE + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS FALSE + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT FALSE + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END BETWEEN CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END NOT BETWEEN CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END like '%' + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IN (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END, + CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END) + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END NOT IN (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS NULL + OR CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IN + (SELECT CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS NULL + OR (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS NOT DISTINCT + FROM CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS DISTINCT + FROM CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END > CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END >= CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END < CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <= CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS TRUE + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT TRUE + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS FALSE + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT FALSE + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END BETWEEN CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END NOT BETWEEN CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END like '%' + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IN (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END, + CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END) + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END NOT IN (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END, + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS NULL + OR (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS NOT DISTINCT + FROM CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IS DISTINCT + FROM CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END > CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END >= CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END < CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <= CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS TRUE + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT TRUE + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS FALSE + AND (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT FALSE + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END BETWEEN CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END NOT BETWEEN CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END like '%' + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END IN (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END, + CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END) + AND CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 1 + ELSE 1 + END NOT IN (CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN array_overlap(mv_to_array("language"), mv_to_array("language")) THEN 3 + ELSE 2 + END))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A7: scalar_in_array +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END IS NULL + OR (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END IS NOT DISTINCT + FROM CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END IS DISTINCT + FROM CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END > CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END >= CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END < CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END <= CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) IS TRUE + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT TRUE + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) IS FALSE + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT FALSE + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END BETWEEN CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END NOT BETWEEN CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END like '%' + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END IN (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END, + CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END) + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END NOT IN (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END IS NULL + OR CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END IN + (SELECT CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END IS NULL + OR (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END IS NOT DISTINCT + FROM CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END IS DISTINCT + FROM CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END > CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END >= CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END < CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END <= CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) IS TRUE + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT TRUE + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) IS FALSE + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT FALSE + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END BETWEEN CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END NOT BETWEEN CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END like '%' + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END IN (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END, + CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END) + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END NOT IN (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END, + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END IS NULL + OR (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END IS NOT DISTINCT + FROM CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END IS DISTINCT + FROM CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END > CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END >= CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END < CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END <= CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) IS TRUE + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT TRUE + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END = CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) IS FALSE + AND (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END <> CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END) IS NOT FALSE + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END BETWEEN CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END NOT BETWEEN CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END like '%' + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END IN (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END, + CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END) + AND CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 1 + ELSE 1 + END NOT IN (CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 0 + ELSE 0 + END, + CASE + WHEN scalar_in_array('en-US', mv_to_array("language")) THEN 3 + ELSE 2 + END))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A8: array_offset_of +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) IS NULL + OR (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) = array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+0 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) IS NOT DISTINCT + FROM array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+0 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) <> array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) IS DISTINCT + FROM array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) > array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) >= array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) < array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) <= array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1 + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) <> array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) IS TRUE + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) = array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) IS NOT TRUE + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) = array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) IS FALSE + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) <> array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) IS NOT FALSE + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) BETWEEN array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) NOT BETWEEN array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) like '%' + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) not like '__DOES_NOT_EXIST__%' + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) IN (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1, + array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+0, + array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1) + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) NOT IN (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1, + array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) IS NULL + OR array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) IN + (SELECT array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) IS NULL + OR (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) = array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+0 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) IS NOT DISTINCT + FROM array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+0 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) <> array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) IS DISTINCT + FROM array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) > array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) >= array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) < array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) <= array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1 + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) <> array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) IS TRUE + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) = array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) IS NOT TRUE + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) = array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) IS FALSE + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) <> array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) IS NOT FALSE + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) BETWEEN array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) NOT BETWEEN array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) like '%' + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) not like '__DOES_NOT_EXIST__%' + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) IN (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1, + array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+0, + array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1) + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) NOT IN (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1, + array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) IS NULL + OR (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) = array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+0 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) IS NOT DISTINCT + FROM array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+0 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) <> array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) IS DISTINCT + FROM array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) > array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) >= array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) < array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) <= array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1 + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) <> array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) IS TRUE + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) = array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) IS NOT TRUE + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) = array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) IS FALSE + AND (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) <> array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1) IS NOT FALSE + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) BETWEEN array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) NOT BETWEEN array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1 + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) like '%' + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) not like '__DOES_NOT_EXIST__%' + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) IN (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1, + array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+0, + array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1) + AND array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0)) NOT IN (array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))-1, + array_offset_of(mv_to_array("language"), array_offset(mv_to_array("language"), 0))+1))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A9: array_ordinal_of +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) IS NULL + OR (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) = array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+0 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) IS NOT DISTINCT + FROM array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+0 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) <> array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) IS DISTINCT + FROM array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) > array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) >= array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) < array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) <= array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1 + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) <> array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) IS TRUE + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) = array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) IS NOT TRUE + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) = array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) IS FALSE + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) <> array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) IS NOT FALSE + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) BETWEEN array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) NOT BETWEEN array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) like '%' + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) not like '__DOES_NOT_EXIST__%' + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) IN (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1, + array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+0, + array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1) + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) NOT IN (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1, + array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) IS NULL + OR array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) IN + (SELECT array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) IS NULL + OR (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) = array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+0 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) IS NOT DISTINCT + FROM array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+0 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) <> array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) IS DISTINCT + FROM array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) > array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) >= array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) < array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) <= array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1 + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) <> array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) IS TRUE + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) = array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) IS NOT TRUE + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) = array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) IS FALSE + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) <> array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) IS NOT FALSE + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) BETWEEN array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) NOT BETWEEN array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) like '%' + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) not like '__DOES_NOT_EXIST__%' + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) IN (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1, + array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+0, + array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1) + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) NOT IN (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1, + array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) IS NULL + OR (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) = array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+0 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) IS NOT DISTINCT + FROM array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+0 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) <> array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) IS DISTINCT + FROM array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) > array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) >= array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) < array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) <= array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1 + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) <> array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) IS TRUE + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) = array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) IS NOT TRUE + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) = array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) IS FALSE + AND (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) <> array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1) IS NOT FALSE + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) BETWEEN array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) NOT BETWEEN array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1 + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) like '%' + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) not like '__DOES_NOT_EXIST__%' + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) IN (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1, + array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+0, + array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1) + AND array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1)) NOT IN (array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))-1, + array_ordinal_of(mv_to_array("language"), array_ordinal(mv_to_array("language"), 1))+1))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A10: array_prepend +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', mv_to_array("language")) IS NULL + OR (array_prepend('1', mv_to_array("language")) = array_prepend('1', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) IS NOT DISTINCT + FROM array_prepend('1', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) <> array_prepend('0', mv_to_array("language")) + AND (array_prepend('1', mv_to_array("language")) IS DISTINCT + FROM array_prepend('0', mv_to_array("language"))) + AND array_prepend('1', mv_to_array("language")) > array_prepend('0', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) >= array_prepend('0', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) < array_prepend('2', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) <= array_prepend('2', mv_to_array("language")) + AND (array_prepend('1', mv_to_array("language")) <> array_prepend('0', mv_to_array("language"))) IS TRUE + AND (array_prepend('1', mv_to_array("language")) = array_prepend('0', mv_to_array("language"))) IS NOT TRUE + AND (array_prepend('1', mv_to_array("language")) = array_prepend('0', mv_to_array("language"))) IS FALSE + AND (array_prepend('1', mv_to_array("language")) <> array_prepend('0', mv_to_array("language"))) IS NOT FALSE + AND array_prepend('1', mv_to_array("language")) BETWEEN array_prepend('0', mv_to_array("language")) AND array_prepend('2', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) NOT BETWEEN array_prepend('1', mv_to_array("language")) AND array_prepend('0', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) IN (array_prepend('0', mv_to_array("language")), + array_prepend('1', mv_to_array("language")), + array_prepend('2', mv_to_array("language"))) + AND array_prepend('1', mv_to_array("language")) NOT IN (array_prepend('0', mv_to_array("language")), + array_prepend('2', mv_to_array("language"))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + array_prepend('1', mv_to_array("language")), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', mv_to_array("language")) IS NULL + OR (array_prepend('1', mv_to_array("language")) = array_prepend('1', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) IS NOT DISTINCT + FROM array_prepend('1', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) <> array_prepend('0', mv_to_array("language")) + AND (array_prepend('1', mv_to_array("language")) IS DISTINCT + FROM array_prepend('0', mv_to_array("language"))) + AND array_prepend('1', mv_to_array("language")) > array_prepend('0', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) >= array_prepend('0', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) < array_prepend('2', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) <= array_prepend('2', mv_to_array("language")) + AND (array_prepend('1', mv_to_array("language")) <> array_prepend('0', mv_to_array("language"))) IS TRUE + AND (array_prepend('1', mv_to_array("language")) = array_prepend('0', mv_to_array("language"))) IS NOT TRUE + AND (array_prepend('1', mv_to_array("language")) = array_prepend('0', mv_to_array("language"))) IS FALSE + AND (array_prepend('1', mv_to_array("language")) <> array_prepend('0', mv_to_array("language"))) IS NOT FALSE + AND array_prepend('1', mv_to_array("language")) BETWEEN array_prepend('0', mv_to_array("language")) AND array_prepend('2', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) NOT BETWEEN array_prepend('1', mv_to_array("language")) AND array_prepend('0', mv_to_array("language")) + AND array_prepend('1', mv_to_array("language")) IN (array_prepend('0', mv_to_array("language")), + array_prepend('1', mv_to_array("language")), + array_prepend('2', mv_to_array("language"))) + AND array_prepend('1', mv_to_array("language")) NOT IN (array_prepend('0', mv_to_array("language")), + array_prepend('2', mv_to_array("language"))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A11: array_append +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', array_append(mv_to_array("language"), 'A')) IS NULL + OR (array_prepend('1', array_append(mv_to_array("language"), 'A')) = array_prepend('1', array_append(mv_to_array("language"), 'A')) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) IS NOT DISTINCT + FROM array_prepend('1', array_append(mv_to_array("language"), 'A')) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) <> array_prepend('0', array_append(mv_to_array("language"), 'A')) + AND (array_prepend('1', array_append(mv_to_array("language"), 'A')) IS DISTINCT + FROM array_prepend('0', array_append(mv_to_array("language"), 'A'))) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) > array_prepend('0', array_append(mv_to_array("language"), 'A')) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) >= array_prepend('0', array_append(mv_to_array("language"), 'A')) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) < array_prepend('2', array_append(mv_to_array("language"), 'A')) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) <= array_prepend('2', array_append(mv_to_array("language"), 'A')) + AND (array_prepend('1', array_append(mv_to_array("language"), 'A')) <> array_prepend('0', array_append(mv_to_array("language"), 'A'))) IS TRUE + AND (array_prepend('1', array_append(mv_to_array("language"), 'A')) = array_prepend('0', array_append(mv_to_array("language"), 'A'))) IS NOT TRUE + AND (array_prepend('1', array_append(mv_to_array("language"), 'A')) = array_prepend('0', array_append(mv_to_array("language"), 'A'))) IS FALSE + AND (array_prepend('1', array_append(mv_to_array("language"), 'A')) <> array_prepend('0', array_append(mv_to_array("language"), 'A'))) IS NOT FALSE + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) BETWEEN array_prepend('0', array_append(mv_to_array("language"), 'A')) AND array_prepend('2', array_append(mv_to_array("language"), 'A')) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) NOT BETWEEN array_prepend('1', array_append(mv_to_array("language"), 'A')) AND array_prepend('0', array_append(mv_to_array("language"), 'A')) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) IN (array_prepend('0', array_append(mv_to_array("language"), 'A')), + array_prepend('1', array_append(mv_to_array("language"), 'A')), + array_prepend('2', array_append(mv_to_array("language"), 'A'))) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) NOT IN (array_prepend('0', array_append(mv_to_array("language"), 'A')), + array_prepend('2', array_append(mv_to_array("language"), 'A'))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + array_prepend('1', array_append(mv_to_array("language"), 'A')), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', array_append(mv_to_array("language"), 'A')) IS NULL + OR (array_prepend('1', array_append(mv_to_array("language"), 'A')) = array_prepend('1', array_append(mv_to_array("language"), 'A')) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) IS NOT DISTINCT + FROM array_prepend('1', array_append(mv_to_array("language"), 'A')) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) <> array_prepend('0', array_append(mv_to_array("language"), 'A')) + AND (array_prepend('1', array_append(mv_to_array("language"), 'A')) IS DISTINCT + FROM array_prepend('0', array_append(mv_to_array("language"), 'A'))) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) > array_prepend('0', array_append(mv_to_array("language"), 'A')) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) >= array_prepend('0', array_append(mv_to_array("language"), 'A')) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) < array_prepend('2', array_append(mv_to_array("language"), 'A')) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) <= array_prepend('2', array_append(mv_to_array("language"), 'A')) + AND (array_prepend('1', array_append(mv_to_array("language"), 'A')) <> array_prepend('0', array_append(mv_to_array("language"), 'A'))) IS TRUE + AND (array_prepend('1', array_append(mv_to_array("language"), 'A')) = array_prepend('0', array_append(mv_to_array("language"), 'A'))) IS NOT TRUE + AND (array_prepend('1', array_append(mv_to_array("language"), 'A')) = array_prepend('0', array_append(mv_to_array("language"), 'A'))) IS FALSE + AND (array_prepend('1', array_append(mv_to_array("language"), 'A')) <> array_prepend('0', array_append(mv_to_array("language"), 'A'))) IS NOT FALSE + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) BETWEEN array_prepend('0', array_append(mv_to_array("language"), 'A')) AND array_prepend('2', array_append(mv_to_array("language"), 'A')) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) NOT BETWEEN array_prepend('1', array_append(mv_to_array("language"), 'A')) AND array_prepend('0', array_append(mv_to_array("language"), 'A')) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) IN (array_prepend('0', array_append(mv_to_array("language"), 'A')), + array_prepend('1', array_append(mv_to_array("language"), 'A')), + array_prepend('2', array_append(mv_to_array("language"), 'A'))) + AND array_prepend('1', array_append(mv_to_array("language"), 'A')) NOT IN (array_prepend('0', array_append(mv_to_array("language"), 'A')), + array_prepend('2', array_append(mv_to_array("language"), 'A'))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A12: array_concat +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) IS NULL + OR (array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) = array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) IS NOT DISTINCT + FROM array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) <> array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND (array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) IS DISTINCT + FROM array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language")))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) > array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) >= array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) < array_prepend('2', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) <= array_prepend('2', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND (array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) <> array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language")))) IS TRUE + AND (array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) = array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language")))) IS NOT TRUE + AND (array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) = array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language")))) IS FALSE + AND (array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) <> array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language")))) IS NOT FALSE + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) BETWEEN array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language"))) AND array_prepend('2', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) NOT BETWEEN array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) AND array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) IN (array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language"))), + array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))), + array_prepend('2', array_concat(mv_to_array("language"), mv_to_array("language")))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) NOT IN (array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language"))), + array_prepend('2', array_concat(mv_to_array("language"), mv_to_array("language")))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) IS NULL + OR (array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) = array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) IS NOT DISTINCT + FROM array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) <> array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND (array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) IS DISTINCT + FROM array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language")))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) > array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) >= array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) < array_prepend('2', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) <= array_prepend('2', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND (array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) <> array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language")))) IS TRUE + AND (array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) = array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language")))) IS NOT TRUE + AND (array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) = array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language")))) IS FALSE + AND (array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) <> array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language")))) IS NOT FALSE + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) BETWEEN array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language"))) AND array_prepend('2', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) NOT BETWEEN array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) AND array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language"))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) IN (array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language"))), + array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))), + array_prepend('2', array_concat(mv_to_array("language"), mv_to_array("language")))) + AND array_prepend('1', array_concat(mv_to_array("language"), mv_to_array("language"))) NOT IN (array_prepend('0', array_concat(mv_to_array("language"), mv_to_array("language"))), + array_prepend('2', array_concat(mv_to_array("language"), mv_to_array("language")))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A13: array_slice +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) IS NULL + OR (array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) = array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) IS NOT DISTINCT + FROM array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) <> array_prepend('0', array_slice(mv_to_array("language"), 0, 1)) + AND (array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) IS DISTINCT + FROM array_prepend('0', array_slice(mv_to_array("language"), 0, 1))) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) > array_prepend('0', array_slice(mv_to_array("language"), 0, 1)) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) >= array_prepend('0', array_slice(mv_to_array("language"), 0, 1)) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) < array_prepend('2', array_slice(mv_to_array("language"), 0, 1)) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) <= array_prepend('2', array_slice(mv_to_array("language"), 0, 1)) + AND (array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) <> array_prepend('0', array_slice(mv_to_array("language"), 0, 1))) IS TRUE + AND (array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) = array_prepend('0', array_slice(mv_to_array("language"), 0, 1))) IS NOT TRUE + AND (array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) = array_prepend('0', array_slice(mv_to_array("language"), 0, 1))) IS FALSE + AND (array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) <> array_prepend('0', array_slice(mv_to_array("language"), 0, 1))) IS NOT FALSE + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) BETWEEN array_prepend('0', array_slice(mv_to_array("language"), 0, 1)) AND array_prepend('2', array_slice(mv_to_array("language"), 0, 1)) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) NOT BETWEEN array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) AND array_prepend('0', array_slice(mv_to_array("language"), 0, 1)) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) IN (array_prepend('0', array_slice(mv_to_array("language"), 0, 1)), + array_prepend('1', array_slice(mv_to_array("language"), 0, 1)), + array_prepend('2', array_slice(mv_to_array("language"), 0, 1))) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) NOT IN (array_prepend('0', array_slice(mv_to_array("language"), 0, 1)), + array_prepend('2', array_slice(mv_to_array("language"), 0, 1))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + array_prepend('1', array_slice(mv_to_array("language"), 0, 1)), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) IS NULL + OR (array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) = array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) IS NOT DISTINCT + FROM array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) <> array_prepend('0', array_slice(mv_to_array("language"), 0, 1)) + AND (array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) IS DISTINCT + FROM array_prepend('0', array_slice(mv_to_array("language"), 0, 1))) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) > array_prepend('0', array_slice(mv_to_array("language"), 0, 1)) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) >= array_prepend('0', array_slice(mv_to_array("language"), 0, 1)) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) < array_prepend('2', array_slice(mv_to_array("language"), 0, 1)) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) <= array_prepend('2', array_slice(mv_to_array("language"), 0, 1)) + AND (array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) <> array_prepend('0', array_slice(mv_to_array("language"), 0, 1))) IS TRUE + AND (array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) = array_prepend('0', array_slice(mv_to_array("language"), 0, 1))) IS NOT TRUE + AND (array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) = array_prepend('0', array_slice(mv_to_array("language"), 0, 1))) IS FALSE + AND (array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) <> array_prepend('0', array_slice(mv_to_array("language"), 0, 1))) IS NOT FALSE + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) BETWEEN array_prepend('0', array_slice(mv_to_array("language"), 0, 1)) AND array_prepend('2', array_slice(mv_to_array("language"), 0, 1)) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) NOT BETWEEN array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) AND array_prepend('0', array_slice(mv_to_array("language"), 0, 1)) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) IN (array_prepend('0', array_slice(mv_to_array("language"), 0, 1)), + array_prepend('1', array_slice(mv_to_array("language"), 0, 1)), + array_prepend('2', array_slice(mv_to_array("language"), 0, 1))) + AND array_prepend('1', array_slice(mv_to_array("language"), 0, 1)) NOT IN (array_prepend('0', array_slice(mv_to_array("language"), 0, 1)), + array_prepend('2', array_slice(mv_to_array("language"), 0, 1))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A14: array_to_string +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_to_string(mv_to_array("language"), '|') IS NULL + OR ('1'||array_to_string(mv_to_array("language"), '|') = 1||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') IS NOT DISTINCT + FROM 1||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') <> 0||array_to_string(mv_to_array("language"), '|') + AND ('1'||array_to_string(mv_to_array("language"), '|') IS DISTINCT + FROM 0||array_to_string(mv_to_array("language"), '|')) + AND '1'||array_to_string(mv_to_array("language"), '|') > 0||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') >= 0||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') < 2||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') <= 2||array_to_string(mv_to_array("language"), '|') + AND ('1'||array_to_string(mv_to_array("language"), '|') <> 0||array_to_string(mv_to_array("language"), '|')) IS TRUE + AND ('1'||array_to_string(mv_to_array("language"), '|') = 0||array_to_string(mv_to_array("language"), '|')) IS NOT TRUE + AND ('1'||array_to_string(mv_to_array("language"), '|') = 0||array_to_string(mv_to_array("language"), '|')) IS FALSE + AND ('1'||array_to_string(mv_to_array("language"), '|') <> 0||array_to_string(mv_to_array("language"), '|')) IS NOT FALSE + AND '1'||array_to_string(mv_to_array("language"), '|') BETWEEN 0||array_to_string(mv_to_array("language"), '|') AND 2||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') NOT BETWEEN '1'||array_to_string(mv_to_array("language"), '|') AND 0||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') like '%' + AND '1'||array_to_string(mv_to_array("language"), '|') not like '__DOES_NOT_EXIST__%' + AND '1'||array_to_string(mv_to_array("language"), '|') IN (0||array_to_string(mv_to_array("language"), '|'), + 1||array_to_string(mv_to_array("language"), '|'), + 2||array_to_string(mv_to_array("language"), '|')) + AND '1'||array_to_string(mv_to_array("language"), '|') NOT IN (0||array_to_string(mv_to_array("language"), '|'), + 2||array_to_string(mv_to_array("language"), '|')))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_to_string(mv_to_array("language"), '|') IS NULL + OR '1'||array_to_string(mv_to_array("language"), '|') IN + (SELECT '1'||array_to_string(mv_to_array("language"), '|') + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_to_string(mv_to_array("language"), '|') IS NULL + OR ('1'||array_to_string(mv_to_array("language"), '|') = 1||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') IS NOT DISTINCT + FROM 1||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') <> 0||array_to_string(mv_to_array("language"), '|') + AND ('1'||array_to_string(mv_to_array("language"), '|') IS DISTINCT + FROM 0||array_to_string(mv_to_array("language"), '|')) + AND '1'||array_to_string(mv_to_array("language"), '|') > 0||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') >= 0||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') < 2||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') <= 2||array_to_string(mv_to_array("language"), '|') + AND ('1'||array_to_string(mv_to_array("language"), '|') <> 0||array_to_string(mv_to_array("language"), '|')) IS TRUE + AND ('1'||array_to_string(mv_to_array("language"), '|') = 0||array_to_string(mv_to_array("language"), '|')) IS NOT TRUE + AND ('1'||array_to_string(mv_to_array("language"), '|') = 0||array_to_string(mv_to_array("language"), '|')) IS FALSE + AND ('1'||array_to_string(mv_to_array("language"), '|') <> 0||array_to_string(mv_to_array("language"), '|')) IS NOT FALSE + AND '1'||array_to_string(mv_to_array("language"), '|') BETWEEN 0||array_to_string(mv_to_array("language"), '|') AND 2||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') NOT BETWEEN '1'||array_to_string(mv_to_array("language"), '|') AND 0||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') like '%' + AND '1'||array_to_string(mv_to_array("language"), '|') not like '__DOES_NOT_EXIST__%' + AND '1'||array_to_string(mv_to_array("language"), '|') IN (0||array_to_string(mv_to_array("language"), '|'), + 1||array_to_string(mv_to_array("language"), '|'), + 2||array_to_string(mv_to_array("language"), '|')) + AND '1'||array_to_string(mv_to_array("language"), '|') NOT IN (0||array_to_string(mv_to_array("language"), '|'), + 2||array_to_string(mv_to_array("language"), '|')))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||array_to_string(mv_to_array("language"), '|'), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_to_string(mv_to_array("language"), '|') IS NULL + OR ('1'||array_to_string(mv_to_array("language"), '|') = 1||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') IS NOT DISTINCT + FROM 1||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') <> 0||array_to_string(mv_to_array("language"), '|') + AND ('1'||array_to_string(mv_to_array("language"), '|') IS DISTINCT + FROM 0||array_to_string(mv_to_array("language"), '|')) + AND '1'||array_to_string(mv_to_array("language"), '|') > 0||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') >= 0||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') < 2||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') <= 2||array_to_string(mv_to_array("language"), '|') + AND ('1'||array_to_string(mv_to_array("language"), '|') <> 0||array_to_string(mv_to_array("language"), '|')) IS TRUE + AND ('1'||array_to_string(mv_to_array("language"), '|') = 0||array_to_string(mv_to_array("language"), '|')) IS NOT TRUE + AND ('1'||array_to_string(mv_to_array("language"), '|') = 0||array_to_string(mv_to_array("language"), '|')) IS FALSE + AND ('1'||array_to_string(mv_to_array("language"), '|') <> 0||array_to_string(mv_to_array("language"), '|')) IS NOT FALSE + AND '1'||array_to_string(mv_to_array("language"), '|') BETWEEN 0||array_to_string(mv_to_array("language"), '|') AND 2||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') NOT BETWEEN '1'||array_to_string(mv_to_array("language"), '|') AND 0||array_to_string(mv_to_array("language"), '|') + AND '1'||array_to_string(mv_to_array("language"), '|') like '%' + AND '1'||array_to_string(mv_to_array("language"), '|') not like '__DOES_NOT_EXIST__%' + AND '1'||array_to_string(mv_to_array("language"), '|') IN (0||array_to_string(mv_to_array("language"), '|'), + 1||array_to_string(mv_to_array("language"), '|'), + 2||array_to_string(mv_to_array("language"), '|')) + AND '1'||array_to_string(mv_to_array("language"), '|') NOT IN (0||array_to_string(mv_to_array("language"), '|'), + 2||array_to_string(mv_to_array("language"), '|')))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A15: string_to_array +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', string_to_array('A|B', '|')) IS NULL + OR (array_prepend('1', string_to_array('A|B', '|')) = array_prepend('1', string_to_array('A|B', '|')) + AND array_prepend('1', string_to_array('A|B', '|')) IS NOT DISTINCT + FROM array_prepend('1', string_to_array('A|B', '|')) + AND array_prepend('1', string_to_array('A|B', '|')) <> array_prepend('0', string_to_array('A|B', '|')) + AND (array_prepend('1', string_to_array('A|B', '|')) IS DISTINCT + FROM array_prepend('0', string_to_array('A|B', '|'))) + AND array_prepend('1', string_to_array('A|B', '|')) > array_prepend('0', string_to_array('A|B', '|')) + AND array_prepend('1', string_to_array('A|B', '|')) >= array_prepend('0', string_to_array('A|B', '|')) + AND array_prepend('1', string_to_array('A|B', '|')) < array_prepend('2', string_to_array('A|B', '|')) + AND array_prepend('1', string_to_array('A|B', '|')) <= array_prepend('2', string_to_array('A|B', '|')) + AND (array_prepend('1', string_to_array('A|B', '|')) <> array_prepend('0', string_to_array('A|B', '|'))) IS TRUE + AND (array_prepend('1', string_to_array('A|B', '|')) = array_prepend('0', string_to_array('A|B', '|'))) IS NOT TRUE + AND (array_prepend('1', string_to_array('A|B', '|')) = array_prepend('0', string_to_array('A|B', '|'))) IS FALSE + AND (array_prepend('1', string_to_array('A|B', '|')) <> array_prepend('0', string_to_array('A|B', '|'))) IS NOT FALSE + AND array_prepend('1', string_to_array('A|B', '|')) BETWEEN array_prepend('0', string_to_array('A|B', '|')) AND array_prepend('2', string_to_array('A|B', '|')) + AND array_prepend('1', string_to_array('A|B', '|')) NOT BETWEEN array_prepend('1', string_to_array('A|B', '|')) AND array_prepend('0', string_to_array('A|B', '|')) + AND array_prepend('1', string_to_array('A|B', '|')) IN (array_prepend('0', string_to_array('A|B', '|')), + array_prepend('1', string_to_array('A|B', '|')), + array_prepend('2', string_to_array('A|B', '|'))) + AND array_prepend('1', string_to_array('A|B', '|')) NOT IN (array_prepend('0', string_to_array('A|B', '|')), + array_prepend('2', string_to_array('A|B', '|'))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + array_prepend('1', string_to_array('A|B', '|')), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', string_to_array('A|B', '|')) IS NULL + OR (array_prepend('1', string_to_array('A|B', '|')) = array_prepend('1', string_to_array('A|B', '|')) + AND array_prepend('1', string_to_array('A|B', '|')) IS NOT DISTINCT + FROM array_prepend('1', string_to_array('A|B', '|')) + AND array_prepend('1', string_to_array('A|B', '|')) <> array_prepend('0', string_to_array('A|B', '|')) + AND (array_prepend('1', string_to_array('A|B', '|')) IS DISTINCT + FROM array_prepend('0', string_to_array('A|B', '|'))) + AND array_prepend('1', string_to_array('A|B', '|')) > array_prepend('0', string_to_array('A|B', '|')) + AND array_prepend('1', string_to_array('A|B', '|')) >= array_prepend('0', string_to_array('A|B', '|')) + AND array_prepend('1', string_to_array('A|B', '|')) < array_prepend('2', string_to_array('A|B', '|')) + AND array_prepend('1', string_to_array('A|B', '|')) <= array_prepend('2', string_to_array('A|B', '|')) + AND (array_prepend('1', string_to_array('A|B', '|')) <> array_prepend('0', string_to_array('A|B', '|'))) IS TRUE + AND (array_prepend('1', string_to_array('A|B', '|')) = array_prepend('0', string_to_array('A|B', '|'))) IS NOT TRUE + AND (array_prepend('1', string_to_array('A|B', '|')) = array_prepend('0', string_to_array('A|B', '|'))) IS FALSE + AND (array_prepend('1', string_to_array('A|B', '|')) <> array_prepend('0', string_to_array('A|B', '|'))) IS NOT FALSE + AND array_prepend('1', string_to_array('A|B', '|')) BETWEEN array_prepend('0', string_to_array('A|B', '|')) AND array_prepend('2', string_to_array('A|B', '|')) + AND array_prepend('1', string_to_array('A|B', '|')) NOT BETWEEN array_prepend('1', string_to_array('A|B', '|')) AND array_prepend('0', string_to_array('A|B', '|')) + AND array_prepend('1', string_to_array('A|B', '|')) IN (array_prepend('0', string_to_array('A|B', '|')), + array_prepend('1', string_to_array('A|B', '|')), + array_prepend('2', string_to_array('A|B', '|'))) + AND array_prepend('1', string_to_array('A|B', '|')) NOT IN (array_prepend('0', string_to_array('A|B', '|')), + array_prepend('2', string_to_array('A|B', '|'))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A16: array_to_mv +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) IS NULL + OR ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) = 1||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) IS NOT DISTINCT + FROM 1||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) <> 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) IS DISTINCT + FROM 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) > 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) >= 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) < 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) <= 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) <> 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) IS TRUE + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) = 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) IS NOT TRUE + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) = 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) IS FALSE + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) <> 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) IS NOT FALSE + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) BETWEEN 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) AND 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) NOT BETWEEN '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) AND 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) like '%' + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) not like '__DOES_NOT_EXIST__%' + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) IN (0||mv_offset_of(array_to_mv(mv_to_array("language")), 0), + 1||mv_offset_of(array_to_mv(mv_to_array("language")), 0), + 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) NOT IN (0||mv_offset_of(array_to_mv(mv_to_array("language")), 0), + 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) IS NULL + OR '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) IN + (SELECT '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) IS NULL + OR ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) = 1||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) IS NOT DISTINCT + FROM 1||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) <> 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) IS DISTINCT + FROM 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) > 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) >= 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) < 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) <= 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) <> 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) IS TRUE + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) = 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) IS NOT TRUE + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) = 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) IS FALSE + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) <> 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) IS NOT FALSE + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) BETWEEN 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) AND 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) NOT BETWEEN '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) AND 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) like '%' + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) not like '__DOES_NOT_EXIST__%' + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) IN (0||mv_offset_of(array_to_mv(mv_to_array("language")), 0), + 1||mv_offset_of(array_to_mv(mv_to_array("language")), 0), + 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) NOT IN (0||mv_offset_of(array_to_mv(mv_to_array("language")), 0), + 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) IS NULL + OR ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) = 1||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) IS NOT DISTINCT + FROM 1||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) <> 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) IS DISTINCT + FROM 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) > 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) >= 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) < 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) <= 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) <> 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) IS TRUE + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) = 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) IS NOT TRUE + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) = 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) IS FALSE + AND ('1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) <> 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) IS NOT FALSE + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) BETWEEN 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) AND 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) NOT BETWEEN '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) AND 0||mv_offset_of(array_to_mv(mv_to_array("language")), 0) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) like '%' + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) not like '__DOES_NOT_EXIST__%' + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) IN (0||mv_offset_of(array_to_mv(mv_to_array("language")), 0), + 1||mv_offset_of(array_to_mv(mv_to_array("language")), 0), + 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0)) + AND '1'||mv_offset_of(array_to_mv(mv_to_array("language")), 0) NOT IN (0||mv_offset_of(array_to_mv(mv_to_array("language")), 0), + 2||mv_offset_of(array_to_mv(mv_to_array("language")), 0)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# Total query count 43 +#------------------------------------------------------------------------- diff --git a/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_json.iq b/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_json.iq new file mode 100644 index 00000000000..c6deceeee5d --- /dev/null +++ b/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_json.iq @@ -0,0 +1,1653 @@ +!set useApproximateCountDistinct false +!use druidtest:///?componentSupplier=KttmNestedComponentSupplier +!set outputformat mysql +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00'; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A1: json_keys +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', json_keys(agent, '$.')) IS NULL + OR (array_prepend('1', json_keys(agent, '$.')) = array_prepend('1', json_keys(agent, '$.')) + AND array_prepend('1', json_keys(agent, '$.')) IS NOT DISTINCT + FROM array_prepend('1', json_keys(agent, '$.')) + AND array_prepend('1', json_keys(agent, '$.')) <> array_prepend('0', json_keys(agent, '$.')) + AND (array_prepend('1', json_keys(agent, '$.')) IS DISTINCT + FROM array_prepend('0', json_keys(agent, '$.'))) + AND array_prepend('1', json_keys(agent, '$.')) > array_prepend('0', json_keys(agent, '$.')) + AND array_prepend('1', json_keys(agent, '$.')) >= array_prepend('0', json_keys(agent, '$.')) + AND array_prepend('1', json_keys(agent, '$.')) < array_prepend('2', json_keys(agent, '$.')) + AND array_prepend('1', json_keys(agent, '$.')) <= array_prepend('2', json_keys(agent, '$.')) + AND (array_prepend('1', json_keys(agent, '$.')) <> array_prepend('0', json_keys(agent, '$.'))) IS TRUE + AND (array_prepend('1', json_keys(agent, '$.')) = array_prepend('0', json_keys(agent, '$.'))) IS NOT TRUE + AND (array_prepend('1', json_keys(agent, '$.')) = array_prepend('0', json_keys(agent, '$.'))) IS FALSE + AND (array_prepend('1', json_keys(agent, '$.')) <> array_prepend('0', json_keys(agent, '$.'))) IS NOT FALSE + AND array_prepend('1', json_keys(agent, '$.')) BETWEEN array_prepend('0', json_keys(agent, '$.')) AND array_prepend('2', json_keys(agent, '$.')) + AND array_prepend('1', json_keys(agent, '$.')) NOT BETWEEN array_prepend('1', json_keys(agent, '$.')) AND array_prepend('0', json_keys(agent, '$.')) + AND array_prepend('1', json_keys(agent, '$.')) IN (array_prepend('0', json_keys(agent, '$.')), + array_prepend('1', json_keys(agent, '$.')), + array_prepend('2', json_keys(agent, '$.'))) + AND array_prepend('1', json_keys(agent, '$.')) NOT IN (array_prepend('0', json_keys(agent, '$.')), + array_prepend('2', json_keys(agent, '$.'))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + array_prepend('1', json_keys(agent, '$.')), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', json_keys(agent, '$.')) IS NULL + OR (array_prepend('1', json_keys(agent, '$.')) = array_prepend('1', json_keys(agent, '$.')) + AND array_prepend('1', json_keys(agent, '$.')) IS NOT DISTINCT + FROM array_prepend('1', json_keys(agent, '$.')) + AND array_prepend('1', json_keys(agent, '$.')) <> array_prepend('0', json_keys(agent, '$.')) + AND (array_prepend('1', json_keys(agent, '$.')) IS DISTINCT + FROM array_prepend('0', json_keys(agent, '$.'))) + AND array_prepend('1', json_keys(agent, '$.')) > array_prepend('0', json_keys(agent, '$.')) + AND array_prepend('1', json_keys(agent, '$.')) >= array_prepend('0', json_keys(agent, '$.')) + AND array_prepend('1', json_keys(agent, '$.')) < array_prepend('2', json_keys(agent, '$.')) + AND array_prepend('1', json_keys(agent, '$.')) <= array_prepend('2', json_keys(agent, '$.')) + AND (array_prepend('1', json_keys(agent, '$.')) <> array_prepend('0', json_keys(agent, '$.'))) IS TRUE + AND (array_prepend('1', json_keys(agent, '$.')) = array_prepend('0', json_keys(agent, '$.'))) IS NOT TRUE + AND (array_prepend('1', json_keys(agent, '$.')) = array_prepend('0', json_keys(agent, '$.'))) IS FALSE + AND (array_prepend('1', json_keys(agent, '$.')) <> array_prepend('0', json_keys(agent, '$.'))) IS NOT FALSE + AND array_prepend('1', json_keys(agent, '$.')) BETWEEN array_prepend('0', json_keys(agent, '$.')) AND array_prepend('2', json_keys(agent, '$.')) + AND array_prepend('1', json_keys(agent, '$.')) NOT BETWEEN array_prepend('1', json_keys(agent, '$.')) AND array_prepend('0', json_keys(agent, '$.')) + AND array_prepend('1', json_keys(agent, '$.')) IN (array_prepend('0', json_keys(agent, '$.')), + array_prepend('1', json_keys(agent, '$.')), + array_prepend('2', json_keys(agent, '$.'))) + AND array_prepend('1', json_keys(agent, '$.')) NOT IN (array_prepend('0', json_keys(agent, '$.')), + array_prepend('2', json_keys(agent, '$.'))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A2: json_object +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) IS NULL + OR ('1'||to_json_string(json_object(KEY 'c1' value number)) = 1||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) IS NOT DISTINCT + FROM 1||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) <> '0'||to_json_string(json_object(KEY 'c1' value number)) + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) IS DISTINCT + FROM '0'||to_json_string(json_object(KEY 'c1' value number))) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) > '0'||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) >= '0'||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) < 2||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) <= 2||to_json_string(json_object(KEY 'c1' value number)) + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) <> '0'||to_json_string(json_object(KEY 'c1' value number))) IS TRUE + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) = '0'||to_json_string(json_object(KEY 'c1' value number))) IS NOT TRUE + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) = '0'||to_json_string(json_object(KEY 'c1' value number))) IS FALSE + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) <> '0'||to_json_string(json_object(KEY 'c1' value number))) IS NOT FALSE + AND '1'||to_json_string(json_object(KEY 'c1' value number)) BETWEEN '0'||to_json_string(json_object(KEY 'c1' value number)) AND 2||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) NOT BETWEEN '1'||to_json_string(json_object(KEY 'c1' value number)) AND '0'||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) like '%' + AND '1'||to_json_string(json_object(KEY 'c1' value number)) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(json_object(KEY 'c1' value number)) IN ('0'||to_json_string(json_object(KEY 'c1' value number)), + 1||to_json_string(json_object(KEY 'c1' value number)), + 2||to_json_string(json_object(KEY 'c1' value number))) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) NOT IN ('0'||to_json_string(json_object(KEY 'c1' value number)), + 2||to_json_string(json_object(KEY 'c1' value number))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) IS NULL + OR '1'||to_json_string(json_object(KEY 'c1' value number)) IN + (SELECT '1'||to_json_string(json_object(KEY 'c1' value number)) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) IS NULL + OR ('1'||to_json_string(json_object(KEY 'c1' value number)) = 1||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) IS NOT DISTINCT + FROM 1||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) <> '0'||to_json_string(json_object(KEY 'c1' value number)) + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) IS DISTINCT + FROM '0'||to_json_string(json_object(KEY 'c1' value number))) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) > '0'||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) >= '0'||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) < 2||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) <= 2||to_json_string(json_object(KEY 'c1' value number)) + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) <> '0'||to_json_string(json_object(KEY 'c1' value number))) IS TRUE + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) = '0'||to_json_string(json_object(KEY 'c1' value number))) IS NOT TRUE + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) = '0'||to_json_string(json_object(KEY 'c1' value number))) IS FALSE + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) <> '0'||to_json_string(json_object(KEY 'c1' value number))) IS NOT FALSE + AND '1'||to_json_string(json_object(KEY 'c1' value number)) BETWEEN '0'||to_json_string(json_object(KEY 'c1' value number)) AND 2||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) NOT BETWEEN '1'||to_json_string(json_object(KEY 'c1' value number)) AND '0'||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) like '%' + AND '1'||to_json_string(json_object(KEY 'c1' value number)) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(json_object(KEY 'c1' value number)) IN ('0'||to_json_string(json_object(KEY 'c1' value number)), + 1||to_json_string(json_object(KEY 'c1' value number)), + 2||to_json_string(json_object(KEY 'c1' value number))) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) NOT IN ('0'||to_json_string(json_object(KEY 'c1' value number)), + 2||to_json_string(json_object(KEY 'c1' value number))))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||to_json_string(json_object(KEY 'c1' value number)), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) IS NULL + OR ('1'||to_json_string(json_object(KEY 'c1' value number)) = 1||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) IS NOT DISTINCT + FROM 1||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) <> '0'||to_json_string(json_object(KEY 'c1' value number)) + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) IS DISTINCT + FROM '0'||to_json_string(json_object(KEY 'c1' value number))) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) > '0'||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) >= '0'||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) < 2||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) <= 2||to_json_string(json_object(KEY 'c1' value number)) + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) <> '0'||to_json_string(json_object(KEY 'c1' value number))) IS TRUE + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) = '0'||to_json_string(json_object(KEY 'c1' value number))) IS NOT TRUE + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) = '0'||to_json_string(json_object(KEY 'c1' value number))) IS FALSE + AND ('1'||to_json_string(json_object(KEY 'c1' value number)) <> '0'||to_json_string(json_object(KEY 'c1' value number))) IS NOT FALSE + AND '1'||to_json_string(json_object(KEY 'c1' value number)) BETWEEN '0'||to_json_string(json_object(KEY 'c1' value number)) AND 2||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) NOT BETWEEN '1'||to_json_string(json_object(KEY 'c1' value number)) AND '0'||to_json_string(json_object(KEY 'c1' value number)) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) like '%' + AND '1'||to_json_string(json_object(KEY 'c1' value number)) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(json_object(KEY 'c1' value number)) IN ('0'||to_json_string(json_object(KEY 'c1' value number)), + 1||to_json_string(json_object(KEY 'c1' value number)), + 2||to_json_string(json_object(KEY 'c1' value number))) + AND '1'||to_json_string(json_object(KEY 'c1' value number)) NOT IN ('0'||to_json_string(json_object(KEY 'c1' value number)), + 2||to_json_string(json_object(KEY 'c1' value number))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A3: json_paths +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', json_paths(agent)) IS NULL + OR (array_prepend('1', json_paths(agent)) = array_prepend('1', json_paths(agent)) + AND array_prepend('1', json_paths(agent)) IS NOT DISTINCT + FROM array_prepend('1', json_paths(agent)) + AND array_prepend('1', json_paths(agent)) <> array_prepend('0', json_paths(agent)) + AND (array_prepend('1', json_paths(agent)) IS DISTINCT + FROM array_prepend('0', json_paths(agent))) + AND array_prepend('1', json_paths(agent)) > array_prepend('0', json_paths(agent)) + AND array_prepend('1', json_paths(agent)) >= array_prepend('0', json_paths(agent)) + AND array_prepend('1', json_paths(agent)) < array_prepend('2', json_paths(agent)) + AND array_prepend('1', json_paths(agent)) <= array_prepend('2', json_paths(agent)) + AND (array_prepend('1', json_paths(agent)) <> array_prepend('0', json_paths(agent))) IS TRUE + AND (array_prepend('1', json_paths(agent)) = array_prepend('0', json_paths(agent))) IS NOT TRUE + AND (array_prepend('1', json_paths(agent)) = array_prepend('0', json_paths(agent))) IS FALSE + AND (array_prepend('1', json_paths(agent)) <> array_prepend('0', json_paths(agent))) IS NOT FALSE + AND array_prepend('1', json_paths(agent)) BETWEEN array_prepend('0', json_paths(agent)) AND array_prepend('2', json_paths(agent)) + AND array_prepend('1', json_paths(agent)) NOT BETWEEN array_prepend('1', json_paths(agent)) AND array_prepend('0', json_paths(agent)) + AND array_prepend('1', json_paths(agent)) IN (array_prepend('0', json_paths(agent)), + array_prepend('1', json_paths(agent)), + array_prepend('2', json_paths(agent))) + AND array_prepend('1', json_paths(agent)) NOT IN (array_prepend('0', json_paths(agent)), + array_prepend('2', json_paths(agent))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + array_prepend('1', json_paths(agent)), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (array_prepend('1', json_paths(agent)) IS NULL + OR (array_prepend('1', json_paths(agent)) = array_prepend('1', json_paths(agent)) + AND array_prepend('1', json_paths(agent)) IS NOT DISTINCT + FROM array_prepend('1', json_paths(agent)) + AND array_prepend('1', json_paths(agent)) <> array_prepend('0', json_paths(agent)) + AND (array_prepend('1', json_paths(agent)) IS DISTINCT + FROM array_prepend('0', json_paths(agent))) + AND array_prepend('1', json_paths(agent)) > array_prepend('0', json_paths(agent)) + AND array_prepend('1', json_paths(agent)) >= array_prepend('0', json_paths(agent)) + AND array_prepend('1', json_paths(agent)) < array_prepend('2', json_paths(agent)) + AND array_prepend('1', json_paths(agent)) <= array_prepend('2', json_paths(agent)) + AND (array_prepend('1', json_paths(agent)) <> array_prepend('0', json_paths(agent))) IS TRUE + AND (array_prepend('1', json_paths(agent)) = array_prepend('0', json_paths(agent))) IS NOT TRUE + AND (array_prepend('1', json_paths(agent)) = array_prepend('0', json_paths(agent))) IS FALSE + AND (array_prepend('1', json_paths(agent)) <> array_prepend('0', json_paths(agent))) IS NOT FALSE + AND array_prepend('1', json_paths(agent)) BETWEEN array_prepend('0', json_paths(agent)) AND array_prepend('2', json_paths(agent)) + AND array_prepend('1', json_paths(agent)) NOT BETWEEN array_prepend('1', json_paths(agent)) AND array_prepend('0', json_paths(agent)) + AND array_prepend('1', json_paths(agent)) IN (array_prepend('0', json_paths(agent)), + array_prepend('1', json_paths(agent)), + array_prepend('2', json_paths(agent))) + AND array_prepend('1', json_paths(agent)) NOT IN (array_prepend('0', json_paths(agent)), + array_prepend('2', json_paths(agent))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A4: json_query +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(json_query(agent, '$.')) IS NULL + OR ('1'||to_json_string(json_query(agent, '$.')) = 1||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) IS NOT DISTINCT + FROM 1||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) <> '0'||to_json_string(json_query(agent, '$.')) + AND ('1'||to_json_string(json_query(agent, '$.')) IS DISTINCT + FROM '0'||to_json_string(json_query(agent, '$.'))) + AND '1'||to_json_string(json_query(agent, '$.')) > '0'||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) >= '0'||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) < 2||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) <= 2||to_json_string(json_query(agent, '$.')) + AND ('1'||to_json_string(json_query(agent, '$.')) <> '0'||to_json_string(json_query(agent, '$.'))) IS TRUE + AND ('1'||to_json_string(json_query(agent, '$.')) = '0'||to_json_string(json_query(agent, '$.'))) IS NOT TRUE + AND ('1'||to_json_string(json_query(agent, '$.')) = '0'||to_json_string(json_query(agent, '$.'))) IS FALSE + AND ('1'||to_json_string(json_query(agent, '$.')) <> '0'||to_json_string(json_query(agent, '$.'))) IS NOT FALSE + AND '1'||to_json_string(json_query(agent, '$.')) BETWEEN '0'||to_json_string(json_query(agent, '$.')) AND 2||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) NOT BETWEEN '1'||to_json_string(json_query(agent, '$.')) AND '0'||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) like '%' + AND '1'||to_json_string(json_query(agent, '$.')) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(json_query(agent, '$.')) IN ('0'||to_json_string(json_query(agent, '$.')), + 1||to_json_string(json_query(agent, '$.')), + 2||to_json_string(json_query(agent, '$.'))) + AND '1'||to_json_string(json_query(agent, '$.')) NOT IN ('0'||to_json_string(json_query(agent, '$.')), + 2||to_json_string(json_query(agent, '$.'))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(json_query(agent, '$.')) IS NULL + OR '1'||to_json_string(json_query(agent, '$.')) IN + (SELECT '1'||to_json_string(json_query(agent, '$.')) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(json_query(agent, '$.')) IS NULL + OR ('1'||to_json_string(json_query(agent, '$.')) = 1||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) IS NOT DISTINCT + FROM 1||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) <> '0'||to_json_string(json_query(agent, '$.')) + AND ('1'||to_json_string(json_query(agent, '$.')) IS DISTINCT + FROM '0'||to_json_string(json_query(agent, '$.'))) + AND '1'||to_json_string(json_query(agent, '$.')) > '0'||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) >= '0'||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) < 2||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) <= 2||to_json_string(json_query(agent, '$.')) + AND ('1'||to_json_string(json_query(agent, '$.')) <> '0'||to_json_string(json_query(agent, '$.'))) IS TRUE + AND ('1'||to_json_string(json_query(agent, '$.')) = '0'||to_json_string(json_query(agent, '$.'))) IS NOT TRUE + AND ('1'||to_json_string(json_query(agent, '$.')) = '0'||to_json_string(json_query(agent, '$.'))) IS FALSE + AND ('1'||to_json_string(json_query(agent, '$.')) <> '0'||to_json_string(json_query(agent, '$.'))) IS NOT FALSE + AND '1'||to_json_string(json_query(agent, '$.')) BETWEEN '0'||to_json_string(json_query(agent, '$.')) AND 2||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) NOT BETWEEN '1'||to_json_string(json_query(agent, '$.')) AND '0'||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) like '%' + AND '1'||to_json_string(json_query(agent, '$.')) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(json_query(agent, '$.')) IN ('0'||to_json_string(json_query(agent, '$.')), + 1||to_json_string(json_query(agent, '$.')), + 2||to_json_string(json_query(agent, '$.'))) + AND '1'||to_json_string(json_query(agent, '$.')) NOT IN ('0'||to_json_string(json_query(agent, '$.')), + 2||to_json_string(json_query(agent, '$.'))))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||to_json_string(json_query(agent, '$.')), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(json_query(agent, '$.')) IS NULL + OR ('1'||to_json_string(json_query(agent, '$.')) = 1||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) IS NOT DISTINCT + FROM 1||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) <> '0'||to_json_string(json_query(agent, '$.')) + AND ('1'||to_json_string(json_query(agent, '$.')) IS DISTINCT + FROM '0'||to_json_string(json_query(agent, '$.'))) + AND '1'||to_json_string(json_query(agent, '$.')) > '0'||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) >= '0'||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) < 2||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) <= 2||to_json_string(json_query(agent, '$.')) + AND ('1'||to_json_string(json_query(agent, '$.')) <> '0'||to_json_string(json_query(agent, '$.'))) IS TRUE + AND ('1'||to_json_string(json_query(agent, '$.')) = '0'||to_json_string(json_query(agent, '$.'))) IS NOT TRUE + AND ('1'||to_json_string(json_query(agent, '$.')) = '0'||to_json_string(json_query(agent, '$.'))) IS FALSE + AND ('1'||to_json_string(json_query(agent, '$.')) <> '0'||to_json_string(json_query(agent, '$.'))) IS NOT FALSE + AND '1'||to_json_string(json_query(agent, '$.')) BETWEEN '0'||to_json_string(json_query(agent, '$.')) AND 2||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) NOT BETWEEN '1'||to_json_string(json_query(agent, '$.')) AND '0'||to_json_string(json_query(agent, '$.')) + AND '1'||to_json_string(json_query(agent, '$.')) like '%' + AND '1'||to_json_string(json_query(agent, '$.')) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(json_query(agent, '$.')) IN ('0'||to_json_string(json_query(agent, '$.')), + 1||to_json_string(json_query(agent, '$.')), + 2||to_json_string(json_query(agent, '$.'))) + AND '1'||to_json_string(json_query(agent, '$.')) NOT IN ('0'||to_json_string(json_query(agent, '$.')), + 2||to_json_string(json_query(agent, '$.'))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A5: json_query_array +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) IS NULL + OR ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) = 1||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) IS NOT DISTINCT + FROM 1||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) <> '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) IS DISTINCT + FROM '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) > '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) >= '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) < 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) <= 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) <> '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) IS TRUE + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) = '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) IS NOT TRUE + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) = '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) IS FALSE + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) <> '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) IS NOT FALSE + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) BETWEEN '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) AND 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) NOT BETWEEN '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) AND '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) like '%' + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) IN ('0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')), + 1||to_json_string(json_query_array(array[client_ip, server_ip], '$.')), + 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) NOT IN ('0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')), + 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) IS NULL + OR '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) IN + (SELECT '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) IS NULL + OR ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) = 1||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) IS NOT DISTINCT + FROM 1||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) <> '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) IS DISTINCT + FROM '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) > '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) >= '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) < 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) <= 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) <> '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) IS TRUE + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) = '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) IS NOT TRUE + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) = '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) IS FALSE + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) <> '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) IS NOT FALSE + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) BETWEEN '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) AND 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) NOT BETWEEN '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) AND '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) like '%' + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) IN ('0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')), + 1||to_json_string(json_query_array(array[client_ip, server_ip], '$.')), + 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) NOT IN ('0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')), + 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) IS NULL + OR ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) = 1||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) IS NOT DISTINCT + FROM 1||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) <> '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) IS DISTINCT + FROM '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) > '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) >= '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) < 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) <= 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) <> '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) IS TRUE + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) = '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) IS NOT TRUE + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) = '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) IS FALSE + AND ('1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) <> '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) IS NOT FALSE + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) BETWEEN '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) AND 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) NOT BETWEEN '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) AND '0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) like '%' + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) IN ('0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')), + 1||to_json_string(json_query_array(array[client_ip, server_ip], '$.')), + 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))) + AND '1'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')) NOT IN ('0'||to_json_string(json_query_array(array[client_ip, server_ip], '$.')), + 2||to_json_string(json_query_array(array[client_ip, server_ip], '$.'))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A6: json_value +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (('1'||json_value(agent, '$.type')) IS NULL + OR (('1'||json_value(agent, '$.type')) = (1||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) IS NOT DISTINCT + FROM (1||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) <> ('0'||json_value(agent, '$.type')) + AND (('1'||json_value(agent, '$.type')) IS DISTINCT + FROM ('0'||json_value(agent, '$.type'))) + AND ('1'||json_value(agent, '$.type')) > ('0'||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) >= ('0'||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) < (2||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) <= (2||json_value(agent, '$.type')) + AND (('1'||json_value(agent, '$.type')) <> ('0'||json_value(agent, '$.type'))) IS TRUE + AND (('1'||json_value(agent, '$.type')) = ('0'||json_value(agent, '$.type'))) IS NOT TRUE + AND (('1'||json_value(agent, '$.type')) = ('0'||json_value(agent, '$.type'))) IS FALSE + AND (('1'||json_value(agent, '$.type')) <> ('0'||json_value(agent, '$.type'))) IS NOT FALSE + AND ('1'||json_value(agent, '$.type')) BETWEEN ('0'||json_value(agent, '$.type')) AND (2||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) NOT BETWEEN ('1'||json_value(agent, '$.type')) AND ('0'||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) like '%' + AND ('1'||json_value(agent, '$.type')) not like '__DOES_NOT_EXIST__%' + AND ('1'||json_value(agent, '$.type')) IN (('0'||json_value(agent, '$.type')), (1||json_value(agent, '$.type')), (2||json_value(agent, '$.type'))) + AND ('1'||json_value(agent, '$.type')) NOT IN (('0'||json_value(agent, '$.type')), (2||json_value(agent, '$.type'))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (('1'||json_value(agent, '$.type')) IS NULL + OR ('1'||json_value(agent, '$.type')) IN + (SELECT ('1'||json_value(agent, '$.type')) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (('1'||json_value(agent, '$.type')) IS NULL + OR (('1'||json_value(agent, '$.type')) = (1||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) IS NOT DISTINCT + FROM (1||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) <> ('0'||json_value(agent, '$.type')) + AND (('1'||json_value(agent, '$.type')) IS DISTINCT + FROM ('0'||json_value(agent, '$.type'))) + AND ('1'||json_value(agent, '$.type')) > ('0'||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) >= ('0'||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) < (2||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) <= (2||json_value(agent, '$.type')) + AND (('1'||json_value(agent, '$.type')) <> ('0'||json_value(agent, '$.type'))) IS TRUE + AND (('1'||json_value(agent, '$.type')) = ('0'||json_value(agent, '$.type'))) IS NOT TRUE + AND (('1'||json_value(agent, '$.type')) = ('0'||json_value(agent, '$.type'))) IS FALSE + AND (('1'||json_value(agent, '$.type')) <> ('0'||json_value(agent, '$.type'))) IS NOT FALSE + AND ('1'||json_value(agent, '$.type')) BETWEEN ('0'||json_value(agent, '$.type')) AND (2||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) NOT BETWEEN ('1'||json_value(agent, '$.type')) AND ('0'||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) like '%' + AND ('1'||json_value(agent, '$.type')) not like '__DOES_NOT_EXIST__%' + AND ('1'||json_value(agent, '$.type')) IN (('0'||json_value(agent, '$.type')), (1||json_value(agent, '$.type')), (2||json_value(agent, '$.type'))) + AND ('1'||json_value(agent, '$.type')) NOT IN (('0'||json_value(agent, '$.type')), (2||json_value(agent, '$.type'))))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, ('1'||json_value(agent, '$.type')), count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (('1'||json_value(agent, '$.type')) IS NULL + OR (('1'||json_value(agent, '$.type')) = (1||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) IS NOT DISTINCT + FROM (1||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) <> ('0'||json_value(agent, '$.type')) + AND (('1'||json_value(agent, '$.type')) IS DISTINCT + FROM ('0'||json_value(agent, '$.type'))) + AND ('1'||json_value(agent, '$.type')) > ('0'||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) >= ('0'||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) < (2||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) <= (2||json_value(agent, '$.type')) + AND (('1'||json_value(agent, '$.type')) <> ('0'||json_value(agent, '$.type'))) IS TRUE + AND (('1'||json_value(agent, '$.type')) = ('0'||json_value(agent, '$.type'))) IS NOT TRUE + AND (('1'||json_value(agent, '$.type')) = ('0'||json_value(agent, '$.type'))) IS FALSE + AND (('1'||json_value(agent, '$.type')) <> ('0'||json_value(agent, '$.type'))) IS NOT FALSE + AND ('1'||json_value(agent, '$.type')) BETWEEN ('0'||json_value(agent, '$.type')) AND (2||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) NOT BETWEEN ('1'||json_value(agent, '$.type')) AND ('0'||json_value(agent, '$.type')) + AND ('1'||json_value(agent, '$.type')) like '%' + AND ('1'||json_value(agent, '$.type')) not like '__DOES_NOT_EXIST__%' + AND ('1'||json_value(agent, '$.type')) IN (('0'||json_value(agent, '$.type')), (1||json_value(agent, '$.type')), (2||json_value(agent, '$.type'))) + AND ('1'||json_value(agent, '$.type')) NOT IN (('0'||json_value(agent, '$.type')), (2||json_value(agent, '$.type'))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A7: json_value_returning_char +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||json_value(event, '$.percentage' RETURNING char) IS NULL + OR ('1'||json_value(event, '$.percentage' RETURNING char) = 1||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) IS NOT DISTINCT + FROM 1||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) <> '0'||json_value(event, '$.percentage' RETURNING char) + AND ('1'||json_value(event, '$.percentage' RETURNING char) IS DISTINCT + FROM '0'||json_value(event, '$.percentage' RETURNING char)) + AND '1'||json_value(event, '$.percentage' RETURNING char) > '0'||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) >= '0'||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) < 2||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) <= 2||json_value(event, '$.percentage' RETURNING char) + AND ('1'||json_value(event, '$.percentage' RETURNING char) <> '0'||json_value(event, '$.percentage' RETURNING char)) IS TRUE + AND ('1'||json_value(event, '$.percentage' RETURNING char) = '0'||json_value(event, '$.percentage' RETURNING char)) IS NOT TRUE + AND ('1'||json_value(event, '$.percentage' RETURNING char) = '0'||json_value(event, '$.percentage' RETURNING char)) IS FALSE + AND ('1'||json_value(event, '$.percentage' RETURNING char) <> '0'||json_value(event, '$.percentage' RETURNING char)) IS NOT FALSE + AND '1'||json_value(event, '$.percentage' RETURNING char) BETWEEN '0'||json_value(event, '$.percentage' RETURNING char) AND 2||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) NOT BETWEEN '1'||json_value(event, '$.percentage' RETURNING char) AND '0'||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) like '%' + AND '1'||json_value(event, '$.percentage' RETURNING char) not like '__DOES_NOT_EXIST__%' + AND '1'||json_value(event, '$.percentage' RETURNING char) IN ('0'||json_value(event, '$.percentage' RETURNING char), + 1||json_value(event, '$.percentage' RETURNING char), + 2||json_value(event, '$.percentage' RETURNING char)) + AND '1'||json_value(event, '$.percentage' RETURNING char) NOT IN ('0'||json_value(event, '$.percentage' RETURNING char), + 2||json_value(event, '$.percentage' RETURNING char)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||json_value(event, '$.percentage' RETURNING char) IS NULL + OR '1'||json_value(event, '$.percentage' RETURNING char) IN + (SELECT '1'||json_value(event, '$.percentage' RETURNING char) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||json_value(event, '$.percentage' RETURNING char) IS NULL + OR ('1'||json_value(event, '$.percentage' RETURNING char) = 1||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) IS NOT DISTINCT + FROM 1||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) <> '0'||json_value(event, '$.percentage' RETURNING char) + AND ('1'||json_value(event, '$.percentage' RETURNING char) IS DISTINCT + FROM '0'||json_value(event, '$.percentage' RETURNING char)) + AND '1'||json_value(event, '$.percentage' RETURNING char) > '0'||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) >= '0'||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) < 2||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) <= 2||json_value(event, '$.percentage' RETURNING char) + AND ('1'||json_value(event, '$.percentage' RETURNING char) <> '0'||json_value(event, '$.percentage' RETURNING char)) IS TRUE + AND ('1'||json_value(event, '$.percentage' RETURNING char) = '0'||json_value(event, '$.percentage' RETURNING char)) IS NOT TRUE + AND ('1'||json_value(event, '$.percentage' RETURNING char) = '0'||json_value(event, '$.percentage' RETURNING char)) IS FALSE + AND ('1'||json_value(event, '$.percentage' RETURNING char) <> '0'||json_value(event, '$.percentage' RETURNING char)) IS NOT FALSE + AND '1'||json_value(event, '$.percentage' RETURNING char) BETWEEN '0'||json_value(event, '$.percentage' RETURNING char) AND 2||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) NOT BETWEEN '1'||json_value(event, '$.percentage' RETURNING char) AND '0'||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) like '%' + AND '1'||json_value(event, '$.percentage' RETURNING char) not like '__DOES_NOT_EXIST__%' + AND '1'||json_value(event, '$.percentage' RETURNING char) IN ('0'||json_value(event, '$.percentage' RETURNING char), + 1||json_value(event, '$.percentage' RETURNING char), + 2||json_value(event, '$.percentage' RETURNING char)) + AND '1'||json_value(event, '$.percentage' RETURNING char) NOT IN ('0'||json_value(event, '$.percentage' RETURNING char), + 2||json_value(event, '$.percentage' RETURNING char)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||json_value(event, '$.percentage' RETURNING char), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||json_value(event, '$.percentage' RETURNING char) IS NULL + OR ('1'||json_value(event, '$.percentage' RETURNING char) = 1||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) IS NOT DISTINCT + FROM 1||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) <> '0'||json_value(event, '$.percentage' RETURNING char) + AND ('1'||json_value(event, '$.percentage' RETURNING char) IS DISTINCT + FROM '0'||json_value(event, '$.percentage' RETURNING char)) + AND '1'||json_value(event, '$.percentage' RETURNING char) > '0'||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) >= '0'||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) < 2||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) <= 2||json_value(event, '$.percentage' RETURNING char) + AND ('1'||json_value(event, '$.percentage' RETURNING char) <> '0'||json_value(event, '$.percentage' RETURNING char)) IS TRUE + AND ('1'||json_value(event, '$.percentage' RETURNING char) = '0'||json_value(event, '$.percentage' RETURNING char)) IS NOT TRUE + AND ('1'||json_value(event, '$.percentage' RETURNING char) = '0'||json_value(event, '$.percentage' RETURNING char)) IS FALSE + AND ('1'||json_value(event, '$.percentage' RETURNING char) <> '0'||json_value(event, '$.percentage' RETURNING char)) IS NOT FALSE + AND '1'||json_value(event, '$.percentage' RETURNING char) BETWEEN '0'||json_value(event, '$.percentage' RETURNING char) AND 2||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) NOT BETWEEN '1'||json_value(event, '$.percentage' RETURNING char) AND '0'||json_value(event, '$.percentage' RETURNING char) + AND '1'||json_value(event, '$.percentage' RETURNING char) like '%' + AND '1'||json_value(event, '$.percentage' RETURNING char) not like '__DOES_NOT_EXIST__%' + AND '1'||json_value(event, '$.percentage' RETURNING char) IN ('0'||json_value(event, '$.percentage' RETURNING char), + 1||json_value(event, '$.percentage' RETURNING char), + 2||json_value(event, '$.percentage' RETURNING char)) + AND '1'||json_value(event, '$.percentage' RETURNING char) NOT IN ('0'||json_value(event, '$.percentage' RETURNING char), + 2||json_value(event, '$.percentage' RETURNING char)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A8: json_value_returning_varchar +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) IS NULL + OR ('1'||json_value(event, '$.percentage' RETURNING varchar) = 1||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) IS NOT DISTINCT + FROM 1||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) <> '0'||json_value(event, '$.percentage' RETURNING varchar) + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) IS DISTINCT + FROM '0'||json_value(event, '$.percentage' RETURNING varchar)) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) > '0'||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) >= '0'||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) < 2||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) <= 2||json_value(event, '$.percentage' RETURNING varchar) + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) <> '0'||json_value(event, '$.percentage' RETURNING varchar)) IS TRUE + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) = '0'||json_value(event, '$.percentage' RETURNING varchar)) IS NOT TRUE + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) = '0'||json_value(event, '$.percentage' RETURNING varchar)) IS FALSE + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) <> '0'||json_value(event, '$.percentage' RETURNING varchar)) IS NOT FALSE + AND '1'||json_value(event, '$.percentage' RETURNING varchar) BETWEEN '0'||json_value(event, '$.percentage' RETURNING varchar) AND 2||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) NOT BETWEEN '1'||json_value(event, '$.percentage' RETURNING varchar) AND '0'||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) like '%' + AND '1'||json_value(event, '$.percentage' RETURNING varchar) not like '__DOES_NOT_EXIST__%' + AND '1'||json_value(event, '$.percentage' RETURNING varchar) IN ('0'||json_value(event, '$.percentage' RETURNING varchar), + 1||json_value(event, '$.percentage' RETURNING varchar), + 2||json_value(event, '$.percentage' RETURNING varchar)) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) NOT IN ('0'||json_value(event, '$.percentage' RETURNING varchar), + 2||json_value(event, '$.percentage' RETURNING varchar)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) IS NULL + OR '1'||json_value(event, '$.percentage' RETURNING varchar) IN + (SELECT '1'||json_value(event, '$.percentage' RETURNING varchar) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) IS NULL + OR ('1'||json_value(event, '$.percentage' RETURNING varchar) = 1||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) IS NOT DISTINCT + FROM 1||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) <> '0'||json_value(event, '$.percentage' RETURNING varchar) + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) IS DISTINCT + FROM '0'||json_value(event, '$.percentage' RETURNING varchar)) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) > '0'||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) >= '0'||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) < 2||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) <= 2||json_value(event, '$.percentage' RETURNING varchar) + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) <> '0'||json_value(event, '$.percentage' RETURNING varchar)) IS TRUE + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) = '0'||json_value(event, '$.percentage' RETURNING varchar)) IS NOT TRUE + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) = '0'||json_value(event, '$.percentage' RETURNING varchar)) IS FALSE + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) <> '0'||json_value(event, '$.percentage' RETURNING varchar)) IS NOT FALSE + AND '1'||json_value(event, '$.percentage' RETURNING varchar) BETWEEN '0'||json_value(event, '$.percentage' RETURNING varchar) AND 2||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) NOT BETWEEN '1'||json_value(event, '$.percentage' RETURNING varchar) AND '0'||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) like '%' + AND '1'||json_value(event, '$.percentage' RETURNING varchar) not like '__DOES_NOT_EXIST__%' + AND '1'||json_value(event, '$.percentage' RETURNING varchar) IN ('0'||json_value(event, '$.percentage' RETURNING varchar), + 1||json_value(event, '$.percentage' RETURNING varchar), + 2||json_value(event, '$.percentage' RETURNING varchar)) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) NOT IN ('0'||json_value(event, '$.percentage' RETURNING varchar), + 2||json_value(event, '$.percentage' RETURNING varchar)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||json_value(event, '$.percentage' RETURNING varchar), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) IS NULL + OR ('1'||json_value(event, '$.percentage' RETURNING varchar) = 1||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) IS NOT DISTINCT + FROM 1||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) <> '0'||json_value(event, '$.percentage' RETURNING varchar) + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) IS DISTINCT + FROM '0'||json_value(event, '$.percentage' RETURNING varchar)) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) > '0'||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) >= '0'||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) < 2||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) <= 2||json_value(event, '$.percentage' RETURNING varchar) + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) <> '0'||json_value(event, '$.percentage' RETURNING varchar)) IS TRUE + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) = '0'||json_value(event, '$.percentage' RETURNING varchar)) IS NOT TRUE + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) = '0'||json_value(event, '$.percentage' RETURNING varchar)) IS FALSE + AND ('1'||json_value(event, '$.percentage' RETURNING varchar) <> '0'||json_value(event, '$.percentage' RETURNING varchar)) IS NOT FALSE + AND '1'||json_value(event, '$.percentage' RETURNING varchar) BETWEEN '0'||json_value(event, '$.percentage' RETURNING varchar) AND 2||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) NOT BETWEEN '1'||json_value(event, '$.percentage' RETURNING varchar) AND '0'||json_value(event, '$.percentage' RETURNING varchar) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) like '%' + AND '1'||json_value(event, '$.percentage' RETURNING varchar) not like '__DOES_NOT_EXIST__%' + AND '1'||json_value(event, '$.percentage' RETURNING varchar) IN ('0'||json_value(event, '$.percentage' RETURNING varchar), + 1||json_value(event, '$.percentage' RETURNING varchar), + 2||json_value(event, '$.percentage' RETURNING varchar)) + AND '1'||json_value(event, '$.percentage' RETURNING varchar) NOT IN ('0'||json_value(event, '$.percentage' RETURNING varchar), + 2||json_value(event, '$.percentage' RETURNING varchar)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A9: json_value_returning_bigint +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (json_value(event, '$.percentage' RETURNING bigint)+1 IS NULL + OR (json_value(event, '$.percentage' RETURNING bigint)+1 = json_value(event, '$.percentage' RETURNING bigint)+1 + AND json_value(event, '$.percentage' RETURNING bigint)+1 IS NOT DISTINCT + FROM json_value(event, '$.percentage' RETURNING bigint)+1 + AND json_value(event, '$.percentage' RETURNING bigint)+1 <> json_value(event, '$.percentage' RETURNING bigint) + AND (json_value(event, '$.percentage' RETURNING bigint)+1 IS DISTINCT + FROM json_value(event, '$.percentage' RETURNING bigint)) + AND json_value(event, '$.percentage' RETURNING bigint)+1 > json_value(event, '$.percentage' RETURNING bigint) + AND json_value(event, '$.percentage' RETURNING bigint)+1 >= json_value(event, '$.percentage' RETURNING bigint) + AND json_value(event, '$.percentage' RETURNING bigint)+1 < json_value(event, '$.percentage' RETURNING bigint)+2 + AND json_value(event, '$.percentage' RETURNING bigint)+1 <= json_value(event, '$.percentage' RETURNING bigint)+2 + AND (json_value(event, '$.percentage' RETURNING bigint)+1 <> json_value(event, '$.percentage' RETURNING bigint)) IS TRUE + AND (json_value(event, '$.percentage' RETURNING bigint)+1 = json_value(event, '$.percentage' RETURNING bigint)) IS NOT TRUE + AND (json_value(event, '$.percentage' RETURNING bigint)+1 = json_value(event, '$.percentage' RETURNING bigint)) IS FALSE + AND (json_value(event, '$.percentage' RETURNING bigint)+1 <> json_value(event, '$.percentage' RETURNING bigint)) IS NOT FALSE + AND json_value(event, '$.percentage' RETURNING bigint)+1 BETWEEN json_value(event, '$.percentage' RETURNING bigint) AND json_value(event, '$.percentage' RETURNING bigint)+2 + AND json_value(event, '$.percentage' RETURNING bigint)+1 NOT BETWEEN json_value(event, '$.percentage' RETURNING bigint)+1 AND json_value(event, '$.percentage' RETURNING bigint) + AND json_value(event, '$.percentage' RETURNING bigint)+1 like '%' + AND json_value(event, '$.percentage' RETURNING bigint)+1 not like '__DOES_NOT_EXIST__%' + AND json_value(event, '$.percentage' RETURNING bigint)+1 IN (json_value(event, '$.percentage' RETURNING bigint), + json_value(event, '$.percentage' RETURNING bigint)+1, + json_value(event, '$.percentage' RETURNING bigint)+2) + AND json_value(event, '$.percentage' RETURNING bigint)+1 NOT IN (json_value(event, '$.percentage' RETURNING bigint), + json_value(event, '$.percentage' RETURNING bigint)+2))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (json_value(event, '$.percentage' RETURNING bigint)+1 IS NULL + OR json_value(event, '$.percentage' RETURNING bigint)+1 IN + (SELECT json_value(event, '$.percentage' RETURNING bigint)+1 + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (json_value(event, '$.percentage' RETURNING bigint)+1 IS NULL + OR (json_value(event, '$.percentage' RETURNING bigint)+1 = json_value(event, '$.percentage' RETURNING bigint)+1 + AND json_value(event, '$.percentage' RETURNING bigint)+1 IS NOT DISTINCT + FROM json_value(event, '$.percentage' RETURNING bigint)+1 + AND json_value(event, '$.percentage' RETURNING bigint)+1 <> json_value(event, '$.percentage' RETURNING bigint) + AND (json_value(event, '$.percentage' RETURNING bigint)+1 IS DISTINCT + FROM json_value(event, '$.percentage' RETURNING bigint)) + AND json_value(event, '$.percentage' RETURNING bigint)+1 > json_value(event, '$.percentage' RETURNING bigint) + AND json_value(event, '$.percentage' RETURNING bigint)+1 >= json_value(event, '$.percentage' RETURNING bigint) + AND json_value(event, '$.percentage' RETURNING bigint)+1 < json_value(event, '$.percentage' RETURNING bigint)+2 + AND json_value(event, '$.percentage' RETURNING bigint)+1 <= json_value(event, '$.percentage' RETURNING bigint)+2 + AND (json_value(event, '$.percentage' RETURNING bigint)+1 <> json_value(event, '$.percentage' RETURNING bigint)) IS TRUE + AND (json_value(event, '$.percentage' RETURNING bigint)+1 = json_value(event, '$.percentage' RETURNING bigint)) IS NOT TRUE + AND (json_value(event, '$.percentage' RETURNING bigint)+1 = json_value(event, '$.percentage' RETURNING bigint)) IS FALSE + AND (json_value(event, '$.percentage' RETURNING bigint)+1 <> json_value(event, '$.percentage' RETURNING bigint)) IS NOT FALSE + AND json_value(event, '$.percentage' RETURNING bigint)+1 BETWEEN json_value(event, '$.percentage' RETURNING bigint) AND json_value(event, '$.percentage' RETURNING bigint)+2 + AND json_value(event, '$.percentage' RETURNING bigint)+1 NOT BETWEEN json_value(event, '$.percentage' RETURNING bigint)+1 AND json_value(event, '$.percentage' RETURNING bigint) + AND json_value(event, '$.percentage' RETURNING bigint)+1 like '%' + AND json_value(event, '$.percentage' RETURNING bigint)+1 not like '__DOES_NOT_EXIST__%' + AND json_value(event, '$.percentage' RETURNING bigint)+1 IN (json_value(event, '$.percentage' RETURNING bigint), + json_value(event, '$.percentage' RETURNING bigint)+1, + json_value(event, '$.percentage' RETURNING bigint)+2) + AND json_value(event, '$.percentage' RETURNING bigint)+1 NOT IN (json_value(event, '$.percentage' RETURNING bigint), + json_value(event, '$.percentage' RETURNING bigint)+2))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + json_value(event, '$.percentage' RETURNING bigint)+1, + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (json_value(event, '$.percentage' RETURNING bigint)+1 IS NULL + OR (json_value(event, '$.percentage' RETURNING bigint)+1 = json_value(event, '$.percentage' RETURNING bigint)+1 + AND json_value(event, '$.percentage' RETURNING bigint)+1 IS NOT DISTINCT + FROM json_value(event, '$.percentage' RETURNING bigint)+1 + AND json_value(event, '$.percentage' RETURNING bigint)+1 <> json_value(event, '$.percentage' RETURNING bigint) + AND (json_value(event, '$.percentage' RETURNING bigint)+1 IS DISTINCT + FROM json_value(event, '$.percentage' RETURNING bigint)) + AND json_value(event, '$.percentage' RETURNING bigint)+1 > json_value(event, '$.percentage' RETURNING bigint) + AND json_value(event, '$.percentage' RETURNING bigint)+1 >= json_value(event, '$.percentage' RETURNING bigint) + AND json_value(event, '$.percentage' RETURNING bigint)+1 < json_value(event, '$.percentage' RETURNING bigint)+2 + AND json_value(event, '$.percentage' RETURNING bigint)+1 <= json_value(event, '$.percentage' RETURNING bigint)+2 + AND (json_value(event, '$.percentage' RETURNING bigint)+1 <> json_value(event, '$.percentage' RETURNING bigint)) IS TRUE + AND (json_value(event, '$.percentage' RETURNING bigint)+1 = json_value(event, '$.percentage' RETURNING bigint)) IS NOT TRUE + AND (json_value(event, '$.percentage' RETURNING bigint)+1 = json_value(event, '$.percentage' RETURNING bigint)) IS FALSE + AND (json_value(event, '$.percentage' RETURNING bigint)+1 <> json_value(event, '$.percentage' RETURNING bigint)) IS NOT FALSE + AND json_value(event, '$.percentage' RETURNING bigint)+1 BETWEEN json_value(event, '$.percentage' RETURNING bigint) AND json_value(event, '$.percentage' RETURNING bigint)+2 + AND json_value(event, '$.percentage' RETURNING bigint)+1 NOT BETWEEN json_value(event, '$.percentage' RETURNING bigint)+1 AND json_value(event, '$.percentage' RETURNING bigint) + AND json_value(event, '$.percentage' RETURNING bigint)+1 like '%' + AND json_value(event, '$.percentage' RETURNING bigint)+1 not like '__DOES_NOT_EXIST__%' + AND json_value(event, '$.percentage' RETURNING bigint)+1 IN (json_value(event, '$.percentage' RETURNING bigint), + json_value(event, '$.percentage' RETURNING bigint)+1, + json_value(event, '$.percentage' RETURNING bigint)+2) + AND json_value(event, '$.percentage' RETURNING bigint)+1 NOT IN (json_value(event, '$.percentage' RETURNING bigint), + json_value(event, '$.percentage' RETURNING bigint)+2))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A10: json_value_returning_double +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 IS NULL + OR (json_value(event, '$.percentage' RETURNING DOUBLE)+1 = json_value(event, '$.percentage' RETURNING DOUBLE)+1 + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 IS NOT DISTINCT + FROM json_value(event, '$.percentage' RETURNING DOUBLE)+1 + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 <> json_value(event, '$.percentage' RETURNING DOUBLE) + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 IS DISTINCT + FROM json_value(event, '$.percentage' RETURNING DOUBLE)) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 > json_value(event, '$.percentage' RETURNING DOUBLE) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 >= json_value(event, '$.percentage' RETURNING DOUBLE) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 < json_value(event, '$.percentage' RETURNING DOUBLE)+2 + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 <= json_value(event, '$.percentage' RETURNING DOUBLE)+2 + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 <> json_value(event, '$.percentage' RETURNING DOUBLE)) IS TRUE + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 = json_value(event, '$.percentage' RETURNING DOUBLE)) IS NOT TRUE + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 = json_value(event, '$.percentage' RETURNING DOUBLE)) IS FALSE + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 <> json_value(event, '$.percentage' RETURNING DOUBLE)) IS NOT FALSE + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 BETWEEN json_value(event, '$.percentage' RETURNING DOUBLE) AND json_value(event, '$.percentage' RETURNING DOUBLE)+2 + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 NOT BETWEEN json_value(event, '$.percentage' RETURNING DOUBLE)+1 AND json_value(event, '$.percentage' RETURNING DOUBLE) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 like '%' + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 not like '__DOES_NOT_EXIST__%' + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 IN (json_value(event, '$.percentage' RETURNING DOUBLE), + json_value(event, '$.percentage' RETURNING DOUBLE)+1, + json_value(event, '$.percentage' RETURNING DOUBLE)+2) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 NOT IN (json_value(event, '$.percentage' RETURNING DOUBLE), + json_value(event, '$.percentage' RETURNING DOUBLE)+2))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 IS NULL + OR json_value(event, '$.percentage' RETURNING DOUBLE)+1 IN + (SELECT json_value(event, '$.percentage' RETURNING DOUBLE)+1 + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 IS NULL + OR (json_value(event, '$.percentage' RETURNING DOUBLE)+1 = json_value(event, '$.percentage' RETURNING DOUBLE)+1 + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 IS NOT DISTINCT + FROM json_value(event, '$.percentage' RETURNING DOUBLE)+1 + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 <> json_value(event, '$.percentage' RETURNING DOUBLE) + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 IS DISTINCT + FROM json_value(event, '$.percentage' RETURNING DOUBLE)) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 > json_value(event, '$.percentage' RETURNING DOUBLE) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 >= json_value(event, '$.percentage' RETURNING DOUBLE) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 < json_value(event, '$.percentage' RETURNING DOUBLE)+2 + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 <= json_value(event, '$.percentage' RETURNING DOUBLE)+2 + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 <> json_value(event, '$.percentage' RETURNING DOUBLE)) IS TRUE + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 = json_value(event, '$.percentage' RETURNING DOUBLE)) IS NOT TRUE + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 = json_value(event, '$.percentage' RETURNING DOUBLE)) IS FALSE + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 <> json_value(event, '$.percentage' RETURNING DOUBLE)) IS NOT FALSE + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 BETWEEN json_value(event, '$.percentage' RETURNING DOUBLE) AND json_value(event, '$.percentage' RETURNING DOUBLE)+2 + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 NOT BETWEEN json_value(event, '$.percentage' RETURNING DOUBLE)+1 AND json_value(event, '$.percentage' RETURNING DOUBLE) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 like '%' + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 not like '__DOES_NOT_EXIST__%' + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 IN (json_value(event, '$.percentage' RETURNING DOUBLE), + json_value(event, '$.percentage' RETURNING DOUBLE)+1, + json_value(event, '$.percentage' RETURNING DOUBLE)+2) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 NOT IN (json_value(event, '$.percentage' RETURNING DOUBLE), + json_value(event, '$.percentage' RETURNING DOUBLE)+2))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + json_value(event, '$.percentage' RETURNING DOUBLE)+1, + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 IS NULL + OR (json_value(event, '$.percentage' RETURNING DOUBLE)+1 = json_value(event, '$.percentage' RETURNING DOUBLE)+1 + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 IS NOT DISTINCT + FROM json_value(event, '$.percentage' RETURNING DOUBLE)+1 + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 <> json_value(event, '$.percentage' RETURNING DOUBLE) + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 IS DISTINCT + FROM json_value(event, '$.percentage' RETURNING DOUBLE)) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 > json_value(event, '$.percentage' RETURNING DOUBLE) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 >= json_value(event, '$.percentage' RETURNING DOUBLE) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 < json_value(event, '$.percentage' RETURNING DOUBLE)+2 + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 <= json_value(event, '$.percentage' RETURNING DOUBLE)+2 + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 <> json_value(event, '$.percentage' RETURNING DOUBLE)) IS TRUE + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 = json_value(event, '$.percentage' RETURNING DOUBLE)) IS NOT TRUE + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 = json_value(event, '$.percentage' RETURNING DOUBLE)) IS FALSE + AND (json_value(event, '$.percentage' RETURNING DOUBLE)+1 <> json_value(event, '$.percentage' RETURNING DOUBLE)) IS NOT FALSE + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 BETWEEN json_value(event, '$.percentage' RETURNING DOUBLE) AND json_value(event, '$.percentage' RETURNING DOUBLE)+2 + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 NOT BETWEEN json_value(event, '$.percentage' RETURNING DOUBLE)+1 AND json_value(event, '$.percentage' RETURNING DOUBLE) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 like '%' + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 not like '__DOES_NOT_EXIST__%' + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 IN (json_value(event, '$.percentage' RETURNING DOUBLE), + json_value(event, '$.percentage' RETURNING DOUBLE)+1, + json_value(event, '$.percentage' RETURNING DOUBLE)+2) + AND json_value(event, '$.percentage' RETURNING DOUBLE)+1 NOT IN (json_value(event, '$.percentage' RETURNING DOUBLE), + json_value(event, '$.percentage' RETURNING DOUBLE)+2))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A11: json_value_returning_timestamp +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR IS NULL + OR (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR = json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR IS NOT DISTINCT + FROM json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR <> json_value(event, '$.percentage' RETURNING timestamp) + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR IS DISTINCT + FROM json_value(event, '$.percentage' RETURNING timestamp)) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR > json_value(event, '$.percentage' RETURNING timestamp) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR >= json_value(event, '$.percentage' RETURNING timestamp) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR < json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR <= json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR <> json_value(event, '$.percentage' RETURNING timestamp)) IS TRUE + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR = json_value(event, '$.percentage' RETURNING timestamp)) IS NOT TRUE + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR = json_value(event, '$.percentage' RETURNING timestamp)) IS FALSE + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR <> json_value(event, '$.percentage' RETURNING timestamp)) IS NOT FALSE + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR BETWEEN json_value(event, '$.percentage' RETURNING timestamp) AND json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR NOT BETWEEN json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR AND json_value(event, '$.percentage' RETURNING timestamp) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR like '%' + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR not like '__DOES_NOT_EXIST__%' + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR IN (json_value(event, '$.percentage' RETURNING timestamp), + json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR, + json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR NOT IN (json_value(event, '$.percentage' RETURNING timestamp), + json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR IS NULL + OR json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR IN + (SELECT json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR IS NULL + OR (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR = json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR IS NOT DISTINCT + FROM json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR <> json_value(event, '$.percentage' RETURNING timestamp) + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR IS DISTINCT + FROM json_value(event, '$.percentage' RETURNING timestamp)) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR > json_value(event, '$.percentage' RETURNING timestamp) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR >= json_value(event, '$.percentage' RETURNING timestamp) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR < json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR <= json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR <> json_value(event, '$.percentage' RETURNING timestamp)) IS TRUE + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR = json_value(event, '$.percentage' RETURNING timestamp)) IS NOT TRUE + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR = json_value(event, '$.percentage' RETURNING timestamp)) IS FALSE + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR <> json_value(event, '$.percentage' RETURNING timestamp)) IS NOT FALSE + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR BETWEEN json_value(event, '$.percentage' RETURNING timestamp) AND json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR NOT BETWEEN json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR AND json_value(event, '$.percentage' RETURNING timestamp) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR like '%' + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR not like '__DOES_NOT_EXIST__%' + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR IN (json_value(event, '$.percentage' RETURNING timestamp), + json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR, + json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR NOT IN (json_value(event, '$.percentage' RETURNING timestamp), + json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR, + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR IS NULL + OR (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR = json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR IS NOT DISTINCT + FROM json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR <> json_value(event, '$.percentage' RETURNING timestamp) + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR IS DISTINCT + FROM json_value(event, '$.percentage' RETURNING timestamp)) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR > json_value(event, '$.percentage' RETURNING timestamp) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR >= json_value(event, '$.percentage' RETURNING timestamp) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR < json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR <= json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR <> json_value(event, '$.percentage' RETURNING timestamp)) IS TRUE + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR = json_value(event, '$.percentage' RETURNING timestamp)) IS NOT TRUE + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR = json_value(event, '$.percentage' RETURNING timestamp)) IS FALSE + AND (json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR <> json_value(event, '$.percentage' RETURNING timestamp)) IS NOT FALSE + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR BETWEEN json_value(event, '$.percentage' RETURNING timestamp) AND json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR NOT BETWEEN json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR AND json_value(event, '$.percentage' RETURNING timestamp) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR like '%' + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR not like '__DOES_NOT_EXIST__%' + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR IN (json_value(event, '$.percentage' RETURNING timestamp), + json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR, + json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR) + AND json_value(event, '$.percentage' RETURNING timestamp)+interval '1' YEAR NOT IN (json_value(event, '$.percentage' RETURNING timestamp), + json_value(event, '$.percentage' RETURNING timestamp)+interval '2' YEAR))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A12: parse_json +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(parse_json(to_json_string(agent))) IS NULL + OR ('1'||to_json_string(parse_json(to_json_string(agent))) = 1||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) IS NOT DISTINCT + FROM 1||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) <> '0'||to_json_string(parse_json(to_json_string(agent))) + AND ('1'||to_json_string(parse_json(to_json_string(agent))) IS DISTINCT + FROM '0'||to_json_string(parse_json(to_json_string(agent)))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) > '0'||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) >= '0'||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) < 2||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) <= 2||to_json_string(parse_json(to_json_string(agent))) + AND ('1'||to_json_string(parse_json(to_json_string(agent))) <> '0'||to_json_string(parse_json(to_json_string(agent)))) IS TRUE + AND ('1'||to_json_string(parse_json(to_json_string(agent))) = '0'||to_json_string(parse_json(to_json_string(agent)))) IS NOT TRUE + AND ('1'||to_json_string(parse_json(to_json_string(agent))) = '0'||to_json_string(parse_json(to_json_string(agent)))) IS FALSE + AND ('1'||to_json_string(parse_json(to_json_string(agent))) <> '0'||to_json_string(parse_json(to_json_string(agent)))) IS NOT FALSE + AND '1'||to_json_string(parse_json(to_json_string(agent))) BETWEEN '0'||to_json_string(parse_json(to_json_string(agent))) AND 2||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) NOT BETWEEN '1'||to_json_string(parse_json(to_json_string(agent))) AND '0'||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) like '%' + AND '1'||to_json_string(parse_json(to_json_string(agent))) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(parse_json(to_json_string(agent))) IN ('0'||to_json_string(parse_json(to_json_string(agent))), + 1||to_json_string(parse_json(to_json_string(agent))), + 2||to_json_string(parse_json(to_json_string(agent)))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) NOT IN ('0'||to_json_string(parse_json(to_json_string(agent))), + 2||to_json_string(parse_json(to_json_string(agent)))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(parse_json(to_json_string(agent))) IS NULL + OR '1'||to_json_string(parse_json(to_json_string(agent))) IN + (SELECT '1'||to_json_string(parse_json(to_json_string(agent))) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(parse_json(to_json_string(agent))) IS NULL + OR ('1'||to_json_string(parse_json(to_json_string(agent))) = 1||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) IS NOT DISTINCT + FROM 1||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) <> '0'||to_json_string(parse_json(to_json_string(agent))) + AND ('1'||to_json_string(parse_json(to_json_string(agent))) IS DISTINCT + FROM '0'||to_json_string(parse_json(to_json_string(agent)))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) > '0'||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) >= '0'||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) < 2||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) <= 2||to_json_string(parse_json(to_json_string(agent))) + AND ('1'||to_json_string(parse_json(to_json_string(agent))) <> '0'||to_json_string(parse_json(to_json_string(agent)))) IS TRUE + AND ('1'||to_json_string(parse_json(to_json_string(agent))) = '0'||to_json_string(parse_json(to_json_string(agent)))) IS NOT TRUE + AND ('1'||to_json_string(parse_json(to_json_string(agent))) = '0'||to_json_string(parse_json(to_json_string(agent)))) IS FALSE + AND ('1'||to_json_string(parse_json(to_json_string(agent))) <> '0'||to_json_string(parse_json(to_json_string(agent)))) IS NOT FALSE + AND '1'||to_json_string(parse_json(to_json_string(agent))) BETWEEN '0'||to_json_string(parse_json(to_json_string(agent))) AND 2||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) NOT BETWEEN '1'||to_json_string(parse_json(to_json_string(agent))) AND '0'||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) like '%' + AND '1'||to_json_string(parse_json(to_json_string(agent))) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(parse_json(to_json_string(agent))) IN ('0'||to_json_string(parse_json(to_json_string(agent))), + 1||to_json_string(parse_json(to_json_string(agent))), + 2||to_json_string(parse_json(to_json_string(agent)))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) NOT IN ('0'||to_json_string(parse_json(to_json_string(agent))), + 2||to_json_string(parse_json(to_json_string(agent)))))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||to_json_string(parse_json(to_json_string(agent))), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(parse_json(to_json_string(agent))) IS NULL + OR ('1'||to_json_string(parse_json(to_json_string(agent))) = 1||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) IS NOT DISTINCT + FROM 1||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) <> '0'||to_json_string(parse_json(to_json_string(agent))) + AND ('1'||to_json_string(parse_json(to_json_string(agent))) IS DISTINCT + FROM '0'||to_json_string(parse_json(to_json_string(agent)))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) > '0'||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) >= '0'||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) < 2||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) <= 2||to_json_string(parse_json(to_json_string(agent))) + AND ('1'||to_json_string(parse_json(to_json_string(agent))) <> '0'||to_json_string(parse_json(to_json_string(agent)))) IS TRUE + AND ('1'||to_json_string(parse_json(to_json_string(agent))) = '0'||to_json_string(parse_json(to_json_string(agent)))) IS NOT TRUE + AND ('1'||to_json_string(parse_json(to_json_string(agent))) = '0'||to_json_string(parse_json(to_json_string(agent)))) IS FALSE + AND ('1'||to_json_string(parse_json(to_json_string(agent))) <> '0'||to_json_string(parse_json(to_json_string(agent)))) IS NOT FALSE + AND '1'||to_json_string(parse_json(to_json_string(agent))) BETWEEN '0'||to_json_string(parse_json(to_json_string(agent))) AND 2||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) NOT BETWEEN '1'||to_json_string(parse_json(to_json_string(agent))) AND '0'||to_json_string(parse_json(to_json_string(agent))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) like '%' + AND '1'||to_json_string(parse_json(to_json_string(agent))) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(parse_json(to_json_string(agent))) IN ('0'||to_json_string(parse_json(to_json_string(agent))), + 1||to_json_string(parse_json(to_json_string(agent))), + 2||to_json_string(parse_json(to_json_string(agent)))) + AND '1'||to_json_string(parse_json(to_json_string(agent))) NOT IN ('0'||to_json_string(parse_json(to_json_string(agent))), + 2||to_json_string(parse_json(to_json_string(agent)))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A13: try_parse_json +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) IS NULL + OR ('1'||to_json_string(try_parse_json(to_json_string(agent))) = 1||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) IS NOT DISTINCT + FROM 1||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) <> '0'||to_json_string(try_parse_json(to_json_string(agent))) + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) IS DISTINCT + FROM '0'||to_json_string(try_parse_json(to_json_string(agent)))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) > '0'||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) >= '0'||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) < 2||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) <= 2||to_json_string(try_parse_json(to_json_string(agent))) + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) <> '0'||to_json_string(try_parse_json(to_json_string(agent)))) IS TRUE + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) = '0'||to_json_string(try_parse_json(to_json_string(agent)))) IS NOT TRUE + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) = '0'||to_json_string(try_parse_json(to_json_string(agent)))) IS FALSE + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) <> '0'||to_json_string(try_parse_json(to_json_string(agent)))) IS NOT FALSE + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) BETWEEN '0'||to_json_string(try_parse_json(to_json_string(agent))) AND 2||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) NOT BETWEEN '1'||to_json_string(try_parse_json(to_json_string(agent))) AND '0'||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) like '%' + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) IN ('0'||to_json_string(try_parse_json(to_json_string(agent))), + 1||to_json_string(try_parse_json(to_json_string(agent))), + 2||to_json_string(try_parse_json(to_json_string(agent)))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) NOT IN ('0'||to_json_string(try_parse_json(to_json_string(agent))), + 2||to_json_string(try_parse_json(to_json_string(agent)))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) IS NULL + OR '1'||to_json_string(try_parse_json(to_json_string(agent))) IN + (SELECT '1'||to_json_string(try_parse_json(to_json_string(agent))) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) IS NULL + OR ('1'||to_json_string(try_parse_json(to_json_string(agent))) = 1||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) IS NOT DISTINCT + FROM 1||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) <> '0'||to_json_string(try_parse_json(to_json_string(agent))) + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) IS DISTINCT + FROM '0'||to_json_string(try_parse_json(to_json_string(agent)))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) > '0'||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) >= '0'||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) < 2||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) <= 2||to_json_string(try_parse_json(to_json_string(agent))) + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) <> '0'||to_json_string(try_parse_json(to_json_string(agent)))) IS TRUE + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) = '0'||to_json_string(try_parse_json(to_json_string(agent)))) IS NOT TRUE + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) = '0'||to_json_string(try_parse_json(to_json_string(agent)))) IS FALSE + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) <> '0'||to_json_string(try_parse_json(to_json_string(agent)))) IS NOT FALSE + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) BETWEEN '0'||to_json_string(try_parse_json(to_json_string(agent))) AND 2||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) NOT BETWEEN '1'||to_json_string(try_parse_json(to_json_string(agent))) AND '0'||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) like '%' + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) IN ('0'||to_json_string(try_parse_json(to_json_string(agent))), + 1||to_json_string(try_parse_json(to_json_string(agent))), + 2||to_json_string(try_parse_json(to_json_string(agent)))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) NOT IN ('0'||to_json_string(try_parse_json(to_json_string(agent))), + 2||to_json_string(try_parse_json(to_json_string(agent)))))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||to_json_string(try_parse_json(to_json_string(agent))), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) IS NULL + OR ('1'||to_json_string(try_parse_json(to_json_string(agent))) = 1||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) IS NOT DISTINCT + FROM 1||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) <> '0'||to_json_string(try_parse_json(to_json_string(agent))) + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) IS DISTINCT + FROM '0'||to_json_string(try_parse_json(to_json_string(agent)))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) > '0'||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) >= '0'||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) < 2||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) <= 2||to_json_string(try_parse_json(to_json_string(agent))) + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) <> '0'||to_json_string(try_parse_json(to_json_string(agent)))) IS TRUE + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) = '0'||to_json_string(try_parse_json(to_json_string(agent)))) IS NOT TRUE + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) = '0'||to_json_string(try_parse_json(to_json_string(agent)))) IS FALSE + AND ('1'||to_json_string(try_parse_json(to_json_string(agent))) <> '0'||to_json_string(try_parse_json(to_json_string(agent)))) IS NOT FALSE + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) BETWEEN '0'||to_json_string(try_parse_json(to_json_string(agent))) AND 2||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) NOT BETWEEN '1'||to_json_string(try_parse_json(to_json_string(agent))) AND '0'||to_json_string(try_parse_json(to_json_string(agent))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) like '%' + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) IN ('0'||to_json_string(try_parse_json(to_json_string(agent))), + 1||to_json_string(try_parse_json(to_json_string(agent))), + 2||to_json_string(try_parse_json(to_json_string(agent)))) + AND '1'||to_json_string(try_parse_json(to_json_string(agent))) NOT IN ('0'||to_json_string(try_parse_json(to_json_string(agent))), + 2||to_json_string(try_parse_json(to_json_string(agent)))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A14: to_json_string +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(agent) IS NULL + OR ('1'||to_json_string(agent) = 1||to_json_string(agent) + AND '1'||to_json_string(agent) IS NOT DISTINCT + FROM 1||to_json_string(agent) + AND '1'||to_json_string(agent) <> '0'||to_json_string(agent) + AND ('1'||to_json_string(agent) IS DISTINCT + FROM '0'||to_json_string(agent)) + AND '1'||to_json_string(agent) > '0'||to_json_string(agent) + AND '1'||to_json_string(agent) >= '0'||to_json_string(agent) + AND '1'||to_json_string(agent) < 2||to_json_string(agent) + AND '1'||to_json_string(agent) <= 2||to_json_string(agent) + AND ('1'||to_json_string(agent) <> '0'||to_json_string(agent)) IS TRUE + AND ('1'||to_json_string(agent) = '0'||to_json_string(agent)) IS NOT TRUE + AND ('1'||to_json_string(agent) = '0'||to_json_string(agent)) IS FALSE + AND ('1'||to_json_string(agent) <> '0'||to_json_string(agent)) IS NOT FALSE + AND '1'||to_json_string(agent) BETWEEN '0'||to_json_string(agent) AND 2||to_json_string(agent) + AND '1'||to_json_string(agent) NOT BETWEEN '1'||to_json_string(agent) AND '0'||to_json_string(agent) + AND '1'||to_json_string(agent) like '%' + AND '1'||to_json_string(agent) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(agent) IN ('0'||to_json_string(agent), + 1||to_json_string(agent), + 2||to_json_string(agent)) + AND '1'||to_json_string(agent) NOT IN ('0'||to_json_string(agent), + 2||to_json_string(agent)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(agent) IS NULL + OR '1'||to_json_string(agent) IN + (SELECT '1'||to_json_string(agent) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(agent) IS NULL + OR ('1'||to_json_string(agent) = 1||to_json_string(agent) + AND '1'||to_json_string(agent) IS NOT DISTINCT + FROM 1||to_json_string(agent) + AND '1'||to_json_string(agent) <> '0'||to_json_string(agent) + AND ('1'||to_json_string(agent) IS DISTINCT + FROM '0'||to_json_string(agent)) + AND '1'||to_json_string(agent) > '0'||to_json_string(agent) + AND '1'||to_json_string(agent) >= '0'||to_json_string(agent) + AND '1'||to_json_string(agent) < 2||to_json_string(agent) + AND '1'||to_json_string(agent) <= 2||to_json_string(agent) + AND ('1'||to_json_string(agent) <> '0'||to_json_string(agent)) IS TRUE + AND ('1'||to_json_string(agent) = '0'||to_json_string(agent)) IS NOT TRUE + AND ('1'||to_json_string(agent) = '0'||to_json_string(agent)) IS FALSE + AND ('1'||to_json_string(agent) <> '0'||to_json_string(agent)) IS NOT FALSE + AND '1'||to_json_string(agent) BETWEEN '0'||to_json_string(agent) AND 2||to_json_string(agent) + AND '1'||to_json_string(agent) NOT BETWEEN '1'||to_json_string(agent) AND '0'||to_json_string(agent) + AND '1'||to_json_string(agent) like '%' + AND '1'||to_json_string(agent) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(agent) IN ('0'||to_json_string(agent), + 1||to_json_string(agent), + 2||to_json_string(agent)) + AND '1'||to_json_string(agent) NOT IN ('0'||to_json_string(agent), + 2||to_json_string(agent)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||to_json_string(agent), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(agent) IS NULL + OR ('1'||to_json_string(agent) = 1||to_json_string(agent) + AND '1'||to_json_string(agent) IS NOT DISTINCT + FROM 1||to_json_string(agent) + AND '1'||to_json_string(agent) <> '0'||to_json_string(agent) + AND ('1'||to_json_string(agent) IS DISTINCT + FROM '0'||to_json_string(agent)) + AND '1'||to_json_string(agent) > '0'||to_json_string(agent) + AND '1'||to_json_string(agent) >= '0'||to_json_string(agent) + AND '1'||to_json_string(agent) < 2||to_json_string(agent) + AND '1'||to_json_string(agent) <= 2||to_json_string(agent) + AND ('1'||to_json_string(agent) <> '0'||to_json_string(agent)) IS TRUE + AND ('1'||to_json_string(agent) = '0'||to_json_string(agent)) IS NOT TRUE + AND ('1'||to_json_string(agent) = '0'||to_json_string(agent)) IS FALSE + AND ('1'||to_json_string(agent) <> '0'||to_json_string(agent)) IS NOT FALSE + AND '1'||to_json_string(agent) BETWEEN '0'||to_json_string(agent) AND 2||to_json_string(agent) + AND '1'||to_json_string(agent) NOT BETWEEN '1'||to_json_string(agent) AND '0'||to_json_string(agent) + AND '1'||to_json_string(agent) like '%' + AND '1'||to_json_string(agent) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(agent) IN ('0'||to_json_string(agent), + 1||to_json_string(agent), + 2||to_json_string(agent)) + AND '1'||to_json_string(agent) NOT IN ('0'||to_json_string(agent), + 2||to_json_string(agent)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# Total query count 41 +#------------------------------------------------------------------------- diff --git a/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_mv.iq b/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_mv.iq new file mode 100644 index 00000000000..575c64c57f5 --- /dev/null +++ b/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_mv.iq @@ -0,0 +1,2746 @@ +!set useApproximateCountDistinct false +!use druidtest:///?componentSupplier=KttmNestedComponentSupplier +!set outputformat mysql +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00'; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A1: mv_filter_only +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') IS NULL + OR ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') = 1||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') > '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') >= '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') < 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') <= 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) IS TRUE + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') = '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') = '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) IS FALSE + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') BETWEEN '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') AND 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') NOT BETWEEN '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') AND '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') like '%' + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') IN ('0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ','), + 1||mv_to_string(mv_filter_only("language", mv_to_array("language")), ','), + 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') NOT IN ('0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ','), + 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') IS NULL + OR '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') IN + (SELECT '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') IS NULL + OR ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') = 1||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') > '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') >= '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') < 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') <= 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) IS TRUE + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') = '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') = '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) IS FALSE + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') BETWEEN '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') AND 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') NOT BETWEEN '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') AND '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') like '%' + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') IN ('0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ','), + 1||mv_to_string(mv_filter_only("language", mv_to_array("language")), ','), + 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') NOT IN ('0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ','), + 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ','), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') IS NULL + OR ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') = 1||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') > '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') >= '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') < 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') <= 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) IS TRUE + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') = '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') = '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) IS FALSE + AND ('1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') BETWEEN '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') AND 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') NOT BETWEEN '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') AND '0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') like '%' + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') IN ('0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ','), + 1||mv_to_string(mv_filter_only("language", mv_to_array("language")), ','), + 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')) + AND '1'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',') NOT IN ('0'||mv_to_string(mv_filter_only("language", mv_to_array("language")), ','), + 2||mv_to_string(mv_filter_only("language", mv_to_array("language")), ',')))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A2: mv_filter_none +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') IS NULL + OR ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') = 1||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') > '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') >= '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') < 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') <= 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) IS TRUE + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') = '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') = '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) IS FALSE + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') BETWEEN '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') AND 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') NOT BETWEEN '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') AND '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') like '%' + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') IN ('0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ','), + 1||mv_to_string(mv_filter_none("language", mv_to_array("language")), ','), + 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') NOT IN ('0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ','), + 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') IS NULL + OR '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') IN + (SELECT '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') IS NULL + OR ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') = 1||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') > '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') >= '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') < 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') <= 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) IS TRUE + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') = '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') = '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) IS FALSE + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') BETWEEN '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') AND 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') NOT BETWEEN '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') AND '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') like '%' + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') IN ('0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ','), + 1||mv_to_string(mv_filter_none("language", mv_to_array("language")), ','), + 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') NOT IN ('0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ','), + 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ','), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') IS NULL + OR ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') = 1||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') > '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') >= '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') < 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') <= 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) IS TRUE + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') = '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') = '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) IS FALSE + AND ('1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') <> '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') BETWEEN '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') AND 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') NOT BETWEEN '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') AND '0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') like '%' + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') IN ('0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ','), + 1||mv_to_string(mv_filter_none("language", mv_to_array("language")), ','), + 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')) + AND '1'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',') NOT IN ('0'||mv_to_string(mv_filter_none("language", mv_to_array("language")), ','), + 2||mv_to_string(mv_filter_none("language", mv_to_array("language")), ',')))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A3: mv_length +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (mv_length("language")+1 IS NULL + OR (mv_length("language")+1 = mv_length("language")+1 + AND mv_length("language")+1 IS NOT DISTINCT + FROM mv_length("language")+1 + AND mv_length("language")+1 <> mv_length("language")+0 + AND (mv_length("language")+1 IS DISTINCT + FROM mv_length("language")+0) + AND mv_length("language")+1 > mv_length("language")+0 + AND mv_length("language")+1 >= mv_length("language")+0 + AND mv_length("language")+1 < mv_length("language")+2 + AND mv_length("language")+1 <= mv_length("language")+2 + AND (mv_length("language")+1 <> mv_length("language")+0) IS TRUE + AND (mv_length("language")+1 = mv_length("language")+0) IS NOT TRUE + AND (mv_length("language")+1 = mv_length("language")+0) IS FALSE + AND (mv_length("language")+1 <> mv_length("language")+0) IS NOT FALSE + AND mv_length("language")+1 BETWEEN mv_length("language")+0 AND mv_length("language")+2 + AND mv_length("language")+1 NOT BETWEEN mv_length("language")+1 AND mv_length("language")+0 + AND mv_length("language")+1 like '%' + AND mv_length("language")+1 not like '__DOES_NOT_EXIST__%' + AND mv_length("language")+1 IN (mv_length("language")+0, + mv_length("language")+1, + mv_length("language")+2) + AND mv_length("language")+1 NOT IN (mv_length("language")+0, + mv_length("language")+2))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (mv_length("language")+1 IS NULL + OR mv_length("language")+1 IN + (SELECT mv_length("language")+1 + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (mv_length("language")+1 IS NULL + OR (mv_length("language")+1 = mv_length("language")+1 + AND mv_length("language")+1 IS NOT DISTINCT + FROM mv_length("language")+1 + AND mv_length("language")+1 <> mv_length("language")+0 + AND (mv_length("language")+1 IS DISTINCT + FROM mv_length("language")+0) + AND mv_length("language")+1 > mv_length("language")+0 + AND mv_length("language")+1 >= mv_length("language")+0 + AND mv_length("language")+1 < mv_length("language")+2 + AND mv_length("language")+1 <= mv_length("language")+2 + AND (mv_length("language")+1 <> mv_length("language")+0) IS TRUE + AND (mv_length("language")+1 = mv_length("language")+0) IS NOT TRUE + AND (mv_length("language")+1 = mv_length("language")+0) IS FALSE + AND (mv_length("language")+1 <> mv_length("language")+0) IS NOT FALSE + AND mv_length("language")+1 BETWEEN mv_length("language")+0 AND mv_length("language")+2 + AND mv_length("language")+1 NOT BETWEEN mv_length("language")+1 AND mv_length("language")+0 + AND mv_length("language")+1 like '%' + AND mv_length("language")+1 not like '__DOES_NOT_EXIST__%' + AND mv_length("language")+1 IN (mv_length("language")+0, + mv_length("language")+1, + mv_length("language")+2) + AND mv_length("language")+1 NOT IN (mv_length("language")+0, + mv_length("language")+2))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + mv_length("language")+1, + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (mv_length("language")+1 IS NULL + OR (mv_length("language")+1 = mv_length("language")+1 + AND mv_length("language")+1 IS NOT DISTINCT + FROM mv_length("language")+1 + AND mv_length("language")+1 <> mv_length("language")+0 + AND (mv_length("language")+1 IS DISTINCT + FROM mv_length("language")+0) + AND mv_length("language")+1 > mv_length("language")+0 + AND mv_length("language")+1 >= mv_length("language")+0 + AND mv_length("language")+1 < mv_length("language")+2 + AND mv_length("language")+1 <= mv_length("language")+2 + AND (mv_length("language")+1 <> mv_length("language")+0) IS TRUE + AND (mv_length("language")+1 = mv_length("language")+0) IS NOT TRUE + AND (mv_length("language")+1 = mv_length("language")+0) IS FALSE + AND (mv_length("language")+1 <> mv_length("language")+0) IS NOT FALSE + AND mv_length("language")+1 BETWEEN mv_length("language")+0 AND mv_length("language")+2 + AND mv_length("language")+1 NOT BETWEEN mv_length("language")+1 AND mv_length("language")+0 + AND mv_length("language")+1 like '%' + AND mv_length("language")+1 not like '__DOES_NOT_EXIST__%' + AND mv_length("language")+1 IN (mv_length("language")+0, + mv_length("language")+1, + mv_length("language")+2) + AND mv_length("language")+1 NOT IN (mv_length("language")+0, + mv_length("language")+2))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A4: mv_offset +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_offset("language", 0) IS NULL + OR ('1'||mv_offset("language", 0) = 1||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) IS NOT DISTINCT + FROM 1||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) <> '0'||mv_offset("language", 0) + AND ('1'||mv_offset("language", 0) IS DISTINCT + FROM '0'||mv_offset("language", 0)) + AND '1'||mv_offset("language", 0) > '0'||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) >= '0'||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) < 2||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) <= 2||mv_offset("language", 0) + AND ('1'||mv_offset("language", 0) <> '0'||mv_offset("language", 0)) IS TRUE + AND ('1'||mv_offset("language", 0) = '0'||mv_offset("language", 0)) IS NOT TRUE + AND ('1'||mv_offset("language", 0) = '0'||mv_offset("language", 0)) IS FALSE + AND ('1'||mv_offset("language", 0) <> '0'||mv_offset("language", 0)) IS NOT FALSE + AND '1'||mv_offset("language", 0) BETWEEN '0'||mv_offset("language", 0) AND 2||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) NOT BETWEEN '1'||mv_offset("language", 0) AND '0'||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) like '%' + AND '1'||mv_offset("language", 0) not like '__DOES_NOT_EXIST__%' + AND '1'||mv_offset("language", 0) IN ('0'||mv_offset("language", 0), + 1||mv_offset("language", 0), + 2||mv_offset("language", 0)) + AND '1'||mv_offset("language", 0) NOT IN ('0'||mv_offset("language", 0), + 2||mv_offset("language", 0)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_offset("language", 0) IS NULL + OR '1'||mv_offset("language", 0) IN + (SELECT '1'||mv_offset("language", 0) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_offset("language", 0) IS NULL + OR ('1'||mv_offset("language", 0) = 1||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) IS NOT DISTINCT + FROM 1||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) <> '0'||mv_offset("language", 0) + AND ('1'||mv_offset("language", 0) IS DISTINCT + FROM '0'||mv_offset("language", 0)) + AND '1'||mv_offset("language", 0) > '0'||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) >= '0'||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) < 2||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) <= 2||mv_offset("language", 0) + AND ('1'||mv_offset("language", 0) <> '0'||mv_offset("language", 0)) IS TRUE + AND ('1'||mv_offset("language", 0) = '0'||mv_offset("language", 0)) IS NOT TRUE + AND ('1'||mv_offset("language", 0) = '0'||mv_offset("language", 0)) IS FALSE + AND ('1'||mv_offset("language", 0) <> '0'||mv_offset("language", 0)) IS NOT FALSE + AND '1'||mv_offset("language", 0) BETWEEN '0'||mv_offset("language", 0) AND 2||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) NOT BETWEEN '1'||mv_offset("language", 0) AND '0'||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) like '%' + AND '1'||mv_offset("language", 0) not like '__DOES_NOT_EXIST__%' + AND '1'||mv_offset("language", 0) IN ('0'||mv_offset("language", 0), + 1||mv_offset("language", 0), + 2||mv_offset("language", 0)) + AND '1'||mv_offset("language", 0) NOT IN ('0'||mv_offset("language", 0), + 2||mv_offset("language", 0)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||mv_offset("language", 0), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_offset("language", 0) IS NULL + OR ('1'||mv_offset("language", 0) = 1||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) IS NOT DISTINCT + FROM 1||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) <> '0'||mv_offset("language", 0) + AND ('1'||mv_offset("language", 0) IS DISTINCT + FROM '0'||mv_offset("language", 0)) + AND '1'||mv_offset("language", 0) > '0'||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) >= '0'||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) < 2||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) <= 2||mv_offset("language", 0) + AND ('1'||mv_offset("language", 0) <> '0'||mv_offset("language", 0)) IS TRUE + AND ('1'||mv_offset("language", 0) = '0'||mv_offset("language", 0)) IS NOT TRUE + AND ('1'||mv_offset("language", 0) = '0'||mv_offset("language", 0)) IS FALSE + AND ('1'||mv_offset("language", 0) <> '0'||mv_offset("language", 0)) IS NOT FALSE + AND '1'||mv_offset("language", 0) BETWEEN '0'||mv_offset("language", 0) AND 2||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) NOT BETWEEN '1'||mv_offset("language", 0) AND '0'||mv_offset("language", 0) + AND '1'||mv_offset("language", 0) like '%' + AND '1'||mv_offset("language", 0) not like '__DOES_NOT_EXIST__%' + AND '1'||mv_offset("language", 0) IN ('0'||mv_offset("language", 0), + 1||mv_offset("language", 0), + 2||mv_offset("language", 0)) + AND '1'||mv_offset("language", 0) NOT IN ('0'||mv_offset("language", 0), + 2||mv_offset("language", 0)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A5: mv_ordinal +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_ordinal("language", 1) IS NULL + OR ('1'||mv_ordinal("language", 1) = 1||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) IS NOT DISTINCT + FROM 1||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) <> '0'||mv_ordinal("language", 1) + AND ('1'||mv_ordinal("language", 1) IS DISTINCT + FROM '0'||mv_ordinal("language", 1)) + AND '1'||mv_ordinal("language", 1) > '0'||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) >= '0'||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) < 2||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) <= 2||mv_ordinal("language", 1) + AND ('1'||mv_ordinal("language", 1) <> '0'||mv_ordinal("language", 1)) IS TRUE + AND ('1'||mv_ordinal("language", 1) = '0'||mv_ordinal("language", 1)) IS NOT TRUE + AND ('1'||mv_ordinal("language", 1) = '0'||mv_ordinal("language", 1)) IS FALSE + AND ('1'||mv_ordinal("language", 1) <> '0'||mv_ordinal("language", 1)) IS NOT FALSE + AND '1'||mv_ordinal("language", 1) BETWEEN '0'||mv_ordinal("language", 1) AND 2||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) NOT BETWEEN '1'||mv_ordinal("language", 1) AND '0'||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) like '%' + AND '1'||mv_ordinal("language", 1) not like '__DOES_NOT_EXIST__%' + AND '1'||mv_ordinal("language", 1) IN ('0'||mv_ordinal("language", 1), + 1||mv_ordinal("language", 1), + 2||mv_ordinal("language", 1)) + AND '1'||mv_ordinal("language", 1) NOT IN ('0'||mv_ordinal("language", 1), + 2||mv_ordinal("language", 1)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_ordinal("language", 1) IS NULL + OR '1'||mv_ordinal("language", 1) IN + (SELECT '1'||mv_ordinal("language", 1) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_ordinal("language", 1) IS NULL + OR ('1'||mv_ordinal("language", 1) = 1||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) IS NOT DISTINCT + FROM 1||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) <> '0'||mv_ordinal("language", 1) + AND ('1'||mv_ordinal("language", 1) IS DISTINCT + FROM '0'||mv_ordinal("language", 1)) + AND '1'||mv_ordinal("language", 1) > '0'||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) >= '0'||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) < 2||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) <= 2||mv_ordinal("language", 1) + AND ('1'||mv_ordinal("language", 1) <> '0'||mv_ordinal("language", 1)) IS TRUE + AND ('1'||mv_ordinal("language", 1) = '0'||mv_ordinal("language", 1)) IS NOT TRUE + AND ('1'||mv_ordinal("language", 1) = '0'||mv_ordinal("language", 1)) IS FALSE + AND ('1'||mv_ordinal("language", 1) <> '0'||mv_ordinal("language", 1)) IS NOT FALSE + AND '1'||mv_ordinal("language", 1) BETWEEN '0'||mv_ordinal("language", 1) AND 2||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) NOT BETWEEN '1'||mv_ordinal("language", 1) AND '0'||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) like '%' + AND '1'||mv_ordinal("language", 1) not like '__DOES_NOT_EXIST__%' + AND '1'||mv_ordinal("language", 1) IN ('0'||mv_ordinal("language", 1), + 1||mv_ordinal("language", 1), + 2||mv_ordinal("language", 1)) + AND '1'||mv_ordinal("language", 1) NOT IN ('0'||mv_ordinal("language", 1), + 2||mv_ordinal("language", 1)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||mv_ordinal("language", 1), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_ordinal("language", 1) IS NULL + OR ('1'||mv_ordinal("language", 1) = 1||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) IS NOT DISTINCT + FROM 1||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) <> '0'||mv_ordinal("language", 1) + AND ('1'||mv_ordinal("language", 1) IS DISTINCT + FROM '0'||mv_ordinal("language", 1)) + AND '1'||mv_ordinal("language", 1) > '0'||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) >= '0'||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) < 2||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) <= 2||mv_ordinal("language", 1) + AND ('1'||mv_ordinal("language", 1) <> '0'||mv_ordinal("language", 1)) IS TRUE + AND ('1'||mv_ordinal("language", 1) = '0'||mv_ordinal("language", 1)) IS NOT TRUE + AND ('1'||mv_ordinal("language", 1) = '0'||mv_ordinal("language", 1)) IS FALSE + AND ('1'||mv_ordinal("language", 1) <> '0'||mv_ordinal("language", 1)) IS NOT FALSE + AND '1'||mv_ordinal("language", 1) BETWEEN '0'||mv_ordinal("language", 1) AND 2||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) NOT BETWEEN '1'||mv_ordinal("language", 1) AND '0'||mv_ordinal("language", 1) + AND '1'||mv_ordinal("language", 1) like '%' + AND '1'||mv_ordinal("language", 1) not like '__DOES_NOT_EXIST__%' + AND '1'||mv_ordinal("language", 1) IN ('0'||mv_ordinal("language", 1), + 1||mv_ordinal("language", 1), + 2||mv_ordinal("language", 1)) + AND '1'||mv_ordinal("language", 1) NOT IN ('0'||mv_ordinal("language", 1), + 2||mv_ordinal("language", 1)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A6: mv_contains +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END IS NULL + OR (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END IS NOT DISTINCT + FROM CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END IS DISTINCT + FROM CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END > CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END >= CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END < CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END <= CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) IS TRUE + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) IS NOT TRUE + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) IS FALSE + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) IS NOT FALSE + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END BETWEEN CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END AND CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END NOT BETWEEN CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END AND CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END like '%' + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END IN (CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END, + CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END, + CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END) + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END NOT IN (CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END, + CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END IS NULL + OR CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END IN + (SELECT CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END IS NULL + OR (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END IS NOT DISTINCT + FROM CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END IS DISTINCT + FROM CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END > CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END >= CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END < CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END <= CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) IS TRUE + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) IS NOT TRUE + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) IS FALSE + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) IS NOT FALSE + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END BETWEEN CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END AND CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END NOT BETWEEN CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END AND CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END like '%' + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END IN (CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END, + CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END, + CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END) + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END NOT IN (CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END, + CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END, + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END IS NULL + OR (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END IS NOT DISTINCT + FROM CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END IS DISTINCT + FROM CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END > CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END >= CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END < CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END <= CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) IS TRUE + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) IS NOT TRUE + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) IS FALSE + AND (CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END) IS NOT FALSE + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END BETWEEN CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END AND CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END NOT BETWEEN CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END AND CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END like '%' + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END IN (CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END, + CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END, + CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END) + AND CASE + WHEN mv_contains("language", "language") THEN 20 + ELSE 2 + END NOT IN (CASE + WHEN mv_contains("language", "language") THEN 10 + ELSE 1 + END, + CASE + WHEN mv_contains("language", "language") THEN 30 + ELSE 3 + END))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A7: mv_overlap +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END IS NULL + OR (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END IS NOT DISTINCT + FROM CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END IS DISTINCT + FROM CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END > CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END >= CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END < CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END <= CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) IS TRUE + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) IS NOT TRUE + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) IS FALSE + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) IS NOT FALSE + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END BETWEEN CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END AND CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END NOT BETWEEN CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END AND CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END like '%' + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END IN (CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END, + CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END, + CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END) + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END NOT IN (CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END, + CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END IS NULL + OR CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END IN + (SELECT CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END IS NULL + OR (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END IS NOT DISTINCT + FROM CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END IS DISTINCT + FROM CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END > CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END >= CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END < CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END <= CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) IS TRUE + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) IS NOT TRUE + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) IS FALSE + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) IS NOT FALSE + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END BETWEEN CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END AND CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END NOT BETWEEN CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END AND CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END like '%' + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END IN (CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END, + CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END, + CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END) + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END NOT IN (CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END, + CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END, + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END IS NULL + OR (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END IS NOT DISTINCT + FROM CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END IS DISTINCT + FROM CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END > CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END >= CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END < CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END <= CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) IS TRUE + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) IS NOT TRUE + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END = CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) IS FALSE + AND (CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END <> CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END) IS NOT FALSE + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END BETWEEN CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END AND CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END NOT BETWEEN CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END AND CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END like '%' + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END not like '__DOES_NOT_EXIST__%' + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END IN (CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END, + CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END, + CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END) + AND CASE + WHEN mv_overlap("language", "language") THEN 20 + ELSE 2 + END NOT IN (CASE + WHEN mv_overlap("language", "language") THEN 10 + ELSE 1 + END, + CASE + WHEN mv_overlap("language", "language") THEN 30 + ELSE 3 + END))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A8: mv_offset_of +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (mv_offset_of("language", client_ip) IS NULL + OR (mv_offset_of("language", client_ip) = mv_offset_of("language", client_ip)+0 + AND mv_offset_of("language", client_ip) IS NOT DISTINCT + FROM mv_offset_of("language", client_ip)+0 + AND mv_offset_of("language", client_ip) <> mv_offset_of("language", client_ip)-1 + AND (mv_offset_of("language", client_ip) IS DISTINCT + FROM mv_offset_of("language", client_ip)-1) + AND mv_offset_of("language", client_ip) > mv_offset_of("language", client_ip)-1 + AND mv_offset_of("language", client_ip) >= mv_offset_of("language", client_ip)-1 + AND mv_offset_of("language", client_ip) < mv_offset_of("language", client_ip)+1 + AND mv_offset_of("language", client_ip) <= mv_offset_of("language", client_ip)+1 + AND (mv_offset_of("language", client_ip) <> mv_offset_of("language", client_ip)-1) IS TRUE + AND (mv_offset_of("language", client_ip) = mv_offset_of("language", client_ip)-1) IS NOT TRUE + AND (mv_offset_of("language", client_ip) = mv_offset_of("language", client_ip)-1) IS FALSE + AND (mv_offset_of("language", client_ip) <> mv_offset_of("language", client_ip)-1) IS NOT FALSE + AND mv_offset_of("language", client_ip) BETWEEN mv_offset_of("language", client_ip)-1 AND mv_offset_of("language", client_ip)+1 + AND mv_offset_of("language", client_ip) NOT BETWEEN mv_offset_of("language", client_ip) AND mv_offset_of("language", client_ip)-1 + AND mv_offset_of("language", client_ip) like '%' + AND mv_offset_of("language", client_ip) not like '__DOES_NOT_EXIST__%' + AND mv_offset_of("language", client_ip) IN (mv_offset_of("language", client_ip)-1, + mv_offset_of("language", client_ip)+0, + mv_offset_of("language", client_ip)+1) + AND mv_offset_of("language", client_ip) NOT IN (mv_offset_of("language", client_ip)-1, + mv_offset_of("language", client_ip)+1))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (mv_offset_of("language", client_ip) IS NULL + OR mv_offset_of("language", client_ip) IN + (SELECT mv_offset_of("language", client_ip) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (mv_offset_of("language", client_ip) IS NULL + OR (mv_offset_of("language", client_ip) = mv_offset_of("language", client_ip)+0 + AND mv_offset_of("language", client_ip) IS NOT DISTINCT + FROM mv_offset_of("language", client_ip)+0 + AND mv_offset_of("language", client_ip) <> mv_offset_of("language", client_ip)-1 + AND (mv_offset_of("language", client_ip) IS DISTINCT + FROM mv_offset_of("language", client_ip)-1) + AND mv_offset_of("language", client_ip) > mv_offset_of("language", client_ip)-1 + AND mv_offset_of("language", client_ip) >= mv_offset_of("language", client_ip)-1 + AND mv_offset_of("language", client_ip) < mv_offset_of("language", client_ip)+1 + AND mv_offset_of("language", client_ip) <= mv_offset_of("language", client_ip)+1 + AND (mv_offset_of("language", client_ip) <> mv_offset_of("language", client_ip)-1) IS TRUE + AND (mv_offset_of("language", client_ip) = mv_offset_of("language", client_ip)-1) IS NOT TRUE + AND (mv_offset_of("language", client_ip) = mv_offset_of("language", client_ip)-1) IS FALSE + AND (mv_offset_of("language", client_ip) <> mv_offset_of("language", client_ip)-1) IS NOT FALSE + AND mv_offset_of("language", client_ip) BETWEEN mv_offset_of("language", client_ip)-1 AND mv_offset_of("language", client_ip)+1 + AND mv_offset_of("language", client_ip) NOT BETWEEN mv_offset_of("language", client_ip) AND mv_offset_of("language", client_ip)-1 + AND mv_offset_of("language", client_ip) like '%' + AND mv_offset_of("language", client_ip) not like '__DOES_NOT_EXIST__%' + AND mv_offset_of("language", client_ip) IN (mv_offset_of("language", client_ip)-1, + mv_offset_of("language", client_ip)+0, + mv_offset_of("language", client_ip)+1) + AND mv_offset_of("language", client_ip) NOT IN (mv_offset_of("language", client_ip)-1, + mv_offset_of("language", client_ip)+1))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + mv_offset_of("language", client_ip), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (mv_offset_of("language", client_ip) IS NULL + OR (mv_offset_of("language", client_ip) = mv_offset_of("language", client_ip)+0 + AND mv_offset_of("language", client_ip) IS NOT DISTINCT + FROM mv_offset_of("language", client_ip)+0 + AND mv_offset_of("language", client_ip) <> mv_offset_of("language", client_ip)-1 + AND (mv_offset_of("language", client_ip) IS DISTINCT + FROM mv_offset_of("language", client_ip)-1) + AND mv_offset_of("language", client_ip) > mv_offset_of("language", client_ip)-1 + AND mv_offset_of("language", client_ip) >= mv_offset_of("language", client_ip)-1 + AND mv_offset_of("language", client_ip) < mv_offset_of("language", client_ip)+1 + AND mv_offset_of("language", client_ip) <= mv_offset_of("language", client_ip)+1 + AND (mv_offset_of("language", client_ip) <> mv_offset_of("language", client_ip)-1) IS TRUE + AND (mv_offset_of("language", client_ip) = mv_offset_of("language", client_ip)-1) IS NOT TRUE + AND (mv_offset_of("language", client_ip) = mv_offset_of("language", client_ip)-1) IS FALSE + AND (mv_offset_of("language", client_ip) <> mv_offset_of("language", client_ip)-1) IS NOT FALSE + AND mv_offset_of("language", client_ip) BETWEEN mv_offset_of("language", client_ip)-1 AND mv_offset_of("language", client_ip)+1 + AND mv_offset_of("language", client_ip) NOT BETWEEN mv_offset_of("language", client_ip) AND mv_offset_of("language", client_ip)-1 + AND mv_offset_of("language", client_ip) like '%' + AND mv_offset_of("language", client_ip) not like '__DOES_NOT_EXIST__%' + AND mv_offset_of("language", client_ip) IN (mv_offset_of("language", client_ip)-1, + mv_offset_of("language", client_ip)+0, + mv_offset_of("language", client_ip)+1) + AND mv_offset_of("language", client_ip) NOT IN (mv_offset_of("language", client_ip)-1, + mv_offset_of("language", client_ip)+1))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A9: mv_ordinal_of +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (mv_ordinal_of("language", client_ip) IS NULL + OR (mv_ordinal_of("language", client_ip) = mv_ordinal_of("language", client_ip)+0 + AND mv_ordinal_of("language", client_ip) IS NOT DISTINCT + FROM mv_ordinal_of("language", client_ip)+0 + AND mv_ordinal_of("language", client_ip) <> mv_ordinal_of("language", client_ip)-1 + AND (mv_ordinal_of("language", client_ip) IS DISTINCT + FROM mv_ordinal_of("language", client_ip)-1) + AND mv_ordinal_of("language", client_ip) > mv_ordinal_of("language", client_ip)-1 + AND mv_ordinal_of("language", client_ip) >= mv_ordinal_of("language", client_ip)-1 + AND mv_ordinal_of("language", client_ip) < mv_ordinal_of("language", client_ip)+1 + AND mv_ordinal_of("language", client_ip) <= mv_ordinal_of("language", client_ip)+1 + AND (mv_ordinal_of("language", client_ip) <> mv_ordinal_of("language", client_ip)-1) IS TRUE + AND (mv_ordinal_of("language", client_ip) = mv_ordinal_of("language", client_ip)-1) IS NOT TRUE + AND (mv_ordinal_of("language", client_ip) = mv_ordinal_of("language", client_ip)-1) IS FALSE + AND (mv_ordinal_of("language", client_ip) <> mv_ordinal_of("language", client_ip)-1) IS NOT FALSE + AND mv_ordinal_of("language", client_ip) BETWEEN mv_ordinal_of("language", client_ip)-1 AND mv_ordinal_of("language", client_ip)+1 + AND mv_ordinal_of("language", client_ip) NOT BETWEEN mv_ordinal_of("language", client_ip) AND mv_ordinal_of("language", client_ip)-1 + AND mv_ordinal_of("language", client_ip) like '%' + AND mv_ordinal_of("language", client_ip) not like '__DOES_NOT_EXIST__%' + AND mv_ordinal_of("language", client_ip) IN (mv_ordinal_of("language", client_ip)-1, + mv_ordinal_of("language", client_ip)+0, + mv_ordinal_of("language", client_ip)+1) + AND mv_ordinal_of("language", client_ip) NOT IN (mv_ordinal_of("language", client_ip)-1, + mv_ordinal_of("language", client_ip)+1))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (mv_ordinal_of("language", client_ip) IS NULL + OR mv_ordinal_of("language", client_ip) IN + (SELECT mv_ordinal_of("language", client_ip) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (mv_ordinal_of("language", client_ip) IS NULL + OR (mv_ordinal_of("language", client_ip) = mv_ordinal_of("language", client_ip)+0 + AND mv_ordinal_of("language", client_ip) IS NOT DISTINCT + FROM mv_ordinal_of("language", client_ip)+0 + AND mv_ordinal_of("language", client_ip) <> mv_ordinal_of("language", client_ip)-1 + AND (mv_ordinal_of("language", client_ip) IS DISTINCT + FROM mv_ordinal_of("language", client_ip)-1) + AND mv_ordinal_of("language", client_ip) > mv_ordinal_of("language", client_ip)-1 + AND mv_ordinal_of("language", client_ip) >= mv_ordinal_of("language", client_ip)-1 + AND mv_ordinal_of("language", client_ip) < mv_ordinal_of("language", client_ip)+1 + AND mv_ordinal_of("language", client_ip) <= mv_ordinal_of("language", client_ip)+1 + AND (mv_ordinal_of("language", client_ip) <> mv_ordinal_of("language", client_ip)-1) IS TRUE + AND (mv_ordinal_of("language", client_ip) = mv_ordinal_of("language", client_ip)-1) IS NOT TRUE + AND (mv_ordinal_of("language", client_ip) = mv_ordinal_of("language", client_ip)-1) IS FALSE + AND (mv_ordinal_of("language", client_ip) <> mv_ordinal_of("language", client_ip)-1) IS NOT FALSE + AND mv_ordinal_of("language", client_ip) BETWEEN mv_ordinal_of("language", client_ip)-1 AND mv_ordinal_of("language", client_ip)+1 + AND mv_ordinal_of("language", client_ip) NOT BETWEEN mv_ordinal_of("language", client_ip) AND mv_ordinal_of("language", client_ip)-1 + AND mv_ordinal_of("language", client_ip) like '%' + AND mv_ordinal_of("language", client_ip) not like '__DOES_NOT_EXIST__%' + AND mv_ordinal_of("language", client_ip) IN (mv_ordinal_of("language", client_ip)-1, + mv_ordinal_of("language", client_ip)+0, + mv_ordinal_of("language", client_ip)+1) + AND mv_ordinal_of("language", client_ip) NOT IN (mv_ordinal_of("language", client_ip)-1, + mv_ordinal_of("language", client_ip)+1))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + mv_ordinal_of("language", client_ip), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (mv_ordinal_of("language", client_ip) IS NULL + OR (mv_ordinal_of("language", client_ip) = mv_ordinal_of("language", client_ip)+0 + AND mv_ordinal_of("language", client_ip) IS NOT DISTINCT + FROM mv_ordinal_of("language", client_ip)+0 + AND mv_ordinal_of("language", client_ip) <> mv_ordinal_of("language", client_ip)-1 + AND (mv_ordinal_of("language", client_ip) IS DISTINCT + FROM mv_ordinal_of("language", client_ip)-1) + AND mv_ordinal_of("language", client_ip) > mv_ordinal_of("language", client_ip)-1 + AND mv_ordinal_of("language", client_ip) >= mv_ordinal_of("language", client_ip)-1 + AND mv_ordinal_of("language", client_ip) < mv_ordinal_of("language", client_ip)+1 + AND mv_ordinal_of("language", client_ip) <= mv_ordinal_of("language", client_ip)+1 + AND (mv_ordinal_of("language", client_ip) <> mv_ordinal_of("language", client_ip)-1) IS TRUE + AND (mv_ordinal_of("language", client_ip) = mv_ordinal_of("language", client_ip)-1) IS NOT TRUE + AND (mv_ordinal_of("language", client_ip) = mv_ordinal_of("language", client_ip)-1) IS FALSE + AND (mv_ordinal_of("language", client_ip) <> mv_ordinal_of("language", client_ip)-1) IS NOT FALSE + AND mv_ordinal_of("language", client_ip) BETWEEN mv_ordinal_of("language", client_ip)-1 AND mv_ordinal_of("language", client_ip)+1 + AND mv_ordinal_of("language", client_ip) NOT BETWEEN mv_ordinal_of("language", client_ip) AND mv_ordinal_of("language", client_ip)-1 + AND mv_ordinal_of("language", client_ip) like '%' + AND mv_ordinal_of("language", client_ip) not like '__DOES_NOT_EXIST__%' + AND mv_ordinal_of("language", client_ip) IN (mv_ordinal_of("language", client_ip)-1, + mv_ordinal_of("language", client_ip)+0, + mv_ordinal_of("language", client_ip)+1) + AND mv_ordinal_of("language", client_ip) NOT IN (mv_ordinal_of("language", client_ip)-1, + mv_ordinal_of("language", client_ip)+1))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A10: mv_prepend +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') IS NULL + OR ('1'||mv_to_string(mv_prepend('1', "language"), ',') = 1||mv_to_string(mv_prepend('1', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_prepend('1', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') <> '0'||mv_to_string(mv_prepend('0', "language"), ',') + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_prepend('0', "language"), ',')) + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') > '0'||mv_to_string(mv_prepend('0', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') >= '0'||mv_to_string(mv_prepend('0', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') < 2||mv_to_string(mv_prepend('2', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') <= 2||mv_to_string(mv_prepend('2', "language"), ',') + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') <> '0'||mv_to_string(mv_prepend('0', "language"), ',')) IS TRUE + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') = '0'||mv_to_string(mv_prepend('0', "language"), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') = '0'||mv_to_string(mv_prepend('0', "language"), ',')) IS FALSE + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') <> '0'||mv_to_string(mv_prepend('0', "language"), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') BETWEEN '0'||mv_to_string(mv_prepend('0', "language"), ',') AND 2||mv_to_string(mv_prepend('2', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') NOT BETWEEN '1'||mv_to_string(mv_prepend('1', "language"), ',') AND '0'||mv_to_string(mv_prepend('0', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') like '%' + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') IN ('0'||mv_to_string(mv_prepend('0', "language"), ','), + 1||mv_to_string(mv_prepend('1', "language"), ','), + 2||mv_to_string(mv_prepend('2', "language"), ',')) + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') NOT IN ('0'||mv_to_string(mv_prepend('0', "language"), ','), + 2||mv_to_string(mv_prepend('2', "language"), ',')))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') IS NULL + OR '1'||mv_to_string(mv_prepend('1', "language"), ',') IN + (SELECT '1'||mv_to_string(mv_prepend('1', "language"), ',') + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') IS NULL + OR ('1'||mv_to_string(mv_prepend('1', "language"), ',') = 1||mv_to_string(mv_prepend('1', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_prepend('1', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') <> '0'||mv_to_string(mv_prepend('0', "language"), ',') + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_prepend('0', "language"), ',')) + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') > '0'||mv_to_string(mv_prepend('0', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') >= '0'||mv_to_string(mv_prepend('0', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') < 2||mv_to_string(mv_prepend('2', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') <= 2||mv_to_string(mv_prepend('2', "language"), ',') + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') <> '0'||mv_to_string(mv_prepend('0', "language"), ',')) IS TRUE + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') = '0'||mv_to_string(mv_prepend('0', "language"), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') = '0'||mv_to_string(mv_prepend('0', "language"), ',')) IS FALSE + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') <> '0'||mv_to_string(mv_prepend('0', "language"), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') BETWEEN '0'||mv_to_string(mv_prepend('0', "language"), ',') AND 2||mv_to_string(mv_prepend('2', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') NOT BETWEEN '1'||mv_to_string(mv_prepend('1', "language"), ',') AND '0'||mv_to_string(mv_prepend('0', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') like '%' + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') IN ('0'||mv_to_string(mv_prepend('0', "language"), ','), + 1||mv_to_string(mv_prepend('1', "language"), ','), + 2||mv_to_string(mv_prepend('2', "language"), ',')) + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') NOT IN ('0'||mv_to_string(mv_prepend('0', "language"), ','), + 2||mv_to_string(mv_prepend('2', "language"), ',')))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||mv_to_string(mv_prepend('1', "language"), ','), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') IS NULL + OR ('1'||mv_to_string(mv_prepend('1', "language"), ',') = 1||mv_to_string(mv_prepend('1', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_prepend('1', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') <> '0'||mv_to_string(mv_prepend('0', "language"), ',') + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_prepend('0', "language"), ',')) + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') > '0'||mv_to_string(mv_prepend('0', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') >= '0'||mv_to_string(mv_prepend('0', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') < 2||mv_to_string(mv_prepend('2', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') <= 2||mv_to_string(mv_prepend('2', "language"), ',') + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') <> '0'||mv_to_string(mv_prepend('0', "language"), ',')) IS TRUE + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') = '0'||mv_to_string(mv_prepend('0', "language"), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') = '0'||mv_to_string(mv_prepend('0', "language"), ',')) IS FALSE + AND ('1'||mv_to_string(mv_prepend('1', "language"), ',') <> '0'||mv_to_string(mv_prepend('0', "language"), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') BETWEEN '0'||mv_to_string(mv_prepend('0', "language"), ',') AND 2||mv_to_string(mv_prepend('2', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') NOT BETWEEN '1'||mv_to_string(mv_prepend('1', "language"), ',') AND '0'||mv_to_string(mv_prepend('0', "language"), ',') + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') like '%' + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') IN ('0'||mv_to_string(mv_prepend('0', "language"), ','), + 1||mv_to_string(mv_prepend('1', "language"), ','), + 2||mv_to_string(mv_prepend('2', "language"), ',')) + AND '1'||mv_to_string(mv_prepend('1', "language"), ',') NOT IN ('0'||mv_to_string(mv_prepend('0', "language"), ','), + 2||mv_to_string(mv_prepend('2', "language"), ',')))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A11: mv_append +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') IS NULL + OR ('1'||mv_to_string(mv_append("language", 'A'), ',') = 1||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') <> '0'||mv_to_string(mv_append("language", 'A'), ',') + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_append("language", 'A'), ',')) + AND '1'||mv_to_string(mv_append("language", 'A'), ',') > '0'||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') >= '0'||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') < 2||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') <= 2||mv_to_string(mv_append("language", 'A'), ',') + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') <> '0'||mv_to_string(mv_append("language", 'A'), ',')) IS TRUE + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') = '0'||mv_to_string(mv_append("language", 'A'), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') = '0'||mv_to_string(mv_append("language", 'A'), ',')) IS FALSE + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') <> '0'||mv_to_string(mv_append("language", 'A'), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_append("language", 'A'), ',') BETWEEN '0'||mv_to_string(mv_append("language", 'A'), ',') AND 2||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') NOT BETWEEN '1'||mv_to_string(mv_append("language", 'A'), ',') AND '0'||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') like '%' + AND '1'||mv_to_string(mv_append("language", 'A'), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_append("language", 'A'), ',') IN ('0'||mv_to_string(mv_append("language", 'A'), ','), + 1||mv_to_string(mv_append("language", 'A'), ','), + 2||mv_to_string(mv_append("language", 'A'), ',')) + AND '1'||mv_to_string(mv_append("language", 'A'), ',') NOT IN ('0'||mv_to_string(mv_append("language", 'A'), ','), + 2||mv_to_string(mv_append("language", 'A'), ',')))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') IS NULL + OR '1'||mv_to_string(mv_append("language", 'A'), ',') IN + (SELECT '1'||mv_to_string(mv_append("language", 'A'), ',') + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') IS NULL + OR ('1'||mv_to_string(mv_append("language", 'A'), ',') = 1||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') <> '0'||mv_to_string(mv_append("language", 'A'), ',') + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_append("language", 'A'), ',')) + AND '1'||mv_to_string(mv_append("language", 'A'), ',') > '0'||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') >= '0'||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') < 2||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') <= 2||mv_to_string(mv_append("language", 'A'), ',') + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') <> '0'||mv_to_string(mv_append("language", 'A'), ',')) IS TRUE + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') = '0'||mv_to_string(mv_append("language", 'A'), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') = '0'||mv_to_string(mv_append("language", 'A'), ',')) IS FALSE + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') <> '0'||mv_to_string(mv_append("language", 'A'), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_append("language", 'A'), ',') BETWEEN '0'||mv_to_string(mv_append("language", 'A'), ',') AND 2||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') NOT BETWEEN '1'||mv_to_string(mv_append("language", 'A'), ',') AND '0'||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') like '%' + AND '1'||mv_to_string(mv_append("language", 'A'), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_append("language", 'A'), ',') IN ('0'||mv_to_string(mv_append("language", 'A'), ','), + 1||mv_to_string(mv_append("language", 'A'), ','), + 2||mv_to_string(mv_append("language", 'A'), ',')) + AND '1'||mv_to_string(mv_append("language", 'A'), ',') NOT IN ('0'||mv_to_string(mv_append("language", 'A'), ','), + 2||mv_to_string(mv_append("language", 'A'), ',')))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||mv_to_string(mv_append("language", 'A'), ','), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') IS NULL + OR ('1'||mv_to_string(mv_append("language", 'A'), ',') = 1||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') <> '0'||mv_to_string(mv_append("language", 'A'), ',') + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_append("language", 'A'), ',')) + AND '1'||mv_to_string(mv_append("language", 'A'), ',') > '0'||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') >= '0'||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') < 2||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') <= 2||mv_to_string(mv_append("language", 'A'), ',') + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') <> '0'||mv_to_string(mv_append("language", 'A'), ',')) IS TRUE + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') = '0'||mv_to_string(mv_append("language", 'A'), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') = '0'||mv_to_string(mv_append("language", 'A'), ',')) IS FALSE + AND ('1'||mv_to_string(mv_append("language", 'A'), ',') <> '0'||mv_to_string(mv_append("language", 'A'), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_append("language", 'A'), ',') BETWEEN '0'||mv_to_string(mv_append("language", 'A'), ',') AND 2||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') NOT BETWEEN '1'||mv_to_string(mv_append("language", 'A'), ',') AND '0'||mv_to_string(mv_append("language", 'A'), ',') + AND '1'||mv_to_string(mv_append("language", 'A'), ',') like '%' + AND '1'||mv_to_string(mv_append("language", 'A'), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_append("language", 'A'), ',') IN ('0'||mv_to_string(mv_append("language", 'A'), ','), + 1||mv_to_string(mv_append("language", 'A'), ','), + 2||mv_to_string(mv_append("language", 'A'), ',')) + AND '1'||mv_to_string(mv_append("language", 'A'), ',') NOT IN ('0'||mv_to_string(mv_append("language", 'A'), ','), + 2||mv_to_string(mv_append("language", 'A'), ',')))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A12: mv_concat +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') IS NULL + OR ('1'||mv_to_string(mv_concat("language", "language"), ',') = 1||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') <> '0'||mv_to_string(mv_concat("language", "language"), ',') + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_concat("language", "language"), ',')) + AND '1'||mv_to_string(mv_concat("language", "language"), ',') > '0'||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') >= '0'||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') < 2||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') <= 2||mv_to_string(mv_concat("language", "language"), ',') + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') <> '0'||mv_to_string(mv_concat("language", "language"), ',')) IS TRUE + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') = '0'||mv_to_string(mv_concat("language", "language"), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') = '0'||mv_to_string(mv_concat("language", "language"), ',')) IS FALSE + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') <> '0'||mv_to_string(mv_concat("language", "language"), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_concat("language", "language"), ',') BETWEEN '0'||mv_to_string(mv_concat("language", "language"), ',') AND 2||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') NOT BETWEEN '1'||mv_to_string(mv_concat("language", "language"), ',') AND '0'||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') like '%' + AND '1'||mv_to_string(mv_concat("language", "language"), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_concat("language", "language"), ',') IN ('0'||mv_to_string(mv_concat("language", "language"), ','), + 1||mv_to_string(mv_concat("language", "language"), ','), + 2||mv_to_string(mv_concat("language", "language"), ',')) + AND '1'||mv_to_string(mv_concat("language", "language"), ',') NOT IN ('0'||mv_to_string(mv_concat("language", "language"), ','), + 2||mv_to_string(mv_concat("language", "language"), ',')))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') IS NULL + OR '1'||mv_to_string(mv_concat("language", "language"), ',') IN + (SELECT '1'||mv_to_string(mv_concat("language", "language"), ',') + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') IS NULL + OR ('1'||mv_to_string(mv_concat("language", "language"), ',') = 1||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') <> '0'||mv_to_string(mv_concat("language", "language"), ',') + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_concat("language", "language"), ',')) + AND '1'||mv_to_string(mv_concat("language", "language"), ',') > '0'||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') >= '0'||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') < 2||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') <= 2||mv_to_string(mv_concat("language", "language"), ',') + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') <> '0'||mv_to_string(mv_concat("language", "language"), ',')) IS TRUE + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') = '0'||mv_to_string(mv_concat("language", "language"), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') = '0'||mv_to_string(mv_concat("language", "language"), ',')) IS FALSE + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') <> '0'||mv_to_string(mv_concat("language", "language"), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_concat("language", "language"), ',') BETWEEN '0'||mv_to_string(mv_concat("language", "language"), ',') AND 2||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') NOT BETWEEN '1'||mv_to_string(mv_concat("language", "language"), ',') AND '0'||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') like '%' + AND '1'||mv_to_string(mv_concat("language", "language"), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_concat("language", "language"), ',') IN ('0'||mv_to_string(mv_concat("language", "language"), ','), + 1||mv_to_string(mv_concat("language", "language"), ','), + 2||mv_to_string(mv_concat("language", "language"), ',')) + AND '1'||mv_to_string(mv_concat("language", "language"), ',') NOT IN ('0'||mv_to_string(mv_concat("language", "language"), ','), + 2||mv_to_string(mv_concat("language", "language"), ',')))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||mv_to_string(mv_concat("language", "language"), ','), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') IS NULL + OR ('1'||mv_to_string(mv_concat("language", "language"), ',') = 1||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') <> '0'||mv_to_string(mv_concat("language", "language"), ',') + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_concat("language", "language"), ',')) + AND '1'||mv_to_string(mv_concat("language", "language"), ',') > '0'||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') >= '0'||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') < 2||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') <= 2||mv_to_string(mv_concat("language", "language"), ',') + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') <> '0'||mv_to_string(mv_concat("language", "language"), ',')) IS TRUE + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') = '0'||mv_to_string(mv_concat("language", "language"), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') = '0'||mv_to_string(mv_concat("language", "language"), ',')) IS FALSE + AND ('1'||mv_to_string(mv_concat("language", "language"), ',') <> '0'||mv_to_string(mv_concat("language", "language"), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_concat("language", "language"), ',') BETWEEN '0'||mv_to_string(mv_concat("language", "language"), ',') AND 2||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') NOT BETWEEN '1'||mv_to_string(mv_concat("language", "language"), ',') AND '0'||mv_to_string(mv_concat("language", "language"), ',') + AND '1'||mv_to_string(mv_concat("language", "language"), ',') like '%' + AND '1'||mv_to_string(mv_concat("language", "language"), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_concat("language", "language"), ',') IN ('0'||mv_to_string(mv_concat("language", "language"), ','), + 1||mv_to_string(mv_concat("language", "language"), ','), + 2||mv_to_string(mv_concat("language", "language"), ',')) + AND '1'||mv_to_string(mv_concat("language", "language"), ',') NOT IN ('0'||mv_to_string(mv_concat("language", "language"), ','), + 2||mv_to_string(mv_concat("language", "language"), ',')))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A13: mv_slice +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') IS NULL + OR ('1'||mv_to_string(mv_slice("language", 0, 1), ',') = 1||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') <> '0'||mv_to_string(mv_slice("language", 0, 1), ',') + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_slice("language", 0, 1), ',')) + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') > '0'||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') >= '0'||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') < 2||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') <= 2||mv_to_string(mv_slice("language", 0, 1), ',') + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') <> '0'||mv_to_string(mv_slice("language", 0, 1), ',')) IS TRUE + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') = '0'||mv_to_string(mv_slice("language", 0, 1), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') = '0'||mv_to_string(mv_slice("language", 0, 1), ',')) IS FALSE + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') <> '0'||mv_to_string(mv_slice("language", 0, 1), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') BETWEEN '0'||mv_to_string(mv_slice("language", 0, 1), ',') AND 2||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') NOT BETWEEN '1'||mv_to_string(mv_slice("language", 0, 1), ',') AND '0'||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') like '%' + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') IN ('0'||mv_to_string(mv_slice("language", 0, 1), ','), + 1||mv_to_string(mv_slice("language", 0, 1), ','), + 2||mv_to_string(mv_slice("language", 0, 1), ',')) + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') NOT IN ('0'||mv_to_string(mv_slice("language", 0, 1), ','), + 2||mv_to_string(mv_slice("language", 0, 1), ',')))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') IS NULL + OR '1'||mv_to_string(mv_slice("language", 0, 1), ',') IN + (SELECT '1'||mv_to_string(mv_slice("language", 0, 1), ',') + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') IS NULL + OR ('1'||mv_to_string(mv_slice("language", 0, 1), ',') = 1||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') <> '0'||mv_to_string(mv_slice("language", 0, 1), ',') + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_slice("language", 0, 1), ',')) + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') > '0'||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') >= '0'||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') < 2||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') <= 2||mv_to_string(mv_slice("language", 0, 1), ',') + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') <> '0'||mv_to_string(mv_slice("language", 0, 1), ',')) IS TRUE + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') = '0'||mv_to_string(mv_slice("language", 0, 1), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') = '0'||mv_to_string(mv_slice("language", 0, 1), ',')) IS FALSE + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') <> '0'||mv_to_string(mv_slice("language", 0, 1), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') BETWEEN '0'||mv_to_string(mv_slice("language", 0, 1), ',') AND 2||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') NOT BETWEEN '1'||mv_to_string(mv_slice("language", 0, 1), ',') AND '0'||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') like '%' + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') IN ('0'||mv_to_string(mv_slice("language", 0, 1), ','), + 1||mv_to_string(mv_slice("language", 0, 1), ','), + 2||mv_to_string(mv_slice("language", 0, 1), ',')) + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') NOT IN ('0'||mv_to_string(mv_slice("language", 0, 1), ','), + 2||mv_to_string(mv_slice("language", 0, 1), ',')))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||mv_to_string(mv_slice("language", 0, 1), ','), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') IS NULL + OR ('1'||mv_to_string(mv_slice("language", 0, 1), ',') = 1||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') IS NOT DISTINCT + FROM 1||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') <> '0'||mv_to_string(mv_slice("language", 0, 1), ',') + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') IS DISTINCT + FROM '0'||mv_to_string(mv_slice("language", 0, 1), ',')) + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') > '0'||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') >= '0'||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') < 2||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') <= 2||mv_to_string(mv_slice("language", 0, 1), ',') + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') <> '0'||mv_to_string(mv_slice("language", 0, 1), ',')) IS TRUE + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') = '0'||mv_to_string(mv_slice("language", 0, 1), ',')) IS NOT TRUE + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') = '0'||mv_to_string(mv_slice("language", 0, 1), ',')) IS FALSE + AND ('1'||mv_to_string(mv_slice("language", 0, 1), ',') <> '0'||mv_to_string(mv_slice("language", 0, 1), ',')) IS NOT FALSE + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') BETWEEN '0'||mv_to_string(mv_slice("language", 0, 1), ',') AND 2||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') NOT BETWEEN '1'||mv_to_string(mv_slice("language", 0, 1), ',') AND '0'||mv_to_string(mv_slice("language", 0, 1), ',') + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') like '%' + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') IN ('0'||mv_to_string(mv_slice("language", 0, 1), ','), + 1||mv_to_string(mv_slice("language", 0, 1), ','), + 2||mv_to_string(mv_slice("language", 0, 1), ',')) + AND '1'||mv_to_string(mv_slice("language", 0, 1), ',') NOT IN ('0'||mv_to_string(mv_slice("language", 0, 1), ','), + 2||mv_to_string(mv_slice("language", 0, 1), ',')))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A14: mv_to_string +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string("language", ',') IS NULL + OR ('1'||mv_to_string("language", ',') = 1||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') IS NOT DISTINCT + FROM 1||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') <> 0||mv_to_string("language", ',') + AND ('1'||mv_to_string("language", ',') IS DISTINCT + FROM 0||mv_to_string("language", ',')) + AND '1'||mv_to_string("language", ',') > 0||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') >= 0||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') < 2||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') <= 2||mv_to_string("language", ',') + AND ('1'||mv_to_string("language", ',') <> 0||mv_to_string("language", ',')) IS TRUE + AND ('1'||mv_to_string("language", ',') = 0||mv_to_string("language", ',')) IS NOT TRUE + AND ('1'||mv_to_string("language", ',') = 0||mv_to_string("language", ',')) IS FALSE + AND ('1'||mv_to_string("language", ',') <> 0||mv_to_string("language", ',')) IS NOT FALSE + AND '1'||mv_to_string("language", ',') BETWEEN 0||mv_to_string("language", ',') AND 2||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') NOT BETWEEN '1'||mv_to_string("language", ',') AND 0||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') like '%' + AND '1'||mv_to_string("language", ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string("language", ',') IN (0||mv_to_string("language", ','), + 1||mv_to_string("language", ','), + 2||mv_to_string("language", ',')) + AND '1'||mv_to_string("language", ',') NOT IN (0||mv_to_string("language", ','), + 2||mv_to_string("language", ',')))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string("language", ',') IS NULL + OR '1'||mv_to_string("language", ',') IN + (SELECT '1'||mv_to_string("language", ',') + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string("language", ',') IS NULL + OR ('1'||mv_to_string("language", ',') = 1||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') IS NOT DISTINCT + FROM 1||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') <> 0||mv_to_string("language", ',') + AND ('1'||mv_to_string("language", ',') IS DISTINCT + FROM 0||mv_to_string("language", ',')) + AND '1'||mv_to_string("language", ',') > 0||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') >= 0||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') < 2||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') <= 2||mv_to_string("language", ',') + AND ('1'||mv_to_string("language", ',') <> 0||mv_to_string("language", ',')) IS TRUE + AND ('1'||mv_to_string("language", ',') = 0||mv_to_string("language", ',')) IS NOT TRUE + AND ('1'||mv_to_string("language", ',') = 0||mv_to_string("language", ',')) IS FALSE + AND ('1'||mv_to_string("language", ',') <> 0||mv_to_string("language", ',')) IS NOT FALSE + AND '1'||mv_to_string("language", ',') BETWEEN 0||mv_to_string("language", ',') AND 2||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') NOT BETWEEN '1'||mv_to_string("language", ',') AND 0||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') like '%' + AND '1'||mv_to_string("language", ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string("language", ',') IN (0||mv_to_string("language", ','), + 1||mv_to_string("language", ','), + 2||mv_to_string("language", ',')) + AND '1'||mv_to_string("language", ',') NOT IN (0||mv_to_string("language", ','), + 2||mv_to_string("language", ',')))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||mv_to_string("language", ','), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||mv_to_string("language", ',') IS NULL + OR ('1'||mv_to_string("language", ',') = 1||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') IS NOT DISTINCT + FROM 1||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') <> 0||mv_to_string("language", ',') + AND ('1'||mv_to_string("language", ',') IS DISTINCT + FROM 0||mv_to_string("language", ',')) + AND '1'||mv_to_string("language", ',') > 0||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') >= 0||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') < 2||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') <= 2||mv_to_string("language", ',') + AND ('1'||mv_to_string("language", ',') <> 0||mv_to_string("language", ',')) IS TRUE + AND ('1'||mv_to_string("language", ',') = 0||mv_to_string("language", ',')) IS NOT TRUE + AND ('1'||mv_to_string("language", ',') = 0||mv_to_string("language", ',')) IS FALSE + AND ('1'||mv_to_string("language", ',') <> 0||mv_to_string("language", ',')) IS NOT FALSE + AND '1'||mv_to_string("language", ',') BETWEEN 0||mv_to_string("language", ',') AND 2||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') NOT BETWEEN '1'||mv_to_string("language", ',') AND 0||mv_to_string("language", ',') + AND '1'||mv_to_string("language", ',') like '%' + AND '1'||mv_to_string("language", ',') not like '__DOES_NOT_EXIST__%' + AND '1'||mv_to_string("language", ',') IN (0||mv_to_string("language", ','), + 1||mv_to_string("language", ','), + 2||mv_to_string("language", ',')) + AND '1'||mv_to_string("language", ',') NOT IN (0||mv_to_string("language", ','), + 2||mv_to_string("language", ',')))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A15: string_to_mv +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||string_to_mv('A|B', '|') IS NULL + OR ('1'||string_to_mv('A|B', '|') = '1'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') IS NOT DISTINCT + FROM '1'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') <> '0'||string_to_mv('A|B', '|') + AND ('1'||string_to_mv('A|B', '|') IS DISTINCT + FROM '0'||string_to_mv('A|B', '|')) + AND '1'||string_to_mv('A|B', '|') > '0'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') >= '0'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') < '2'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') <= '2'||string_to_mv('A|B', '|') + AND ('1'||string_to_mv('A|B', '|') <> '0'||string_to_mv('A|B', '|')) IS TRUE + AND ('1'||string_to_mv('A|B', '|') = '0'||string_to_mv('A|B', '|')) IS NOT TRUE + AND ('1'||string_to_mv('A|B', '|') = '0'||string_to_mv('A|B', '|')) IS FALSE + AND ('1'||string_to_mv('A|B', '|') <> '0'||string_to_mv('A|B', '|')) IS NOT FALSE + AND '1'||string_to_mv('A|B', '|') BETWEEN '0'||string_to_mv('A|B', '|') AND '2'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') NOT BETWEEN '1'||string_to_mv('A|B', '|') AND '0'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') like '%' + AND '1'||string_to_mv('A|B', '|') not like '__DOES_NOT_EXIST__%' + AND '1'||string_to_mv('A|B', '|') IN ('0'||string_to_mv('A|B', '|'), + '1'||string_to_mv('A|B', '|'), + '2'||string_to_mv('A|B', '|')) + AND '1'||string_to_mv('A|B', '|') NOT IN ('0'||string_to_mv('A|B', '|'), + '2'||string_to_mv('A|B', '|')))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||string_to_mv('A|B', '|') IS NULL + OR '1'||string_to_mv('A|B', '|') IN + (SELECT '1'||string_to_mv('A|B', '|') + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||string_to_mv('A|B', '|') IS NULL + OR ('1'||string_to_mv('A|B', '|') = '1'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') IS NOT DISTINCT + FROM '1'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') <> '0'||string_to_mv('A|B', '|') + AND ('1'||string_to_mv('A|B', '|') IS DISTINCT + FROM '0'||string_to_mv('A|B', '|')) + AND '1'||string_to_mv('A|B', '|') > '0'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') >= '0'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') < '2'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') <= '2'||string_to_mv('A|B', '|') + AND ('1'||string_to_mv('A|B', '|') <> '0'||string_to_mv('A|B', '|')) IS TRUE + AND ('1'||string_to_mv('A|B', '|') = '0'||string_to_mv('A|B', '|')) IS NOT TRUE + AND ('1'||string_to_mv('A|B', '|') = '0'||string_to_mv('A|B', '|')) IS FALSE + AND ('1'||string_to_mv('A|B', '|') <> '0'||string_to_mv('A|B', '|')) IS NOT FALSE + AND '1'||string_to_mv('A|B', '|') BETWEEN '0'||string_to_mv('A|B', '|') AND '2'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') NOT BETWEEN '1'||string_to_mv('A|B', '|') AND '0'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') like '%' + AND '1'||string_to_mv('A|B', '|') not like '__DOES_NOT_EXIST__%' + AND '1'||string_to_mv('A|B', '|') IN ('0'||string_to_mv('A|B', '|'), + '1'||string_to_mv('A|B', '|'), + '2'||string_to_mv('A|B', '|')) + AND '1'||string_to_mv('A|B', '|') NOT IN ('0'||string_to_mv('A|B', '|'), + '2'||string_to_mv('A|B', '|')))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||string_to_mv('A|B', '|'), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||string_to_mv('A|B', '|') IS NULL + OR ('1'||string_to_mv('A|B', '|') = '1'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') IS NOT DISTINCT + FROM '1'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') <> '0'||string_to_mv('A|B', '|') + AND ('1'||string_to_mv('A|B', '|') IS DISTINCT + FROM '0'||string_to_mv('A|B', '|')) + AND '1'||string_to_mv('A|B', '|') > '0'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') >= '0'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') < '2'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') <= '2'||string_to_mv('A|B', '|') + AND ('1'||string_to_mv('A|B', '|') <> '0'||string_to_mv('A|B', '|')) IS TRUE + AND ('1'||string_to_mv('A|B', '|') = '0'||string_to_mv('A|B', '|')) IS NOT TRUE + AND ('1'||string_to_mv('A|B', '|') = '0'||string_to_mv('A|B', '|')) IS FALSE + AND ('1'||string_to_mv('A|B', '|') <> '0'||string_to_mv('A|B', '|')) IS NOT FALSE + AND '1'||string_to_mv('A|B', '|') BETWEEN '0'||string_to_mv('A|B', '|') AND '2'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') NOT BETWEEN '1'||string_to_mv('A|B', '|') AND '0'||string_to_mv('A|B', '|') + AND '1'||string_to_mv('A|B', '|') like '%' + AND '1'||string_to_mv('A|B', '|') not like '__DOES_NOT_EXIST__%' + AND '1'||string_to_mv('A|B', '|') IN ('0'||string_to_mv('A|B', '|'), + '1'||string_to_mv('A|B', '|'), + '2'||string_to_mv('A|B', '|')) + AND '1'||string_to_mv('A|B', '|') NOT IN ('0'||string_to_mv('A|B', '|'), + '2'||string_to_mv('A|B', '|')))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A16: mv_to_array +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_offset(mv_to_array("language"), 0) IS NULL + OR ('1'||array_offset(mv_to_array("language"), 0) = 1||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) IS NOT DISTINCT + FROM 1||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0) + AND ('1'||array_offset(mv_to_array("language"), 0) IS DISTINCT + FROM 0||array_offset(mv_to_array("language"), 0)) + AND '1'||array_offset(mv_to_array("language"), 0) > 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) >= 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) < 2||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) <= 2||array_offset(mv_to_array("language"), 0) + AND ('1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0)) IS TRUE + AND ('1'||array_offset(mv_to_array("language"), 0) = 0||array_offset(mv_to_array("language"), 0)) IS NOT TRUE + AND ('1'||array_offset(mv_to_array("language"), 0) = 0||array_offset(mv_to_array("language"), 0)) IS FALSE + AND ('1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0)) IS NOT FALSE + AND '1'||array_offset(mv_to_array("language"), 0) BETWEEN 0||array_offset(mv_to_array("language"), 0) AND 2||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) NOT BETWEEN '1'||array_offset(mv_to_array("language"), 0) AND 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) like '%' + AND '1'||array_offset(mv_to_array("language"), 0) not like '__DOES_NOT_EXIST__%' + AND '1'||array_offset(mv_to_array("language"), 0) IN (0||array_offset(mv_to_array("language"), 0), + 1||array_offset(mv_to_array("language"), 0), + 2||array_offset(mv_to_array("language"), 0)) + AND '1'||array_offset(mv_to_array("language"), 0) NOT IN (0||array_offset(mv_to_array("language"), 0), + 2||array_offset(mv_to_array("language"), 0)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_offset(mv_to_array("language"), 0) IS NULL + OR '1'||array_offset(mv_to_array("language"), 0) IN + (SELECT '1'||array_offset(mv_to_array("language"), 0) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_offset(mv_to_array("language"), 0) IS NULL + OR ('1'||array_offset(mv_to_array("language"), 0) = 1||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) IS NOT DISTINCT + FROM 1||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0) + AND ('1'||array_offset(mv_to_array("language"), 0) IS DISTINCT + FROM 0||array_offset(mv_to_array("language"), 0)) + AND '1'||array_offset(mv_to_array("language"), 0) > 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) >= 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) < 2||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) <= 2||array_offset(mv_to_array("language"), 0) + AND ('1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0)) IS TRUE + AND ('1'||array_offset(mv_to_array("language"), 0) = 0||array_offset(mv_to_array("language"), 0)) IS NOT TRUE + AND ('1'||array_offset(mv_to_array("language"), 0) = 0||array_offset(mv_to_array("language"), 0)) IS FALSE + AND ('1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0)) IS NOT FALSE + AND '1'||array_offset(mv_to_array("language"), 0) BETWEEN 0||array_offset(mv_to_array("language"), 0) AND 2||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) NOT BETWEEN '1'||array_offset(mv_to_array("language"), 0) AND 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) like '%' + AND '1'||array_offset(mv_to_array("language"), 0) not like '__DOES_NOT_EXIST__%' + AND '1'||array_offset(mv_to_array("language"), 0) IN (0||array_offset(mv_to_array("language"), 0), + 1||array_offset(mv_to_array("language"), 0), + 2||array_offset(mv_to_array("language"), 0)) + AND '1'||array_offset(mv_to_array("language"), 0) NOT IN (0||array_offset(mv_to_array("language"), 0), + 2||array_offset(mv_to_array("language"), 0)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||array_offset(mv_to_array("language"), 0), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||array_offset(mv_to_array("language"), 0) IS NULL + OR ('1'||array_offset(mv_to_array("language"), 0) = 1||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) IS NOT DISTINCT + FROM 1||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0) + AND ('1'||array_offset(mv_to_array("language"), 0) IS DISTINCT + FROM 0||array_offset(mv_to_array("language"), 0)) + AND '1'||array_offset(mv_to_array("language"), 0) > 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) >= 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) < 2||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) <= 2||array_offset(mv_to_array("language"), 0) + AND ('1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0)) IS TRUE + AND ('1'||array_offset(mv_to_array("language"), 0) = 0||array_offset(mv_to_array("language"), 0)) IS NOT TRUE + AND ('1'||array_offset(mv_to_array("language"), 0) = 0||array_offset(mv_to_array("language"), 0)) IS FALSE + AND ('1'||array_offset(mv_to_array("language"), 0) <> 0||array_offset(mv_to_array("language"), 0)) IS NOT FALSE + AND '1'||array_offset(mv_to_array("language"), 0) BETWEEN 0||array_offset(mv_to_array("language"), 0) AND 2||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) NOT BETWEEN '1'||array_offset(mv_to_array("language"), 0) AND 0||array_offset(mv_to_array("language"), 0) + AND '1'||array_offset(mv_to_array("language"), 0) like '%' + AND '1'||array_offset(mv_to_array("language"), 0) not like '__DOES_NOT_EXIST__%' + AND '1'||array_offset(mv_to_array("language"), 0) IN (0||array_offset(mv_to_array("language"), 0), + 1||array_offset(mv_to_array("language"), 0), + 2||array_offset(mv_to_array("language"), 0)) + AND '1'||array_offset(mv_to_array("language"), 0) NOT IN (0||array_offset(mv_to_array("language"), 0), + 2||array_offset(mv_to_array("language"), 0)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# Total query count 49 +#------------------------------------------------------------------------- diff --git a/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_scalar_other.iq b/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_scalar_other.iq new file mode 100644 index 00000000000..4a0b9561602 --- /dev/null +++ b/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_scalar_other.iq @@ -0,0 +1,3490 @@ +!set useApproximateCountDistinct false +!use druidtest:///?componentSupplier=KttmNestedComponentSupplier +!set outputformat mysql +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00'; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A1: case_scalar +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) IS NULL + OR ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) = 1||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) IS NOT DISTINCT + FROM 1||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) <> '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) IS DISTINCT + FROM '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) > '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) >= '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) < 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) <= 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) <> '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) IS TRUE + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) = '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) IS NOT TRUE + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) = '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) IS FALSE + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) <> '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) IS NOT FALSE + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) BETWEEN '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) AND 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) NOT BETWEEN '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) AND '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) like '%' + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) not like '__DOES_NOT_EXIST__%' + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) IN ('0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END), + 1||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END), + 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) NOT IN ('0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END), + 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) IS NULL + OR '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) IN + (SELECT '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) IS NULL + OR ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) = 1||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) IS NOT DISTINCT + FROM 1||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) <> '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) IS DISTINCT + FROM '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) > '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) >= '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) < 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) <= 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) <> '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) IS TRUE + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) = '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) IS NOT TRUE + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) = '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) IS FALSE + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) <> '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) IS NOT FALSE + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) BETWEEN '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) AND 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) NOT BETWEEN '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) AND '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) like '%' + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) not like '__DOES_NOT_EXIST__%' + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) IN ('0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END), + 1||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END), + 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) NOT IN ('0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END), + 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) IS NULL + OR ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) = 1||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) IS NOT DISTINCT + FROM 1||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) <> '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) IS DISTINCT + FROM '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) > '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) >= '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) < 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) <= 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) <> '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) IS TRUE + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) = '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) IS NOT TRUE + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) = '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) IS FALSE + AND ('1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) <> '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) IS NOT FALSE + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) BETWEEN '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) AND 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) NOT BETWEEN '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) AND '0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) like '%' + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) not like '__DOES_NOT_EXIST__%' + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) IN ('0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END), + 1||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END), + 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)) + AND '1'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END) NOT IN ('0'||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END), + 2||(CASE client_ip + WHEN server_ip THEN session_length + ELSE session_length+1 + END)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A2: case_complex +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS NULL + OR ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = 1||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS NOT DISTINCT + FROM 1||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS DISTINCT + FROM '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) > '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) >= '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) < 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <= 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS TRUE + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS NOT TRUE + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS FALSE + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS NOT FALSE + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) BETWEEN '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) AND 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) NOT BETWEEN '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) AND '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) like '%' + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) not like '__DOES_NOT_EXIST__%' + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IN ('0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 1||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) NOT IN ('0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS NULL + OR '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IN + (SELECT '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS NULL + OR ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = 1||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS NOT DISTINCT + FROM 1||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS DISTINCT + FROM '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) > '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) >= '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) < 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <= 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS TRUE + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS NOT TRUE + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS FALSE + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS NOT FALSE + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) BETWEEN '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) AND 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) NOT BETWEEN '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) AND '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) like '%' + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) not like '__DOES_NOT_EXIST__%' + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IN ('0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 1||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) NOT IN ('0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS NULL + OR ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = 1||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS NOT DISTINCT + FROM 1||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS DISTINCT + FROM '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) > '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) >= '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) < 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <= 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS TRUE + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS NOT TRUE + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS FALSE + AND ('1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS NOT FALSE + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) BETWEEN '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) AND 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) NOT BETWEEN '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) AND '0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) like '%' + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) not like '__DOES_NOT_EXIST__%' + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IN ('0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 1||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) + AND '1'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) NOT IN ('0'||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 2||(CASE session_length + WHEN session_length+1 THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A3: case_searched_scalar +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) IS NULL + OR ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) = 1||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) IS NOT DISTINCT + FROM 1||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) <> '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) IS DISTINCT + FROM '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) > '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) >= '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) < 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) <= 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) <> '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) IS TRUE + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) = '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) IS NOT TRUE + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) = '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) IS FALSE + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) <> '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) IS NOT FALSE + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) BETWEEN '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) AND 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) NOT BETWEEN '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) AND '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) like '%' + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) not like '__DOES_NOT_EXIST__%' + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) IN ('0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char), + 1||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char), + 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) NOT IN ('0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char), + 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) IS NULL + OR '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) IN + (SELECT '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) IS NULL + OR ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) = 1||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) IS NOT DISTINCT + FROM 1||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) <> '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) IS DISTINCT + FROM '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) > '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) >= '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) < 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) <= 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) <> '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) IS TRUE + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) = '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) IS NOT TRUE + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) = '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) IS FALSE + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) <> '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) IS NOT FALSE + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) BETWEEN '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) AND 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) NOT BETWEEN '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) AND '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) like '%' + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) not like '__DOES_NOT_EXIST__%' + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) IN ('0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char), + 1||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char), + 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) NOT IN ('0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char), + 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) IS NULL + OR ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) = 1||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) IS NOT DISTINCT + FROM 1||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) <> '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) IS DISTINCT + FROM '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) > '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) >= '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) < 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) <= 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) <> '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) IS TRUE + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) = '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) IS NOT TRUE + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) = '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) IS FALSE + AND ('1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) <> '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) IS NOT FALSE + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) BETWEEN '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) AND 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) NOT BETWEEN '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) AND '0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) like '%' + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) not like '__DOES_NOT_EXIST__%' + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) IN ('0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char), + 1||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char), + 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)) + AND '1'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char) NOT IN ('0'||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char), + 2||cast(CASE + WHEN client_ip=server_ip THEN session_length + ELSE session_length+1 + END AS char)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A4: case_searched_complex +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS NULL + OR ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = 1||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS NOT DISTINCT + FROM 1||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS DISTINCT + FROM '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) > '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) >= '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) < 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <= 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS TRUE + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS NOT TRUE + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS FALSE + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS NOT FALSE + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) BETWEEN '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) AND 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) NOT BETWEEN '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) AND '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) like '%' + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) not like '__DOES_NOT_EXIST__%' + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IN ('0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 1||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) NOT IN ('0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS NULL + OR '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IN + (SELECT '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS NULL + OR ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = 1||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS NOT DISTINCT + FROM 1||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS DISTINCT + FROM '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) > '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) >= '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) < 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <= 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS TRUE + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS NOT TRUE + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS FALSE + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS NOT FALSE + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) BETWEEN '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) AND 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) NOT BETWEEN '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) AND '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) like '%' + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) not like '__DOES_NOT_EXIST__%' + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IN ('0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 1||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) NOT IN ('0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS NULL + OR ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = 1||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS NOT DISTINCT + FROM 1||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IS DISTINCT + FROM '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) > '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) >= '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) < 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <= 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS TRUE + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS NOT TRUE + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) = '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS FALSE + AND ('1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) <> '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) IS NOT FALSE + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) BETWEEN '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) AND 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) NOT BETWEEN '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) AND '0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) like '%' + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) not like '__DOES_NOT_EXIST__%' + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) IN ('0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 1||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)) + AND '1'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END) NOT IN ('0'||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END), + 2||(CASE + WHEN json_value(agent, '$.browser')=json_value(agent, '$.browser_version') THEN json_value(agent, '$.browser') + ELSE json_value(agent, '$.browser_version') + END)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A5: cast_as_char +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||cast(session_length AS char) IS NULL + OR ('1'||cast(session_length AS char) = 1||cast(session_length AS char) + AND '1'||cast(session_length AS char) IS NOT DISTINCT + FROM 1||cast(session_length AS char) + AND '1'||cast(session_length AS char) <> '0'||cast(session_length AS char) + AND ('1'||cast(session_length AS char) IS DISTINCT + FROM '0'||cast(session_length AS char)) + AND '1'||cast(session_length AS char) > '0'||cast(session_length AS char) + AND '1'||cast(session_length AS char) >= '0'||cast(session_length AS char) + AND '1'||cast(session_length AS char) < 2||cast(session_length AS char) + AND '1'||cast(session_length AS char) <= 2||cast(session_length AS char) + AND ('1'||cast(session_length AS char) <> '0'||cast(session_length AS char)) IS TRUE + AND ('1'||cast(session_length AS char) = '0'||cast(session_length AS char)) IS NOT TRUE + AND ('1'||cast(session_length AS char) = '0'||cast(session_length AS char)) IS FALSE + AND ('1'||cast(session_length AS char) <> '0'||cast(session_length AS char)) IS NOT FALSE + AND '1'||cast(session_length AS char) BETWEEN '0'||cast(session_length AS char) AND 2||cast(session_length AS char) + AND '1'||cast(session_length AS char) NOT BETWEEN '1'||cast(session_length AS char) AND '0'||cast(session_length AS char) + AND '1'||cast(session_length AS char) like '%' + AND '1'||cast(session_length AS char) not like '__DOES_NOT_EXIST__%' + AND '1'||cast(session_length AS char) IN ('0'||cast(session_length AS char), + 1||cast(session_length AS char), + 2||cast(session_length AS char)) + AND '1'||cast(session_length AS char) NOT IN ('0'||cast(session_length AS char), + 2||cast(session_length AS char)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||cast(session_length AS char) IS NULL + OR '1'||cast(session_length AS char) IN + (SELECT '1'||cast(session_length AS char) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||cast(session_length AS char) IS NULL + OR ('1'||cast(session_length AS char) = 1||cast(session_length AS char) + AND '1'||cast(session_length AS char) IS NOT DISTINCT + FROM 1||cast(session_length AS char) + AND '1'||cast(session_length AS char) <> '0'||cast(session_length AS char) + AND ('1'||cast(session_length AS char) IS DISTINCT + FROM '0'||cast(session_length AS char)) + AND '1'||cast(session_length AS char) > '0'||cast(session_length AS char) + AND '1'||cast(session_length AS char) >= '0'||cast(session_length AS char) + AND '1'||cast(session_length AS char) < 2||cast(session_length AS char) + AND '1'||cast(session_length AS char) <= 2||cast(session_length AS char) + AND ('1'||cast(session_length AS char) <> '0'||cast(session_length AS char)) IS TRUE + AND ('1'||cast(session_length AS char) = '0'||cast(session_length AS char)) IS NOT TRUE + AND ('1'||cast(session_length AS char) = '0'||cast(session_length AS char)) IS FALSE + AND ('1'||cast(session_length AS char) <> '0'||cast(session_length AS char)) IS NOT FALSE + AND '1'||cast(session_length AS char) BETWEEN '0'||cast(session_length AS char) AND 2||cast(session_length AS char) + AND '1'||cast(session_length AS char) NOT BETWEEN '1'||cast(session_length AS char) AND '0'||cast(session_length AS char) + AND '1'||cast(session_length AS char) like '%' + AND '1'||cast(session_length AS char) not like '__DOES_NOT_EXIST__%' + AND '1'||cast(session_length AS char) IN ('0'||cast(session_length AS char), + 1||cast(session_length AS char), + 2||cast(session_length AS char)) + AND '1'||cast(session_length AS char) NOT IN ('0'||cast(session_length AS char), + 2||cast(session_length AS char)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||cast(session_length AS char), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||cast(session_length AS char) IS NULL + OR ('1'||cast(session_length AS char) = 1||cast(session_length AS char) + AND '1'||cast(session_length AS char) IS NOT DISTINCT + FROM 1||cast(session_length AS char) + AND '1'||cast(session_length AS char) <> '0'||cast(session_length AS char) + AND ('1'||cast(session_length AS char) IS DISTINCT + FROM '0'||cast(session_length AS char)) + AND '1'||cast(session_length AS char) > '0'||cast(session_length AS char) + AND '1'||cast(session_length AS char) >= '0'||cast(session_length AS char) + AND '1'||cast(session_length AS char) < 2||cast(session_length AS char) + AND '1'||cast(session_length AS char) <= 2||cast(session_length AS char) + AND ('1'||cast(session_length AS char) <> '0'||cast(session_length AS char)) IS TRUE + AND ('1'||cast(session_length AS char) = '0'||cast(session_length AS char)) IS NOT TRUE + AND ('1'||cast(session_length AS char) = '0'||cast(session_length AS char)) IS FALSE + AND ('1'||cast(session_length AS char) <> '0'||cast(session_length AS char)) IS NOT FALSE + AND '1'||cast(session_length AS char) BETWEEN '0'||cast(session_length AS char) AND 2||cast(session_length AS char) + AND '1'||cast(session_length AS char) NOT BETWEEN '1'||cast(session_length AS char) AND '0'||cast(session_length AS char) + AND '1'||cast(session_length AS char) like '%' + AND '1'||cast(session_length AS char) not like '__DOES_NOT_EXIST__%' + AND '1'||cast(session_length AS char) IN ('0'||cast(session_length AS char), + 1||cast(session_length AS char), + 2||cast(session_length AS char)) + AND '1'||cast(session_length AS char) NOT IN ('0'||cast(session_length AS char), + 2||cast(session_length AS char)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A6: cast_as_bigint +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (cast(ltrim("session", 'S') AS bigint)+1 IS NULL + OR (cast(ltrim("session", 'S') AS bigint)+1 = cast(ltrim("session", 'S') AS bigint)+1 + AND cast(ltrim("session", 'S') AS bigint)+1 IS NOT DISTINCT + FROM cast(ltrim("session", 'S') AS bigint)+1 + AND cast(ltrim("session", 'S') AS bigint)+1 <> cast(ltrim("session", 'S') AS bigint) + AND (cast(ltrim("session", 'S') AS bigint)+1 IS DISTINCT + FROM cast(ltrim("session", 'S') AS bigint)) + AND cast(ltrim("session", 'S') AS bigint)+1 > cast(ltrim("session", 'S') AS bigint) + AND cast(ltrim("session", 'S') AS bigint)+1 >= cast(ltrim("session", 'S') AS bigint) + AND cast(ltrim("session", 'S') AS bigint)+1 < cast(ltrim("session", 'S') AS bigint)+2 + AND cast(ltrim("session", 'S') AS bigint)+1 <= cast(ltrim("session", 'S') AS bigint)+2 + AND (cast(ltrim("session", 'S') AS bigint)+1 <> cast(ltrim("session", 'S') AS bigint)) IS TRUE + AND (cast(ltrim("session", 'S') AS bigint)+1 = cast(ltrim("session", 'S') AS bigint)) IS NOT TRUE + AND (cast(ltrim("session", 'S') AS bigint)+1 = cast(ltrim("session", 'S') AS bigint)) IS FALSE + AND (cast(ltrim("session", 'S') AS bigint)+1 <> cast(ltrim("session", 'S') AS bigint)) IS NOT FALSE + AND cast(ltrim("session", 'S') AS bigint)+1 BETWEEN cast(ltrim("session", 'S') AS bigint) AND cast(ltrim("session", 'S') AS bigint)+2 + AND cast(ltrim("session", 'S') AS bigint)+1 NOT BETWEEN cast(ltrim("session", 'S') AS bigint)+1 AND cast(ltrim("session", 'S') AS bigint) + AND cast(ltrim("session", 'S') AS bigint)+1 like '%' + AND cast(ltrim("session", 'S') AS bigint)+1 not like '__DOES_NOT_EXIST__%' + AND cast(ltrim("session", 'S') AS bigint)+1 IN (cast(ltrim("session", 'S') AS bigint), + cast(ltrim("session", 'S') AS bigint)+1, + cast(ltrim("session", 'S') AS bigint)+2) + AND cast(ltrim("session", 'S') AS bigint)+1 NOT IN (cast(ltrim("session", 'S') AS bigint), + cast(ltrim("session", 'S') AS bigint)+2))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (cast(ltrim("session", 'S') AS bigint)+1 IS NULL + OR cast(ltrim("session", 'S') AS bigint)+1 IN + (SELECT cast(ltrim("session", 'S') AS bigint)+1 + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (cast(ltrim("session", 'S') AS bigint)+1 IS NULL + OR (cast(ltrim("session", 'S') AS bigint)+1 = cast(ltrim("session", 'S') AS bigint)+1 + AND cast(ltrim("session", 'S') AS bigint)+1 IS NOT DISTINCT + FROM cast(ltrim("session", 'S') AS bigint)+1 + AND cast(ltrim("session", 'S') AS bigint)+1 <> cast(ltrim("session", 'S') AS bigint) + AND (cast(ltrim("session", 'S') AS bigint)+1 IS DISTINCT + FROM cast(ltrim("session", 'S') AS bigint)) + AND cast(ltrim("session", 'S') AS bigint)+1 > cast(ltrim("session", 'S') AS bigint) + AND cast(ltrim("session", 'S') AS bigint)+1 >= cast(ltrim("session", 'S') AS bigint) + AND cast(ltrim("session", 'S') AS bigint)+1 < cast(ltrim("session", 'S') AS bigint)+2 + AND cast(ltrim("session", 'S') AS bigint)+1 <= cast(ltrim("session", 'S') AS bigint)+2 + AND (cast(ltrim("session", 'S') AS bigint)+1 <> cast(ltrim("session", 'S') AS bigint)) IS TRUE + AND (cast(ltrim("session", 'S') AS bigint)+1 = cast(ltrim("session", 'S') AS bigint)) IS NOT TRUE + AND (cast(ltrim("session", 'S') AS bigint)+1 = cast(ltrim("session", 'S') AS bigint)) IS FALSE + AND (cast(ltrim("session", 'S') AS bigint)+1 <> cast(ltrim("session", 'S') AS bigint)) IS NOT FALSE + AND cast(ltrim("session", 'S') AS bigint)+1 BETWEEN cast(ltrim("session", 'S') AS bigint) AND cast(ltrim("session", 'S') AS bigint)+2 + AND cast(ltrim("session", 'S') AS bigint)+1 NOT BETWEEN cast(ltrim("session", 'S') AS bigint)+1 AND cast(ltrim("session", 'S') AS bigint) + AND cast(ltrim("session", 'S') AS bigint)+1 like '%' + AND cast(ltrim("session", 'S') AS bigint)+1 not like '__DOES_NOT_EXIST__%' + AND cast(ltrim("session", 'S') AS bigint)+1 IN (cast(ltrim("session", 'S') AS bigint), + cast(ltrim("session", 'S') AS bigint)+1, + cast(ltrim("session", 'S') AS bigint)+2) + AND cast(ltrim("session", 'S') AS bigint)+1 NOT IN (cast(ltrim("session", 'S') AS bigint), + cast(ltrim("session", 'S') AS bigint)+2))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + cast(ltrim("session", 'S') AS bigint)+1, + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (cast(ltrim("session", 'S') AS bigint)+1 IS NULL + OR (cast(ltrim("session", 'S') AS bigint)+1 = cast(ltrim("session", 'S') AS bigint)+1 + AND cast(ltrim("session", 'S') AS bigint)+1 IS NOT DISTINCT + FROM cast(ltrim("session", 'S') AS bigint)+1 + AND cast(ltrim("session", 'S') AS bigint)+1 <> cast(ltrim("session", 'S') AS bigint) + AND (cast(ltrim("session", 'S') AS bigint)+1 IS DISTINCT + FROM cast(ltrim("session", 'S') AS bigint)) + AND cast(ltrim("session", 'S') AS bigint)+1 > cast(ltrim("session", 'S') AS bigint) + AND cast(ltrim("session", 'S') AS bigint)+1 >= cast(ltrim("session", 'S') AS bigint) + AND cast(ltrim("session", 'S') AS bigint)+1 < cast(ltrim("session", 'S') AS bigint)+2 + AND cast(ltrim("session", 'S') AS bigint)+1 <= cast(ltrim("session", 'S') AS bigint)+2 + AND (cast(ltrim("session", 'S') AS bigint)+1 <> cast(ltrim("session", 'S') AS bigint)) IS TRUE + AND (cast(ltrim("session", 'S') AS bigint)+1 = cast(ltrim("session", 'S') AS bigint)) IS NOT TRUE + AND (cast(ltrim("session", 'S') AS bigint)+1 = cast(ltrim("session", 'S') AS bigint)) IS FALSE + AND (cast(ltrim("session", 'S') AS bigint)+1 <> cast(ltrim("session", 'S') AS bigint)) IS NOT FALSE + AND cast(ltrim("session", 'S') AS bigint)+1 BETWEEN cast(ltrim("session", 'S') AS bigint) AND cast(ltrim("session", 'S') AS bigint)+2 + AND cast(ltrim("session", 'S') AS bigint)+1 NOT BETWEEN cast(ltrim("session", 'S') AS bigint)+1 AND cast(ltrim("session", 'S') AS bigint) + AND cast(ltrim("session", 'S') AS bigint)+1 like '%' + AND cast(ltrim("session", 'S') AS bigint)+1 not like '__DOES_NOT_EXIST__%' + AND cast(ltrim("session", 'S') AS bigint)+1 IN (cast(ltrim("session", 'S') AS bigint), + cast(ltrim("session", 'S') AS bigint)+1, + cast(ltrim("session", 'S') AS bigint)+2) + AND cast(ltrim("session", 'S') AS bigint)+1 NOT IN (cast(ltrim("session", 'S') AS bigint), + cast(ltrim("session", 'S') AS bigint)+2))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A7: cast_as_float +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (floor(cast(ltrim("session", 'S') AS float))+1 IS NULL + OR (floor(cast(ltrim("session", 'S') AS float))+1 = floor(cast(ltrim("session", 'S') AS float))+1 + AND floor(cast(ltrim("session", 'S') AS float))+1 IS NOT DISTINCT + FROM floor(cast(ltrim("session", 'S') AS float))+1 + AND floor(cast(ltrim("session", 'S') AS float))+1 <> floor(cast(ltrim("session", 'S') AS float)) + AND (floor(cast(ltrim("session", 'S') AS float))+1 IS DISTINCT + FROM floor(cast(ltrim("session", 'S') AS float))) + AND floor(cast(ltrim("session", 'S') AS float))+1 > floor(cast(ltrim("session", 'S') AS float)) + AND floor(cast(ltrim("session", 'S') AS float))+1 >= floor(cast(ltrim("session", 'S') AS float)) + AND floor(cast(ltrim("session", 'S') AS float))+1 < floor(cast(ltrim("session", 'S') AS float))+2 + AND floor(cast(ltrim("session", 'S') AS float))+1 <= floor(cast(ltrim("session", 'S') AS float))+2 + AND (floor(cast(ltrim("session", 'S') AS float))+1 <> floor(cast(ltrim("session", 'S') AS float))) IS TRUE + AND (floor(cast(ltrim("session", 'S') AS float))+1 = floor(cast(ltrim("session", 'S') AS float))) IS NOT TRUE + AND (floor(cast(ltrim("session", 'S') AS float))+1 = floor(cast(ltrim("session", 'S') AS float))) IS FALSE + AND (floor(cast(ltrim("session", 'S') AS float))+1 <> floor(cast(ltrim("session", 'S') AS float))) IS NOT FALSE + AND floor(cast(ltrim("session", 'S') AS float))+1 BETWEEN floor(cast(ltrim("session", 'S') AS float)) AND floor(cast(ltrim("session", 'S') AS float))+2 + AND floor(cast(ltrim("session", 'S') AS float))+1 NOT BETWEEN floor(cast(ltrim("session", 'S') AS float))+1 AND floor(cast(ltrim("session", 'S') AS float)) + AND floor(cast(ltrim("session", 'S') AS float))+1 like '%' + AND floor(cast(ltrim("session", 'S') AS float))+1 not like '__DOES_NOT_EXIST__%' + AND floor(cast(ltrim("session", 'S') AS float))+1 IN (floor(cast(ltrim("session", 'S') AS float)), + floor(cast(ltrim("session", 'S') AS float))+1, + floor(cast(ltrim("session", 'S') AS float))+2) + AND floor(cast(ltrim("session", 'S') AS float))+1 NOT IN (floor(cast(ltrim("session", 'S') AS float)), + floor(cast(ltrim("session", 'S') AS float))+2))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (floor(cast(ltrim("session", 'S') AS float))+1 IS NULL + OR floor(cast(ltrim("session", 'S') AS float))+1 IN + (SELECT floor(cast(ltrim("session", 'S') AS float))+1 + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (floor(cast(ltrim("session", 'S') AS float))+1 IS NULL + OR (floor(cast(ltrim("session", 'S') AS float))+1 = floor(cast(ltrim("session", 'S') AS float))+1 + AND floor(cast(ltrim("session", 'S') AS float))+1 IS NOT DISTINCT + FROM floor(cast(ltrim("session", 'S') AS float))+1 + AND floor(cast(ltrim("session", 'S') AS float))+1 <> floor(cast(ltrim("session", 'S') AS float)) + AND (floor(cast(ltrim("session", 'S') AS float))+1 IS DISTINCT + FROM floor(cast(ltrim("session", 'S') AS float))) + AND floor(cast(ltrim("session", 'S') AS float))+1 > floor(cast(ltrim("session", 'S') AS float)) + AND floor(cast(ltrim("session", 'S') AS float))+1 >= floor(cast(ltrim("session", 'S') AS float)) + AND floor(cast(ltrim("session", 'S') AS float))+1 < floor(cast(ltrim("session", 'S') AS float))+2 + AND floor(cast(ltrim("session", 'S') AS float))+1 <= floor(cast(ltrim("session", 'S') AS float))+2 + AND (floor(cast(ltrim("session", 'S') AS float))+1 <> floor(cast(ltrim("session", 'S') AS float))) IS TRUE + AND (floor(cast(ltrim("session", 'S') AS float))+1 = floor(cast(ltrim("session", 'S') AS float))) IS NOT TRUE + AND (floor(cast(ltrim("session", 'S') AS float))+1 = floor(cast(ltrim("session", 'S') AS float))) IS FALSE + AND (floor(cast(ltrim("session", 'S') AS float))+1 <> floor(cast(ltrim("session", 'S') AS float))) IS NOT FALSE + AND floor(cast(ltrim("session", 'S') AS float))+1 BETWEEN floor(cast(ltrim("session", 'S') AS float)) AND floor(cast(ltrim("session", 'S') AS float))+2 + AND floor(cast(ltrim("session", 'S') AS float))+1 NOT BETWEEN floor(cast(ltrim("session", 'S') AS float))+1 AND floor(cast(ltrim("session", 'S') AS float)) + AND floor(cast(ltrim("session", 'S') AS float))+1 like '%' + AND floor(cast(ltrim("session", 'S') AS float))+1 not like '__DOES_NOT_EXIST__%' + AND floor(cast(ltrim("session", 'S') AS float))+1 IN (floor(cast(ltrim("session", 'S') AS float)), + floor(cast(ltrim("session", 'S') AS float))+1, + floor(cast(ltrim("session", 'S') AS float))+2) + AND floor(cast(ltrim("session", 'S') AS float))+1 NOT IN (floor(cast(ltrim("session", 'S') AS float)), + floor(cast(ltrim("session", 'S') AS float))+2))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + floor(cast(ltrim("session", 'S') AS float))+1, + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (floor(cast(ltrim("session", 'S') AS float))+1 IS NULL + OR (floor(cast(ltrim("session", 'S') AS float))+1 = floor(cast(ltrim("session", 'S') AS float))+1 + AND floor(cast(ltrim("session", 'S') AS float))+1 IS NOT DISTINCT + FROM floor(cast(ltrim("session", 'S') AS float))+1 + AND floor(cast(ltrim("session", 'S') AS float))+1 <> floor(cast(ltrim("session", 'S') AS float)) + AND (floor(cast(ltrim("session", 'S') AS float))+1 IS DISTINCT + FROM floor(cast(ltrim("session", 'S') AS float))) + AND floor(cast(ltrim("session", 'S') AS float))+1 > floor(cast(ltrim("session", 'S') AS float)) + AND floor(cast(ltrim("session", 'S') AS float))+1 >= floor(cast(ltrim("session", 'S') AS float)) + AND floor(cast(ltrim("session", 'S') AS float))+1 < floor(cast(ltrim("session", 'S') AS float))+2 + AND floor(cast(ltrim("session", 'S') AS float))+1 <= floor(cast(ltrim("session", 'S') AS float))+2 + AND (floor(cast(ltrim("session", 'S') AS float))+1 <> floor(cast(ltrim("session", 'S') AS float))) IS TRUE + AND (floor(cast(ltrim("session", 'S') AS float))+1 = floor(cast(ltrim("session", 'S') AS float))) IS NOT TRUE + AND (floor(cast(ltrim("session", 'S') AS float))+1 = floor(cast(ltrim("session", 'S') AS float))) IS FALSE + AND (floor(cast(ltrim("session", 'S') AS float))+1 <> floor(cast(ltrim("session", 'S') AS float))) IS NOT FALSE + AND floor(cast(ltrim("session", 'S') AS float))+1 BETWEEN floor(cast(ltrim("session", 'S') AS float)) AND floor(cast(ltrim("session", 'S') AS float))+2 + AND floor(cast(ltrim("session", 'S') AS float))+1 NOT BETWEEN floor(cast(ltrim("session", 'S') AS float))+1 AND floor(cast(ltrim("session", 'S') AS float)) + AND floor(cast(ltrim("session", 'S') AS float))+1 like '%' + AND floor(cast(ltrim("session", 'S') AS float))+1 not like '__DOES_NOT_EXIST__%' + AND floor(cast(ltrim("session", 'S') AS float))+1 IN (floor(cast(ltrim("session", 'S') AS float)), + floor(cast(ltrim("session", 'S') AS float))+1, + floor(cast(ltrim("session", 'S') AS float))+2) + AND floor(cast(ltrim("session", 'S') AS float))+1 NOT IN (floor(cast(ltrim("session", 'S') AS float)), + floor(cast(ltrim("session", 'S') AS float))+2))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A8: cast_as_double +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 IS NULL + OR (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 = floor(cast(ltrim("session", 'S') AS DOUBLE))+1 + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 IS NOT DISTINCT + FROM floor(cast(ltrim("session", 'S') AS DOUBLE))+1 + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 <> floor(cast(ltrim("session", 'S') AS DOUBLE)) + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 IS DISTINCT + FROM floor(cast(ltrim("session", 'S') AS DOUBLE))) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 > floor(cast(ltrim("session", 'S') AS DOUBLE)) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 >= floor(cast(ltrim("session", 'S') AS DOUBLE)) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 < floor(cast(ltrim("session", 'S') AS DOUBLE))+2 + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 <= floor(cast(ltrim("session", 'S') AS DOUBLE))+2 + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 <> floor(cast(ltrim("session", 'S') AS DOUBLE))) IS TRUE + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 = floor(cast(ltrim("session", 'S') AS DOUBLE))) IS NOT TRUE + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 = floor(cast(ltrim("session", 'S') AS DOUBLE))) IS FALSE + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 <> floor(cast(ltrim("session", 'S') AS DOUBLE))) IS NOT FALSE + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 BETWEEN floor(cast(ltrim("session", 'S') AS DOUBLE)) AND floor(cast(ltrim("session", 'S') AS DOUBLE))+2 + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 NOT BETWEEN floor(cast(ltrim("session", 'S') AS DOUBLE))+1 AND floor(cast(ltrim("session", 'S') AS DOUBLE)) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 like '%' + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 not like '__DOES_NOT_EXIST__%' + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 IN (floor(cast(ltrim("session", 'S') AS DOUBLE)), + floor(cast(ltrim("session", 'S') AS DOUBLE))+1, + floor(cast(ltrim("session", 'S') AS DOUBLE))+2) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 NOT IN (floor(cast(ltrim("session", 'S') AS DOUBLE)), + floor(cast(ltrim("session", 'S') AS DOUBLE))+2))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 IS NULL + OR floor(cast(ltrim("session", 'S') AS DOUBLE))+1 IN + (SELECT floor(cast(ltrim("session", 'S') AS DOUBLE))+1 + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 IS NULL + OR (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 = floor(cast(ltrim("session", 'S') AS DOUBLE))+1 + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 IS NOT DISTINCT + FROM floor(cast(ltrim("session", 'S') AS DOUBLE))+1 + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 <> floor(cast(ltrim("session", 'S') AS DOUBLE)) + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 IS DISTINCT + FROM floor(cast(ltrim("session", 'S') AS DOUBLE))) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 > floor(cast(ltrim("session", 'S') AS DOUBLE)) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 >= floor(cast(ltrim("session", 'S') AS DOUBLE)) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 < floor(cast(ltrim("session", 'S') AS DOUBLE))+2 + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 <= floor(cast(ltrim("session", 'S') AS DOUBLE))+2 + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 <> floor(cast(ltrim("session", 'S') AS DOUBLE))) IS TRUE + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 = floor(cast(ltrim("session", 'S') AS DOUBLE))) IS NOT TRUE + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 = floor(cast(ltrim("session", 'S') AS DOUBLE))) IS FALSE + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 <> floor(cast(ltrim("session", 'S') AS DOUBLE))) IS NOT FALSE + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 BETWEEN floor(cast(ltrim("session", 'S') AS DOUBLE)) AND floor(cast(ltrim("session", 'S') AS DOUBLE))+2 + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 NOT BETWEEN floor(cast(ltrim("session", 'S') AS DOUBLE))+1 AND floor(cast(ltrim("session", 'S') AS DOUBLE)) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 like '%' + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 not like '__DOES_NOT_EXIST__%' + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 IN (floor(cast(ltrim("session", 'S') AS DOUBLE)), + floor(cast(ltrim("session", 'S') AS DOUBLE))+1, + floor(cast(ltrim("session", 'S') AS DOUBLE))+2) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 NOT IN (floor(cast(ltrim("session", 'S') AS DOUBLE)), + floor(cast(ltrim("session", 'S') AS DOUBLE))+2))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + floor(cast(ltrim("session", 'S') AS DOUBLE))+1, + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 IS NULL + OR (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 = floor(cast(ltrim("session", 'S') AS DOUBLE))+1 + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 IS NOT DISTINCT + FROM floor(cast(ltrim("session", 'S') AS DOUBLE))+1 + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 <> floor(cast(ltrim("session", 'S') AS DOUBLE)) + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 IS DISTINCT + FROM floor(cast(ltrim("session", 'S') AS DOUBLE))) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 > floor(cast(ltrim("session", 'S') AS DOUBLE)) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 >= floor(cast(ltrim("session", 'S') AS DOUBLE)) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 < floor(cast(ltrim("session", 'S') AS DOUBLE))+2 + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 <= floor(cast(ltrim("session", 'S') AS DOUBLE))+2 + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 <> floor(cast(ltrim("session", 'S') AS DOUBLE))) IS TRUE + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 = floor(cast(ltrim("session", 'S') AS DOUBLE))) IS NOT TRUE + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 = floor(cast(ltrim("session", 'S') AS DOUBLE))) IS FALSE + AND (floor(cast(ltrim("session", 'S') AS DOUBLE))+1 <> floor(cast(ltrim("session", 'S') AS DOUBLE))) IS NOT FALSE + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 BETWEEN floor(cast(ltrim("session", 'S') AS DOUBLE)) AND floor(cast(ltrim("session", 'S') AS DOUBLE))+2 + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 NOT BETWEEN floor(cast(ltrim("session", 'S') AS DOUBLE))+1 AND floor(cast(ltrim("session", 'S') AS DOUBLE)) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 like '%' + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 not like '__DOES_NOT_EXIST__%' + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 IN (floor(cast(ltrim("session", 'S') AS DOUBLE)), + floor(cast(ltrim("session", 'S') AS DOUBLE))+1, + floor(cast(ltrim("session", 'S') AS DOUBLE))+2) + AND floor(cast(ltrim("session", 'S') AS DOUBLE))+1 NOT IN (floor(cast(ltrim("session", 'S') AS DOUBLE)), + floor(cast(ltrim("session", 'S') AS DOUBLE))+2))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A9: cast_as_boolean +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) IS NULL + OR ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) = 1||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) IS NOT DISTINCT + FROM 1||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) <> '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) IS DISTINCT + FROM '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) > '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) >= '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) < 2||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) <= 2||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) <> '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) IS TRUE + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) = '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) IS NOT TRUE + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) = '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) IS FALSE + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) <> '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) IS NOT FALSE + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) BETWEEN '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) AND 2||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) NOT BETWEEN '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) AND '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) like '%' + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) not like '__DOES_NOT_EXIST__%' + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) IN ('0'||cast(cast(ltrim("session", 'S') AS boolean) AS char), + 1||cast(cast(ltrim("session", 'S') AS boolean) AS char), + 2||cast(cast(ltrim("session", 'S') AS boolean) AS char)) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) NOT IN ('0'||cast(cast(ltrim("session", 'S') AS boolean) AS char), + 2||cast(cast(ltrim("session", 'S') AS boolean) AS char)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) IS NULL + OR '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) IN + (SELECT '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) IS NULL + OR ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) = 1||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) IS NOT DISTINCT + FROM 1||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) <> '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) IS DISTINCT + FROM '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) > '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) >= '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) < 2||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) <= 2||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) <> '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) IS TRUE + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) = '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) IS NOT TRUE + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) = '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) IS FALSE + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) <> '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) IS NOT FALSE + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) BETWEEN '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) AND 2||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) NOT BETWEEN '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) AND '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) like '%' + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) not like '__DOES_NOT_EXIST__%' + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) IN ('0'||cast(cast(ltrim("session", 'S') AS boolean) AS char), + 1||cast(cast(ltrim("session", 'S') AS boolean) AS char), + 2||cast(cast(ltrim("session", 'S') AS boolean) AS char)) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) NOT IN ('0'||cast(cast(ltrim("session", 'S') AS boolean) AS char), + 2||cast(cast(ltrim("session", 'S') AS boolean) AS char)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) IS NULL + OR ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) = 1||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) IS NOT DISTINCT + FROM 1||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) <> '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) IS DISTINCT + FROM '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) > '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) >= '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) < 2||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) <= 2||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) <> '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) IS TRUE + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) = '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) IS NOT TRUE + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) = '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) IS FALSE + AND ('1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) <> '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char)) IS NOT FALSE + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) BETWEEN '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) AND 2||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) NOT BETWEEN '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) AND '0'||cast(cast(ltrim("session", 'S') AS boolean) AS char) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) like '%' + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) not like '__DOES_NOT_EXIST__%' + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) IN ('0'||cast(cast(ltrim("session", 'S') AS boolean) AS char), + 1||cast(cast(ltrim("session", 'S') AS boolean) AS char), + 2||cast(cast(ltrim("session", 'S') AS boolean) AS char)) + AND '1'||cast(cast(ltrim("session", 'S') AS boolean) AS char) NOT IN ('0'||cast(cast(ltrim("session", 'S') AS boolean) AS char), + 2||cast(cast(ltrim("session", 'S') AS boolean) AS char)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A10: cast_as_timestamp +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (cast(session_length AS timestamp) IS NULL + OR (cast(session_length AS timestamp) = cast(session_length AS timestamp) + AND cast(session_length AS timestamp) IS NOT DISTINCT + FROM cast(session_length AS timestamp) + AND cast(session_length AS timestamp) <> cast(session_length AS timestamp) - interval '2' YEAR + AND (cast(session_length AS timestamp) IS DISTINCT + FROM cast(session_length AS timestamp) - interval '2' YEAR) + AND cast(session_length AS timestamp) > cast(session_length AS timestamp) - interval '2' YEAR + AND cast(session_length AS timestamp) >= cast(session_length AS timestamp) - interval '2' YEAR + AND cast(session_length AS timestamp) < cast(session_length AS timestamp) + interval '2' YEAR + AND cast(session_length AS timestamp) <= cast(session_length AS timestamp) + interval '2' YEAR + AND (cast(session_length AS timestamp) <> cast(session_length AS timestamp) - interval '2' YEAR) IS TRUE + AND (cast(session_length AS timestamp) = cast(session_length AS timestamp) - interval '2' YEAR) IS NOT TRUE + AND (cast(session_length AS timestamp) = cast(session_length AS timestamp) - interval '2' YEAR) IS FALSE + AND (cast(session_length AS timestamp) <> cast(session_length AS timestamp) - interval '2' YEAR) IS NOT FALSE + AND cast(session_length AS timestamp) BETWEEN cast(session_length AS timestamp) - interval '2' YEAR AND cast(session_length AS timestamp) + interval '2' YEAR + AND cast(session_length AS timestamp) NOT BETWEEN cast(session_length AS timestamp) AND cast(session_length AS timestamp) - interval '2' YEAR + AND cast(session_length AS timestamp) like '%' + AND cast(session_length AS timestamp) not like '__DOES_NOT_EXIST__%' + AND cast(session_length AS timestamp) IN (cast(session_length AS timestamp) - interval '2' YEAR, + cast(session_length AS timestamp), + cast(session_length AS timestamp) + interval '2' YEAR) + AND cast(session_length AS timestamp) NOT IN (cast(session_length AS timestamp) - interval '2' YEAR, + cast(session_length AS timestamp) + interval '2' YEAR))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (cast(session_length AS timestamp) IS NULL + OR cast(session_length AS timestamp) IN + (SELECT cast(session_length AS timestamp) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (cast(session_length AS timestamp) IS NULL + OR (cast(session_length AS timestamp) = cast(session_length AS timestamp) + AND cast(session_length AS timestamp) IS NOT DISTINCT + FROM cast(session_length AS timestamp) + AND cast(session_length AS timestamp) <> cast(session_length AS timestamp) - interval '2' YEAR + AND (cast(session_length AS timestamp) IS DISTINCT + FROM cast(session_length AS timestamp) - interval '2' YEAR) + AND cast(session_length AS timestamp) > cast(session_length AS timestamp) - interval '2' YEAR + AND cast(session_length AS timestamp) >= cast(session_length AS timestamp) - interval '2' YEAR + AND cast(session_length AS timestamp) < cast(session_length AS timestamp) + interval '2' YEAR + AND cast(session_length AS timestamp) <= cast(session_length AS timestamp) + interval '2' YEAR + AND (cast(session_length AS timestamp) <> cast(session_length AS timestamp) - interval '2' YEAR) IS TRUE + AND (cast(session_length AS timestamp) = cast(session_length AS timestamp) - interval '2' YEAR) IS NOT TRUE + AND (cast(session_length AS timestamp) = cast(session_length AS timestamp) - interval '2' YEAR) IS FALSE + AND (cast(session_length AS timestamp) <> cast(session_length AS timestamp) - interval '2' YEAR) IS NOT FALSE + AND cast(session_length AS timestamp) BETWEEN cast(session_length AS timestamp) - interval '2' YEAR AND cast(session_length AS timestamp) + interval '2' YEAR + AND cast(session_length AS timestamp) NOT BETWEEN cast(session_length AS timestamp) AND cast(session_length AS timestamp) - interval '2' YEAR + AND cast(session_length AS timestamp) like '%' + AND cast(session_length AS timestamp) not like '__DOES_NOT_EXIST__%' + AND cast(session_length AS timestamp) IN (cast(session_length AS timestamp) - interval '2' YEAR, + cast(session_length AS timestamp), + cast(session_length AS timestamp) + interval '2' YEAR) + AND cast(session_length AS timestamp) NOT IN (cast(session_length AS timestamp) - interval '2' YEAR, + cast(session_length AS timestamp) + interval '2' YEAR))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + cast(session_length AS timestamp), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND (cast(session_length AS timestamp) IS NULL + OR (cast(session_length AS timestamp) = cast(session_length AS timestamp) + AND cast(session_length AS timestamp) IS NOT DISTINCT + FROM cast(session_length AS timestamp) + AND cast(session_length AS timestamp) <> cast(session_length AS timestamp) - interval '2' YEAR + AND (cast(session_length AS timestamp) IS DISTINCT + FROM cast(session_length AS timestamp) - interval '2' YEAR) + AND cast(session_length AS timestamp) > cast(session_length AS timestamp) - interval '2' YEAR + AND cast(session_length AS timestamp) >= cast(session_length AS timestamp) - interval '2' YEAR + AND cast(session_length AS timestamp) < cast(session_length AS timestamp) + interval '2' YEAR + AND cast(session_length AS timestamp) <= cast(session_length AS timestamp) + interval '2' YEAR + AND (cast(session_length AS timestamp) <> cast(session_length AS timestamp) - interval '2' YEAR) IS TRUE + AND (cast(session_length AS timestamp) = cast(session_length AS timestamp) - interval '2' YEAR) IS NOT TRUE + AND (cast(session_length AS timestamp) = cast(session_length AS timestamp) - interval '2' YEAR) IS FALSE + AND (cast(session_length AS timestamp) <> cast(session_length AS timestamp) - interval '2' YEAR) IS NOT FALSE + AND cast(session_length AS timestamp) BETWEEN cast(session_length AS timestamp) - interval '2' YEAR AND cast(session_length AS timestamp) + interval '2' YEAR + AND cast(session_length AS timestamp) NOT BETWEEN cast(session_length AS timestamp) AND cast(session_length AS timestamp) - interval '2' YEAR + AND cast(session_length AS timestamp) like '%' + AND cast(session_length AS timestamp) not like '__DOES_NOT_EXIST__%' + AND cast(session_length AS timestamp) IN (cast(session_length AS timestamp) - interval '2' YEAR, + cast(session_length AS timestamp), + cast(session_length AS timestamp) + interval '2' YEAR) + AND cast(session_length AS timestamp) NOT IN (cast(session_length AS timestamp) - interval '2' YEAR, + cast(session_length AS timestamp) + interval '2' YEAR))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A11: coalesce_scalar +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||coalesce(client_ip, server_ip) IS NULL + OR ('1'||coalesce(client_ip, server_ip) = 1||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) IS NOT DISTINCT + FROM 1||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) <> '0'||coalesce(client_ip, server_ip) + AND ('1'||coalesce(client_ip, server_ip) IS DISTINCT + FROM '0'||coalesce(client_ip, server_ip)) + AND '1'||coalesce(client_ip, server_ip) > '0'||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) >= '0'||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) < 2||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) <= 2||coalesce(client_ip, server_ip) + AND ('1'||coalesce(client_ip, server_ip) <> '0'||coalesce(client_ip, server_ip)) IS TRUE + AND ('1'||coalesce(client_ip, server_ip) = '0'||coalesce(client_ip, server_ip)) IS NOT TRUE + AND ('1'||coalesce(client_ip, server_ip) = '0'||coalesce(client_ip, server_ip)) IS FALSE + AND ('1'||coalesce(client_ip, server_ip) <> '0'||coalesce(client_ip, server_ip)) IS NOT FALSE + AND '1'||coalesce(client_ip, server_ip) BETWEEN '0'||coalesce(client_ip, server_ip) AND 2||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) NOT BETWEEN '1'||coalesce(client_ip, server_ip) AND '0'||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) like '%' + AND '1'||coalesce(client_ip, server_ip) not like '__DOES_NOT_EXIST__%' + AND '1'||coalesce(client_ip, server_ip) IN ('0'||coalesce(client_ip, server_ip), + 1||coalesce(client_ip, server_ip), + 2||coalesce(client_ip, server_ip)) + AND '1'||coalesce(client_ip, server_ip) NOT IN ('0'||coalesce(client_ip, server_ip), + 2||coalesce(client_ip, server_ip)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||coalesce(client_ip, server_ip) IS NULL + OR '1'||coalesce(client_ip, server_ip) IN + (SELECT '1'||coalesce(client_ip, server_ip) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||coalesce(client_ip, server_ip) IS NULL + OR ('1'||coalesce(client_ip, server_ip) = 1||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) IS NOT DISTINCT + FROM 1||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) <> '0'||coalesce(client_ip, server_ip) + AND ('1'||coalesce(client_ip, server_ip) IS DISTINCT + FROM '0'||coalesce(client_ip, server_ip)) + AND '1'||coalesce(client_ip, server_ip) > '0'||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) >= '0'||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) < 2||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) <= 2||coalesce(client_ip, server_ip) + AND ('1'||coalesce(client_ip, server_ip) <> '0'||coalesce(client_ip, server_ip)) IS TRUE + AND ('1'||coalesce(client_ip, server_ip) = '0'||coalesce(client_ip, server_ip)) IS NOT TRUE + AND ('1'||coalesce(client_ip, server_ip) = '0'||coalesce(client_ip, server_ip)) IS FALSE + AND ('1'||coalesce(client_ip, server_ip) <> '0'||coalesce(client_ip, server_ip)) IS NOT FALSE + AND '1'||coalesce(client_ip, server_ip) BETWEEN '0'||coalesce(client_ip, server_ip) AND 2||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) NOT BETWEEN '1'||coalesce(client_ip, server_ip) AND '0'||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) like '%' + AND '1'||coalesce(client_ip, server_ip) not like '__DOES_NOT_EXIST__%' + AND '1'||coalesce(client_ip, server_ip) IN ('0'||coalesce(client_ip, server_ip), + 1||coalesce(client_ip, server_ip), + 2||coalesce(client_ip, server_ip)) + AND '1'||coalesce(client_ip, server_ip) NOT IN ('0'||coalesce(client_ip, server_ip), + 2||coalesce(client_ip, server_ip)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||coalesce(client_ip, server_ip), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||coalesce(client_ip, server_ip) IS NULL + OR ('1'||coalesce(client_ip, server_ip) = 1||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) IS NOT DISTINCT + FROM 1||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) <> '0'||coalesce(client_ip, server_ip) + AND ('1'||coalesce(client_ip, server_ip) IS DISTINCT + FROM '0'||coalesce(client_ip, server_ip)) + AND '1'||coalesce(client_ip, server_ip) > '0'||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) >= '0'||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) < 2||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) <= 2||coalesce(client_ip, server_ip) + AND ('1'||coalesce(client_ip, server_ip) <> '0'||coalesce(client_ip, server_ip)) IS TRUE + AND ('1'||coalesce(client_ip, server_ip) = '0'||coalesce(client_ip, server_ip)) IS NOT TRUE + AND ('1'||coalesce(client_ip, server_ip) = '0'||coalesce(client_ip, server_ip)) IS FALSE + AND ('1'||coalesce(client_ip, server_ip) <> '0'||coalesce(client_ip, server_ip)) IS NOT FALSE + AND '1'||coalesce(client_ip, server_ip) BETWEEN '0'||coalesce(client_ip, server_ip) AND 2||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) NOT BETWEEN '1'||coalesce(client_ip, server_ip) AND '0'||coalesce(client_ip, server_ip) + AND '1'||coalesce(client_ip, server_ip) like '%' + AND '1'||coalesce(client_ip, server_ip) not like '__DOES_NOT_EXIST__%' + AND '1'||coalesce(client_ip, server_ip) IN ('0'||coalesce(client_ip, server_ip), + 1||coalesce(client_ip, server_ip), + 2||coalesce(client_ip, server_ip)) + AND '1'||coalesce(client_ip, server_ip) NOT IN ('0'||coalesce(client_ip, server_ip), + 2||coalesce(client_ip, server_ip)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A12: coalesce_complex +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(coalesce(event, agent)) IS NULL + OR ('1'||to_json_string(coalesce(event, agent)) = 1||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) IS NOT DISTINCT + FROM 1||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) <> '0'||to_json_string(coalesce(event, agent)) + AND ('1'||to_json_string(coalesce(event, agent)) IS DISTINCT + FROM '0'||to_json_string(coalesce(event, agent))) + AND '1'||to_json_string(coalesce(event, agent)) > '0'||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) >= '0'||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) < 2||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) <= 2||to_json_string(coalesce(event, agent)) + AND ('1'||to_json_string(coalesce(event, agent)) <> '0'||to_json_string(coalesce(event, agent))) IS TRUE + AND ('1'||to_json_string(coalesce(event, agent)) = '0'||to_json_string(coalesce(event, agent))) IS NOT TRUE + AND ('1'||to_json_string(coalesce(event, agent)) = '0'||to_json_string(coalesce(event, agent))) IS FALSE + AND ('1'||to_json_string(coalesce(event, agent)) <> '0'||to_json_string(coalesce(event, agent))) IS NOT FALSE + AND '1'||to_json_string(coalesce(event, agent)) BETWEEN '0'||to_json_string(coalesce(event, agent)) AND 2||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) NOT BETWEEN '1'||to_json_string(coalesce(event, agent)) AND '0'||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) like '%' + AND '1'||to_json_string(coalesce(event, agent)) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(coalesce(event, agent)) IN ('0'||to_json_string(coalesce(event, agent)), + 1||to_json_string(coalesce(event, agent)), + 2||to_json_string(coalesce(event, agent))) + AND '1'||to_json_string(coalesce(event, agent)) NOT IN ('0'||to_json_string(coalesce(event, agent)), + 2||to_json_string(coalesce(event, agent))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(coalesce(event, agent)) IS NULL + OR '1'||to_json_string(coalesce(event, agent)) IN + (SELECT '1'||to_json_string(coalesce(event, agent)) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(coalesce(event, agent)) IS NULL + OR ('1'||to_json_string(coalesce(event, agent)) = 1||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) IS NOT DISTINCT + FROM 1||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) <> '0'||to_json_string(coalesce(event, agent)) + AND ('1'||to_json_string(coalesce(event, agent)) IS DISTINCT + FROM '0'||to_json_string(coalesce(event, agent))) + AND '1'||to_json_string(coalesce(event, agent)) > '0'||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) >= '0'||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) < 2||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) <= 2||to_json_string(coalesce(event, agent)) + AND ('1'||to_json_string(coalesce(event, agent)) <> '0'||to_json_string(coalesce(event, agent))) IS TRUE + AND ('1'||to_json_string(coalesce(event, agent)) = '0'||to_json_string(coalesce(event, agent))) IS NOT TRUE + AND ('1'||to_json_string(coalesce(event, agent)) = '0'||to_json_string(coalesce(event, agent))) IS FALSE + AND ('1'||to_json_string(coalesce(event, agent)) <> '0'||to_json_string(coalesce(event, agent))) IS NOT FALSE + AND '1'||to_json_string(coalesce(event, agent)) BETWEEN '0'||to_json_string(coalesce(event, agent)) AND 2||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) NOT BETWEEN '1'||to_json_string(coalesce(event, agent)) AND '0'||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) like '%' + AND '1'||to_json_string(coalesce(event, agent)) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(coalesce(event, agent)) IN ('0'||to_json_string(coalesce(event, agent)), + 1||to_json_string(coalesce(event, agent)), + 2||to_json_string(coalesce(event, agent))) + AND '1'||to_json_string(coalesce(event, agent)) NOT IN ('0'||to_json_string(coalesce(event, agent)), + 2||to_json_string(coalesce(event, agent))))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||to_json_string(coalesce(event, agent)), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(coalesce(event, agent)) IS NULL + OR ('1'||to_json_string(coalesce(event, agent)) = 1||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) IS NOT DISTINCT + FROM 1||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) <> '0'||to_json_string(coalesce(event, agent)) + AND ('1'||to_json_string(coalesce(event, agent)) IS DISTINCT + FROM '0'||to_json_string(coalesce(event, agent))) + AND '1'||to_json_string(coalesce(event, agent)) > '0'||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) >= '0'||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) < 2||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) <= 2||to_json_string(coalesce(event, agent)) + AND ('1'||to_json_string(coalesce(event, agent)) <> '0'||to_json_string(coalesce(event, agent))) IS TRUE + AND ('1'||to_json_string(coalesce(event, agent)) = '0'||to_json_string(coalesce(event, agent))) IS NOT TRUE + AND ('1'||to_json_string(coalesce(event, agent)) = '0'||to_json_string(coalesce(event, agent))) IS FALSE + AND ('1'||to_json_string(coalesce(event, agent)) <> '0'||to_json_string(coalesce(event, agent))) IS NOT FALSE + AND '1'||to_json_string(coalesce(event, agent)) BETWEEN '0'||to_json_string(coalesce(event, agent)) AND 2||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) NOT BETWEEN '1'||to_json_string(coalesce(event, agent)) AND '0'||to_json_string(coalesce(event, agent)) + AND '1'||to_json_string(coalesce(event, agent)) like '%' + AND '1'||to_json_string(coalesce(event, agent)) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(coalesce(event, agent)) IN ('0'||to_json_string(coalesce(event, agent)), + 1||to_json_string(coalesce(event, agent)), + 2||to_json_string(coalesce(event, agent))) + AND '1'||to_json_string(coalesce(event, agent)) NOT IN ('0'||to_json_string(coalesce(event, agent)), + 2||to_json_string(coalesce(event, agent))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A13: nullif_scalar +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||nullif(client_ip, server_ip) IS NULL + OR ('1'||nullif(client_ip, server_ip) = 1||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) IS NOT DISTINCT + FROM 1||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) <> '0'||nullif(client_ip, server_ip) + AND ('1'||nullif(client_ip, server_ip) IS DISTINCT + FROM '0'||nullif(client_ip, server_ip)) + AND '1'||nullif(client_ip, server_ip) > '0'||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) >= '0'||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) < 2||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) <= 2||nullif(client_ip, server_ip) + AND ('1'||nullif(client_ip, server_ip) <> '0'||nullif(client_ip, server_ip)) IS TRUE + AND ('1'||nullif(client_ip, server_ip) = '0'||nullif(client_ip, server_ip)) IS NOT TRUE + AND ('1'||nullif(client_ip, server_ip) = '0'||nullif(client_ip, server_ip)) IS FALSE + AND ('1'||nullif(client_ip, server_ip) <> '0'||nullif(client_ip, server_ip)) IS NOT FALSE + AND '1'||nullif(client_ip, server_ip) BETWEEN '0'||nullif(client_ip, server_ip) AND 2||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) NOT BETWEEN '1'||nullif(client_ip, server_ip) AND '0'||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) like '%' + AND '1'||nullif(client_ip, server_ip) not like '__DOES_NOT_EXIST__%' + AND '1'||nullif(client_ip, server_ip) IN ('0'||nullif(client_ip, server_ip), + 1||nullif(client_ip, server_ip), + 2||nullif(client_ip, server_ip)) + AND '1'||nullif(client_ip, server_ip) NOT IN ('0'||nullif(client_ip, server_ip), + 2||nullif(client_ip, server_ip)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||nullif(client_ip, server_ip) IS NULL + OR '1'||nullif(client_ip, server_ip) IN + (SELECT '1'||nullif(client_ip, server_ip) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||nullif(client_ip, server_ip) IS NULL + OR ('1'||nullif(client_ip, server_ip) = 1||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) IS NOT DISTINCT + FROM 1||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) <> '0'||nullif(client_ip, server_ip) + AND ('1'||nullif(client_ip, server_ip) IS DISTINCT + FROM '0'||nullif(client_ip, server_ip)) + AND '1'||nullif(client_ip, server_ip) > '0'||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) >= '0'||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) < 2||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) <= 2||nullif(client_ip, server_ip) + AND ('1'||nullif(client_ip, server_ip) <> '0'||nullif(client_ip, server_ip)) IS TRUE + AND ('1'||nullif(client_ip, server_ip) = '0'||nullif(client_ip, server_ip)) IS NOT TRUE + AND ('1'||nullif(client_ip, server_ip) = '0'||nullif(client_ip, server_ip)) IS FALSE + AND ('1'||nullif(client_ip, server_ip) <> '0'||nullif(client_ip, server_ip)) IS NOT FALSE + AND '1'||nullif(client_ip, server_ip) BETWEEN '0'||nullif(client_ip, server_ip) AND 2||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) NOT BETWEEN '1'||nullif(client_ip, server_ip) AND '0'||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) like '%' + AND '1'||nullif(client_ip, server_ip) not like '__DOES_NOT_EXIST__%' + AND '1'||nullif(client_ip, server_ip) IN ('0'||nullif(client_ip, server_ip), + 1||nullif(client_ip, server_ip), + 2||nullif(client_ip, server_ip)) + AND '1'||nullif(client_ip, server_ip) NOT IN ('0'||nullif(client_ip, server_ip), + 2||nullif(client_ip, server_ip)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||nullif(client_ip, server_ip), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||nullif(client_ip, server_ip) IS NULL + OR ('1'||nullif(client_ip, server_ip) = 1||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) IS NOT DISTINCT + FROM 1||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) <> '0'||nullif(client_ip, server_ip) + AND ('1'||nullif(client_ip, server_ip) IS DISTINCT + FROM '0'||nullif(client_ip, server_ip)) + AND '1'||nullif(client_ip, server_ip) > '0'||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) >= '0'||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) < 2||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) <= 2||nullif(client_ip, server_ip) + AND ('1'||nullif(client_ip, server_ip) <> '0'||nullif(client_ip, server_ip)) IS TRUE + AND ('1'||nullif(client_ip, server_ip) = '0'||nullif(client_ip, server_ip)) IS NOT TRUE + AND ('1'||nullif(client_ip, server_ip) = '0'||nullif(client_ip, server_ip)) IS FALSE + AND ('1'||nullif(client_ip, server_ip) <> '0'||nullif(client_ip, server_ip)) IS NOT FALSE + AND '1'||nullif(client_ip, server_ip) BETWEEN '0'||nullif(client_ip, server_ip) AND 2||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) NOT BETWEEN '1'||nullif(client_ip, server_ip) AND '0'||nullif(client_ip, server_ip) + AND '1'||nullif(client_ip, server_ip) like '%' + AND '1'||nullif(client_ip, server_ip) not like '__DOES_NOT_EXIST__%' + AND '1'||nullif(client_ip, server_ip) IN ('0'||nullif(client_ip, server_ip), + 1||nullif(client_ip, server_ip), + 2||nullif(client_ip, server_ip)) + AND '1'||nullif(client_ip, server_ip) NOT IN ('0'||nullif(client_ip, server_ip), + 2||nullif(client_ip, server_ip)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A14: nullif_complex +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(nullif(event, agent)) IS NULL + OR ('1'||to_json_string(nullif(event, agent)) = 1||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) IS NOT DISTINCT + FROM 1||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) <> '0'||to_json_string(nullif(event, agent)) + AND ('1'||to_json_string(nullif(event, agent)) IS DISTINCT + FROM '0'||to_json_string(nullif(event, agent))) + AND '1'||to_json_string(nullif(event, agent)) > '0'||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) >= '0'||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) < 2||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) <= 2||to_json_string(nullif(event, agent)) + AND ('1'||to_json_string(nullif(event, agent)) <> '0'||to_json_string(nullif(event, agent))) IS TRUE + AND ('1'||to_json_string(nullif(event, agent)) = '0'||to_json_string(nullif(event, agent))) IS NOT TRUE + AND ('1'||to_json_string(nullif(event, agent)) = '0'||to_json_string(nullif(event, agent))) IS FALSE + AND ('1'||to_json_string(nullif(event, agent)) <> '0'||to_json_string(nullif(event, agent))) IS NOT FALSE + AND '1'||to_json_string(nullif(event, agent)) BETWEEN '0'||to_json_string(nullif(event, agent)) AND 2||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) NOT BETWEEN '1'||to_json_string(nullif(event, agent)) AND '0'||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) like '%' + AND '1'||to_json_string(nullif(event, agent)) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(nullif(event, agent)) IN ('0'||to_json_string(nullif(event, agent)), + 1||to_json_string(nullif(event, agent)), + 2||to_json_string(nullif(event, agent))) + AND '1'||to_json_string(nullif(event, agent)) NOT IN ('0'||to_json_string(nullif(event, agent)), + 2||to_json_string(nullif(event, agent))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(nullif(event, agent)) IS NULL + OR '1'||to_json_string(nullif(event, agent)) IN + (SELECT '1'||to_json_string(nullif(event, agent)) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(nullif(event, agent)) IS NULL + OR ('1'||to_json_string(nullif(event, agent)) = 1||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) IS NOT DISTINCT + FROM 1||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) <> '0'||to_json_string(nullif(event, agent)) + AND ('1'||to_json_string(nullif(event, agent)) IS DISTINCT + FROM '0'||to_json_string(nullif(event, agent))) + AND '1'||to_json_string(nullif(event, agent)) > '0'||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) >= '0'||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) < 2||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) <= 2||to_json_string(nullif(event, agent)) + AND ('1'||to_json_string(nullif(event, agent)) <> '0'||to_json_string(nullif(event, agent))) IS TRUE + AND ('1'||to_json_string(nullif(event, agent)) = '0'||to_json_string(nullif(event, agent))) IS NOT TRUE + AND ('1'||to_json_string(nullif(event, agent)) = '0'||to_json_string(nullif(event, agent))) IS FALSE + AND ('1'||to_json_string(nullif(event, agent)) <> '0'||to_json_string(nullif(event, agent))) IS NOT FALSE + AND '1'||to_json_string(nullif(event, agent)) BETWEEN '0'||to_json_string(nullif(event, agent)) AND 2||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) NOT BETWEEN '1'||to_json_string(nullif(event, agent)) AND '0'||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) like '%' + AND '1'||to_json_string(nullif(event, agent)) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(nullif(event, agent)) IN ('0'||to_json_string(nullif(event, agent)), + 1||to_json_string(nullif(event, agent)), + 2||to_json_string(nullif(event, agent))) + AND '1'||to_json_string(nullif(event, agent)) NOT IN ('0'||to_json_string(nullif(event, agent)), + 2||to_json_string(nullif(event, agent))))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||to_json_string(nullif(event, agent)), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(nullif(event, agent)) IS NULL + OR ('1'||to_json_string(nullif(event, agent)) = 1||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) IS NOT DISTINCT + FROM 1||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) <> '0'||to_json_string(nullif(event, agent)) + AND ('1'||to_json_string(nullif(event, agent)) IS DISTINCT + FROM '0'||to_json_string(nullif(event, agent))) + AND '1'||to_json_string(nullif(event, agent)) > '0'||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) >= '0'||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) < 2||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) <= 2||to_json_string(nullif(event, agent)) + AND ('1'||to_json_string(nullif(event, agent)) <> '0'||to_json_string(nullif(event, agent))) IS TRUE + AND ('1'||to_json_string(nullif(event, agent)) = '0'||to_json_string(nullif(event, agent))) IS NOT TRUE + AND ('1'||to_json_string(nullif(event, agent)) = '0'||to_json_string(nullif(event, agent))) IS FALSE + AND ('1'||to_json_string(nullif(event, agent)) <> '0'||to_json_string(nullif(event, agent))) IS NOT FALSE + AND '1'||to_json_string(nullif(event, agent)) BETWEEN '0'||to_json_string(nullif(event, agent)) AND 2||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) NOT BETWEEN '1'||to_json_string(nullif(event, agent)) AND '0'||to_json_string(nullif(event, agent)) + AND '1'||to_json_string(nullif(event, agent)) like '%' + AND '1'||to_json_string(nullif(event, agent)) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(nullif(event, agent)) IN ('0'||to_json_string(nullif(event, agent)), + 1||to_json_string(nullif(event, agent)), + 2||to_json_string(nullif(event, agent))) + AND '1'||to_json_string(nullif(event, agent)) NOT IN ('0'||to_json_string(nullif(event, agent)), + 2||to_json_string(nullif(event, agent))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A15: nvl_scalar +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||nvl(client_ip, server_ip) IS NULL + OR ('1'||nvl(client_ip, server_ip) = 1||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) IS NOT DISTINCT + FROM 1||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) <> '0'||nvl(client_ip, server_ip) + AND ('1'||nvl(client_ip, server_ip) IS DISTINCT + FROM '0'||nvl(client_ip, server_ip)) + AND '1'||nvl(client_ip, server_ip) > '0'||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) >= '0'||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) < 2||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) <= 2||nvl(client_ip, server_ip) + AND ('1'||nvl(client_ip, server_ip) <> '0'||nvl(client_ip, server_ip)) IS TRUE + AND ('1'||nvl(client_ip, server_ip) = '0'||nvl(client_ip, server_ip)) IS NOT TRUE + AND ('1'||nvl(client_ip, server_ip) = '0'||nvl(client_ip, server_ip)) IS FALSE + AND ('1'||nvl(client_ip, server_ip) <> '0'||nvl(client_ip, server_ip)) IS NOT FALSE + AND '1'||nvl(client_ip, server_ip) BETWEEN '0'||nvl(client_ip, server_ip) AND 2||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) NOT BETWEEN '1'||nvl(client_ip, server_ip) AND '0'||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) like '%' + AND '1'||nvl(client_ip, server_ip) not like '__DOES_NOT_EXIST__%' + AND '1'||nvl(client_ip, server_ip) IN ('0'||nvl(client_ip, server_ip), + 1||nvl(client_ip, server_ip), + 2||nvl(client_ip, server_ip)) + AND '1'||nvl(client_ip, server_ip) NOT IN ('0'||nvl(client_ip, server_ip), + 2||nvl(client_ip, server_ip)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||nvl(client_ip, server_ip) IS NULL + OR '1'||nvl(client_ip, server_ip) IN + (SELECT '1'||nvl(client_ip, server_ip) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||nvl(client_ip, server_ip) IS NULL + OR ('1'||nvl(client_ip, server_ip) = 1||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) IS NOT DISTINCT + FROM 1||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) <> '0'||nvl(client_ip, server_ip) + AND ('1'||nvl(client_ip, server_ip) IS DISTINCT + FROM '0'||nvl(client_ip, server_ip)) + AND '1'||nvl(client_ip, server_ip) > '0'||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) >= '0'||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) < 2||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) <= 2||nvl(client_ip, server_ip) + AND ('1'||nvl(client_ip, server_ip) <> '0'||nvl(client_ip, server_ip)) IS TRUE + AND ('1'||nvl(client_ip, server_ip) = '0'||nvl(client_ip, server_ip)) IS NOT TRUE + AND ('1'||nvl(client_ip, server_ip) = '0'||nvl(client_ip, server_ip)) IS FALSE + AND ('1'||nvl(client_ip, server_ip) <> '0'||nvl(client_ip, server_ip)) IS NOT FALSE + AND '1'||nvl(client_ip, server_ip) BETWEEN '0'||nvl(client_ip, server_ip) AND 2||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) NOT BETWEEN '1'||nvl(client_ip, server_ip) AND '0'||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) like '%' + AND '1'||nvl(client_ip, server_ip) not like '__DOES_NOT_EXIST__%' + AND '1'||nvl(client_ip, server_ip) IN ('0'||nvl(client_ip, server_ip), + 1||nvl(client_ip, server_ip), + 2||nvl(client_ip, server_ip)) + AND '1'||nvl(client_ip, server_ip) NOT IN ('0'||nvl(client_ip, server_ip), + 2||nvl(client_ip, server_ip)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||nvl(client_ip, server_ip), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||nvl(client_ip, server_ip) IS NULL + OR ('1'||nvl(client_ip, server_ip) = 1||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) IS NOT DISTINCT + FROM 1||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) <> '0'||nvl(client_ip, server_ip) + AND ('1'||nvl(client_ip, server_ip) IS DISTINCT + FROM '0'||nvl(client_ip, server_ip)) + AND '1'||nvl(client_ip, server_ip) > '0'||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) >= '0'||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) < 2||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) <= 2||nvl(client_ip, server_ip) + AND ('1'||nvl(client_ip, server_ip) <> '0'||nvl(client_ip, server_ip)) IS TRUE + AND ('1'||nvl(client_ip, server_ip) = '0'||nvl(client_ip, server_ip)) IS NOT TRUE + AND ('1'||nvl(client_ip, server_ip) = '0'||nvl(client_ip, server_ip)) IS FALSE + AND ('1'||nvl(client_ip, server_ip) <> '0'||nvl(client_ip, server_ip)) IS NOT FALSE + AND '1'||nvl(client_ip, server_ip) BETWEEN '0'||nvl(client_ip, server_ip) AND 2||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) NOT BETWEEN '1'||nvl(client_ip, server_ip) AND '0'||nvl(client_ip, server_ip) + AND '1'||nvl(client_ip, server_ip) like '%' + AND '1'||nvl(client_ip, server_ip) not like '__DOES_NOT_EXIST__%' + AND '1'||nvl(client_ip, server_ip) IN ('0'||nvl(client_ip, server_ip), + 1||nvl(client_ip, server_ip), + 2||nvl(client_ip, server_ip)) + AND '1'||nvl(client_ip, server_ip) NOT IN ('0'||nvl(client_ip, server_ip), + 2||nvl(client_ip, server_ip)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A16: nvl_complex +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(nvl(event, agent)) IS NULL + OR ('1'||to_json_string(nvl(event, agent)) = 1||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) IS NOT DISTINCT + FROM 1||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) <> '0'||to_json_string(nvl(event, agent)) + AND ('1'||to_json_string(nvl(event, agent)) IS DISTINCT + FROM '0'||to_json_string(nvl(event, agent))) + AND '1'||to_json_string(nvl(event, agent)) > '0'||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) >= '0'||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) < 2||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) <= 2||to_json_string(nvl(event, agent)) + AND ('1'||to_json_string(nvl(event, agent)) <> '0'||to_json_string(nvl(event, agent))) IS TRUE + AND ('1'||to_json_string(nvl(event, agent)) = '0'||to_json_string(nvl(event, agent))) IS NOT TRUE + AND ('1'||to_json_string(nvl(event, agent)) = '0'||to_json_string(nvl(event, agent))) IS FALSE + AND ('1'||to_json_string(nvl(event, agent)) <> '0'||to_json_string(nvl(event, agent))) IS NOT FALSE + AND '1'||to_json_string(nvl(event, agent)) BETWEEN '0'||to_json_string(nvl(event, agent)) AND 2||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) NOT BETWEEN '1'||to_json_string(nvl(event, agent)) AND '0'||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) like '%' + AND '1'||to_json_string(nvl(event, agent)) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(nvl(event, agent)) IN ('0'||to_json_string(nvl(event, agent)), + 1||to_json_string(nvl(event, agent)), + 2||to_json_string(nvl(event, agent))) + AND '1'||to_json_string(nvl(event, agent)) NOT IN ('0'||to_json_string(nvl(event, agent)), + 2||to_json_string(nvl(event, agent))))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(nvl(event, agent)) IS NULL + OR '1'||to_json_string(nvl(event, agent)) IN + (SELECT '1'||to_json_string(nvl(event, agent)) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(nvl(event, agent)) IS NULL + OR ('1'||to_json_string(nvl(event, agent)) = 1||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) IS NOT DISTINCT + FROM 1||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) <> '0'||to_json_string(nvl(event, agent)) + AND ('1'||to_json_string(nvl(event, agent)) IS DISTINCT + FROM '0'||to_json_string(nvl(event, agent))) + AND '1'||to_json_string(nvl(event, agent)) > '0'||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) >= '0'||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) < 2||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) <= 2||to_json_string(nvl(event, agent)) + AND ('1'||to_json_string(nvl(event, agent)) <> '0'||to_json_string(nvl(event, agent))) IS TRUE + AND ('1'||to_json_string(nvl(event, agent)) = '0'||to_json_string(nvl(event, agent))) IS NOT TRUE + AND ('1'||to_json_string(nvl(event, agent)) = '0'||to_json_string(nvl(event, agent))) IS FALSE + AND ('1'||to_json_string(nvl(event, agent)) <> '0'||to_json_string(nvl(event, agent))) IS NOT FALSE + AND '1'||to_json_string(nvl(event, agent)) BETWEEN '0'||to_json_string(nvl(event, agent)) AND 2||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) NOT BETWEEN '1'||to_json_string(nvl(event, agent)) AND '0'||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) like '%' + AND '1'||to_json_string(nvl(event, agent)) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(nvl(event, agent)) IN ('0'||to_json_string(nvl(event, agent)), + 1||to_json_string(nvl(event, agent)), + 2||to_json_string(nvl(event, agent))) + AND '1'||to_json_string(nvl(event, agent)) NOT IN ('0'||to_json_string(nvl(event, agent)), + 2||to_json_string(nvl(event, agent))))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||to_json_string(nvl(event, agent)), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||to_json_string(nvl(event, agent)) IS NULL + OR ('1'||to_json_string(nvl(event, agent)) = 1||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) IS NOT DISTINCT + FROM 1||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) <> '0'||to_json_string(nvl(event, agent)) + AND ('1'||to_json_string(nvl(event, agent)) IS DISTINCT + FROM '0'||to_json_string(nvl(event, agent))) + AND '1'||to_json_string(nvl(event, agent)) > '0'||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) >= '0'||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) < 2||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) <= 2||to_json_string(nvl(event, agent)) + AND ('1'||to_json_string(nvl(event, agent)) <> '0'||to_json_string(nvl(event, agent))) IS TRUE + AND ('1'||to_json_string(nvl(event, agent)) = '0'||to_json_string(nvl(event, agent))) IS NOT TRUE + AND ('1'||to_json_string(nvl(event, agent)) = '0'||to_json_string(nvl(event, agent))) IS FALSE + AND ('1'||to_json_string(nvl(event, agent)) <> '0'||to_json_string(nvl(event, agent))) IS NOT FALSE + AND '1'||to_json_string(nvl(event, agent)) BETWEEN '0'||to_json_string(nvl(event, agent)) AND 2||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) NOT BETWEEN '1'||to_json_string(nvl(event, agent)) AND '0'||to_json_string(nvl(event, agent)) + AND '1'||to_json_string(nvl(event, agent)) like '%' + AND '1'||to_json_string(nvl(event, agent)) not like '__DOES_NOT_EXIST__%' + AND '1'||to_json_string(nvl(event, agent)) IN ('0'||to_json_string(nvl(event, agent)), + 1||to_json_string(nvl(event, agent)), + 2||to_json_string(nvl(event, agent))) + AND '1'||to_json_string(nvl(event, agent)) NOT IN ('0'||to_json_string(nvl(event, agent)), + 2||to_json_string(nvl(event, agent))))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# Total query count 49 +#------------------------------------------------------------------------- diff --git a/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_scalar_reduction.iq b/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_scalar_reduction.iq new file mode 100644 index 00000000000..2b39782d6b7 --- /dev/null +++ b/quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_scalar_reduction.iq @@ -0,0 +1,266 @@ +!set useApproximateCountDistinct false +!use druidtest:///?componentSupplier=KttmNestedComponentSupplier +!set outputformat mysql +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00'; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A1: greatest +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||greatest(session_length, 1, NULL) IS NULL + OR ('1'||greatest(session_length, 1, NULL) = 1||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) IS NOT DISTINCT + FROM 1||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) <> '0'||greatest(session_length, 1, NULL) + AND ('1'||greatest(session_length, 1, NULL) IS DISTINCT + FROM '0'||greatest(session_length, 1, NULL)) + AND '1'||greatest(session_length, 1, NULL) > '0'||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) >= '0'||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) < 2||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) <= 2||greatest(session_length, 1, NULL) + AND ('1'||greatest(session_length, 1, NULL) <> '0'||greatest(session_length, 1, NULL)) IS TRUE + AND ('1'||greatest(session_length, 1, NULL) = '0'||greatest(session_length, 1, NULL)) IS NOT TRUE + AND ('1'||greatest(session_length, 1, NULL) = '0'||greatest(session_length, 1, NULL)) IS FALSE + AND ('1'||greatest(session_length, 1, NULL) <> '0'||greatest(session_length, 1, NULL)) IS NOT FALSE + AND '1'||greatest(session_length, 1, NULL) BETWEEN '0'||greatest(session_length, 1, NULL) AND 2||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) NOT BETWEEN '1'||greatest(session_length, 1, NULL) AND '0'||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) like '%' + AND '1'||greatest(session_length, 1, NULL) not like '__DOES_NOT_EXIST__%' + AND '1'||greatest(session_length, 1, NULL) IN ('0'||greatest(session_length, 1, NULL), + 1||greatest(session_length, 1, NULL), + 2||greatest(session_length, 1, NULL)) + AND '1'||greatest(session_length, 1, NULL) NOT IN ('0'||greatest(session_length, 1, NULL), + 2||greatest(session_length, 1, NULL)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||greatest(session_length, 1, NULL) IS NULL + OR '1'||greatest(session_length, 1, NULL) IN + (SELECT '1'||greatest(session_length, 1, NULL) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||greatest(session_length, 1, NULL) IS NULL + OR ('1'||greatest(session_length, 1, NULL) = 1||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) IS NOT DISTINCT + FROM 1||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) <> '0'||greatest(session_length, 1, NULL) + AND ('1'||greatest(session_length, 1, NULL) IS DISTINCT + FROM '0'||greatest(session_length, 1, NULL)) + AND '1'||greatest(session_length, 1, NULL) > '0'||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) >= '0'||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) < 2||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) <= 2||greatest(session_length, 1, NULL) + AND ('1'||greatest(session_length, 1, NULL) <> '0'||greatest(session_length, 1, NULL)) IS TRUE + AND ('1'||greatest(session_length, 1, NULL) = '0'||greatest(session_length, 1, NULL)) IS NOT TRUE + AND ('1'||greatest(session_length, 1, NULL) = '0'||greatest(session_length, 1, NULL)) IS FALSE + AND ('1'||greatest(session_length, 1, NULL) <> '0'||greatest(session_length, 1, NULL)) IS NOT FALSE + AND '1'||greatest(session_length, 1, NULL) BETWEEN '0'||greatest(session_length, 1, NULL) AND 2||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) NOT BETWEEN '1'||greatest(session_length, 1, NULL) AND '0'||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) like '%' + AND '1'||greatest(session_length, 1, NULL) not like '__DOES_NOT_EXIST__%' + AND '1'||greatest(session_length, 1, NULL) IN ('0'||greatest(session_length, 1, NULL), + 1||greatest(session_length, 1, NULL), + 2||greatest(session_length, 1, NULL)) + AND '1'||greatest(session_length, 1, NULL) NOT IN ('0'||greatest(session_length, 1, NULL), + 2||greatest(session_length, 1, NULL)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||greatest(session_length, 1, NULL), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||greatest(session_length, 1, NULL) IS NULL + OR ('1'||greatest(session_length, 1, NULL) = 1||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) IS NOT DISTINCT + FROM 1||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) <> '0'||greatest(session_length, 1, NULL) + AND ('1'||greatest(session_length, 1, NULL) IS DISTINCT + FROM '0'||greatest(session_length, 1, NULL)) + AND '1'||greatest(session_length, 1, NULL) > '0'||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) >= '0'||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) < 2||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) <= 2||greatest(session_length, 1, NULL) + AND ('1'||greatest(session_length, 1, NULL) <> '0'||greatest(session_length, 1, NULL)) IS TRUE + AND ('1'||greatest(session_length, 1, NULL) = '0'||greatest(session_length, 1, NULL)) IS NOT TRUE + AND ('1'||greatest(session_length, 1, NULL) = '0'||greatest(session_length, 1, NULL)) IS FALSE + AND ('1'||greatest(session_length, 1, NULL) <> '0'||greatest(session_length, 1, NULL)) IS NOT FALSE + AND '1'||greatest(session_length, 1, NULL) BETWEEN '0'||greatest(session_length, 1, NULL) AND 2||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) NOT BETWEEN '1'||greatest(session_length, 1, NULL) AND '0'||greatest(session_length, 1, NULL) + AND '1'||greatest(session_length, 1, NULL) like '%' + AND '1'||greatest(session_length, 1, NULL) not like '__DOES_NOT_EXIST__%' + AND '1'||greatest(session_length, 1, NULL) IN ('0'||greatest(session_length, 1, NULL), + 1||greatest(session_length, 1, NULL), + 2||greatest(session_length, 1, NULL)) + AND '1'||greatest(session_length, 1, NULL) NOT IN ('0'||greatest(session_length, 1, NULL), + 2||greatest(session_length, 1, NULL)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# TEST_ID: A2: least +#------------------------------------------------------------------------- +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||least(loaded_image, '1', NULL) IS NULL + OR ('1'||least(loaded_image, '1', NULL) = 1||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) IS NOT DISTINCT + FROM 1||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) <> '0'||least(loaded_image, '1', NULL) + AND ('1'||least(loaded_image, '1', NULL) IS DISTINCT + FROM '0'||least(loaded_image, '1', NULL)) + AND '1'||least(loaded_image, '1', NULL) > '0'||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) >= '0'||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) < 2||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) <= 2||least(loaded_image, '1', NULL) + AND ('1'||least(loaded_image, '1', NULL) <> '0'||least(loaded_image, '1', NULL)) IS TRUE + AND ('1'||least(loaded_image, '1', NULL) = '0'||least(loaded_image, '1', NULL)) IS NOT TRUE + AND ('1'||least(loaded_image, '1', NULL) = '0'||least(loaded_image, '1', NULL)) IS FALSE + AND ('1'||least(loaded_image, '1', NULL) <> '0'||least(loaded_image, '1', NULL)) IS NOT FALSE + AND '1'||least(loaded_image, '1', NULL) BETWEEN '0'||least(loaded_image, '1', NULL) AND 2||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) NOT BETWEEN '1'||least(loaded_image, '1', NULL) AND '0'||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) like '%' + AND '1'||least(loaded_image, '1', NULL) not like '__DOES_NOT_EXIST__%' + AND '1'||least(loaded_image, '1', NULL) IN ('0'||least(loaded_image, '1', NULL), + 1||least(loaded_image, '1', NULL), + 2||least(loaded_image, '1', NULL)) + AND '1'||least(loaded_image, '1', NULL) NOT IN ('0'||least(loaded_image, '1', NULL), + 2||least(loaded_image, '1', NULL)))) ; ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM kttm_nested +WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||least(loaded_image, '1', NULL) IS NULL + OR '1'||least(loaded_image, '1', NULL) IN + (SELECT '1'||least(loaded_image, '1', NULL) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||least(loaded_image, '1', NULL) IS NULL + OR ('1'||least(loaded_image, '1', NULL) = 1||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) IS NOT DISTINCT + FROM 1||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) <> '0'||least(loaded_image, '1', NULL) + AND ('1'||least(loaded_image, '1', NULL) IS DISTINCT + FROM '0'||least(loaded_image, '1', NULL)) + AND '1'||least(loaded_image, '1', NULL) > '0'||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) >= '0'||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) < 2||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) <= 2||least(loaded_image, '1', NULL) + AND ('1'||least(loaded_image, '1', NULL) <> '0'||least(loaded_image, '1', NULL)) IS TRUE + AND ('1'||least(loaded_image, '1', NULL) = '0'||least(loaded_image, '1', NULL)) IS NOT TRUE + AND ('1'||least(loaded_image, '1', NULL) = '0'||least(loaded_image, '1', NULL)) IS FALSE + AND ('1'||least(loaded_image, '1', NULL) <> '0'||least(loaded_image, '1', NULL)) IS NOT FALSE + AND '1'||least(loaded_image, '1', NULL) BETWEEN '0'||least(loaded_image, '1', NULL) AND 2||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) NOT BETWEEN '1'||least(loaded_image, '1', NULL) AND '0'||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) like '%' + AND '1'||least(loaded_image, '1', NULL) not like '__DOES_NOT_EXIST__%' + AND '1'||least(loaded_image, '1', NULL) IN ('0'||least(loaded_image, '1', NULL), + 1||least(loaded_image, '1', NULL), + 2||least(loaded_image, '1', NULL)) + AND '1'||least(loaded_image, '1', NULL) NOT IN ('0'||least(loaded_image, '1', NULL), + 2||least(loaded_image, '1', NULL)))))); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +SELECT count(*) cnt +FROM + (SELECT __time, number, client_ip, + '1'||least(loaded_image, '1', NULL), + count(*) + FROM kttm_nested + WHERE time_floor(__time, 'PT1H') BETWEEN timestamp '2019-08-25 00:00:00' AND timestamp '2019-08-25 06:00:00' + AND ('1'||least(loaded_image, '1', NULL) IS NULL + OR ('1'||least(loaded_image, '1', NULL) = 1||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) IS NOT DISTINCT + FROM 1||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) <> '0'||least(loaded_image, '1', NULL) + AND ('1'||least(loaded_image, '1', NULL) IS DISTINCT + FROM '0'||least(loaded_image, '1', NULL)) + AND '1'||least(loaded_image, '1', NULL) > '0'||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) >= '0'||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) < 2||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) <= 2||least(loaded_image, '1', NULL) + AND ('1'||least(loaded_image, '1', NULL) <> '0'||least(loaded_image, '1', NULL)) IS TRUE + AND ('1'||least(loaded_image, '1', NULL) = '0'||least(loaded_image, '1', NULL)) IS NOT TRUE + AND ('1'||least(loaded_image, '1', NULL) = '0'||least(loaded_image, '1', NULL)) IS FALSE + AND ('1'||least(loaded_image, '1', NULL) <> '0'||least(loaded_image, '1', NULL)) IS NOT FALSE + AND '1'||least(loaded_image, '1', NULL) BETWEEN '0'||least(loaded_image, '1', NULL) AND 2||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) NOT BETWEEN '1'||least(loaded_image, '1', NULL) AND '0'||least(loaded_image, '1', NULL) + AND '1'||least(loaded_image, '1', NULL) like '%' + AND '1'||least(loaded_image, '1', NULL) not like '__DOES_NOT_EXIST__%' + AND '1'||least(loaded_image, '1', NULL) IN ('0'||least(loaded_image, '1', NULL), + 1||least(loaded_image, '1', NULL), + 2||least(loaded_image, '1', NULL)) + AND '1'||least(loaded_image, '1', NULL) NOT IN ('0'||least(loaded_image, '1', NULL), + 2||least(loaded_image, '1', NULL)))) + GROUP BY 1, + 2, + 3, + 4); ++-------+ +| cnt | ++-------+ +| 78197 | ++-------+ +(1 row) + +!ok + +#------------------------------------------------------------------------- +# Total query count 7 +#-------------------------------------------------------------------------