2021-09-12 12:35:27 +00:00
|
|
|
-- Tags: shard
|
|
|
|
|
2017-10-12 21:28:24 +00:00
|
|
|
SELECT X FROM (SELECT * FROM (SELECT 1 AS X, 2 AS Y) UNION ALL SELECT 3, 4) ORDER BY X;
|
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
DROP TABLE IF EXISTS globalin;
|
2017-10-12 21:28:24 +00:00
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
CREATE TABLE globalin (CounterID UInt32, StartDate Date ) ENGINE = Memory;
|
2017-10-12 21:28:24 +00:00
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
INSERT INTO globalin VALUES (34, toDate('2017-10-02')), (42, toDate('2017-10-02')), (55, toDate('2017-10-01'));
|
2017-10-12 21:28:24 +00:00
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM ( SELECT CounterID FROM remote('127.0.0.2', currentDatabase(), 'globalin') WHERE (CounterID GLOBAL IN ( SELECT toUInt32(34))) GROUP BY CounterID);
|
2017-10-12 21:28:24 +00:00
|
|
|
SELECT 'NOW okay =========================:';
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT CounterID FROM remote('127.0.0.2', currentDatabase(), 'globalin') WHERE (CounterID GLOBAL IN ( SELECT toUInt32(34) )) GROUP BY CounterID UNION ALL SELECT CounterID FROM remote('127.0.0.2', currentDatabase(), 'globalin') WHERE (CounterID GLOBAL IN ( SELECT toUInt32(34))) GROUP BY CounterID;
|
2017-10-12 21:28:24 +00:00
|
|
|
SELECT 'NOW BAD ==========================:';
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM ( SELECT CounterID FROM remote('127.0.0.2', currentDatabase(), 'globalin') WHERE (CounterID GLOBAL IN ( SELECT toUInt32(34) )) GROUP BY CounterID UNION ALL SELECT CounterID FROM remote('127.0.0.2', currentDatabase(), 'globalin') WHERE (CounterID GLOBAL IN ( SELECT toUInt32(34))) GROUP BY CounterID);
|
2017-10-12 21:28:24 +00:00
|
|
|
SELECT 'finish ===========================;';
|
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
DROP TABLE globalin;
|
2017-12-22 18:30:42 +00:00
|
|
|
|
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
DROP TABLE IF EXISTS union_bug;
|
2017-12-22 18:30:42 +00:00
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
CREATE TABLE union_bug (
|
2017-12-22 18:30:42 +00:00
|
|
|
Event String,
|
2018-12-27 20:44:07 +00:00
|
|
|
Datetime DateTime('Europe/Moscow')
|
2017-12-22 18:30:42 +00:00
|
|
|
) Engine = Memory;
|
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
INSERT INTO union_bug VALUES ('A', 1), ('B', 2);
|
2017-12-22 18:30:42 +00:00
|
|
|
|
|
|
|
SELECT ' * A UNION * B:';
|
|
|
|
SELECT * FROM (
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM union_bug WHERE Event = 'A'
|
2017-12-22 18:30:42 +00:00
|
|
|
UNION ALL
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM union_bug WHERE Event = 'B'
|
2017-12-22 18:30:42 +00:00
|
|
|
) ORDER BY Datetime;
|
|
|
|
|
|
|
|
SELECT ' Event, Datetime A UNION * B:';
|
|
|
|
SELECT * FROM (
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT Event, Datetime FROM union_bug WHERE Event = 'A'
|
2017-12-22 18:30:42 +00:00
|
|
|
UNION ALL
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM union_bug WHERE Event = 'B'
|
2017-12-22 18:30:42 +00:00
|
|
|
) ORDER BY Datetime;
|
|
|
|
|
|
|
|
SELECT ' * A UNION Event, Datetime B:';
|
|
|
|
SELECT * FROM (
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM union_bug WHERE Event = 'A'
|
2017-12-22 18:30:42 +00:00
|
|
|
UNION ALL
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT Event, Datetime FROM union_bug WHERE Event = 'B'
|
2017-12-22 18:30:42 +00:00
|
|
|
) ORDER BY Datetime;
|
|
|
|
|
|
|
|
SELECT ' Event, Datetime A UNION Event, Datetime B:';
|
|
|
|
SELECT * FROM (
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT Event, Datetime FROM union_bug WHERE Event = 'A'
|
2017-12-22 18:30:42 +00:00
|
|
|
UNION ALL
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT Event, Datetime FROM union_bug WHERE Event = 'B'
|
2017-12-22 18:30:42 +00:00
|
|
|
) ORDER BY Datetime;
|
|
|
|
|
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
DROP TABLE union_bug;
|