2019-07-29 14:58:36 +00:00
|
|
|
DROP TABLE IF EXISTS A;
|
|
|
|
DROP TABLE IF EXISTS B;
|
|
|
|
|
|
|
|
CREATE TABLE A(a UInt32, t UInt32) ENGINE = Memory;
|
|
|
|
CREATE TABLE B(b UInt32, t UInt32) ENGINE = Memory;
|
|
|
|
|
|
|
|
INSERT INTO A (a,t) VALUES (1,1),(1,2),(1,3), (2,1),(2,2),(2,3), (3,1),(3,2),(3,3);
|
|
|
|
INSERT INTO B (b,t) VALUES (1,2),(1,4),(2,3);
|
|
|
|
|
2024-07-18 11:31:23 +00:00
|
|
|
{% for join_use_nulls in [0, 1] -%}
|
2023-09-28 12:50:24 +00:00
|
|
|
{% for join_algorithm in ['default', 'full_sorting_merge'] -%}
|
|
|
|
|
|
|
|
SET join_algorithm = '{{ join_algorithm }}';
|
|
|
|
|
2024-07-18 11:31:23 +00:00
|
|
|
SELECT '- {{ join_algorithm }} / join_use_nulls = {{ join_use_nulls }} -';
|
|
|
|
set join_use_nulls = {{ join_use_nulls }};
|
2023-09-28 12:50:24 +00:00
|
|
|
|
2019-07-29 14:58:36 +00:00
|
|
|
SELECT A.a, A.t, B.b, B.t FROM A ASOF LEFT JOIN B ON A.a == B.b AND A.t >= B.t ORDER BY (A.a, A.t);
|
|
|
|
SELECT count() FROM A ASOF LEFT JOIN B ON A.a == B.b AND B.t <= A.t;
|
2019-10-11 17:56:26 +00:00
|
|
|
SELECT A.a, A.t, B.b, B.t FROM A ASOF INNER JOIN B ON B.t <= A.t AND A.a == B.b ORDER BY (A.a, A.t);
|
|
|
|
SELECT '-';
|
|
|
|
SELECT A.a, A.t, B.b, B.t FROM A ASOF JOIN B ON A.a == B.b AND A.t <= B.t ORDER BY (A.a, A.t);
|
|
|
|
SELECT '-';
|
|
|
|
SELECT A.a, A.t, B.b, B.t FROM A ASOF JOIN B ON A.a == B.b AND B.t >= A.t ORDER BY (A.a, A.t);
|
|
|
|
SELECT '-';
|
|
|
|
SELECT A.a, A.t, B.b, B.t FROM A ASOF JOIN B ON A.a == B.b AND A.t > B.t ORDER BY (A.a, A.t);
|
|
|
|
SELECT '-';
|
|
|
|
SELECT A.a, A.t, B.b, B.t FROM A ASOF JOIN B ON A.a == B.b AND A.t < B.t ORDER BY (A.a, A.t);
|
2024-05-30 12:27:25 +00:00
|
|
|
SELECT count() FROM A ASOF JOIN B ON A.a == B.b AND A.t == B.t; -- { serverError INVALID_JOIN_ON_EXPRESSION }
|
|
|
|
SELECT count() FROM A ASOF JOIN B ON A.a == B.b AND A.t != B.t; -- { serverError INVALID_JOIN_ON_EXPRESSION }
|
2019-07-29 14:58:36 +00:00
|
|
|
|
2024-05-30 12:27:25 +00:00
|
|
|
SELECT A.a, A.t, B.b, B.t FROM A ASOF JOIN B ON A.a == B.b AND A.t < B.t OR A.a == B.b + 1 ORDER BY (A.a, A.t); -- { serverError NOT_IMPLEMENTED }
|
2021-09-13 09:34:34 +00:00
|
|
|
|
2023-06-29 17:12:55 +00:00
|
|
|
SELECT A.a, A.t, B.b, B.t FROM A
|
|
|
|
ASOF INNER JOIN (SELECT * FROM B UNION ALL SELECT 1, 3) AS B ON B.t <= A.t AND A.a == B.b
|
|
|
|
WHERE B.t != 3 ORDER BY (A.a, A.t)
|
|
|
|
;
|
|
|
|
|
2024-07-18 11:31:23 +00:00
|
|
|
{% endfor -%}
|
|
|
|
{% endfor -%}
|
2023-09-28 12:50:24 +00:00
|
|
|
|
2019-07-29 14:58:36 +00:00
|
|
|
DROP TABLE A;
|
|
|
|
DROP TABLE B;
|