mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
add asof_join_ddb tests
This commit is contained in:
parent
256ad60115
commit
29494d0bc6
@ -1,4 +1,5 @@
|
||||
SET join_algorithm = 'full_sorting_merge';
|
||||
SET allow_experimental_analyzer = 1;
|
||||
|
||||
DROP TABLE IF EXISTS events0;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
DROP TABLE IF EXISTS events0;
|
||||
DROP TABLE IF EXISTS probe0;
|
||||
|
||||
SET allow_experimental_analyzer = 1;
|
||||
SET join_algorithm = 'full_sorting_merge';
|
||||
|
||||
CREATE TABLE events0 (
|
||||
|
@ -0,0 +1,10 @@
|
||||
108
|
||||
108 27
|
||||
513
|
||||
1218
|
||||
3528
|
||||
14553
|
||||
121275
|
||||
1495503
|
||||
12462525
|
||||
1249625025
|
186
tests/queries/0_stateless/03147_asof_join_ddb_missing.sql
Normal file
186
tests/queries/0_stateless/03147_asof_join_ddb_missing.sql
Normal file
@ -0,0 +1,186 @@
|
||||
SET allow_experimental_analyzer=1;
|
||||
|
||||
SET session_timezone = 'UTC';
|
||||
SET joined_subquery_requires_alias = 0;
|
||||
SET allow_experimental_analyzer = 1;
|
||||
SET join_algorithm = 'full_sorting_merge';
|
||||
|
||||
-- # 10 dates, 5 keys
|
||||
WITH build AS (
|
||||
SELECT
|
||||
k,
|
||||
toDateTime('2001-01-01 00:00:00') + INTERVAL number MINUTE AS t,
|
||||
number AS v
|
||||
FROM numbers(10), (SELECT number AS k FROM numbers(5))
|
||||
SETTINGS join_algorithm = 'default'
|
||||
),
|
||||
probe AS (
|
||||
SELECT
|
||||
k * 2 AS k,
|
||||
t - INTERVAL 30 SECOND AS t
|
||||
FROM build
|
||||
)
|
||||
SELECT SUM(v)
|
||||
FROM probe ASOF JOIN build USING (k, t);
|
||||
|
||||
-- # Coverage: Missing right side bin
|
||||
WITH build AS (
|
||||
SELECT
|
||||
k * 2 AS k,
|
||||
toDateTime('2001-01-01 00:00:00') + INTERVAL number MINUTE AS t,
|
||||
number AS v
|
||||
FROM numbers(10), (SELECT number AS k FROM numbers(5))
|
||||
SETTINGS join_algorithm = 'default'
|
||||
),
|
||||
probe AS (
|
||||
SELECT
|
||||
intDiv(k, 2) AS k,
|
||||
t - INTERVAL 30 SECOND AS t
|
||||
FROM build
|
||||
)
|
||||
SELECT SUM(v), COUNT(*)
|
||||
FROM probe ASOF JOIN build USING (k, t);
|
||||
|
||||
-- # 20 dates, 5 keys
|
||||
WITH build AS (
|
||||
SELECT
|
||||
k,
|
||||
toDateTime('2001-01-01 00:00:00') + INTERVAL number MINUTE AS t,
|
||||
number AS v
|
||||
FROM numbers(20), (SELECT number AS k FROM numbers(5))
|
||||
SETTINGS join_algorithm = 'default'
|
||||
),
|
||||
probe AS (
|
||||
SELECT
|
||||
k * 2 AS k,
|
||||
t - INTERVAL 30 SECOND AS t
|
||||
FROM build
|
||||
)
|
||||
SELECT SUM(v)
|
||||
FROM probe ASOF JOIN build USING (k, t);
|
||||
|
||||
-- # 30 dates, 5 keys
|
||||
WITH build AS (
|
||||
SELECT
|
||||
k,
|
||||
toDateTime('2001-01-01 00:00:00') + INTERVAL number MINUTE AS t,
|
||||
number AS v
|
||||
FROM numbers(30), (SELECT number AS k FROM numbers(5))
|
||||
SETTINGS join_algorithm = 'default'
|
||||
),
|
||||
probe AS (
|
||||
SELECT
|
||||
k * 2 AS k,
|
||||
t - INTERVAL 30 SECOND AS t
|
||||
FROM build
|
||||
)
|
||||
SELECT SUM(v)
|
||||
FROM probe ASOF JOIN build USING (k, t);
|
||||
|
||||
-- # 50 dates, 5 keys
|
||||
WITH build AS (
|
||||
SELECT
|
||||
k,
|
||||
toDateTime('2001-01-01 00:00:00') + INTERVAL number MINUTE AS t,
|
||||
number AS v
|
||||
FROM numbers(50), (SELECT number AS k FROM numbers(5))
|
||||
SETTINGS join_algorithm = 'default'
|
||||
),
|
||||
probe AS (
|
||||
SELECT
|
||||
k * 2 AS k,
|
||||
t - INTERVAL 30 SECOND AS t
|
||||
FROM build
|
||||
)
|
||||
SELECT SUM(v)
|
||||
FROM probe ASOF JOIN build USING (k, t);
|
||||
|
||||
-- # 100 dates, 5 keys
|
||||
WITH build AS (
|
||||
SELECT
|
||||
k,
|
||||
toDateTime('2001-01-01 00:00:00') + INTERVAL number MINUTE AS t,
|
||||
number AS v
|
||||
FROM numbers(100), (SELECT number AS k FROM numbers(5))
|
||||
SETTINGS join_algorithm = 'default'
|
||||
),
|
||||
probe AS (
|
||||
SELECT
|
||||
k * 2 AS k,
|
||||
t - INTERVAL 30 SECOND AS t
|
||||
FROM build
|
||||
)
|
||||
SELECT SUM(v)
|
||||
FROM probe ASOF JOIN build USING (k, t);
|
||||
|
||||
-- # 100 dates, 50 keys
|
||||
WITH build AS (
|
||||
SELECT
|
||||
k,
|
||||
toDateTime('2001-01-01 00:00:00') + INTERVAL number MINUTE AS t,
|
||||
number AS v
|
||||
FROM numbers(100), (SELECT number AS k FROM numbers(50))
|
||||
SETTINGS join_algorithm = 'default'
|
||||
),
|
||||
probe AS (
|
||||
SELECT
|
||||
k * 2 AS k,
|
||||
t - INTERVAL 30 SECOND AS t
|
||||
FROM build
|
||||
)
|
||||
SELECT SUM(v)
|
||||
FROM probe ASOF JOIN build USING (k, t);
|
||||
|
||||
-- # 1000 dates, 5 keys
|
||||
WITH build AS (
|
||||
SELECT
|
||||
k,
|
||||
toDateTime('2001-01-01 00:00:00') + INTERVAL number MINUTE AS t,
|
||||
number AS v
|
||||
FROM numbers(1000), (SELECT number AS k FROM numbers(5))
|
||||
SETTINGS join_algorithm = 'default'
|
||||
),
|
||||
probe AS (
|
||||
SELECT
|
||||
k * 2 AS k,
|
||||
t - INTERVAL 30 SECOND AS t
|
||||
FROM build
|
||||
)
|
||||
SELECT SUM(v)
|
||||
FROM probe ASOF JOIN build USING (k, t);
|
||||
|
||||
-- # 1000 dates, 50 keys
|
||||
WITH build AS (
|
||||
SELECT
|
||||
k,
|
||||
toDateTime('2001-01-01 00:00:00') + INTERVAL number MINUTE AS t,
|
||||
number AS v
|
||||
FROM numbers(1000), (SELECT number AS k FROM numbers(50))
|
||||
SETTINGS join_algorithm = 'default'
|
||||
),
|
||||
probe AS (
|
||||
SELECT
|
||||
k * 2 AS k,
|
||||
t - INTERVAL 30 SECOND AS t
|
||||
FROM build
|
||||
)
|
||||
SELECT SUM(v)
|
||||
FROM probe ASOF JOIN build USING (k, t);
|
||||
|
||||
-- # 10000 dates, 50 keys
|
||||
WITH build AS (
|
||||
SELECT
|
||||
k,
|
||||
toDateTime('2001-01-01 00:00:00') + INTERVAL number MINUTE AS t,
|
||||
number AS v
|
||||
FROM numbers(10000), (SELECT number AS k FROM numbers(50))
|
||||
SETTINGS join_algorithm = 'default'
|
||||
),
|
||||
probe AS (
|
||||
SELECT
|
||||
k * 2 AS k,
|
||||
t - INTERVAL 30 SECOND AS t
|
||||
FROM build
|
||||
)
|
||||
SELECT SUM(v)
|
||||
FROM probe ASOF JOIN build USING (k, t);
|
@ -0,0 +1,4 @@
|
||||
1 1
|
||||
3 1
|
||||
6 1
|
||||
8 1
|
29
tests/queries/0_stateless/03148_asof_join_ddb_subquery.sql
Normal file
29
tests/queries/0_stateless/03148_asof_join_ddb_subquery.sql
Normal file
@ -0,0 +1,29 @@
|
||||
DROP TABLE IF EXISTS events;
|
||||
CREATE TABLE events (begin Float64, value Int32) ENGINE = MergeTree() ORDER BY begin;
|
||||
|
||||
INSERT INTO events VALUES (1, 0), (3, 1), (6, 2), (8, 3);
|
||||
|
||||
SET allow_experimental_analyzer = 1;
|
||||
SET join_algorithm = 'full_sorting_merge';
|
||||
SET joined_subquery_requires_alias = 0;
|
||||
|
||||
SELECT
|
||||
begin,
|
||||
value IN (
|
||||
SELECT e1.value
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM events e1
|
||||
WHERE e1.value = events.value
|
||||
) AS e1
|
||||
ASOF JOIN (
|
||||
SELECT number :: Float64 AS begin
|
||||
FROM numbers(10)
|
||||
WHERE number >= 1 AND number < 10
|
||||
)
|
||||
USING (begin)
|
||||
)
|
||||
FROM events
|
||||
ORDER BY begin ASC;
|
||||
|
||||
DROP TABLE IF EXISTS events;
|
@ -0,0 +1,56 @@
|
||||
2023-03-21 13:00:00 0
|
||||
2023-03-21 14:00:00 1
|
||||
2023-03-21 15:00:00 2
|
||||
2023-03-21 16:00:00 3
|
||||
2023-03-21 17:00:00 3
|
||||
2023-03-21 18:00:00 3
|
||||
2023-03-21 19:00:00 3
|
||||
2023-03-21 20:00:00 3
|
||||
2023-03-21 21:00:00 3
|
||||
2106-02-07 06:28:15 9
|
||||
2023-03-21 13:00:00 0
|
||||
2023-03-21 14:00:00 1
|
||||
2023-03-21 15:00:00 2
|
||||
2023-03-21 16:00:00 3
|
||||
2023-03-21 17:00:00 3
|
||||
2023-03-21 18:00:00 3
|
||||
2023-03-21 19:00:00 3
|
||||
2023-03-21 20:00:00 3
|
||||
2023-03-21 21:00:00 3
|
||||
2106-02-07 06:28:15 9
|
||||
2023-03-21 12:00:00 \N
|
||||
2023-03-21 13:00:00 0
|
||||
2023-03-21 14:00:00 1
|
||||
2023-03-21 15:00:00 2
|
||||
2023-03-21 16:00:00 3
|
||||
2023-03-21 17:00:00 3
|
||||
2023-03-21 18:00:00 3
|
||||
2023-03-21 19:00:00 3
|
||||
2023-03-21 20:00:00 3
|
||||
2023-03-21 21:00:00 3
|
||||
2106-02-07 06:28:15 9
|
||||
\N \N
|
||||
2023-03-21 12:00:00 0
|
||||
2023-03-21 13:00:00 0
|
||||
2023-03-21 14:00:00 1
|
||||
2023-03-21 15:00:00 2
|
||||
2023-03-21 16:00:00 3
|
||||
2023-03-21 17:00:00 3
|
||||
2023-03-21 18:00:00 3
|
||||
2023-03-21 19:00:00 3
|
||||
2023-03-21 20:00:00 3
|
||||
2023-03-21 21:00:00 3
|
||||
2106-02-07 06:28:15 9
|
||||
\N 0
|
||||
2023-03-21 12:00:00 \N
|
||||
2023-03-21 13:00:00 \N
|
||||
2023-03-21 14:00:00 \N
|
||||
2023-03-21 15:00:00 \N
|
||||
2023-03-21 16:00:00 \N
|
||||
2023-03-21 17:00:00 \N
|
||||
2023-03-21 18:00:00 \N
|
||||
2023-03-21 19:00:00 \N
|
||||
2023-03-21 20:00:00 \N
|
||||
2023-03-21 21:00:00 \N
|
||||
2106-02-07 06:28:15 \N
|
||||
\N \N
|
95
tests/queries/0_stateless/03149_asof_join_ddb_timestamps.sql
Normal file
95
tests/queries/0_stateless/03149_asof_join_ddb_timestamps.sql
Normal file
@ -0,0 +1,95 @@
|
||||
DROP TABLE IF EXISTS events0;
|
||||
DROP TABLE IF EXISTS probe0;
|
||||
|
||||
SET session_timezone = 'UTC';
|
||||
SET allow_experimental_analyzer = 1;
|
||||
SET join_algorithm = 'full_sorting_merge';
|
||||
SET join_use_nulls = 1;
|
||||
|
||||
CREATE TABLE events0
|
||||
ENGINE = MergeTree()
|
||||
ORDER BY COALESCE(begin, toDateTime('9999-12-31 23:59:59'))
|
||||
AS
|
||||
SELECT
|
||||
toNullable(toDateTime('2023-03-21 13:00:00') + INTERVAL number HOUR) AS begin,
|
||||
number AS value
|
||||
FROM numbers(4);
|
||||
|
||||
INSERT INTO events0 VALUES (NULL, -1), (toDateTime('9999-12-31 23:59:59'), 9);
|
||||
|
||||
CREATE TABLE probe0
|
||||
ENGINE = MergeTree()
|
||||
ORDER BY COALESCE(begin, toDateTime('9999-12-31 23:59:59'))
|
||||
AS
|
||||
SELECT
|
||||
toNullable(toDateTime('2023-03-21 12:00:00') + INTERVAL number HOUR) AS begin
|
||||
FROM numbers(10);
|
||||
|
||||
INSERT INTO probe0 VALUES (NULL), (toDateTime('9999-12-31 23:59:59'));
|
||||
|
||||
SELECT
|
||||
p.begin,
|
||||
e.value
|
||||
FROM
|
||||
probe0 p
|
||||
ASOF JOIN events0 e ON p.begin >= e.begin
|
||||
ORDER BY p.begin ASC;
|
||||
|
||||
SELECT
|
||||
p.begin,
|
||||
e.value
|
||||
FROM
|
||||
probe0 p
|
||||
ASOF JOIN events0 e USING (begin)
|
||||
ORDER BY p.begin ASC
|
||||
SETTINGS join_use_nulls = 0
|
||||
;
|
||||
|
||||
SELECT
|
||||
p.begin,
|
||||
e.value
|
||||
FROM
|
||||
probe0 p
|
||||
ASOF LEFT JOIN events0 e ON p.begin >= e.begin
|
||||
ORDER BY p.begin ASC;
|
||||
|
||||
SELECT
|
||||
p.begin,
|
||||
e.value
|
||||
FROM
|
||||
probe0 p
|
||||
ASOF LEFT JOIN events0 e USING (begin)
|
||||
ORDER BY p.begin ASC
|
||||
SETTINGS join_use_nulls = 0
|
||||
;
|
||||
|
||||
SELECT
|
||||
p.begin,
|
||||
e.value
|
||||
FROM
|
||||
probe0 p
|
||||
ASOF RIGHT JOIN events0 e ON p.begin >= e.begin
|
||||
ORDER BY e.begin ASC; -- { serverError NOT_IMPLEMENTED}
|
||||
|
||||
SELECT
|
||||
p.begin,
|
||||
e.value
|
||||
FROM
|
||||
probe0 p
|
||||
ASOF RIGHT JOIN events0 e USING (begin)
|
||||
ORDER BY e.begin ASC; -- { serverError NOT_IMPLEMENTED}
|
||||
|
||||
|
||||
SELECT
|
||||
p.begin,
|
||||
e.value
|
||||
FROM
|
||||
probe0 p
|
||||
ASOF LEFT JOIN (
|
||||
SELECT * FROM events0 WHERE log(value + 5) > 10
|
||||
) e ON p.begin >= e.begin
|
||||
ORDER BY p.begin ASC;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS events0;
|
||||
DROP TABLE IF EXISTS probe0;
|
Loading…
Reference in New Issue
Block a user