2024-04-03 10:04:36 +00:00
|
|
|
-- https://github.com/ClickHouse/ClickHouse/issues/6571
|
2024-04-05 16:19:47 +00:00
|
|
|
-- Tag: no-replicated-database
|
|
|
|
|
2024-04-04 13:37:38 +00:00
|
|
|
SET allow_experimental_analyzer=1;
|
2024-04-03 10:04:36 +00:00
|
|
|
CREATE TABLE LINEITEM_shard ON CLUSTER test_shard_localhost
|
|
|
|
(
|
|
|
|
L_ORDERKEY UInt64,
|
|
|
|
L_COMMITDATE UInt32,
|
|
|
|
L_RECEIPTDATE UInt32
|
|
|
|
)
|
|
|
|
ENGINE = MergeTree()
|
|
|
|
ORDER BY L_ORDERKEY;
|
|
|
|
|
|
|
|
CREATE TABLE LINEITEM AS LINEITEM_shard
|
|
|
|
ENGINE = Distributed('test_shard_localhost', currentDatabase(), LINEITEM_shard, rand());
|
|
|
|
|
|
|
|
CREATE TABLE ORDERS_shard ON CLUSTER test_shard_localhost
|
|
|
|
(
|
|
|
|
O_ORDERKEY UInt64,
|
|
|
|
O_ORDERPRIORITY UInt32
|
|
|
|
)
|
|
|
|
ENGINE = MergeTree()
|
|
|
|
ORDER BY O_ORDERKEY;
|
|
|
|
|
|
|
|
CREATE TABLE ORDERS AS ORDERS_shard
|
|
|
|
ENGINE = Distributed('test_shard_localhost', currentDatabase(), ORDERS_shard, rand());
|
|
|
|
|
|
|
|
SET joined_subquery_requires_alias=0;
|
|
|
|
|
|
|
|
select
|
|
|
|
O_ORDERPRIORITY,
|
|
|
|
count(*) as order_count
|
|
|
|
from ORDERS JOIN (
|
|
|
|
select L_ORDERKEY
|
|
|
|
from
|
|
|
|
LINEITEM_shard
|
|
|
|
group by L_ORDERKEY
|
|
|
|
having any(L_COMMITDATE < L_RECEIPTDATE)
|
|
|
|
) on O_ORDERKEY=L_ORDERKEY
|
|
|
|
group by O_ORDERPRIORITY
|
|
|
|
order by O_ORDERPRIORITY
|
|
|
|
limit 1;
|
|
|
|
|
|
|
|
SET joined_subquery_requires_alias=1;
|
|
|
|
|
|
|
|
select
|
|
|
|
O_ORDERPRIORITY,
|
|
|
|
count(*) as order_count
|
|
|
|
from ORDERS JOIN (
|
|
|
|
select L_ORDERKEY
|
|
|
|
from
|
|
|
|
LINEITEM_shard
|
|
|
|
group by L_ORDERKEY
|
|
|
|
having any(L_COMMITDATE < L_RECEIPTDATE)
|
|
|
|
) AS x on O_ORDERKEY=L_ORDERKEY
|
|
|
|
group by O_ORDERPRIORITY
|
|
|
|
order by O_ORDERPRIORITY
|
|
|
|
limit 1;
|