ClickHouse/tests/queries/0_stateless/00927_asof_join_long.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
1.0 KiB
MySQL
Raw Normal View History

2021-09-12 12:35:27 +00:00
-- Tags: long
2019-04-08 10:20:18 +00:00
DROP TABLE IF EXISTS tvs;
-- to use different algorithms for in subquery
SET allow_experimental_analyzer = 1;
2019-04-08 10:20:18 +00:00
CREATE TABLE tvs(k UInt32, t UInt32, tv UInt64) ENGINE = Memory;
INSERT INTO tvs(k,t,tv) SELECT k, t, t
FROM (SELECT toUInt32(number) AS k FROM numbers(1000)) keys
CROSS JOIN (SELECT toUInt32(number * 3) as t FROM numbers(10000)) tv_times
SETTINGS join_algorithm = 'hash';
2019-04-08 10:20:18 +00:00
SELECT SUM(trades.price - tvs.tv) FROM
(SELECT k, t, t as price
FROM (SELECT toUInt32(number) AS k FROM numbers(1000)) keys
CROSS JOIN (SELECT toUInt32(number * 10) AS t FROM numbers(3000)) trade_times
SETTINGS join_algorithm = 'hash') trades
2019-04-08 10:20:18 +00:00
ASOF LEFT JOIN tvs USING(k,t);
SELECT SUM(trades.price - tvs.tv) FROM
(SELECT k, t, t as price
FROM (SELECT toUInt32(number) AS k FROM numbers(1000)) keys
CROSS JOIN (SELECT toUInt32(number * 10) AS t FROM numbers(3000)) trade_times
SETTINGS join_algorithm = 'hash') trades
ASOF LEFT JOIN tvs USING(k,t)
SETTINGS join_algorithm = 'full_sorting_merge';
2019-04-08 10:20:18 +00:00
DROP TABLE tvs;