2021-01-13 10:34:58 +00:00
|
|
|
DROP TABLE IF EXISTS xp;
|
|
|
|
DROP TABLE IF EXISTS xp_d;
|
|
|
|
|
2021-01-14 13:53:42 +00:00
|
|
|
SET log_queries = 1;
|
|
|
|
|
2021-01-13 10:34:58 +00:00
|
|
|
CREATE TABLE xp (`A` Date, `B` Int64, `S` String) ENGINE = MergeTree PARTITION BY toYYYYMM(A) ORDER BY B;
|
|
|
|
INSERT INTO xp SELECT '2020-01-01', number, '' FROM numbers(100000);
|
|
|
|
|
|
|
|
CREATE TABLE xp_d AS xp ENGINE = Distributed(test_shard_localhost, currentDatabase(), xp);
|
|
|
|
|
2023-06-02 13:36:14 +00:00
|
|
|
SELECT count(7 = (SELECT number FROM numbers(0) ORDER BY number ASC NULLS FIRST LIMIT 7)) FROM xp_d PREWHERE toYYYYMM(A) GLOBAL IN (SELECT NULL = (SELECT number FROM numbers(1) ORDER BY number DESC NULLS LAST LIMIT 1), toYYYYMM(min(A)) FROM xp_d) WHERE B > NULL; -- { serverError 8 }
|
2021-01-13 10:34:58 +00:00
|
|
|
|
2023-06-02 13:36:14 +00:00
|
|
|
SELECT count() FROM xp_d WHERE A GLOBAL IN (SELECT NULL);
|
2021-01-13 10:34:58 +00:00
|
|
|
|
|
|
|
DROP TABLE IF EXISTS xp;
|
|
|
|
DROP TABLE IF EXISTS xp_d;
|
|
|
|
|
2021-01-14 08:38:24 +00:00
|
|
|
DROP TABLE IF EXISTS trace_log;
|
|
|
|
CREATE TABLE trace_log
|
|
|
|
(
|
|
|
|
`event_date` Date,
|
|
|
|
`event_time` DateTime,
|
|
|
|
`event_time_microseconds` DateTime64(6),
|
|
|
|
`timestamp_ns` UInt64,
|
|
|
|
`revision` UInt32,
|
|
|
|
`trace_type` Enum8('Real' = 0, 'CPU' = 1, 'Memory' = 2, 'MemorySample' = 3),
|
|
|
|
`thread_id` UInt64,
|
|
|
|
`query_id` String,
|
|
|
|
`trace` Array(UInt64),
|
|
|
|
`size` Int64
|
|
|
|
)
|
|
|
|
ENGINE = MergeTree
|
|
|
|
PARTITION BY toYYYYMM(event_date)
|
|
|
|
ORDER BY (event_date, event_time)
|
|
|
|
SETTINGS index_granularity = 8192;
|
|
|
|
|
|
|
|
INSERT INTO trace_log values ('2020-10-06','2020-10-06 13:43:39','2020-10-06 13:43:39.208819',1601981019208819975,54441,'Real',20412,'2e8ddf40-48da-4641-8ccc-573dd487753f',[140316350688023,130685338,226362737,224904385,227758790,227742969,227761037,224450136,219847931,219844987,219854151,223212098,223208665,228194329,228227607,257889111,257890159,258775545,258767526,140316350645979,140316343425599],0);
|
|
|
|
|
|
|
|
|
2021-01-13 10:34:58 +00:00
|
|
|
set allow_introspection_functions = 1;
|
|
|
|
|
2021-01-15 17:39:32 +00:00
|
|
|
-- make sure query_log exists
|
|
|
|
SYSTEM FLUSH LOGS;
|
|
|
|
|
2021-01-13 10:34:58 +00:00
|
|
|
WITH concat(addressToLine(arrayJoin(trace) AS addr), '#') AS symbol
|
|
|
|
SELECT count() > 7
|
2021-01-14 08:39:27 +00:00
|
|
|
FROM trace_log AS t
|
2021-05-31 18:50:07 +00:00
|
|
|
WHERE (query_id =
|
2021-01-13 10:34:58 +00:00
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
[NULL, NULL, NULL, NULL, 0.00009999999747378752, NULL, NULL, NULL, NULL, NULL],
|
|
|
|
query_id
|
|
|
|
FROM system.query_log
|
2021-01-26 19:56:11 +00:00
|
|
|
WHERE current_database = currentDatabase() AND (query LIKE '%test cpu time query profiler%') AND (query NOT LIKE '%system%')
|
2021-01-13 10:34:58 +00:00
|
|
|
ORDER BY event_time DESC
|
|
|
|
LIMIT 1
|
2021-07-19 12:35:55 +00:00
|
|
|
)) AND (symbol LIKE '%Source%'); -- { serverError 125 }
|
2021-01-13 10:34:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
WITH addressToSymbol(arrayJoin(trace)) AS symbol
|
|
|
|
SELECT count() > 0
|
2021-01-14 08:39:27 +00:00
|
|
|
FROM trace_log AS t
|
2021-05-31 18:50:07 +00:00
|
|
|
WHERE greaterOrEquals(event_date, ignore(ignore(ignore(NULL, '')), 256), yesterday()) AND (trace_type = 'Memory') AND (query_id =
|
2021-01-13 10:34:58 +00:00
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
ignore(ignore(ignore(ignore(65536)), ignore(65537), ignore(2)), ''),
|
|
|
|
query_id
|
|
|
|
FROM system.query_log
|
2021-01-26 19:56:11 +00:00
|
|
|
WHERE current_database = currentDatabase() AND (event_date >= yesterday()) AND (query LIKE '%test memory profiler%')
|
2021-01-13 10:34:58 +00:00
|
|
|
ORDER BY event_time DESC
|
|
|
|
LIMIT 1
|
2021-07-19 12:35:55 +00:00
|
|
|
)); -- { serverError 125 }
|
2021-01-13 10:34:58 +00:00
|
|
|
|
2021-01-14 08:38:24 +00:00
|
|
|
DROP TABLE IF EXISTS trace_log;
|
|
|
|
|
2021-01-14 13:53:42 +00:00
|
|
|
SYSTEM FLUSH LOGS;
|
|
|
|
|
2021-01-13 10:34:58 +00:00
|
|
|
WITH (
|
|
|
|
(
|
|
|
|
SELECT query_start_time_microseconds
|
|
|
|
FROM system.query_log
|
2021-01-26 19:56:11 +00:00
|
|
|
WHERE current_database = currentDatabase()
|
2021-01-13 10:34:58 +00:00
|
|
|
ORDER BY query_start_time DESC
|
|
|
|
LIMIT 1
|
2021-05-31 18:50:07 +00:00
|
|
|
) AS time_with_microseconds,
|
2021-01-13 10:34:58 +00:00
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
inf,
|
|
|
|
query_start_time
|
|
|
|
FROM system.query_log
|
2021-01-26 19:56:11 +00:00
|
|
|
WHERE current_database = currentDatabase()
|
2021-01-13 10:34:58 +00:00
|
|
|
ORDER BY query_start_time DESC
|
|
|
|
LIMIT 1
|
|
|
|
) AS t)
|
|
|
|
SELECT if(dateDiff('second', toDateTime(time_with_microseconds), toDateTime(t)) = -9223372036854775808, 'ok', ''); -- { serverError 43 }
|
|
|
|
|
|
|
|
WITH (
|
|
|
|
(
|
|
|
|
SELECT query_start_time_microseconds
|
|
|
|
FROM system.query_log
|
2021-01-26 19:56:11 +00:00
|
|
|
WHERE current_database = currentDatabase()
|
2021-01-13 10:34:58 +00:00
|
|
|
ORDER BY query_start_time DESC
|
|
|
|
LIMIT 1
|
2021-05-31 18:50:07 +00:00
|
|
|
) AS time_with_microseconds,
|
2021-01-13 10:34:58 +00:00
|
|
|
(
|
|
|
|
SELECT query_start_time
|
|
|
|
FROM system.query_log
|
2021-01-26 19:56:11 +00:00
|
|
|
WHERE current_database = currentDatabase()
|
2021-01-13 10:34:58 +00:00
|
|
|
ORDER BY query_start_time DESC
|
|
|
|
LIMIT 1
|
|
|
|
) AS t)
|
|
|
|
SELECT if(dateDiff('second', toDateTime(time_with_microseconds), toDateTime(t)) = -9223372036854775808, 'ok', '');
|
|
|
|
|
2021-01-22 10:25:59 +00:00
|
|
|
set joined_subquery_requires_alias=0;
|
2021-01-22 09:39:33 +00:00
|
|
|
SELECT number, number / 2 AS n, j1, j2 FROM remote('127.0.0.{2,3}', system.numbers) GLOBAL ANY LEFT JOIN (SELECT number / 3 AS n, number AS j1, 'Hello' AS j2 FROM system.numbers LIMIT 1048577) USING (n) LIMIT 10 format Null;
|