Skip to content

Commit

Permalink
Adding remaining 6 sets of SQL tests in quidem (#17583)
Browse files Browse the repository at this point in the history
This is the 2nd part of the PR #17548. It migrates the remaining 6 sets of SQL tests to quidem.  These 6 sets cover aggregation, array, json, mv, reduction, and other scalar functions.

These tests use the existing kttm dataset.  They aim to exercise SQL queries in a more comprehensive way:

Aggregation functions:
Each aggregation function is exercised in 1 query shape:
group by query
Each query covers all operators in the predicates of the having clause.
All queries are designed to return 7 rows.
Scalar functions:
Each scalar function is exercised in 3 different query shapes:
simple query
subquery
group by query
Each query covers all operators in the predicates of the where clause.
All queries are select count(*) queries.  They are designed to all return the same result for easy maintenance and debugging.

Update array and mv tests to use the language column

This PR updates the array and the mv tests to use the MV column "language" instead of constructing the data in the queries.
  • Loading branch information
weishiuntsai authored Dec 19, 2024
1 parent ca8f24e commit 78ce97a
Show file tree
Hide file tree
Showing 6 changed files with 12,149 additions and 0 deletions.
1,146 changes: 1,146 additions & 0 deletions quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_aggr_general.iq

Large diffs are not rendered by default.

2,848 changes: 2,848 additions & 0 deletions quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_array.iq

Large diffs are not rendered by default.

1,653 changes: 1,653 additions & 0 deletions quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_json.iq

Large diffs are not rendered by default.

2,746 changes: 2,746 additions & 0 deletions quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_mv.iq

Large diffs are not rendered by default.

3,490 changes: 3,490 additions & 0 deletions quidem-ut/src/test/quidem/org.apache.druid.quidem.QTest/qaSQL_scalar_other.iq

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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
#-------------------------------------------------------------------------

0 comments on commit 78ce97a

Please sign in to comment.