From da51e2963a0fe0cdcfdae314ea0f708b66599393 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Tue, 31 Mar 2026 17:35:19 +0000 Subject: [PATCH 01/70] Backport #100225 to 26.3: Fix use-of-uninitialized-value in StringSearcher.h --- src/Common/StringSearcher.h | 12 +++++++++--- .../03629_starts_endswith_caseinsensitive.reference | 8 ++++++++ .../03629_starts_endswith_caseinsensitive.sql | 11 +++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/Common/StringSearcher.h b/src/Common/StringSearcher.h index baee8abf9dc3..b7123fa3fc11 100644 --- a/src/Common/StringSearcher.h +++ b/src/Common/StringSearcher.h @@ -162,8 +162,11 @@ class StringSearcher final : public StringSearcherBase #endif } - ALWAYS_INLINE bool compare(const UInt8 * /*haystack*/, const UInt8 * /*haystack_end*/, const UInt8 * pos) const + ALWAYS_INLINE bool compare(const UInt8 * /*haystack*/, const UInt8 * haystack_end, const UInt8 * pos) const { + if (needle == needle_end) + return true; + #ifdef __SSE4_1__ if (isPageSafe(pos)) { @@ -180,7 +183,7 @@ class StringSearcher final : public StringSearcherBase pos += N; const auto * needle_pos = needle + N; - while (needle_pos < needle_end && std::tolower(*pos) == std::tolower(*needle_pos)) + while (needle_pos < needle_end && pos < haystack_end && std::tolower(*pos) == std::tolower(*needle_pos)) { ++pos; ++needle_pos; @@ -202,7 +205,7 @@ class StringSearcher final : public StringSearcherBase ++pos; const auto * needle_pos = needle + 1; - while (needle_pos < needle_end && std::tolower(*pos) == std::tolower(*needle_pos)) + while (needle_pos < needle_end && pos < haystack_end && std::tolower(*pos) == std::tolower(*needle_pos)) { ++pos; ++needle_pos; @@ -470,6 +473,9 @@ class StringSearcher final : public StringSearcherBase ALWAYS_INLINE bool compare(const UInt8 * /*haystack*/, const UInt8 * haystack_end, const UInt8 * pos) const { + if (needle == needle_end) + return true; + #ifdef __SSE4_1__ if (isPageSafe(pos) && !force_fallback) { diff --git a/tests/queries/0_stateless/03629_starts_endswith_caseinsensitive.reference b/tests/queries/0_stateless/03629_starts_endswith_caseinsensitive.reference index 2f463aba3e5d..b1ac263b6ad2 100644 --- a/tests/queries/0_stateless/03629_starts_endswith_caseinsensitive.reference +++ b/tests/queries/0_stateless/03629_starts_endswith_caseinsensitive.reference @@ -49,3 +49,11 @@ 0 3 1 +-- Test empty needle +1 +1 +1 +1 +1 +1 +1 diff --git a/tests/queries/0_stateless/03629_starts_endswith_caseinsensitive.sql b/tests/queries/0_stateless/03629_starts_endswith_caseinsensitive.sql index 8d0c387c007f..75c71ac0df84 100644 --- a/tests/queries/0_stateless/03629_starts_endswith_caseinsensitive.sql +++ b/tests/queries/0_stateless/03629_starts_endswith_caseinsensitive.sql @@ -82,3 +82,14 @@ SELECT COUNT() FROM tab WHERE endsWithCaseInsensitiveUTF8(S1, S2); -- endsWithCaseCaseInsensitiveUTF8 does not support FixedString DROP TABLE tab; + +-- Empty needle must always match (return 1). Regression test for a use-of-uninitialized-value +-- in StringSearcher::compare which unconditionally dereferenced *pos even when needle was empty. +SELECT '-- Test empty needle'; +SELECT startsWithCaseInsensitive('Hello', ''); +SELECT startsWithCaseInsensitive(toFixedString('Hello', 10), ''); +SELECT endsWithCaseInsensitive('Hello', ''); +SELECT endsWithCaseInsensitive(toFixedString('Hello', 10), ''); +SELECT endsWithCaseInsensitive(toFixedString(toFixedString('富强民主文明和谐', 24), 24), ''); +SELECT startsWithCaseInsensitiveUTF8('Привет', ''); +SELECT endsWithCaseInsensitiveUTF8('Привет', ''); From 6f2d1682b1a54dcb5778336efd49dcb31f5b2d55 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Mon, 6 Apr 2026 17:29:02 +0000 Subject: [PATCH 02/70] Backport #101405 to 26.3: Fix BACKUP FROM SNAPSHOT AST formatting and cloning --- src/Parsers/ASTBackupQuery.cpp | 15 ++++++++++++++- ...4073_backup_from_snapshot_ast_format.reference | 3 +++ .../04073_backup_from_snapshot_ast_format.sql | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/queries/0_stateless/04073_backup_from_snapshot_ast_format.reference create mode 100644 tests/queries/0_stateless/04073_backup_from_snapshot_ast_format.sql diff --git a/src/Parsers/ASTBackupQuery.cpp b/src/Parsers/ASTBackupQuery.cpp index 1a8af1d0312b..30b3e141a57c 100644 --- a/src/Parsers/ASTBackupQuery.cpp +++ b/src/Parsers/ASTBackupQuery.cpp @@ -291,6 +291,9 @@ ASTPtr ASTBackupQuery::clone() const if (base_backup_name) res->set(res->base_backup_name, base_backup_name->clone()); + if (base_snapshot_name) + res->set(res->base_snapshot_name, base_snapshot_name->clone()); + if (cluster_host_ids) res->cluster_host_ids = cluster_host_ids->clone(); @@ -307,7 +310,17 @@ void ASTBackupQuery::formatQueryImpl(WriteBuffer & ostr, const FormatSettings & { ostr << ((kind == Kind::BACKUP) ? "BACKUP " : "RESTORE "); - formatElements(elements, ostr, fs); + if (base_snapshot_name) + { + /// BACKUP FROM SNAPSHOT [ON CLUSTER ...] TO + ostr << "FROM SNAPSHOT "; + base_snapshot_name->format(ostr, fs); + } + else + { + formatElements(elements, ostr, fs); + } + formatOnCluster(ostr, fs); ostr << ((kind == Kind::BACKUP) ? " TO " : " FROM "); diff --git a/tests/queries/0_stateless/04073_backup_from_snapshot_ast_format.reference b/tests/queries/0_stateless/04073_backup_from_snapshot_ast_format.reference new file mode 100644 index 000000000000..e562daec120c --- /dev/null +++ b/tests/queries/0_stateless/04073_backup_from_snapshot_ast_format.reference @@ -0,0 +1,3 @@ +BACKUP FROM SNAPSHOT S3(\'http://localhost:9000/bucket/snapshot/\') TO S3(\'http://localhost:9000/bucket/backup/\') +BACKUP FROM SNAPSHOT S3(\'http://localhost:9000/bucket/snapshot/\') TO S3(\'http://localhost:9000/bucket/backup/\') SETTINGS id = \'abc\' +BACKUP FROM SNAPSHOT Disk(\'default\', \'/snapshot/\') TO Disk(\'default\', \'/backup/\') diff --git a/tests/queries/0_stateless/04073_backup_from_snapshot_ast_format.sql b/tests/queries/0_stateless/04073_backup_from_snapshot_ast_format.sql new file mode 100644 index 000000000000..871d35b45495 --- /dev/null +++ b/tests/queries/0_stateless/04073_backup_from_snapshot_ast_format.sql @@ -0,0 +1,3 @@ +SELECT formatQuery('BACKUP FROM SNAPSHOT S3(\'http://localhost:9000/bucket/snapshot/\') TO S3(\'http://localhost:9000/bucket/backup/\')'); +SELECT formatQuery('BACKUP FROM SNAPSHOT S3(\'http://localhost:9000/bucket/snapshot/\') TO S3(\'http://localhost:9000/bucket/backup/\') SETTINGS id = \'abc\''); +SELECT formatQuery('BACKUP FROM SNAPSHOT Disk(\'default\', \'/snapshot/\') TO Disk(\'default\', \'/backup/\')'); From ab73e5c6be10cdee8e6ab6f9b4f03cf06143796c Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Tue, 14 Apr 2026 13:26:36 +0000 Subject: [PATCH 03/70] Update autogenerated version to 26.3.9.8 and contributors --- cmake/autogenerated_versions.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/autogenerated_versions.txt b/cmake/autogenerated_versions.txt index 005fad76dc6a..d2edda671281 100644 --- a/cmake/autogenerated_versions.txt +++ b/cmake/autogenerated_versions.txt @@ -2,11 +2,11 @@ # NOTE: VERSION_REVISION has nothing common with DBMS_TCP_PROTOCOL_VERSION, # only DBMS_TCP_PROTOCOL_VERSION should be incremented on protocol changes. -SET(VERSION_REVISION 54516) +SET(VERSION_REVISION 54517) SET(VERSION_MAJOR 26) SET(VERSION_MINOR 3) -SET(VERSION_PATCH 9) -SET(VERSION_GITHASH f3c6e5a4d27c3997b2a91174752e44acedc51f74) -SET(VERSION_DESCRIBE v26.3.9.1-lts) -SET(VERSION_STRING 26.3.9.1) +SET(VERSION_PATCH 10) +SET(VERSION_GITHASH 0d82c1998e3b4d54e110dd8a77a64d247c4bff4a) +SET(VERSION_DESCRIBE v26.3.10.1-lts) +SET(VERSION_STRING 26.3.10.1) # end of autochange From a44e12daa098ac5cac3ff40cf638d211f4132752 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Tue, 14 Apr 2026 13:49:11 +0000 Subject: [PATCH 04/70] Backport #101761 to 26.3: Fix use-after-free in CPULeaseAllocation wait timer --- src/Common/Scheduler/CPULeaseAllocation.cpp | 10 +++++++++- src/Common/Scheduler/CPULeaseAllocation.h | 9 +++++++++ .../integration/test_scheduler_cpu_preemptive/test.py | 10 ++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Common/Scheduler/CPULeaseAllocation.cpp b/src/Common/Scheduler/CPULeaseAllocation.cpp index a39c84ebb93f..c29142268d77 100644 --- a/src/Common/Scheduler/CPULeaseAllocation.cpp +++ b/src/Common/Scheduler/CPULeaseAllocation.cpp @@ -202,6 +202,13 @@ CPULeaseAllocation::CPULeaseAllocation(SlotCount max_threads_, ResourceLink mast , scheduled_increment(CurrentMetrics::ConcurrencyControlScheduled, 0) , lease_id(lease_counter.fetch_add(1, std::memory_order_relaxed)) { + // Capture query-level counters (ThreadGroup) that outlive all worker threads. + // Cannot use CurrentThread::getProfileEvents() in schedule() — it returns the calling + // thread's counters, which may be destroyed before the timer is flushed (UAF). + wait_thread_group = CurrentThread::getGroup(); + if (wait_thread_group) + wait_counters = &wait_thread_group->performance_counters; + std::unique_lock lock{mutex}; if (!schedule(lock)) grantImpl(lock); @@ -221,6 +228,7 @@ void CPULeaseAllocation::free() shutdown = true; acquirable.store(false, std::memory_order_relaxed); + wait_timer.reset(); // Wake up all preempted threads while (true) @@ -597,7 +605,7 @@ bool CPULeaseAllocation::schedule(std::unique_lock &) if (requests.enqueue(cost, requested_ns)) { scheduled_increment.add(); - wait_timer.emplace(CurrentThread::getProfileEvents().timer(ProfileEvents::ConcurrencyControlWaitMicroseconds)); + wait_timer.emplace(wait_counters->timer(ProfileEvents::ConcurrencyControlWaitMicroseconds)); LOG_EVENT(E); return true; } diff --git a/src/Common/Scheduler/CPULeaseAllocation.h b/src/Common/Scheduler/CPULeaseAllocation.h index 20a5dba51cd7..2fd663409d02 100644 --- a/src/Common/Scheduler/CPULeaseAllocation.h +++ b/src/Common/Scheduler/CPULeaseAllocation.h @@ -20,6 +20,8 @@ namespace DB { +class ThreadGroup; + struct CPULeaseSettings { static constexpr ResourceCost default_quantum_ns = 10'000'000; @@ -316,6 +318,13 @@ class CPULeaseAllocation final : public ISlotAllocation /// Introspection CurrentMetrics::Increment acquired_increment; CurrentMetrics::Increment scheduled_increment; + /// Stable counters for wait_timer. We cannot use CurrentThread::getProfileEvents() in + /// schedule() because it returns the calling thread's counters, which may be destroyed + /// before the timer is flushed — storing a Timer with a dangling Counters& causes UAF. + /// The ThreadGroupPtr keeps the ThreadGroup (and its performance_counters) alive. + /// Declared before wait_timer so the owner outlives the timer during member destruction. + std::shared_ptr wait_thread_group; + ProfileEvents::Counters * wait_counters = &ProfileEvents::global_counters; std::optional wait_timer; const size_t lease_id; /// Unique identifier for this lease allocation, used for tracing static std::atomic lease_counter; diff --git a/tests/integration/test_scheduler_cpu_preemptive/test.py b/tests/integration/test_scheduler_cpu_preemptive/test.py index 2fe4753b39da..9aab4e5368f9 100644 --- a/tests/integration/test_scheduler_cpu_preemptive/test.py +++ b/tests/integration/test_scheduler_cpu_preemptive/test.py @@ -195,6 +195,16 @@ def assert_query(node, query_id, slots): "ConcurrencyControlDownscales", lambda x: x == 0, ) + # Verify ConcurrencyControlWaitMicroseconds is populated at query level. + # With independent pools all running concurrently, each query will experience + # scheduler wait time > 0. This serves as a smoke test for the wait timer fix + # (the metric is tracked at ThreadGroup level, not per-thread). + assert_profile_event( + node, + query_id, + "ConcurrencyControlWaitMicroseconds", + lambda x: x > 0, + ) # NOTE: checking thread_ids length is pointless, because query could downscale and then upscale again, gaining more threads than slots assert_query(node, 'test_production', 15) From 96cd9db1fdb460e8db333fa3eedec91745e15bb9 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 15 Apr 2026 03:19:26 +0000 Subject: [PATCH 05/70] Backport #102606 to 26.3: Use `openssl` 3.5.6 --- contrib/openssl | 2 +- contrib/openssl-cmake/common/include/openssl/cmp.h | 2 ++ .../openssl-cmake/common/include/openssl/opensslv.h | 10 +++++----- tests/integration/test_dictionaries_ddl/test.py | 12 ++++++++++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/contrib/openssl b/contrib/openssl index 04b25b3dadff..d0f95dba4cb0 160000 --- a/contrib/openssl +++ b/contrib/openssl @@ -1 +1 @@ -Subproject commit 04b25b3dadff812b1e11e8ef1e0e2c4ec29d41f9 +Subproject commit d0f95dba4cb06e912c131d64ec77acb20d270fd1 diff --git a/contrib/openssl-cmake/common/include/openssl/cmp.h b/contrib/openssl-cmake/common/include/openssl/cmp.h index 05aed3029d59..fff7ea754c17 100644 --- a/contrib/openssl-cmake/common/include/openssl/cmp.h +++ b/contrib/openssl-cmake/common/include/openssl/cmp.h @@ -194,6 +194,8 @@ typedef ASN1_BIT_STRING OSSL_CMP_PKIFAILUREINFO; * -- CertReqMsg * } */ +# define OSSL_CMP_PKISTATUS_rejected_by_client -5 +# define OSSL_CMP_PKISTATUS_checking_response -4 # define OSSL_CMP_PKISTATUS_request -3 # define OSSL_CMP_PKISTATUS_trans -2 # define OSSL_CMP_PKISTATUS_unspecified -1 diff --git a/contrib/openssl-cmake/common/include/openssl/opensslv.h b/contrib/openssl-cmake/common/include/openssl/opensslv.h index 4b628b6f49e3..110c34de0e46 100644 --- a/contrib/openssl-cmake/common/include/openssl/opensslv.h +++ b/contrib/openssl-cmake/common/include/openssl/opensslv.h @@ -29,7 +29,7 @@ extern "C" { */ # define OPENSSL_VERSION_MAJOR 3 # define OPENSSL_VERSION_MINOR 5 -# define OPENSSL_VERSION_PATCH 0 +# define OPENSSL_VERSION_PATCH 6 /* * Additional version information @@ -74,21 +74,21 @@ extern "C" { * longer variant with OPENSSL_VERSION_PRE_RELEASE_STR and * OPENSSL_VERSION_BUILD_METADATA_STR appended. */ -# define OPENSSL_VERSION_STR "3.5.0" -# define OPENSSL_FULL_VERSION_STR "3.5.0" +# define OPENSSL_VERSION_STR "3.5.6" +# define OPENSSL_FULL_VERSION_STR "3.5.6" /* * SECTION 3: ADDITIONAL METADATA * * These strings are defined separately to allow them to be parsable. */ -# define OPENSSL_RELEASE_DATE "8 Apr 2025" +# define OPENSSL_RELEASE_DATE "7 Apr 2026" /* * SECTION 4: BACKWARD COMPATIBILITY */ -# define OPENSSL_VERSION_TEXT "OpenSSL 3.5.0 8 Apr 2025" +# define OPENSSL_VERSION_TEXT "OpenSSL 3.5.6 7 Apr 2026" /* Synthesize OPENSSL_VERSION_NUMBER with the layout 0xMNN00PPSL */ # ifdef OPENSSL_VERSION_PRE_RELEASE diff --git a/tests/integration/test_dictionaries_ddl/test.py b/tests/integration/test_dictionaries_ddl/test.py index 85beda5af81f..6d455b8c07f3 100644 --- a/tests/integration/test_dictionaries_ddl/test.py +++ b/tests/integration/test_dictionaries_ddl/test.py @@ -590,7 +590,11 @@ def test_secure(started_cluster): ) with pytest.raises(QueryRuntimeException) as excinfo: node1.query("SELECT dictGet('test.clickhouse_secure', 'value', toUInt64(1))") - assert "Unexpected packet from server localhost:9440" in str(excinfo.value) + error = str(excinfo.value) + assert ( + "Unexpected packet from server localhost:9440" in error + or "Connection reset by peer" in error + ) # Secure is set to 0 in named collection node1.query("DROP DICTIONARY IF EXISTS test.clickhouse_secure") @@ -611,7 +615,11 @@ def test_secure(started_cluster): ) with pytest.raises(QueryRuntimeException) as excinfo: node1.query("SELECT dictGet('test.clickhouse_secure', 'value', toUInt64(1))") - assert "Unexpected packet from server localhost:9440" in str(excinfo.value) + error = str(excinfo.value) + assert ( + "Unexpected packet from server localhost:9440" in error + or "Connection reset by peer" in error + ) # Secure is set to 0 in named collection and in 1 in DDL node1.query("DROP DICTIONARY IF EXISTS test.clickhouse_secure") From ee150cd859b9bbf4a46c8f229229ced837c3d149 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 15 Apr 2026 08:50:39 +0000 Subject: [PATCH 06/70] Backport #102681 to 26.3: Fix SYSTEM WAIT VIEW hanging forever when the view is dropped --- src/Storages/MaterializedView/RefreshTask.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Storages/MaterializedView/RefreshTask.cpp b/src/Storages/MaterializedView/RefreshTask.cpp index ed1e4ad8e94f..0e5f3a9006a9 100644 --- a/src/Storages/MaterializedView/RefreshTask.cpp +++ b/src/Storages/MaterializedView/RefreshTask.cpp @@ -229,6 +229,11 @@ void RefreshTask::shutdown() set_handle.reset(); view = nullptr; + + /// Wake up any threads blocked in wait(), so they can see !view and throw TABLE_IS_DROPPED. + /// Without this, wait() would block forever after deactivate() prevents the background task + /// from running (and therefore from ever notifying refresh_cv). + refresh_cv.notify_all(); } void RefreshTask::drop(ContextPtr context) @@ -404,8 +409,10 @@ void RefreshTask::wait() std::unique_lock lock(mutex); refresh_cv.wait(lock, [&] { - return state != RefreshState::Running && state != RefreshState::Scheduling && - state != RefreshState::RunningOnAnotherReplica && (state == RefreshState::Disabled || !scheduling.out_of_schedule_refresh_requested); + return !view + || (state != RefreshState::Running && state != RefreshState::Scheduling + && state != RefreshState::RunningOnAnotherReplica + && (state == RefreshState::Disabled || !scheduling.out_of_schedule_refresh_requested)); }); throw_if_error(); From 63841ff810776c88f63bf3dae5b8704ae8554e61 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 15 Apr 2026 08:52:22 +0000 Subject: [PATCH 07/70] Backport #102598 to 26.3: Fix `NamedCollection` metric inflation on `IF NOT EXISTS` and missing initialization --- .../NamedCollectionsFactory.cpp | 4 +- .../InterpreterCreateNamedCollectionQuery.cpp | 1 - .../config/named_collections.xml | 10 +++ .../test_table_db_num_limit/test.py | 86 ++++++++++++++++++- .../02931_max_num_to_warn.reference | 1 + 5 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 tests/integration/test_table_db_num_limit/config/named_collections.xml diff --git a/src/Common/NamedCollections/NamedCollectionsFactory.cpp b/src/Common/NamedCollections/NamedCollectionsFactory.cpp index f80019536d02..f84482daaa26 100644 --- a/src/Common/NamedCollections/NamedCollectionsFactory.cpp +++ b/src/Common/NamedCollections/NamedCollectionsFactory.cpp @@ -127,6 +127,7 @@ void NamedCollectionFactory::add( "A named collection `{}` already exists", collection_name); } + CurrentMetrics::set(CurrentMetrics::NamedCollection, loaded_named_collections.size()); } void NamedCollectionFactory::add(NamedCollectionsMap collections, std::lock_guard & lock) @@ -164,6 +165,7 @@ bool NamedCollectionFactory::removeIfExists( collection_name); } loaded_named_collections.erase(collection_name); + CurrentMetrics::set(CurrentMetrics::NamedCollection, loaded_named_collections.size()); return true; } @@ -172,6 +174,7 @@ void NamedCollectionFactory::removeById(NamedCollection::SourceId id, std::lock_ std::erase_if( loaded_named_collections, [&](const auto & value) { return value.second->getSourceId() == id; }); + CurrentMetrics::set(CurrentMetrics::NamedCollection, loaded_named_collections.size()); } namespace @@ -322,7 +325,6 @@ void NamedCollectionFactory::removeFromSQL(const ASTDropNamedCollectionQuery & q metadata_storage->remove(query.collection_name); remove(query.collection_name, lock); - CurrentMetrics::sub(CurrentMetrics::NamedCollection); } void NamedCollectionFactory::updateFromSQL(const ASTAlterNamedCollectionQuery & query) diff --git a/src/Interpreters/InterpreterCreateNamedCollectionQuery.cpp b/src/Interpreters/InterpreterCreateNamedCollectionQuery.cpp index 83dee9563a6c..27cb2bee9f15 100644 --- a/src/Interpreters/InterpreterCreateNamedCollectionQuery.cpp +++ b/src/Interpreters/InterpreterCreateNamedCollectionQuery.cpp @@ -50,7 +50,6 @@ BlockIO InterpreterCreateNamedCollectionQuery::execute() } NamedCollectionFactory::instance().createFromSQL(query); - CurrentMetrics::add(CurrentMetrics::NamedCollection); return {}; } diff --git a/tests/integration/test_table_db_num_limit/config/named_collections.xml b/tests/integration/test_table_db_num_limit/config/named_collections.xml new file mode 100644 index 000000000000..2477693f5fe7 --- /dev/null +++ b/tests/integration/test_table_db_num_limit/config/named_collections.xml @@ -0,0 +1,10 @@ + + + + value1 + + + value2 + + + diff --git a/tests/integration/test_table_db_num_limit/test.py b/tests/integration/test_table_db_num_limit/test.py index a037a1eedfa3..3d9d9b4bbb96 100644 --- a/tests/integration/test_table_db_num_limit/test.py +++ b/tests/integration/test_table_db_num_limit/test.py @@ -16,7 +16,7 @@ "node2", with_zookeeper=True, macros={"replica": "r2"}, - main_configs=["config/config.xml", "config/config2.xml"], + main_configs=["config/config.xml", "config/config2.xml", "config/named_collections.xml"], ) @@ -285,3 +285,87 @@ def _get_number_of_collections(): finally: for i in range(throw_limit + 1): node.query(f"DROP NAMED COLLECTION IF EXISTS nc_{i}") + + +def test_named_collection_if_not_exists_metric(started_cluster): + """ + CREATE NAMED COLLECTION IF NOT EXISTS must not inflate the NamedCollection + metric when the collection already exists. + DROP NAMED COLLECTION IF EXISTS on a nonexistent collection must not + deflate the metric either. + https://github.com/ClickHouse/ClickHouse/issues/102507 + """ + + def _get_number_of_collections(): + return int(node.query("SELECT value FROM system.metrics WHERE name = 'NamedCollection'")) + + try: + node.query("DROP NAMED COLLECTION IF EXISTS nc_ine_test") + before = _get_number_of_collections() + + node.query("CREATE NAMED COLLECTION nc_ine_test AS key = 1") + assert _get_number_of_collections() == before + 1 + + # IF NOT EXISTS on an already-existing collection must not change the metric + node.query("CREATE NAMED COLLECTION IF NOT EXISTS nc_ine_test AS key = 2") + assert _get_number_of_collections() == before + 1 + + node.query("CREATE NAMED COLLECTION IF NOT EXISTS nc_ine_test AS key = 3") + assert _get_number_of_collections() == before + 1 + + node.query("DROP NAMED COLLECTION nc_ine_test") + assert _get_number_of_collections() == before + + # DROP IF EXISTS on an already-dropped collection must not change the metric + node.query("DROP NAMED COLLECTION IF EXISTS nc_ine_test") + assert _get_number_of_collections() == before + + node.query("DROP NAMED COLLECTION IF EXISTS nc_ine_test") + assert _get_number_of_collections() == before + + finally: + node.query("DROP NAMED COLLECTION IF EXISTS nc_ine_test") + + +def test_named_collection_metric_on_startup(started_cluster): + """ + Collections loaded from config on startup must be reflected in the + NamedCollection metric. node2 starts with 2 config-defined collections + (from_config_1, from_config_2). + https://github.com/ClickHouse/ClickHouse/issues/102507 + """ + + def _get_metric(n): + return int(n.query("SELECT value FROM system.metrics WHERE name = 'NamedCollection'")) + + metric = _get_metric(node2) + assert metric >= 2, ( + f"Expected NamedCollection metric >= 2 (from_config_1 + from_config_2), got {metric}" + ) + + +def test_named_collection_metric_after_config_reload(started_cluster): + """ + SYSTEM RELOAD CONFIG must not break the NamedCollection metric for + SQL-created collections. + https://github.com/ClickHouse/ClickHouse/issues/102507 + """ + + def _get_metric(n): + return int(n.query("SELECT value FROM system.metrics WHERE name = 'NamedCollection'")) + + try: + node2.query("DROP NAMED COLLECTION IF EXISTS nc_reload_test") + before = _get_metric(node2) + + node2.query("CREATE NAMED COLLECTION nc_reload_test AS key = 1") + assert _get_metric(node2) == before + 1 + + node2.query("SYSTEM RELOAD CONFIG") + assert _get_metric(node2) == before + 1 + + node2.query("DROP NAMED COLLECTION nc_reload_test") + assert _get_metric(node2) == before + + finally: + node2.query("DROP NAMED COLLECTION IF EXISTS nc_reload_test") diff --git a/tests/queries/0_stateless/02931_max_num_to_warn.reference b/tests/queries/0_stateless/02931_max_num_to_warn.reference index 2b363fb177b9..585e15a84106 100644 --- a/tests/queries/0_stateless/02931_max_num_to_warn.reference +++ b/tests/queries/0_stateless/02931_max_num_to_warn.reference @@ -3,3 +3,4 @@ The number of attached databases _ exceeds the warning limit of 2. The number of The number of attached dictionaries _ exceeds the warning limit of 5. The number of attached dictionaries ({}) exceeds the warning limit of {}. The number of attached tables _ exceeds the warning limit of 5. The number of attached tables ({}) exceeds the warning limit of {}. The number of attached views _ exceeds the warning limit of 5. The number of attached views ({}) exceeds the warning limit of {}. +The number of named collections _ exceeds the warning limit of 5. The number of named collections ({}) exceeds the warning limit of {}. From 9fe43ba9d6b86b0a831717bd951888274c6a919b Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 15 Apr 2026 10:42:23 +0000 Subject: [PATCH 08/70] Backport #102648 to 26.3: Fix NOT_FOUND_COLUMN_IN_BLOCK with row policies in SourceStepWithFilter --- .../QueryPlan/SourceStepWithFilter.cpp | 5 +- ...04099_source_step_with_filter_rp.reference | 2 + .../04099_source_step_with_filter_rp.sql | 59 +++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 tests/queries/0_stateless/04099_source_step_with_filter_rp.reference create mode 100644 tests/queries/0_stateless/04099_source_step_with_filter_rp.sql diff --git a/src/Processors/QueryPlan/SourceStepWithFilter.cpp b/src/Processors/QueryPlan/SourceStepWithFilter.cpp index 47c086bc1b53..cbdcdfed2b46 100644 --- a/src/Processors/QueryPlan/SourceStepWithFilter.cpp +++ b/src/Processors/QueryPlan/SourceStepWithFilter.cpp @@ -93,7 +93,10 @@ void SourceStepWithFilter::applyFilters(ActionDAGNodes added_filter_nodes) void SourceStepWithFilter::updatePrewhereInfo(const PrewhereInfoPtr & prewhere_info_value) { query_info.prewhere_info = prewhere_info_value; - output_header = std::make_shared(applyPrewhereActions(*output_header, query_info.row_level_filter, query_info.prewhere_info)); + output_header = std::make_shared(applyPrewhereActions( + storage_snapshot->getSampleBlockForColumns(required_source_columns), + query_info.row_level_filter, + query_info.prewhere_info)); } void SourceStepWithFilter::describeActions(FormatSettings & format_settings) const diff --git a/tests/queries/0_stateless/04099_source_step_with_filter_rp.reference b/tests/queries/0_stateless/04099_source_step_with_filter_rp.reference new file mode 100644 index 000000000000..20f0bc3b63f3 --- /dev/null +++ b/tests/queries/0_stateless/04099_source_step_with_filter_rp.reference @@ -0,0 +1,2 @@ +2020-01-01 BTC 100 src1 +2020-01-01 ETH 200 src2 diff --git a/tests/queries/0_stateless/04099_source_step_with_filter_rp.sql b/tests/queries/0_stateless/04099_source_step_with_filter_rp.sql new file mode 100644 index 000000000000..e568221913fb --- /dev/null +++ b/tests/queries/0_stateless/04099_source_step_with_filter_rp.sql @@ -0,0 +1,59 @@ +-- NOT_FOUND_COLUMN_IN_BLOCK when querying a view over a table with a row policy +-- where the view does not select the row policy column and optimize_move_to_prewhere is enabled +-- +-- The bug was in SourceStepWithFilter::updatePrewhereInfo which re-applied +-- row_level_filter on the already-transformed output_header instead of rebuilding it + +DROP TABLE IF EXISTS t_rp; +DROP TABLE IF EXISTS ref_rp; +DROP VIEW IF EXISTS v_rp; + +CREATE TABLE t_rp +( + timestamp DateTime64(9), + asset_id Int64, + price Float64, + source String, + is_valid Bool DEFAULT true, + inserted_at DateTime64(9) +) +ENGINE = ReplacingMergeTree(inserted_at) +ORDER BY (asset_id, timestamp); + +CREATE TABLE ref_rp (id Int64, name String) ENGINE = MergeTree ORDER BY id; + +INSERT INTO ref_rp VALUES (1, 'BTC'), (2, 'ETH'), (3, 'SOL'); +INSERT INTO t_rp VALUES + ('2020-01-01', 1, 100.0, 'src1', true, '2020-01-01'), + ('2020-01-01', 2, 200.0, 'src2', true, '2020-01-01'), + ('2020-01-01', 3, 0.0, 'src3', false, '2020-01-01'); + +CREATE ROW POLICY rp_100003 ON t_rp FOR SELECT USING is_valid = true TO ALL; + +CREATE VIEW v_rp AS +SELECT + toDate(timestamp) AS date, + ref_rp.name AS asset_name, + asset_id, + argMax(price, p.inserted_at) AS price, + argMax(source, p.inserted_at) AS source +FROM t_rp AS p +INNER JOIN ref_rp ON ref_rp.id = p.asset_id +GROUP BY date, asset_id, asset_name; + +SELECT date, asset_name, price, source +FROM v_rp +WHERE date = '2020-01-01' AND price > 0 +ORDER BY asset_name +SETTINGS + optimize_move_to_prewhere = 1, + allow_experimental_parallel_reading_from_replicas = 2, + max_parallel_replicas = 3, + cluster_for_parallel_replicas = 'parallel_replicas', + parallel_replicas_min_number_of_rows_per_replica = 1, + parallel_replicas_for_non_replicated_merge_tree = 1; + +DROP VIEW v_rp; +DROP ROW POLICY rp_100003 ON t_rp; +DROP TABLE ref_rp; +DROP TABLE t_rp; From 40113afe6c3284621dae39a619fbf9d6a5ad2c17 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 15 Apr 2026 12:38:01 +0000 Subject: [PATCH 09/70] Backport #99539 to 26.3: Fix segfault in UBSan build when calling JIT-compiled sort description --- src/Core/SortCursor.h | 8 ++++++-- src/Interpreters/JIT/compileFunction.h | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Core/SortCursor.h b/src/Core/SortCursor.h index 4c1a7e99d89f..248037af11ac 100644 --- a/src/Core/SortCursor.h +++ b/src/Core/SortCursor.h @@ -184,7 +184,11 @@ struct SortCursor : SortCursorHelper assert(impl->raw_sort_columns_data.size() == rhs.impl->raw_sort_columns_data.size()); auto sort_description_func_typed = reinterpret_cast(impl->desc.compiled_sort_description); - int res = sort_description_func_typed(lhs_pos, rhs_pos, impl->raw_sort_columns_data.data(), rhs.impl->raw_sort_columns_data.data()); /// NOLINT + /// JIT-compiled functions lack the type metadata prologue that UBSan's + /// -fsanitize=function expects before every indirect call. When the JIT + /// code sits at a page boundary the pre-call read hits unmapped memory. + /// NOLINTNEXTLINE(bugprone-signed-char-misuse,cert-str34-c) -- JIT comparator returns -1/0/1, sign is meaningful + int res = callJITFunction(sort_description_func_typed, lhs_pos, rhs_pos, impl->raw_sort_columns_data.data(), rhs.impl->raw_sort_columns_data.data()); if (res > 0) return true; @@ -235,7 +239,7 @@ struct SimpleSortCursor : SortCursorHelper assert(impl->raw_sort_columns_data.size() == rhs.impl->raw_sort_columns_data.size()); auto sort_description_func_typed = reinterpret_cast(impl->desc.compiled_sort_description); - res = sort_description_func_typed(lhs_pos, rhs_pos, impl->raw_sort_columns_data.data(), rhs.impl->raw_sort_columns_data.data()); /// NOLINT + res = callJITFunction(sort_description_func_typed, lhs_pos, rhs_pos, impl->raw_sort_columns_data.data(), rhs.impl->raw_sort_columns_data.data()); // NOLINT(bugprone-signed-char-misuse,cert-str34-c) } else #endif diff --git a/src/Interpreters/JIT/compileFunction.h b/src/Interpreters/JIT/compileFunction.h index 1bdd9c34f8c0..6f815b1117d3 100644 --- a/src/Interpreters/JIT/compileFunction.h +++ b/src/Interpreters/JIT/compileFunction.h @@ -40,9 +40,9 @@ using JITCompiledFunction = void (*)(ColumnDataRowsSize, ColumnData *); * the read accesses unmapped memory, causing a SIGSEGV. */ template -NO_SANITIZE_UNDEFINED inline void callJITFunction(F && f, Args &&... args) +NO_SANITIZE_UNDEFINED inline decltype(auto) callJITFunction(F && f, Args &&... args) { - f(std::forward(args)...); + return f(std::forward(args)...); } struct CompiledFunction From 3482ae135ba14f5bdde7d9f8a732451c344f8eb0 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 15 Apr 2026 16:37:18 +0000 Subject: [PATCH 10/70] Backport #102607 to 26.3: Use `xz` 5.8.3 --- .gitmodules | 2 +- contrib/xz | 2 +- contrib/xz-cmake/CMakeLists.txt | 19 ++++++++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.gitmodules b/.gitmodules index 5b215faf314b..087ee2fe699c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -142,7 +142,7 @@ url = https://github.com/ClickHouse/rocksdb [submodule "contrib/xz"] path = contrib/xz - url = https://github.com/xz-mirror/xz + url = https://github.com/tukaani-project/xz [submodule "contrib/abseil-cpp"] path = contrib/abseil-cpp url = https://github.com/ClickHouse/abseil-cpp.git diff --git a/contrib/xz b/contrib/xz index 869b9d1b4edd..4b73f2ec19a9 160000 --- a/contrib/xz +++ b/contrib/xz @@ -1 +1 @@ -Subproject commit 869b9d1b4edd6df07f819d360d306251f8147353 +Subproject commit 4b73f2ec19a99ef465282fbce633e8deb33691b3 diff --git a/contrib/xz-cmake/CMakeLists.txt b/contrib/xz-cmake/CMakeLists.txt index c73433d9863c..0848fc753a10 100644 --- a/contrib/xz-cmake/CMakeLists.txt +++ b/contrib/xz-cmake/CMakeLists.txt @@ -30,22 +30,26 @@ add_compile_definitions( HAVE_CHECK_SHA256 HAVE_DECODERS HAVE_DECODER_ARM + HAVE_DECODER_ARM64 HAVE_DECODER_ARMTHUMB HAVE_DECODER_DELTA HAVE_DECODER_IA64 HAVE_DECODER_LZMA1 HAVE_DECODER_LZMA2 HAVE_DECODER_POWERPC + HAVE_DECODER_RISCV HAVE_DECODER_SPARC HAVE_DECODER_X86 HAVE_ENCODERS HAVE_ENCODER_ARM + HAVE_ENCODER_ARM64 HAVE_ENCODER_ARMTHUMB HAVE_ENCODER_DELTA HAVE_ENCODER_IA64 HAVE_ENCODER_LZMA1 HAVE_ENCODER_LZMA2 HAVE_ENCODER_POWERPC + HAVE_ENCODER_RISCV HAVE_ENCODER_SPARC HAVE_ENCODER_X86 HAVE_MF_BT2 @@ -126,15 +130,16 @@ add_library(_liblzma ${SRC_DIR}/src/liblzma/api/lzma/vli.h ${SRC_DIR}/src/liblzma/check/check.c ${SRC_DIR}/src/liblzma/check/check.h + ${SRC_DIR}/src/liblzma/check/crc32_arm64.h ${SRC_DIR}/src/liblzma/check/crc32_fast.c - ${SRC_DIR}/src/liblzma/check/crc32_table.c + ${SRC_DIR}/src/liblzma/check/crc32_loongarch.h ${SRC_DIR}/src/liblzma/check/crc32_table_be.h ${SRC_DIR}/src/liblzma/check/crc32_table_le.h ${SRC_DIR}/src/liblzma/check/crc64_fast.c - ${SRC_DIR}/src/liblzma/check/crc64_table.c ${SRC_DIR}/src/liblzma/check/crc64_table_be.h ${SRC_DIR}/src/liblzma/check/crc64_table_le.h - ${SRC_DIR}/src/liblzma/check/crc_macros.h + ${SRC_DIR}/src/liblzma/check/crc_common.h + ${SRC_DIR}/src/liblzma/check/crc_x86_clmul.h ${SRC_DIR}/src/liblzma/check/sha256.c ${SRC_DIR}/src/liblzma/common/alone_decoder.c ${SRC_DIR}/src/liblzma/common/alone_decoder.h @@ -178,19 +183,25 @@ add_library(_liblzma ${SRC_DIR}/src/liblzma/common/index_encoder.c ${SRC_DIR}/src/liblzma/common/index_encoder.h ${SRC_DIR}/src/liblzma/common/index_hash.c + ${SRC_DIR}/src/liblzma/common/lzip_decoder.c + ${SRC_DIR}/src/liblzma/common/lzip_decoder.h ${SRC_DIR}/src/liblzma/common/memcmplen.h + ${SRC_DIR}/src/liblzma/common/microlzma_decoder.c + ${SRC_DIR}/src/liblzma/common/microlzma_encoder.c ${SRC_DIR}/src/liblzma/common/outqueue.c ${SRC_DIR}/src/liblzma/common/outqueue.h ${SRC_DIR}/src/liblzma/common/stream_buffer_decoder.c ${SRC_DIR}/src/liblzma/common/stream_buffer_encoder.c ${SRC_DIR}/src/liblzma/common/stream_decoder.c ${SRC_DIR}/src/liblzma/common/stream_decoder.h + ${SRC_DIR}/src/liblzma/common/stream_decoder_mt.c ${SRC_DIR}/src/liblzma/common/stream_encoder.c ${SRC_DIR}/src/liblzma/common/stream_encoder_mt.c ${SRC_DIR}/src/liblzma/common/stream_flags_common.c ${SRC_DIR}/src/liblzma/common/stream_flags_common.h ${SRC_DIR}/src/liblzma/common/stream_flags_decoder.c ${SRC_DIR}/src/liblzma/common/stream_flags_encoder.c + ${SRC_DIR}/src/liblzma/common/string_conversion.c ${SRC_DIR}/src/liblzma/common/vli_decoder.c ${SRC_DIR}/src/liblzma/common/vli_encoder.c ${SRC_DIR}/src/liblzma/common/vli_size.c @@ -229,9 +240,11 @@ add_library(_liblzma ${SRC_DIR}/src/liblzma/rangecoder/range_decoder.h ${SRC_DIR}/src/liblzma/rangecoder/range_encoder.h ${SRC_DIR}/src/liblzma/simple/arm.c + ${SRC_DIR}/src/liblzma/simple/arm64.c ${SRC_DIR}/src/liblzma/simple/armthumb.c ${SRC_DIR}/src/liblzma/simple/ia64.c ${SRC_DIR}/src/liblzma/simple/powerpc.c + ${SRC_DIR}/src/liblzma/simple/riscv.c ${SRC_DIR}/src/liblzma/simple/simple_coder.c ${SRC_DIR}/src/liblzma/simple/simple_coder.h ${SRC_DIR}/src/liblzma/simple/simple_decoder.c From 143cf922ee1bb2bbcd96a95202a1468e0e658b98 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 15 Apr 2026 17:36:39 +0000 Subject: [PATCH 11/70] Backport #102385 to 26.3: Fix Parquet bloom filter segfault in prefetch range coalescing --- .../Formats/Impl/Parquet/Prefetcher.cpp | 6 ++ ..._bloom_filter_overlapping_ranges.reference | 1 + ...parquet_bloom_filter_overlapping_ranges.sh | 96 +++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 tests/queries/0_stateless/04097_parquet_bloom_filter_overlapping_ranges.reference create mode 100755 tests/queries/0_stateless/04097_parquet_bloom_filter_overlapping_ranges.sh diff --git a/src/Processors/Formats/Impl/Parquet/Prefetcher.cpp b/src/Processors/Formats/Impl/Parquet/Prefetcher.cpp index 9f5a998529da..d8b4f226614d 100644 --- a/src/Processors/Formats/Impl/Parquet/Prefetcher.cpp +++ b/src/Processors/Formats/Impl/Parquet/Prefetcher.cpp @@ -323,6 +323,10 @@ void Prefetcher::pickRangesAndCreateTaskIfNotExists(RequestState * initial_req, start_idx = idx - 1; total_length_of_covered_ranges += r.length(); start_offset = std::min(start_offset, r.start); + /// A range found to the left may extend past the current end (e.g. when ranges + /// share the same start offset but have different lengths, and the sort placed + /// the longer range first). We must extend end_offset to cover it. + end_offset = std::max(end_offset, r.end); } else if (s != RequestState::State::Cancelled) { @@ -353,6 +357,8 @@ void Prefetcher::pickRangesAndCreateTaskIfNotExists(RequestState * initial_req, end_idx = idx + 1; total_length_of_covered_ranges += r.length(); end_offset = std::max(end_offset, r.end); + /// (This currently doesn't do anything because ranges are sorted by `start`, but why not.) + start_offset = std::min(start_offset, r.start); } else if (s != RequestState::State::Cancelled) { diff --git a/tests/queries/0_stateless/04097_parquet_bloom_filter_overlapping_ranges.reference b/tests/queries/0_stateless/04097_parquet_bloom_filter_overlapping_ranges.reference new file mode 100644 index 000000000000..d86bac9de59a --- /dev/null +++ b/tests/queries/0_stateless/04097_parquet_bloom_filter_overlapping_ranges.reference @@ -0,0 +1 @@ +OK diff --git a/tests/queries/0_stateless/04097_parquet_bloom_filter_overlapping_ranges.sh b/tests/queries/0_stateless/04097_parquet_bloom_filter_overlapping_ranges.sh new file mode 100755 index 000000000000..66a91fdd0659 --- /dev/null +++ b/tests/queries/0_stateless/04097_parquet_bloom_filter_overlapping_ranges.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +# Tags: no-fasttest + +# Regression test for a segfault/assertion failure in Parquet bloom filter +# prefetch range coalescing. When two overlapping prefetch ranges (bloom filter +# header and bloom filter data) share the same start offset and happen to be +# sorted with the larger range before the smaller one, the leftward coalescing +# scan included the larger range but did not extend end_offset. The created task +# was too small, causing out-of-bounds access in findAnyHash/getRangeData. +# https://github.com/ClickHouse/ClickHouse/issues/102257 + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +USER_FILES_PATH=$($CLICKHOUSE_CLIENT_BINARY --query "select _path,_file from file('nonexist.txt', 'CSV', 'val1 char')" 2>&1 | grep Exception | awk '{gsub("/nonexist.txt","",$9); print $9}') +WORKING_DIR="${USER_FILES_PATH}/${CLICKHOUSE_TEST_UNIQUE_NAME}" +mkdir -p "${WORKING_DIR}" +FILE_PATH="${WORKING_DIR}/test.parquet" + +# Create a parquet file with Nullable(String) columns containing a mix of +# empty strings, NULLs, and number strings. The bloom filter for col1 will +# have a small number of blocks (the key ingredient for the bug). +${CLICKHOUSE_CLIENT} --query " + INSERT INTO FUNCTION file('${FILE_PATH}', 'Parquet') + SELECT + multiIf( + cityHash64(number) % 113, ''::Nullable(String), + cityHash64(number) % 5, NULL::Nullable(String), + toString(number) + ) AS col1, + toString(number)::Nullable(String) AS col2, + toString(number)::Nullable(String) AS col3, + toString(number)::Nullable(String) AS col4, + toString(number)::Nullable(String) AS col5, + NULL::Nullable(String) AS col23 + FROM numbers(500000) +" + +# Reference result without bloom filter +EXPECTED=$(${CLICKHOUSE_CLIENT} --query " + SELECT count() + FROM file('${FILE_PATH}', Parquet, + 'col1 String, col2 String, col3 String, col4 String, col5 String') + WHERE col1 = '' AND col2 != '' + SETTINGS input_format_parquet_bloom_filter_push_down = 0 +") + +# Run with bloom filter multiple times. Before the fix, this would either +# crash (segfault / LOGICAL_ERROR assertion) or return inconsistent results. +for _ in $(seq 1 5); do + RESULT=$(${CLICKHOUSE_CLIENT} --query " + SET max_threads = 1; + SELECT count() + FROM file('${FILE_PATH}', Parquet, + 'col1 String, col2 String, col3 String, col4 String, col5 String') + WHERE col1 = '' AND col2 != '' + ") + if [ "$RESULT" != "$EXPECTED" ]; then + echo "MISMATCH: got $RESULT, expected $EXPECTED" + rm -rf "${WORKING_DIR}" + exit 1 + fi +done + +# Also test den-crane's simpler reproducer (https://github.com/ClickHouse/ClickHouse/issues/102231) +FILE_PATH2="${WORKING_DIR}/bloom_simple.parquet" +${CLICKHOUSE_CLIENT} --query " + INSERT INTO FUNCTION file('${FILE_PATH2}', 'Parquet') + SELECT + IF(number % 113 = 0, toString(number), '') AS col1, + toString(number) AS col2 + FROM numbers(50000) +" + +BLOOM_ON=$(${CLICKHOUSE_CLIENT} --query " + SELECT count() + FROM file('${FILE_PATH2}', Parquet, 'col1 String, col2 String') + WHERE col1 = '' + SETTINGS input_format_parquet_bloom_filter_push_down = 1 +") +BLOOM_OFF=$(${CLICKHOUSE_CLIENT} --query " + SELECT count() + FROM file('${FILE_PATH2}', Parquet, 'col1 String, col2 String') + WHERE col1 = '' + SETTINGS input_format_parquet_bloom_filter_push_down = 0 +") +if [ "$BLOOM_ON" != "$BLOOM_OFF" ]; then + echo "SIMPLE MISMATCH: bloom_on=$BLOOM_ON bloom_off=$BLOOM_OFF" + rm -rf "${WORKING_DIR}" + exit 1 +fi + +echo "OK" + +rm -rf "${WORKING_DIR}" From c02a7785f2f2e1774b6509e5a39c6b28420e7285 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 15 Apr 2026 18:40:47 +0000 Subject: [PATCH 12/70] Backport #102610 to 26.3: Fix `LOGICAL_ERROR` in `S3Queue` concurrent `CREATE TABLE IF NOT EXISTS` --- src/Storages/StreamingStorageRegistry.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Storages/StreamingStorageRegistry.cpp b/src/Storages/StreamingStorageRegistry.cpp index f377c1249565..4ca0fb86e98c 100644 --- a/src/Storages/StreamingStorageRegistry.cpp +++ b/src/Storages/StreamingStorageRegistry.cpp @@ -29,6 +29,7 @@ namespace ErrorCodes { extern const int BAD_ARGUMENTS; extern const int LOGICAL_ERROR; + extern const int TABLE_ALREADY_EXISTS; } StreamingStorageRegistry & StreamingStorageRegistry::instance() @@ -46,7 +47,7 @@ void StreamingStorageRegistry::registerTable(const StorageID & storage) const bool inserted = storages.emplace(storage).second; if (!inserted) - throw Exception(ErrorCodes::LOGICAL_ERROR, "Table with storage id {} already registered", storage.getNameForLogs()); + throw Exception(ErrorCodes::TABLE_ALREADY_EXISTS, "Table with storage id {} already registered", storage.getNameForLogs()); LOG_TRACE(log, "Registered table: {}", storage.getNameForLogs()); } From 65a254ee5d563133a1c3e94ccdf4f5945de73b7b Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Thu, 16 Apr 2026 08:49:08 +0000 Subject: [PATCH 13/70] Backport #102759 to 26.3: Apply Poisson sampling correction to collapsed jemalloc heap profiles --- .../Sources/JemallocProfileSource.cpp | 124 ++++++++-- .../Sources/JemallocProfileSource.h | 6 + .../tests/gtest_jemalloc_profile_source.cpp | 218 ++++++++++++++++++ 3 files changed, 327 insertions(+), 21 deletions(-) create mode 100644 src/Processors/tests/gtest_jemalloc_profile_source.cpp diff --git a/src/Processors/Sources/JemallocProfileSource.cpp b/src/Processors/Sources/JemallocProfileSource.cpp index f14c1a4f27c5..bea13a159bb0 100644 --- a/src/Processors/Sources/JemallocProfileSource.cpp +++ b/src/Processors/Sources/JemallocProfileSource.cpp @@ -2,6 +2,8 @@ #if USE_JEMALLOC +# include +# include # include # include # include @@ -90,6 +92,56 @@ std::vector parseStackAddresses(std::string_view line) return result; } +/// Parse the sampling interval from a jemalloc heap_v2 header line ("heap_v2/N"). +/// Returns 0 if the header doesn't match heap_v2 format or the value is not a valid integer. +UInt64 parseSamplingInterval(std::string_view header) +{ + static constexpr std::string_view prefix = "heap_v2/"; + if (!header.starts_with(prefix)) + return 0; + header.remove_prefix(prefix.size()); + trim(header); + if (header.empty()) + return 0; + UInt64 result = 0; + ReadBufferFromMemory buf(header.data(), header.size()); + if (!tryReadIntText(result, buf) || !buf.eof()) + return 0; + return result; +} + +/// Apply Poisson sampling correction as jeprof does for heap_v2 profiles. +/// Each allocation is sampled with probability 1-exp(-size/interval), so the correction +/// factor is 1/(1-exp(-mean_size/interval)). +/// Uses std::expm1 to avoid catastrophic cancellation for small ratios where +/// 1-exp(-x) loses precision, and guards against non-finite results to prevent +/// undefined behavior in std::llround. +/// Returns the scaled metric value. +UInt64 applySamplingCorrection(UInt64 count, UInt64 bytes, UInt64 sampling_interval, bool use_count) +{ + if (sampling_interval == 0 || count == 0) + return use_count ? count : bytes; + + if (bytes == 0) + return use_count ? count : 0; + + double mean_size = static_cast(bytes) / static_cast(count); + double ratio = mean_size / static_cast(sampling_interval); + double denom = -std::expm1(-ratio); /// accurate even for tiny ratio + + if (denom <= 0.0) /// defensive: shouldn't happen after expm1, but clamp + return use_count ? count : bytes; + + double scale = 1.0 / denom; + double metric = use_count ? static_cast(count) : static_cast(bytes); + double corrected = metric * scale; + + if (!std::isfinite(corrected) || corrected < 0.0 || corrected > static_cast(std::numeric_limits::max())) + return use_count ? count : bytes; + + return static_cast(std::llround(corrected)); +} + /// Simple LRU cache: evicts the least-recently-used entry when the capacity is exceeded. /// Key includes both the address and the symbolize_with_inline flag so that queries /// with different inline settings don't silently reuse each other's results. @@ -430,6 +482,7 @@ Chunk JemallocProfileSource::generateCollapsed() ReadBufferFromFile in(filename); std::string line; std::vector current_stack; + UInt64 sampling_interval = 0; while (!in.eof()) { @@ -446,6 +499,13 @@ Chunk JemallocProfileSource::generateCollapsed() if (line.empty()) continue; + /// Parse sampling interval from heap_v2/N header (first non-empty line) + if (sampling_interval == 0 && line.starts_with("heap_v2/")) + { + sampling_interval = parseSamplingInterval(line); + continue; + } + if (line[0] == '@') { current_stack = parseStackAddresses(line); @@ -460,30 +520,28 @@ Chunk JemallocProfileSource::generateCollapsed() /// /// The record has the form `: : [: ]`, /// where the bracketed pair holds the cumulative (total) counts since profiling started. - /// We extract either (between the 2nd and 3rd colon) or - /// (between the 1st and 2nd colon) depending on the `collapsed_use_count` setting. + /// We extract both and to apply Poisson sampling correction, + /// then report the requested metric (bytes or count). size_t first_colon = line.find(':'); size_t second_colon = line.find(':', first_colon + 1); if (second_colon != std::string::npos) { - std::string_view metric_str; - if (collapsed_use_count) - { - /// : between 1st and 2nd colon - metric_str = std::string_view(line.data() + first_colon + 1, second_colon - first_colon - 1); - } - else - { - /// : between 2nd colon and opening bracket (or end of line) - size_t bracket_pos = line.find('[', second_colon); - size_t end_pos = (bracket_pos != std::string::npos) ? bracket_pos : line.size(); - metric_str = std::string_view(line.data() + second_colon + 1, end_pos - second_colon - 1); - } - trim(metric_str); + /// : between 1st and 2nd colon + std::string_view count_str(line.data() + first_colon + 1, second_colon - first_colon - 1); + trim(count_str); + UInt64 live_count = parseInt(count_str); - UInt64 metric = parseInt(metric_str); + /// : between 2nd colon and opening bracket (or end of line) + size_t bracket_pos = line.find('[', second_colon); + size_t end_pos = (bracket_pos != std::string::npos) ? bracket_pos : line.size(); + std::string_view bytes_str(line.data() + second_colon + 1, end_pos - second_colon - 1); + trim(bytes_str); + UInt64 live_bytes = parseInt(bytes_str); + + /// Apply Poisson sampling correction (same algorithm as jeprof's AdjustSamples). + UInt64 metric = applySamplingCorrection(live_count, live_bytes, sampling_interval, collapsed_use_count); if (metric > 0) { @@ -555,11 +613,14 @@ Chunk JemallocProfileSource::generateCollapsed() return Chunk(std::move(columns), num_rows); } -void symbolizeJemallocHeapProfile( +namespace +{ + +void pullProfileLines( const std::string & input_filename, - const std::string & output_filename, JemallocProfileFormat format, - bool symbolize_with_inline) + bool symbolize_with_inline, + WriteBuffer & out) { Block header; header.insert({ColumnString::create(), std::make_shared(), "line"}); @@ -572,7 +633,6 @@ void symbolizeJemallocHeapProfile( QueryPipeline pipeline(std::move(source)); PullingPipelineExecutor executor(pipeline); - WriteBufferFromFile out(output_filename); Block block; while (executor.pull(block)) { @@ -584,9 +644,31 @@ void symbolizeJemallocHeapProfile( writeChar('\n', out); } } +} + +} + +void symbolizeJemallocHeapProfile( + const std::string & input_filename, + const std::string & output_filename, + JemallocProfileFormat format, + bool symbolize_with_inline) +{ + WriteBufferFromFile out(output_filename); + pullProfileLines(input_filename, format, symbolize_with_inline, out); out.finalize(); } +std::string symbolizeJemallocHeapProfileToString( + const std::string & input_filename, + JemallocProfileFormat format, + bool symbolize_with_inline) +{ + WriteBufferFromOwnString out; + pullProfileLines(input_filename, format, symbolize_with_inline, out); + return std::move(out.str()); +} + } #endif diff --git a/src/Processors/Sources/JemallocProfileSource.h b/src/Processors/Sources/JemallocProfileSource.h index 971ff50c3e11..24e3ce54adda 100644 --- a/src/Processors/Sources/JemallocProfileSource.h +++ b/src/Processors/Sources/JemallocProfileSource.h @@ -98,6 +98,12 @@ void symbolizeJemallocHeapProfile( JemallocProfileFormat format = JemallocProfileFormat::Symbolized, bool symbolize_with_inline = true); +/// Like symbolizeJemallocHeapProfile but returns the result as a string. +std::string symbolizeJemallocHeapProfileToString( + const std::string & input_filename, + JemallocProfileFormat format = JemallocProfileFormat::Symbolized, + bool symbolize_with_inline = true); + } #endif diff --git a/src/Processors/tests/gtest_jemalloc_profile_source.cpp b/src/Processors/tests/gtest_jemalloc_profile_source.cpp new file mode 100644 index 000000000000..f5ede4f17cd6 --- /dev/null +++ b/src/Processors/tests/gtest_jemalloc_profile_source.cpp @@ -0,0 +1,218 @@ +#include "config.h" + +#if USE_JEMALLOC + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace DB; + +namespace +{ + +/// Subset of a real jemalloc heap_v2 profile with sampling interval 524288. +/// Contains 7 stacks with varying allocation sizes to exercise the Poisson correction. +constexpr std::string_view test_heap_profile = R"(heap_v2/524288 + t*: 162: 11166737 [0: 0] + t0: 0: 0 [0: 0] +@ 0x1e51c218 0x1e51c118 0x1e50731c 0x1e49c720 0x12e08714 0x191dbd6c 0x17793e14 0x1f4d5b48 0x131ecee0 0x1e449e5c 0x131d4118 0x131d10e8 0xcac9260 0xffff9db37400 0xffff9db374d8 + t*: 1: 5121 [0: 0] + t0: 1: 5121 [0: 0] +@ 0x1e51c218 0x1e51c118 0x1e50731c 0x1e49c720 0x12e08714 0x191dbd6c 0x1979221c 0x197aee08 0x1321bb7c 0x1e4268d8 0x1e426ed4 0x1e3dacfc 0x1e3d8e30 0xffff9db90398 0xffff9dbf9e9c + t*: 25: 128032 [0: 0] + t3127: 25: 128032 [0: 0] +@ 0x1e51c218 0x1e51c118 0x1e50731c 0x1e49c720 0x12e08714 0xb3c8080 0x11c34d60 0x169b0bf4 0x169b4c74 0x169cac24 0x12f7901c 0xffff9db90398 0xffff9dbf9e9c + t*: 1: 128 [0: 0] + t3821: 1: 128 [0: 0] +@ 0x1e51c218 0x1e51c118 0x1e50731c 0x1e49c720 0x12e08914 0x17a7f00c 0x17e5c7fc 0x17e5a53c 0x1321bb7c 0x1e4268d8 0x1e426ed4 0x1e3dacfc 0x1e3d8e30 0xffff9db90398 0xffff9dbf9e9c + t*: 3: 247015 [0: 0] + t2993: 1: 82338 [0: 0] + t3009: 1: 82338 [0: 0] + t3196: 1: 82338 [0: 0] +@ 0x1e51c218 0x1e51c118 0x1e50731c 0x1e49c720 0x12e08914 0x17a7f00c 0x17e5c7fc 0x17e64fb8 0x197bd8d0 0x1321bb7c 0x1e4268d8 0x1e426ed4 0x1e3dacfc 0x1e3d8e30 0xffff9db90398 0xffff9dbf9e9c + t*: 2: 164677 [0: 0] + t3195: 1: 82338 [0: 0] + t3211: 1: 82338 [0: 0] +@ 0x1e51c218 0x1e51c118 0x1e50731c 0x1e49c720 0x12e08714 0x12ed7044 0x12f7af00 0x12f721b4 0x12f7901c 0xffff9db90398 0xffff9dbf9e9c + t*: 129: 10621636 [0: 0] + t588: 1: 82338 [0: 0] + t597: 1: 82338 [0: 0] + t598: 1: 82338 [0: 0] +@ 0x1e51c218 0x1e51c118 0x1e50731c 0x1e49c720 0x12e08714 0x12ed7044 0xaaa0000 0xbbb0000 0xffff9db90398 0xffff9dbf9e9c + t*: 1: 128 [0: 0] + t100: 1: 128 [0: 0] +)"; + +/// Raw t* bytes sum: 11,166,737 +/// Expected Poisson-corrected bytes total (matching jeprof AdjustSamples): 90,662,471 +/// Computed with: scale = 1/(1-exp(-mean_size/524288)) per stack, then sum(bytes * scale). +constexpr UInt64 expected_raw_total = 11166737; +constexpr UInt64 expected_corrected_total = 90662471; + +/// Raw t* count sum: 162 +/// Expected Poisson-corrected count total (matching jeprof AdjustSamples): 11,792 +/// Computed with: scale = 1/(1-exp(-mean_size/524288)) per stack, then sum(count * scale). +constexpr UInt64 expected_raw_count_total = 162; +constexpr UInt64 expected_corrected_count_total = 11792; + +std::string writeToTempFile(std::string_view content, const std::string & name) +{ + auto path = std::filesystem::temp_directory_path() / name; + std::ofstream out(path); + out.write(content.data(), content.size()); + return path.string(); +} + +UInt64 sumCollapsedValues(std::string_view collapsed_output) +{ + UInt64 total = 0; + while (!collapsed_output.empty()) + { + auto nl = collapsed_output.find('\n'); + auto line = collapsed_output.substr(0, nl); + collapsed_output.remove_prefix(nl == std::string_view::npos ? collapsed_output.size() : nl + 1); + + auto last_space = line.rfind(' '); + if (last_space != std::string_view::npos) + total += parseInt(line.substr(last_space + 1)); + } + return total; +} + +/// Run JemallocProfileSource in collapsed mode with the given collapsed_use_count flag +/// and collect the output as a string. +std::string runCollapsedProfile(const std::string & input_filename, bool collapsed_use_count) +{ + Block header; + header.insert({ColumnString::create(), std::make_shared(), "line"}); + auto source = std::make_shared( + input_filename, + std::make_shared(std::move(header)), + DEFAULT_BLOCK_SIZE, + JemallocProfileFormat::Collapsed, + false, /* symbolize_with_inline */ + collapsed_use_count); + + std::string output; + WriteBufferFromString out(output); + QueryPipeline pipeline(std::move(source)); + PullingPipelineExecutor executor(pipeline); + Block block; + while (executor.pull(block)) + { + const auto & column = assert_cast(*block.getByPosition(0).column); + for (size_t i = 0; i < column.size(); ++i) + { + auto sv = column.getDataAt(i); + out.write(sv.data(), sv.size()); + writeChar('\n', out); + } + } + out.finalize(); + return output; +} + +} + +/// Write a real jemalloc heap_v2 profile to disk, process it through +/// symbolizeJemallocHeapProfile in collapsed mode, and verify the total +/// matches the expected Poisson sampling correction. +TEST(JemallocProfileSource, CollapsedSamplingCorrection) +{ + auto input = writeToTempFile(test_heap_profile, "gtest_jemalloc_profile.heap"); + + auto collapsed_output = symbolizeJemallocHeapProfileToString(input, JemallocProfileFormat::Collapsed, false); + + UInt64 total = sumCollapsedValues(collapsed_output); + + /// Allow +-1 per stack for floating-point rounding (7 stacks). + EXPECT_NEAR(static_cast(total), static_cast(expected_corrected_total), 7.0); + EXPECT_GT(total, expected_raw_total); + + std::filesystem::remove(input); +} + +/// Same heap_v2 profile, but verify the Poisson correction for count mode +/// (collapsed_use_count = true). +TEST(JemallocProfileSource, CollapsedSamplingCorrectionCount) +{ + auto input = writeToTempFile(test_heap_profile, "gtest_jemalloc_profile_count.heap"); + + std::string collapsed_output = runCollapsedProfile(input, /* collapsed_use_count= */ true); + + UInt64 total = sumCollapsedValues(collapsed_output); + + /// Allow +-1 per stack for floating-point rounding (7 stacks). + EXPECT_NEAR(static_cast(total), static_cast(expected_corrected_count_total), 7.0); + EXPECT_GT(total, expected_raw_count_total); + + std::filesystem::remove(input); +} + +/// When the profile lacks a heap_v2/ header, sampling correction should be +/// disabled and raw values passed through unchanged. +TEST(JemallocProfileSource, CollapsedNoV2HeaderRawPassthrough) +{ + /// Build a v1-style profile by replacing the first line of the test profile. + std::string profile_no_v2 = "heap\n"; + auto nl = test_heap_profile.find('\n'); + profile_no_v2 += std::string(test_heap_profile.substr(nl + 1)); + + auto input = writeToTempFile(profile_no_v2, "gtest_jemalloc_profile_no_v2.heap"); + + /// Bytes mode — should return raw bytes without Poisson correction. + { + std::string collapsed_output = runCollapsedProfile(input, /* collapsed_use_count= */ false); + UInt64 total = sumCollapsedValues(collapsed_output); + EXPECT_EQ(total, expected_raw_total); + } + + /// Count mode — should return raw counts without Poisson correction. + { + std::string collapsed_output = runCollapsedProfile(input, /* collapsed_use_count= */ true); + UInt64 total = sumCollapsedValues(collapsed_output); + EXPECT_EQ(total, expected_raw_count_total); + } + + std::filesystem::remove(input); +} + +/// When the heap_v2 header has a malformed interval (e.g. "heap_v2/abc"), +/// parseSamplingInterval should return 0 and raw values should pass through. +TEST(JemallocProfileSource, CollapsedMalformedHeaderRawPassthrough) +{ + std::string profile_malformed = "heap_v2/abc\n"; + auto nl = test_heap_profile.find('\n'); + profile_malformed += std::string(test_heap_profile.substr(nl + 1)); + + auto input = writeToTempFile(profile_malformed, "gtest_jemalloc_profile_malformed.heap"); + + /// Bytes mode — should return raw bytes without Poisson correction. + { + std::string collapsed_output = runCollapsedProfile(input, /* collapsed_use_count= */ false); + UInt64 total = sumCollapsedValues(collapsed_output); + EXPECT_EQ(total, expected_raw_total); + } + + /// Count mode — should return raw counts without Poisson correction. + { + std::string collapsed_output = runCollapsedProfile(input, /* collapsed_use_count= */ true); + UInt64 total = sumCollapsedValues(collapsed_output); + EXPECT_EQ(total, expected_raw_count_total); + } + + std::filesystem::remove(input); +} + +#endif From 248f74c1975496a3642170cbaec9f31ad71ff912 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Thu, 16 Apr 2026 09:45:26 +0000 Subject: [PATCH 14/70] Backport #101503 to 26.3: Remove `functions_h3_default_if_invalid` duplicate record in SettingsChangesHistory.cpp --- src/Core/SettingsChangesHistory.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Core/SettingsChangesHistory.cpp b/src/Core/SettingsChangesHistory.cpp index 2603c5be3398..5f1b713e8076 100644 --- a/src/Core/SettingsChangesHistory.cpp +++ b/src/Core/SettingsChangesHistory.cpp @@ -67,7 +67,6 @@ const VersionToSettingsChangesMap & getSettingsChangesHistory() {"iceberg_expire_default_min_snapshots_to_keep", 1, 1, "New setting."}, {"iceberg_expire_default_max_snapshot_age_ms", 432000000, 432000000, "New setting."}, {"iceberg_expire_default_max_ref_age_ms", 9223372036854775807, 9223372036854775807, "New setting."}, - {"functions_h3_default_if_invalid", true, false, "A new setting for legacy behaviour to allow invalid inputs to h3 functions"}, {"max_skip_unavailable_shards_num", 0, 0, "New setting to limit the number of shards that can be silently skipped when skip_unavailable_shards is enabled."}, {"max_skip_unavailable_shards_ratio", 0, 0, "New setting to limit the ratio of shards that can be silently skipped when skip_unavailable_shards is enabled."}, }); From 070373b79d1fe5ee1bf38c67c27a981fe5fd5141 Mon Sep 17 00:00:00 2001 From: Rahul <254529899+motsc@users.noreply.github.com> Date: Thu, 16 Apr 2026 19:25:36 -0700 Subject: [PATCH 15/70] Backport distroless Docker image variant to 26.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add distroless Dockerfile for server and keeper images. These are minimal images with no shell, no package manager — only the ClickHouse binary. The release workflow on master already includes distroless in its build configs; this backport ensures the Dockerfiles exist at the release tag so the images are actually built. --- docker/keeper/Dockerfile.distroless | 179 +++++++++++++++++++++++++ docker/server/Dockerfile.distroless | 199 ++++++++++++++++++++++++++++ 2 files changed, 378 insertions(+) create mode 100644 docker/keeper/Dockerfile.distroless create mode 100644 docker/server/Dockerfile.distroless diff --git a/docker/keeper/Dockerfile.distroless b/docker/keeper/Dockerfile.distroless new file mode 100644 index 000000000000..5e849d048773 --- /dev/null +++ b/docker/keeper/Dockerfile.distroless @@ -0,0 +1,179 @@ +# Distroless ClickHouse Keeper image. +# Contains no shell, no package manager, no coreutils. +# The entrypoint is the compiled `clickhouse docker-init --keeper` subcommand. +# +# Build targets: +# production — gcr.io/distroless/cc-debian13:nonroot (default) +# debug — gcr.io/distroless/cc-debian13:debug-nonroot (includes busybox shell) +# +# Usage: +# docker build -f Dockerfile.distroless --target production -t clickhouse/clickhouse-keeper:distroless . +# docker build -f Dockerfile.distroless --target debug -t clickhouse/clickhouse-keeper:distroless-debug . + +# ────────────────────────────────────────────────────────────────────────────── +# Stage 1: Install ClickHouse and assemble the output directory tree. +# ────────────────────────────────────────────────────────────────────────────── +FROM ubuntu:22.04 AS ch-builder + +ARG DEBIAN_FRONTEND=noninteractive +ARG apt_archive="http://archive.ubuntu.com" + +# user/group precreated explicitly with fixed uid/gid on purpose. +# The same uid/gid (101) is used both for alpine and ubuntu. +RUN sed -i "s|http://archive.ubuntu.com|${apt_archive}|g" /etc/apt/sources.list \ + && groupadd -r clickhouse --gid=101 \ + && useradd -r -g clickhouse --uid=101 --home-dir=/var/lib/clickhouse --shell=/bin/bash clickhouse \ + && apt-get update \ + && apt-get install --yes --no-install-recommends \ + ca-certificates \ + wget \ + && rm -rf /var/lib/apt/lists/* /var/cache/debconf /tmp/* + +ARG REPO_CHANNEL="stable" +ARG REPOSITORY="deb [signed-by=/usr/share/keyrings/clickhouse-keyring.gpg] https://packages.clickhouse.com/deb ${REPO_CHANNEL} main" +ARG VERSION="26.3.4.11" +ARG PACKAGES="clickhouse-common-static clickhouse-keeper" + +ARG deb_location_url="" +ARG DIRECT_DOWNLOAD_URLS="" +ARG single_binary_location_url="" +ARG TARGETARCH + +# Install from direct URLs (deb packages provided by CI). +RUN if [ -n "${DIRECT_DOWNLOAD_URLS}" ]; then \ + rm -rf /tmp/clickhouse_debs \ + && mkdir -p /tmp/clickhouse_debs \ + && for url in $DIRECT_DOWNLOAD_URLS; do \ + wget --progress=bar:force:noscroll "$url" -P /tmp/clickhouse_debs || exit 1 \ + ; done \ + && dpkg -i /tmp/clickhouse_debs/*.deb \ + && rm -rf /tmp/* ; \ + fi + +# Install from a web location with deb packages. +RUN arch="${TARGETARCH:-amd64}" \ + && if [ -n "${deb_location_url}" ]; then \ + rm -rf /tmp/clickhouse_debs \ + && mkdir -p /tmp/clickhouse_debs \ + && for package in ${PACKAGES}; do \ + { wget --progress=bar:force:noscroll "${deb_location_url}/${package}_${VERSION}_${arch}.deb" -P /tmp/clickhouse_debs || \ + wget --progress=bar:force:noscroll "${deb_location_url}/${package}_${VERSION}_all.deb" -P /tmp/clickhouse_debs ; } \ + || exit 1 \ + ; done \ + && dpkg -i /tmp/clickhouse_debs/*.deb \ + && rm -rf /tmp/* ; \ + fi + +# Install from a single binary. +RUN if [ -n "${single_binary_location_url}" ]; then \ + rm -rf /tmp/clickhouse_binary \ + && mkdir -p /tmp/clickhouse_binary \ + && wget --progress=bar:force:noscroll "${single_binary_location_url}" -O /tmp/clickhouse_binary/clickhouse \ + && chmod +x /tmp/clickhouse_binary/clickhouse \ + && /tmp/clickhouse_binary/clickhouse install --user "clickhouse" --group "clickhouse" \ + && rm -rf /tmp/* ; \ + fi + +# Fall back to installation from the ClickHouse repository. +RUN clickhouse local -q 'SELECT 1' >/dev/null 2>&1 && exit 0 || : \ + ; apt-get update \ + && apt-get install --yes --no-install-recommends dirmngr gnupg2 \ + && mkdir -p /etc/apt/sources.list.d \ + && GNUPGHOME=$(mktemp -d) \ + && GNUPGHOME="$GNUPGHOME" gpg --batch --no-default-keyring \ + --keyring /usr/share/keyrings/clickhouse-keyring.gpg \ + --keyserver hkp://keyserver.ubuntu.com:80 \ + --recv-keys 3a9ea1193a97b548be1457d48919f6bd2b48d754 \ + && rm -rf "$GNUPGHOME" \ + && chmod +r /usr/share/keyrings/clickhouse-keyring.gpg \ + && echo "${REPOSITORY}" > /etc/apt/sources.list.d/clickhouse.list \ + && echo "installing from repository: ${REPOSITORY}" \ + && apt-get update \ + && for package in ${PACKAGES}; do \ + packages="${packages} ${package}=${VERSION}" \ + ; done \ + && apt-get install --yes --no-install-recommends ${packages} \ + && rm -rf /var/lib/apt/lists/* /var/cache/debconf /tmp/* \ + && apt-get autoremove --purge -yq dirmngr gnupg2 + +# Verify the installation. +# Use "clickhouse local" (not "clickhouse-local") because the clickhouse-local symlink +# is provided by clickhouse-server which is not installed here. +RUN clickhouse local -q 'SELECT version()' + +ARG DEFAULT_DATA_DIR="/var/lib/clickhouse" +ARG DEFAULT_LOG_DIR="/var/log/clickhouse-keeper" +ARG DEFAULT_CONFIG_DIR="/etc/clickhouse-keeper" + +# Assemble the output directory tree. +RUN mkdir -p \ + /output/usr/bin \ + /output${DEFAULT_CONFIG_DIR} \ + /output${DEFAULT_DATA_DIR} \ + /output${DEFAULT_LOG_DIR} \ + /output/tmp \ + && cp /usr/bin/clickhouse /output/usr/bin/clickhouse \ + && for link in clickhouse-keeper clickhouse-keeper-client clickhouse-docker-init; do \ + ln -sf /usr/bin/clickhouse "/output/usr/bin/${link}" ; \ + done \ + && if [ -d "${DEFAULT_CONFIG_DIR}" ]; then cp -rp "${DEFAULT_CONFIG_DIR}/." "/output${DEFAULT_CONFIG_DIR}/"; fi \ + && chown -R clickhouse:clickhouse \ + /output${DEFAULT_CONFIG_DIR} \ + /output${DEFAULT_DATA_DIR} \ + /output${DEFAULT_LOG_DIR} \ + && chmod 1777 /output/tmp \ + && { \ + printf 'root:x:0:0:root:/root:/sbin/nologin\n'; \ + printf 'nobody:x:65534:65534:nobody:/nonexistent:/sbin/nologin\n'; \ + printf 'nonroot:x:65532:65532:nonroot:/home/nonroot:/sbin/nologin\n'; \ + printf 'clickhouse:x:101:101:ClickHouse:/var/lib/clickhouse:/sbin/nologin\n'; \ + } > /output/etc/passwd \ + && { \ + printf 'root:x:0:\n'; \ + printf 'nobody:x:65534:\n'; \ + printf 'nonroot:x:65532:\n'; \ + printf 'clickhouse:x:101:\n'; \ + } > /output/etc/group + +# ────────────────────────────────────────────────────────────────────────────── +# Stage 2: Production distroless image. +# ────────────────────────────────────────────────────────────────────────────── +# Pinned 2026-04-02. Refresh: docker pull gcr.io/distroless/cc-debian13:nonroot && docker inspect --format='{{index .RepoDigests 0}}' gcr.io/distroless/cc-debian13:nonroot +FROM gcr.io/distroless/cc-debian13:nonroot@sha256:9c4fe2381c2e6d53c4cfdefeff6edbd2a67ec7713e2c3ca6653806cbdbf27a1e AS production + +COPY --from=ch-builder /output/ / + +ENV TZ=UTC \ + CLICKHOUSE_WATCHDOG_ENABLE=0 + +# 9181: ZooKeeper-compatible client port +# 9234: Raft port (inter-node communication) +EXPOSE 9181 9234 + +VOLUME ["/var/lib/clickhouse", "/var/log/clickhouse-keeper"] + +USER 101:101 +WORKDIR /var/lib/clickhouse + +ENTRYPOINT ["/usr/bin/clickhouse", "docker-init", "--keeper"] + +# ────────────────────────────────────────────────────────────────────────────── +# Stage 3: Debug image — same as production but includes the busybox shell +# at /busybox/sh for interactive troubleshooting. +# ────────────────────────────────────────────────────────────────────────────── +# Pinned 2026-04-02. Refresh: docker pull gcr.io/distroless/cc-debian13:debug-nonroot && docker inspect --format='{{index .RepoDigests 0}}' gcr.io/distroless/cc-debian13:debug-nonroot +FROM gcr.io/distroless/cc-debian13:debug-nonroot@sha256:d47b319b1047dff7cdee335e3e61468f3610fac20060653aabe3786d6ecba621 AS debug + +COPY --from=ch-builder /output/ / + +ENV TZ=UTC \ + CLICKHOUSE_WATCHDOG_ENABLE=0 + +EXPOSE 9181 9234 + +VOLUME ["/var/lib/clickhouse", "/var/log/clickhouse-keeper"] + +USER 101:101 +WORKDIR /var/lib/clickhouse + +ENTRYPOINT ["/usr/bin/clickhouse", "docker-init", "--keeper"] diff --git a/docker/server/Dockerfile.distroless b/docker/server/Dockerfile.distroless new file mode 100644 index 000000000000..07da5d16fd08 --- /dev/null +++ b/docker/server/Dockerfile.distroless @@ -0,0 +1,199 @@ +# Distroless ClickHouse server image. +# Contains no shell, no package manager, no coreutils. +# The entrypoint is the compiled `clickhouse docker-init` subcommand. +# +# Build targets: +# production — gcr.io/distroless/cc-debian13:nonroot (default) +# debug — gcr.io/distroless/cc-debian13:debug-nonroot (includes busybox shell) +# +# Usage: +# docker build -f Dockerfile.distroless --target production -t clickhouse/clickhouse-server:distroless . +# docker build -f Dockerfile.distroless --target debug -t clickhouse/clickhouse-server:distroless-debug . + +# ────────────────────────────────────────────────────────────────────────────── +# Stage 1: Install ClickHouse and assemble the output directory tree. +# ────────────────────────────────────────────────────────────────────────────── +FROM ubuntu:22.04 AS ch-builder + +# see https://github.com/moby/moby/issues/4032#issuecomment-192327844 +ARG DEBIAN_FRONTEND=noninteractive + +ARG apt_archive="http://archive.ubuntu.com" + +# user/group precreated explicitly with fixed uid/gid on purpose. +# It is especially important for rootless containers: in that case entrypoint +# can't do chown and owners of mounted volumes should be configured externally. +# We do that in advance at the beginning of Dockerfile before any packages will be +# installed to prevent picking those uid/gid by some unrelated software. +# The same uid/gid (101) is used both for alpine and ubuntu. +RUN sed -i "s|http://archive.ubuntu.com|${apt_archive}|g" /etc/apt/sources.list \ + && groupadd -r clickhouse --gid=101 \ + && useradd -r -g clickhouse --uid=101 --home-dir=/var/lib/clickhouse --shell=/bin/bash clickhouse \ + && apt-get update \ + && apt-get install --yes --no-install-recommends \ + ca-certificates \ + wget \ + && rm -rf /var/lib/apt/lists/* /var/cache/debconf /tmp/* + +ARG REPO_CHANNEL="stable" +ARG REPOSITORY="deb [signed-by=/usr/share/keyrings/clickhouse-keyring.gpg] https://packages.clickhouse.com/deb ${REPO_CHANNEL} main" +ARG VERSION="26.3.4.11" +ARG PACKAGES="clickhouse-client clickhouse-server clickhouse-common-static" + +#docker-official-library:off +ARG deb_location_url="" +ARG DIRECT_DOWNLOAD_URLS="" +ARG single_binary_location_url="" +ARG TARGETARCH + +# Install from direct URLs (deb packages provided by CI). +RUN if [ -n "${DIRECT_DOWNLOAD_URLS}" ]; then \ + rm -rf /tmp/clickhouse_debs \ + && mkdir -p /tmp/clickhouse_debs \ + && for url in $DIRECT_DOWNLOAD_URLS; do \ + wget --progress=bar:force:noscroll "$url" -P /tmp/clickhouse_debs || exit 1 \ + ; done \ + && dpkg -i /tmp/clickhouse_debs/*.deb \ + && rm -rf /tmp/* ; \ + fi + +# Install from a web location with deb packages. +RUN arch="${TARGETARCH:-amd64}" \ + && if [ -n "${deb_location_url}" ]; then \ + rm -rf /tmp/clickhouse_debs \ + && mkdir -p /tmp/clickhouse_debs \ + && for package in ${PACKAGES}; do \ + { wget --progress=bar:force:noscroll "${deb_location_url}/${package}_${VERSION}_${arch}.deb" -P /tmp/clickhouse_debs || \ + wget --progress=bar:force:noscroll "${deb_location_url}/${package}_${VERSION}_all.deb" -P /tmp/clickhouse_debs ; } \ + || exit 1 \ + ; done \ + && dpkg -i /tmp/clickhouse_debs/*.deb \ + && rm -rf /tmp/* ; \ + fi + +# Install from a single binary. +RUN if [ -n "${single_binary_location_url}" ]; then \ + rm -rf /tmp/clickhouse_binary \ + && mkdir -p /tmp/clickhouse_binary \ + && wget --progress=bar:force:noscroll "${single_binary_location_url}" -O /tmp/clickhouse_binary/clickhouse \ + && chmod +x /tmp/clickhouse_binary/clickhouse \ + && /tmp/clickhouse_binary/clickhouse install --user "clickhouse" --group "clickhouse" \ + && rm -rf /tmp/* ; \ + fi + +# Fall back to installation from the ClickHouse repository. +RUN clickhouse local -q 'SELECT 1' >/dev/null 2>&1 && exit 0 || : \ + ; apt-get update \ + && apt-get install --yes --no-install-recommends dirmngr gnupg2 \ + && mkdir -p /etc/apt/sources.list.d \ + && GNUPGHOME=$(mktemp -d) \ + && GNUPGHOME="$GNUPGHOME" gpg --batch --no-default-keyring \ + --keyring /usr/share/keyrings/clickhouse-keyring.gpg \ + --keyserver hkp://keyserver.ubuntu.com:80 \ + --recv-keys 3a9ea1193a97b548be1457d48919f6bd2b48d754 \ + && rm -rf "$GNUPGHOME" \ + && chmod +r /usr/share/keyrings/clickhouse-keyring.gpg \ + && echo "${REPOSITORY}" > /etc/apt/sources.list.d/clickhouse.list \ + && echo "installing from repository: ${REPOSITORY}" \ + && apt-get update \ + && for package in ${PACKAGES}; do \ + packages="${packages} ${package}=${VERSION}" \ + ; done \ + && apt-get install --yes --no-install-recommends ${packages} \ + && rm -rf /var/lib/apt/lists/* /var/cache/debconf /tmp/* \ + && apt-get autoremove --purge -yq dirmngr gnupg2 + +#docker-official-library:on + +# Verify the installation. +RUN clickhouse-local -q 'SELECT * FROM system.build_options' + +# Assemble the output directory tree that will be COPYed into the distroless image. +# Symlinks pointing to /usr/bin/clickhouse are preserved by Docker COPY. +RUN mkdir -p \ + /output/usr/bin \ + /output/etc/clickhouse-server/config.d \ + /output/etc/clickhouse-server/users.d \ + /output/etc/clickhouse-client \ + /output/var/lib/clickhouse \ + /output/var/log/clickhouse-server \ + /output/docker-entrypoint-initdb.d \ + /output/tmp \ + && cp /usr/bin/clickhouse /output/usr/bin/clickhouse \ + && for link in clickhouse-server clickhouse-client clickhouse-local \ + clickhouse-keeper clickhouse-keeper-client \ + clickhouse-docker-init; do \ + ln -sf /usr/bin/clickhouse "/output/usr/bin/${link}" ; \ + done \ + && cp -r /etc/clickhouse-server/. /output/etc/clickhouse-server/ \ + && if [ -d /etc/clickhouse-client ]; then cp -r /etc/clickhouse-client/. /output/etc/clickhouse-client/; fi + +COPY docker_related_config.xml /output/etc/clickhouse-server/config.d/ + +# Set ownership after all config files are in place (including docker_related_config.xml above). +RUN chown -R clickhouse:clickhouse \ + /output/etc/clickhouse-server \ + /output/var/lib/clickhouse \ + /output/var/log/clickhouse-server \ + /output/docker-entrypoint-initdb.d \ + && chmod 1777 /output/tmp + +# Create /etc/passwd and /etc/group that include the clickhouse user (uid/gid 101). +# These entries are merged with the distroless base's existing entries. +RUN { \ + printf 'root:x:0:0:root:/root:/sbin/nologin\n'; \ + printf 'nobody:x:65534:65534:nobody:/nonexistent:/sbin/nologin\n'; \ + printf 'nonroot:x:65532:65532:nonroot:/home/nonroot:/sbin/nologin\n'; \ + printf 'clickhouse:x:101:101:ClickHouse:/var/lib/clickhouse:/sbin/nologin\n'; \ + } > /output/etc/passwd \ + && { \ + printf 'root:x:0:\n'; \ + printf 'nobody:x:65534:\n'; \ + printf 'nonroot:x:65532:\n'; \ + printf 'clickhouse:x:101:\n'; \ + } > /output/etc/group + +# ────────────────────────────────────────────────────────────────────────────── +# Stage 2: Production distroless image. +# ────────────────────────────────────────────────────────────────────────────── +# Pinned 2026-04-02. Refresh: docker pull gcr.io/distroless/cc-debian13:nonroot && docker inspect --format='{{index .RepoDigests 0}}' gcr.io/distroless/cc-debian13:nonroot +FROM gcr.io/distroless/cc-debian13:nonroot@sha256:9c4fe2381c2e6d53c4cfdefeff6edbd2a67ec7713e2c3ca6653806cbdbf27a1e AS production + +COPY --from=ch-builder /output/ / + +ENV CLICKHOUSE_CONFIG=/etc/clickhouse-server/config.xml \ + LC_ALL=C.UTF-8 \ + TZ=UTC \ + CLICKHOUSE_WATCHDOG_ENABLE=0 + +EXPOSE 9000 8123 9009 + +VOLUME ["/var/lib/clickhouse", "/var/log/clickhouse-server"] + +USER 101:101 +WORKDIR /var/lib/clickhouse + +ENTRYPOINT ["/usr/bin/clickhouse", "docker-init"] + +# ────────────────────────────────────────────────────────────────────────────── +# Stage 3: Debug image — same as production but includes the busybox shell +# at /busybox/sh for interactive troubleshooting. +# ────────────────────────────────────────────────────────────────────────────── +# Pinned 2026-04-02. Refresh: docker pull gcr.io/distroless/cc-debian13:debug-nonroot && docker inspect --format='{{index .RepoDigests 0}}' gcr.io/distroless/cc-debian13:debug-nonroot +FROM gcr.io/distroless/cc-debian13:debug-nonroot@sha256:d47b319b1047dff7cdee335e3e61468f3610fac20060653aabe3786d6ecba621 AS debug + +COPY --from=ch-builder /output/ / + +ENV CLICKHOUSE_CONFIG=/etc/clickhouse-server/config.xml \ + LC_ALL=C.UTF-8 \ + TZ=UTC \ + CLICKHOUSE_WATCHDOG_ENABLE=0 + +EXPOSE 9000 8123 9009 + +VOLUME ["/var/lib/clickhouse", "/var/log/clickhouse-server"] + +USER 101:101 +WORKDIR /var/lib/clickhouse + +ENTRYPOINT ["/usr/bin/clickhouse", "docker-init"] From c004ba50cf9ba44ccd2c079951bd856a6d579ccf Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Fri, 17 Apr 2026 08:51:19 +0000 Subject: [PATCH 16/70] Backport #102913 to 26.3: Fix random crashes in jemalloc due to LTO --- contrib/jemalloc-cmake/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/jemalloc-cmake/CMakeLists.txt b/contrib/jemalloc-cmake/CMakeLists.txt index 60d24b008211..b7ca3e080b0c 100644 --- a/contrib/jemalloc-cmake/CMakeLists.txt +++ b/contrib/jemalloc-cmake/CMakeLists.txt @@ -191,6 +191,8 @@ target_compile_definitions(_jemalloc INTERFACE -DJEMALLOC_NO_RENAME) # Because our coverage callbacks call malloc, and recursive call of malloc could not work. target_compile_options(_jemalloc PRIVATE ${WITHOUT_COVERAGE_FLAGS_LIST}) +# Due to LTO there are some UB in tcache +target_compile_options(_jemalloc PRIVATE -fno-lto -fno-whole-program-vtables) target_compile_definitions(_jemalloc PRIVATE -DJEMALLOC_PROF=1) From 7de4c303a672cbfd97a5405baf8aa9f3f9850284 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Fri, 17 Apr 2026 11:33:19 +0000 Subject: [PATCH 17/70] Backport #102674 to 26.3: Fix wrong date data type inference in case of overflow after timezone adjustment --- src/IO/parseDateTimeBestEffort.cpp | 9 +++++++++ ...me_timezone_boundary_range_check.reference | 4 ++++ ...datetime_timezone_boundary_range_check.sql | 20 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 tests/queries/0_stateless/04093_best_effort_datetime_timezone_boundary_range_check.reference create mode 100644 tests/queries/0_stateless/04093_best_effort_datetime_timezone_boundary_range_check.sql diff --git a/src/IO/parseDateTimeBestEffort.cpp b/src/IO/parseDateTimeBestEffort.cpp index 885b877d945c..a0b6cdf2d264 100644 --- a/src/IO/parseDateTimeBestEffort.cpp +++ b/src/IO/parseDateTimeBestEffort.cpp @@ -855,6 +855,15 @@ ReturnType parseDateTimeBestEffortImpl( } res = *res_maybe; adjust_time_zone(); + + /// After timezone adjustment, the value may have shifted outside the valid range. + /// For example, "2106-02-07 06:28:15-01:00" is within range before adjustment, + /// but after converting to UTC it exceeds UINT32_MAX. + if constexpr (!is_64) + { + if (res < 0 || static_cast(res) > UINT32_MAX) + return false; + } } else { diff --git a/tests/queries/0_stateless/04093_best_effort_datetime_timezone_boundary_range_check.reference b/tests/queries/0_stateless/04093_best_effort_datetime_timezone_boundary_range_check.reference new file mode 100644 index 000000000000..2634ecb23695 --- /dev/null +++ b/tests/queries/0_stateless/04093_best_effort_datetime_timezone_boundary_range_check.reference @@ -0,0 +1,4 @@ +2106-02-07 07:28:15.000000000 Nullable(DateTime64(9)) +1969-12-31 23:00:00.000000000 Nullable(DateTime64(9)) +2106-02-07 05:28:15 Nullable(DateTime) +1970-01-01 00:00:00 Nullable(DateTime) diff --git a/tests/queries/0_stateless/04093_best_effort_datetime_timezone_boundary_range_check.sql b/tests/queries/0_stateless/04093_best_effort_datetime_timezone_boundary_range_check.sql new file mode 100644 index 000000000000..ec4567169f5b --- /dev/null +++ b/tests/queries/0_stateless/04093_best_effort_datetime_timezone_boundary_range_check.sql @@ -0,0 +1,20 @@ +-- Tags: no-fasttest +-- Test for missing range check after adjust_time_zone in parseDateTimeBestEffortImpl +-- https://github.com/ClickHouse/ClickHouse/issues/102601 + +SET session_timezone = 'UTC'; +SET date_time_input_format = 'best_effort'; + +-- Upper boundary: 2106-02-07 06:28:15 UTC is exactly UINT32_MAX. +-- With -01:00 offset, UTC time is 2106-02-07 07:28:15, which exceeds UINT32_MAX. +-- Should be inferred as DateTime64, not DateTime with wrap-around. +SELECT d, toTypeName(d) FROM format(JSONEachRow, '{"d" : "2106-02-07 06:28:15-01:00"}'); + +-- Lower boundary: 1970-01-01 00:00:00 UTC is timestamp 0. +-- With +01:00 offset, UTC time is 1969-12-31 23:00:00, which is negative. +-- Should be inferred as DateTime64, not DateTime with clamped value. +SELECT d, toTypeName(d) FROM format(JSONEachRow, '{"d" : "1970-01-01 00:00:00+01:00"}'); + +-- Control: values that SHOULD remain DateTime (timezone adjustment stays within range) +SELECT d, toTypeName(d) FROM format(JSONEachRow, '{"d" : "2106-02-07 06:28:15+01:00"}'); +SELECT d, toTypeName(d) FROM format(JSONEachRow, '{"d" : "1970-01-01 01:00:00+01:00"}'); From e140c32bbe5865cdedb45b65f35b32d6a5ff89db Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Fri, 17 Apr 2026 13:45:57 +0000 Subject: [PATCH 18/70] Backport #102661 to 26.3: Fix crash in cluster discovery static configuration --- src/Interpreters/ClusterDiscovery.cpp | 20 ++++--- src/Interpreters/ClusterDiscovery.h | 2 +- .../test_cluster_discovery/test.py | 53 +++++++++++++++++++ 3 files changed, 66 insertions(+), 9 deletions(-) diff --git a/src/Interpreters/ClusterDiscovery.cpp b/src/Interpreters/ClusterDiscovery.cpp index 98f57c31e9e5..edcc559fb02b 100644 --- a/src/Interpreters/ClusterDiscovery.cpp +++ b/src/Interpreters/ClusterDiscovery.cpp @@ -470,9 +470,7 @@ bool ClusterDiscovery::upsertCluster(ClusterInfo & cluster_info) if (nodes_info.empty()) { - String name = cluster_info.name; - /// cluster_info removed inside removeCluster, can't use reference to name. - removeCluster(name); + removeCluster(cluster_info.name, /* is_dynamic_cluster */cluster_info.zk_root_index != 0); return true; } @@ -483,15 +481,21 @@ bool ClusterDiscovery::upsertCluster(ClusterInfo & cluster_info) return true; } -void ClusterDiscovery::removeCluster(const String & name) +void ClusterDiscovery::removeCluster(const String & name, bool is_dynamic) { { std::lock_guard lock(mutex); cluster_impls.erase(name); } - clusters_to_update->remove(name); - get_nodes_callbacks.erase(name); - LOG_DEBUG(log, "Dynamic cluster '{}' removed successfully", name); + /// For static clusters (defined in config), `clusters_to_update` and `get_nodes_callbacks` + /// are initialized once at startup and must persist so the cluster can be re-registered after + /// a ZooKeeper session loss. Dynamic clusters own their entries and must clean them up. + if (is_dynamic) + { + clusters_to_update->remove(name); + get_nodes_callbacks.erase(name); + LOG_DEBUG(log, "Dynamic cluster '{}' removed successfully", name); + } } void ClusterDiscovery::registerInZk(zkutil::ZooKeeperPtr & zk, ClusterInfo & info) @@ -719,7 +723,7 @@ bool ClusterDiscovery::runMainThread(std::function up_to_date_callback) clusters_to_insert.insert(cluster_name); for (const auto & cluster_name : clusters_to_remove) - removeCluster(cluster_name); + removeCluster(cluster_name, /* is_dynamic_cluster */true); clusters_info.merge(new_dynamic_clusters_info); diff --git a/src/Interpreters/ClusterDiscovery.h b/src/Interpreters/ClusterDiscovery.h index 963970b32af2..2bea12d9f1e0 100644 --- a/src/Interpreters/ClusterDiscovery.h +++ b/src/Interpreters/ClusterDiscovery.h @@ -126,7 +126,7 @@ class ClusterDiscovery bool needUpdate(const Strings & node_uuids, const NodesInfo & nodes); bool upsertCluster(ClusterInfo & cluster_info); - void removeCluster(const String & name); + void removeCluster(const String & name, bool is_dynamic); bool runMainThread(std::function up_to_date_callback); void shutdown(); diff --git a/tests/integration/test_cluster_discovery/test.py b/tests/integration/test_cluster_discovery/test.py index ad24fc16a095..bcff94d50c76 100644 --- a/tests/integration/test_cluster_discovery/test.py +++ b/tests/integration/test_cluster_discovery/test.py @@ -124,6 +124,59 @@ def test_cluster_discovery_startup_and_stop(start_cluster): nodes["node0"].query("DROP TABLE tbl ON CLUSTER 'test_auto_cluster' SYNC") +def test_cluster_discovery_no_crash_on_empty_static_cluster(start_cluster): + """ + Regression test: server must not crash when a static cluster temporarily has no nodes. + + Crash path (without fix): + 1. All member nodes stop → ZK ephemeral nodes deleted → observer detects empty cluster. + 2. upsertCluster sees nodes_info.empty() → calls removeCluster() → erases watch callback + from get_nodes_callbacks. + 3. A member node restarts → old ZK watch fires → cluster re-queued for update. + 4. upsertCluster is called again → on_exit calls getNodeNames(set_callback=True). + 5. Callback not found, zk_root_index==0 → multicluster_discovery_paths[0-1] OOB → crash. + """ + import time + + observer = nodes["node_observer"] + member_nodes = [nodes[n] for n in ("node0", "node1", "node2", "node3", "node4")] + + # Wait for cluster to be fully up before the test + check_on_cluster( + [observer], len(member_nodes), what="count()", msg="Pre-test cluster count wrong" + ) + + # Stop all member nodes gracefully — closes ZK sessions immediately, + # deleting their ephemeral registration nodes in ZK. + for node in member_nodes: + node.stop_clickhouse() + + # Wait for the observer to detect the now-empty cluster. + # This triggers upsertCluster → nodes_info.empty() → removeCluster() erasing the + # watch callback (the step that sets up the crash on the subsequent call). + check_on_cluster( + [observer], 0, what="count()", msg="Cluster should appear empty to observer" + ) + + assert observer.query("SELECT 1").strip() == "1", "Observer crashed after cluster became empty" + + # Restart one member node. It registers in ZK, which triggers the old watch callback + # that was stored in the ZK client (independently of get_nodes_callbacks). + # On unfixed code this triggers the second upsertCluster call that crashes. + nodes["node0"].start_clickhouse() + time.sleep(10) + + assert observer.query("SELECT 1").strip() == "1", "Observer crashed after member node restarted" + + # Restore all nodes for subsequent tests + for node in member_nodes[1:]: + node.start_clickhouse() + + check_on_cluster( + [observer], len(member_nodes), what="count()", msg="Cluster should recover after restart" + ) + + def test_cluster_discovery_macros(start_cluster): # wait for all nodes to be started check_nodes_count = functools.partial( From b65babe963ac5f913259c7ad76ba34b0a2b2b7e1 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Fri, 17 Apr 2026 13:47:52 +0000 Subject: [PATCH 19/70] Backport #101918 to 26.3: Fix using wrong extreams in min-max index created on JSON column --- src/Columns/ColumnObject.cpp | 27 ++++++---- .../04076_json_in_min_max_index_bug.reference | 54 +++++++++++++++++++ .../04076_json_in_min_max_index_bug.sql | 21 ++++++++ 3 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 tests/queries/0_stateless/04076_json_in_min_max_index_bug.reference create mode 100644 tests/queries/0_stateless/04076_json_in_min_max_index_bug.sql diff --git a/src/Columns/ColumnObject.cpp b/src/Columns/ColumnObject.cpp index 7e8638c713c2..4312dd65a674 100644 --- a/src/Columns/ColumnObject.cpp +++ b/src/Columns/ColumnObject.cpp @@ -1556,18 +1556,27 @@ bool ColumnObject::isFinalized() const return finalized; } -void ColumnObject::getExtremes(DB::Field & min, DB::Field & max, size_t, size_t) const +void ColumnObject::getExtremes(Field & min, Field & max, size_t start, size_t end) const { - if (empty()) - { - min = Object(); - max = Object(); - } - else + min = Object(); + max = Object(); + + if (start >= end) + return; + + size_t min_idx = start; + size_t max_idx = start; + + for (size_t i = start + 1; i < end; ++i) { - get(0, min); - get(0, max); + if (compareAt(i, min_idx, *this, /* nan_direction_hint = */ 1) < 0) + min_idx = i; + else if (compareAt(i, max_idx, *this, /* nan_direction_hint = */ -1) > 0) + max_idx = i; } + + get(min_idx, min); + get(max_idx, max); } void ColumnObject::prepareForSquashing(const std::vector & source_columns, size_t factor) diff --git a/tests/queries/0_stateless/04076_json_in_min_max_index_bug.reference b/tests/queries/0_stateless/04076_json_in_min_max_index_bug.reference new file mode 100644 index 000000000000..e9202056898b --- /dev/null +++ b/tests/queries/0_stateless/04076_json_in_min_max_index_bug.reference @@ -0,0 +1,54 @@ +3 +Expression (Project names) + Sorting (Sorting for ORDER BY) + Expression ((Before ORDER BY + Projection)) + Expression ((WHERE + Change column names to column identifiers)) + ReadFromMergeTree (default.t_json_minmax_idx) + Indexes: + PrimaryKey + Condition: true + Parts: 1/1 + Granules: 3/3 + Skip + Name: idx_j + Description: minmax GRANULARITY 1 + Condition: (j in (\'{"a": "2"}\', +Inf)) + Parts: 1/1 + Granules: 1/3 + Ranges: 1 +2 +Expression (Project names) + Sorting (Sorting for ORDER BY) + Expression ((Before ORDER BY + Projection)) + Expression ((WHERE + Change column names to column identifiers)) + ReadFromMergeTree (default.t_json_minmax_idx) + Indexes: + PrimaryKey + Condition: true + Parts: 1/1 + Granules: 3/3 + Skip + Name: idx_j + Description: minmax GRANULARITY 1 + Condition: (j in [\'{"a": "2"}\', \'{"a": "2"}\']) + Parts: 1/1 + Granules: 1/3 + Ranges: 1 +1 +Expression (Project names) + Sorting (Sorting for ORDER BY) + Expression ((Before ORDER BY + Projection)) + Expression ((WHERE + Change column names to column identifiers)) + ReadFromMergeTree (default.t_json_minmax_idx) + Indexes: + PrimaryKey + Condition: true + Parts: 1/1 + Granules: 3/3 + Skip + Name: idx_j + Description: minmax GRANULARITY 1 + Condition: (j in (-Inf, \'{"a": "2"}\')) + Parts: 1/1 + Granules: 1/3 + Ranges: 1 diff --git a/tests/queries/0_stateless/04076_json_in_min_max_index_bug.sql b/tests/queries/0_stateless/04076_json_in_min_max_index_bug.sql new file mode 100644 index 000000000000..cb754f3faa1e --- /dev/null +++ b/tests/queries/0_stateless/04076_json_in_min_max_index_bug.sql @@ -0,0 +1,21 @@ +-- Tags: no-parallel-replicas +-- Tag no-parallel-replicas: output of explain is different + +DROP TABLE IF EXISTS t_json_minmax_idx; + +CREATE TABLE t_json_minmax_idx (id UInt32, j JSON, INDEX idx_j j TYPE minmax GRANULARITY 1) ENGINE = MergeTree() ORDER BY id SETTINGS index_granularity=1; + +INSERT INTO t_json_minmax_idx VALUES (1, '{"a":"1"}'), (2, '{"a":"2"}'), (3, '{"a":"3"}'); + +SET enable_analyzer = 1; +SET optimize_move_to_prewhere = 1; +SET query_plan_optimize_prewhere = 1; + +SELECT id FROM t_json_minmax_idx WHERE j > '{"a":"2"}'::JSON ORDER BY id; +EXPLAIN indexes=1 SELECT id FROM t_json_minmax_idx WHERE j > '{"a":"2"}'::JSON ORDER BY id; +SELECT id FROM t_json_minmax_idx WHERE j = '{"a":"2"}'::JSON ORDER BY id; +EXPLAIN indexes=1 SELECT id FROM t_json_minmax_idx WHERE j = '{"a":"2"}'::JSON ORDER BY id; +SELECT id FROM t_json_minmax_idx WHERE j < '{"a":"2"}'::JSON ORDER BY id; +EXPLAIN indexes=1 SELECT id FROM t_json_minmax_idx WHERE j < '{"a":"2"}'::JSON ORDER BY id; + +DROP TABLE IF EXISTS t_json_minmax_idx; From 51a128193928f7e6a9c4905812c3df23ff67b8ba Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Fri, 17 Apr 2026 14:41:42 +0000 Subject: [PATCH 20/70] Backport #102915 to 26.3: Optimize row policy OR-chains to IN in the new analyzer --- src/Planner/Utils.cpp | 7 ++++ ..._policy_disjunction_optimization.reference | 8 +++++ ...98_row_policy_disjunction_optimization.sql | 36 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 tests/queries/0_stateless/04098_row_policy_disjunction_optimization.reference create mode 100644 tests/queries/0_stateless/04098_row_policy_disjunction_optimization.sql diff --git a/src/Planner/Utils.cpp b/src/Planner/Utils.cpp index 547ab3da1350..f24395a855ef 100644 --- a/src/Planner/Utils.cpp +++ b/src/Planner/Utils.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -498,6 +499,12 @@ FilterDAGInfo buildFilterInfo(ASTPtr filter_expression, QueryAnalysisPass query_analysis_pass(table_expression); query_analysis_pass.run(filter_query_tree, query_context); + /// Optimize logical expressions in the filter, e.g. convert OR-chains of + /// equalities into IN (important for row policies that produce many + /// permissive conditions like `x = 1 OR x = 2 OR ... OR x = N`). + LogicalExpressionOptimizerPass logical_expression_optimizer_pass; + logical_expression_optimizer_pass.run(filter_query_tree, query_context); + return buildFilterInfo(std::move(filter_query_tree), table_expression, planner_context, std::move(table_expression_required_names_without_filter)); } diff --git a/tests/queries/0_stateless/04098_row_policy_disjunction_optimization.reference b/tests/queries/0_stateless/04098_row_policy_disjunction_optimization.reference new file mode 100644 index 000000000000..67d82bc6da81 --- /dev/null +++ b/tests/queries/0_stateless/04098_row_policy_disjunction_optimization.reference @@ -0,0 +1,8 @@ +old analyzer + Row level filter column: in(id, (1, 3, 5)) (removed) +new analyzer + Row level filter column: in(id, __set_UInt64_) (removed) +result +1 +3 +5 diff --git a/tests/queries/0_stateless/04098_row_policy_disjunction_optimization.sql b/tests/queries/0_stateless/04098_row_policy_disjunction_optimization.sql new file mode 100644 index 000000000000..e97074ad7079 --- /dev/null +++ b/tests/queries/0_stateless/04098_row_policy_disjunction_optimization.sql @@ -0,0 +1,36 @@ +-- Tags: no-parallel, no-parallel-replicas + +DROP TABLE IF EXISTS t_row_policy_or; +CREATE TABLE t_row_policy_or (id UInt64, value String) ENGINE = MergeTree ORDER BY id; +INSERT INTO t_row_policy_or SELECT number, toString(number) FROM numbers(10); + +DROP ROW POLICY IF EXISTS 04098_p1 ON t_row_policy_or; +DROP ROW POLICY IF EXISTS 04098_p2 ON t_row_policy_or; +DROP ROW POLICY IF EXISTS 04098_p3 ON t_row_policy_or; + +CREATE ROW POLICY 04098_p1 ON t_row_policy_or USING id = 1 AS permissive TO ALL; +CREATE ROW POLICY 04098_p2 ON t_row_policy_or USING id = 3 AS permissive TO ALL; +CREATE ROW POLICY 04098_p3 ON t_row_policy_or USING id = 5 AS permissive TO ALL; + +-- With the old analyzer the OR chain is converted to IN by LogicalExpressionsOptimizer. +-- With the new analyzer the same should happen via LogicalExpressionOptimizerPass +-- applied to the row policy filter in buildFilterInfo. + +SET enable_analyzer = 0; +SELECT 'old analyzer'; +SELECT explain FROM (EXPLAIN actions = 1 SELECT id FROM t_row_policy_or) +WHERE explain LIKE '%Row level filter column:%'; + +SET enable_analyzer = 1; +SELECT 'new analyzer'; +SELECT replaceRegexpOne(explain, '__set_UInt64_\\d+_\\d+', '__set_UInt64_') +FROM (EXPLAIN actions = 1 SELECT id FROM t_row_policy_or) +WHERE explain LIKE '%Row level filter column:%'; + +SELECT 'result'; +SELECT id FROM t_row_policy_or ORDER BY id; + +DROP ROW POLICY 04098_p1 ON t_row_policy_or; +DROP ROW POLICY 04098_p2 ON t_row_policy_or; +DROP ROW POLICY 04098_p3 ON t_row_policy_or; +DROP TABLE t_row_policy_or; From abfd09725b76a35777e37593da077444933e5d5b Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Sun, 19 Apr 2026 10:26:56 +0000 Subject: [PATCH 21/70] Backport #99957 to 26.3: Revert #97114 Move join step row estimation before check for 1 child" --- .../QueryPlan/Optimizations/optimizeJoin.cpp | 16 ++++++++-------- ...correlated_subquery_exists_asterisk.reference | 2 +- ...subquery_ndv_propagation_join_order.reference | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp b/src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp index b1f5f553a0cf..d3425b283f2a 100644 --- a/src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp +++ b/src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp @@ -305,14 +305,6 @@ RelationStats estimateReadRowsCount(QueryPlan::Node & node, const ActionsDAG::No return estimateReadRowsCount(*reading->getSubplanReferenceRoot(), filter); } - if (const auto * join_step = typeid_cast(step); join_step && join_step->isOptimized()) - { - return RelationStats{ - .estimated_rows = join_step->getResultRowsEstimation(), - .column_stats = join_step->getResultColumnStats(), - .table_name = join_step->getReadableRelationName()}; - } - if (node.children.size() != 1) return {}; @@ -348,6 +340,14 @@ RelationStats estimateReadRowsCount(QueryPlan::Node & node, const ActionsDAG::No return aggregation_stats; } + if (const auto * join_step = typeid_cast(step); join_step && join_step->isOptimized()) + { + return RelationStats{ + .estimated_rows = join_step->getResultRowsEstimation(), + .column_stats = join_step->getResultColumnStats(), + .table_name = join_step->getReadableRelationName()}; + } + if (const auto * sorting_step = typeid_cast(step)) { auto stats = estimateReadRowsCount(*node.children.front(), filter); diff --git a/tests/queries/0_stateless/03545_analyzer_correlated_subquery_exists_asterisk.reference b/tests/queries/0_stateless/03545_analyzer_correlated_subquery_exists_asterisk.reference index 690b0dbea9fa..ac9e84fd0a6c 100644 --- a/tests/queries/0_stateless/03545_analyzer_correlated_subquery_exists_asterisk.reference +++ b/tests/queries/0_stateless/03545_analyzer_correlated_subquery_exists_asterisk.reference @@ -10,7 +10,7 @@ Positions: 2 Join (JOIN FillRightFirst) Type: LEFT Strictness: SEMI - Algorithm: HashJoin + Algorithm: ConcurrentHashJoin Clauses: [(__table1.i1) = (exists(__table2).__table1.i1)] Expression (Left Pre Join Actions) Actions: INPUT :: 0 -> __table1.i1 Int64 : 0 diff --git a/tests/queries/0_stateless/03837_subquery_ndv_propagation_join_order.reference b/tests/queries/0_stateless/03837_subquery_ndv_propagation_join_order.reference index 1a7443ac6518..4382a0fbf373 100644 --- a/tests/queries/0_stateless/03837_subquery_ndv_propagation_join_order.reference +++ b/tests/queries/0_stateless/03837_subquery_ndv_propagation_join_order.reference @@ -1,14 +1,14 @@ JoinLogical - Join: sq[50000] ⋈ pc[300] ⋈ rs[200] - ResultRows: 60000 + Join: sq ⋈ rs[200] ⋈ pc[300] + ResultRows: unknown JoinLogical - Join: sq[50000] ⋈ pc[300] - ResultRows: 1500 + Join: sq ⋈ rs[200] + ResultRows: unknown Aggregating JoinLogical Join: s[50000] ⋈ p[10000] ResultRows: 50000 ReadFromMergeTree (default.test_sales) ReadFromMergeTree (default.test_partners) - ReadFromMergeTree (default.test_product_catalog) - ReadFromMergeTree (default.test_region_subsidies) + ReadFromMergeTree (default.test_region_subsidies) + ReadFromMergeTree (default.test_product_catalog) From bb5c3efa4d848788ed9311280287e999bc1e4ff9 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Mon, 20 Apr 2026 07:02:41 +0000 Subject: [PATCH 22/70] Backport #102918 to 26.3: Fix jemalloc metadata corruption caused by page cache freeing with wrong alignment --- src/Common/Allocator.cpp | 2 +- src/Common/Allocator.h | 6 +++--- src/Common/JemallocCacheAllocator.cpp | 11 +++++++---- src/Common/JemallocCacheAllocator.h | 2 +- src/Common/PageCache.cpp | 2 +- src/IO/BufferWithOwnMemory.h | 2 +- src/IO/tests/gtest_memory_resize.cpp | 2 +- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Common/Allocator.cpp b/src/Common/Allocator.cpp index fe573d64f524..2ca034eb17c9 100644 --- a/src/Common/Allocator.cpp +++ b/src/Common/Allocator.cpp @@ -141,7 +141,7 @@ void * Allocator::alloc(size_t size, size_t alignment) template -void Allocator::free(void * buf, size_t size) +void Allocator::free(void * buf, size_t size, size_t /* alignment */) { try { diff --git a/src/Common/Allocator.h b/src/Common/Allocator.h index 71977af7e73e..b584b015a7d3 100644 --- a/src/Common/Allocator.h +++ b/src/Common/Allocator.h @@ -46,7 +46,7 @@ class Allocator void * alloc(size_t size, size_t alignment = 0); /// Free memory range. - void free(void * buf, size_t size); + void free(void * buf, size_t size, size_t alignment = 0); /** Enlarge memory range. * Data from old range is moved to the beginning of new range. @@ -97,10 +97,10 @@ class AllocatorWithStackMemory : private Base return Base::alloc(size, Alignment); } - void free(void * buf, size_t size) + void free(void * buf, size_t size, size_t alignment = 0) { if (size > initial_bytes) - Base::free(buf, size); + Base::free(buf, size, alignment); } void * realloc(void * buf, size_t old_size, size_t new_size) diff --git a/src/Common/JemallocCacheAllocator.cpp b/src/Common/JemallocCacheAllocator.cpp index a58833310079..06dfd56176f6 100644 --- a/src/Common/JemallocCacheAllocator.cpp +++ b/src/Common/JemallocCacheAllocator.cpp @@ -41,9 +41,12 @@ int arenaFlags(size_t alignment) return flags; } -int freeFlags() +int freeFlags(size_t alignment) { - return MALLOCX_TCACHE_NONE; + int flags = MALLOCX_TCACHE_NONE; + if (alignment > MALLOC_MIN_ALIGNMENT) + flags |= MALLOCX_ALIGN(alignment); + return flags; } } @@ -65,12 +68,12 @@ void * JemallocCacheAllocator::alloc(size_t size, size_t alignment) return ptr; } -void JemallocCacheAllocator::free(void * buf, size_t size) +void JemallocCacheAllocator::free(void * buf, size_t size, size_t alignment) { try { checkSize(size); - je_sdallocx(buf, size, freeFlags()); + je_sdallocx(buf, size, freeFlags(alignment)); auto trace = CurrentMemoryTracker::free(size); trace.onFree(buf, size); } diff --git a/src/Common/JemallocCacheAllocator.h b/src/Common/JemallocCacheAllocator.h index 16b2d35c0b4d..3aaa44e52458 100644 --- a/src/Common/JemallocCacheAllocator.h +++ b/src/Common/JemallocCacheAllocator.h @@ -30,7 +30,7 @@ class JemallocCacheAllocator { public: void * alloc(size_t size, size_t alignment = 0); - void free(void * buf, size_t size); + void free(void * buf, size_t size, size_t alignment = 0); void * realloc(void * buf, size_t old_size, size_t new_size, size_t alignment = 0); protected: diff --git a/src/Common/PageCache.cpp b/src/Common/PageCache.cpp index 1f6bbe35a5ba..7789d4f3db5b 100644 --- a/src/Common/PageCache.cpp +++ b/src/Common/PageCache.cpp @@ -269,7 +269,7 @@ PageCacheCell::~PageCacheCell() std::optional blocker; if (!m_temporary) blocker.emplace(); - JemallocCacheAllocator().free(m_data, m_size); + JemallocCacheAllocator().free(m_data, m_size, DEFAULT_AIO_FILE_BLOCK_SIZE); } } diff --git a/src/IO/BufferWithOwnMemory.h b/src/IO/BufferWithOwnMemory.h index 23a0de76a7c7..138b7cab3afa 100644 --- a/src/IO/BufferWithOwnMemory.h +++ b/src/IO/BufferWithOwnMemory.h @@ -142,7 +142,7 @@ struct Memory : boost::noncopyable, Allocator if (!m_data) return; - Allocator::free(m_data, m_capacity); + Allocator::free(m_data, m_capacity, alignment); m_data = nullptr; /// To avoid double free if next alloc will throw an exception. } }; diff --git a/src/IO/tests/gtest_memory_resize.cpp b/src/IO/tests/gtest_memory_resize.cpp index a54baf828994..339bf07f0a91 100644 --- a/src/IO/tests/gtest_memory_resize.cpp +++ b/src/IO/tests/gtest_memory_resize.cpp @@ -51,7 +51,7 @@ class DummyAllocator return dummy_address; } - void free([[maybe_unused]] void * buf, size_t /*size*/) + void free([[maybe_unused]] void * buf, size_t /*size*/, size_t /*alignment*/ = 0) { assert(buf == dummy_address); } From 87b5b594e05cc691c7572a6906e401ddc35a4eae Mon Sep 17 00:00:00 2001 From: Nikolay Degterinsky <43110995+evillique@users.noreply.github.com> Date: Mon, 20 Apr 2026 19:14:20 +0200 Subject: [PATCH 23/70] Update 02995_settings_26_2_1.tsv --- tests/queries/0_stateless/02995_settings_26_2_1.tsv | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/queries/0_stateless/02995_settings_26_2_1.tsv b/tests/queries/0_stateless/02995_settings_26_2_1.tsv index 17550d7ed430..4846200cf459 100644 --- a/tests/queries/0_stateless/02995_settings_26_2_1.tsv +++ b/tests/queries/0_stateless/02995_settings_26_2_1.tsv @@ -530,6 +530,7 @@ function_locate_has_mysql_compatible_argument_order 1 function_range_max_elements_in_block 500000000 function_sleep_max_microseconds_per_block 3000000 function_visible_width_behavior 1 +functions_h3_default_if_invalid 1 geo_distance_returns_float64_on_float64_arguments 1 geotoh3_argument_order lat_lon glob_expansion_max_elements 1000 From 21e8753ce91e6a626dd4027d55e303f6e97eac27 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Mon, 20 Apr 2026 17:37:04 +0000 Subject: [PATCH 24/70] Backport #103160 to 26.3: CI: disable automerge for backport branches --- ci/workflows/backport_branches.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/workflows/backport_branches.py b/ci/workflows/backport_branches.py index 30a9374d04f7..e64945352aed 100644 --- a/ci/workflows/backport_branches.py +++ b/ci/workflows/backport_branches.py @@ -49,7 +49,7 @@ enable_job_filtering_by_changes=True, enable_cache=True, enable_report=True, - enable_automerge=True, + enable_automerge=False, enable_cidb=True, enable_commit_status_on_failure=True, enable_gh_summary_comment=True, From 60c20b69488192f4e56174c695df6574d764f470 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Mon, 20 Apr 2026 20:28:03 +0000 Subject: [PATCH 25/70] Backport #103065 to 26.3: Expose per-thread untracked_memory in system.stack_trace --- src/Storages/System/StorageSystemStackTrace.cpp | 11 ++++++++++- .../02117_show_create_table_system.reference | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Storages/System/StorageSystemStackTrace.cpp b/src/Storages/System/StorageSystemStackTrace.cpp index 783499ebac70..8b77b31217ca 100644 --- a/src/Storages/System/StorageSystemStackTrace.cpp +++ b/src/Storages/System/StorageSystemStackTrace.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -105,6 +106,8 @@ constexpr size_t max_query_id_size = 128; char query_id_data[max_query_id_size]; size_t query_id_size = 0; +Int64 untracked_memory_data = 0; + LazyPipeFDs notification_pipe; #ifdef OS_LINUX @@ -164,6 +167,8 @@ void signalHandler(int, siginfo_t * info, void * context) if (!query_id.empty()) memcpy(query_id_data, query_id.data(), query_id_size); + untracked_memory_data = current_thread ? current_thread->untracked_memory : 0; + /// This is unneeded (because we synchronize through pipe) but makes TSan happy. data_ready_num.store(notification_num, std::memory_order_release); @@ -405,7 +410,7 @@ class StackTraceSource : public ISource { /// Create a mask of what columns are needed in the result. NameSet names_set(column_names.begin(), column_names.end()); - send_signal = names_set.contains("trace") || names_set.contains("query_id"); + send_signal = names_set.contains("trace") || names_set.contains("query_id") || names_set.contains("untracked_memory"); read_thread_names = names_set.contains("thread_name"); #ifdef OS_DARWIN @@ -464,6 +469,7 @@ class StackTraceSource : public ISource res_columns[res_index++]->insert(tid); res_columns[res_index++]->insertDefault(); res_columns[res_index++]->insertDefault(); + res_columns[res_index++]->insertDefault(); } else { @@ -567,6 +573,7 @@ class StackTraceSource : public ISource res_columns[res_index++]->insert(tid); res_columns[res_index++]->insertData(query_id_data, query_id_size); res_columns[res_index++]->insert(arr); + res_columns[res_index++]->insert(untracked_memory_data); continue; } @@ -581,6 +588,7 @@ class StackTraceSource : public ISource res_columns[res_index++]->insert(tid); res_columns[res_index++]->insertDefault(); res_columns[res_index++]->insertDefault(); + res_columns[res_index++]->insertDefault(); } } LOG_TRACE(log, "Send signal to {} threads (total), took {} ms", signals_sent, signals_sent_ms); @@ -723,6 +731,7 @@ StorageSystemStackTrace::StorageSystemStackTrace(const StorageID & table_id_) {"thread_id", std::make_shared(), "The thread identifier"}, {"query_id", std::make_shared(), "The ID of the query this thread belongs to."}, {"trace", std::make_shared(std::make_shared()), "The stacktrace of this thread. Basically just an array of addresses."}, + {"untracked_memory", std::make_shared(), "Per-thread atomic-less counter of memory allocations not yet propagated to the parent MemoryTracker. May be negative if more was freed than allocated since the last flush."}, })); setInMemoryMetadata(storage_metadata); diff --git a/tests/queries/0_stateless/02117_show_create_table_system.reference b/tests/queries/0_stateless/02117_show_create_table_system.reference index 367a81453db7..d452faa93f1a 100644 --- a/tests/queries/0_stateless/02117_show_create_table_system.reference +++ b/tests/queries/0_stateless/02117_show_create_table_system.reference @@ -1089,7 +1089,8 @@ CREATE TABLE system.stack_trace `thread_name` String, `thread_id` UInt64, `query_id` String, - `trace` Array(UInt64) + `trace` Array(UInt64), + `untracked_memory` Int64 ) ENGINE = SystemStackTrace COMMENT 'Allows to obtain an unsymbolized stacktrace from all the threads of the server process.' From b8055af70eaf801b2dbfdc2e2461c4e18d5838df Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Mon, 20 Apr 2026 20:29:08 +0000 Subject: [PATCH 26/70] Backport #102999 to 26.3: Reintroduce ArrowMemoryPool to allow throwing MEMORY_LIMIT_EXCEEDED to avoid kernel OOM --- .../Formats/Impl/ArrowBlockInputFormat.cpp | 4 +- .../Formats/Impl/ArrowBufferedStreams.cpp | 76 ++++++++++++++++++- .../Formats/Impl/ArrowBufferedStreams.h | 28 +++++++ .../Formats/Impl/ArrowColumnToCHColumn.cpp | 3 +- .../Formats/Impl/CHColumnToArrowColumn.cpp | 4 +- .../Formats/Impl/ORCBlockInputFormat.cpp | 2 +- .../Formats/Impl/ParquetBlockInputFormat.cpp | 4 +- .../Formats/Impl/ParquetBlockOutputFormat.cpp | 2 +- src/Storages/Hive/HiveFile.cpp | 4 +- .../DataLakes/DeltaLakeMetadata.cpp | 2 +- 10 files changed, 113 insertions(+), 16 deletions(-) diff --git a/src/Processors/Formats/Impl/ArrowBlockInputFormat.cpp b/src/Processors/Formats/Impl/ArrowBlockInputFormat.cpp index 433439878376..6cce6530d789 100644 --- a/src/Processors/Formats/Impl/ArrowBlockInputFormat.cpp +++ b/src/Processors/Formats/Impl/ArrowBlockInputFormat.cpp @@ -166,7 +166,7 @@ static std::shared_ptr createStreamReader(ReadBuffer & } auto options = arrow::ipc::IpcReadOptions::Defaults(); - options.memory_pool = arrow::default_memory_pool(); + options.memory_pool = ArrowMemoryPool::instance(); auto stream_reader_status = arrow::ipc::RecordBatchStreamReader::Open(std::make_unique(in), options); if (!stream_reader_status.ok()) throw Exception(ErrorCodes::UNKNOWN_EXCEPTION, @@ -181,7 +181,7 @@ static std::shared_ptr createFileReader(ReadB return nullptr; auto options = arrow::ipc::IpcReadOptions::Defaults(); - options.memory_pool = arrow::default_memory_pool(); + options.memory_pool = ArrowMemoryPool::instance(); auto file_reader_status = arrow::ipc::RecordBatchFileReader::Open(arrow_file, options); if (!file_reader_status.ok()) throw Exception(ErrorCodes::UNKNOWN_EXCEPTION, diff --git a/src/Processors/Formats/Impl/ArrowBufferedStreams.cpp b/src/Processors/Formats/Impl/ArrowBufferedStreams.cpp index 6ea0d70977c6..4699b1b2fdf0 100644 --- a/src/Processors/Formats/Impl/ArrowBufferedStreams.cpp +++ b/src/Processors/Formats/Impl/ArrowBufferedStreams.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -98,7 +99,7 @@ arrow::Result RandomAccessFileFromSeekableReadBuffer::Read(int64_t nbyt arrow::Result> RandomAccessFileFromSeekableReadBuffer::Read(int64_t nbytes) { - ARROW_ASSIGN_OR_RAISE(auto buffer, arrow::AllocateResizableBuffer(nbytes, arrow::default_memory_pool())) + ARROW_ASSIGN_OR_RAISE(auto buffer, arrow::AllocateResizableBuffer(nbytes, ArrowMemoryPool::instance())) ARROW_ASSIGN_OR_RAISE(int64_t bytes_read, Read(nbytes, buffer->mutable_data())) if (bytes_read < nbytes) @@ -155,7 +156,7 @@ arrow::Result ArrowInputStreamFromReadBuffer::Read(int64_t nbytes, void arrow::Result> ArrowInputStreamFromReadBuffer::Read(int64_t nbytes) { - ARROW_ASSIGN_OR_RAISE(auto buffer, arrow::AllocateResizableBuffer(nbytes, arrow::default_memory_pool())) + ARROW_ASSIGN_OR_RAISE(auto buffer, arrow::AllocateResizableBuffer(nbytes, ArrowMemoryPool::instance())) ARROW_ASSIGN_OR_RAISE(int64_t bytes_read, Read(nbytes, buffer->mutable_data())) if (bytes_read < nbytes) @@ -208,7 +209,7 @@ arrow::Result RandomAccessFileFromRandomAccessReadBuffer::ReadAt(int64_ arrow::Result> RandomAccessFileFromRandomAccessReadBuffer::ReadAt(int64_t position, int64_t nbytes) { - ARROW_ASSIGN_OR_RAISE(auto buffer, arrow::AllocateResizableBuffer(nbytes, arrow::default_memory_pool())) + ARROW_ASSIGN_OR_RAISE(auto buffer, arrow::AllocateResizableBuffer(nbytes, ArrowMemoryPool::instance())) ARROW_ASSIGN_OR_RAISE(int64_t bytes_read, ReadAt(position, nbytes, buffer->mutable_data())) if (bytes_read < nbytes) @@ -248,6 +249,75 @@ arrow::Result RandomAccessFileFromRandomAccessReadBuffer::Tell() const arrow::Result RandomAccessFileFromRandomAccessReadBuffer::Read(int64_t, void*) { return arrow::Status::NotImplemented(""); } arrow::Result> RandomAccessFileFromRandomAccessReadBuffer::Read(int64_t) { return arrow::Status::NotImplemented(""); } +ArrowMemoryPool * ArrowMemoryPool::instance() +{ + static ArrowMemoryPool x; + return &x; +} + +arrow::Status ArrowMemoryPool::Allocate(int64_t size, int64_t alignment, uint8_t ** out) +{ + if (size == 0) + { + *out = arrow::memory_pool::internal::kZeroSizeArea; + return arrow::Status::OK(); + } + + try + { + void * p = Allocator().alloc(size_t(size), size_t(alignment)); + *out = reinterpret_cast(p); + } + catch (...) + { + return arrow::Status::OutOfMemory("allocation of size ", size, " failed: ", getCurrentExceptionMessage(false)); + } + + stats.DidAllocateBytes(size); + return arrow::Status::OK(); +} + +arrow::Status ArrowMemoryPool::Reallocate(int64_t old_size, int64_t new_size, int64_t alignment, uint8_t ** ptr) +{ + if (old_size == 0) + { + chassert(*ptr == arrow::memory_pool::internal::kZeroSizeArea); + return Allocate(new_size, alignment, ptr); + } + if (new_size == 0) + { + Free(*ptr, old_size, alignment); + *ptr = arrow::memory_pool::internal::kZeroSizeArea; + return arrow::Status::OK(); + } + + try + { + void * p = Allocator().realloc(*ptr, size_t(old_size), size_t(new_size), size_t(alignment)); + *ptr = reinterpret_cast(p); + } + catch (...) + { + return arrow::Status::OutOfMemory("reallocation of size ", new_size, " failed: ", getCurrentExceptionMessage(false)); + } + + stats.DidReallocateBytes(old_size, new_size); + return arrow::Status::OK(); +} + +void ArrowMemoryPool::Free(uint8_t * buffer, int64_t size, int64_t alignment) +{ + if (size == 0) + { + chassert(buffer == arrow::memory_pool::internal::kZeroSizeArea); + return; + } + + Allocator().free(buffer, size_t(size), alignment); + stats.DidFreeBytes(size); +} + + std::shared_ptr asArrowFile( ReadBuffer & in, const FormatSettings & settings, diff --git a/src/Processors/Formats/Impl/ArrowBufferedStreams.h b/src/Processors/Formats/Impl/ArrowBufferedStreams.h index cbfe1a039674..ecb6ef8cb6fe 100644 --- a/src/Processors/Formats/Impl/ArrowBufferedStreams.h +++ b/src/Processors/Formats/Impl/ArrowBufferedStreams.h @@ -131,6 +131,34 @@ class ArrowInputStreamFromReadBuffer : public arrow::io::InputStream ARROW_DISALLOW_COPY_AND_ASSIGN(ArrowInputStreamFromReadBuffer); }; +/// By default, arrow allocates memory using posix_memalign(). Our posix_memalign +/// interceptor tracks memory, but cannot throw on `MEMORY_LIMIT_EXCEEDED` (throwing +/// from `malloc`/`posix_memalign` is not allowed because callers, including inside +/// arrow/parquet, do not expect it). This adapter routes arrow/parquet allocations +/// through ClickHouse's `Allocator`, which *can* throw +/// `MEMORY_LIMIT_EXCEEDED`; we catch it and convert to `arrow::Status::OutOfMemory` +/// so arrow unwinds via its normal error path. +class ArrowMemoryPool : public arrow::MemoryPool +{ +public: + static ArrowMemoryPool * instance(); + + arrow::Status Allocate(int64_t size, int64_t alignment, uint8_t ** out) override; + arrow::Status Reallocate(int64_t old_size, int64_t new_size, int64_t alignment, uint8_t ** ptr) override; + void Free(uint8_t * buffer, int64_t size, int64_t alignment) override; + + std::string backend_name() const override { return "clickhouse"; } + + int64_t bytes_allocated() const override { return stats.bytes_allocated(); } + int64_t total_bytes_allocated() const override { return stats.total_bytes_allocated(); } + int64_t num_allocations() const override { return stats.num_allocations(); } + +private: + ArrowMemoryPool() = default; + + arrow::internal::MemoryPoolStats stats; +}; + std::shared_ptr asArrowFile( ReadBuffer & in, const FormatSettings & settings, diff --git a/src/Processors/Formats/Impl/ArrowColumnToCHColumn.cpp b/src/Processors/Formats/Impl/ArrowColumnToCHColumn.cpp index dac72f844453..1ed34febcd15 100644 --- a/src/Processors/Formats/Impl/ArrowColumnToCHColumn.cpp +++ b/src/Processors/Formats/Impl/ArrowColumnToCHColumn.cpp @@ -1465,8 +1465,7 @@ static void checkStatus(const arrow::Status & status, const String & column_name static std::shared_ptr createArrowColumn(const std::shared_ptr & field, const String & format_name) { std::unique_ptr array_builder; - /// default_memory_pool() uses posix_memalign which is intercepted and counted in MemoryTracker. - arrow::Status status = MakeBuilder(arrow::default_memory_pool(), field->type(), &array_builder); + arrow::Status status = MakeBuilder(ArrowMemoryPool::instance(), field->type(), &array_builder); checkStatus(status, field->name(), format_name); std::shared_ptr arrow_array; diff --git a/src/Processors/Formats/Impl/CHColumnToArrowColumn.cpp b/src/Processors/Formats/Impl/CHColumnToArrowColumn.cpp index e69b69d1cfad..5acfa96721c6 100644 --- a/src/Processors/Formats/Impl/CHColumnToArrowColumn.cpp +++ b/src/Processors/Formats/Impl/CHColumnToArrowColumn.cpp @@ -453,7 +453,7 @@ namespace DB /// Convert dictionary values to arrow array. auto value_type = assert_cast(builder->type().get())->value_type(); std::unique_ptr values_builder; - arrow::Status status = MakeBuilder(arrow::default_memory_pool(), value_type, &values_builder); + arrow::Status status = MakeBuilder(ArrowMemoryPool::instance(), value_type, &values_builder); checkStatus(status, column->getName(), format_name); auto dict_column = dynamic_cast(*dict_values).getNestedNotNullableColumn(); @@ -1203,7 +1203,7 @@ namespace DB column = recursiveRemoveLowCardinality(column); std::unique_ptr array_builder; - arrow::Status status = MakeBuilder(arrow::default_memory_pool(), arrow_schema->field(static_cast(column_i))->type(), &array_builder); + arrow::Status status = MakeBuilder(ArrowMemoryPool::instance(), arrow_schema->field(static_cast(column_i))->type(), &array_builder); checkStatus(status, column->getName(), format_name); fillArrowArray( diff --git a/src/Processors/Formats/Impl/ORCBlockInputFormat.cpp b/src/Processors/Formats/Impl/ORCBlockInputFormat.cpp index c89e369a7b62..6c08be61bc9e 100644 --- a/src/Processors/Formats/Impl/ORCBlockInputFormat.cpp +++ b/src/Processors/Formats/Impl/ORCBlockInputFormat.cpp @@ -114,7 +114,7 @@ static void getFileReaderAndSchema( if (is_stopped) return; - auto result = arrow::adapters::orc::ORCFileReader::Open(arrow_file, arrow::default_memory_pool()); + auto result = arrow::adapters::orc::ORCFileReader::Open(arrow_file, ArrowMemoryPool::instance()); if (!result.ok()) throw Exception::createDeprecated(result.status().ToString(), ErrorCodes::BAD_ARGUMENTS); file_reader = std::move(result).ValueOrDie(); diff --git a/src/Processors/Formats/Impl/ParquetBlockInputFormat.cpp b/src/Processors/Formats/Impl/ParquetBlockInputFormat.cpp index 9e5fe77e3d9f..2a88c7f000c9 100644 --- a/src/Processors/Formats/Impl/ParquetBlockInputFormat.cpp +++ b/src/Processors/Formats/Impl/ParquetBlockInputFormat.cpp @@ -883,7 +883,7 @@ void ParquetBlockInputFormat::initializeRowGroupBatchReader(size_t row_group_bat auto & row_group_batch = row_group_batches[row_group_batch_idx]; parquet::ArrowReaderProperties arrow_properties; - parquet::ReaderProperties reader_properties(arrow::default_memory_pool()); + parquet::ReaderProperties reader_properties(ArrowMemoryPool::instance()); arrow_properties.set_use_threads(false); arrow_properties.set_batch_size(row_group_batch.adaptive_chunk_size); reader_properties.set_page_checksum_verification(format_settings.parquet.verify_checksums); @@ -940,7 +940,7 @@ void ParquetBlockInputFormat::initializeRowGroupBatchReader(size_t row_group_bat parquet::arrow::FileReaderBuilder builder; THROW_ARROW_NOT_OK(builder.Open(arrow_file, reader_properties, metadata)); builder.properties(arrow_properties); - builder.memory_pool(arrow::default_memory_pool()); + builder.memory_pool(ArrowMemoryPool::instance()); // should get raw reader before build, raw_reader will set null after build auto * parquet_file_reader = builder.raw_reader(); THROW_ARROW_NOT_OK(builder.Build(&row_group_batch.file_reader)); diff --git a/src/Processors/Formats/Impl/ParquetBlockOutputFormat.cpp b/src/Processors/Formats/Impl/ParquetBlockOutputFormat.cpp index 416f8cb1752c..3e938fddea10 100644 --- a/src/Processors/Formats/Impl/ParquetBlockOutputFormat.cpp +++ b/src/Processors/Formats/Impl/ParquetBlockOutputFormat.cpp @@ -378,7 +378,7 @@ void ParquetBlockOutputFormat::writeUsingArrow(std::vector chunks) auto result = parquet::arrow::FileWriter::Open( *arrow_table->schema(), - arrow::default_memory_pool(), + ArrowMemoryPool::instance(), sink, builder.build(), writer_props_builder.build()); diff --git a/src/Storages/Hive/HiveFile.cpp b/src/Storages/Hive/HiveFile.cpp index 9677cfc69bde..18c9bf27a6f6 100644 --- a/src/Storages/Hive/HiveFile.cpp +++ b/src/Storages/Hive/HiveFile.cpp @@ -166,7 +166,7 @@ void HiveORCFile::prepareReader() in = std::make_unique(namenode_url, path, getContext()->getGlobalContext()->getConfigRef(), getContext()->getReadSettings()); auto format_settings = getFormatSettings(getContext()); std::atomic is_stopped{0}; - auto result = arrow::adapters::orc::ORCFileReader::Open(asArrowFile(*in, format_settings, is_stopped, "ORC", ORC_MAGIC_BYTES), arrow::default_memory_pool()); + auto result = arrow::adapters::orc::ORCFileReader::Open(asArrowFile(*in, format_settings, is_stopped, "ORC", ORC_MAGIC_BYTES), ArrowMemoryPool::instance()); THROW_ARROW_NOT_OK(result.status()); reader = std::move(result).ValueOrDie(); } @@ -285,7 +285,7 @@ void HiveParquetFile::prepareReader() in = std::make_unique(namenode_url, path, getContext()->getGlobalContext()->getConfigRef(), getContext()->getReadSettings()); auto format_settings = getFormatSettings(getContext()); std::atomic is_stopped{0}; - auto open_file_res = parquet::arrow::OpenFile(asArrowFile(*in, format_settings, is_stopped, "Parquet", PARQUET_MAGIC_BYTES), arrow::default_memory_pool()); + auto open_file_res = parquet::arrow::OpenFile(asArrowFile(*in, format_settings, is_stopped, "Parquet", PARQUET_MAGIC_BYTES), ArrowMemoryPool::instance()); THROW_ARROW_NOT_OK(open_file_res.status()); reader = *std::move(open_file_res); } diff --git a/src/Storages/ObjectStorage/DataLakes/DeltaLakeMetadata.cpp b/src/Storages/ObjectStorage/DataLakes/DeltaLakeMetadata.cpp index afc12cee5e5e..22b0dd7cd013 100644 --- a/src/Storages/ObjectStorage/DataLakes/DeltaLakeMetadata.cpp +++ b/src/Storages/ObjectStorage/DataLakes/DeltaLakeMetadata.cpp @@ -499,7 +499,7 @@ struct DeltaLakeMetadataImpl std::atomic is_stopped{0}; auto open_file_res = parquet::arrow::OpenFile( - asArrowFile(*buf, format_settings, is_stopped, "Parquet", PARQUET_MAGIC_BYTES), arrow::default_memory_pool()); + asArrowFile(*buf, format_settings, is_stopped, "Parquet", PARQUET_MAGIC_BYTES), ArrowMemoryPool::instance()); THROW_ARROW_NOT_OK(open_file_res.status()); auto reader = *std::move(open_file_res); From 85e3e177d5e0a0d3ad8c9339bf275eb0f2497d4b Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Tue, 21 Apr 2026 01:48:16 +0000 Subject: [PATCH 27/70] Backport #102900 to 26.3: Fix several optimizations after lightweight deletes [2] --- .../optimizeUseAggregateProjection.cpp | 5 +- src/Storages/IStorage.h | 3 - src/Storages/MergeTree/MergeTask.cpp | 5 +- src/Storages/MergeTree/MergeTreeData.cpp | 65 +++++++++------- src/Storages/MergeTree/MergeTreeData.h | 20 +++-- .../MergeTree/StorageFromMergeTreeDataPart.h | 2 +- src/Storages/StorageAlias.h | 1 - src/Storages/StorageMergeTree.cpp | 5 -- src/Storages/StorageMergeTree.h | 2 - src/Storages/StorageReplicatedMergeTree.cpp | 5 -- src/Storages/StorageReplicatedMergeTree.h | 2 - ...8_lwd_minmax_projection_recovery.reference | 13 ++++ .../04068_lwd_minmax_projection_recovery.sql | 78 +++++++++++++++++++ ...d_minmax_projection_recovery_rmt.reference | 7 ++ ...068_lwd_minmax_projection_recovery_rmt.sql | 60 ++++++++++++++ 15 files changed, 217 insertions(+), 56 deletions(-) create mode 100644 tests/queries/0_stateless/04068_lwd_minmax_projection_recovery.reference create mode 100644 tests/queries/0_stateless/04068_lwd_minmax_projection_recovery.sql create mode 100644 tests/queries/0_stateless/04068_lwd_minmax_projection_recovery_rmt.reference create mode 100644 tests/queries/0_stateless/04068_lwd_minmax_projection_recovery_rmt.sql diff --git a/src/Processors/QueryPlan/Optimizations/optimizeUseAggregateProjection.cpp b/src/Processors/QueryPlan/Optimizations/optimizeUseAggregateProjection.cpp index 751ae690e088..cac258e1f5d1 100644 --- a/src/Processors/QueryPlan/Optimizations/optimizeUseAggregateProjection.cpp +++ b/src/Processors/QueryPlan/Optimizations/optimizeUseAggregateProjection.cpp @@ -362,8 +362,9 @@ AggregateProjectionCandidates getAggregateProjectionCandidates( if (projection.type == ProjectionDescription::Type::Aggregate) agg_projections.push_back(&projection); - bool can_use_minmax_projection = allow_implicit_projections && metadata->minmax_count_projection - && !reading.getMergeTreeData().has_lightweight_delete_parts.load(); + bool can_use_minmax_projection = allow_implicit_projections + && metadata->minmax_count_projection + && !reading.getMutationsSnapshot()->hasLightweightDeletedMask(); if (!can_use_minmax_projection && agg_projections.empty()) return candidates; diff --git a/src/Storages/IStorage.h b/src/Storages/IStorage.h index c166225ea058..0c0d38886d06 100644 --- a/src/Storages/IStorage.h +++ b/src/Storages/IStorage.h @@ -272,9 +272,6 @@ class IStorage : public std::enable_shared_from_this, public TypePromo /// is_restore_from_backup = true in StorageFactory::Arguments). virtual void finalizeRestoreFromBackup() {} - /// Return true if there is at least one part containing lightweight deleted mask. - virtual bool hasLightweightDeletedMask() const { return false; } - /// Return true if storage can execute lightweight delete mutations. virtual bool supportsLightweightDelete() const { return false; } diff --git a/src/Storages/MergeTree/MergeTask.cpp b/src/Storages/MergeTree/MergeTask.cpp index e27ce4b0fd95..20280ab948b2 100644 --- a/src/Storages/MergeTree/MergeTask.cpp +++ b/src/Storages/MergeTree/MergeTask.cpp @@ -671,15 +671,18 @@ bool MergeTask::ExecuteAndFinalizeHorizontalPart::prepare() const if (enabledBlockOffsetColumn(global_ctx)) addGatheringColumn(global_ctx, BlockOffsetColumn::name, BlockOffsetColumn::type); + auto parts_info = MergeTreeData::getPartsSnapshotInfo(global_ctx->future_part->parts); + MergeTreeData::IMutationsSnapshot::Params params { .metadata_version = global_ctx->metadata_snapshot->getMetadataVersion(), - .min_part_metadata_version = MergeTreeData::getMinMetadataVersion(global_ctx->future_part->parts), + .min_part_metadata_version = parts_info.min_metadata_version, .min_part_data_versions = nullptr, .max_mutation_versions = nullptr, .need_data_mutations = false, .need_alter_mutations = !patch_parts.empty(), .need_patch_parts = false, + .has_lightweight_delete_parts = parts_info.has_lightweight_delete_parts, }; auto mutations_snapshot = global_ctx->data->getMutationsSnapshot(params); diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index b7f36962b0b6..d1c4c984a5f5 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -5224,7 +5224,6 @@ bool MergeTreeData::renameTempPartAndReplaceImpl( if (hierarchy.duplicate_part) throw Exception(ErrorCodes::LOGICAL_ERROR, "Unexpected duplicate part {}. It is a bug.", hierarchy.duplicate_part->getNameWithState()); - if (part->hasLightweightDelete()) has_lightweight_delete_parts.store(true); @@ -10409,50 +10408,55 @@ SerializationInfoByName MergeTreeData::getSerializationHints() const bool MergeTreeData::supportsTrivialCountOptimization(const StorageSnapshotPtr & storage_snapshot, ContextPtr query_context) const { - if (hasLightweightDeletedMask()) - return false; - const auto & settings = query_context->getSettingsRef(); + + auto supports_trivial_count = [&]() + { + /// Fallback for callers that don't provide a storage snapshot (e.g. StorageMerge). + return !has_lightweight_delete_parts.load(std::memory_order_relaxed) && !settings[Setting::apply_mutations_on_fly] && !settings[Setting::apply_patch_parts]; + }; + if (!storage_snapshot) - return !settings[Setting::apply_mutations_on_fly] && !settings[Setting::apply_patch_parts]; + return supports_trivial_count(); const auto & snapshot_data = assert_cast(*storage_snapshot->data); const auto & mutations_snapshot = snapshot_data.mutations_snapshot; if (!mutations_snapshot) - return !settings[Setting::apply_mutations_on_fly] && !settings[Setting::apply_patch_parts]; + return supports_trivial_count(); - return !mutations_snapshot->hasDataMutations() && !mutations_snapshot->hasPatchParts(); + return !mutations_snapshot->hasDataMutations() && !mutations_snapshot->hasPatchParts() && !mutations_snapshot->hasLightweightDeletedMask(); } -Int64 MergeTreeData::getMinMetadataVersion(const DataPartsVector & parts) +MergeTreeData::PartsSnapshotInfo MergeTreeData::getPartsSnapshotInfo(const DataPartsVector & parts) { - Int64 version = -1; + PartsSnapshotInfo info; + PartitionIdToMinBlock min_data_versions; + for (const auto & part : parts) { - Int64 part_version = part->getMetadataVersion(); - if (version == -1 || part_version < version) - version = part_version; - } - return version; -} + { + Int64 part_metadata_version = part->getMetadataVersion(); + if (info.min_metadata_version == -1 || part_metadata_version < info.min_metadata_version) + info.min_metadata_version = part_metadata_version; + } -MergeTreeData::PartitionIdToMinBlockPtr MergeTreeData::getMinDataVersionForEachPartition(const DataPartsVector & parts) -{ - PartitionIdToMinBlock partition_to_min_data_version; + { + const String & partition_id = part->info.getPartitionId(); + const Int64 data_version = part->info.getDataVersion(); - for (const auto & part : parts) - { - const String & partition_id = part->info.getPartitionId(); - const Int64 data_version = part->info.getDataVersion(); + if (auto it = min_data_versions.find(partition_id); it != min_data_versions.end()) + it->second = std::min(it->second, data_version); + else + min_data_versions.emplace(partition_id, data_version); + } - if (auto partition_it = partition_to_min_data_version.find(partition_id); partition_it != partition_to_min_data_version.end()) - partition_it->second = std::min(partition_it->second, data_version); - else - partition_to_min_data_version.emplace(partition_id, data_version); + if (!info.has_lightweight_delete_parts && part->hasLightweightDelete()) + info.has_lightweight_delete_parts = true; } - return std::make_shared(std::move(partition_to_min_data_version)); + info.min_data_versions = std::make_shared(std::move(min_data_versions)); + return info; } MergeTreeSettingsPtr MergeTreeData::getSettings(ProjectionDescriptionRawPtr projection) const @@ -10509,18 +10513,21 @@ MergeTreeData::createStorageSnapshot(const StorageMetadataPtr & metadata_snapsho auto [query_ranges, query_parts] = getPossiblySharedVisibleDataPartsRanges(query_context); snapshot_data->parts = query_ranges; + auto parts_info = getPartsSnapshotInfo(*query_parts); + bool apply_mutations_on_fly = query_context->getSettingsRef()[Setting::apply_mutations_on_fly]; bool apply_patch_parts = query_context->getSettingsRef()[Setting::apply_patch_parts]; IMutationsSnapshot::Params params { .metadata_version = metadata_snapshot->getMetadataVersion(), - .min_part_metadata_version = getMinMetadataVersion(*query_parts), - .min_part_data_versions = getMinDataVersionForEachPartition(*query_parts), + .min_part_metadata_version = parts_info.min_metadata_version, + .min_part_data_versions = std::move(parts_info.min_data_versions), .max_mutation_versions = query_context->getPartitionIdToMaxBlock(getStorageID().uuid), .need_data_mutations = apply_mutations_on_fly, .need_alter_mutations = apply_mutations_on_fly || apply_patch_parts, .need_patch_parts = apply_patch_parts, + .has_lightweight_delete_parts = parts_info.has_lightweight_delete_parts, }; snapshot_data->mutations_snapshot = getMutationsSnapshot(params); diff --git a/src/Storages/MergeTree/MergeTreeData.h b/src/Storages/MergeTree/MergeTreeData.h index 85d3f5f7ae0d..c2b1a4a50fde 100644 --- a/src/Storages/MergeTree/MergeTreeData.h +++ b/src/Storages/MergeTree/MergeTreeData.h @@ -562,6 +562,7 @@ class MergeTreeData : public WithMutableContext, public IStorage, public IBackgr bool need_data_mutations = false; bool need_alter_mutations = false; bool need_patch_parts = false; + bool has_lightweight_delete_parts = false; }; static Int64 getMinPartDataVersionForPartition(const Params & params, const String & partition_id); @@ -583,6 +584,7 @@ class MergeTreeData : public WithMutableContext, public IStorage, public IBackgr virtual bool hasDataMutations() const = 0; virtual bool hasAlterMutations() const = 0; virtual bool hasMetadataMutations() const = 0; + virtual bool hasLightweightDeletedMask() const = 0; }; struct MutationsSnapshotBase : public IMutationsSnapshot @@ -603,6 +605,7 @@ class MergeTreeData : public WithMutableContext, public IStorage, public IBackgr bool hasAlterMutations() const final { return counters.num_alter > 0; } bool hasMetadataMutations() const final { return counters.num_metadata > 0; } bool hasAnyMutations() const { return hasDataMutations() || hasAlterMutations() || hasMetadataMutations(); } + bool hasLightweightDeletedMask() const final { return params.has_lightweight_delete_parts; } protected: NameSet getColumnsUpdatedInPatches() const; @@ -1199,11 +1202,16 @@ class MergeTreeData : public WithMutableContext, public IStorage, public IBackgr /// Returns a snapshot of mutations that probably will be applied on the fly to parts during reading. virtual MutationsSnapshotPtr getMutationsSnapshot(const IMutationsSnapshot::Params & params) const = 0; - /// Returns the minimum version of metadata among parts. - static Int64 getMinMetadataVersion(const DataPartsVector & parts); + /// Computes snapshot-related part statistics in a single pass: + /// min metadata version, per-partition min data version, and whether any part has a lightweight delete mask. + struct PartsSnapshotInfo + { + Int64 min_metadata_version = -1; + PartitionIdToMinBlockPtr min_data_versions; + bool has_lightweight_delete_parts = false; + }; - /// Returns minimum data version among parts inside each of the partitions. - static PartitionIdToMinBlockPtr getMinDataVersionForEachPartition(const DataPartsVector & parts); + static PartsSnapshotInfo getPartsSnapshotInfo(const DataPartsVector & parts); /// Return alter conversions for part which must be applied on fly. static AlterConversionsPtr getAlterConversionsForPart( @@ -1291,7 +1299,9 @@ class MergeTreeData : public WithMutableContext, public IStorage, public IBackgr bool has_non_adaptive_index_granularity_parts = false; - /// True if at least one part contains lightweight delete. + /// True if at least one part contains a lightweight delete mask. + /// Used as a fallback in `supportsTrivialCountOptimization` when + /// no storage snapshot is available (e.g. from `StorageMerge`). mutable std::atomic_bool has_lightweight_delete_parts = false; /// Parts that currently moving from disk/volume to another. diff --git a/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h b/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h index 49e3dccdcb8a..adeafe1c4d05 100644 --- a/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h +++ b/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h @@ -73,7 +73,7 @@ class StorageFromMergeTreeDataPart final : public IStorage bool materializeTTLRecalculateOnly() const; - bool hasLightweightDeletedMask() const override + bool hasLightweightDeletedMask() const { return !parts.empty() && parts.front().data_part->hasLightweightDelete(); } diff --git a/src/Storages/StorageAlias.h b/src/Storages/StorageAlias.h index 5d0a2e2e59eb..fc44dd4cf9cb 100644 --- a/src/Storages/StorageAlias.h +++ b/src/Storages/StorageAlias.h @@ -149,7 +149,6 @@ class StorageAlias final : public IStorage, WithContext bool isRemote() const override { return getTargetTable()->isRemote(); } bool isSharedStorage() const override { return getTargetTable()->isSharedStorage(); } bool supportsReplication() const override { return getTargetTable()->supportsReplication(); } - bool hasLightweightDeletedMask() const override { return getTargetTable()->hasLightweightDeletedMask(); } bool supportsLightweightDelete() const override { return getTargetTable()->supportsLightweightDelete(); } std::expected supportsLightweightUpdate() const override { return getTargetTable()->supportsLightweightUpdate(); } bool supportsDelete() const override { return getTargetTable()->supportsDelete(); } diff --git a/src/Storages/StorageMergeTree.cpp b/src/Storages/StorageMergeTree.cpp index 044057830d19..8a57eaaa2482 100644 --- a/src/Storages/StorageMergeTree.cpp +++ b/src/Storages/StorageMergeTree.cpp @@ -896,11 +896,6 @@ QueryPipeline StorageMergeTree::updateLightweight(const MutationCommands & comma return pipeline; } -bool StorageMergeTree::hasLightweightDeletedMask() const -{ - return has_lightweight_delete_parts.load(std::memory_order_relaxed); -} - namespace { diff --git a/src/Storages/StorageMergeTree.h b/src/Storages/StorageMergeTree.h index 2c01687618d1..9bceb139c4dc 100644 --- a/src/Storages/StorageMergeTree.h +++ b/src/Storages/StorageMergeTree.h @@ -96,8 +96,6 @@ class StorageMergeTree final : public MergeTreeData void mutate(const MutationCommands & commands, ContextPtr context) override; QueryPipeline updateLightweight(const MutationCommands & commands, ContextPtr query_context) override; - bool hasLightweightDeletedMask() const override; - /// Return introspection information about currently processing or recently processed mutations. std::vector getMutationsStatus() const override; diff --git a/src/Storages/StorageReplicatedMergeTree.cpp b/src/Storages/StorageReplicatedMergeTree.cpp index 290fed301ff6..feb80e0c9b78 100644 --- a/src/Storages/StorageReplicatedMergeTree.cpp +++ b/src/Storages/StorageReplicatedMergeTree.cpp @@ -8430,11 +8430,6 @@ QueryPipeline StorageReplicatedMergeTree::updateLightweight(const MutationComman return pipeline; } -bool StorageReplicatedMergeTree::hasLightweightDeletedMask() const -{ - return has_lightweight_delete_parts.load(std::memory_order_relaxed); -} - size_t StorageReplicatedMergeTree::clearOldPartsAndRemoveFromZK() { auto table_lock = lockForShare(RWLockImpl::NO_QUERY, (*getSettings())[MergeTreeSetting::lock_acquire_timeout_for_background_operations]); diff --git a/src/Storages/StorageReplicatedMergeTree.h b/src/Storages/StorageReplicatedMergeTree.h index ee2913b72691..030c79ba3636 100644 --- a/src/Storages/StorageReplicatedMergeTree.h +++ b/src/Storages/StorageReplicatedMergeTree.h @@ -194,8 +194,6 @@ class StorageReplicatedMergeTree final : public MergeTreeData bool haveCommittingOps(const CommittingBlocks & committing_blocks, PartitionIdToMaxBlockPtr partitions, std::set ops) const; void waitForCommittingOpsToFinish(zkutil::ZooKeeperPtr zookeeper, PartitionIdToMaxBlockPtr partitions, std::set ops, size_t backoff_ms, size_t sync_timeout_ms); - bool hasLightweightDeletedMask() const override; - /** Removes a replica from ZooKeeper. If there are no other replicas, it deletes the entire table from ZooKeeper. */ void drop() override; diff --git a/tests/queries/0_stateless/04068_lwd_minmax_projection_recovery.reference b/tests/queries/0_stateless/04068_lwd_minmax_projection_recovery.reference new file mode 100644 index 000000000000..4393f13a879b --- /dev/null +++ b/tests/queries/0_stateless/04068_lwd_minmax_projection_recovery.reference @@ -0,0 +1,13 @@ +before_delete +1 +1 +12 +after_delete +0 +0 +8 +lwd_parts_remaining 0 +after_optimize +1 +1 +8 diff --git a/tests/queries/0_stateless/04068_lwd_minmax_projection_recovery.sql b/tests/queries/0_stateless/04068_lwd_minmax_projection_recovery.sql new file mode 100644 index 000000000000..3f74e96e2390 --- /dev/null +++ b/tests/queries/0_stateless/04068_lwd_minmax_projection_recovery.sql @@ -0,0 +1,78 @@ +-- Verify that minmax_count_projection is re-enabled after all lightweight-deleted parts are merged away. +-- Previously, the has_lightweight_delete_parts flag was "sticky" and never reset, +-- permanently disabling minmax_count_projection even after OPTIMIZE TABLE FINAL. + +SET lightweight_deletes_sync = 2, alter_sync = 2; + +DROP TABLE IF EXISTS t_lwd_proj; + +CREATE TABLE t_lwd_proj +( + dt Date, + id UInt64, + value String +) +ENGINE = ReplacingMergeTree() +PARTITION BY toYYYYMM(dt) +ORDER BY (id, dt); + +INSERT INTO t_lwd_proj VALUES ('2025-01-15', 1, 'First record'); +INSERT INTO t_lwd_proj VALUES ('2025-02-15', 2, 'Second record'); +INSERT INTO t_lwd_proj VALUES ('2025-03-15', 3, 'Third record'); +INSERT INTO t_lwd_proj VALUES ('2025-04-15', 4, 'Fourth record'); +INSERT INTO t_lwd_proj VALUES ('2025-05-15', 5, 'Fifth record'); +INSERT INTO t_lwd_proj VALUES ('2025-06-15', 6, 'Sixth record'); +INSERT INTO t_lwd_proj VALUES ('2025-07-15', 7, 'Seventh record'); +INSERT INTO t_lwd_proj VALUES ('2025-08-15', 8, 'Eighth record'); +INSERT INTO t_lwd_proj VALUES ('2025-09-15', 9, 'Ninth record'); +INSERT INTO t_lwd_proj VALUES ('2025-10-15', 10, 'Tenth record'); +INSERT INTO t_lwd_proj VALUES ('2025-11-15', 11, 'Eleventh record'); +INSERT INTO t_lwd_proj VALUES ('2025-12-15', 12, 'Twelfth record'); + +-- Before any delete: minmax_count_projection should be used. +SELECT 'before_delete'; +SELECT count() FROM (EXPLAIN indexes = 1 SELECT min(dt), max(dt) FROM t_lwd_proj + SETTINGS optimize_use_projections = 1, optimize_use_implicit_projections = 1) +WHERE explain LIKE '%_minmax_count_projection%'; + +-- Before any delete: trivial count optimization should be used. +SELECT count() FROM (EXPLAIN SELECT count() FROM t_lwd_proj + SETTINGS optimize_trivial_count_query = 1) +WHERE explain LIKE '%Optimized trivial count%'; +SELECT count() FROM t_lwd_proj; + +-- Perform lightweight delete. +DELETE FROM t_lwd_proj WHERE id < 5; + +-- After delete: minmax_count_projection should NOT be used (parts have LWD mask). +SELECT 'after_delete'; +SELECT count() FROM (EXPLAIN indexes = 1 SELECT min(dt), max(dt) FROM t_lwd_proj + SETTINGS optimize_use_projections = 1, optimize_use_implicit_projections = 1) +WHERE explain LIKE '%_minmax_count_projection%'; + +-- After delete: trivial count optimization should NOT be used. +SELECT count() FROM (EXPLAIN SELECT count() FROM t_lwd_proj + SETTINGS optimize_trivial_count_query = 1) +WHERE explain LIKE '%Optimized trivial count%'; +SELECT count() FROM t_lwd_proj; + +-- Merge away the LWD parts. +OPTIMIZE TABLE t_lwd_proj FINAL; + +-- Verify no parts have lightweight delete mask. +SELECT 'lwd_parts_remaining', countIf(has_lightweight_delete) FROM system.parts +WHERE table = 't_lwd_proj' AND database = currentDatabase() AND active; + +-- After merge: minmax_count_projection should be used again. +SELECT 'after_optimize'; +SELECT count() FROM (EXPLAIN indexes = 1 SELECT min(dt), max(dt) FROM t_lwd_proj + SETTINGS optimize_use_projections = 1, optimize_use_implicit_projections = 1) +WHERE explain LIKE '%_minmax_count_projection%'; + +-- After merge: trivial count optimization should be used again. +SELECT count() FROM (EXPLAIN SELECT count() FROM t_lwd_proj + SETTINGS optimize_trivial_count_query = 1) +WHERE explain LIKE '%Optimized trivial count%'; +SELECT count() FROM t_lwd_proj; + +DROP TABLE t_lwd_proj; diff --git a/tests/queries/0_stateless/04068_lwd_minmax_projection_recovery_rmt.reference b/tests/queries/0_stateless/04068_lwd_minmax_projection_recovery_rmt.reference new file mode 100644 index 000000000000..db5961702184 --- /dev/null +++ b/tests/queries/0_stateless/04068_lwd_minmax_projection_recovery_rmt.reference @@ -0,0 +1,7 @@ +before_delete +1 +after_delete +0 +lwd_parts_remaining 0 +after_optimize +1 diff --git a/tests/queries/0_stateless/04068_lwd_minmax_projection_recovery_rmt.sql b/tests/queries/0_stateless/04068_lwd_minmax_projection_recovery_rmt.sql new file mode 100644 index 000000000000..45f3acd0f582 --- /dev/null +++ b/tests/queries/0_stateless/04068_lwd_minmax_projection_recovery_rmt.sql @@ -0,0 +1,60 @@ +-- Verify that minmax_count_projection is re-enabled after all lightweight-deleted parts are merged away. +-- Previously, the has_lightweight_delete_parts flag was "sticky" and never reset, +-- permanently disabling minmax_count_projection even after OPTIMIZE TABLE FINAL. + +SET lightweight_deletes_sync = 2, alter_sync = 2; + +DROP TABLE IF EXISTS t_lwd_proj; + +CREATE TABLE t_lwd_proj +( + dt Date, + id UInt64, + value String +) +ENGINE = ReplicatedReplacingMergeTree('/clickhouse/{database}/tables/test_cleanup/', '1') +PARTITION BY toYYYYMM(dt) +ORDER BY (id, dt); + +INSERT INTO t_lwd_proj VALUES ('2025-01-15', 1, 'First record'); +INSERT INTO t_lwd_proj VALUES ('2025-02-15', 2, 'Second record'); +INSERT INTO t_lwd_proj VALUES ('2025-03-15', 3, 'Third record'); +INSERT INTO t_lwd_proj VALUES ('2025-04-15', 4, 'Fourth record'); +INSERT INTO t_lwd_proj VALUES ('2025-05-15', 5, 'Fifth record'); +INSERT INTO t_lwd_proj VALUES ('2025-06-15', 6, 'Sixth record'); +INSERT INTO t_lwd_proj VALUES ('2025-07-15', 7, 'Seventh record'); +INSERT INTO t_lwd_proj VALUES ('2025-08-15', 8, 'Eighth record'); +INSERT INTO t_lwd_proj VALUES ('2025-09-15', 9, 'Ninth record'); +INSERT INTO t_lwd_proj VALUES ('2025-10-15', 10, 'Tenth record'); +INSERT INTO t_lwd_proj VALUES ('2025-11-15', 11, 'Eleventh record'); +INSERT INTO t_lwd_proj VALUES ('2025-12-15', 12, 'Twelfth record'); + +-- Before any delete: minmax_count_projection should be used. +SELECT 'before_delete'; +SELECT count() FROM (EXPLAIN indexes = 1 SELECT min(dt), max(dt) FROM t_lwd_proj + SETTINGS optimize_use_projections = 1, optimize_use_implicit_projections = 1) +WHERE explain LIKE '%_minmax_count_projection%'; + +-- Perform lightweight delete. +DELETE FROM t_lwd_proj WHERE id < 5; + +-- After delete: minmax_count_projection should NOT be used (parts have LWD mask). +SELECT 'after_delete'; +SELECT count() FROM (EXPLAIN indexes = 1 SELECT min(dt), max(dt) FROM t_lwd_proj + SETTINGS optimize_use_projections = 1, optimize_use_implicit_projections = 1) +WHERE explain LIKE '%_minmax_count_projection%'; + +-- Merge away the LWD parts. +OPTIMIZE TABLE t_lwd_proj FINAL; + +-- Verify no parts have lightweight delete mask. +SELECT 'lwd_parts_remaining', countIf(has_lightweight_delete) FROM system.parts +WHERE table = 't_lwd_proj' AND database = currentDatabase() AND active; + +-- After merge: minmax_count_projection should be used again. +SELECT 'after_optimize'; +SELECT count() FROM (EXPLAIN indexes = 1 SELECT min(dt), max(dt) FROM t_lwd_proj + SETTINGS optimize_use_projections = 1, optimize_use_implicit_projections = 1) +WHERE explain LIKE '%_minmax_count_projection%'; + +DROP TABLE t_lwd_proj; From d4a5262b5a7d2f896bb0e3bd2d7ad7b0708fd95d Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Tue, 21 Apr 2026 08:52:50 +0000 Subject: [PATCH 28/70] Backport #102961 to 26.3: Use max_insert_threads for plain INSERTs without materialized views --- src/Interpreters/InterpreterInsertQuery.cpp | 6 +- ...2_insert_threads_eagerly_spawned.reference | 4 + .../04102_insert_threads_eagerly_spawned.sh | 80 +++++++++++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 tests/queries/0_stateless/04102_insert_threads_eagerly_spawned.reference create mode 100755 tests/queries/0_stateless/04102_insert_threads_eagerly_spawned.sh diff --git a/src/Interpreters/InterpreterInsertQuery.cpp b/src/Interpreters/InterpreterInsertQuery.cpp index a254a0ad9ea5..3e39c4b8ce57 100644 --- a/src/Interpreters/InterpreterInsertQuery.cpp +++ b/src/Interpreters/InterpreterInsertQuery.cpp @@ -763,7 +763,11 @@ QueryPipeline InterpreterInsertQuery::buildInsertPipeline(ASTInsertQuery & query QueryPipeline pipeline = QueryPipeline(std::move(chain)); - pipeline.setNumThreads(max_threads); + /// When materialized views are attached, their inner SELECT queries benefit + /// from full parallelism, so we use max_threads. Without MVs the insert + /// pipeline is 1-wide and requesting max_threads would only waste + /// ConcurrencyControl slots and spawn unnecessary threads (see #102947). + pipeline.setNumThreads(insert_dependencies->isViewsInvolved() ? max_threads : max_insert_threads); pipeline.setConcurrencyControl(settings[Setting::use_concurrency_control]); if (query.hasInlinedData() && !async_insert) diff --git a/tests/queries/0_stateless/04102_insert_threads_eagerly_spawned.reference b/tests/queries/0_stateless/04102_insert_threads_eagerly_spawned.reference new file mode 100644 index 000000000000..f10182ea5bce --- /dev/null +++ b/tests/queries/0_stateless/04102_insert_threads_eagerly_spawned.reference @@ -0,0 +1,4 @@ +=== Plain INSERT without MVs === +FEW THREADS +=== Plain INSERT with MV === +MORE THAN 1 THREAD diff --git a/tests/queries/0_stateless/04102_insert_threads_eagerly_spawned.sh b/tests/queries/0_stateless/04102_insert_threads_eagerly_spawned.sh new file mode 100755 index 000000000000..6f3c71bd9bff --- /dev/null +++ b/tests/queries/0_stateless/04102_insert_threads_eagerly_spawned.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +# Tags: no-parallel, no-replicated-database, no-async-insert, no-parallel-replicas, no-s3-storage +# no-parallel: checks thread count, which can be affected by concurrent queries +# no-replicated-database: query_log lookup assumes single-node execution +# no-async-insert: test measures synchronous INSERT pipeline threading +# no-parallel-replicas: parallel replicas settings alter query execution plans and thread allocation +# no-s3-storage: S3 I/O threads inflate peak_threads_usage beyond the pipeline thread count + +# Verifies that a plain INSERT (no SELECT, no MVs) does not request +# excessive ConcurrencyControl slots or spawn unnecessary threads. +# Regression test for https://github.com/ClickHouse/ClickHouse/issues/102947 + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CUR_DIR"/../shell_config.sh + +$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS test_insert_threads" +$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS test_insert_threads_mv" +$CLICKHOUSE_CLIENT -q "CREATE TABLE test_insert_threads (x UInt64) ENGINE = MergeTree ORDER BY x" + +# Test 1: Plain INSERT FORMAT TSV with max_threads=16, no MVs. +# The insert pipeline is a single chain — should use max_insert_threads (1). +echo "=== Plain INSERT without MVs ===" +QUERY_ID1="04102_no_mv_$RANDOM" + +$CLICKHOUSE_CLIENT -q "SELECT number FROM numbers(10000) FORMAT TSV" | \ +$CLICKHOUSE_CLIENT \ + --query_id="$QUERY_ID1" \ + --max_threads=16 \ + --max_insert_threads=1 \ + --input_format_parallel_parsing=0 \ + --log_queries=1 \ + -q "INSERT INTO test_insert_threads FORMAT TSV" + +$CLICKHOUSE_CLIENT -q "SYSTEM FLUSH LOGS query_log" + +$CLICKHOUSE_CLIENT -q " + SELECT + if(peak_threads_usage <= 4, 'FEW THREADS', 'MANY THREADS SPAWNED') + FROM system.query_log + WHERE event_date >= yesterday() + AND event_time >= now() - 600 + AND current_database = currentDatabase() + AND type = 'QueryFinish' + AND query_id = '$QUERY_ID1' + SETTINGS optimize_if_transform_strings_to_enum = 0 +" + +# Test 2: INSERT with a materialized view — should use more threads. +echo "=== Plain INSERT with MV ===" +$CLICKHOUSE_CLIENT -q "CREATE MATERIALIZED VIEW test_insert_threads_mv ENGINE = MergeTree ORDER BY x AS SELECT x FROM test_insert_threads" + +QUERY_ID2="04102_with_mv_$RANDOM" + +$CLICKHOUSE_CLIENT -q "SELECT number FROM numbers(10000) FORMAT TSV" | \ +$CLICKHOUSE_CLIENT \ + --query_id="$QUERY_ID2" \ + --max_threads=16 \ + --max_insert_threads=1 \ + --input_format_parallel_parsing=0 \ + --log_queries=1 \ + -q "INSERT INTO test_insert_threads FORMAT TSV" + +$CLICKHOUSE_CLIENT -q "SYSTEM FLUSH LOGS query_log" + +# With MVs, peak_threads should be higher than without MVs +$CLICKHOUSE_CLIENT -q " + SELECT + if(peak_threads_usage > 1, 'MORE THAN 1 THREAD', 'SINGLE THREAD') + FROM system.query_log + WHERE event_date >= yesterday() + AND event_time >= now() - 600 + AND current_database = currentDatabase() + AND type = 'QueryFinish' + AND query_id = '$QUERY_ID2' + SETTINGS optimize_if_transform_strings_to_enum = 0 +" + +$CLICKHOUSE_CLIENT -q "DROP TABLE test_insert_threads_mv" +$CLICKHOUSE_CLIENT -q "DROP TABLE test_insert_threads" From 905bc2767df192e66303b686782e4515632058d7 Mon Sep 17 00:00:00 2001 From: Nikolay Degterinsky <43110995+evillique@users.noreply.github.com> Date: Tue, 21 Apr 2026 11:28:31 +0200 Subject: [PATCH 29/70] Update 02995_settings_26_2_1.tsv --- tests/queries/0_stateless/02995_settings_26_2_1.tsv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/queries/0_stateless/02995_settings_26_2_1.tsv b/tests/queries/0_stateless/02995_settings_26_2_1.tsv index 4846200cf459..25ef199073af 100644 --- a/tests/queries/0_stateless/02995_settings_26_2_1.tsv +++ b/tests/queries/0_stateless/02995_settings_26_2_1.tsv @@ -530,7 +530,7 @@ function_locate_has_mysql_compatible_argument_order 1 function_range_max_elements_in_block 500000000 function_sleep_max_microseconds_per_block 3000000 function_visible_width_behavior 1 -functions_h3_default_if_invalid 1 +functions_h3_default_if_invalid 0 geo_distance_returns_float64_on_float64_arguments 1 geotoh3_argument_order lat_lon glob_expansion_max_elements 1000 From b18d24885efc916c23d0beacdea30c1d770674a0 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Tue, 21 Apr 2026 17:37:18 +0000 Subject: [PATCH 30/70] Backport #101036 to 26.3: Fix ColumnReplicated type mismatch crash in merge algorithms --- .../Merges/Algorithms/MergedData.cpp | 38 ++- .../tests/gtest_merged_data_replicated.cpp | 237 ++++++++++++++++++ 2 files changed, 273 insertions(+), 2 deletions(-) create mode 100644 src/Processors/Merges/Algorithms/tests/gtest_merged_data_replicated.cpp diff --git a/src/Processors/Merges/Algorithms/MergedData.cpp b/src/Processors/Merges/Algorithms/MergedData.cpp index c5bfaf396f2c..5d63ecca6df4 100644 --- a/src/Processors/Merges/Algorithms/MergedData.cpp +++ b/src/Processors/Merges/Algorithms/MergedData.cpp @@ -54,7 +54,21 @@ void MergedData::insertRow(const ColumnRawPtrs & raw_columns, size_t row, size_t size_t num_columns = raw_columns.size(); chassert(columns.size() == num_columns); for (size_t i = 0; i < num_columns; ++i) + { + /// If the source is `ColumnReplicated` but the destination is not, wrap the destination + /// in `ColumnReplicated` so its `insertFrom` can consume both regular and replicated + /// sources through the same optimized path. This preserves the lazy replication + /// optimization instead of eagerly materializing the source. + /// + /// This can happen when `initialize` set the destination type based on the initial + /// inputs (none of which were `ColumnReplicated`), but a later chunk arrives via + /// `consume` with non-sort `ColumnReplicated` columns (for example, from a JOIN + /// with `enable_lazy_columns_replication = 1`). + if (raw_columns[i]->isReplicated() && !columns[i]->isReplicated()) + columns[i] = ColumnReplicated::create(std::move(columns[i])); + columns[i]->insertFrom(*raw_columns[i], row); + } ++total_merged_rows; ++merged_rows; @@ -67,6 +81,10 @@ void MergedData::insertRows(const ColumnRawPtrs & raw_columns, size_t start_inde chassert(columns.size() == num_columns); for (size_t i = 0; i < num_columns; ++i) { + /// See comment in `insertRow` for why this wrapping is needed. + if (raw_columns[i]->isReplicated() && !columns[i]->isReplicated()) + columns[i] = ColumnReplicated::create(std::move(columns[i])); + if (length == 1) columns[i]->insertFrom(*raw_columns[i], start_index); else @@ -101,24 +119,40 @@ void MergedData::insertChunk(Chunk && chunk, size_t rows_size) /// the input chunk because the resulting column may have different dynamic structure /// (after calling `chooseDynamicStructureForMerge`). /// We need to use `cloneEmpty` + `insertRangeFrom` to properly re-insert data. + /// + /// If `chunk_columns[i]` is `ColumnReplicated`, wrap the empty destination in + /// `ColumnReplicated` so `insertRangeFrom` consumes the source via the optimized path + /// without eagerly materializing it. This preserves the lazy replication optimization. else if (columns[i]->hasDynamicStructure()) { columns[i] = columns[i]->cloneEmpty(); + if (chunk_columns[i]->isReplicated() && !columns[i]->isReplicated()) + columns[i] = ColumnReplicated::create(std::move(columns[i])); columns[i]->insertRangeFrom(*chunk_columns[i], 0, num_rows); } /// For columns with statistics (like Map with adaptive buckets) we can reuse the column /// from the input chunk, but need to preserve the merged statistics computed during `initialize`. + /// `takeOrCalculateStatisticsFrom` is delegated through `ColumnReplicated` to the nested + /// column, so no special handling is needed when `chunk_columns[i]` is `ColumnReplicated`. else if (columns[i]->hasStatistics()) { chunk_columns[i]->takeOrCalculateStatisticsFrom({columns[i]->getPtr()}); columns[i] = std::move(chunk_columns[i]); } - else if (columns[i]->isReplicated() && !chunk_columns[i]->isReplicated()) + else if (columns[i]->isReplicated()) { - columns[i] = ColumnReplicated::create(std::move(chunk_columns[i])); + /// Destination is `ColumnReplicated` (set during `initialize`). If the chunk is also + /// `ColumnReplicated` move it through; otherwise wrap the regular chunk column. + if (chunk_columns[i]->isReplicated()) + columns[i] = std::move(chunk_columns[i]); + else + columns[i] = ColumnReplicated::create(std::move(chunk_columns[i])); } else { + /// Simple case: move the chunk column into the destination. If the chunk is + /// `ColumnReplicated`, the destination becomes `ColumnReplicated` — this preserves + /// the lazy replication optimization. columns[i] = std::move(chunk_columns[i]); } } diff --git a/src/Processors/Merges/Algorithms/tests/gtest_merged_data_replicated.cpp b/src/Processors/Merges/Algorithms/tests/gtest_merged_data_replicated.cpp new file mode 100644 index 000000000000..efb81ec5e2fb --- /dev/null +++ b/src/Processors/Merges/Algorithms/tests/gtest_merged_data_replicated.cpp @@ -0,0 +1,237 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace DB; + +/// Regression tests for STID 2508 family: type mismatch exception when `MergedData` +/// destination is a regular column but a late-arriving chunk brings in `ColumnReplicated` +/// non-sort columns. +/// +/// This can happen when `initialize` set destination types based on the initial inputs +/// (none of which were `ColumnReplicated`), but a later chunk arrives via `consume` with +/// `ColumnReplicated` non-sort columns — for example, from a JOIN executed with +/// `enable_lazy_columns_replication = 1`. The sort-column-only materialization in the +/// merge algorithms' `consume` methods leaves non-sort columns untouched, so the +/// mismatch propagates into `insertRow` / `insertRows` / `insertChunk`. +/// +/// The fix detects the mismatch in `MergedData` and WRAPS the destination in +/// `ColumnReplicated`, so `insertFrom` / `insertRangeFrom` consume both regular and +/// replicated sources through `ColumnReplicated`'s optimized path. This preserves the +/// lazy replication optimization instead of eagerly materializing the source. + +TEST(MergedDataReplicated, InsertRowsReplicatedSourceRegularDestination) +{ + /// Set up a header with 2 columns: "key" (would be sort) and "value" (non-sort). + Block header; + header.insert(ColumnWithTypeAndName(ColumnInt64::create(), std::make_shared(), "key")); + header.insert(ColumnWithTypeAndName(ColumnInt64::create(), std::make_shared(), "value")); + + /// Initialize with input 0 having regular columns; input 1 is null (late-arriving). + /// This means `MergedData` destination columns are regular (not `ColumnReplicated`). + IMergingAlgorithm::Inputs inputs(2); + { + auto key_col = ColumnInt64::create(); + auto val_col = ColumnInt64::create(); + key_col->insertValue(1); + val_col->insertValue(100); + inputs[0].chunk.setColumns(Columns{std::move(key_col), std::move(val_col)}, 1); + } + /// inputs[1] has no chunk — simulates a merge input that arrives later via `consume`. + + MergedData merged_data(false, 1000, 0, {}); + merged_data.initialize(header, inputs); + + /// Simulate `insertRows` with a `ColumnReplicated` value column. + /// In the real bug scenario, this comes from a JOIN with `enable_lazy_columns_replication = 1` + /// where `consume` didn't materialize non-sort `ColumnReplicated` columns. + auto key_src = ColumnInt64::create(); + key_src->insertValue(2); + auto val_nested = ColumnInt64::create(); + val_nested->insertValue(200); + ColumnPtr val_replicated = ColumnReplicated::create(ColumnPtr(std::move(val_nested))); + + ColumnRawPtrs raw_columns = {key_src.get(), val_replicated.get()}; + + /// Before the fix, this would trigger: + /// `chassert((isConst() || isSparse() || isReplicated()) ? getDataType() == rhs.getDataType() + /// : typeid(*this) == typeid(rhs))` + /// at `IColumn.h:862` because destination is regular `ColumnInt64` but source is `ColumnReplicated`. + ASSERT_NO_THROW(merged_data.insertRows(raw_columns, 0, 1, 1)); + + /// Verify the data was inserted correctly. + Chunk result = merged_data.pull(); + ASSERT_EQ(result.getNumRows(), 1); + const auto & result_key = assert_cast(*result.getColumns()[0]); + ASSERT_EQ(result_key.getInt(0), 2); + ASSERT_EQ(result.getColumns()[1]->getInt(0), 200); +} + +TEST(MergedDataReplicated, InsertRowReplicatedSourceRegularDestination) +{ + Block header; + header.insert(ColumnWithTypeAndName(ColumnInt64::create(), std::make_shared(), "key")); + header.insert(ColumnWithTypeAndName(ColumnInt64::create(), std::make_shared(), "value")); + + /// Initialize with only regular columns. + IMergingAlgorithm::Inputs inputs(1); + { + auto key_col = ColumnInt64::create(); + auto val_col = ColumnInt64::create(); + key_col->insertValue(1); + val_col->insertValue(100); + inputs[0].chunk.setColumns(Columns{std::move(key_col), std::move(val_col)}, 1); + } + + MergedData merged_data(false, 1000, 0, {}); + merged_data.initialize(header, inputs); + + /// Insert a single row with `ColumnReplicated` source. + auto key_src = ColumnInt64::create(); + key_src->insertValue(2); + auto val_nested = ColumnInt64::create(); + val_nested->insertValue(200); + ColumnPtr val_replicated = ColumnReplicated::create(ColumnPtr(std::move(val_nested))); + + ColumnRawPtrs raw_columns = {key_src.get(), val_replicated.get()}; + ASSERT_NO_THROW(merged_data.insertRow(raw_columns, 0, 1)); + + Chunk result = merged_data.pull(); + ASSERT_EQ(result.getNumRows(), 1); + const auto & result_val = *result.getColumns()[1]; + ASSERT_EQ(result_val.getInt(0), 200); +} + +/// Verifies that the fix preserves the lazy replication optimization: when the +/// mismatch is detected, the destination is WRAPPED in `ColumnReplicated` rather +/// than materializing the source. Future inserts into the merged data then use +/// `ColumnReplicated::insertFrom`'s optimized path, which avoids copying unique +/// values that are already present. +TEST(MergedDataReplicated, InsertRowsWrapsDestinationPreservingOptimization) +{ + Block header; + header.insert(ColumnWithTypeAndName(ColumnInt64::create(), std::make_shared(), "key")); + header.insert(ColumnWithTypeAndName(ColumnInt64::create(), std::make_shared(), "value")); + + IMergingAlgorithm::Inputs inputs(1); + { + auto key_col = ColumnInt64::create(); + auto val_col = ColumnInt64::create(); + key_col->insertValue(1); + val_col->insertValue(100); + inputs[0].chunk.setColumns(Columns{std::move(key_col), std::move(val_col)}, 1); + } + + MergedData merged_data(false, 1000, 0, {}); + merged_data.initialize(header, inputs); + + auto key_src = ColumnInt64::create(); + key_src->insertValue(2); + auto val_nested = ColumnInt64::create(); + val_nested->insertValue(200); + ColumnPtr val_replicated = ColumnReplicated::create(ColumnPtr(std::move(val_nested))); + + ColumnRawPtrs raw_columns = {key_src.get(), val_replicated.get()}; + merged_data.insertRows(raw_columns, 0, 1, 1); + + Chunk result = merged_data.pull(); + ASSERT_EQ(result.getNumRows(), 1); + /// After the mismatch is detected, the destination column should be `ColumnReplicated` + /// (not a regular `ColumnInt64`). This confirms we preserved the optimization rather + /// than materializing the source. + ASSERT_TRUE(result.getColumns()[1]->isReplicated()); + ASSERT_EQ(result.getColumns()[1]->getInt(0), 200); +} + +TEST(MergedDataReplicated, InsertChunkReplicatedSourceRegularDestination) +{ + Block header; + header.insert(ColumnWithTypeAndName(ColumnInt64::create(), std::make_shared(), "key")); + header.insert(ColumnWithTypeAndName(ColumnInt64::create(), std::make_shared(), "value")); + + /// Initialize with only regular columns — no `ColumnReplicated` seen. + IMergingAlgorithm::Inputs inputs(2); + { + auto key_col = ColumnInt64::create(); + auto val_col = ColumnInt64::create(); + key_col->insertValue(1); + val_col->insertValue(100); + inputs[0].chunk.setColumns(Columns{std::move(key_col), std::move(val_col)}, 1); + } + + MergedData merged_data(false, 1000, 0, {}); + merged_data.initialize(header, inputs); + + /// Construct a chunk with `ColumnReplicated` value column. + auto key_col = ColumnInt64::create(); + key_col->insertValue(3); + auto val_nested = ColumnInt64::create(); + val_nested->insertValue(300); + ColumnPtr val_replicated = ColumnReplicated::create(ColumnPtr(std::move(val_nested))); + + Chunk chunk(Columns{std::move(key_col), std::move(val_replicated)}, 1); + ASSERT_NO_THROW(merged_data.insertChunk(std::move(chunk), 1)); + + Chunk result = merged_data.pull(); + ASSERT_EQ(result.getNumRows(), 1); + /// With the fix, `insertChunk`'s simple branch just moves the `ColumnReplicated` + /// chunk column into the destination. The destination becomes `ColumnReplicated` + /// — the lazy replication optimization is preserved all the way through. + ASSERT_TRUE(result.getColumns()[1]->isReplicated()); + ASSERT_EQ(result.getColumns()[1]->getInt(0), 300); +} + +/// Regression test for the second code path reported by the automated PR review: +/// `insertChunk`'s `hasDynamicStructure` branch does `cloneEmpty` + `insertRangeFrom`. +/// Without the fix, when the chunk column is `ColumnReplicated(ColumnDynamic)`, the +/// empty destination `ColumnDynamic` receives `ColumnReplicated` via `insertRangeFrom` +/// and `ColumnDynamic::insertRangeFrom` does `assert_cast(src)`, +/// which fails in debug/sanitizer builds and is UB in release. +/// +/// The fix wraps the empty destination in `ColumnReplicated` when the chunk is +/// `ColumnReplicated`, so `ColumnReplicated::insertRangeFrom` handles the source +/// through its optimized path and re-inserts values into the nested column with the +/// merged dynamic structure. +TEST(MergedDataReplicated, InsertChunkReplicatedDynamicSourceRegularDestination) +{ + Block header; + header.insert(ColumnWithTypeAndName(ColumnInt64::create(), std::make_shared(), "key")); + header.insert(ColumnWithTypeAndName(ColumnDynamic::create(254), std::make_shared(), "value")); + + /// Initialize with one regular input (no `ColumnReplicated`) — destination is `ColumnDynamic`. + /// Input 1 is null (late-arriving), so `MergedData` won't see `ColumnReplicated` during init. + IMergingAlgorithm::Inputs inputs(2); + { + auto key_col = ColumnInt64::create(); + key_col->insertValue(1); + auto val_col = ColumnDynamic::create(254); + val_col->insert(Field(100)); + inputs[0].chunk.setColumns(Columns{std::move(key_col), std::move(val_col)}, 1); + } + + MergedData merged_data(false, 1000, 0, 254); + merged_data.initialize(header, inputs); + + /// Construct a chunk where the Dynamic column is wrapped in `ColumnReplicated`. + /// This simulates a late-arriving merge input from a JOIN with `enable_lazy_columns_replication = 1`. + auto key_col = ColumnInt64::create(); + key_col->insertValue(3); + auto val_dynamic = ColumnDynamic::create(254); + val_dynamic->insert(Field(300)); + ColumnPtr val_replicated = ColumnReplicated::create(ColumnPtr(std::move(val_dynamic))); + + Chunk chunk(Columns{std::move(key_col), std::move(val_replicated)}, 1); + + ASSERT_NO_THROW(merged_data.insertChunk(std::move(chunk), 1)); + + Chunk result = merged_data.pull(); + ASSERT_EQ(result.getNumRows(), 1); + /// The destination should be wrapped as `ColumnReplicated(ColumnDynamic)`, + /// preserving the optimization. + ASSERT_TRUE(result.getColumns()[1]->isReplicated()); +} From cdb3a1782b51b2f68d3cf0ff8e306bd27dce5683 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Tue, 21 Apr 2026 21:31:20 +0000 Subject: [PATCH 31/70] Backport #102692 to 26.3: Fix flattened Dynamic type serialization with binary encoded data types --- .../Serializations/SerializationDynamic.cpp | 2 +- ...dynamic_native_encode_types_binary.reference | 3 +++ ...ttened_dynamic_native_encode_types_binary.sh | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/queries/0_stateless/04094_flattened_dynamic_native_encode_types_binary.reference create mode 100755 tests/queries/0_stateless/04094_flattened_dynamic_native_encode_types_binary.sh diff --git a/src/DataTypes/Serializations/SerializationDynamic.cpp b/src/DataTypes/Serializations/SerializationDynamic.cpp index 2091af5900e3..10da12f245b8 100644 --- a/src/DataTypes/Serializations/SerializationDynamic.cpp +++ b/src/DataTypes/Serializations/SerializationDynamic.cpp @@ -159,7 +159,7 @@ void SerializationDynamic::serializeBinaryBulkStatePrefix( for (const auto & type : flattened_column.types) { if (settings.native_format && settings.format_settings && settings.format_settings->native.encode_types_in_binary_format) - encodeDataType(type); + encodeDataType(type, *stream); else writeStringBinary(type->getName(), *stream); } diff --git a/tests/queries/0_stateless/04094_flattened_dynamic_native_encode_types_binary.reference b/tests/queries/0_stateless/04094_flattened_dynamic_native_encode_types_binary.reference new file mode 100644 index 000000000000..664388937d73 --- /dev/null +++ b/tests/queries/0_stateless/04094_flattened_dynamic_native_encode_types_binary.reference @@ -0,0 +1,3 @@ +42 Int64 +hello String +2020-01-01 Date diff --git a/tests/queries/0_stateless/04094_flattened_dynamic_native_encode_types_binary.sh b/tests/queries/0_stateless/04094_flattened_dynamic_native_encode_types_binary.sh new file mode 100755 index 000000000000..fa66b56af53b --- /dev/null +++ b/tests/queries/0_stateless/04094_flattened_dynamic_native_encode_types_binary.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# Test: flattened Dynamic serialization with encode_types_in_binary_format=1. +# encodeDataType at SerializationDynamic.cpp must use the two-arg overload +# that writes to the stream, not the one-arg overload that returns a String. + +$CLICKHOUSE_LOCAL -m -q " + CREATE TABLE test (d Dynamic(max_types=2)) ENGINE=Memory; + INSERT INTO test VALUES (42::Int64), ('hello'), ('2020-01-01'::Date); + SELECT * FROM test FORMAT Native SETTINGS + output_format_native_use_flattened_dynamic_and_json_serialization=1, + output_format_native_encode_types_in_binary_format=1; +" | $CLICKHOUSE_LOCAL --table test --input-format Native --input_format_native_decode_types_in_binary_format=1 -q "SELECT d, dynamicType(d) FROM test" From 72ffcc4a18cb96ca90851548fba7bdfc34ab1a34 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 22 Apr 2026 08:51:29 +0000 Subject: [PATCH 32/70] Backport #102997 to 26.3: Hide secret key in HMAC SQL function --- src/Parsers/FunctionSecretArgumentsFinder.h | 17 +++++++++++++++++ .../02494_query_cache_secrets.reference | 2 ++ .../0_stateless/02494_query_cache_secrets.sql | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/src/Parsers/FunctionSecretArgumentsFinder.h b/src/Parsers/FunctionSecretArgumentsFinder.h index 8a3ef97422e8..27bc89431d5c 100644 --- a/src/Parsers/FunctionSecretArgumentsFinder.h +++ b/src/Parsers/FunctionSecretArgumentsFinder.h @@ -140,6 +140,11 @@ class FunctionSecretArgumentsFinder /// encrypt('mode', 'plaintext', 'key' [, iv, aad]) findEncryptionFunctionSecretArguments(); } + else if (boost::iequals(function->name(), "HMAC")) + { + /// HMAC('mode', 'message', 'key') -> HMAC('mode', 'message', '[HIDDEN]') + findHMACSecretArguments(); + } else if (function->name() == "url") { findURLSecretArguments(); @@ -531,6 +536,18 @@ class FunctionSecretArgumentsFinder result.count = function->arguments->size() - 1; } + void findHMACSecretArguments() + { + if (function->arguments->size() < 3) + return; + + /// We hide the key argument and any following for the case of mistyping or using extra arguments by mistake: + /// HMAC('mode', 'message', 'key') -> HMAC('mode', 'message', '[HIDDEN]') + /// HMAC('sha256', toString(toFixedString('b', 3), 3), '(', 'this_should_be_secret') -> HMAC('sha256', toString(toFixedString('b', 3), 3), '[HIDDEN]', '[HIDDEN]') + result.start = 2; + result.count = function->arguments->size() - 2; + } + void findTableEngineSecretArguments() { const String & engine_name = function->name(); diff --git a/tests/queries/0_stateless/02494_query_cache_secrets.reference b/tests/queries/0_stateless/02494_query_cache_secrets.reference index 82833f28369a..2081fee07299 100644 --- a/tests/queries/0_stateless/02494_query_cache_secrets.reference +++ b/tests/queries/0_stateless/02494_query_cache_secrets.reference @@ -1,2 +1,4 @@ A2193552DCF8A9F99AC35F86BC4D2FFD SELECT hex(encrypt(\'aes-128-ecb\', \'[HIDDEN]\')) SETTINGS use_query_cache = true +F57183CE1F2616499E9FDE8EB1B7A60F8336688BA1F3E324B26B5C5A4B143F09 +SELECT hex(HMAC(\'sha256\', \'message\', \'[HIDDEN]\')) SETTINGS use_query_cache = true diff --git a/tests/queries/0_stateless/02494_query_cache_secrets.sql b/tests/queries/0_stateless/02494_query_cache_secrets.sql index ff25531088c8..bd3c7af831ac 100644 --- a/tests/queries/0_stateless/02494_query_cache_secrets.sql +++ b/tests/queries/0_stateless/02494_query_cache_secrets.sql @@ -11,3 +11,12 @@ SELECT hex(encrypt('aes-128-ecb', 'plaintext', 'passwordpassword')) SETTINGS use SELECT query FROM system.query_cache; SYSTEM CLEAR QUERY CACHE; + +-- https://github.com/ClickHouse/ClickHouse/issues/102927 +-- HMAC key should be hidden in system.query_cache +SELECT hex(HMAC('sha256', 'message', 'this_should_be_secret')) SETTINGS use_query_cache = true; + +-- The HMAC key should not be revealed in system.query_cache +SELECT query FROM system.query_cache; + +SYSTEM CLEAR QUERY CACHE; From d3eadf3d6400d2a0acc6cc28d213f64290deab91 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 22 Apr 2026 11:38:23 +0000 Subject: [PATCH 33/70] Backport #103285 to 26.3: Reduce default HTTP header limits to prevent pre-auth memory exhaustion --- programs/keeper/Keeper.cpp | 10 + src/Interpreters/Context.cpp | 12 + src/Interpreters/Context.h | 4 + src/Server/HTTP/DeadlineReadBuffer.cpp | 28 +++ src/Server/HTTP/DeadlineReadBuffer.h | 41 +++ src/Server/HTTP/HTMLForm.cpp | 4 +- src/Server/HTTP/HTMLForm.h | 2 +- src/Server/HTTP/HTTPContext.h | 2 + src/Server/HTTP/HTTPServerRequest.cpp | 36 ++- src/Server/HTTP/HTTPServerRequest.h | 1 + src/Server/HTTP/ReadHeaders.cpp | 12 +- src/Server/HTTP/ReadHeaders.h | 7 +- .../test_http_header_limits/__init__.py | 0 .../test_http_header_limits/configs/users.xml | 12 + .../test_http_header_limits/test.py | 237 ++++++++++++++++++ 15 files changed, 400 insertions(+), 8 deletions(-) create mode 100644 src/Server/HTTP/DeadlineReadBuffer.cpp create mode 100644 src/Server/HTTP/DeadlineReadBuffer.h create mode 100644 tests/integration/test_http_header_limits/__init__.py create mode 100644 tests/integration/test_http_header_limits/configs/users.xml create mode 100644 tests/integration/test_http_header_limits/test.py diff --git a/programs/keeper/Keeper.cpp b/programs/keeper/Keeper.cpp index ac20054e279e..2f6ff040fab7 100644 --- a/programs/keeper/Keeper.cpp +++ b/programs/keeper/Keeper.cpp @@ -269,6 +269,16 @@ struct KeeperHTTPContext : public IHTTPContext return context->getConfigRef().getUInt64("keeper_server.http_max_field_value_size", 128 * 1024); } + uint64_t getMaxRequestHeaderSize() const override + { + return context->getConfigRef().getUInt64("keeper_server.http_max_request_header_size", 0); + } + + Poco::Timespan getHeadersReadTimeout() const override + { + return {context->getConfigRef().getInt64("keeper_server.http_headers_read_timeout", 0), 0}; + } + Poco::Timespan getReceiveTimeout() const override { return {context->getConfigRef().getInt64("keeper_server.http_receive_timeout", DBMS_DEFAULT_RECEIVE_TIMEOUT_SEC), 0}; diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index 92ae95d7e9c9..bedd20ba9002 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -290,6 +290,8 @@ namespace Setting extern const SettingsUInt64 http_max_fields; extern const SettingsUInt64 http_max_field_name_size; extern const SettingsUInt64 http_max_field_value_size; + extern const SettingsUInt64 http_max_request_header_size; + extern const SettingsSeconds http_headers_read_timeout; extern const SettingsUInt64 http_max_tries; extern const SettingsUInt64 http_max_uri_size; extern const SettingsSeconds http_receive_timeout; @@ -7678,6 +7680,16 @@ uint64_t HTTPContext::getMaxFieldValueSize() const return context->getSettingsRef()[Setting::http_max_field_value_size]; } +uint64_t HTTPContext::getMaxRequestHeaderSize() const +{ + return context->getSettingsRef()[Setting::http_max_request_header_size]; +} + +Poco::Timespan HTTPContext::getHeadersReadTimeout() const +{ + return context->getSettingsRef()[Setting::http_headers_read_timeout]; +} + Poco::Timespan HTTPContext::getReceiveTimeout() const { return context->getSettingsRef()[Setting::http_receive_timeout]; diff --git a/src/Interpreters/Context.h b/src/Interpreters/Context.h index b10d3a3f2ce4..a8ba3ebaec0c 100644 --- a/src/Interpreters/Context.h +++ b/src/Interpreters/Context.h @@ -1862,6 +1862,10 @@ struct HTTPContext : public IHTTPContext uint64_t getMaxFieldValueSize() const override; + uint64_t getMaxRequestHeaderSize() const override; + + Poco::Timespan getHeadersReadTimeout() const override; + Poco::Timespan getReceiveTimeout() const override; Poco::Timespan getSendTimeout() const override; diff --git a/src/Server/HTTP/DeadlineReadBuffer.cpp b/src/Server/HTTP/DeadlineReadBuffer.cpp new file mode 100644 index 000000000000..c737f5708379 --- /dev/null +++ b/src/Server/HTTP/DeadlineReadBuffer.cpp @@ -0,0 +1,28 @@ +#include + +#include + +namespace DB +{ + +bool DeadlineReadBuffer::nextImpl() +{ + /// Sync our position to the inner buffer before asking for more data. + in.position() = position(); + + bool has_data = in.next(); + + /// Check after the potentially blocking read so that + /// `http_headers_read_timeout` remains a strict wall-clock limit. + if (std::chrono::steady_clock::now() > deadline) + throw Poco::Net::MessageException("Timeout exceeded while reading HTTP headers"); + + if (has_data) + BufferBase::set(in.position(), in.available(), 0); + else + BufferBase::set(in.position(), 0, 0); + + return has_data; +} + +} diff --git a/src/Server/HTTP/DeadlineReadBuffer.h b/src/Server/HTTP/DeadlineReadBuffer.h new file mode 100644 index 000000000000..cbda8114cd05 --- /dev/null +++ b/src/Server/HTTP/DeadlineReadBuffer.h @@ -0,0 +1,41 @@ +#pragma once + +#include + +#include + +namespace DB +{ + +/// Wraps another ReadBuffer and enforces a wall-clock deadline on reads. +/// Throws Poco::Net::MessageException when the deadline is exceeded, +/// which the HTTP server translates to a 400 Bad Request response. +/// Used to protect HTTP header parsing against slowloris-style attacks. +class DeadlineReadBuffer : public ReadBuffer +{ +public: + using TimePoint = std::chrono::steady_clock::time_point; + + DeadlineReadBuffer(ReadBuffer & in_, TimePoint deadline_) + : ReadBuffer(in_.position(), 0) + , in(in_) + , deadline(deadline_) + { + BufferBase::set(in.position(), in.available(), 0); + } + + ~DeadlineReadBuffer() override + { + /// Sync position back to the inner buffer. + if (!working_buffer.empty()) + in.position() = position(); + } + +private: + bool nextImpl() override; + + ReadBuffer & in; + TimePoint deadline; +}; + +} diff --git a/src/Server/HTTP/HTMLForm.cpp b/src/Server/HTTP/HTMLForm.cpp index dfce23779416..ffa580fa3e49 100644 --- a/src/Server/HTTP/HTMLForm.cpp +++ b/src/Server/HTTP/HTMLForm.cpp @@ -24,6 +24,7 @@ namespace Setting extern const SettingsUInt64 http_max_fields; extern const SettingsUInt64 http_max_field_name_size; extern const SettingsUInt64 http_max_field_value_size; + extern const SettingsUInt64 http_max_request_header_size; } namespace ErrorCodes @@ -51,6 +52,7 @@ HTMLForm::HTMLForm(const Settings & settings) : max_fields_number(settings[Setting::http_max_fields]) , max_field_name_size(settings[Setting::http_max_field_name_size]) , max_field_value_size(settings[Setting::http_max_field_value_size]) + , max_request_header_size(settings[Setting::http_max_request_header_size]) , encoding(ENCODING_URL) { } @@ -204,7 +206,7 @@ void HTMLForm::readMultipart(ReadBuffer & in_, PartHandler & handler) throw Poco::Net::HTMLFormException("Too many form fields"); Poco::Net::MessageHeader header; - readHeaders(header, in, max_fields_number, max_field_name_size, max_field_value_size); + readHeaders(header, in, max_fields_number, max_field_name_size, max_field_value_size, max_request_header_size); skipToNextLineOrEOF(in); NameValueCollection params; diff --git a/src/Server/HTTP/HTMLForm.h b/src/Server/HTTP/HTMLForm.h index 53e7be9d5bfe..0591045f8770 100644 --- a/src/Server/HTTP/HTMLForm.h +++ b/src/Server/HTTP/HTMLForm.h @@ -93,7 +93,7 @@ class HTMLForm : public Poco::Net::NameValueCollection, private boost::noncopyab using PartVec = std::vector; - const size_t max_fields_number, max_field_name_size, max_field_value_size; + const size_t max_fields_number, max_field_name_size, max_field_value_size, max_request_header_size; std::string encoding; std::string boundary; diff --git a/src/Server/HTTP/HTTPContext.h b/src/Server/HTTP/HTTPContext.h index 86054827632d..fda38b4581ec 100644 --- a/src/Server/HTTP/HTTPContext.h +++ b/src/Server/HTTP/HTTPContext.h @@ -12,6 +12,8 @@ struct IHTTPContext virtual uint64_t getMaxFields() const = 0; virtual uint64_t getMaxFieldNameSize() const = 0; virtual uint64_t getMaxFieldValueSize() const = 0; + virtual uint64_t getMaxRequestHeaderSize() const = 0; + virtual Poco::Timespan getHeadersReadTimeout() const = 0; virtual Poco::Timespan getReceiveTimeout() const = 0; virtual Poco::Timespan getSendTimeout() const = 0; diff --git a/src/Server/HTTP/HTTPServerRequest.cpp b/src/Server/HTTP/HTTPServerRequest.cpp index b7047875e0c7..4ae7c7f4d3da 100644 --- a/src/Server/HTTP/HTTPServerRequest.cpp +++ b/src/Server/HTTP/HTTPServerRequest.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -31,6 +32,7 @@ HTTPServerRequest::HTTPServerRequest(HTTPContextPtr context, HTTPServerResponse , max_fields_number(context->getMaxFields()) , max_field_name_size(context->getMaxFieldNameSize()) , max_field_value_size(context->getMaxFieldValueSize()) + , max_request_header_size(context->getMaxRequestHeaderSize()) { response.attachRequest(this); @@ -41,14 +43,40 @@ HTTPServerRequest::HTTPServerRequest(HTTPContextPtr context, HTTPServerResponse auto receive_timeout = context->getReceiveTimeout(); auto send_timeout = context->getSendTimeout(); + auto headers_read_timeout = context->getHeadersReadTimeout(); - session.socket().setReceiveTimeout(receive_timeout); + /// Use the smaller of headers_read_timeout and receive_timeout during header parsing + /// to enforce a total deadline on the entire handshake phase. + auto effective_timeout = (headers_read_timeout > Poco::Timespan(0) && + (receive_timeout <= Poco::Timespan(0) || headers_read_timeout < receive_timeout)) + ? headers_read_timeout : receive_timeout; + + session.socket().setReceiveTimeout(effective_timeout); session.socket().setSendTimeout(send_timeout); - auto in = std::make_unique(session.socket(), read_event); + auto socket_in = std::make_unique(session.socket(), read_event); socket = session.socket().impl(); - readRequest(*in); /// Try parse according to RFC7230 + /// Wrap the socket buffer with a deadline check if configured. + /// The deadline is enforced in DeadlineReadBuffer::nextImpl on every buffer refill, + /// which protects all parsing (request line, URI, headers) automatically. + if (headers_read_timeout > Poco::Timespan(0)) + { + auto deadline = std::chrono::steady_clock::now() + + std::chrono::microseconds(headers_read_timeout.totalMicroseconds()); + DeadlineReadBuffer deadline_in(*socket_in, deadline); + readRequest(deadline_in); /// Try parse according to RFC7230 + } + else + { + readRequest(*socket_in); /// Try parse according to RFC7230 + } + + /// Restore the original receive timeout for body reads. + session.socket().setReceiveTimeout(receive_timeout); + + /// Build the body stream from the underlying socket buffer (not the deadline wrapper). + auto in = std::move(socket_in); /// If a client crashes, most systems will gracefully terminate the connection with FIN just like it's done on close(). /// So we will get 0 from recv(...) and will not be able to understand that something went wrong (well, we probably @@ -173,7 +201,7 @@ void HTTPServerRequest::readRequest(ReadBuffer & in) skipToNextLineOrEOF(in); - readHeaders(*this, in, max_fields_number, max_field_name_size, max_field_value_size); + readHeaders(*this, in, max_fields_number, max_field_name_size, max_field_value_size, max_request_header_size); skipToNextLineOrEOF(in); diff --git a/src/Server/HTTP/HTTPServerRequest.h b/src/Server/HTTP/HTTPServerRequest.h index c4beada5dca0..6da5c3651285 100644 --- a/src/Server/HTTP/HTTPServerRequest.h +++ b/src/Server/HTTP/HTTPServerRequest.h @@ -93,6 +93,7 @@ class HTTPServerRequest : public HTTPRequest const size_t max_fields_number; const size_t max_field_name_size; const size_t max_field_value_size; + const size_t max_request_header_size; mutable std::mutex get_stream_mutex; ReadBufferPtr stream TSA_GUARDED_BY(get_stream_mutex); diff --git a/src/Server/HTTP/ReadHeaders.cpp b/src/Server/HTTP/ReadHeaders.cpp index d6c7b8ddc0fe..142b47a8d6d2 100644 --- a/src/Server/HTTP/ReadHeaders.cpp +++ b/src/Server/HTTP/ReadHeaders.cpp @@ -9,7 +9,12 @@ namespace DB { void readHeaders( - Poco::Net::MessageHeader & headers, ReadBuffer & in, size_t max_fields_number, size_t max_name_length, size_t max_value_length) + Poco::Net::MessageHeader & headers, + ReadBuffer & in, + size_t max_fields_number, + size_t max_name_length, + size_t max_value_length, + size_t max_total_size) { char ch = 0; // silence uninitialized warning from gcc-* std::string name; @@ -19,6 +24,7 @@ void readHeaders( value.reserve(64); size_t fields = 0; + size_t total_size = 0; while (true) { @@ -74,6 +80,10 @@ void readHeaders( if (value.size() > max_value_length) throw Poco::Net::MessageException("Field value is too long"); + total_size += name.size() + value.size(); + if (max_total_size && total_size > max_total_size) + throw Poco::Net::MessageException("Total request header size is too large"); + skipToNextLineOrEOF(in); Poco::trimRightInPlace(value); diff --git a/src/Server/HTTP/ReadHeaders.h b/src/Server/HTTP/ReadHeaders.h index 1b0e627f7796..c7715a2f4b15 100644 --- a/src/Server/HTTP/ReadHeaders.h +++ b/src/Server/HTTP/ReadHeaders.h @@ -8,6 +8,11 @@ namespace DB class ReadBuffer; void readHeaders( - Poco::Net::MessageHeader & headers, ReadBuffer & in, size_t max_fields_number, size_t max_name_length, size_t max_value_length); + Poco::Net::MessageHeader & headers, + ReadBuffer & in, + size_t max_fields_number, + size_t max_name_length, + size_t max_value_length, + size_t max_total_size = 0); } diff --git a/tests/integration/test_http_header_limits/__init__.py b/tests/integration/test_http_header_limits/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/integration/test_http_header_limits/configs/users.xml b/tests/integration/test_http_header_limits/configs/users.xml new file mode 100644 index 000000000000..06ad12a54325 --- /dev/null +++ b/tests/integration/test_http_header_limits/configs/users.xml @@ -0,0 +1,12 @@ + + + + + 10 + 64 + 256 + 512 + 3 + + + diff --git a/tests/integration/test_http_header_limits/test.py b/tests/integration/test_http_header_limits/test.py new file mode 100644 index 000000000000..0470b567b8bb --- /dev/null +++ b/tests/integration/test_http_header_limits/test.py @@ -0,0 +1,237 @@ +import socket +import time +import re +import pytest +from helpers.cluster import ClickHouseCluster + +cluster = ClickHouseCluster(__file__) +node = cluster.add_instance( + "node", + user_configs=["configs/users.xml"], +) + +HTTP_PORT = 8123 + + +@pytest.fixture(scope="module") +def started_cluster(): + try: + cluster.start() + yield cluster + finally: + cluster.shutdown() + + +def send_raw_http(host, port, request_bytes, timeout=5): + """Send a raw HTTP request and return (status_code, body).""" + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(timeout) + sock.connect((host, port)) + sock.sendall(request_bytes) + + response = b"" + try: + while True: + chunk = sock.recv(4096) + if not chunk: + break + response += chunk + if b"\r\n\r\n" in response: + header_part, _, body_part = response.partition(b"\r\n\r\n") + match = re.search( + rb"Content-Length:\s*(\d+)", header_part, re.IGNORECASE + ) + if match: + content_length = int(match.group(1)) + if len(body_part) >= content_length: + break + else: + break + except socket.timeout: + pass + sock.close() + + if not response: + return 0, "" + + header_part, _, body_part = response.partition(b"\r\n\r\n") + status_line = header_part.split(b"\r\n")[0].decode() + parts = status_line.split(" ", 2) + status_code = int(parts[1]) if len(parts) >= 2 else 0 + body = body_part.decode(errors="replace").strip() + return status_code, body + + +def build_http_request(path="/?query=SELECT+1", headers=None): + """Build a raw HTTP/1.1 request.""" + if headers is None: + headers = {} + lines = [f"POST {path} HTTP/1.1"] + if "Host" not in headers: + lines.append("Host: localhost") + lines.append("Content-Length: 0") + for name, value in headers.items(): + lines.append(f"{name}: {value}") + lines.append("") + lines.append("") + return "\r\n".join(lines).encode() + + +# -- http_max_fields (configured to 10) -- + + +def test_max_fields_within_limit(started_cluster): + headers = {f"X-Test-{i}": "v" for i in range(5)} + request = build_http_request(headers=headers) + status, body = send_raw_http(node.ip_address, HTTP_PORT, request) + assert status == 200 + + +def test_max_fields_exceeds_limit(started_cluster): + # 12 custom headers + Host + Content-Length = 14, exceeding limit of 10. + headers = {f"X-Test-{i}": "v" for i in range(12)} + request = build_http_request(headers=headers) + status, body = send_raw_http(node.ip_address, HTTP_PORT, request) + assert status == 400 + assert body == "Too many header fields" + + +# -- http_max_field_name_size (configured to 64) -- + + +def test_field_name_within_limit(started_cluster): + headers = {"X-" + "a" * 50: "value"} + request = build_http_request(headers=headers) + status, body = send_raw_http(node.ip_address, HTTP_PORT, request) + assert status == 200 + + +def test_field_name_exceeds_limit(started_cluster): + headers = {"X-" + "a" * 100: "value"} + request = build_http_request(headers=headers) + status, body = send_raw_http(node.ip_address, HTTP_PORT, request) + assert status == 400 + assert body == "Field name is too long" + + +# -- http_max_field_value_size (configured to 256) -- + + +def test_field_value_within_limit(started_cluster): + headers = {"X-Test": "v" * 200} + request = build_http_request(headers=headers) + status, body = send_raw_http(node.ip_address, HTTP_PORT, request) + assert status == 200 + + +def test_field_value_exceeds_limit(started_cluster): + headers = {"X-Test": "v" * 300} + request = build_http_request(headers=headers) + status, body = send_raw_http(node.ip_address, HTTP_PORT, request) + assert status == 400 + assert body == "Field value is too long" + + +# -- http_max_request_header_size (configured to 512 bytes total) -- + + +def test_total_header_size_within_limit(started_cluster): + headers = {f"X-T{i}": "v" * 30 for i in range(3)} + request = build_http_request(headers=headers) + status, body = send_raw_http(node.ip_address, HTTP_PORT, request) + assert status == 200 + + +def test_total_header_size_exceeds_limit(started_cluster): + # 5 headers of ~200 bytes value each = ~1000 bytes total, exceeding 512 limit. + # Each value is under the 256 per-field limit. + headers = {f"X-Pad-{i}": "v" * 200 for i in range(5)} + request = build_http_request(headers=headers) + status, body = send_raw_http(node.ip_address, HTTP_PORT, request) + assert status == 400 + assert body == "Total request header size is too large" + + +# -- http_headers_read_timeout (configured to 3 seconds) -- + + +def test_normal_request_within_timeout(started_cluster): + request = build_http_request() + status, body = send_raw_http(node.ip_address, HTTP_PORT, request) + assert status == 200 + + +def test_slowloris_exceeds_timeout(started_cluster): + """Trickling header data slower than the timeout should be rejected.""" + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(10) + sock.connect((node.ip_address, HTTP_PORT)) + + sock.sendall(b"POST /?query=SELECT+1 HTTP/1.1\r\n") + sock.sendall(b"Host: localhost\r\n") + sock.sendall(b"Content-Length: 0\r\n") + + # Trickle one byte per 0.5 seconds — the 3-second timeout + # should trigger before we finish sending this header. + header_line = b"X-Slow: " + b"a" * 100 + b"\r\n" + send_failed = False + try: + for byte in header_line: + sock.sendall(bytes([byte])) + time.sleep(0.5) + except (BrokenPipeError, ConnectionResetError, OSError): + send_failed = True + + if not send_failed: + try: + sock.sendall(b"\r\n") + except (BrokenPipeError, ConnectionResetError, OSError): + send_failed = True + + if not send_failed: + response = b"" + try: + while True: + chunk = sock.recv(4096) + if not chunk: + break + response += chunk + except socket.timeout: + pass + + if response: + header_part, _, body_part = response.partition(b"\r\n\r\n") + status_line = header_part.split(b"\r\n")[0].decode() + parts = status_line.split(" ", 2) + status = int(parts[1]) if len(parts) >= 2 else 0 + body = body_part.decode(errors="replace").strip() + assert status == 400, f"Expected 400, got {status}" + assert body == "Timeout exceeded while reading HTTP headers" + # else: connection closed without response — also acceptable. + # else: send failed with broken pipe — server closed the connection. + + sock.close() + + +# -- query-string overrides must not bypass pre-auth limits -- + + +def test_max_fields_override_ignored(started_cluster): + headers = {f"X-Test-{i}": "v" for i in range(12)} + request = build_http_request( + path="/?query=SELECT+1&http_max_fields=1000", headers=headers + ) + status, body = send_raw_http(node.ip_address, HTTP_PORT, request) + assert status == 400 + assert body == "Too many header fields" + + +def test_max_request_header_size_override_ignored(started_cluster): + headers = {f"X-Pad-{i}": "v" * 200 for i in range(5)} + request = build_http_request( + path="/?query=SELECT+1&http_max_request_header_size=10485760", + headers=headers, + ) + status, body = send_raw_http(node.ip_address, HTTP_PORT, request) + assert status == 400 + assert body == "Total request header size is too large" From e87b6de6e240f34c7863f25d973ef117e91787ed Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 22 Apr 2026 11:40:19 +0000 Subject: [PATCH 34/70] Backport #103284 to 26.3: Cap pre-auth Hello packet strings to 64 KB and limit handshake time --- src/IO/ReadBufferFromPocoSocket.cpp | 20 + src/IO/ReadBufferFromPocoSocket.h | 11 + src/Server/TCPHandler.cpp | 39 +- .../test_tcp_hello_string_limits/__init__.py | 0 .../configs/config.d/handshake_timeout.xml | 3 + .../test_tcp_hello_string_limits/test.py | 454 ++++++++++++++++++ 6 files changed, 514 insertions(+), 13 deletions(-) create mode 100644 tests/integration/test_tcp_hello_string_limits/__init__.py create mode 100644 tests/integration/test_tcp_hello_string_limits/configs/config.d/handshake_timeout.xml create mode 100644 tests/integration/test_tcp_hello_string_limits/test.py diff --git a/src/IO/ReadBufferFromPocoSocket.cpp b/src/IO/ReadBufferFromPocoSocket.cpp index 0e7f3a496a59..c48ae04bd413 100644 --- a/src/IO/ReadBufferFromPocoSocket.cpp +++ b/src/IO/ReadBufferFromPocoSocket.cpp @@ -102,6 +102,13 @@ ssize_t ReadBufferFromPocoSocketBase::socketReceiveBytesImpl(char * ptr, size_t bool ReadBufferFromPocoSocketBase::nextImpl() { + if (handshake_timeout_milliseconds > 0 && handshake_stopwatch.elapsedMilliseconds() > handshake_timeout_milliseconds) + throw NetException( + ErrorCodes::SOCKET_TIMEOUT, + "Handshake timeout exceeded ({} milliseconds, peer: {})", + handshake_timeout_milliseconds, + peer_address.toString()); + if (internal_buffer.size() > INT_MAX) throw Exception(ErrorCodes::LOGICAL_ERROR, "Buffer overflow"); @@ -152,4 +159,17 @@ void ReadBufferFromPocoSocketBase::setReceiveTimeout(size_t receive_timeout_micr socket.setReceiveTimeout(Poco::Timespan(receive_timeout_microseconds, 0)); } +void ReadBufferFromPocoSocketBase::setHandshakeTimeout(size_t timeout_milliseconds) +{ + handshake_timeout_milliseconds = timeout_milliseconds; + if (handshake_timeout_milliseconds > 0) + handshake_stopwatch.restart(); +} + +void ReadBufferFromPocoSocketBase::clearHandshakeTimeout() +{ + handshake_timeout_milliseconds = 0; + handshake_stopwatch.stop(); +} + } diff --git a/src/IO/ReadBufferFromPocoSocket.h b/src/IO/ReadBufferFromPocoSocket.h index 2a0c02133020..0d63c08ff27f 100644 --- a/src/IO/ReadBufferFromPocoSocket.h +++ b/src/IO/ReadBufferFromPocoSocket.h @@ -3,6 +3,7 @@ #include #include #include +#include #include namespace DB @@ -36,9 +37,19 @@ class ReadBufferFromPocoSocketBase : public BufferWithOwnMemory void setReceiveTimeout(size_t receive_timeout_microseconds); + /// Set a wall-clock deadline for the entire handshake phase. + /// Every nextImpl() call will check elapsed time and throw SOCKET_TIMEOUT if exceeded. + /// Call clearHandshakeTimeout() after the handshake completes. + void setHandshakeTimeout(size_t timeout_milliseconds); + void clearHandshakeTimeout(); + private: AsyncCallback async_callback; std::string socket_description; + + /// Wall-clock deadline for the handshake phase (optional). + size_t handshake_timeout_milliseconds = 0; + Stopwatch handshake_stopwatch = Stopwatch(STOPWATCH_DEFAULT_CLOCK, 0, /* is running */ false); }; class ReadBufferFromPocoSocket : public ReadBufferFromPocoSocketBase diff --git a/src/Server/TCPHandler.cpp b/src/Server/TCPHandler.cpp index 85ad3a977a4c..f024bd1780d7 100644 --- a/src/Server/TCPHandler.cpp +++ b/src/Server/TCPHandler.cpp @@ -126,6 +126,7 @@ namespace ServerSetting extern const ServerSettingsBool process_query_plan_packet; extern const ServerSettingsUInt64 tcp_close_connection_after_queries_num; extern const ServerSettingsUInt64 tcp_close_connection_after_queries_seconds; + extern const ServerSettingsUInt64 handshake_timeout_milliseconds; } namespace FailPoints @@ -354,6 +355,11 @@ void TCPHandler::runImpl() in = std::make_shared(socket(), read_event); + /// Limit the total wall-clock time for the handshake phase to prevent + /// slowloris-style attacks from holding a thread indefinitely. + UInt64 handshake_timeout_ms = server.context()->getServerSettings()[ServerSetting::handshake_timeout_milliseconds]; + in->setHandshakeTimeout(handshake_timeout_ms); + /// Support for PROXY protocol if (parse_proxy_protocol && !receiveProxyHeader()) return; @@ -383,6 +389,8 @@ void TCPHandler::runImpl() if (client_tcp_protocol_version >= DBMS_MIN_PROTOCOL_VERSION_WITH_ADDENDUM) receiveAddendum(); + in->clearHandshakeTimeout(); + { /// Server side of chunked protocol negotiation. /// Server advertises its protocol capabilities (separate for send and receive channels) by sending @@ -1859,6 +1867,11 @@ std::unique_ptr TCPHandler::makeSession() } +/// Maximum size of a string field during the Hello handshake. +/// Applied before authentication to prevent unauthenticated clients +/// from consuming excessive memory. See #52501. +static constexpr size_t MAX_HELLO_STRING_SIZE = 64 * 1024; + void TCPHandler::receiveHello() { /// Receive `hello` packet. @@ -1885,16 +1898,16 @@ void TCPHandler::receiveHello() "Unexpected packet from client (expected Hello, got {})", packet_type); } - readStringBinary(client_name, *in); + readStringBinary(client_name, *in, MAX_HELLO_STRING_SIZE); readVarUInt(client_version_major, *in); readVarUInt(client_version_minor, *in); // NOTE For backward compatibility of the protocol, client cannot send its version_patch. readVarUInt(client_tcp_protocol_version, *in); - readStringBinary(default_db, *in); + readStringBinary(default_db, *in, MAX_HELLO_STRING_SIZE); if (!default_db.empty()) default_database = default_db; - readStringBinary(user, *in); - readStringBinary(password, *in); + readStringBinary(user, *in, MAX_HELLO_STRING_SIZE); + readStringBinary(password, *in, MAX_HELLO_STRING_SIZE); if (user.empty()) throw Exception(ErrorCodes::UNEXPECTED_PACKET_FROM_CLIENT, "Unexpected packet from client (no user in Hello package)"); @@ -1994,7 +2007,7 @@ void TCPHandler::receiveHello() readVarUInt(packet_type, *in); if (packet_type != Protocol::Client::SSHChallengeResponse) throw Exception(ErrorCodes::UNEXPECTED_PACKET_FROM_CLIENT, "Server expected to receive a packet with a response for a challenge"); - readStringBinary(signature, *in); + readStringBinary(signature, *in, MAX_HELLO_STRING_SIZE); auto prepare_string_for_ssh_validation = [&](const String & username, const String & challenge_) { @@ -2019,15 +2032,15 @@ void TCPHandler::receiveHello() void TCPHandler::receiveAddendum() { if (client_tcp_protocol_version >= DBMS_MIN_PROTOCOL_VERSION_WITH_QUOTA_KEY) - readStringBinary(quota_key, *in); + readStringBinary(quota_key, *in, MAX_HELLO_STRING_SIZE); if (!is_interserver_mode) session->setQuotaClientKey(quota_key); if (client_tcp_protocol_version >= DBMS_MIN_PROTOCOL_VERSION_WITH_CHUNKED_PACKETS) { - readStringBinary(proto_send_chunked_cl, *in); - readStringBinary(proto_recv_chunked_cl, *in); + readStringBinary(proto_send_chunked_cl, *in, MAX_HELLO_STRING_SIZE); + readStringBinary(proto_recv_chunked_cl, *in, MAX_HELLO_STRING_SIZE); } if (client_tcp_protocol_version >= DBMS_MIN_REVISION_WITH_VERSIONED_PARALLEL_REPLICAS_PROTOCOL) @@ -2040,13 +2053,13 @@ void TCPHandler::processUnexpectedHello() UInt64 skip_uint_64; String skip_string; - readStringBinary(skip_string, *in); + readStringBinary(skip_string, *in, MAX_HELLO_STRING_SIZE); readVarUInt(skip_uint_64, *in); readVarUInt(skip_uint_64, *in); readVarUInt(skip_uint_64, *in); - readStringBinary(skip_string, *in); - readStringBinary(skip_string, *in); - readStringBinary(skip_string, *in); + readStringBinary(skip_string, *in, MAX_HELLO_STRING_SIZE); + readStringBinary(skip_string, *in, MAX_HELLO_STRING_SIZE); + readStringBinary(skip_string, *in, MAX_HELLO_STRING_SIZE); throw Exception(ErrorCodes::UNEXPECTED_PACKET_FROM_CLIENT, "Unexpected packet Hello received from client"); } @@ -2181,7 +2194,7 @@ std::optional TCPHandler::receivePartitionMergeTreeReadTas void TCPHandler::processClusterNameAndSalt() { - readStringBinary(cluster, *in); + readStringBinary(cluster, *in, MAX_HELLO_STRING_SIZE); readStringBinary(salt, *in, 32); } diff --git a/tests/integration/test_tcp_hello_string_limits/__init__.py b/tests/integration/test_tcp_hello_string_limits/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/integration/test_tcp_hello_string_limits/configs/config.d/handshake_timeout.xml b/tests/integration/test_tcp_hello_string_limits/configs/config.d/handshake_timeout.xml new file mode 100644 index 000000000000..60c73d1061db --- /dev/null +++ b/tests/integration/test_tcp_hello_string_limits/configs/config.d/handshake_timeout.xml @@ -0,0 +1,3 @@ + + 3000 + diff --git a/tests/integration/test_tcp_hello_string_limits/test.py b/tests/integration/test_tcp_hello_string_limits/test.py new file mode 100644 index 000000000000..2c1186c6b008 --- /dev/null +++ b/tests/integration/test_tcp_hello_string_limits/test.py @@ -0,0 +1,454 @@ +import socket +import struct +import time + +import pytest +from helpers.cluster import ClickHouseCluster + +cluster = ClickHouseCluster(__file__) +node = cluster.add_instance( + "node", + main_configs=["configs/config.d/handshake_timeout.xml"], +) + +MAX_HELLO_STRING_SIZE = 64 * 1024 +OVERSIZED = 1 * 1024 * 1024 # 1 MB — exceeds the 64 KB limit + + +@pytest.fixture(scope="module") +def started_cluster(): + try: + cluster.start() + yield cluster + finally: + cluster.shutdown() + + +def encode_varuint(n): + """Encode an integer as a VarUInt (7 bits per byte, MSB continuation).""" + buf = bytearray() + while n >= 0x80: + buf.append((n & 0x7F) | 0x80) + n >>= 7 + buf.append(n & 0x7F) + return bytes(buf) + + +def encode_string(s): + """Encode a string as VarUInt length prefix + UTF-8 bytes.""" + if isinstance(s, str): + s = s.encode("utf-8") + return encode_varuint(len(s)) + s + + +def encode_oversized_string(size): + """Encode a string header claiming `size` bytes, followed by actual data. + + We only send a small amount of actual data — the server should reject + the connection after reading the size prefix (before the full payload). + """ + return encode_varuint(size) + b"A" * min(size, 4096) + + +def build_hello_packet( + client_name=b"test", + version_major=24, + version_minor=1, + tcp_protocol_version=54471, + default_db=b"", + user=b"default", + password=b"", + oversized_field=None, + oversized_size=OVERSIZED, +): + """Build a native protocol Hello packet. + + If `oversized_field` is set to one of "client_name", "default_db", + "user", "password", the corresponding field will be replaced with + an oversized string header. + """ + parts = [] + + # Packet type: Client::Hello = 0 + parts.append(encode_varuint(0)) + + # client_name + if oversized_field == "client_name": + parts.append(encode_oversized_string(oversized_size)) + else: + parts.append(encode_string(client_name)) + + # version_major, version_minor, tcp_protocol_version + parts.append(encode_varuint(version_major)) + parts.append(encode_varuint(version_minor)) + parts.append(encode_varuint(tcp_protocol_version)) + + # default_db + if oversized_field == "default_db": + parts.append(encode_oversized_string(oversized_size)) + else: + parts.append(encode_string(default_db)) + + # user + if oversized_field == "user": + parts.append(encode_oversized_string(oversized_size)) + else: + parts.append(encode_string(user)) + + # password + if oversized_field == "password": + parts.append(encode_oversized_string(oversized_size)) + else: + parts.append(encode_string(password)) + + return b"".join(parts) + + +USER_INTERSERVER_MARKER = " INTERSERVER SECRET " + + +def build_interserver_hello_with_oversized_cluster(oversized_size=OVERSIZED): + """Build a Hello packet that triggers the interserver path, + then sends an oversized cluster name.""" + parts = [] + + # Hello packet with interserver marker as user and empty password + parts.append(encode_varuint(0)) # Client::Hello = 0 + parts.append(encode_string(b"test")) # client_name + parts.append(encode_varuint(24)) # version_major + parts.append(encode_varuint(1)) # version_minor + parts.append(encode_varuint(54471)) # tcp_protocol_version + parts.append(encode_string(b"")) # default_db + parts.append(encode_string(USER_INTERSERVER_MARKER.encode())) # user + parts.append(encode_string(b"")) # password (empty for interserver) + + # After the hello fields, the server calls processClusterNameAndSalt + # which reads cluster (string) and salt (string, max 32 bytes) + parts.append(encode_oversized_string(oversized_size)) # cluster — oversized + + return b"".join(parts) + + +def decode_varuint(sock): + """Read a VarUInt from a socket.""" + result = 0 + shift = 0 + while True: + byte = sock.recv(1) + if not byte: + raise ConnectionError("Connection closed while reading VarUInt") + b = byte[0] + result |= (b & 0x7F) << shift + if (b & 0x80) == 0: + break + shift += 7 + return result + + +def skip_string(sock): + """Read and discard a length-prefixed string from a socket.""" + length = decode_varuint(sock) + remaining = length + while remaining > 0: + chunk = sock.recv(min(remaining, 65536)) + if not chunk: + raise ConnectionError("Connection closed while reading string") + remaining -= len(chunk) + + +def read_exact(sock, n): + """Read exactly n bytes from a socket.""" + buf = b"" + while len(buf) < n: + chunk = sock.recv(n - len(buf)) + if not chunk: + raise ConnectionError("Connection closed while reading bytes") + buf += chunk + return buf + + +def skip_settings(sock): + """Read and discard a serialized Settings block from a socket. + + Format: sequence of (String name, VarUInt flags, String value), + terminated by an empty name (single 0x00 byte). + """ + while True: + name_len = decode_varuint(sock) + if name_len == 0: + break + remaining = name_len + while remaining > 0: + chunk = sock.recv(min(remaining, 65536)) + if not chunk: + raise ConnectionError("Connection closed while reading settings name") + remaining -= len(chunk) + decode_varuint(sock) # flags + skip_string(sock) # value + + +def complete_hello_handshake(sock, tcp_protocol_version=54471): + """Send a valid Hello packet and read the server's Hello response. + + Returns the socket ready for sending addendum or query packets. + The Hello uses user=default with empty password (no auth needed + for default user in test config). + """ + # Send Hello + hello = build_hello_packet(tcp_protocol_version=tcp_protocol_version) + sock.sendall(hello) + + # Read server Hello response: + # VarUInt packet_type (0 = Hello), String server_name, + # VarUInt major, VarUInt minor, VarUInt revision + packet_type = decode_varuint(sock) + if packet_type == 2: + # Exception packet — auth failure or other error + raise Exception("Server returned exception during Hello") + assert packet_type == 0, f"Expected Hello response (0), got {packet_type}" + + skip_string(sock) # server_name + decode_varuint(sock) # version_major + decode_varuint(sock) # version_minor + decode_varuint(sock) # revision + + # Conditional fields based on protocol version + if tcp_protocol_version >= 54471: # DBMS_MIN_REVISION_WITH_VERSIONED_PARALLEL_REPLICAS_PROTOCOL + decode_varuint(sock) # parallel_replicas_protocol_version + if tcp_protocol_version >= 54058: # DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE + skip_string(sock) # server_timezone + if tcp_protocol_version >= 54372: # DBMS_MIN_REVISION_WITH_SERVER_DISPLAY_NAME + skip_string(sock) # server_display_name + if tcp_protocol_version >= 54401: # DBMS_MIN_REVISION_WITH_VERSION_PATCH + decode_varuint(sock) # version_patch + if tcp_protocol_version >= 54470: # DBMS_MIN_PROTOCOL_VERSION_WITH_CHUNKED_PACKETS + skip_string(sock) # proto_send_chunked + skip_string(sock) # proto_recv_chunked + if tcp_protocol_version >= 54461: # DBMS_MIN_PROTOCOL_VERSION_WITH_PASSWORD_COMPLEXITY_RULES + num_rules = decode_varuint(sock) + for _ in range(num_rules): + skip_string(sock) # original_pattern + skip_string(sock) # exception_message + if tcp_protocol_version >= 54462: # DBMS_MIN_REVISION_WITH_INTERSERVER_SECRET_V2 + read_exact(sock, 8) # nonce (Int64) + if tcp_protocol_version >= 54474: # DBMS_MIN_REVISION_WITH_SERVER_SETTINGS + skip_settings(sock) + if tcp_protocol_version >= 54477: # DBMS_MIN_REVISION_WITH_QUERY_PLAN_SERIALIZATION + decode_varuint(sock) # query_plan_serialization_version + if tcp_protocol_version >= 54479: # DBMS_MIN_REVISION_WITH_VERSIONED_CLUSTER_FUNCTION_PROTOCOL + decode_varuint(sock) # cluster_processing_protocol_version + + return sock + + +def send_packet_expect_rejection(node, packet): + """Send a raw packet to the ClickHouse native port and expect rejection. + + The server should close the connection or send an error response. + Returns True if the connection was rejected (as expected). + """ + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(10) + try: + sock.connect((node.ip_address, 9000)) + sock.sendall(packet) + # Try to receive — we expect the server to close the connection + # or send an exception packet + try: + response = sock.recv(4096) + # If we get a response, check it is an exception (packet type 2) + if response and response[0] == 2: + return True # Exception packet — rejected as expected + # Empty response means connection closed + assert len(response) == 0 + except (ConnectionResetError, BrokenPipeError): + return True # Connection reset — rejected as expected + except socket.timeout: + return False # Server did not reject in time + finally: + sock.close() + + +@pytest.mark.parametrize( + "field_name", + ["client_name", "default_db", "user", "password"], +) +def test_oversized_hello_field_rejected(started_cluster, field_name): + """Each Hello string field exceeding 64 KB must be rejected.""" + packet = build_hello_packet(oversized_field=field_name) + assert send_packet_expect_rejection( + node, packet + ), f"Server did not reject oversized {field_name}" + + +def test_oversized_cluster_name_rejected(started_cluster): + """The cluster field in processClusterNameAndSalt must be rejected + when exceeding 64 KB (reachable via interserver marker user).""" + packet = build_interserver_hello_with_oversized_cluster() + assert send_packet_expect_rejection( + node, packet + ), "Server did not reject oversized cluster name" + + +def test_boundary_just_over_limit_rejected(started_cluster): + """A string of exactly 64 KB + 1 byte must be rejected.""" + packet = build_hello_packet( + oversized_field="client_name", + oversized_size=MAX_HELLO_STRING_SIZE + 1, + ) + assert send_packet_expect_rejection( + node, packet + ), "Server did not reject string of 64 KB + 1" + + +def test_boundary_at_limit_accepted(started_cluster): + """A string of exactly 64 KB must be accepted (not rejected).""" + # Build a Hello packet where client_name is exactly 64 KB + large_name = b"A" * MAX_HELLO_STRING_SIZE + packet = build_hello_packet(client_name=large_name) + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(10) + try: + sock.connect((node.ip_address, 9000)) + sock.sendall(packet) + # The server should NOT reject this — it should proceed to auth + # (which will fail because user is "default" with no password, + # but that is after reading all fields successfully). + response = sock.recv(4096) + # We expect either a Hello response (packet type 0) or an + # Exception (packet type 2) from auth failure — NOT a connection + # reset from TOO_LARGE_STRING_SIZE. + assert len(response) > 0, "Server closed connection for a 64 KB string" + finally: + sock.close() + + +@pytest.mark.parametrize( + "field_name", + ["quota_key", "proto_send_chunked", "proto_recv_chunked"], +) +def test_oversized_addendum_field_rejected(started_cluster, field_name): + """Addendum string fields exceeding 64 KB must be rejected. + + The addendum is sent after the Hello handshake completes. + quota_key is sent when protocol >= 54458, + proto_send_chunked/proto_recv_chunked when protocol >= 54470. + """ + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(10) + try: + sock.connect((node.ip_address, 9000)) + complete_hello_handshake(sock, tcp_protocol_version=54471) + + # Build addendum with one oversized field + parts = [] + + # quota_key (protocol >= 54458) + if field_name == "quota_key": + parts.append(encode_oversized_string(OVERSIZED)) + else: + parts.append(encode_string(b"")) + + # proto_send_chunked_cl, proto_recv_chunked_cl (protocol >= 54470) + if field_name == "proto_send_chunked": + parts.append(encode_oversized_string(OVERSIZED)) + else: + parts.append(encode_string(b"notchunked")) + + if field_name == "proto_recv_chunked": + parts.append(encode_oversized_string(OVERSIZED)) + else: + parts.append(encode_string(b"notchunked")) + + sock.sendall(b"".join(parts)) + response = b"" + + # Expect rejection + try: + response = sock.recv(4096) + if response and response[0] == 2: + return # Exception packet — rejected as expected + assert len(response) == 0, f"Server did not reject oversized {field_name}, got response: {response}" + except (ConnectionResetError, BrokenPipeError): + pass # Connection reset — rejected as expected + finally: + sock.close() + + +def test_oversized_unexpected_hello_rejected(started_cluster): + """processUnexpectedHello string fields exceeding 64 KB must be rejected. + + After completing the handshake + addendum, sending a Hello packet (type 0) + instead of a Query triggers processUnexpectedHello which reads 4 strings. + """ + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(10) + try: + sock.connect((node.ip_address, 9000)) + complete_hello_handshake(sock, tcp_protocol_version=54471) + + # Send valid addendum to complete the handshake + parts = [] + parts.append(encode_string(b"")) # quota_key + parts.append(encode_string(b"notchunked")) # proto_send_chunked + parts.append(encode_string(b"notchunked")) # proto_recv_chunked + # parallel_replicas_protocol_version (protocol >= 54471) + parts.append(encode_varuint(0)) + sock.sendall(b"".join(parts)) + + # Now send a Hello packet (type 0) with an oversized string — + # this triggers processUnexpectedHello + unexpected = [] + unexpected.append(encode_varuint(0)) # Client::Hello = 0 + unexpected.append(encode_oversized_string(OVERSIZED)) # oversized client_name + sock.sendall(b"".join(unexpected)) + + # Expect rejection + try: + response = sock.recv(4096) + if response and response[0] == 2: + return # Exception packet — rejected as expected + assert len(response) == 0, "Server did not reject oversized unexpected Hello" + except (ConnectionResetError, BrokenPipeError): + pass # Connection reset — rejected as expected + finally: + sock.close() + + +def test_slowloris_handshake_timeout(started_cluster): + """A client that trickles data too slowly must be disconnected + by the handshake wall-clock timeout (set to 3 seconds in test config).""" + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(10) + try: + sock.connect((node.ip_address, 9000)) + # Send just the Hello packet type byte, then trickle slowly + sock.sendall(encode_varuint(0)) # Client::Hello = 0 + # Send client_name length prefix claiming a small string (10 bytes) + sock.sendall(encode_varuint(10)) + # Trickle 1 byte per second — the handshake timeout (3s) should fire + # before we finish sending the 10-byte string + for i in range(10): + time.sleep(1) + try: + sock.sendall(b"A") + except (BrokenPipeError, ConnectionResetError, OSError): + return # Server closed the connection — expected + # If we sent all 10 bytes, try to send more / receive response + # The server should have closed the connection by now + try: + response = sock.recv(4096) + # Exception packet (type 2) with timeout error is acceptable + if response and response[0] == 2: + return + assert len(response) == 0, "Server did not enforce handshake timeout" + except (ConnectionResetError, BrokenPipeError, OSError): + pass # Server closed the connection — expected + finally: + sock.close() + + +def test_server_healthy_after_rejections(started_cluster): + """After rejecting oversized packets, the server must still be healthy.""" + result = node.query("SELECT 1") + assert result.strip() == "1" From dae0464424528c1d0b306ccac162071759a2767f Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 22 Apr 2026 14:48:33 +0000 Subject: [PATCH 35/70] Backport #103080 to 26.3: Apply max_network_bandwidth_for_{user,all_users} to remote filesystem reads/writes --- src/Common/ProfileEvents.cpp | 4 ++ src/Interpreters/Context.cpp | 9 +++ src/Interpreters/ProcessList.cpp | 20 ++++++- ...user_network_bandwidth_throttler.reference | 2 + .../04103_user_network_bandwidth_throttler.sh | 57 +++++++++++++++++++ 5 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 tests/queries/0_stateless/04103_user_network_bandwidth_throttler.reference create mode 100755 tests/queries/0_stateless/04103_user_network_bandwidth_throttler.sh diff --git a/src/Common/ProfileEvents.cpp b/src/Common/ProfileEvents.cpp index 9872e039abfa..6acf71a5374a 100644 --- a/src/Common/ProfileEvents.cpp +++ b/src/Common/ProfileEvents.cpp @@ -223,6 +223,10 @@ M(MergesThrottlerSleepMicroseconds, "Total time a query was sleeping to conform 'max_merges_bandwidth_for_server' throttling.", ValueType::Microseconds) \ M(MutationsThrottlerBytes, "Bytes passed through 'max_mutations_bandwidth_for_server' throttler.", ValueType::Bytes) \ M(MutationsThrottlerSleepMicroseconds, "Total time a query was sleeping to conform 'max_mutations_bandwidth_for_server' throttling.", ValueType::Microseconds) \ + M(UserThrottlerBytes, "Bytes passed through 'max_network_bandwidth_for_user' throttler.", ValueType::Bytes) \ + M(UserThrottlerSleepMicroseconds, "Total time a query was sleeping to conform 'max_network_bandwidth_for_user' throttling.", ValueType::Microseconds) \ + M(AllUsersThrottlerBytes, "Bytes passed through 'max_network_bandwidth_for_all_users' throttler.", ValueType::Bytes) \ + M(AllUsersThrottlerSleepMicroseconds, "Total time a query was sleeping to conform 'max_network_bandwidth_for_all_users' throttling.", ValueType::Microseconds) \ M(QueryRemoteReadThrottlerBytes, "Bytes passed through 'max_remote_read_network_bandwidth' throttler.", ValueType::Bytes) \ M(QueryRemoteReadThrottlerSleepMicroseconds, "Total time a query was sleeping to conform 'max_remote_read_network_bandwidth' throttling.", ValueType::Microseconds) \ M(QueryRemoteWriteThrottlerBytes, "Bytes passed through 'max_remote_write_network_bandwidth' throttler.", ValueType::Bytes) \ diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index 92ae95d7e9c9..ad3f0db3f193 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -4680,6 +4681,10 @@ ThrottlerPtr Context::getRemoteReadThrottler() const throttler = shared->remote_read_throttler; } + /// User-level throttler (`max_network_bandwidth_for_user` / `max_network_bandwidth_for_all_users`). + if (auto process_list_element = getProcessListElement()) + addThrottler(throttler, process_list_element->getUserNetworkThrottler()); + if (auto bandwidth = getSettingsRef()[Setting::max_remote_read_network_bandwidth]) { std::lock_guard lock(mutex); @@ -4698,6 +4703,10 @@ ThrottlerPtr Context::getRemoteWriteThrottler() const throttler = shared->remote_write_throttler; } + /// User-level throttler (`max_network_bandwidth_for_user` / `max_network_bandwidth_for_all_users`). + if (auto process_list_element = getProcessListElement()) + addThrottler(throttler, process_list_element->getUserNetworkThrottler()); + if (auto bandwidth = getSettingsRef()[Setting::max_remote_write_network_bandwidth]) { std::lock_guard lock(mutex); diff --git a/src/Interpreters/ProcessList.cpp b/src/Interpreters/ProcessList.cpp index 412ce9c0ec93..482825074e02 100644 --- a/src/Interpreters/ProcessList.cpp +++ b/src/Interpreters/ProcessList.cpp @@ -26,6 +26,14 @@ namespace CurrentMetrics extern const Metric QueryNonInternal; } +namespace ProfileEvents +{ + extern const Event UserThrottlerBytes; + extern const Event UserThrottlerSleepMicroseconds; + extern const Event AllUsersThrottlerBytes; + extern const Event AllUsersThrottlerSleepMicroseconds; +} + namespace DB { namespace Setting @@ -379,14 +387,20 @@ ProcessList::EntryPtr ProcessList::insert( if (!total_network_throttler && settings[Setting::max_network_bandwidth_for_all_users]) { - total_network_throttler = std::make_shared(settings[Setting::max_network_bandwidth_for_all_users]); + total_network_throttler = std::make_shared( + settings[Setting::max_network_bandwidth_for_all_users], + ProfileEvents::AllUsersThrottlerBytes, + ProfileEvents::AllUsersThrottlerSleepMicroseconds); } if (!user_process_list.user_throttler) { if (settings[Setting::max_network_bandwidth_for_user]) - user_process_list.user_throttler - = std::make_shared(settings[Setting::max_network_bandwidth_for_user], total_network_throttler); + user_process_list.user_throttler = std::make_shared( + settings[Setting::max_network_bandwidth_for_user], + total_network_throttler, + ProfileEvents::UserThrottlerBytes, + ProfileEvents::UserThrottlerSleepMicroseconds); else if (settings[Setting::max_network_bandwidth_for_all_users]) user_process_list.user_throttler = total_network_throttler; } diff --git a/tests/queries/0_stateless/04103_user_network_bandwidth_throttler.reference b/tests/queries/0_stateless/04103_user_network_bandwidth_throttler.reference new file mode 100644 index 000000000000..71042daeaa59 --- /dev/null +++ b/tests/queries/0_stateless/04103_user_network_bandwidth_throttler.reference @@ -0,0 +1,2 @@ +read 1 1 1 +write 1 1 1 diff --git a/tests/queries/0_stateless/04103_user_network_bandwidth_throttler.sh b/tests/queries/0_stateless/04103_user_network_bandwidth_throttler.sh new file mode 100755 index 000000000000..4aa17ce0b892 --- /dev/null +++ b/tests/queries/0_stateless/04103_user_network_bandwidth_throttler.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# Tags: no-fasttest, long +# no-fasttest: needs S3, and the test is slow (exercises throttling) + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CUR_DIR"/../shell_config.sh + +# Separate users for INSERT and SELECT: each gets its own +# `ProcessListForUser::user_throttler`, so the two queries can run in parallel +# without sharing the same user-level token bucket. +READ_USER="u_04103_r_$CLICKHOUSE_DATABASE" +WRITE_USER="u_04103_w_$CLICKHOUSE_DATABASE" +$CLICKHOUSE_CLIENT --format Null -q "CREATE USER $READ_USER, $WRITE_USER" + +$CLICKHOUSE_CLIENT -m -q " + DROP TABLE IF EXISTS data_04103; + CREATE TABLE data_04103 (key UInt64 CODEC(NONE)) ENGINE=MergeTree() ORDER BY key + SETTINGS min_bytes_for_wide_part=1e9, disk='s3_disk'; + INSERT INTO data_04103 SELECT * FROM numbers(1e6); + GRANT SELECT, INSERT ON ${CLICKHOUSE_DATABASE}.data_04103 TO $READ_USER, $WRITE_USER; +" + +write_query_id="04103_w_$CLICKHOUSE_DATABASE" +read_query_id="04103_r_$CLICKHOUSE_DATABASE" + +# Writing/reading ~1e6*8 bytes with a 1M/s cap should each take ~7 seconds. +# They run in parallel (~7s wall-clock) because each user has its own throttler. +$CLICKHOUSE_CLIENT --user "$WRITE_USER" --query_id "$write_query_id" -q " + INSERT INTO ${CLICKHOUSE_DATABASE}.data_04103 SELECT number+1e6 FROM numbers(1e6) + SETTINGS max_network_bandwidth_for_user = 1000000 +" & +$CLICKHOUSE_CLIENT --user "$READ_USER" --query_id "$read_query_id" -q " + SELECT * FROM ${CLICKHOUSE_DATABASE}.data_04103 WHERE key < 1e6 FORMAT Null + SETTINGS max_network_bandwidth_for_user = 1000000 +" & +wait + +# FIXME: some issues with query plan serialization +$CLICKHOUSE_CLIENT --serialize_query_plan=0 -m -q " + SYSTEM FLUSH LOGS query_log; + SELECT + if(query_id = '$write_query_id', 'write', 'read') AS q, + query_duration_ms >= 7e3, + ProfileEvents['UserThrottlerBytes'] > 8e6, + ProfileEvents['UserThrottlerSleepMicroseconds'] > 7e6 * 0.5 + FROM system.query_log + WHERE event_date >= yesterday() AND event_time >= now() - 600 + AND current_database = '$CLICKHOUSE_DATABASE' + AND query_id IN ('$write_query_id', '$read_query_id') AND type != 'QueryStart' + ORDER BY q +" + +$CLICKHOUSE_CLIENT --format Null -q " + DROP TABLE data_04103; + DROP USER $READ_USER, $WRITE_USER; +" From e7fcb2bdff209821e11b4481967f741dbddbee6d Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Thu, 23 Apr 2026 00:57:40 +0000 Subject: [PATCH 36/70] Backport #103392 to 26.3: Check for malformed flattened Dynamic data in Native format --- .../SerializationDynamicHelpers.cpp | 12 ++++++++++++ ..._dynamic_flattened_malformed_index.reference | 1 + .../04108_dynamic_flattened_malformed_index.sh | 16 ++++++++++++++++ .../dynamic_flattened_bad_index.native | Bin 0 -> 64 bytes 4 files changed, 29 insertions(+) create mode 100644 tests/queries/0_stateless/04108_dynamic_flattened_malformed_index.reference create mode 100755 tests/queries/0_stateless/04108_dynamic_flattened_malformed_index.sh create mode 100644 tests/queries/0_stateless/data_native/dynamic_flattened_bad_index.native diff --git a/src/DataTypes/Serializations/SerializationDynamicHelpers.cpp b/src/DataTypes/Serializations/SerializationDynamicHelpers.cpp index dcc166feadd9..1a32e0e95277 100644 --- a/src/DataTypes/Serializations/SerializationDynamicHelpers.cpp +++ b/src/DataTypes/Serializations/SerializationDynamicHelpers.cpp @@ -14,6 +14,7 @@ namespace DB namespace ErrorCodes { extern const int LOGICAL_ERROR; + extern const int INCORRECT_DATA; } namespace @@ -157,6 +158,17 @@ void fillDynamicColumn( for (size_t i = 0; i != indexes_data.size(); ++i) { auto index = indexes_data[i]; + if (index > null_index) + throw Exception( + ErrorCodes::INCORRECT_DATA, + "Incorrect index {} in indexes column of flattened Dynamic column at row {}: " + "the index should be in range [0, {}] (there are {} types, index {} is reserved for NULL values)", + static_cast(index), + i, + null_index, + flattened_column.types.size(), + null_index); + if (index == null_index) { local_discriminators.push_back(ColumnVariant::NULL_DISCRIMINATOR); diff --git a/tests/queries/0_stateless/04108_dynamic_flattened_malformed_index.reference b/tests/queries/0_stateless/04108_dynamic_flattened_malformed_index.reference new file mode 100644 index 000000000000..336d78135719 --- /dev/null +++ b/tests/queries/0_stateless/04108_dynamic_flattened_malformed_index.reference @@ -0,0 +1 @@ +Incorrect index 10 in indexes column of flattened Dynamic column at row 2: the index should be in range [0, 2] (there are 2 types, index 2 is reserved for NULL values) diff --git a/tests/queries/0_stateless/04108_dynamic_flattened_malformed_index.sh b/tests/queries/0_stateless/04108_dynamic_flattened_malformed_index.sh new file mode 100755 index 000000000000..027009815edb --- /dev/null +++ b/tests/queries/0_stateless/04108_dynamic_flattened_malformed_index.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Tags: no-fasttest + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CUR_DIR"/../shell_config.sh + +# Test that reading a Native file with a corrupted index in flattened Dynamic +# serialization produces an informative error message instead of a crash. +# +# The file data_native/dynamic_flattened_bad_index.native is a pregenerated +# Native file with flattened Dynamic serialization for Dynamic(max_types=2) +# containing 3 rows: (42::Int64, 'hello', NULL). The NULL index byte (value 2) +# was changed to 10, which exceeds the valid range [0, 2]. + +$CLICKHOUSE_LOCAL --table test --input-format Native -q "SELECT * FROM test" < "${CUR_DIR}/data_native/dynamic_flattened_bad_index.native" 2>&1 | grep -o 'Incorrect index.*reserved for NULL values)' diff --git a/tests/queries/0_stateless/data_native/dynamic_flattened_bad_index.native b/tests/queries/0_stateless/data_native/dynamic_flattened_bad_index.native new file mode 100644 index 0000000000000000000000000000000000000000..787e73ad1e27f15e99e97f1de6a8ac8d471548c3 GIT binary patch literal 64 zcmZQ%W=s)rsmx2v%}mzFO{|D7sVqn>wl&gZW`F=DR?oZ=GZVJplA_GKbOuH)EvN)* JMruw@J^=RG4o3h0 literal 0 HcmV?d00001 From eadf67b1b4b6676fd821d0f0b034fb0b70212f63 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 23 Apr 2026 10:13:41 +0200 Subject: [PATCH 37/70] Apply suggestions from code review Co-authored-by: Azat Khuzhin --- src/Interpreters/Context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index ad3f0db3f193..2a2e7a2b5386 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -4682,7 +4682,7 @@ ThrottlerPtr Context::getRemoteReadThrottler() const } /// User-level throttler (`max_network_bandwidth_for_user` / `max_network_bandwidth_for_all_users`). - if (auto process_list_element = getProcessListElement()) + if (auto process_list_element = getProcessListElementSafe()) addThrottler(throttler, process_list_element->getUserNetworkThrottler()); if (auto bandwidth = getSettingsRef()[Setting::max_remote_read_network_bandwidth]) @@ -4704,7 +4704,7 @@ ThrottlerPtr Context::getRemoteWriteThrottler() const } /// User-level throttler (`max_network_bandwidth_for_user` / `max_network_bandwidth_for_all_users`). - if (auto process_list_element = getProcessListElement()) + if (auto process_list_element = getProcessListElementSafe()) addThrottler(throttler, process_list_element->getUserNetworkThrottler()); if (auto bandwidth = getSettingsRef()[Setting::max_remote_write_network_bandwidth]) From b3ea037a8ac109204e3d7780c9780c4c50acb3ca Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Thu, 23 Apr 2026 15:00:30 +0000 Subject: [PATCH 38/70] Backport #103273 to 26.3: Fix possible crash during statistics calculation in Map type with lazy replication --- src/Processors/Merges/Algorithms/MergedData.cpp | 6 ++++-- ..._replicated_and_non_replicated_columns_merge.reference | 0 .../04108_replicated_and_non_replicated_columns_merge.sql | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tests/queries/0_stateless/04108_replicated_and_non_replicated_columns_merge.reference create mode 100644 tests/queries/0_stateless/04108_replicated_and_non_replicated_columns_merge.sql diff --git a/src/Processors/Merges/Algorithms/MergedData.cpp b/src/Processors/Merges/Algorithms/MergedData.cpp index 5d63ecca6df4..a3d2c9953e97 100644 --- a/src/Processors/Merges/Algorithms/MergedData.cpp +++ b/src/Processors/Merges/Algorithms/MergedData.cpp @@ -132,10 +132,12 @@ void MergedData::insertChunk(Chunk && chunk, size_t rows_size) } /// For columns with statistics (like Map with adaptive buckets) we can reuse the column /// from the input chunk, but need to preserve the merged statistics computed during `initialize`. - /// `takeOrCalculateStatisticsFrom` is delegated through `ColumnReplicated` to the nested - /// column, so no special handling is needed when `chunk_columns[i]` is `ColumnReplicated`. else if (columns[i]->hasStatistics()) { + /// We cannot call takeOrCalculateStatisticsFrom for non-replicated column with replicated arguments. + if (columns[i]->getPtr()->isReplicated() && !chunk_columns[i]->isReplicated()) + chunk_columns[i] = ColumnReplicated::create(std::move(chunk_columns[i])); + chunk_columns[i]->takeOrCalculateStatisticsFrom({columns[i]->getPtr()}); columns[i] = std::move(chunk_columns[i]); } diff --git a/tests/queries/0_stateless/04108_replicated_and_non_replicated_columns_merge.reference b/tests/queries/0_stateless/04108_replicated_and_non_replicated_columns_merge.reference new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/queries/0_stateless/04108_replicated_and_non_replicated_columns_merge.sql b/tests/queries/0_stateless/04108_replicated_and_non_replicated_columns_merge.sql new file mode 100644 index 000000000000..9ad7e1a1c9a2 --- /dev/null +++ b/tests/queries/0_stateless/04108_replicated_and_non_replicated_columns_merge.sql @@ -0,0 +1,8 @@ +SELECT * FROM +( + SELECT n, m FROM (SELECT 2 AS n, map('a', toString(number)) AS m, [1] AS arr FROM numbers(1)) ARRAY JOIN arr + UNION ALL + SELECT 1 AS n, map('a', toString(number)) AS m FROM numbers(1) +) +ORDER BY n +FORMAT Null; From 517ecda48bd7e2e335e46ce93e5164a032a6c9b6 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Thu, 23 Apr 2026 15:48:37 +0000 Subject: [PATCH 39/70] Backport #103052 to 26.3: Fix wrong results in `DISTINCT` with partial aggregate projection --- .../optimizeUseAggregateProjection.cpp | 25 +++++- ...ojection_partial_projection_data.reference | 79 +++++++++++++++++++ ...ate_projection_partial_projection_data.sql | 38 +++++++++ 3 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 tests/queries/0_stateless/04099_distinct_aggregate_projection_partial_projection_data.reference create mode 100644 tests/queries/0_stateless/04099_distinct_aggregate_projection_partial_projection_data.sql diff --git a/src/Processors/QueryPlan/Optimizations/optimizeUseAggregateProjection.cpp b/src/Processors/QueryPlan/Optimizations/optimizeUseAggregateProjection.cpp index cac258e1f5d1..78adfdc03901 100644 --- a/src/Processors/QueryPlan/Optimizations/optimizeUseAggregateProjection.cpp +++ b/src/Processors/QueryPlan/Optimizations/optimizeUseAggregateProjection.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -952,7 +953,8 @@ std::optional optimizeUseAggregateProjections( const auto & expected_header = node.step->getOutputHeader(); if (blocksHaveEqualStructure(*projection_header, *expected_header)) { - node.step->updateInputHeader(projection_header); + if (!has_parent_parts) + node.step->updateInputHeader(projection_header); } else { @@ -970,7 +972,26 @@ std::optional optimizeUseAggregateProjections( } if (has_parent_parts) - node.children.push_back(source_node); + { + if (aggregating) + { + node.children.push_back(source_node); + } + else + { + /// Some parts have no projection data. DistinctStep must see rows from both readings + /// to return the correct set of distinct values; union them into its single input. + auto * main_node = node.children.front(); + SharedHeaders input_headers = { + main_node->step->getOutputHeader(), + source_node->step->getOutputHeader(), + }; + auto & union_node = nodes.emplace_back(); + union_node.step = std::make_unique(std::move(input_headers)); + union_node.children = {main_node, source_node}; + node.children.front() = &union_node; + } + } else node.children.front() = source_node; diff --git a/tests/queries/0_stateless/04099_distinct_aggregate_projection_partial_projection_data.reference b/tests/queries/0_stateless/04099_distinct_aggregate_projection_partial_projection_data.reference new file mode 100644 index 000000000000..ea3de10a33dc --- /dev/null +++ b/tests/queries/0_stateless/04099_distinct_aggregate_projection_partial_projection_data.reference @@ -0,0 +1,79 @@ +-- { echo } + +SET optimize_use_projections = 1; +DROP TABLE IF EXISTS test_distinct_proj_partial_projection; +CREATE TABLE test_distinct_proj_partial_projection +( + a UInt32, + b UInt32 +) +ENGINE = MergeTree ORDER BY tuple(); +INSERT INTO test_distinct_proj_partial_projection VALUES (1, 10), (1, 10), (2, 20), (3, 30), (3, 30); +ALTER TABLE test_distinct_proj_partial_projection ADD PROJECTION p (SELECT count() GROUP BY a, b); +INSERT INTO test_distinct_proj_partial_projection VALUES (3, 30), (4, 40), (4, 40), (5, 50), (6, 60), (6, 60); +SELECT count() FROM test_distinct_proj_partial_projection; +11 +SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection ORDER BY a, b; +1 10 +2 20 +3 30 +4 40 +5 50 +6 60 +EXPLAIN SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection ORDER BY a, b SETTINGS optimize_move_to_prewhere = 1, query_plan_optimize_prewhere = 1; +Expression (Project names) + Distinct (DISTINCT) + Sorting (Sorting for ORDER BY) + Expression (Before ORDER BY) + Distinct (Preliminary DISTINCT) + Union + Expression ((Projection + Change column names to column identifiers)) + ReadFromMergeTree (default.test_distinct_proj_partial_projection) + Expression + ReadFromMergeTree (p) +SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection WHERE a <= 2 ORDER BY a, b; +1 10 +2 20 +EXPLAIN SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection WHERE a <= 2 ORDER BY a, b SETTINGS optimize_move_to_prewhere = 1, query_plan_optimize_prewhere = 1; +Expression (Project names) + Distinct (DISTINCT) + Sorting (Sorting for ORDER BY) + Expression (Before ORDER BY) + Distinct (Preliminary DISTINCT) + Union + Expression (Projection) + Expression ((WHERE + Change column names to column identifiers)) + ReadFromMergeTree (default.test_distinct_proj_partial_projection) + Filter + ReadFromPreparedSource (p) +SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection WHERE a >= 4 ORDER BY a, b; +4 40 +5 50 +6 60 +EXPLAIN SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection WHERE a >= 4 ORDER BY a, b SETTINGS optimize_move_to_prewhere = 1, query_plan_optimize_prewhere = 1; +Expression (Project names) + Distinct (DISTINCT) + Sorting (Sorting for ORDER BY) + Expression (Before ORDER BY) + Distinct (Preliminary DISTINCT) + Union + Expression (Projection) + Expression ((WHERE + Change column names to column identifiers)) + ReadFromMergeTree (default.test_distinct_proj_partial_projection) + Filter + ReadFromMergeTree (p) +SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection WHERE a = 3 ORDER BY a, b; +3 30 +EXPLAIN SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection WHERE a = 3 ORDER BY a, b SETTINGS optimize_move_to_prewhere = 1, query_plan_optimize_prewhere = 1; +Expression (Project names) + Distinct (DISTINCT) + Sorting (Sorting for ORDER BY) + Expression (Before ORDER BY) + Distinct (Preliminary DISTINCT) + Union + Expression (Projection) + Expression ((WHERE + Change column names to column identifiers)) + ReadFromMergeTree (default.test_distinct_proj_partial_projection) + Filter + ReadFromMergeTree (p) +DROP TABLE test_distinct_proj_partial_projection; diff --git a/tests/queries/0_stateless/04099_distinct_aggregate_projection_partial_projection_data.sql b/tests/queries/0_stateless/04099_distinct_aggregate_projection_partial_projection_data.sql new file mode 100644 index 000000000000..1e6bfa4ab052 --- /dev/null +++ b/tests/queries/0_stateless/04099_distinct_aggregate_projection_partial_projection_data.sql @@ -0,0 +1,38 @@ +-- Tags: no-replicated-database, no-parallel-replicas +-- no-replicated-database: EXPLAIN output differs for replicated database. +-- no-parallel-replicas: EXPLAIN output differs for parallel replicas. + +-- { echo } + +SET optimize_use_projections = 1; + +DROP TABLE IF EXISTS test_distinct_proj_partial_projection; + +CREATE TABLE test_distinct_proj_partial_projection +( + a UInt32, + b UInt32 +) +ENGINE = MergeTree ORDER BY tuple(); + +INSERT INTO test_distinct_proj_partial_projection VALUES (1, 10), (1, 10), (2, 20), (3, 30), (3, 30); + +ALTER TABLE test_distinct_proj_partial_projection ADD PROJECTION p (SELECT count() GROUP BY a, b); + +INSERT INTO test_distinct_proj_partial_projection VALUES (3, 30), (4, 40), (4, 40), (5, 50), (6, 60), (6, 60); + +SELECT count() FROM test_distinct_proj_partial_projection; + +SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection ORDER BY a, b; +EXPLAIN SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection ORDER BY a, b SETTINGS optimize_move_to_prewhere = 1, query_plan_optimize_prewhere = 1; + +SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection WHERE a <= 2 ORDER BY a, b; +EXPLAIN SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection WHERE a <= 2 ORDER BY a, b SETTINGS optimize_move_to_prewhere = 1, query_plan_optimize_prewhere = 1; + +SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection WHERE a >= 4 ORDER BY a, b; +EXPLAIN SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection WHERE a >= 4 ORDER BY a, b SETTINGS optimize_move_to_prewhere = 1, query_plan_optimize_prewhere = 1; + +SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection WHERE a = 3 ORDER BY a, b; +EXPLAIN SELECT DISTINCT a, b FROM test_distinct_proj_partial_projection WHERE a = 3 ORDER BY a, b SETTINGS optimize_move_to_prewhere = 1, query_plan_optimize_prewhere = 1; + +DROP TABLE test_distinct_proj_partial_projection; From 036b47087611c03d80f3942c5dbc4e6fda23f971 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Fri, 24 Apr 2026 08:57:39 +0000 Subject: [PATCH 40/70] Backport #102894 to 26.3: Fix short writes in Poco BufferedStreamBuf::flushBuffer --- .../Poco/BufferedBidirectionalStreamBuf.h | 12 +- .../include/Poco/BufferedStreamBuf.h | 12 +- base/poco/Net/src/HTTPChunkedStream.cpp | 15 +- base/poco/Net/src/HTTPFixedLengthStream.cpp | 13 +- .../NetSSL_OpenSSL/src/SecureSocketImpl.cpp | 12 +- .../gtest_buffered_stream_short_write.cpp | 161 ++++++++++++ .../tests/gtest_http_fixed_length_stream.cpp | 103 ++++++++ src/Common/tests/gtest_ssl_send_timeout.cpp | 229 ++++++++++++++++++ 8 files changed, 536 insertions(+), 21 deletions(-) create mode 100644 src/Common/tests/gtest_buffered_stream_short_write.cpp create mode 100644 src/Common/tests/gtest_http_fixed_length_stream.cpp create mode 100644 src/Common/tests/gtest_ssl_send_timeout.cpp diff --git a/base/poco/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h b/base/poco/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h index 05d2f81b16d4..b0b9b318571a 100644 --- a/base/poco/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h +++ b/base/poco/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h @@ -136,12 +136,16 @@ class BasicBufferedBidirectionalStreamBuf : public std::basic_streambuf int flushBuffer() { int n = int(this->pptr() - this->pbase()); - if (writeToDevice(this->pbase(), n) == n) + int offset = 0; + while (offset < n) { - this->pbump(-n); - return n; + int written = writeToDevice(this->pbase() + offset, n - offset); + if (written <= 0) + return -1; + offset += written; } - return -1; + this->pbump(-n); + return n; } std::streamsize _bufsize; diff --git a/base/poco/Foundation/include/Poco/BufferedStreamBuf.h b/base/poco/Foundation/include/Poco/BufferedStreamBuf.h index d97e37eedf36..3e8e54e5e594 100644 --- a/base/poco/Foundation/include/Poco/BufferedStreamBuf.h +++ b/base/poco/Foundation/include/Poco/BufferedStreamBuf.h @@ -134,12 +134,16 @@ class BasicBufferedStreamBuf : public std::basic_streambuf int flushBuffer() { int n = int(this->pptr() - this->pbase()); - if (writeToDevice(this->pbase(), n) == n) + int offset = 0; + while (offset < n) { - this->pbump(-n); - return n; + int written = writeToDevice(this->pbase() + offset, n - offset); + if (written <= 0) + return -1; + offset += written; } - return -1; + this->pbump(-n); + return n; } std::streamsize _bufsize; diff --git a/base/poco/Net/src/HTTPChunkedStream.cpp b/base/poco/Net/src/HTTPChunkedStream.cpp index b545c089e520..425ca7ad6210 100644 --- a/base/poco/Net/src/HTTPChunkedStream.cpp +++ b/base/poco/Net/src/HTTPChunkedStream.cpp @@ -52,8 +52,8 @@ void HTTPChunkedStreamBuf::close() if (_mode & std::ios::out && _chunk != std::char_traits::eof()) { sync(); - _session.write("0\r\n\r\n", 5); - + if (writeToDevice("", 0) < 0) + throw MessageException("Failed to write terminating chunk"); _chunk = std::char_traits::eof(); } } @@ -167,7 +167,16 @@ int HTTPChunkedStreamBuf::writeToDevice(const char* buffer, std::streamsize leng _chunkBuffer.append("\r\n", 2); _chunkBuffer.append(buffer, static_cast(length)); _chunkBuffer.append("\r\n", 2); - _session.write(_chunkBuffer.data(), static_cast(_chunkBuffer.size())); + + std::streamsize chunkSize = static_cast(_chunkBuffer.size()); + std::streamsize offset = 0; + while (offset < chunkSize) + { + int written = _session.write(_chunkBuffer.data() + offset, chunkSize - offset); + if (written <= 0) + return -1; + offset += written; + } return static_cast(length); } diff --git a/base/poco/Net/src/HTTPFixedLengthStream.cpp b/base/poco/Net/src/HTTPFixedLengthStream.cpp index c61c41f0ddc9..00e32e5d6895 100644 --- a/base/poco/Net/src/HTTPFixedLengthStream.cpp +++ b/base/poco/Net/src/HTTPFixedLengthStream.cpp @@ -68,14 +68,11 @@ int HTTPFixedLengthStreamBuf::readFromDevice(char* buffer, std::streamsize lengt int HTTPFixedLengthStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { - int n = 0; - if (_count < _length) - { - if (_count + length > _length) - length = static_cast(_length - _count); - n = _session.write(buffer, length); - if (n > 0) _count += n; - } + if (_count + length > _length) + throw MessageException("Write past Content-Length"); + + int n = _session.write(buffer, length); + if (n > 0) _count += n; return n; } diff --git a/base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp b/base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp index d75391201360..360ce783d82c 100644 --- a/base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp +++ b/base/poco/NetSSL_OpenSSL/src/SecureSocketImpl.cpp @@ -322,6 +322,8 @@ int SecureSocketImpl::sendBytes(const void* buffer, int length, int flags) rc = handleError(rc); if (rc == 0) throw SSLConnectionUnexpectedlyClosedException(); + if (rc < 0 && _pSocket->getBlocking()) + throw Poco::TimeoutException("SSL_write timed out"); } _pSocket->useSendThrottlerBudget(rc); @@ -364,7 +366,10 @@ int SecureSocketImpl::receiveBytes(void* buffer, int length, int flags) while (mustRetry(rc, remaining_time)); if (rc <= 0) { - return handleError(rc); + rc = handleError(rc); + if (rc < 0 && _pSocket->getBlocking()) + throw Poco::TimeoutException("SSL_read timed out"); + return rc; } _pSocket->useRecvThrottlerBudget(rc); @@ -398,7 +403,10 @@ int SecureSocketImpl::completeHandshake() while (mustRetry(rc, remaining_time)); if (rc <= 0) { - return handleError(rc); + rc = handleError(rc); + if (rc < 0 && _pSocket->getBlocking()) + throw Poco::TimeoutException("SSL handshake timed out"); + return rc; } _needHandshake = false; return rc; diff --git a/src/Common/tests/gtest_buffered_stream_short_write.cpp b/src/Common/tests/gtest_buffered_stream_short_write.cpp new file mode 100644 index 000000000000..5b61ed06a797 --- /dev/null +++ b/src/Common/tests/gtest_buffered_stream_short_write.cpp @@ -0,0 +1,161 @@ +#include + +#include +#include +#include +#include + + +/// Mock BufferedStreamBuf that simulates short writes from the device. +/// Each call to writeToDevice writes at most `max_write_size` bytes. +class ShortWriteStreamBuf : public Poco::BufferedStreamBuf +{ +public: + ShortWriteStreamBuf(int buffer_size, int max_write_size_) + : Poco::BufferedStreamBuf(buffer_size, std::ios::out) + , max_write_size(max_write_size_) + { + } + + const std::string & written() const { return output; } + int writeCount() const { return write_calls; } + +private: + int writeToDevice(const char * buffer, std::streamsize length) override + { + ++write_calls; + int to_write = std::min(static_cast(length), max_write_size); + output.append(buffer, to_write); + return to_write; + } + + std::string output; + int max_write_size; + int write_calls = 0; +}; + + +/// Mock that fails after writing a certain number of bytes total. +class FailAfterNStreamBuf : public Poco::BufferedStreamBuf +{ +public: + FailAfterNStreamBuf(int buffer_size, int fail_after_) + : Poco::BufferedStreamBuf(buffer_size, std::ios::out) + , fail_after(fail_after_) + { + } + + const std::string & written() const { return output; } + +private: + int writeToDevice(const char * buffer, std::streamsize length) override + { + if (total_written >= fail_after) + return 0; + + int to_write = std::min(static_cast(length), fail_after - total_written); + output.append(buffer, to_write); + total_written += to_write; + return to_write; + } + + std::string output; + int fail_after; + int total_written = 0; +}; + + +TEST(BufferedStreamBuf, FlushHandlesShortWrites) +{ + /// Buffer size 16, device writes at most 3 bytes per call. + ShortWriteStreamBuf buf(16, 3); + std::ostream os(&buf); + + std::string data = "Hello, World!"; /// 13 bytes + os.write(data.data(), data.size()); + os.flush(); + + ASSERT_TRUE(os.good()) << "Stream should be in good state after flush"; + ASSERT_EQ(buf.written(), data); + /// 13 bytes with max 3 per call = at least 5 writeToDevice calls + ASSERT_GE(buf.writeCount(), 5); +} + + +TEST(BufferedStreamBuf, FlushHandlesShortWritesSingleByte) +{ + /// Worst case: device writes 1 byte at a time. + ShortWriteStreamBuf buf(32, 1); + std::ostream os(&buf); + + std::string data = "Short write test with single byte device"; + os.write(data.data(), data.size()); + os.flush(); + + ASSERT_TRUE(os.good()); + ASSERT_EQ(buf.written(), data); + ASSERT_EQ(buf.writeCount(), static_cast(data.size())); +} + + +TEST(BufferedStreamBuf, FlushHandlesFullWriteInOneCall) +{ + /// Device writes everything in one call -- loop should iterate once. + ShortWriteStreamBuf buf(64, 1000); + std::ostream os(&buf); + + std::string data = "All at once"; + os.write(data.data(), data.size()); + os.flush(); + + ASSERT_TRUE(os.good()); + ASSERT_EQ(buf.written(), data); + ASSERT_EQ(buf.writeCount(), 1); +} + + +TEST(BufferedStreamBuf, FlushSetsErrorOnWriteFailure) +{ + /// Device fails immediately (returns 0). + FailAfterNStreamBuf buf(16, 0); + std::ostream os(&buf); + os.exceptions(std::ios::badbit); + + std::string data = "Will fail"; + os.write(data.data(), data.size()); + + ASSERT_THROW(os.flush(), std::ios_base::failure); +} + + +TEST(BufferedStreamBuf, FlushWritesPartialThenFails) +{ + /// Device writes 5 bytes then fails. + FailAfterNStreamBuf buf(32, 5); + std::ostream os(&buf); + os.exceptions(std::ios::badbit); + + std::string data = "1234567890"; /// 10 bytes, device fails after 5 + os.write(data.data(), data.size()); + + ASSERT_THROW(os.flush(), std::ios_base::failure); + /// The first 5 bytes should have been written before failure. + ASSERT_EQ(buf.written(), "12345"); +} + + +TEST(BufferedStreamBuf, OverflowTriggersShortWriteLoop) +{ + /// Buffer size 8, device writes 3 bytes at a time. + /// Writing 20 bytes should trigger overflow (flushing the 8-byte buffer + /// via the short-write loop) then continue filling the buffer. + ShortWriteStreamBuf buf(8, 3); + std::ostream os(&buf); + + std::string data = "01234567ABCDEFGHIJKL"; /// 20 bytes + os.write(data.data(), data.size()); + os.flush(); + + ASSERT_TRUE(os.good()); + ASSERT_EQ(buf.written(), data); +} diff --git a/src/Common/tests/gtest_http_fixed_length_stream.cpp b/src/Common/tests/gtest_http_fixed_length_stream.cpp new file mode 100644 index 000000000000..2d7f2f3627f8 --- /dev/null +++ b/src/Common/tests/gtest_http_fixed_length_stream.cpp @@ -0,0 +1,103 @@ +#include + +#include +#include +#include +#include +#include +#include + + +namespace +{ + +/// A listening socket that never accepts. The kernel's listen backlog +/// completes the TCP handshake, so a client can connect and write small +/// amounts of data (absorbed by the kernel send buffer) without a server +/// thread. +class PassiveListener +{ +public: + PassiveListener() : server_socket(Poco::Net::SocketAddress("127.0.0.1", 0), 1) {} + + Poco::Net::StreamSocket connect() + { + Poco::Net::StreamSocket sock; + sock.connect(Poco::Net::SocketAddress("127.0.0.1", server_socket.address().port())); + return sock; + } + +private: + Poco::Net::ServerSocket server_socket; +}; + +} + + +/// Writing exactly Content-Length bytes should succeed. +TEST(HTTPFixedLengthStreamBuf, WriteExactLength) +{ + PassiveListener listener; + Poco::Net::HTTPClientSession session(listener.connect()); + + Poco::Net::HTTPFixedLengthOutputStream stream(session, 10); + + stream.write("0123456789", 10); + stream.flush(); + + ASSERT_TRUE(stream.good()) << "Stream should be good after writing exactly Content-Length bytes"; +} + + +/// Writing more than Content-Length should throw MessageException. +TEST(HTTPFixedLengthStreamBuf, WriteOverLengthThrows) +{ + PassiveListener listener; + Poco::Net::HTTPClientSession session(listener.connect()); + + /// Content-Length is 5, but we will try to write 10 bytes. + Poco::Net::HTTPFixedLengthOutputStream stream(session, 5); + + /// The data goes into the 8KB buffer first. On flush, flushBuffer calls + /// writeToDevice which clamps to Content-Length (writes 5 bytes), then the + /// loop calls writeToDevice again with the remaining 5 bytes, which throws + /// MessageException because _count >= _length. + stream.write("0123456789", 10); + + bool got_exception = false; + try + { + stream.flush(); + } + catch (const Poco::Net::MessageException &) + { + got_exception = true; + } + + ASSERT_TRUE(got_exception) << "Expected MessageException when writing past Content-Length"; +} + + +/// Writing exactly Content-Length and then one more byte should throw. +TEST(HTTPFixedLengthStreamBuf, WriteBoundaryPlusOneThrows) +{ + PassiveListener listener; + Poco::Net::HTTPClientSession session(listener.connect()); + + Poco::Net::HTTPFixedLengthOutputStream stream(session, 5); + + /// Write exactly 5 + 1 bytes. + stream.write("012345", 6); + + bool got_exception = false; + try + { + stream.flush(); + } + catch (const Poco::Net::MessageException &) + { + got_exception = true; + } + + ASSERT_TRUE(got_exception) << "Expected MessageException when writing Content-Length + 1"; +} diff --git a/src/Common/tests/gtest_ssl_send_timeout.cpp b/src/Common/tests/gtest_ssl_send_timeout.cpp new file mode 100644 index 000000000000..7e90e6e2e927 --- /dev/null +++ b/src/Common/tests/gtest_ssl_send_timeout.cpp @@ -0,0 +1,229 @@ +#include "config.h" + +#if USE_SSL + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + + +namespace +{ + +/// Generate a self-signed certificate and private key in memory, +/// write them to temporary files for Poco::Net::Context. +struct EphemeralCert +{ + std::string cert_path; + std::string key_path; + + EphemeralCert() + { + EVP_PKEY * pkey = EVP_RSA_gen(2048); + if (!pkey) + throw std::runtime_error("EVP_RSA_gen failed"); + + X509 * x509 = X509_new(); + if (!x509) + { + EVP_PKEY_free(pkey); + throw std::runtime_error("X509_new failed"); + } + + ASN1_INTEGER_set(X509_get_serialNumber(x509), 1); + X509_gmtime_adj(X509_getm_notBefore(x509), 0); + X509_gmtime_adj(X509_getm_notAfter(x509), 3600); + X509_set_pubkey(x509, pkey); + + X509_NAME * name = X509_get_subject_name(x509); + X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, reinterpret_cast("localhost"), -1, -1, 0); + X509_set_issuer_name(x509, name); + X509_sign(x509, pkey, EVP_sha256()); + + cert_path = writeToTempFile( + [&](BIO * bio) { PEM_write_bio_X509(bio, x509); }, "cert"); + key_path = writeToTempFile( + [&](BIO * bio) { PEM_write_bio_PrivateKey(bio, pkey, nullptr, nullptr, 0, nullptr, nullptr); }, "key"); + + X509_free(x509); + EVP_PKEY_free(pkey); + } + + ~EphemeralCert() + { + (void)unlink(cert_path.c_str()); + (void)unlink(key_path.c_str()); + } + +private: + template + static std::string writeToTempFile(Fn writer, const char * suffix) + { + char path[256]; + (void)snprintf(path, sizeof(path), "/tmp/gtest_ssl_%s_XXXXXX", suffix); + int fd = mkstemp(path); + if (fd < 0) + throw std::runtime_error("mkstemp failed"); + + BIO * bio = BIO_new_fd(fd, BIO_CLOSE); + writer(bio); + BIO_free(bio); + return path; + } +}; + + +Poco::Net::Context::Ptr makeContext(const EphemeralCert & cert, Poco::Net::Context::Usage usage) +{ + Poco::Net::Context::Params params; + params.privateKeyFile = cert.key_path; + params.certificateFile = cert.cert_path; + params.verificationMode = Poco::Net::Context::VERIFY_NONE; + return new Poco::Net::Context(usage, params); +} + +} + + +/// Test that a blocking SSL socket write throws TimeoutException +/// when the peer stops reading and the send timeout expires. +TEST(SSLSocketTimeout, SendBytesThrowsTimeoutOnBlockingSocket) +{ + EphemeralCert cert; + auto server_ctx = makeContext(cert, Poco::Net::Context::SERVER_USE); + auto client_ctx = makeContext(cert, Poco::Net::Context::CLIENT_USE); + + Poco::Net::SecureServerSocket server_socket( + Poco::Net::SocketAddress("127.0.0.1", 0), 1, server_ctx); + auto port = server_socket.address().port(); + + std::atomic server_done{false}; + + /// Server thread: accept and handshake, then sit idle (never read). + std::thread server_thread([&] + { + try + { + auto accepted = server_socket.acceptConnection(); + /// Handshake happens on first I/O. Do a small read to trigger it. + char buf[1]; + try { accepted.receiveBytes(buf, 1); } catch (...) {} /// Ok: handshake may fail. NOLINT(bugprone-empty-catch) + /// Keep the connection open until the test completes. + while (!server_done.load()) + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + } + catch (...) {} /// Ok: server thread cleanup, test checks client-side behavior. NOLINT(bugprone-empty-catch) + }); + + try + { + Poco::Net::SecureStreamSocket client( + Poco::Net::SocketAddress("127.0.0.1", port), client_ctx); + + /// Very short send timeout so the test doesn't wait long. + client.setSendTimeout(Poco::Timespan(0, 200'000)); /// 200ms + + /// Write enough data to fill the TCP send buffer and SSL buffer. + /// Typical TCP buffer is 128KB-256KB. Write 4MB to be sure. + std::vector data(4 * 1024 * 1024, 'X'); + + bool got_timeout = false; + try + { + size_t offset = 0; + while (offset < data.size()) + { + int sent = client.sendBytes(data.data() + offset, static_cast(data.size() - offset)); + if (sent > 0) + offset += sent; + else + break; + } + } + catch (const Poco::TimeoutException &) + { + got_timeout = true; + } + + ASSERT_TRUE(got_timeout) << "Expected Poco::TimeoutException when writing to a non-reading SSL peer"; + } + catch (const Poco::Exception & e) + { + /// Connection setup can fail on some systems; skip gracefully. + /// Clean up the server thread before GTEST_SKIP returns from the function. + server_done.store(true); + server_socket.close(); + server_thread.join(); + GTEST_SKIP() << "SSL setup failed: " << e.displayText(); + } + + server_done.store(true); + /// Close the listening socket to unblock acceptConnection if the client + /// failed before connecting (e.g. SSL context error). + server_socket.close(); + server_thread.join(); +} + + +/// Test that SSL handshake throws TimeoutException when the peer +/// is a plain TCP listener that never speaks SSL. +/// No server thread needed -- the kernel's listen backlog completes the +/// TCP handshake, but nobody reads the accepted socket so the SSL +/// ClientHello gets no response. +TEST(SSLSocketTimeout, HandshakeThrowsTimeoutOnNonSSLPeer) +{ + EphemeralCert cert; + auto client_ctx = makeContext(cert, Poco::Net::Context::CLIENT_USE); + + /// Listen but never accept -- kernel backlog handles TCP handshake. + Poco::Net::ServerSocket listener(Poco::Net::SocketAddress("127.0.0.1", 0), 1); + auto port = listener.address().port(); + + bool got_timeout = false; + try + { + Poco::Net::StreamSocket raw_sock; + raw_sock.connect(Poco::Net::SocketAddress("127.0.0.1", port)); + raw_sock.setSendTimeout(Poco::Timespan(0, 200'000)); + raw_sock.setReceiveTimeout(Poco::Timespan(0, 200'000)); + + Poco::Net::SecureStreamSocket ssl_sock( + Poco::Net::SecureStreamSocket::attach(raw_sock, client_ctx)); + + /// completeHandshake is triggered by the first I/O. + /// The peer won't respond with ServerHello, so it will time out. + char buf[1] = {'X'}; + ssl_sock.sendBytes(buf, 1); + } + catch (const Poco::TimeoutException &) + { + got_timeout = true; + } + catch (const Poco::Exception &) + { + /// Some SSL implementations may throw a different SSL error + /// before the timeout fires. That's acceptable -- the key thing + /// is we don't silently return -1. + got_timeout = true; + } + + ASSERT_TRUE(got_timeout) << "Expected exception when SSL handshake times out against a non-SSL peer"; +} + + +#endif /// USE_SSL From 3585f0d2deb39cc87ad26119f8f1d0168b74a138 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Fri, 24 Apr 2026 09:00:02 +0000 Subject: [PATCH 41/70] Backport #102058 to 26.3: Add histogram metrics for S3 read request duration and bytes --- src/Common/HistogramMetrics.cpp | 10 ++++ src/IO/ReadBufferFromIStream.h | 3 +- src/IO/ReadBufferFromS3.cpp | 29 +++++++++- src/IO/S3/ReadBufferFromGetObjectResult.cpp | 58 +++++++++++++++++++ src/IO/S3/ReadBufferFromGetObjectResult.h | 31 +++++----- ...3_read_request_histogram_metrics.reference | 2 + ...4079_s3_read_request_histogram_metrics.sql | 28 +++++++++ 7 files changed, 142 insertions(+), 19 deletions(-) create mode 100644 src/IO/S3/ReadBufferFromGetObjectResult.cpp create mode 100644 tests/queries/0_stateless/04079_s3_read_request_histogram_metrics.reference create mode 100644 tests/queries/0_stateless/04079_s3_read_request_histogram_metrics.sql diff --git a/src/Common/HistogramMetrics.cpp b/src/Common/HistogramMetrics.cpp index 8d6100616600..9c1e8274a2aa 100644 --- a/src/Common/HistogramMetrics.cpp +++ b/src/Common/HistogramMetrics.cpp @@ -63,6 +63,16 @@ namespace HistogramMetrics {"http_method", "attempt"} ); + Metric & S3ReadRequestDuration = Factory::instance().registerMetric( + "s3_read_request_duration_microseconds", + "Duration of S3 read request connections, from request initiation to connection close, in microseconds.", + {1000, 10000, 50000, 200000, 500000, 1000000, 2000000, 5000000, 10000000, 60000000}); + + Metric & S3ReadRequestBytes = Factory::instance().registerMetric( + "s3_read_request_bytes", + "Bytes read per S3 read request connection.", + {4096, 65536, 262144, 1048576, 4194304, 8388608, 16777216, 33554432, 67108864, 268435456}); + MetricFamily & KeeperResponseTime = Factory::instance().registerMetric( "keeper_response_time_ms", "The response time of Keeper, in milliseconds", diff --git a/src/IO/ReadBufferFromIStream.h b/src/IO/ReadBufferFromIStream.h index ab3bb00fc6e3..7320604c66fd 100644 --- a/src/IO/ReadBufferFromIStream.h +++ b/src/IO/ReadBufferFromIStream.h @@ -19,9 +19,10 @@ class ReadBufferFromIStream : public BufferWithOwnMemory }; std::optional stream_holder; + bool eof = false; +protected: bool nextImpl() override; - bool eof = false; public: explicit ReadBufferFromIStream(std::istream & istr_, size_t size = DBMS_DEFAULT_BUFFER_SIZE); diff --git a/src/IO/ReadBufferFromS3.cpp b/src/IO/ReadBufferFromS3.cpp index 74e654c5160b..fd1a68902b41 100644 --- a/src/IO/ReadBufferFromS3.cpp +++ b/src/IO/ReadBufferFromS3.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -30,6 +31,12 @@ namespace ProfileEvents extern const Event DiskS3GetObject; } +namespace HistogramMetrics +{ + extern Metric & S3ReadRequestDuration; + extern Metric & S3ReadRequestBytes; +} + namespace DB { @@ -242,6 +249,17 @@ size_t ReadBufferFromS3::readBigAt(char * to, size_t n, size_t range_begin, cons { bool last_attempt = attempt >= request_settings[S3RequestSetting::max_single_read_retries]; size_t bytes_copied = 0; + Stopwatch request_watch{CLOCK_MONOTONIC}; + bool metrics_observed = false; + + auto observe_request_metrics = [&]() + { + if (metrics_observed) + return; + metrics_observed = true; + HistogramMetrics::S3ReadRequestDuration.observe(static_cast(request_watch.elapsedMicroseconds())); + HistogramMetrics::S3ReadRequestBytes.observe(static_cast(bytes_copied)); + }; ProfileEventTimeIncrement watch(ProfileEvents::ReadBufferFromS3Microseconds); @@ -258,13 +276,18 @@ size_t ReadBufferFromS3::readBigAt(char * to, size_t n, size_t range_begin, cons ProfileEvents::increment(ProfileEvents::ReadBufferFromS3Bytes, bytes_copied); if (cancelled) + { + observe_request_metrics(); return initial_n - n + bytes_copied; + } /// Read remaining bytes after the end of the payload istr.ignore(INT64_MAX); } catch (...) { + observe_request_metrics(); + if (!processException(range_begin, attempt) || last_attempt) throw; @@ -272,6 +295,8 @@ size_t ReadBufferFromS3::readBigAt(char * to, size_t n, size_t range_begin, cons sleep_time_with_backoff_milliseconds *= 2; } + observe_request_metrics(); + range_begin += bytes_copied; to += bytes_copied; n -= bytes_copied; @@ -471,10 +496,12 @@ std::unique_ptr ReadBufferFromS3::initialize( throw Exception(ErrorCodes::LOGICAL_ERROR, "Attempt to read beyond right offset ({} > {})", offset.load(), read_until_position - 1); const auto right_offset = read_until_position ? std::make_optional(read_until_position - 1) : std::nullopt; + + Stopwatch watch{CLOCK_MONOTONIC}; auto read_result = sendRequest(attempt, offset, right_offset); size_t buffer_size = use_external_buffer ? 0 : read_settings.remote_fs_buffer_size; - return std::make_unique(std::move(read_result), buffer_size); + return std::make_unique(std::move(read_result), buffer_size, std::move(watch)); } Aws::S3::Model::GetObjectResult ReadBufferFromS3::sendRequest(size_t attempt, size_t range_begin, std::optional range_end_incl) const diff --git a/src/IO/S3/ReadBufferFromGetObjectResult.cpp b/src/IO/S3/ReadBufferFromGetObjectResult.cpp new file mode 100644 index 000000000000..f7ce38b6ed24 --- /dev/null +++ b/src/IO/S3/ReadBufferFromGetObjectResult.cpp @@ -0,0 +1,58 @@ +#include "config.h" + +#if USE_AWS_S3 + +#include +#include + +namespace HistogramMetrics +{ + extern Metric & S3ReadRequestDuration; + extern Metric & S3ReadRequestBytes; +} + +namespace DB::S3 +{ + +ReadBufferFromGetObjectResult::ReadBufferFromGetObjectResult(Aws::S3::Model::GetObjectResult && result_, size_t size_, Stopwatch && watch_) + : ReadBufferFromIStream(result_.GetBody(), size_), result(std::move(result_)), watch(std::move(watch_)) +{ + metadata.size_bytes = result->GetContentLength(); + metadata.last_modified = Poco::Timestamp::fromEpochTime(result->GetLastModified().Seconds()); + metadata.etag = result->GetETag(); + metadata.attributes = result->GetMetadata(); +} + +ReadBufferFromGetObjectResult::~ReadBufferFromGetObjectResult() +{ + observeMetrics(); +} + +bool ReadBufferFromGetObjectResult::nextImpl() +{ + bool res = ReadBufferFromIStream::nextImpl(); + if (res) + bytes_read += working_buffer.size(); + return res; +} + +void ReadBufferFromGetObjectResult::releaseResult() +{ + observeMetrics(); + detachStream(); + result.reset(); +} + +void ReadBufferFromGetObjectResult::observeMetrics() +{ + if (metrics_observed) + return; + metrics_observed = true; + + HistogramMetrics::S3ReadRequestDuration.observe(static_cast(watch.elapsedMicroseconds())); + HistogramMetrics::S3ReadRequestBytes.observe(static_cast(bytes_read)); +} + +} + +#endif diff --git a/src/IO/S3/ReadBufferFromGetObjectResult.h b/src/IO/S3/ReadBufferFromGetObjectResult.h index b173db496dc8..fc1b7cd4db90 100644 --- a/src/IO/S3/ReadBufferFromGetObjectResult.h +++ b/src/IO/S3/ReadBufferFromGetObjectResult.h @@ -6,32 +6,29 @@ #include #include #include +#include namespace DB::S3 { -/// Wrapper for ReadBufferFromIStream to store GetObjectResult (session holder) with corresponding response body stream +/// Wrapper for ReadBufferFromIStream to store GetObjectResult (session holder) with corresponding response body stream. +/// Tracks per-connection metrics: duration and bytes read. class ReadBufferFromGetObjectResult : public ReadBufferFromIStream { std::optional result; ObjectMetadata metadata; + Stopwatch watch; + size_t bytes_read = 0; + bool metrics_observed = false; + + void observeMetrics(); + bool nextImpl() override; + public: - ReadBufferFromGetObjectResult(Aws::S3::Model::GetObjectResult && result_, size_t size_) - : ReadBufferFromIStream(result_.GetBody(), size_), result(std::move(result_)) - { - metadata.size_bytes = result->GetContentLength(); - metadata.last_modified = Poco::Timestamp::fromEpochTime(result->GetLastModified().Seconds()); - metadata.etag = result->GetETag(); - metadata.attributes = result->GetMetadata(); - } - - /// Allows to safely release the result and detach the underlying body stream from the buffer. - /// The buffer can still be used, but subsequent reads won't return any more data. - void releaseResult() - { - detachStream(); - result.reset(); - } + ReadBufferFromGetObjectResult(Aws::S3::Model::GetObjectResult && result_, size_t size_, Stopwatch && watch_); + ~ReadBufferFromGetObjectResult() override; + + void releaseResult(); bool isResultReleased() const { return !result; } diff --git a/tests/queries/0_stateless/04079_s3_read_request_histogram_metrics.reference b/tests/queries/0_stateless/04079_s3_read_request_histogram_metrics.reference new file mode 100644 index 000000000000..6ed281c757a9 --- /dev/null +++ b/tests/queries/0_stateless/04079_s3_read_request_histogram_metrics.reference @@ -0,0 +1,2 @@ +1 +1 diff --git a/tests/queries/0_stateless/04079_s3_read_request_histogram_metrics.sql b/tests/queries/0_stateless/04079_s3_read_request_histogram_metrics.sql new file mode 100644 index 000000000000..1dbec6d80b57 --- /dev/null +++ b/tests/queries/0_stateless/04079_s3_read_request_histogram_metrics.sql @@ -0,0 +1,28 @@ +-- Tags: no-fasttest + +-- Verify that s3_read_request_duration_microseconds and s3_read_request_bytes histogram metrics +-- are populated after reading data from S3. + +DROP TABLE IF EXISTS test_s3_metrics; +CREATE TABLE test_s3_metrics (key UInt64, value String) +ENGINE = MergeTree ORDER BY key +SETTINGS storage_policy = 's3_no_cache'; + +INSERT INTO test_s3_metrics SELECT number, repeat('x', 1000) FROM numbers(10000); + +-- Force a read from S3. +SELECT count() FROM test_s3_metrics WHERE NOT ignore(value) FORMAT Null; + +-- Check that duration metric has observations (+Inf bucket is cumulative total count). +SELECT value > 0 +FROM system.histogram_metrics +WHERE name = 's3_read_request_duration_microseconds' + AND labels['le'] = '+Inf'; + +-- Check that bytes metric has observations. +SELECT value > 0 +FROM system.histogram_metrics +WHERE name = 's3_read_request_bytes' + AND labels['le'] = '+Inf'; + +DROP TABLE test_s3_metrics; From 38466c5ca749e6992de54e05a14a092533b12939 Mon Sep 17 00:00:00 2001 From: Sema Checherinda Date: Mon, 27 Apr 2026 10:45:50 +0900 Subject: [PATCH 42/70] fix(IO): cast to HistogramMetrics::Value, not double In `release/26.3`, `HistogramMetrics::Value` is `Int64`. The cherry-pick from master (where `Value` is `Float64`) used `static_cast`, which triggers `-Werror,-Wfloat-conversion` when implicitly converted to the integer `Value` parameter of `observe`. Cast to `HistogramMetrics::Value` instead so the code is correct under both type definitions. --- src/IO/ReadBufferFromS3.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/IO/ReadBufferFromS3.cpp b/src/IO/ReadBufferFromS3.cpp index fd1a68902b41..15b006a9e701 100644 --- a/src/IO/ReadBufferFromS3.cpp +++ b/src/IO/ReadBufferFromS3.cpp @@ -257,8 +257,8 @@ size_t ReadBufferFromS3::readBigAt(char * to, size_t n, size_t range_begin, cons if (metrics_observed) return; metrics_observed = true; - HistogramMetrics::S3ReadRequestDuration.observe(static_cast(request_watch.elapsedMicroseconds())); - HistogramMetrics::S3ReadRequestBytes.observe(static_cast(bytes_copied)); + HistogramMetrics::S3ReadRequestDuration.observe(static_cast(request_watch.elapsedMicroseconds())); + HistogramMetrics::S3ReadRequestBytes.observe(static_cast(bytes_copied)); }; ProfileEventTimeIncrement watch(ProfileEvents::ReadBufferFromS3Microseconds); From 18cee9736a45b66c3dafaa3bff350212e53b0121 Mon Sep 17 00:00:00 2001 From: Sema Checherinda Date: Mon, 27 Apr 2026 11:46:22 +0900 Subject: [PATCH 43/70] fix(IO): cast to HistogramMetrics::Value in ReadBufferFromGetObjectResult MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same fix as for `ReadBufferFromS3.cpp` — `HistogramMetrics::Value` is `Int64` in `release/26.3`, so `static_cast` triggers `-Werror,-Wfloat-conversion` when passed to `observe`. --- src/IO/S3/ReadBufferFromGetObjectResult.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/IO/S3/ReadBufferFromGetObjectResult.cpp b/src/IO/S3/ReadBufferFromGetObjectResult.cpp index f7ce38b6ed24..888b9adce4f9 100644 --- a/src/IO/S3/ReadBufferFromGetObjectResult.cpp +++ b/src/IO/S3/ReadBufferFromGetObjectResult.cpp @@ -49,8 +49,8 @@ void ReadBufferFromGetObjectResult::observeMetrics() return; metrics_observed = true; - HistogramMetrics::S3ReadRequestDuration.observe(static_cast(watch.elapsedMicroseconds())); - HistogramMetrics::S3ReadRequestBytes.observe(static_cast(bytes_read)); + HistogramMetrics::S3ReadRequestDuration.observe(static_cast(watch.elapsedMicroseconds())); + HistogramMetrics::S3ReadRequestBytes.observe(static_cast(bytes_read)); } } From d6236eb8d9325ecdbd55b3fa2f0f8f7082ded844 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Mon, 27 Apr 2026 03:22:04 +0000 Subject: [PATCH 44/70] Backport #102711 to 26.3: Fix rabbitmq engine performance issues --- src/Storages/RabbitMQ/RabbitMQHandler.cpp | 14 +- src/Storages/RabbitMQ/RabbitMQHandler.h | 1 + src/Storages/RabbitMQ/RabbitMQProducer.cpp | 4 +- src/Storages/RabbitMQ/StorageRabbitMQ.cpp | 38 +- .../test_storage_rabbitmq/test_shutdown.py | 388 ++++++++++++++++++ 5 files changed, 422 insertions(+), 23 deletions(-) create mode 100644 tests/integration/test_storage_rabbitmq/test_shutdown.py diff --git a/src/Storages/RabbitMQ/RabbitMQHandler.cpp b/src/Storages/RabbitMQ/RabbitMQHandler.cpp index be352f26f7be..533e0dd3d5ca 100644 --- a/src/Storages/RabbitMQ/RabbitMQHandler.cpp +++ b/src/Storages/RabbitMQ/RabbitMQHandler.cpp @@ -1,6 +1,7 @@ #include #include #include +#include namespace DB { @@ -40,7 +41,10 @@ void RabbitMQHandler::startLoop() loop_running.store(true); while (loop_state.load() == Loop::RUN) - uv_run(loop, UV_RUN_NOWAIT); + { + if (!uv_run(loop, UV_RUN_NOWAIT)) + std::this_thread::yield(); + } LOG_DEBUG(log, "Background loop ended"); loop_running.store(false); @@ -64,7 +68,13 @@ int RabbitMQHandler::startBlockingLoop() void RabbitMQHandler::stopLoop() { - LOG_DEBUG(log, "Implicit loop stop."); + LOG_DEBUG(log, "Stopping background loop."); + loop_state.store(Loop::STOP); +} + +void RabbitMQHandler::stopBlockingLoop() +{ + LOG_DEBUG(log, "Stopping blocking loop."); uv_stop(loop); } diff --git a/src/Storages/RabbitMQ/RabbitMQHandler.h b/src/Storages/RabbitMQ/RabbitMQHandler.h index 244692cf8009..66659203b2c0 100644 --- a/src/Storages/RabbitMQ/RabbitMQHandler.h +++ b/src/Storages/RabbitMQ/RabbitMQHandler.h @@ -41,6 +41,7 @@ class RabbitMQHandler : public AMQP::LibUvHandler int startBlockingLoop(); void stopLoop(); + void stopBlockingLoop(); bool connectionRunning() const { return connection_running.load(); } bool loopRunning() const { return loop_running.load(); } diff --git a/src/Storages/RabbitMQ/RabbitMQProducer.cpp b/src/Storages/RabbitMQ/RabbitMQProducer.cpp index 1f8d87dabed1..982865850144 100644 --- a/src/Storages/RabbitMQ/RabbitMQProducer.cpp +++ b/src/Storages/RabbitMQ/RabbitMQProducer.cpp @@ -279,12 +279,12 @@ void RabbitMQProducer::startProducingTaskLoop() .onSuccess([&]() { LOG_TRACE(log, "Successfully closed producer channel"); - connection.getHandler().stopLoop(); + connection.getHandler().stopBlockingLoop(); }) .onError([&](const char * message) { LOG_ERROR(log, "Failed to close producer channel: {}", message); - connection.getHandler().stopLoop(); + connection.getHandler().stopBlockingLoop(); }); int active = connection.getHandler().startBlockingLoop(); diff --git a/src/Storages/RabbitMQ/StorageRabbitMQ.cpp b/src/Storages/RabbitMQ/StorageRabbitMQ.cpp index 14e8a566e1f0..f1e46f095a4a 100644 --- a/src/Storages/RabbitMQ/StorageRabbitMQ.cpp +++ b/src/Storages/RabbitMQ/StorageRabbitMQ.cpp @@ -357,7 +357,7 @@ void StorageRabbitMQ::loopingFunc() void StorageRabbitMQ::stopLoop() { - connection->getHandler().updateLoopState(Loop::STOP); + connection->getHandler().stopLoop(); } void StorageRabbitMQ::stopLoopIfNoReaders() @@ -371,7 +371,7 @@ void StorageRabbitMQ::stopLoopIfNoReaders() std::lock_guard lock(loop_mutex); if (readers_count) return; - connection->getHandler().updateLoopState(Loop::STOP); + connection->getHandler().stopLoop(); } void StorageRabbitMQ::startLoop() @@ -512,7 +512,7 @@ void StorageRabbitMQ::bindExchange(AMQP::TcpChannel & rabbit_channel) rabbit_channel.declareExchange(exchange_name, exchange_type, AMQP::durable) .onError([&](const char * message) { - connection->getHandler().stopLoop(); + connection->getHandler().stopBlockingLoop(); /// This error can be a result of attempt to declare exchange if it was already declared but /// 1) with different exchange type. /// 2) with different exchange settings. @@ -524,7 +524,7 @@ void StorageRabbitMQ::bindExchange(AMQP::TcpChannel & rabbit_channel) rabbit_channel.declareExchange(bridge_exchange, AMQP::fanout, AMQP::durable | AMQP::autodelete) .onError([&](const char * message) { - connection->getHandler().stopLoop(); + connection->getHandler().stopBlockingLoop(); /// This error is not supposed to happen as this exchange name is always unique to type and its settings. if (error.empty()) { @@ -547,7 +547,7 @@ void StorageRabbitMQ::bindExchange(AMQP::TcpChannel & rabbit_channel) rabbit_channel.declareExchange(sharding_exchange, AMQP::consistent_hash, AMQP::durable | AMQP::autodelete, binding_arguments) .onError([&](const char * message) { - connection->getHandler().stopLoop(); + connection->getHandler().stopBlockingLoop(); /// This error can be a result of same reasons as above for exchange_name, i.e. it will mean that sharding exchange name appeared /// to be the same as some other exchange (which purpose is not for sharding). So probably actual error reason: queue_base parameter /// is bad. @@ -562,7 +562,7 @@ void StorageRabbitMQ::bindExchange(AMQP::TcpChannel & rabbit_channel) rabbit_channel.bindExchange(bridge_exchange, sharding_exchange, routing_keys[0]) .onError([&](const char * message) { - connection->getHandler().stopLoop(); + connection->getHandler().stopBlockingLoop(); if (error.empty()) { error = fmt::format( @@ -592,10 +592,10 @@ void StorageRabbitMQ::bindExchange(AMQP::TcpChannel & rabbit_channel) } rabbit_channel.bindExchange(exchange_name, bridge_exchange, routing_keys[0], bind_headers) - .onSuccess([&]() { connection->getHandler().stopLoop(); }) + .onSuccess([&]() { connection->getHandler().stopBlockingLoop(); }) .onError([&](const char * message) { - connection->getHandler().stopLoop(); + connection->getHandler().stopBlockingLoop(); error = fmt::format("Unable to bind exchange {} to bridge exchange ({}). Reason: {}", exchange_name, bridge_exchange, std::string(message)); error_code = ErrorCodes::CANNOT_BIND_RABBITMQ_EXCHANGE; @@ -604,10 +604,10 @@ void StorageRabbitMQ::bindExchange(AMQP::TcpChannel & rabbit_channel) else if (exchange_type == AMQP::ExchangeType::fanout || exchange_type == AMQP::ExchangeType::consistent_hash) { rabbit_channel.bindExchange(exchange_name, bridge_exchange, routing_keys[0]) - .onSuccess([&]() { connection->getHandler().stopLoop(); }) + .onSuccess([&]() { connection->getHandler().stopBlockingLoop(); }) .onError([&](const char * message) { - connection->getHandler().stopLoop(); + connection->getHandler().stopBlockingLoop(); if (error.empty()) { error = fmt::format("Unable to bind exchange {} to bridge exchange ({}). Reason: {}", @@ -625,11 +625,11 @@ void StorageRabbitMQ::bindExchange(AMQP::TcpChannel & rabbit_channel) { ++bound_keys; if (bound_keys == routing_keys.size()) - connection->getHandler().stopLoop(); + connection->getHandler().stopBlockingLoop(); }) .onError([&](const char * message) { - connection->getHandler().stopLoop(); + connection->getHandler().stopBlockingLoop(); if (error.empty()) { error = fmt::format("Unable to bind exchange {} to bridge exchange ({}). Reason: {}", @@ -662,10 +662,10 @@ void StorageRabbitMQ::bindQueue(size_t queue_id, AMQP::TcpChannel & rabbit_chann * fanout exchange it can be arbitrary */ rabbit_channel.bindQueue(consumer_exchange, queue_name, std::to_string(queue_id)) - .onSuccess([&] { connection->getHandler().stopLoop(); }) + .onSuccess([&] { connection->getHandler().stopBlockingLoop(); }) .onError([&](const char * message) { - connection->getHandler().stopLoop(); + connection->getHandler().stopBlockingLoop(); error = fmt::format("Failed to create queue binding for exchange {}. Reason: {}", exchange_name, std::string(message)); }); @@ -673,7 +673,7 @@ void StorageRabbitMQ::bindQueue(size_t queue_id, AMQP::TcpChannel & rabbit_chann auto error_callback([&](const char * message) { - connection->getHandler().stopLoop(); + connection->getHandler().stopBlockingLoop(); /* This error is most likely a result of an attempt to declare queue with different settings if it was declared before. So for a * given queue name either deadletter_exchange parameter changed or queue_size changed, i.e. table was declared with different * max_block_size parameter. Solution: client should specify a different queue_base parameter or manually delete previously @@ -754,11 +754,11 @@ void StorageRabbitMQ::unbindExchange() rabbit_channel->removeExchange(bridge_exchange) .onSuccess([&]() { - connection->getHandler().stopLoop(); + connection->getHandler().stopBlockingLoop(); }) .onError([&](const char * message) { - connection->getHandler().stopLoop(); + connection->getHandler().stopBlockingLoop(); error = fmt::format("Unable to remove exchange. Reason: {}", std::string(message)); }); @@ -997,12 +997,12 @@ void StorageRabbitMQ::cleanupRabbitMQ() const .onSuccess([&](uint32_t num_messages) { LOG_TRACE(log, "Successfully deleted queue {}, messages contained {}", queue, num_messages); - connection->getHandler().stopLoop(); + connection->getHandler().stopBlockingLoop(); }) .onError([&](const char * message) { LOG_ERROR(log, "Failed to delete queue {}. Error message: {}", queue, message); - connection->getHandler().stopLoop(); + connection->getHandler().stopBlockingLoop(); }); } connection->getHandler().startBlockingLoop(); diff --git a/tests/integration/test_storage_rabbitmq/test_shutdown.py b/tests/integration/test_storage_rabbitmq/test_shutdown.py new file mode 100644 index 000000000000..a44e62c1e5cd --- /dev/null +++ b/tests/integration/test_storage_rabbitmq/test_shutdown.py @@ -0,0 +1,388 @@ +import pytest +import datetime +import logging +import time +from helpers.cluster import ClickHouseCluster +from helpers.test_tools import TSV + +cluster = ClickHouseCluster(__file__) + +instance = cluster.add_instance( + "instance", + with_rabbitmq=True, + stay_alive=True, +) + + +@pytest.fixture(scope="module") +def started_cluster(): + try: + cluster.start() + yield cluster + finally: + cluster.shutdown() + + +def get_last_event_time(logger_name, message): + instance.query("SYSTEM FLUSH LOGS") + ts = instance.query( + f"""SELECT + event_time_microseconds + FROM merge(system, '^text_log') + WHERE + logger_name = '{logger_name}' AND + message = '{ message}' + ORDER BY event_time_microseconds DESC + LIMIT 1""" + ).strip() + logging.info( + f"logger_name='{logger_name}', message='{message}', last_event_time='{ts}'" + ) + return datetime.datetime.fromisoformat(ts) + + +def test_shutdown_rabbitmq_with_materialized_view(started_cluster): + """ + Test that restarting server during active RabbitMQ consumption + doesn't cause "Table is shutting down" errors. + """ + + instance.query("DROP DATABASE IF EXISTS test SYNC") + instance.query("CREATE DATABASE test ENGINE=Atomic") + + # Create destination table + instance.query( + """ + CREATE TABLE test.destination ( + key UInt64, + value String, + _timestamp DateTime DEFAULT now() + ) ENGINE = MergeTree() + ORDER BY key + """ + ) + + # Create RabbitMQ queue table + logging.info("Creating RabbitMQ table...") + instance.query( + """ + CREATE TABLE test.rabbitmq_queue ( + key UInt64, + value String + ) ENGINE = RabbitMQ + SETTINGS + rabbitmq_host_port = 'rabbitmq1:5672', + rabbitmq_exchange_name = 'test_shutdown_exchange', + rabbitmq_exchange_type = 'fanout', + rabbitmq_format = 'JSONEachRow', + rabbitmq_username = 'root', + rabbitmq_password = 'clickhouse', + rabbitmq_num_consumers = 3, + rabbitmq_flush_interval_ms = 100, + rabbitmq_max_block_size = 100 + """ + ) + + # Wait for RabbitMQ connection + time.sleep(10) + + # Create materialized view + instance.query( + """ + CREATE MATERIALIZED VIEW test.test_view TO test.destination AS + SELECT key, value FROM test.rabbitmq_queue + """ + ) + + # Publish by inserting directly into RabbitMQ table + logging.info("Publishing messages by inserting into RabbitMQ table") + instance.query( + """ + INSERT INTO test.rabbitmq_queue + SELECT number AS key, toString(number) AS value + FROM numbers(1000) + """ + ) + + # Wait for messages to be published and consumed back + time.sleep(10) + + # Check messages + count_before = int(instance.query("SELECT count() FROM test.destination").strip()) + logging.info(f"Messages in destination before restart: {count_before}") + + # Publish more messages + for batch in range(5): + instance.query( + f""" + INSERT INTO test.rabbitmq_queue + SELECT number + {1000 + batch * 100} AS key, + concat('batch_', toString({batch}), '_', toString(number)) AS value + FROM numbers(100) + """ + ) + time.sleep(0.5) + + time.sleep(3) + + instance.restart_clickhouse() + + registry_shutdown_queue_time = get_last_event_time( + "StreamingStorageRegistry", "Will shutdown 1 queue storages" + ) + + rabbit_shutdown_time = get_last_event_time( + "StorageRabbitMQ (test.rabbitmq_queue)", "Shutdown finished" + ) + + registry_already_shutdown_queue_time = get_last_event_time( + "StreamingStorageRegistry", "Already shutdown 1 queue storages" + ) + assert registry_shutdown_queue_time < rabbit_shutdown_time + assert rabbit_shutdown_time < registry_already_shutdown_queue_time + + +@pytest.mark.skip(reason="There is data race in Rabbit MQ storage when shutting down") +def test_attach_detach_rabbitmq_with_materialized_view(started_cluster): + """ + Test that restarting server during active RabbitMQ consumption + doesn't cause "Table is shutting down" errors. + """ + + instance.query("DROP DATABASE IF EXISTS test SYNC") + instance.query("CREATE DATABASE test ENGINE=Atomic") + + # Create RabbitMQ queue table + logging.info("Creating RabbitMQ table...") + instance.query( + """ + CREATE TABLE test.rabbitmq_queue ( + key UInt64, + value String + ) ENGINE = RabbitMQ + SETTINGS + rabbitmq_host_port = 'rabbitmq1:5672', + rabbitmq_exchange_name = 'test_shutdown_exchange', + rabbitmq_exchange_type = 'fanout', + rabbitmq_format = 'JSONEachRow', + rabbitmq_username = 'root', + rabbitmq_password = 'clickhouse', + rabbitmq_num_consumers = 3, + rabbitmq_flush_interval_ms = 100, + rabbitmq_max_block_size = 100 + """ + ) + + # Wait for RabbitMQ connection + time.sleep(10) + + instance.query_with_retry( + "SELECT count() FROM system.tables WHERE name='rabbitmq_queue' AND database='test'", + check_callback=lambda x: x.strip() == "1", + ) + + instance.query("DETACH TABLE test.rabbitmq_queue") + + instance.query_with_retry( + "SELECT count() FROM system.tables WHERE name='rabbitmq_queue' AND database='test'", + check_callback=lambda x: x.strip() == "0", + ) + + rabbit_shutdown_time_after_detach = get_last_event_time( + "StorageRabbitMQ (test.rabbitmq_queue)", "Shutdown finished" + ) + instance.restart_clickhouse() + + registry_no_queue_to_shutdown_time1 = get_last_event_time( + "StreamingStorageRegistry", "There are no queue storages to shutdown" + ) + + assert registry_no_queue_to_shutdown_time1 > rabbit_shutdown_time_after_detach + + instance.query_with_retry( + "SELECT count() FROM system.tables WHERE name='rabbitmq_queue' AND database='test'", + check_callback=lambda x: x.strip() == "1", + ) + + instance.restart_clickhouse() + + registry_shutdown_queue_time = get_last_event_time( + "StreamingStorageRegistry", "Will shutdown 1 queue storages" + ) + + rabbit_shutdown_time_after_restart = get_last_event_time( + "StorageRabbitMQ (test.rabbitmq_queue)", "Shutdown finished" + ) + + registry_already_shutdown_queue_time = get_last_event_time( + "StreamingStorageRegistry", "Already shutdown 1 queue storages" + ) + + assert registry_shutdown_queue_time > registry_no_queue_to_shutdown_time1 + assert rabbit_shutdown_time_after_restart != rabbit_shutdown_time_after_detach + + assert rabbit_shutdown_time_after_restart > registry_shutdown_queue_time + assert registry_already_shutdown_queue_time > rabbit_shutdown_time_after_restart + + +def test_idle_loop_shutdown_completes_promptly(started_cluster): + """ + Regression test: when the RabbitMQ event loop is idle (no pending messages), + shutdown/deactivation must complete promptly. Previously, UV_RUN_ONCE could + block indefinitely when no events were pending and stop paths did not wake + the libuv loop via uv_stop. + """ + + instance.query("DROP DATABASE IF EXISTS test SYNC") + instance.query("DROP DATABASE IF EXISTS test_idle SYNC") + instance.query("CREATE DATABASE test_idle ENGINE=Atomic") + + instance.query( + """ + CREATE TABLE test_idle.destination ( + key UInt64, + value String + ) ENGINE = MergeTree() + ORDER BY key + """ + ) + + instance.query( + """ + CREATE TABLE test_idle.rabbitmq_queue ( + key UInt64, + value String + ) ENGINE = RabbitMQ + SETTINGS + rabbitmq_host_port = 'rabbitmq1:5672', + rabbitmq_exchange_name = 'test_idle_shutdown_exchange', + rabbitmq_exchange_type = 'fanout', + rabbitmq_format = 'JSONEachRow', + rabbitmq_username = 'root', + rabbitmq_password = 'clickhouse', + rabbitmq_flush_interval_ms = 100, + rabbitmq_max_block_size = 100 + """ + ) + + instance.query( + """ + CREATE MATERIALIZED VIEW test_idle.consumer TO test_idle.destination AS + SELECT key, value FROM test_idle.rabbitmq_queue + """ + ) + + # Wait for streaming to start — the loop is now active but idle (no messages). + instance.wait_for_log_line("Started streaming to .* attached views") + + # Confirm the background loop is actually running before we restart. + instance.wait_for_log_line("Background loop started") + + # Restart without publishing any messages — the loop has no pending events. + instance.restart_clickhouse() + + # Verify the loop was deactivated during shutdown (not already stopped). + instance.query("SYSTEM FLUSH LOGS") + deactivate_count = int( + instance.query( + """SELECT count() + FROM merge(system, '^text_log') + WHERE + logger_name = 'StorageRabbitMQ (test_idle.rabbitmq_queue)' AND + message = 'Deactivating looping task'""" + ).strip() + ) + assert deactivate_count > 0, "Looping task was never deactivated — loop may not have been running" + + registry_shutdown_time = get_last_event_time( + "StreamingStorageRegistry", "Will shutdown 1 queue storages" + ) + + rabbit_shutdown_time = get_last_event_time( + "StorageRabbitMQ (test_idle.rabbitmq_queue)", "Shutdown finished" + ) + + registry_already_shutdown_time = get_last_event_time( + "StreamingStorageRegistry", "Already shutdown 1 queue storages" + ) + + # Verify correct ordering. + assert registry_shutdown_time < rabbit_shutdown_time + assert rabbit_shutdown_time < registry_already_shutdown_time + + # The idle loop must not block shutdown for a long time. + shutdown_duration = ( + rabbit_shutdown_time - registry_shutdown_time + ).total_seconds() + logging.info(f"Idle loop shutdown took {shutdown_duration:.2f}s") + assert shutdown_duration < 15, ( + f"Idle loop shutdown took {shutdown_duration:.2f}s, expected < 15s. " + "The event loop may be blocking in uv_run without being woken by uv_stop." + ) + + instance.query("DROP DATABASE test_idle SYNC") + + +def test_rabbitmq_virtual_column_table(started_cluster): + """ + Test that the `_table` virtual column returns the table name + for the RabbitMQ engine. + """ + + instance.query("DROP DATABASE IF EXISTS test_virt SYNC") + instance.query("CREATE DATABASE test_virt ENGINE=Atomic") + + exchange_name = "test_virtual_table_exchange" + + instance.query( + f""" + CREATE TABLE test_virt.rabbitmq_source ( + key UInt64, + value String + ) ENGINE = RabbitMQ + SETTINGS + rabbitmq_host_port = 'rabbitmq1:5672', + rabbitmq_exchange_name = '{exchange_name}', + rabbitmq_exchange_type = 'fanout', + rabbitmq_format = 'JSONEachRow', + rabbitmq_username = 'root', + rabbitmq_password = 'clickhouse', + rabbitmq_flush_interval_ms = 100, + rabbitmq_max_block_size = 100, + rabbitmq_commit_on_select = 1 + """ + ) + + time.sleep(10) + + instance.query( + """ + INSERT INTO test_virt.rabbitmq_source + SELECT number AS key, toString(number) AS value + FROM numbers(10) + """ + ) + + result = "" + for _ in range(100): + result += instance.query( + """ + SELECT key, value, _exchange_name, _table + FROM test_virt.rabbitmq_source + SETTINGS stream_like_engine_allow_direct_select=1 + """ + ) + lines = [l for l in result.strip().split("\n") if l] + if len(lines) == 10: + break + time.sleep(0.5) + + lines = [l for l in result.strip().split("\n") if l] + assert len(lines) == 10, f"Expected 10 rows, got {len(lines)}" + + for line in lines: + parts = line.split("\t") + assert parts[2] == exchange_name, f"Expected exchange '{exchange_name}', got '{parts[2]}'" + assert parts[3] == "rabbitmq_source", f"Expected table 'rabbitmq_source', got '{parts[3]}'" + + instance.query("DROP DATABASE test_virt SYNC") From b7a0595179c24437f86ed4a26f937a34bf0dfeff Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Mon, 27 Apr 2026 03:22:46 +0000 Subject: [PATCH 45/70] Backport #101161 to 26.3: Fix use-after-free in FileSegmentRangeWriter::completeFileSegment --- src/Disks/IO/CachedOnDiskWriteBufferFromFile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Disks/IO/CachedOnDiskWriteBufferFromFile.cpp b/src/Disks/IO/CachedOnDiskWriteBufferFromFile.cpp index 5bc16ea313e5..e3aa556ede31 100644 --- a/src/Disks/IO/CachedOnDiskWriteBufferFromFile.cpp +++ b/src/Disks/IO/CachedOnDiskWriteBufferFromFile.cpp @@ -283,6 +283,7 @@ void FileSegmentRangeWriter::completeFileSegment() return; LOG_TEST(log, "Completing file segment {}:{}", file_segment.key(), file_segment.offset()); + appendFilesystemCacheLog(file_segment); /// We do not force shrink file segment in case of distributed cache, /// because it is possible that we reconnected and @@ -293,7 +294,6 @@ void FileSegmentRangeWriter::completeFileSegment() /// file segment size != reserved size. /// TODO: we could send a packet from client indicating end of file. file_segments->completeAndPopFront(/*allow_background_download=*/false, /*force_shrink_to_downloaded_size=*/!is_distributed_cache); - appendFilesystemCacheLog(file_segment); } void FileSegmentRangeWriter::jumpToPosition(size_t position) From 50571c928df52341e0ab446f2ff6574074f08ae4 Mon Sep 17 00:00:00 2001 From: Sema Checherinda Date: Mon, 27 Apr 2026 13:05:55 +0900 Subject: [PATCH 46/70] Fix build: define handshake_timeout_milliseconds server setting The cherry-pick of #103284 dropped the `DECLARE(UInt64, handshake_timeout_milliseconds, ...)` line from `src/Core/ServerSettings.cpp` while keeping the matching `extern` in `src/Server/TCPHandler.cpp`. As a result, all `Build` jobs on this backport fail with: ld.lld-21: error: undefined symbol: DB::ServerSetting::handshake_timeout_milliseconds >>> referenced by TCPHandler.cpp:360 (TCPHandler.cpp.o) Re-add the missing declaration. On `master` and on the `26.4` branch the same line is already present (it landed earlier via the sync PR #103269), so this commit only changes the older release branches where the cherry-pick lost it. --- src/Core/ServerSettings.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Core/ServerSettings.cpp b/src/Core/ServerSettings.cpp index cbaaab35929c..bd107f454af1 100644 --- a/src/Core/ServerSettings.cpp +++ b/src/Core/ServerSettings.cpp @@ -1241,6 +1241,7 @@ The policy on how to perform a scheduling of CPU slots specified by `concurrent_ DECLARE(Float, distributed_cache_keep_up_free_connections_ratio, 0.1f, "Soft limit for number of active connection distributed cache will try to keep free. After the number of free connections goes below distributed_cache_keep_up_free_connections_ratio * max_connections, connections with oldest activity will be closed until the number goes above the limit.", 0) \ DECLARE(UInt64, tcp_close_connection_after_queries_num, 0, R"(Maximum number of queries allowed per TCP connection before the connection is closed. Set to 0 for unlimited queries.)", 0) \ DECLARE(UInt64, tcp_close_connection_after_queries_seconds, 0, R"(Maximum lifetime of a TCP connection in seconds before it is closed. Set to 0 for unlimited connection lifetime.)", 0) \ + DECLARE(UInt64, handshake_timeout_milliseconds, 30000, R"(Wall-clock timeout in milliseconds for the entire TCP handshake phase (Hello + Addendum). Limits how long an unauthenticated connection can hold a thread. Set to 0 to disable.)", 0) \ DECLARE(Bool, skip_binary_checksum_checks, false, R"(Skips ClickHouse binary checksum integrity checks)", 0) \ DECLARE(Bool, abort_on_logical_error, false, R"(Crash the server on LOGICAL_ERROR exceptions. Only for experts.)", 0) \ DECLARE(UInt64, jemalloc_flush_profile_interval_bytes, 0, R"(Flushing jemalloc profile will be done after global peak memory usage increased by jemalloc_flush_profile_interval_bytes)", 0) \ From 05a2028fe97cab3c5ca1afeede8292ec3a5a788a Mon Sep 17 00:00:00 2001 From: Sema Checherinda Date: Mon, 27 Apr 2026 13:34:16 +0900 Subject: [PATCH 47/70] Add Settings.cpp entries missed by backport bot The original PR's `Settings.cpp` and `SettingsChangesHistory.cpp` changes landed on master via a separate sync commit (6ec0371f117c), so the backport cherry-pick of #103285 did not carry them, leaving Context.cpp with undefined references to `DB::Setting::http_headers_read_timeout` and `DB::Setting::http_max_request_header_size`. Adds the two new settings, reduces defaults for `http_max_fields` and `http_max_field_name_size`, and records the changes in the 26.3 section of `SettingsChangesHistory.cpp`. --- src/Core/Settings.cpp | 10 ++++++++-- src/Core/SettingsChangesHistory.cpp | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Core/Settings.cpp b/src/Core/Settings.cpp index 0cbb8921adc8..5a8338356a98 100644 --- a/src/Core/Settings.cpp +++ b/src/Core/Settings.cpp @@ -2515,14 +2515,20 @@ Possible values: - Positive integer. )", 0) \ - DECLARE(UInt64, http_max_fields, 1000000, R"( + DECLARE(UInt64, http_max_fields, 1000, R"( Maximum number of fields in HTTP header )", 0) \ - DECLARE(UInt64, http_max_field_name_size, 128 * 1024, R"( + DECLARE(UInt64, http_max_field_name_size, 4 * 1024, R"( Maximum length of field name in HTTP header )", 0) \ DECLARE(UInt64, http_max_field_value_size, 128 * 1024, R"( Maximum length of field value in HTTP header +)", 0) \ + DECLARE(UInt64, http_max_request_header_size, 10 * 1024 * 1024, R"( +Maximum total size of all HTTP request headers (names and values combined) in bytes. +)", 0) \ + DECLARE(Seconds, http_headers_read_timeout, 30, R"( +Maximum time in seconds to read all HTTP request headers. This is a total deadline for the entire header parsing phase, not a per-read timeout. Protects against slowloris-style attacks where a client trickles header data slowly to hold connections open. )", 0) \ DECLARE(Bool, http_skip_not_found_url_for_globs, true, R"( Skip URLs for globs with HTTP_NOT_FOUND error diff --git a/src/Core/SettingsChangesHistory.cpp b/src/Core/SettingsChangesHistory.cpp index 5f1b713e8076..900dd95a75ac 100644 --- a/src/Core/SettingsChangesHistory.cpp +++ b/src/Core/SettingsChangesHistory.cpp @@ -41,6 +41,10 @@ const VersionToSettingsChangesMap & getSettingsChangesHistory() /// Note: please check if the key already exists to prevent duplicate entries. addSettingsChanges(settings_changes_history, "26.3", { + {"http_max_fields", 1000000, 1000, "Reduce default to limit pre-authentication memory usage by HTTP connections."}, + {"http_max_field_name_size", 131072, 4096, "Reduce default to limit pre-authentication memory usage by HTTP connections."}, + {"http_max_request_header_size", 0, 10485760, "New setting to limit total HTTP request header size before authentication."}, + {"http_headers_read_timeout", 0, 30, "New setting to limit total time for reading HTTP request headers, protecting against slowloris attacks."}, {"allow_experimental_polyglot_dialect", false, false, "New setting to enable the polyglot SQL transpiler dialect."}, {"polyglot_dialect", "", "", "New setting to specify the source SQL dialect for the polyglot transpiler."}, {"output_format_trim_fixed_string", false, false, "New setting to trim trailing zero bytes from FixedString values in text output formats"}, From 48fc911f51d07a7e3aa29435df29289d6045c5c5 Mon Sep 17 00:00:00 2001 From: Rahul Nair <254529899+motsc@users.noreply.github.com> Date: Sun, 26 Apr 2026 21:36:49 -0700 Subject: [PATCH 48/70] Backport distroless Docker support to 26.3 (#103156) Add the docker-init entrypoint binary and CI integration needed for distroless images. The Dockerfiles were backported in #102923 but the binary they reference (clickhouse docker-init) was missing. Cherry-picked from master: - programs/docker-init/ (entrypoint binary) - programs/main.cpp, programs/CMakeLists.txt (register docker-init) - ci/jobs/docker_server.py (add distroless build support) - ci/jobs/scripts/docker_server/ (test config and test cases) --- ci/jobs/docker_server.py | 41 +- ci/jobs/scripts/docker_server/config.sh | 7 +- .../clickhouse-distroless-initdb/initdb.sql | 3 + .../tests/clickhouse-distroless-initdb/run.sh | 46 + .../clickhouse-distroless-no-shell/run.sh | 17 + programs/CMakeLists.txt | 2 + programs/docker-init/CMakeLists.txt | 8 + programs/docker-init/docker-init.cpp | 1075 +++++++++++++++++ programs/main.cpp | 2 + 9 files changed, 1194 insertions(+), 7 deletions(-) create mode 100644 ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/initdb.sql create mode 100755 ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/run.sh create mode 100755 ci/jobs/scripts/docker_server/tests/clickhouse-distroless-no-shell/run.sh create mode 100644 programs/docker-init/CMakeLists.txt create mode 100644 programs/docker-init/docker-init.cpp diff --git a/ci/jobs/docker_server.py b/ci/jobs/docker_server.py index 44216b549b5f..bf1cdd71f005 100644 --- a/ci/jobs/docker_server.py +++ b/ci/jobs/docker_server.py @@ -101,7 +101,7 @@ def parse_args() -> argparse.Namespace: ) parser.add_argument("--reports", default=True, help=argparse.SUPPRESS) parser.add_argument("--push", action="store_true", help=argparse.SUPPRESS) - parser.add_argument("--os", default=["ubuntu", "alpine"], help=argparse.SUPPRESS) + parser.add_argument("--os", default=["ubuntu", "alpine", "distroless"], help=argparse.SUPPRESS) parser.add_argument( "--no-ubuntu", action=DelOS, @@ -116,6 +116,13 @@ def parse_args() -> argparse.Namespace: default=argparse.SUPPRESS, help="don't build alpine image", ) + parser.add_argument( + "--no-distroless", + action=DelOS, + nargs=0, + default=argparse.SUPPRESS, + help="don't build distroless image", + ) parser.add_argument( "--allow-build-reuse", action="store_true", @@ -215,10 +222,25 @@ def build_and_push_image( cmd_args = list(init_args) urls = [] if direct_urls: - if os == "ubuntu" and "clickhouse-server" in image.name: - urls = [url for url in direct_urls[arch] if ".deb" in url] + # distroless and ubuntu-server use an Ubuntu builder with dpkg, so they + # need .deb packages. alpine and ubuntu-keeper use .tgz packages. + uses_deb = os == "distroless" or ( + os == "ubuntu" and "clickhouse-server" in image.name + ) + if uses_deb: + urls = [ + url + for url in direct_urls[arch] + if ".deb" in url and "-dbg" not in url + ] else: - urls = [url for url in direct_urls[arch] if ".tgz" in url] + # For keeper/alpine tgz builds, only pass the keeper tgz. + # Excluding clickhouse-common-static.tgz avoids a large unnecessary download. + tgz_urls = [url for url in direct_urls[arch] if ".tgz" in url] + if "keeper" in image.name: + urls = [url for url in tgz_urls if "clickhouse-keeper" in url] + else: + urls = tgz_urls cmd_args.extend( buildx_args( repo_urls, @@ -384,7 +406,16 @@ def main(): "clickhouse-common-static", ] elif "clickhouse-keeper" in image_repo: - PACKAGES = ["clickhouse-keeper"] + # Both packages are needed to cover all three keeper image variants: + # distroless: installs from .deb via dpkg; clickhouse-common-static + # provides the clickhouse multi-tool binary (clickhouse-keeper + # is a symlink to it). clickhouse-keeper .deb is not published + # separately, so the common-static .deb is the only source. + # alpine/ubuntu: installs from .tgz; clickhouse-keeper provides the + # standalone keeper binary and its symlinks. The common-static + # .tgz is implicitly excluded because the url filter below + # keeps only urls containing "clickhouse-keeper" in the name. + PACKAGES = ["clickhouse-common-static", "clickhouse-keeper"] else: assert False, "BUG" urls = read_build_urls(build_name) diff --git a/ci/jobs/scripts/docker_server/config.sh b/ci/jobs/scripts/docker_server/config.sh index 1e69ca534b35..84882b1745df 100644 --- a/ci/jobs/scripts/docker_server/config.sh +++ b/ci/jobs/scripts/docker_server/config.sh @@ -3,11 +3,14 @@ # Get current file directory currentDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" -# interate over all directories in current path -clickhouseTests=$( find "$currentDir"/tests/ -maxdepth 1 -name 'clickhouse-*' -type d -exec basename {} \; ) +# iterate over all directories in current path +clickhouseTests=$( find "$currentDir"/tests/ -maxdepth 1 -name 'clickhouse-*' -not -name 'clickhouse-distroless-*' -type d -exec basename {} \; ) +clickhouseDistrolessTests=$( find "$currentDir"/tests/ -maxdepth 1 -name 'clickhouse-distroless-*' -type d -exec basename {} \; ) keeperTests=$( find "$currentDir"/tests/ -maxdepth 1 -name 'keeper-*' -type d -exec basename {} \; ) imageTests+=( ['clickhouse/clickhouse-server']="${clickhouseTests}" + ['clickhouse/clickhouse-server:distroless']="${clickhouseTests} ${clickhouseDistrolessTests}" ['clickhouse/clickhouse-keeper']="${keeperTests}" + ['clickhouse/clickhouse-keeper:distroless']="${keeperTests}" ) diff --git a/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/initdb.sql b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/initdb.sql new file mode 100644 index 000000000000..16304daf2aa6 --- /dev/null +++ b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/initdb.sql @@ -0,0 +1,3 @@ +CREATE DATABASE IF NOT EXISTS test_db; +CREATE TABLE IF NOT EXISTS test_db.test_table (id UInt32, value UInt32) ENGINE = MergeTree ORDER BY id; +INSERT INTO test_db.test_table VALUES (1, 100), (2, 200); diff --git a/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/run.sh b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/run.sh new file mode 100755 index 000000000000..597818de6c21 --- /dev/null +++ b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/run.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Verify that clickhouse docker-init executes SQL initdb scripts correctly. +# The distroless image has no shell so initdb scripts must be handled +# by the compiled docker-init entrypoint, not by entrypoint.sh. +set -eo pipefail + +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +source "$dir/../lib.sh" + +image="$1" + +export CLICKHOUSE_USER='init_test_user' +export CLICKHOUSE_PASSWORD='init_test_password' + +cid="$( + docker run -d \ + -e CLICKHOUSE_USER \ + -e CLICKHOUSE_PASSWORD \ + -v "$dir/initdb.sql":/docker-entrypoint-initdb.d/initdb.sql:ro \ + --name "$(cname)" \ + "$image" +)" +trap 'docker rm -vf $cid > /dev/null' EXIT + +chCli() { + docker run --rm -i \ + --link "$cid":clickhouse \ + -e CLICKHOUSE_USER \ + -e CLICKHOUSE_PASSWORD \ + "$image" \ + clickhouse-client \ + --host clickhouse \ + --user "$CLICKHOUSE_USER" \ + --password "$CLICKHOUSE_PASSWORD" \ + --query "$*" +} + +# shellcheck source=../../../../../tmp/docker-library/official-images/test/retry.sh +. "$TESTS_LIB_DIR/retry.sh" \ + --tries "$CLICKHOUSE_TEST_TRIES" \ + --sleep "$CLICKHOUSE_TEST_SLEEP" \ + chCli SELECT 1 + +# Verify the initdb script ran and created the table with the expected data +chCli SHOW TABLES IN test_db | grep '^test_table$' >/dev/null +[ "$(chCli 'SELECT SUM(value) FROM test_db.test_table')" = 300 ] diff --git a/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-no-shell/run.sh b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-no-shell/run.sh new file mode 100755 index 000000000000..c5319f120446 --- /dev/null +++ b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-no-shell/run.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Verify the distroless production image contains no shell. +# This is the key property of a distroless image: /bin/sh, /bin/bash, +# and other shells must be absent to reduce the attack surface. +set -eo pipefail + +image="$1" + +if docker run --rm --entrypoint /bin/sh "$image" -c "echo bad" 2>/dev/null; then + echo "FAIL: /bin/sh should not exist in the distroless image" >&2 + exit 1 +fi + +if docker run --rm --entrypoint /bin/bash "$image" -c "echo bad" 2>/dev/null; then + echo "FAIL: /bin/bash should not exist in the distroless image" >&2 + exit 1 +fi diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index 8dfd1b6fffc7..c44a71c1a85a 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -99,6 +99,7 @@ add_subdirectory (checksum-for-compressed-block) add_subdirectory (client) add_subdirectory (compressor) add_subdirectory (disks) +add_subdirectory (docker-init) add_subdirectory (extract-from-config) add_subdirectory (format) add_subdirectory (git-import) @@ -177,6 +178,7 @@ clickhouse_program_install(clickhouse-checksum-for-compressed-block checksum-for clickhouse_program_install(clickhouse-client client chc) clickhouse_program_install(clickhouse-compressor compressor) clickhouse_program_install(clickhouse-disks disks) +clickhouse_program_install(clickhouse-docker-init docker-init) clickhouse_program_install(clickhouse-extract-from-config extract-from-config) clickhouse_program_install(clickhouse-format format) clickhouse_program_install(clickhouse-git-import git-import) diff --git a/programs/docker-init/CMakeLists.txt b/programs/docker-init/CMakeLists.txt new file mode 100644 index 000000000000..10ff94881396 --- /dev/null +++ b/programs/docker-init/CMakeLists.txt @@ -0,0 +1,8 @@ +set (CLICKHOUSE_DOCKER_INIT_SOURCES docker-init.cpp) + +set (CLICKHOUSE_DOCKER_INIT_LINK + PRIVATE + clickhouse_common_io +) + +clickhouse_program_add(docker-init) diff --git a/programs/docker-init/docker-init.cpp b/programs/docker-init/docker-init.cpp new file mode 100644 index 000000000000..4f49cd43b2bc --- /dev/null +++ b/programs/docker-init/docker-init.cpp @@ -0,0 +1,1075 @@ +/// clickhouse docker-init — Docker entrypoint for distroless ClickHouse images. +/// Replaces entrypoint.sh in shell-free environments (no bash, no coreutils). +/// +/// Usage: +/// clickhouse docker-init [--keeper] [-- ...] +/// +/// Environment variables (same as entrypoint.sh): +/// CLICKHOUSE_CONFIG, CLICKHOUSE_RUN_AS_ROOT, CLICKHOUSE_DO_NOT_CHOWN, +/// CLICKHOUSE_UID, CLICKHOUSE_GID, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, +/// CLICKHOUSE_PASSWORD_FILE, CLICKHOUSE_DB, CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT, +/// CLICKHOUSE_SKIP_USER_SETUP, CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS, +/// CLICKHOUSE_INIT_TIMEOUT, CLICKHOUSE_WATCHDOG_ENABLE, KEEPER_CONFIG + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace fs = std::filesystem; + +namespace +{ + +/// Path to the clickhouse multi-tool binary, derived from argv[0]. +/// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +std::string g_clickhouse_binary; + +/// Set by the SIGTERM/SIGINT handler during init to request graceful shutdown. +/// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +volatile sig_atomic_t g_shutdown_requested = 0; + +/// PID of the temporary init server, so the signal handler can forward SIGTERM. +/// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +volatile pid_t g_init_server_pid = 0; + +void shutdownHandler(int sig) +{ + g_shutdown_requested = 1; + + /// Forward the signal to the temporary server if one is running. + pid_t pid = g_init_server_pid; + if (pid > 0) + kill(pid, sig); +} + +/// Get an environment variable value, returning default_value if not set. +std::string getEnv(const char * name, const std::string & default_value = "") +{ + const char * val = std::getenv(name); // NOLINT(concurrency-mt-unsafe) + return val ? std::string(val) : default_value; +} + +/// Build an execvp-compatible argv array from a vector of strings. +std::vector buildArgv(const std::vector & args) +{ + std::vector argv; + argv.reserve(args.size() + 1); + for (const auto & a : args) + argv.push_back(const_cast(a.c_str())); // NOLINT(cppcoreguidelines-pro-type-const-cast) + argv.push_back(nullptr); + return argv; +} + +/// Run a command and wait for it. Returns the exit code (or -1 on error). +int runCommand(const std::vector & args) +{ + pid_t pid = fork(); + if (pid < 0) + return -1; + + if (pid == 0) + { + auto argv = buildArgv(args); + execvp(argv[0], argv.data()); + _exit(127); + } + + int status = 0; + while (waitpid(pid, &status, 0) < 0) + if (errno != EINTR) + return -1; + return WIFEXITED(status) ? WEXITSTATUS(status) : -1; +} + +/// Run a command, capture its stdout, return {exit_code, output_lines}. +std::pair> captureCommand(const std::vector & args) +{ + int pipefd[2]; + if (pipe(pipefd) < 0) + return {-1, {}}; + + pid_t pid = fork(); + if (pid < 0) + { + (void)close(pipefd[0]); + (void)close(pipefd[1]); + return {-1, {}}; + } + + if (pid == 0) + { + (void)close(pipefd[0]); + if (dup2(pipefd[1], STDOUT_FILENO) < 0) + _exit(127); + (void)close(pipefd[1]); + + /// Suppress stderr to avoid noise from --try extractions. + int devnull = open("/dev/null", O_WRONLY); + if (devnull >= 0) + { + (void)dup2(devnull, STDERR_FILENO); + (void)close(devnull); + } + + auto argv = buildArgv(args); + execvp(argv[0], argv.data()); + _exit(127); + } + + (void)close(pipefd[1]); + + std::string output; + char buf[4096]; + ssize_t n; + while ((n = read(pipefd[0], buf, sizeof(buf))) > 0) + output.append(buf, static_cast(n)); + (void)close(pipefd[0]); + + int status = 0; + while (waitpid(pid, &status, 0) < 0) + if (errno != EINTR) + return {-1, {}}; + + /// Split output into non-empty lines. + std::vector lines; + { + size_t pos = 0; + while (pos < output.size()) + { + size_t found = output.find('\n', pos); + if (found == std::string::npos) + found = output.size(); + std::string line = output.substr(pos, found - pos); + if (!line.empty() && line.back() == '\r') + line.pop_back(); + if (!line.empty()) + lines.push_back(std::move(line)); + pos = found + 1; + } + } + + return {WIFEXITED(status) ? WEXITSTATUS(status) : -1, std::move(lines)}; +} + +/// Run two commands connected by a pipe: lhs | rhs. +/// Returns the exit code of the rhs process. +int runPipeline(const std::vector & lhs, const std::vector & rhs) +{ + int pipefd[2]; + if (pipe(pipefd) < 0) + return -1; + + pid_t lhs_pid = fork(); + if (lhs_pid < 0) + { + (void)close(pipefd[0]); + (void)close(pipefd[1]); + return -1; + } + if (lhs_pid == 0) + { + (void)close(pipefd[0]); + (void)dup2(pipefd[1], STDOUT_FILENO); + (void)close(pipefd[1]); + auto argv = buildArgv(lhs); + execvp(argv[0], argv.data()); + _exit(127); + } + + pid_t rhs_pid = fork(); + if (rhs_pid < 0) + { + (void)close(pipefd[0]); + (void)close(pipefd[1]); + kill(lhs_pid, SIGTERM); + while (waitpid(lhs_pid, nullptr, 0) < 0 && errno == EINTR) {} + return -1; + } + if (rhs_pid == 0) + { + (void)close(pipefd[1]); + (void)dup2(pipefd[0], STDIN_FILENO); + (void)close(pipefd[0]); + auto argv = buildArgv(rhs); + execvp(argv[0], argv.data()); + _exit(127); + } + + (void)close(pipefd[0]); + (void)close(pipefd[1]); + + int lhs_status = 0; + int rhs_status = 0; + while (waitpid(lhs_pid, &lhs_status, 0) < 0 && errno == EINTR) {} + while (waitpid(rhs_pid, &rhs_status, 0) < 0 && errno == EINTR) {} + + return WIFEXITED(rhs_status) ? WEXITSTATUS(rhs_status) : -1; +} + +/// Returns true if the string is a safe ClickHouse identifier: +/// alphanumeric + underscore, not starting with a digit. +/// Used to validate CLICKHOUSE_USER and CLICKHOUSE_DB before embedding in SQL/XML. +bool isValidIdentifier(const std::string & s) +{ + if (s.empty()) + return false; + if (std::isdigit(static_cast(s[0]))) + return false; + for (unsigned char c : s) + if (!std::isalnum(c) && c != '_') + return false; + return true; +} + +/// Extract a single value from a ClickHouse config key via `clickhouse extract-from-config`. +/// Returns an empty string if the key is absent (--try flag suppresses errors). +std::string extractConfigValue(const std::string & config_file, const std::string & key, bool use_users = false) +{ + std::vector args = { + g_clickhouse_binary, "extract-from-config", + "--config-file", config_file, + "--key", key, + "--try", + }; + if (use_users) + args.emplace_back("--users"); + + auto [code, lines] = captureCommand(args); + return (code == 0 && !lines.empty()) ? lines[0] : std::string{}; +} + +/// Extract multiple values from a ClickHouse config key (wildcard patterns return multiple lines). +std::vector extractConfigValues(const std::string & config_file, const std::string & key) +{ + auto [code, lines] = captureCommand({ + g_clickhouse_binary, "extract-from-config", + "--config-file", config_file, + "--key", key, + "--try", + }); + return (code == 0) ? std::move(lines) : std::vector{}; +} + +/// Recursively chown a path. Logs warnings but does not abort on failure. +void recursiveChown(const std::string & path_str, uid_t uid, gid_t gid) +{ + if (lchown(path_str.c_str(), uid, gid) < 0) + std::cerr << "docker-init: warning: lchown " << path_str << ": " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) + + std::error_code ec; + if (!fs::is_directory(path_str, ec)) + return; + + for (const auto & entry : fs::recursive_directory_iterator(path_str, fs::directory_options::skip_permission_denied, ec)) + { + if (lchown(entry.path().c_str(), uid, gid) < 0) + std::cerr << "docker-init: warning: lchown " << entry.path() << ": " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) + } +} + +/// Create a directory (and all parents) and optionally chown it. +/// +/// Three cases: +/// 1. do_chown=true (root, normal mode): create with fs::create_directories, then chown. +/// 2. do_chown=false, running as root (CLICKHOUSE_DO_NOT_CHOWN=1): delegate to +/// `clickhouse su UID:GID` so the directory is created as the target user. +/// This handles NFS mounts where root is mapped to nobody. +/// 3. do_chown=false, running as non-root: create directly — we are already the target user. +bool createDirectoryAndChown(const std::string & dir, uid_t uid, gid_t gid, bool do_chown) +{ + if (dir.empty()) + return true; + + if (do_chown) + { + std::error_code ec; + fs::create_directories(dir, ec); + if (ec) + { + std::cerr << "docker-init: couldn't create directory " << dir << ": " << ec.message() << "\n"; + return false; + } + + /// Chown only if the owner needs to change (avoids slow recursive chown on already-correct dirs). + struct stat st{}; + if (stat(dir.c_str(), &st) == 0 && (st.st_uid != uid || st.st_gid != gid)) + recursiveChown(dir, uid, gid); + + return true; + } + + if (getuid() == 0) + { + /// Running as root with CLICKHOUSE_DO_NOT_CHOWN or CLICKHOUSE_RUN_AS_ROOT. + /// On NFS mounts root may be remapped to nobody, so create the directory as + /// the target user. Fork a child that drops privileges before calling + /// fs::create_directories — distroless has no mkdir binary. + pid_t pid = fork(); + if (pid < 0) + { + std::cerr << "docker-init: fork failed for directory creation: " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) + return false; + } + if (pid == 0) + { + if (setgroups(0, nullptr) < 0 || setgid(gid) < 0 || setuid(uid) < 0) + _exit(1); + std::error_code ec; + fs::create_directories(dir, ec); + _exit(ec ? 1 : 0); + } + int status = 0; + while (waitpid(pid, &status, 0) < 0 && errno == EINTR) {} + if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) + { + /// Fallback: try direct creation (works when root is not remapped). + std::error_code ec; + fs::create_directories(dir, ec); + if (ec) + { + std::cerr << "docker-init: couldn't create directory " << dir << ": " << ec.message() << "\n"; + return false; + } + } + return true; + } + + /// Non-root: we are already running as UID:GID, so create the directory directly. + std::error_code ec; + fs::create_directories(dir, ec); + if (ec) + { + std::cerr << "docker-init: couldn't create directory " << dir << ": " << ec.message() << "\n"; + return false; + } + return true; +} + +/// Write the user management XML to `/etc/clickhouse-server/users.d/default-user.xml`. +/// Returns false if a user-requested setup (CLICKHOUSE_USER/PASSWORD/ACCESS_MANAGEMENT) +/// is invalid — caller should treat this as fatal. +bool manageClickHouseUser( + const std::string & config_file, + const std::string & clickhouse_user, + const std::string & clickhouse_password, + const std::string & access_management, + bool skip_user_setup) +{ + if (skip_user_setup) + { + std::cerr << "docker-init: explicitly skip changing user 'default'\n"; + return true; + } + + const std::string users_d_dir = "/etc/clickhouse-server/users.d"; + const std::string default_user_xml = users_d_dir + "/default-user.xml"; + + std::error_code ec; + fs::create_directories(users_d_dir, ec); + + /// Detect whether the default user was customised via a mounted config file. + bool clickhouse_default_changed = false; + std::string users_xml_path = extractConfigValue(config_file, "user_directories.users_xml.path"); + if (!users_xml_path.empty()) + { + std::string abs_users_xml = (users_xml_path[0] == '/') + ? users_xml_path + : (fs::path(config_file).parent_path() / users_xml_path).string(); + + auto join = [](const std::vector & v) + { + std::string s; + for (const auto & line : v) + s += line + "\n"; + return s; + }; + + auto [c1, original] = captureCommand({ + g_clickhouse_binary, "extract-from-config", + "--config-file", abs_users_xml, + "--key", "users.default", "--try", + }); + auto [c2, processed] = captureCommand({ + g_clickhouse_binary, "extract-from-config", + "--config-file", config_file, + "--users", "--key", "users.default", "--try", + }); + + if (c1 == 0 && c2 == 0 && join(original) != join(processed)) + clickhouse_default_changed = true; + } + + bool has_custom_user = !clickhouse_user.empty() && clickhouse_user != "default"; + bool has_password = !clickhouse_password.empty(); + bool has_access_mgmt = access_management != "0"; + + if (has_custom_user || has_password || has_access_mgmt) + { + if (access_management != "0" && access_management != "1") + { + std::cerr << "docker-init: error: CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT must be '0' or '1', got '" + << access_management << "'\n"; + return false; + } + + if (!isValidIdentifier(clickhouse_user)) + { + std::cerr << "docker-init: error: CLICKHOUSE_USER '" << clickhouse_user + << "' contains characters not allowed in an XML element name; " + "use only alphanumeric characters and underscores\n"; + return false; + } + + std::cerr << "docker-init: create new user '" << clickhouse_user << "' instead 'default'\n"; + + /// Escape CDATA end marker: ]]> → ]]]]> + std::string escaped_password; + { + std::string_view src = clickhouse_password; + const std::string_view needle = "]]>"; + const std::string_view replacement = "]]]]>"; + size_t pos = 0; + size_t found; + while ((found = src.find(needle, pos)) != std::string_view::npos) + { + escaped_password.append(src, pos, found - pos); + escaped_password += replacement; + pos = found + needle.size(); + } + escaped_password.append(src, pos, src.size() - pos); + } + + { + std::ofstream f(default_user_xml); + f << "\n" + << " \n" + << " \n" + << " \n" + << " \n" + << " \n" + << "\n" + << " <" << clickhouse_user << ">\n" + << " default\n" + << " \n" + << " ::/0\n" + << " \n" + << " \n" + << " default\n" + << " " << access_management << "\n" + << " \n" + << " \n" + << "\n"; + if (!f.good()) + std::cerr << "docker-init: error: failed to write " << default_user_xml << "\n"; + } + } + else if (clickhouse_default_changed) + { + /// A mounted config already customised the user — leave it as-is. + } + else + { + std::cerr << "docker-init: neither CLICKHOUSE_USER nor CLICKHOUSE_PASSWORD is set, " + "disabling network access for user 'default'\n"; + { + std::ofstream f(default_user_xml); + f << "\n" + << " \n" + << " \n" + << " \n" + << " \n" + << " \n" + << " ::1\n" + << " 127.0.0.1\n" + << " \n" + << " \n" + << " \n" + << "\n"; + if (!f.good()) + std::cerr << "docker-init: error: failed to write " << default_user_xml << "\n"; + } + } + return true; +} + +/// Returns false on first error (fail-fast, matches shell `set -e`). +bool createClickHouseDatabase( + const std::vector & client_base, + const std::string & clickhouse_db) +{ + if (clickhouse_db.empty()) + return true; + if (!isValidIdentifier(clickhouse_db)) + { + std::cerr << "docker-init: error: CLICKHOUSE_DB '" << clickhouse_db + << "' contains characters not safe for use in SQL; " + "use only alphanumeric characters and underscores\n"; + return false; + } + std::cerr << "docker-init: create database '" << clickhouse_db << "'\n"; + std::vector args = client_base; + args.insert(args.end(), {"-q", "CREATE DATABASE IF NOT EXISTS " + clickhouse_db}); + if (runCommand(args) != 0) + { + std::cerr << "docker-init: error: failed to create database '" << clickhouse_db << "'\n"; + return false; + } + return true; +} + +/// Returns false on first script failure (fail-fast, matches shell `set -e`). +bool runInitScripts(const std::vector & client_base) +{ + std::error_code ec; + if (!fs::is_directory("/docker-entrypoint-initdb.d", ec)) + return true; + std::vector init_files; + for (const auto & entry : fs::directory_iterator("/docker-entrypoint-initdb.d", ec)) + init_files.push_back(entry.path()); + std::sort(init_files.begin(), init_files.end()); + + for (const auto & path : init_files) + { + std::string filename = path.filename().string(); + + if (filename.ends_with(".sql") && !filename.ends_with(".sql.gz")) + { + std::cerr << "docker-init: running " << path << "\n"; + std::vector args = client_base; + args.emplace_back("--queries-file"); + args.push_back(path.string()); + if (runCommand(args) != 0) + { + std::cerr << "docker-init: error: init script " << path << " failed\n"; + return false; + } + } + else if (filename.ends_with(".sql.gz")) + { + std::cerr << "docker-init: running " << path << " (decompressing)\n"; + /// Decompress via clickhouse-local (auto-detects .gz) and pipe to clickhouse-client. + /// Escape single quotes in the path to prevent SQL injection via crafted filenames. + std::string escaped_path; + for (char c : path.string()) + { + if (c == '\'') + escaped_path += "''"; + else + escaped_path += c; + } + std::vector decompress_args = { + g_clickhouse_binary, "local", + "--query", + "SELECT * FROM file('" + escaped_path + "', RawBLOB) FORMAT RawBLOB", + }; + if (runPipeline(decompress_args, client_base) != 0) + { + std::cerr << "docker-init: error: init script " << path << " failed\n"; + return false; + } + } + else if (filename.ends_with(".sh")) + { + std::cerr << "docker-init: WARNING: shell scripts cannot run in a distroless " + "environment, skipping " << path << "\n"; + } + else + { + std::cerr << "docker-init: ignoring " << path << "\n"; + } + } + return true; +} + +/// Start a temporary ClickHouse server, run init scripts, then stop it. +bool initClickHouseDB( + const std::string & config_file, + const std::string & data_dir, + const std::string & clickhouse_user, + const std::string & clickhouse_password, + uid_t run_uid, + gid_t run_gid, + const std::vector & extra_server_args, + bool always_run_initdb) +{ + /// Skip if data directory is already initialised and CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS is unset. + bool database_exists = fs::is_directory(data_dir + "/data"); + if (!always_run_initdb && database_exists) + { + std::cerr << "docker-init: ClickHouse data directory appears to contain a database; " + "skipping initialization\n"; + return true; + } + + std::string clickhouse_db = getEnv("CLICKHOUSE_DB"); + + /// Check whether /docker-entrypoint-initdb.d has any files. + std::error_code ec; + bool has_init_files = fs::is_directory("/docker-entrypoint-initdb.d", ec) + && fs::directory_iterator("/docker-entrypoint-initdb.d", ec) != fs::directory_iterator{}; + + if (!has_init_files && clickhouse_db.empty()) + return true; + + std::string native_port = extractConfigValue(config_file, "tcp_port"); + if (native_port.empty()) + native_port = "9000"; + + std::string run_as = std::to_string(run_uid) + ":" + std::to_string(run_gid); + + /// Start a temporary server bound only to localhost. + /// The "--" separator is required: positional arguments after "--" override config.xml + /// properties (e.g. --listen_host=127.0.0.1), while options before "--" are parsed by + /// Poco and must be registered. Without "--", Poco rejects "--listen_host" as unknown. + std::vector server_args = { + g_clickhouse_binary, "su", run_as, "clickhouse-server", + "--config-file=" + config_file, + "--", "--listen_host=127.0.0.1", + }; + for (const auto & arg : extra_server_args) + server_args.push_back(arg); + + if (g_shutdown_requested) + return true; + + pid_t server_pid = fork(); + if (server_pid < 0) + { + std::cerr << "docker-init: failed to fork temporary server\n"; + return false; + } + + if (server_pid == 0) + { + auto argv = buildArgv(server_args); + execvp(argv[0], argv.data()); + _exit(127); + } + + /// Allow the signal handler to forward SIGTERM to the temp server. + g_init_server_pid = server_pid; + + /// Poll until the server accepts connections. + /// This is a service-readiness wait, not a race condition workaround. + int tries = 1000; + { + std::string timeout_str = getEnv("CLICKHOUSE_INIT_TIMEOUT", "1000"); + try + { + tries = std::stoi(timeout_str); + } + catch (const std::exception &) + { + std::cerr << "docker-init: warning: invalid CLICKHOUSE_INIT_TIMEOUT '" + << timeout_str << "', using default 1000\n"; + } + } + bool server_ready = false; + + while (tries > 0 && !server_ready && !g_shutdown_requested) + { + pid_t check_pid = fork(); + if (check_pid < 0) + { + /// fork failed — skip this iteration and retry. + --tries; + sleep(1); // NOLINT(concurrency-mt-unsafe) + continue; + } + if (check_pid == 0) + { + int devnull = open("/dev/null", O_WRONLY); + if (devnull >= 0) + { + dup2(devnull, STDOUT_FILENO); + dup2(devnull, STDERR_FILENO); + close(devnull); + } + /// Keep args in a named variable so the strings outlive argv. + std::vector check_args = { + g_clickhouse_binary, "client", + "--host", "127.0.0.1", + "--port", native_port, + "-u", clickhouse_user, + "--password", clickhouse_password, + "--query", "SELECT 1", + }; + auto argv = buildArgv(check_args); + execvp(argv[0], argv.data()); + _exit(127); + } + + int check_status = 0; + while (waitpid(check_pid, &check_status, 0) < 0 && errno == EINTR) {} + if (WIFEXITED(check_status) && WEXITSTATUS(check_status) == 0) + { + server_ready = true; + } + else + { + --tries; + sleep(1); // NOLINT(concurrency-mt-unsafe) -- Wait between health-check retries — not a race condition fix. + } + } + + if (!server_ready) + { + if (g_shutdown_requested) + std::cerr << "docker-init: shutdown requested, stopping init server\n"; + else + std::cerr << "docker-init: ClickHouse init process timed out\n"; + kill(server_pid, SIGTERM); + while (waitpid(server_pid, nullptr, 0) < 0 && errno == EINTR) {} + g_init_server_pid = 0; + return false; + } + + std::vector client_base = { + g_clickhouse_binary, "client", + "--multiquery", + "--host", "127.0.0.1", + "--port", native_port, + "-u", clickhouse_user, + "--password", clickhouse_password, + }; + + const bool ok = createClickHouseDatabase(client_base, clickhouse_db) + && runInitScripts(client_base); + + /// Always stop the temporary server regardless of init result. + kill(server_pid, SIGTERM); + int server_status = 0; + while (waitpid(server_pid, &server_status, 0) < 0 && errno == EINTR) {} + g_init_server_pid = 0; + if (!WIFEXITED(server_status) || WEXITSTATUS(server_status) != 0) + std::cerr << "docker-init: warning: init server did not exit cleanly\n"; + return ok; +} + +} // anonymous namespace + + +int mainEntryClickHouseDockerInit(int argc, char ** argv) +{ + g_clickhouse_binary = (argc > 0 && argv[0][0] != '\0') ? argv[0] : "clickhouse"; + + bool keeper_mode = false; + bool show_help = false; + bool separator_seen = false; + std::vector extra_args; + + for (int i = 1; i < argc; ++i) + { + std::string_view arg = argv[i]; + + if (!separator_seen && (arg == "--help" || arg == "-h")) + { + show_help = true; + break; + } + else if (!separator_seen && arg == "--keeper") + keeper_mode = true; + else if (!separator_seen && arg == "--") + separator_seen = true; + else + extra_args.emplace_back(arg); + } + + if (show_help) + { + std::cout + << "Usage: clickhouse docker-init [--keeper] [-- ...]\n" + "Docker entrypoint for distroless ClickHouse images.\n" + "\nOptions:\n" + " --keeper Start ClickHouse Keeper instead of server\n" + " --help Show this help message\n" + "\nEnvironment variables (server mode):\n" + " CLICKHOUSE_CONFIG Path to config file " + "(default: /etc/clickhouse-server/config.xml)\n" + " CLICKHOUSE_RUN_AS_ROOT Run as root (0/1)\n" + " CLICKHOUSE_DO_NOT_CHOWN Skip chown operations (0/1)\n" + " CLICKHOUSE_UID Override UID to run as\n" + " CLICKHOUSE_GID Override GID to run as\n" + " CLICKHOUSE_USER Default user name (default: default)\n" + " CLICKHOUSE_PASSWORD Default user password\n" + " CLICKHOUSE_PASSWORD_FILE File containing password\n" + " CLICKHOUSE_DB Database to create on init\n" + " CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT Enable access management (0/1)\n" + " CLICKHOUSE_SKIP_USER_SETUP Skip user setup (0/1)\n" + " CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS Always run init scripts\n" + " CLICKHOUSE_INIT_TIMEOUT Max retries for server readiness (default: 1000)\n" + " CLICKHOUSE_WATCHDOG_ENABLE Enable watchdog (default: 0)\n" + "\nEnvironment variables (keeper mode):\n" + " KEEPER_CONFIG Path to keeper config file\n" + " CLICKHOUSE_DATA_DIR Data directory (default: /var/lib/clickhouse)\n" + " LOG_DIR Log directory (default: /var/log/clickhouse-keeper)\n"; + return 0; + } + + /// --- Passthrough mode --- + /// If the first extra argument does not start with '--', treat it as a command to exec + /// directly without server startup. This mirrors entrypoint.sh: + /// if [[ "$1" == "--"* ]]; then start server; fi; exec "$@" + /// + /// For recognized ClickHouse subcommand names (client, local, etc.) resolve the path + /// via bin_dir so that multi-tool dispatch (by argv[0] basename) works correctly. + /// For everything else (echo, date, bash, ...) let PATH resolution handle it. + if (!extra_args.empty() && !extra_args[0].starts_with("--")) + { + static constexpr std::array clickhouse_tools = { + "clickhouse-client", + "clickhouse-local", + "clickhouse-keeper-client", + "clickhouse-benchmark", + "clickhouse-format", + "clickhouse-compressor", + "clickhouse-obfuscator", + "clickhouse-extract-from-config", + "clickhouse-disks", + "client", + "local", + "keeper-client", + "benchmark", + "format", + "compressor", + "obfuscator", + "extract-from-config", + "disks", + }; + + std::string cmd = extra_args[0]; + if (std::find(clickhouse_tools.begin(), clickhouse_tools.end(), extra_args[0]) != clickhouse_tools.end()) + { + /// Build the full path to the symlink (e.g. /usr/bin/clickhouse-client). + /// The symlink points to the clickhouse binary; dispatching is done by argv[0]. + /// Short names like "client" must be resolved to "clickhouse-client" since the + /// distroless image only has "clickhouse-*" symlinks (not bare "client", "local", etc.). + fs::path bin_dir = fs::path(g_clickhouse_binary).parent_path(); + std::string link_name = extra_args[0]; + if (!link_name.starts_with("clickhouse-")) + link_name = "clickhouse-" + link_name; + cmd = (bin_dir / link_name).string(); + } + + std::vector exec_cmd = {cmd}; + for (std::size_t i = 1; i < extra_args.size(); ++i) + exec_cmd.push_back(extra_args[i]); + + auto exec_argv = buildArgv(exec_cmd); + execvp(exec_argv[0], exec_argv.data()); + std::cerr << "docker-init: failed to exec '" << extra_args[0] << "': " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) + return 1; + } + + /// --- Resolve identity --- + uid_t current_uid = getuid(); + uid_t run_uid; + gid_t run_gid; + bool do_chown = true; + + if (getEnv("CLICKHOUSE_RUN_AS_ROOT") == "1" || getEnv("CLICKHOUSE_DO_NOT_CHOWN") == "1") + do_chown = false; + + if (current_uid == 0) + { + if (getEnv("CLICKHOUSE_RUN_AS_ROOT") == "1") + { + run_uid = 0; + run_gid = 0; + } + else + { + /// Default to the `clickhouse` system user if it exists, otherwise fall back to UID 101. + uid_t default_uid = 101; + gid_t default_gid = 101; + const passwd * pw = getpwnam("clickhouse"); // NOLINT(concurrency-mt-unsafe) + if (pw) + { + default_uid = pw->pw_uid; + default_gid = pw->pw_gid; + } + + std::string uid_str = getEnv("CLICKHOUSE_UID"); + std::string gid_str = getEnv("CLICKHOUSE_GID"); + run_uid = default_uid; + run_gid = default_gid; + try + { + if (!uid_str.empty()) + run_uid = static_cast(std::stoul(uid_str)); + if (!gid_str.empty()) + run_gid = static_cast(std::stoul(gid_str)); + } + catch (const std::exception &) + { + std::cerr << "docker-init: warning: invalid CLICKHOUSE_UID/GID values, " + "using defaults\n"; + } + } + } + else + { + /// Non-root: cannot chown, run as current user. + run_uid = current_uid; + run_gid = getgid(); + do_chown = false; + } + + std::string run_as = std::to_string(run_uid) + ":" + std::to_string(run_gid); + + /// --- Keeper mode --- + if (keeper_mode) + { + std::string keeper_config = getEnv("KEEPER_CONFIG", "/etc/clickhouse-keeper/keeper_config.xml"); + std::string data_dir = getEnv("CLICKHOUSE_DATA_DIR", "/var/lib/clickhouse"); + std::string log_dir = getEnv("LOG_DIR", "/var/log/clickhouse-keeper"); + + for (const auto & dir : {data_dir, log_dir, + data_dir + "/coordination", + data_dir + "/coordination/log", + data_dir + "/coordination/snapshots"}) + { + if (!createDirectoryAndChown(dir, run_uid, run_gid, do_chown)) + return 1; + } + + /// Default to disabled so Ctrl+C works in Docker. Don't override if already set. + setenv("CLICKHOUSE_WATCHDOG_ENABLE", "0", 0); // NOLINT(concurrency-mt-unsafe) + + chdir(data_dir.c_str()); // NOLINT(bugprone-unused-return-value) + + std::vector exec_args = { + g_clickhouse_binary, "su", run_as, "clickhouse-keeper", + }; + + std::error_code ec; + if (!keeper_config.empty() && fs::exists(keeper_config, ec)) + exec_args.push_back("--config-file=" + keeper_config); + + for (const auto & arg : extra_args) + exec_args.push_back(arg); + + auto exec_argv = buildArgv(exec_args); + execvp(exec_argv[0], exec_argv.data()); + std::cerr << "docker-init: failed to exec clickhouse keeper: " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) + return 1; + } + + /// --- Server mode --- + std::string config_file = getEnv("CLICKHOUSE_CONFIG", "/etc/clickhouse-server/config.xml"); + + /// Extract all relevant paths from the config. + std::string data_dir = extractConfigValue(config_file, "path"); + std::string tmp_dir = extractConfigValue(config_file, "tmp_path"); + std::string user_files_path = extractConfigValue(config_file, "user_files_path"); + std::string format_schema_path = extractConfigValue(config_file, "format_schema_path"); + + std::string log_dir; + std::string log_path = extractConfigValue(config_file, "logger.log"); + if (!log_path.empty()) + log_dir = fs::path(log_path).parent_path().string(); + + std::string error_log_dir; + std::string error_log_path = extractConfigValue(config_file, "logger.errorlog"); + if (!error_log_path.empty()) + error_log_dir = fs::path(error_log_path).parent_path().string(); + + auto disk_paths = extractConfigValues(config_file, "storage_configuration.disks.*.path"); + auto disk_metadata_paths = extractConfigValues(config_file, "storage_configuration.disks.*.metadata_path"); + + /// Create and chown data directory first, then cd into it. + if (!data_dir.empty() && !createDirectoryAndChown(data_dir, run_uid, run_gid, do_chown)) + return 1; + + chdir(data_dir.empty() ? "/" : data_dir.c_str()); // NOLINT(bugprone-unused-return-value) + + for (const auto & dir : {error_log_dir, log_dir, tmp_dir, user_files_path, format_schema_path}) + { + if (!dir.empty() && !createDirectoryAndChown(dir, run_uid, run_gid, do_chown)) + return 1; + } + for (const auto & dir : disk_paths) + if (!createDirectoryAndChown(dir, run_uid, run_gid, do_chown)) + return 1; + for (const auto & dir : disk_metadata_paths) + if (!createDirectoryAndChown(dir, run_uid, run_gid, do_chown)) + return 1; + + /// Resolve password (from env or file). + std::string clickhouse_user = getEnv("CLICKHOUSE_USER", "default"); + std::string clickhouse_password = getEnv("CLICKHOUSE_PASSWORD"); + std::string password_file = getEnv("CLICKHOUSE_PASSWORD_FILE"); + if (!password_file.empty()) + { + std::ifstream pf(password_file); + if (pf.is_open()) + std::getline(pf, clickhouse_password); + else + std::cerr << "docker-init: warning: cannot read CLICKHOUSE_PASSWORD_FILE '" + << password_file << "': " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) + } + + std::string access_management = getEnv("CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT", "0"); + bool skip_user_setup = (getEnv("CLICKHOUSE_SKIP_USER_SETUP") == "1"); + + if (!manageClickHouseUser(config_file, clickhouse_user, clickhouse_password, access_management, skip_user_setup)) + return 1; + + /// Install signal handlers so `docker stop` during init triggers graceful shutdown. + /// As PID 1, signals without a handler are silently dropped by the kernel. + { + struct sigaction sa{}; + sa.sa_handler = shutdownHandler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + sigaction(SIGTERM, &sa, nullptr); + sigaction(SIGINT, &sa, nullptr); + } + + bool always_run_initdb = !getEnv("CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS").empty(); + if (!initClickHouseDB(config_file, data_dir, clickhouse_user, clickhouse_password, + run_uid, run_gid, extra_args, always_run_initdb)) + return 1; + + if (g_shutdown_requested) + { + std::cerr << "docker-init: shutdown requested during initialization, exiting\n"; + return 1; + } + + /// Reset signal handlers before exec — the server handles its own signals. + signal(SIGTERM, SIG_DFL); // NOLINT(cert-err33-c) + signal(SIGINT, SIG_DFL); // NOLINT(cert-err33-c) + + /// Set watchdog env — default to disabled so Ctrl+C works in Docker. + if (std::getenv("CLICKHOUSE_WATCHDOG_ENABLE") == nullptr) // NOLINT(concurrency-mt-unsafe) + setenv("CLICKHOUSE_WATCHDOG_ENABLE", "0", 0); // NOLINT(concurrency-mt-unsafe) + + /// Replace this process with clickhouse-server via `clickhouse su`. + std::vector exec_args = { + g_clickhouse_binary, "su", run_as, "clickhouse-server", + "--config-file=" + config_file, + }; + for (const auto & arg : extra_args) + exec_args.push_back(arg); + + auto exec_argv = buildArgv(exec_args); + execvp(exec_argv[0], exec_argv.data()); + std::cerr << "docker-init: failed to exec clickhouse server: " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) + return 1; +} diff --git a/programs/main.cpp b/programs/main.cpp index af2faccf6129..d59bfd04bb65 100644 --- a/programs/main.cpp +++ b/programs/main.cpp @@ -71,6 +71,7 @@ int mainEntryClickHouseChecksumForCompressedBlock(int, char **); int mainEntryClickHouseClient(int argc, char ** argv); int mainEntryClickHouseCompressor(int argc, char ** argv); int mainEntryClickHouseDisks(int argc, char ** argv); +int mainEntryClickHouseDockerInit(int argc, char ** argv); int mainEntryClickHouseExtractFromConfig(int argc, char ** argv); int mainEntryClickHouseFormat(int argc, char ** argv); int mainEntryClickHouseFstDumpTree(int argc, char ** argv); @@ -151,6 +152,7 @@ std::pair clickhouse_applications[] = {"su", mainEntryClickHouseSU}, {"hash-binary", mainEntryClickHouseHashBinary}, {"disks", mainEntryClickHouseDisks}, + {"docker-init", mainEntryClickHouseDockerInit}, {"check-marks", mainEntryClickHouseCheckMarks}, {"checksum-for-compressed-block", mainEntryClickHouseChecksumForCompressedBlock}, {"zookeeper-dump-tree", mainEntryClickHouseZooKeeperDumpTree}, From 2718997c534d8068e0516d172a5eaa20259c4b33 Mon Sep 17 00:00:00 2001 From: Rahul Nair <254529899+motsc@users.noreply.github.com> Date: Sun, 26 Apr 2026 21:41:07 -0700 Subject: [PATCH 49/70] Revert "Backport distroless Docker support to 26.3 (#103156)" (#103575) This reverts commit 48fc911f51d07a7e3aa29435df29289d6045c5c5. --- ci/jobs/docker_server.py | 41 +- ci/jobs/scripts/docker_server/config.sh | 7 +- .../clickhouse-distroless-initdb/initdb.sql | 3 - .../tests/clickhouse-distroless-initdb/run.sh | 46 - .../clickhouse-distroless-no-shell/run.sh | 17 - programs/CMakeLists.txt | 2 - programs/docker-init/CMakeLists.txt | 8 - programs/docker-init/docker-init.cpp | 1075 ----------------- programs/main.cpp | 2 - 9 files changed, 7 insertions(+), 1194 deletions(-) delete mode 100644 ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/initdb.sql delete mode 100755 ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/run.sh delete mode 100755 ci/jobs/scripts/docker_server/tests/clickhouse-distroless-no-shell/run.sh delete mode 100644 programs/docker-init/CMakeLists.txt delete mode 100644 programs/docker-init/docker-init.cpp diff --git a/ci/jobs/docker_server.py b/ci/jobs/docker_server.py index bf1cdd71f005..44216b549b5f 100644 --- a/ci/jobs/docker_server.py +++ b/ci/jobs/docker_server.py @@ -101,7 +101,7 @@ def parse_args() -> argparse.Namespace: ) parser.add_argument("--reports", default=True, help=argparse.SUPPRESS) parser.add_argument("--push", action="store_true", help=argparse.SUPPRESS) - parser.add_argument("--os", default=["ubuntu", "alpine", "distroless"], help=argparse.SUPPRESS) + parser.add_argument("--os", default=["ubuntu", "alpine"], help=argparse.SUPPRESS) parser.add_argument( "--no-ubuntu", action=DelOS, @@ -116,13 +116,6 @@ def parse_args() -> argparse.Namespace: default=argparse.SUPPRESS, help="don't build alpine image", ) - parser.add_argument( - "--no-distroless", - action=DelOS, - nargs=0, - default=argparse.SUPPRESS, - help="don't build distroless image", - ) parser.add_argument( "--allow-build-reuse", action="store_true", @@ -222,25 +215,10 @@ def build_and_push_image( cmd_args = list(init_args) urls = [] if direct_urls: - # distroless and ubuntu-server use an Ubuntu builder with dpkg, so they - # need .deb packages. alpine and ubuntu-keeper use .tgz packages. - uses_deb = os == "distroless" or ( - os == "ubuntu" and "clickhouse-server" in image.name - ) - if uses_deb: - urls = [ - url - for url in direct_urls[arch] - if ".deb" in url and "-dbg" not in url - ] + if os == "ubuntu" and "clickhouse-server" in image.name: + urls = [url for url in direct_urls[arch] if ".deb" in url] else: - # For keeper/alpine tgz builds, only pass the keeper tgz. - # Excluding clickhouse-common-static.tgz avoids a large unnecessary download. - tgz_urls = [url for url in direct_urls[arch] if ".tgz" in url] - if "keeper" in image.name: - urls = [url for url in tgz_urls if "clickhouse-keeper" in url] - else: - urls = tgz_urls + urls = [url for url in direct_urls[arch] if ".tgz" in url] cmd_args.extend( buildx_args( repo_urls, @@ -406,16 +384,7 @@ def main(): "clickhouse-common-static", ] elif "clickhouse-keeper" in image_repo: - # Both packages are needed to cover all three keeper image variants: - # distroless: installs from .deb via dpkg; clickhouse-common-static - # provides the clickhouse multi-tool binary (clickhouse-keeper - # is a symlink to it). clickhouse-keeper .deb is not published - # separately, so the common-static .deb is the only source. - # alpine/ubuntu: installs from .tgz; clickhouse-keeper provides the - # standalone keeper binary and its symlinks. The common-static - # .tgz is implicitly excluded because the url filter below - # keeps only urls containing "clickhouse-keeper" in the name. - PACKAGES = ["clickhouse-common-static", "clickhouse-keeper"] + PACKAGES = ["clickhouse-keeper"] else: assert False, "BUG" urls = read_build_urls(build_name) diff --git a/ci/jobs/scripts/docker_server/config.sh b/ci/jobs/scripts/docker_server/config.sh index 84882b1745df..1e69ca534b35 100644 --- a/ci/jobs/scripts/docker_server/config.sh +++ b/ci/jobs/scripts/docker_server/config.sh @@ -3,14 +3,11 @@ # Get current file directory currentDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" -# iterate over all directories in current path -clickhouseTests=$( find "$currentDir"/tests/ -maxdepth 1 -name 'clickhouse-*' -not -name 'clickhouse-distroless-*' -type d -exec basename {} \; ) -clickhouseDistrolessTests=$( find "$currentDir"/tests/ -maxdepth 1 -name 'clickhouse-distroless-*' -type d -exec basename {} \; ) +# interate over all directories in current path +clickhouseTests=$( find "$currentDir"/tests/ -maxdepth 1 -name 'clickhouse-*' -type d -exec basename {} \; ) keeperTests=$( find "$currentDir"/tests/ -maxdepth 1 -name 'keeper-*' -type d -exec basename {} \; ) imageTests+=( ['clickhouse/clickhouse-server']="${clickhouseTests}" - ['clickhouse/clickhouse-server:distroless']="${clickhouseTests} ${clickhouseDistrolessTests}" ['clickhouse/clickhouse-keeper']="${keeperTests}" - ['clickhouse/clickhouse-keeper:distroless']="${keeperTests}" ) diff --git a/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/initdb.sql b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/initdb.sql deleted file mode 100644 index 16304daf2aa6..000000000000 --- a/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/initdb.sql +++ /dev/null @@ -1,3 +0,0 @@ -CREATE DATABASE IF NOT EXISTS test_db; -CREATE TABLE IF NOT EXISTS test_db.test_table (id UInt32, value UInt32) ENGINE = MergeTree ORDER BY id; -INSERT INTO test_db.test_table VALUES (1, 100), (2, 200); diff --git a/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/run.sh b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/run.sh deleted file mode 100755 index 597818de6c21..000000000000 --- a/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/run.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# Verify that clickhouse docker-init executes SQL initdb scripts correctly. -# The distroless image has no shell so initdb scripts must be handled -# by the compiled docker-init entrypoint, not by entrypoint.sh. -set -eo pipefail - -dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" -source "$dir/../lib.sh" - -image="$1" - -export CLICKHOUSE_USER='init_test_user' -export CLICKHOUSE_PASSWORD='init_test_password' - -cid="$( - docker run -d \ - -e CLICKHOUSE_USER \ - -e CLICKHOUSE_PASSWORD \ - -v "$dir/initdb.sql":/docker-entrypoint-initdb.d/initdb.sql:ro \ - --name "$(cname)" \ - "$image" -)" -trap 'docker rm -vf $cid > /dev/null' EXIT - -chCli() { - docker run --rm -i \ - --link "$cid":clickhouse \ - -e CLICKHOUSE_USER \ - -e CLICKHOUSE_PASSWORD \ - "$image" \ - clickhouse-client \ - --host clickhouse \ - --user "$CLICKHOUSE_USER" \ - --password "$CLICKHOUSE_PASSWORD" \ - --query "$*" -} - -# shellcheck source=../../../../../tmp/docker-library/official-images/test/retry.sh -. "$TESTS_LIB_DIR/retry.sh" \ - --tries "$CLICKHOUSE_TEST_TRIES" \ - --sleep "$CLICKHOUSE_TEST_SLEEP" \ - chCli SELECT 1 - -# Verify the initdb script ran and created the table with the expected data -chCli SHOW TABLES IN test_db | grep '^test_table$' >/dev/null -[ "$(chCli 'SELECT SUM(value) FROM test_db.test_table')" = 300 ] diff --git a/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-no-shell/run.sh b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-no-shell/run.sh deleted file mode 100755 index c5319f120446..000000000000 --- a/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-no-shell/run.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# Verify the distroless production image contains no shell. -# This is the key property of a distroless image: /bin/sh, /bin/bash, -# and other shells must be absent to reduce the attack surface. -set -eo pipefail - -image="$1" - -if docker run --rm --entrypoint /bin/sh "$image" -c "echo bad" 2>/dev/null; then - echo "FAIL: /bin/sh should not exist in the distroless image" >&2 - exit 1 -fi - -if docker run --rm --entrypoint /bin/bash "$image" -c "echo bad" 2>/dev/null; then - echo "FAIL: /bin/bash should not exist in the distroless image" >&2 - exit 1 -fi diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index c44a71c1a85a..8dfd1b6fffc7 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -99,7 +99,6 @@ add_subdirectory (checksum-for-compressed-block) add_subdirectory (client) add_subdirectory (compressor) add_subdirectory (disks) -add_subdirectory (docker-init) add_subdirectory (extract-from-config) add_subdirectory (format) add_subdirectory (git-import) @@ -178,7 +177,6 @@ clickhouse_program_install(clickhouse-checksum-for-compressed-block checksum-for clickhouse_program_install(clickhouse-client client chc) clickhouse_program_install(clickhouse-compressor compressor) clickhouse_program_install(clickhouse-disks disks) -clickhouse_program_install(clickhouse-docker-init docker-init) clickhouse_program_install(clickhouse-extract-from-config extract-from-config) clickhouse_program_install(clickhouse-format format) clickhouse_program_install(clickhouse-git-import git-import) diff --git a/programs/docker-init/CMakeLists.txt b/programs/docker-init/CMakeLists.txt deleted file mode 100644 index 10ff94881396..000000000000 --- a/programs/docker-init/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set (CLICKHOUSE_DOCKER_INIT_SOURCES docker-init.cpp) - -set (CLICKHOUSE_DOCKER_INIT_LINK - PRIVATE - clickhouse_common_io -) - -clickhouse_program_add(docker-init) diff --git a/programs/docker-init/docker-init.cpp b/programs/docker-init/docker-init.cpp deleted file mode 100644 index 4f49cd43b2bc..000000000000 --- a/programs/docker-init/docker-init.cpp +++ /dev/null @@ -1,1075 +0,0 @@ -/// clickhouse docker-init — Docker entrypoint for distroless ClickHouse images. -/// Replaces entrypoint.sh in shell-free environments (no bash, no coreutils). -/// -/// Usage: -/// clickhouse docker-init [--keeper] [-- ...] -/// -/// Environment variables (same as entrypoint.sh): -/// CLICKHOUSE_CONFIG, CLICKHOUSE_RUN_AS_ROOT, CLICKHOUSE_DO_NOT_CHOWN, -/// CLICKHOUSE_UID, CLICKHOUSE_GID, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, -/// CLICKHOUSE_PASSWORD_FILE, CLICKHOUSE_DB, CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT, -/// CLICKHOUSE_SKIP_USER_SETUP, CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS, -/// CLICKHOUSE_INIT_TIMEOUT, CLICKHOUSE_WATCHDOG_ENABLE, KEEPER_CONFIG - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace fs = std::filesystem; - -namespace -{ - -/// Path to the clickhouse multi-tool binary, derived from argv[0]. -/// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) -std::string g_clickhouse_binary; - -/// Set by the SIGTERM/SIGINT handler during init to request graceful shutdown. -/// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) -volatile sig_atomic_t g_shutdown_requested = 0; - -/// PID of the temporary init server, so the signal handler can forward SIGTERM. -/// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) -volatile pid_t g_init_server_pid = 0; - -void shutdownHandler(int sig) -{ - g_shutdown_requested = 1; - - /// Forward the signal to the temporary server if one is running. - pid_t pid = g_init_server_pid; - if (pid > 0) - kill(pid, sig); -} - -/// Get an environment variable value, returning default_value if not set. -std::string getEnv(const char * name, const std::string & default_value = "") -{ - const char * val = std::getenv(name); // NOLINT(concurrency-mt-unsafe) - return val ? std::string(val) : default_value; -} - -/// Build an execvp-compatible argv array from a vector of strings. -std::vector buildArgv(const std::vector & args) -{ - std::vector argv; - argv.reserve(args.size() + 1); - for (const auto & a : args) - argv.push_back(const_cast(a.c_str())); // NOLINT(cppcoreguidelines-pro-type-const-cast) - argv.push_back(nullptr); - return argv; -} - -/// Run a command and wait for it. Returns the exit code (or -1 on error). -int runCommand(const std::vector & args) -{ - pid_t pid = fork(); - if (pid < 0) - return -1; - - if (pid == 0) - { - auto argv = buildArgv(args); - execvp(argv[0], argv.data()); - _exit(127); - } - - int status = 0; - while (waitpid(pid, &status, 0) < 0) - if (errno != EINTR) - return -1; - return WIFEXITED(status) ? WEXITSTATUS(status) : -1; -} - -/// Run a command, capture its stdout, return {exit_code, output_lines}. -std::pair> captureCommand(const std::vector & args) -{ - int pipefd[2]; - if (pipe(pipefd) < 0) - return {-1, {}}; - - pid_t pid = fork(); - if (pid < 0) - { - (void)close(pipefd[0]); - (void)close(pipefd[1]); - return {-1, {}}; - } - - if (pid == 0) - { - (void)close(pipefd[0]); - if (dup2(pipefd[1], STDOUT_FILENO) < 0) - _exit(127); - (void)close(pipefd[1]); - - /// Suppress stderr to avoid noise from --try extractions. - int devnull = open("/dev/null", O_WRONLY); - if (devnull >= 0) - { - (void)dup2(devnull, STDERR_FILENO); - (void)close(devnull); - } - - auto argv = buildArgv(args); - execvp(argv[0], argv.data()); - _exit(127); - } - - (void)close(pipefd[1]); - - std::string output; - char buf[4096]; - ssize_t n; - while ((n = read(pipefd[0], buf, sizeof(buf))) > 0) - output.append(buf, static_cast(n)); - (void)close(pipefd[0]); - - int status = 0; - while (waitpid(pid, &status, 0) < 0) - if (errno != EINTR) - return {-1, {}}; - - /// Split output into non-empty lines. - std::vector lines; - { - size_t pos = 0; - while (pos < output.size()) - { - size_t found = output.find('\n', pos); - if (found == std::string::npos) - found = output.size(); - std::string line = output.substr(pos, found - pos); - if (!line.empty() && line.back() == '\r') - line.pop_back(); - if (!line.empty()) - lines.push_back(std::move(line)); - pos = found + 1; - } - } - - return {WIFEXITED(status) ? WEXITSTATUS(status) : -1, std::move(lines)}; -} - -/// Run two commands connected by a pipe: lhs | rhs. -/// Returns the exit code of the rhs process. -int runPipeline(const std::vector & lhs, const std::vector & rhs) -{ - int pipefd[2]; - if (pipe(pipefd) < 0) - return -1; - - pid_t lhs_pid = fork(); - if (lhs_pid < 0) - { - (void)close(pipefd[0]); - (void)close(pipefd[1]); - return -1; - } - if (lhs_pid == 0) - { - (void)close(pipefd[0]); - (void)dup2(pipefd[1], STDOUT_FILENO); - (void)close(pipefd[1]); - auto argv = buildArgv(lhs); - execvp(argv[0], argv.data()); - _exit(127); - } - - pid_t rhs_pid = fork(); - if (rhs_pid < 0) - { - (void)close(pipefd[0]); - (void)close(pipefd[1]); - kill(lhs_pid, SIGTERM); - while (waitpid(lhs_pid, nullptr, 0) < 0 && errno == EINTR) {} - return -1; - } - if (rhs_pid == 0) - { - (void)close(pipefd[1]); - (void)dup2(pipefd[0], STDIN_FILENO); - (void)close(pipefd[0]); - auto argv = buildArgv(rhs); - execvp(argv[0], argv.data()); - _exit(127); - } - - (void)close(pipefd[0]); - (void)close(pipefd[1]); - - int lhs_status = 0; - int rhs_status = 0; - while (waitpid(lhs_pid, &lhs_status, 0) < 0 && errno == EINTR) {} - while (waitpid(rhs_pid, &rhs_status, 0) < 0 && errno == EINTR) {} - - return WIFEXITED(rhs_status) ? WEXITSTATUS(rhs_status) : -1; -} - -/// Returns true if the string is a safe ClickHouse identifier: -/// alphanumeric + underscore, not starting with a digit. -/// Used to validate CLICKHOUSE_USER and CLICKHOUSE_DB before embedding in SQL/XML. -bool isValidIdentifier(const std::string & s) -{ - if (s.empty()) - return false; - if (std::isdigit(static_cast(s[0]))) - return false; - for (unsigned char c : s) - if (!std::isalnum(c) && c != '_') - return false; - return true; -} - -/// Extract a single value from a ClickHouse config key via `clickhouse extract-from-config`. -/// Returns an empty string if the key is absent (--try flag suppresses errors). -std::string extractConfigValue(const std::string & config_file, const std::string & key, bool use_users = false) -{ - std::vector args = { - g_clickhouse_binary, "extract-from-config", - "--config-file", config_file, - "--key", key, - "--try", - }; - if (use_users) - args.emplace_back("--users"); - - auto [code, lines] = captureCommand(args); - return (code == 0 && !lines.empty()) ? lines[0] : std::string{}; -} - -/// Extract multiple values from a ClickHouse config key (wildcard patterns return multiple lines). -std::vector extractConfigValues(const std::string & config_file, const std::string & key) -{ - auto [code, lines] = captureCommand({ - g_clickhouse_binary, "extract-from-config", - "--config-file", config_file, - "--key", key, - "--try", - }); - return (code == 0) ? std::move(lines) : std::vector{}; -} - -/// Recursively chown a path. Logs warnings but does not abort on failure. -void recursiveChown(const std::string & path_str, uid_t uid, gid_t gid) -{ - if (lchown(path_str.c_str(), uid, gid) < 0) - std::cerr << "docker-init: warning: lchown " << path_str << ": " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) - - std::error_code ec; - if (!fs::is_directory(path_str, ec)) - return; - - for (const auto & entry : fs::recursive_directory_iterator(path_str, fs::directory_options::skip_permission_denied, ec)) - { - if (lchown(entry.path().c_str(), uid, gid) < 0) - std::cerr << "docker-init: warning: lchown " << entry.path() << ": " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) - } -} - -/// Create a directory (and all parents) and optionally chown it. -/// -/// Three cases: -/// 1. do_chown=true (root, normal mode): create with fs::create_directories, then chown. -/// 2. do_chown=false, running as root (CLICKHOUSE_DO_NOT_CHOWN=1): delegate to -/// `clickhouse su UID:GID` so the directory is created as the target user. -/// This handles NFS mounts where root is mapped to nobody. -/// 3. do_chown=false, running as non-root: create directly — we are already the target user. -bool createDirectoryAndChown(const std::string & dir, uid_t uid, gid_t gid, bool do_chown) -{ - if (dir.empty()) - return true; - - if (do_chown) - { - std::error_code ec; - fs::create_directories(dir, ec); - if (ec) - { - std::cerr << "docker-init: couldn't create directory " << dir << ": " << ec.message() << "\n"; - return false; - } - - /// Chown only if the owner needs to change (avoids slow recursive chown on already-correct dirs). - struct stat st{}; - if (stat(dir.c_str(), &st) == 0 && (st.st_uid != uid || st.st_gid != gid)) - recursiveChown(dir, uid, gid); - - return true; - } - - if (getuid() == 0) - { - /// Running as root with CLICKHOUSE_DO_NOT_CHOWN or CLICKHOUSE_RUN_AS_ROOT. - /// On NFS mounts root may be remapped to nobody, so create the directory as - /// the target user. Fork a child that drops privileges before calling - /// fs::create_directories — distroless has no mkdir binary. - pid_t pid = fork(); - if (pid < 0) - { - std::cerr << "docker-init: fork failed for directory creation: " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) - return false; - } - if (pid == 0) - { - if (setgroups(0, nullptr) < 0 || setgid(gid) < 0 || setuid(uid) < 0) - _exit(1); - std::error_code ec; - fs::create_directories(dir, ec); - _exit(ec ? 1 : 0); - } - int status = 0; - while (waitpid(pid, &status, 0) < 0 && errno == EINTR) {} - if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) - { - /// Fallback: try direct creation (works when root is not remapped). - std::error_code ec; - fs::create_directories(dir, ec); - if (ec) - { - std::cerr << "docker-init: couldn't create directory " << dir << ": " << ec.message() << "\n"; - return false; - } - } - return true; - } - - /// Non-root: we are already running as UID:GID, so create the directory directly. - std::error_code ec; - fs::create_directories(dir, ec); - if (ec) - { - std::cerr << "docker-init: couldn't create directory " << dir << ": " << ec.message() << "\n"; - return false; - } - return true; -} - -/// Write the user management XML to `/etc/clickhouse-server/users.d/default-user.xml`. -/// Returns false if a user-requested setup (CLICKHOUSE_USER/PASSWORD/ACCESS_MANAGEMENT) -/// is invalid — caller should treat this as fatal. -bool manageClickHouseUser( - const std::string & config_file, - const std::string & clickhouse_user, - const std::string & clickhouse_password, - const std::string & access_management, - bool skip_user_setup) -{ - if (skip_user_setup) - { - std::cerr << "docker-init: explicitly skip changing user 'default'\n"; - return true; - } - - const std::string users_d_dir = "/etc/clickhouse-server/users.d"; - const std::string default_user_xml = users_d_dir + "/default-user.xml"; - - std::error_code ec; - fs::create_directories(users_d_dir, ec); - - /// Detect whether the default user was customised via a mounted config file. - bool clickhouse_default_changed = false; - std::string users_xml_path = extractConfigValue(config_file, "user_directories.users_xml.path"); - if (!users_xml_path.empty()) - { - std::string abs_users_xml = (users_xml_path[0] == '/') - ? users_xml_path - : (fs::path(config_file).parent_path() / users_xml_path).string(); - - auto join = [](const std::vector & v) - { - std::string s; - for (const auto & line : v) - s += line + "\n"; - return s; - }; - - auto [c1, original] = captureCommand({ - g_clickhouse_binary, "extract-from-config", - "--config-file", abs_users_xml, - "--key", "users.default", "--try", - }); - auto [c2, processed] = captureCommand({ - g_clickhouse_binary, "extract-from-config", - "--config-file", config_file, - "--users", "--key", "users.default", "--try", - }); - - if (c1 == 0 && c2 == 0 && join(original) != join(processed)) - clickhouse_default_changed = true; - } - - bool has_custom_user = !clickhouse_user.empty() && clickhouse_user != "default"; - bool has_password = !clickhouse_password.empty(); - bool has_access_mgmt = access_management != "0"; - - if (has_custom_user || has_password || has_access_mgmt) - { - if (access_management != "0" && access_management != "1") - { - std::cerr << "docker-init: error: CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT must be '0' or '1', got '" - << access_management << "'\n"; - return false; - } - - if (!isValidIdentifier(clickhouse_user)) - { - std::cerr << "docker-init: error: CLICKHOUSE_USER '" << clickhouse_user - << "' contains characters not allowed in an XML element name; " - "use only alphanumeric characters and underscores\n"; - return false; - } - - std::cerr << "docker-init: create new user '" << clickhouse_user << "' instead 'default'\n"; - - /// Escape CDATA end marker: ]]> → ]]]]> - std::string escaped_password; - { - std::string_view src = clickhouse_password; - const std::string_view needle = "]]>"; - const std::string_view replacement = "]]]]>"; - size_t pos = 0; - size_t found; - while ((found = src.find(needle, pos)) != std::string_view::npos) - { - escaped_password.append(src, pos, found - pos); - escaped_password += replacement; - pos = found + needle.size(); - } - escaped_password.append(src, pos, src.size() - pos); - } - - { - std::ofstream f(default_user_xml); - f << "\n" - << " \n" - << " \n" - << " \n" - << " \n" - << " \n" - << "\n" - << " <" << clickhouse_user << ">\n" - << " default\n" - << " \n" - << " ::/0\n" - << " \n" - << " \n" - << " default\n" - << " " << access_management << "\n" - << " \n" - << " \n" - << "\n"; - if (!f.good()) - std::cerr << "docker-init: error: failed to write " << default_user_xml << "\n"; - } - } - else if (clickhouse_default_changed) - { - /// A mounted config already customised the user — leave it as-is. - } - else - { - std::cerr << "docker-init: neither CLICKHOUSE_USER nor CLICKHOUSE_PASSWORD is set, " - "disabling network access for user 'default'\n"; - { - std::ofstream f(default_user_xml); - f << "\n" - << " \n" - << " \n" - << " \n" - << " \n" - << " \n" - << " ::1\n" - << " 127.0.0.1\n" - << " \n" - << " \n" - << " \n" - << "\n"; - if (!f.good()) - std::cerr << "docker-init: error: failed to write " << default_user_xml << "\n"; - } - } - return true; -} - -/// Returns false on first error (fail-fast, matches shell `set -e`). -bool createClickHouseDatabase( - const std::vector & client_base, - const std::string & clickhouse_db) -{ - if (clickhouse_db.empty()) - return true; - if (!isValidIdentifier(clickhouse_db)) - { - std::cerr << "docker-init: error: CLICKHOUSE_DB '" << clickhouse_db - << "' contains characters not safe for use in SQL; " - "use only alphanumeric characters and underscores\n"; - return false; - } - std::cerr << "docker-init: create database '" << clickhouse_db << "'\n"; - std::vector args = client_base; - args.insert(args.end(), {"-q", "CREATE DATABASE IF NOT EXISTS " + clickhouse_db}); - if (runCommand(args) != 0) - { - std::cerr << "docker-init: error: failed to create database '" << clickhouse_db << "'\n"; - return false; - } - return true; -} - -/// Returns false on first script failure (fail-fast, matches shell `set -e`). -bool runInitScripts(const std::vector & client_base) -{ - std::error_code ec; - if (!fs::is_directory("/docker-entrypoint-initdb.d", ec)) - return true; - std::vector init_files; - for (const auto & entry : fs::directory_iterator("/docker-entrypoint-initdb.d", ec)) - init_files.push_back(entry.path()); - std::sort(init_files.begin(), init_files.end()); - - for (const auto & path : init_files) - { - std::string filename = path.filename().string(); - - if (filename.ends_with(".sql") && !filename.ends_with(".sql.gz")) - { - std::cerr << "docker-init: running " << path << "\n"; - std::vector args = client_base; - args.emplace_back("--queries-file"); - args.push_back(path.string()); - if (runCommand(args) != 0) - { - std::cerr << "docker-init: error: init script " << path << " failed\n"; - return false; - } - } - else if (filename.ends_with(".sql.gz")) - { - std::cerr << "docker-init: running " << path << " (decompressing)\n"; - /// Decompress via clickhouse-local (auto-detects .gz) and pipe to clickhouse-client. - /// Escape single quotes in the path to prevent SQL injection via crafted filenames. - std::string escaped_path; - for (char c : path.string()) - { - if (c == '\'') - escaped_path += "''"; - else - escaped_path += c; - } - std::vector decompress_args = { - g_clickhouse_binary, "local", - "--query", - "SELECT * FROM file('" + escaped_path + "', RawBLOB) FORMAT RawBLOB", - }; - if (runPipeline(decompress_args, client_base) != 0) - { - std::cerr << "docker-init: error: init script " << path << " failed\n"; - return false; - } - } - else if (filename.ends_with(".sh")) - { - std::cerr << "docker-init: WARNING: shell scripts cannot run in a distroless " - "environment, skipping " << path << "\n"; - } - else - { - std::cerr << "docker-init: ignoring " << path << "\n"; - } - } - return true; -} - -/// Start a temporary ClickHouse server, run init scripts, then stop it. -bool initClickHouseDB( - const std::string & config_file, - const std::string & data_dir, - const std::string & clickhouse_user, - const std::string & clickhouse_password, - uid_t run_uid, - gid_t run_gid, - const std::vector & extra_server_args, - bool always_run_initdb) -{ - /// Skip if data directory is already initialised and CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS is unset. - bool database_exists = fs::is_directory(data_dir + "/data"); - if (!always_run_initdb && database_exists) - { - std::cerr << "docker-init: ClickHouse data directory appears to contain a database; " - "skipping initialization\n"; - return true; - } - - std::string clickhouse_db = getEnv("CLICKHOUSE_DB"); - - /// Check whether /docker-entrypoint-initdb.d has any files. - std::error_code ec; - bool has_init_files = fs::is_directory("/docker-entrypoint-initdb.d", ec) - && fs::directory_iterator("/docker-entrypoint-initdb.d", ec) != fs::directory_iterator{}; - - if (!has_init_files && clickhouse_db.empty()) - return true; - - std::string native_port = extractConfigValue(config_file, "tcp_port"); - if (native_port.empty()) - native_port = "9000"; - - std::string run_as = std::to_string(run_uid) + ":" + std::to_string(run_gid); - - /// Start a temporary server bound only to localhost. - /// The "--" separator is required: positional arguments after "--" override config.xml - /// properties (e.g. --listen_host=127.0.0.1), while options before "--" are parsed by - /// Poco and must be registered. Without "--", Poco rejects "--listen_host" as unknown. - std::vector server_args = { - g_clickhouse_binary, "su", run_as, "clickhouse-server", - "--config-file=" + config_file, - "--", "--listen_host=127.0.0.1", - }; - for (const auto & arg : extra_server_args) - server_args.push_back(arg); - - if (g_shutdown_requested) - return true; - - pid_t server_pid = fork(); - if (server_pid < 0) - { - std::cerr << "docker-init: failed to fork temporary server\n"; - return false; - } - - if (server_pid == 0) - { - auto argv = buildArgv(server_args); - execvp(argv[0], argv.data()); - _exit(127); - } - - /// Allow the signal handler to forward SIGTERM to the temp server. - g_init_server_pid = server_pid; - - /// Poll until the server accepts connections. - /// This is a service-readiness wait, not a race condition workaround. - int tries = 1000; - { - std::string timeout_str = getEnv("CLICKHOUSE_INIT_TIMEOUT", "1000"); - try - { - tries = std::stoi(timeout_str); - } - catch (const std::exception &) - { - std::cerr << "docker-init: warning: invalid CLICKHOUSE_INIT_TIMEOUT '" - << timeout_str << "', using default 1000\n"; - } - } - bool server_ready = false; - - while (tries > 0 && !server_ready && !g_shutdown_requested) - { - pid_t check_pid = fork(); - if (check_pid < 0) - { - /// fork failed — skip this iteration and retry. - --tries; - sleep(1); // NOLINT(concurrency-mt-unsafe) - continue; - } - if (check_pid == 0) - { - int devnull = open("/dev/null", O_WRONLY); - if (devnull >= 0) - { - dup2(devnull, STDOUT_FILENO); - dup2(devnull, STDERR_FILENO); - close(devnull); - } - /// Keep args in a named variable so the strings outlive argv. - std::vector check_args = { - g_clickhouse_binary, "client", - "--host", "127.0.0.1", - "--port", native_port, - "-u", clickhouse_user, - "--password", clickhouse_password, - "--query", "SELECT 1", - }; - auto argv = buildArgv(check_args); - execvp(argv[0], argv.data()); - _exit(127); - } - - int check_status = 0; - while (waitpid(check_pid, &check_status, 0) < 0 && errno == EINTR) {} - if (WIFEXITED(check_status) && WEXITSTATUS(check_status) == 0) - { - server_ready = true; - } - else - { - --tries; - sleep(1); // NOLINT(concurrency-mt-unsafe) -- Wait between health-check retries — not a race condition fix. - } - } - - if (!server_ready) - { - if (g_shutdown_requested) - std::cerr << "docker-init: shutdown requested, stopping init server\n"; - else - std::cerr << "docker-init: ClickHouse init process timed out\n"; - kill(server_pid, SIGTERM); - while (waitpid(server_pid, nullptr, 0) < 0 && errno == EINTR) {} - g_init_server_pid = 0; - return false; - } - - std::vector client_base = { - g_clickhouse_binary, "client", - "--multiquery", - "--host", "127.0.0.1", - "--port", native_port, - "-u", clickhouse_user, - "--password", clickhouse_password, - }; - - const bool ok = createClickHouseDatabase(client_base, clickhouse_db) - && runInitScripts(client_base); - - /// Always stop the temporary server regardless of init result. - kill(server_pid, SIGTERM); - int server_status = 0; - while (waitpid(server_pid, &server_status, 0) < 0 && errno == EINTR) {} - g_init_server_pid = 0; - if (!WIFEXITED(server_status) || WEXITSTATUS(server_status) != 0) - std::cerr << "docker-init: warning: init server did not exit cleanly\n"; - return ok; -} - -} // anonymous namespace - - -int mainEntryClickHouseDockerInit(int argc, char ** argv) -{ - g_clickhouse_binary = (argc > 0 && argv[0][0] != '\0') ? argv[0] : "clickhouse"; - - bool keeper_mode = false; - bool show_help = false; - bool separator_seen = false; - std::vector extra_args; - - for (int i = 1; i < argc; ++i) - { - std::string_view arg = argv[i]; - - if (!separator_seen && (arg == "--help" || arg == "-h")) - { - show_help = true; - break; - } - else if (!separator_seen && arg == "--keeper") - keeper_mode = true; - else if (!separator_seen && arg == "--") - separator_seen = true; - else - extra_args.emplace_back(arg); - } - - if (show_help) - { - std::cout - << "Usage: clickhouse docker-init [--keeper] [-- ...]\n" - "Docker entrypoint for distroless ClickHouse images.\n" - "\nOptions:\n" - " --keeper Start ClickHouse Keeper instead of server\n" - " --help Show this help message\n" - "\nEnvironment variables (server mode):\n" - " CLICKHOUSE_CONFIG Path to config file " - "(default: /etc/clickhouse-server/config.xml)\n" - " CLICKHOUSE_RUN_AS_ROOT Run as root (0/1)\n" - " CLICKHOUSE_DO_NOT_CHOWN Skip chown operations (0/1)\n" - " CLICKHOUSE_UID Override UID to run as\n" - " CLICKHOUSE_GID Override GID to run as\n" - " CLICKHOUSE_USER Default user name (default: default)\n" - " CLICKHOUSE_PASSWORD Default user password\n" - " CLICKHOUSE_PASSWORD_FILE File containing password\n" - " CLICKHOUSE_DB Database to create on init\n" - " CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT Enable access management (0/1)\n" - " CLICKHOUSE_SKIP_USER_SETUP Skip user setup (0/1)\n" - " CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS Always run init scripts\n" - " CLICKHOUSE_INIT_TIMEOUT Max retries for server readiness (default: 1000)\n" - " CLICKHOUSE_WATCHDOG_ENABLE Enable watchdog (default: 0)\n" - "\nEnvironment variables (keeper mode):\n" - " KEEPER_CONFIG Path to keeper config file\n" - " CLICKHOUSE_DATA_DIR Data directory (default: /var/lib/clickhouse)\n" - " LOG_DIR Log directory (default: /var/log/clickhouse-keeper)\n"; - return 0; - } - - /// --- Passthrough mode --- - /// If the first extra argument does not start with '--', treat it as a command to exec - /// directly without server startup. This mirrors entrypoint.sh: - /// if [[ "$1" == "--"* ]]; then start server; fi; exec "$@" - /// - /// For recognized ClickHouse subcommand names (client, local, etc.) resolve the path - /// via bin_dir so that multi-tool dispatch (by argv[0] basename) works correctly. - /// For everything else (echo, date, bash, ...) let PATH resolution handle it. - if (!extra_args.empty() && !extra_args[0].starts_with("--")) - { - static constexpr std::array clickhouse_tools = { - "clickhouse-client", - "clickhouse-local", - "clickhouse-keeper-client", - "clickhouse-benchmark", - "clickhouse-format", - "clickhouse-compressor", - "clickhouse-obfuscator", - "clickhouse-extract-from-config", - "clickhouse-disks", - "client", - "local", - "keeper-client", - "benchmark", - "format", - "compressor", - "obfuscator", - "extract-from-config", - "disks", - }; - - std::string cmd = extra_args[0]; - if (std::find(clickhouse_tools.begin(), clickhouse_tools.end(), extra_args[0]) != clickhouse_tools.end()) - { - /// Build the full path to the symlink (e.g. /usr/bin/clickhouse-client). - /// The symlink points to the clickhouse binary; dispatching is done by argv[0]. - /// Short names like "client" must be resolved to "clickhouse-client" since the - /// distroless image only has "clickhouse-*" symlinks (not bare "client", "local", etc.). - fs::path bin_dir = fs::path(g_clickhouse_binary).parent_path(); - std::string link_name = extra_args[0]; - if (!link_name.starts_with("clickhouse-")) - link_name = "clickhouse-" + link_name; - cmd = (bin_dir / link_name).string(); - } - - std::vector exec_cmd = {cmd}; - for (std::size_t i = 1; i < extra_args.size(); ++i) - exec_cmd.push_back(extra_args[i]); - - auto exec_argv = buildArgv(exec_cmd); - execvp(exec_argv[0], exec_argv.data()); - std::cerr << "docker-init: failed to exec '" << extra_args[0] << "': " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) - return 1; - } - - /// --- Resolve identity --- - uid_t current_uid = getuid(); - uid_t run_uid; - gid_t run_gid; - bool do_chown = true; - - if (getEnv("CLICKHOUSE_RUN_AS_ROOT") == "1" || getEnv("CLICKHOUSE_DO_NOT_CHOWN") == "1") - do_chown = false; - - if (current_uid == 0) - { - if (getEnv("CLICKHOUSE_RUN_AS_ROOT") == "1") - { - run_uid = 0; - run_gid = 0; - } - else - { - /// Default to the `clickhouse` system user if it exists, otherwise fall back to UID 101. - uid_t default_uid = 101; - gid_t default_gid = 101; - const passwd * pw = getpwnam("clickhouse"); // NOLINT(concurrency-mt-unsafe) - if (pw) - { - default_uid = pw->pw_uid; - default_gid = pw->pw_gid; - } - - std::string uid_str = getEnv("CLICKHOUSE_UID"); - std::string gid_str = getEnv("CLICKHOUSE_GID"); - run_uid = default_uid; - run_gid = default_gid; - try - { - if (!uid_str.empty()) - run_uid = static_cast(std::stoul(uid_str)); - if (!gid_str.empty()) - run_gid = static_cast(std::stoul(gid_str)); - } - catch (const std::exception &) - { - std::cerr << "docker-init: warning: invalid CLICKHOUSE_UID/GID values, " - "using defaults\n"; - } - } - } - else - { - /// Non-root: cannot chown, run as current user. - run_uid = current_uid; - run_gid = getgid(); - do_chown = false; - } - - std::string run_as = std::to_string(run_uid) + ":" + std::to_string(run_gid); - - /// --- Keeper mode --- - if (keeper_mode) - { - std::string keeper_config = getEnv("KEEPER_CONFIG", "/etc/clickhouse-keeper/keeper_config.xml"); - std::string data_dir = getEnv("CLICKHOUSE_DATA_DIR", "/var/lib/clickhouse"); - std::string log_dir = getEnv("LOG_DIR", "/var/log/clickhouse-keeper"); - - for (const auto & dir : {data_dir, log_dir, - data_dir + "/coordination", - data_dir + "/coordination/log", - data_dir + "/coordination/snapshots"}) - { - if (!createDirectoryAndChown(dir, run_uid, run_gid, do_chown)) - return 1; - } - - /// Default to disabled so Ctrl+C works in Docker. Don't override if already set. - setenv("CLICKHOUSE_WATCHDOG_ENABLE", "0", 0); // NOLINT(concurrency-mt-unsafe) - - chdir(data_dir.c_str()); // NOLINT(bugprone-unused-return-value) - - std::vector exec_args = { - g_clickhouse_binary, "su", run_as, "clickhouse-keeper", - }; - - std::error_code ec; - if (!keeper_config.empty() && fs::exists(keeper_config, ec)) - exec_args.push_back("--config-file=" + keeper_config); - - for (const auto & arg : extra_args) - exec_args.push_back(arg); - - auto exec_argv = buildArgv(exec_args); - execvp(exec_argv[0], exec_argv.data()); - std::cerr << "docker-init: failed to exec clickhouse keeper: " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) - return 1; - } - - /// --- Server mode --- - std::string config_file = getEnv("CLICKHOUSE_CONFIG", "/etc/clickhouse-server/config.xml"); - - /// Extract all relevant paths from the config. - std::string data_dir = extractConfigValue(config_file, "path"); - std::string tmp_dir = extractConfigValue(config_file, "tmp_path"); - std::string user_files_path = extractConfigValue(config_file, "user_files_path"); - std::string format_schema_path = extractConfigValue(config_file, "format_schema_path"); - - std::string log_dir; - std::string log_path = extractConfigValue(config_file, "logger.log"); - if (!log_path.empty()) - log_dir = fs::path(log_path).parent_path().string(); - - std::string error_log_dir; - std::string error_log_path = extractConfigValue(config_file, "logger.errorlog"); - if (!error_log_path.empty()) - error_log_dir = fs::path(error_log_path).parent_path().string(); - - auto disk_paths = extractConfigValues(config_file, "storage_configuration.disks.*.path"); - auto disk_metadata_paths = extractConfigValues(config_file, "storage_configuration.disks.*.metadata_path"); - - /// Create and chown data directory first, then cd into it. - if (!data_dir.empty() && !createDirectoryAndChown(data_dir, run_uid, run_gid, do_chown)) - return 1; - - chdir(data_dir.empty() ? "/" : data_dir.c_str()); // NOLINT(bugprone-unused-return-value) - - for (const auto & dir : {error_log_dir, log_dir, tmp_dir, user_files_path, format_schema_path}) - { - if (!dir.empty() && !createDirectoryAndChown(dir, run_uid, run_gid, do_chown)) - return 1; - } - for (const auto & dir : disk_paths) - if (!createDirectoryAndChown(dir, run_uid, run_gid, do_chown)) - return 1; - for (const auto & dir : disk_metadata_paths) - if (!createDirectoryAndChown(dir, run_uid, run_gid, do_chown)) - return 1; - - /// Resolve password (from env or file). - std::string clickhouse_user = getEnv("CLICKHOUSE_USER", "default"); - std::string clickhouse_password = getEnv("CLICKHOUSE_PASSWORD"); - std::string password_file = getEnv("CLICKHOUSE_PASSWORD_FILE"); - if (!password_file.empty()) - { - std::ifstream pf(password_file); - if (pf.is_open()) - std::getline(pf, clickhouse_password); - else - std::cerr << "docker-init: warning: cannot read CLICKHOUSE_PASSWORD_FILE '" - << password_file << "': " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) - } - - std::string access_management = getEnv("CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT", "0"); - bool skip_user_setup = (getEnv("CLICKHOUSE_SKIP_USER_SETUP") == "1"); - - if (!manageClickHouseUser(config_file, clickhouse_user, clickhouse_password, access_management, skip_user_setup)) - return 1; - - /// Install signal handlers so `docker stop` during init triggers graceful shutdown. - /// As PID 1, signals without a handler are silently dropped by the kernel. - { - struct sigaction sa{}; - sa.sa_handler = shutdownHandler; - sigemptyset(&sa.sa_mask); - sa.sa_flags = SA_RESTART; - sigaction(SIGTERM, &sa, nullptr); - sigaction(SIGINT, &sa, nullptr); - } - - bool always_run_initdb = !getEnv("CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS").empty(); - if (!initClickHouseDB(config_file, data_dir, clickhouse_user, clickhouse_password, - run_uid, run_gid, extra_args, always_run_initdb)) - return 1; - - if (g_shutdown_requested) - { - std::cerr << "docker-init: shutdown requested during initialization, exiting\n"; - return 1; - } - - /// Reset signal handlers before exec — the server handles its own signals. - signal(SIGTERM, SIG_DFL); // NOLINT(cert-err33-c) - signal(SIGINT, SIG_DFL); // NOLINT(cert-err33-c) - - /// Set watchdog env — default to disabled so Ctrl+C works in Docker. - if (std::getenv("CLICKHOUSE_WATCHDOG_ENABLE") == nullptr) // NOLINT(concurrency-mt-unsafe) - setenv("CLICKHOUSE_WATCHDOG_ENABLE", "0", 0); // NOLINT(concurrency-mt-unsafe) - - /// Replace this process with clickhouse-server via `clickhouse su`. - std::vector exec_args = { - g_clickhouse_binary, "su", run_as, "clickhouse-server", - "--config-file=" + config_file, - }; - for (const auto & arg : extra_args) - exec_args.push_back(arg); - - auto exec_argv = buildArgv(exec_args); - execvp(exec_argv[0], exec_argv.data()); - std::cerr << "docker-init: failed to exec clickhouse server: " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) - return 1; -} diff --git a/programs/main.cpp b/programs/main.cpp index d59bfd04bb65..af2faccf6129 100644 --- a/programs/main.cpp +++ b/programs/main.cpp @@ -71,7 +71,6 @@ int mainEntryClickHouseChecksumForCompressedBlock(int, char **); int mainEntryClickHouseClient(int argc, char ** argv); int mainEntryClickHouseCompressor(int argc, char ** argv); int mainEntryClickHouseDisks(int argc, char ** argv); -int mainEntryClickHouseDockerInit(int argc, char ** argv); int mainEntryClickHouseExtractFromConfig(int argc, char ** argv); int mainEntryClickHouseFormat(int argc, char ** argv); int mainEntryClickHouseFstDumpTree(int argc, char ** argv); @@ -152,7 +151,6 @@ std::pair clickhouse_applications[] = {"su", mainEntryClickHouseSU}, {"hash-binary", mainEntryClickHouseHashBinary}, {"disks", mainEntryClickHouseDisks}, - {"docker-init", mainEntryClickHouseDockerInit}, {"check-marks", mainEntryClickHouseCheckMarks}, {"checksum-for-compressed-block", mainEntryClickHouseChecksumForCompressedBlock}, {"zookeeper-dump-tree", mainEntryClickHouseZooKeeperDumpTree}, From fbba00d1cea6cc47ab2d8c6154b0f06f5be1da5a Mon Sep 17 00:00:00 2001 From: Rahul Nair <254529899+motsc@users.noreply.github.com> Date: Mon, 27 Apr 2026 01:31:34 -0700 Subject: [PATCH 50/70] Backport docker-init binary to 26.3 (#103577) Add the `docker-init` subcommand to the clickhouse multi-tool binary. This is the compiled entrypoint for distroless Docker images (no shell, no coreutils). Without it, distroless images crash on startup since the Dockerfile uses `clickhouse docker-init` as the entrypoint. Cherry-pick of programs/ changes from b7a8f051c8f1 (master). --- programs/CMakeLists.txt | 2 + programs/docker-init/CMakeLists.txt | 8 + programs/docker-init/docker-init.cpp | 1075 ++++++++++++++++++++++++++ programs/main.cpp | 2 + 4 files changed, 1087 insertions(+) create mode 100644 programs/docker-init/CMakeLists.txt create mode 100644 programs/docker-init/docker-init.cpp diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index 8dfd1b6fffc7..c44a71c1a85a 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -99,6 +99,7 @@ add_subdirectory (checksum-for-compressed-block) add_subdirectory (client) add_subdirectory (compressor) add_subdirectory (disks) +add_subdirectory (docker-init) add_subdirectory (extract-from-config) add_subdirectory (format) add_subdirectory (git-import) @@ -177,6 +178,7 @@ clickhouse_program_install(clickhouse-checksum-for-compressed-block checksum-for clickhouse_program_install(clickhouse-client client chc) clickhouse_program_install(clickhouse-compressor compressor) clickhouse_program_install(clickhouse-disks disks) +clickhouse_program_install(clickhouse-docker-init docker-init) clickhouse_program_install(clickhouse-extract-from-config extract-from-config) clickhouse_program_install(clickhouse-format format) clickhouse_program_install(clickhouse-git-import git-import) diff --git a/programs/docker-init/CMakeLists.txt b/programs/docker-init/CMakeLists.txt new file mode 100644 index 000000000000..10ff94881396 --- /dev/null +++ b/programs/docker-init/CMakeLists.txt @@ -0,0 +1,8 @@ +set (CLICKHOUSE_DOCKER_INIT_SOURCES docker-init.cpp) + +set (CLICKHOUSE_DOCKER_INIT_LINK + PRIVATE + clickhouse_common_io +) + +clickhouse_program_add(docker-init) diff --git a/programs/docker-init/docker-init.cpp b/programs/docker-init/docker-init.cpp new file mode 100644 index 000000000000..4f49cd43b2bc --- /dev/null +++ b/programs/docker-init/docker-init.cpp @@ -0,0 +1,1075 @@ +/// clickhouse docker-init — Docker entrypoint for distroless ClickHouse images. +/// Replaces entrypoint.sh in shell-free environments (no bash, no coreutils). +/// +/// Usage: +/// clickhouse docker-init [--keeper] [-- ...] +/// +/// Environment variables (same as entrypoint.sh): +/// CLICKHOUSE_CONFIG, CLICKHOUSE_RUN_AS_ROOT, CLICKHOUSE_DO_NOT_CHOWN, +/// CLICKHOUSE_UID, CLICKHOUSE_GID, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, +/// CLICKHOUSE_PASSWORD_FILE, CLICKHOUSE_DB, CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT, +/// CLICKHOUSE_SKIP_USER_SETUP, CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS, +/// CLICKHOUSE_INIT_TIMEOUT, CLICKHOUSE_WATCHDOG_ENABLE, KEEPER_CONFIG + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace fs = std::filesystem; + +namespace +{ + +/// Path to the clickhouse multi-tool binary, derived from argv[0]. +/// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +std::string g_clickhouse_binary; + +/// Set by the SIGTERM/SIGINT handler during init to request graceful shutdown. +/// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +volatile sig_atomic_t g_shutdown_requested = 0; + +/// PID of the temporary init server, so the signal handler can forward SIGTERM. +/// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +volatile pid_t g_init_server_pid = 0; + +void shutdownHandler(int sig) +{ + g_shutdown_requested = 1; + + /// Forward the signal to the temporary server if one is running. + pid_t pid = g_init_server_pid; + if (pid > 0) + kill(pid, sig); +} + +/// Get an environment variable value, returning default_value if not set. +std::string getEnv(const char * name, const std::string & default_value = "") +{ + const char * val = std::getenv(name); // NOLINT(concurrency-mt-unsafe) + return val ? std::string(val) : default_value; +} + +/// Build an execvp-compatible argv array from a vector of strings. +std::vector buildArgv(const std::vector & args) +{ + std::vector argv; + argv.reserve(args.size() + 1); + for (const auto & a : args) + argv.push_back(const_cast(a.c_str())); // NOLINT(cppcoreguidelines-pro-type-const-cast) + argv.push_back(nullptr); + return argv; +} + +/// Run a command and wait for it. Returns the exit code (or -1 on error). +int runCommand(const std::vector & args) +{ + pid_t pid = fork(); + if (pid < 0) + return -1; + + if (pid == 0) + { + auto argv = buildArgv(args); + execvp(argv[0], argv.data()); + _exit(127); + } + + int status = 0; + while (waitpid(pid, &status, 0) < 0) + if (errno != EINTR) + return -1; + return WIFEXITED(status) ? WEXITSTATUS(status) : -1; +} + +/// Run a command, capture its stdout, return {exit_code, output_lines}. +std::pair> captureCommand(const std::vector & args) +{ + int pipefd[2]; + if (pipe(pipefd) < 0) + return {-1, {}}; + + pid_t pid = fork(); + if (pid < 0) + { + (void)close(pipefd[0]); + (void)close(pipefd[1]); + return {-1, {}}; + } + + if (pid == 0) + { + (void)close(pipefd[0]); + if (dup2(pipefd[1], STDOUT_FILENO) < 0) + _exit(127); + (void)close(pipefd[1]); + + /// Suppress stderr to avoid noise from --try extractions. + int devnull = open("/dev/null", O_WRONLY); + if (devnull >= 0) + { + (void)dup2(devnull, STDERR_FILENO); + (void)close(devnull); + } + + auto argv = buildArgv(args); + execvp(argv[0], argv.data()); + _exit(127); + } + + (void)close(pipefd[1]); + + std::string output; + char buf[4096]; + ssize_t n; + while ((n = read(pipefd[0], buf, sizeof(buf))) > 0) + output.append(buf, static_cast(n)); + (void)close(pipefd[0]); + + int status = 0; + while (waitpid(pid, &status, 0) < 0) + if (errno != EINTR) + return {-1, {}}; + + /// Split output into non-empty lines. + std::vector lines; + { + size_t pos = 0; + while (pos < output.size()) + { + size_t found = output.find('\n', pos); + if (found == std::string::npos) + found = output.size(); + std::string line = output.substr(pos, found - pos); + if (!line.empty() && line.back() == '\r') + line.pop_back(); + if (!line.empty()) + lines.push_back(std::move(line)); + pos = found + 1; + } + } + + return {WIFEXITED(status) ? WEXITSTATUS(status) : -1, std::move(lines)}; +} + +/// Run two commands connected by a pipe: lhs | rhs. +/// Returns the exit code of the rhs process. +int runPipeline(const std::vector & lhs, const std::vector & rhs) +{ + int pipefd[2]; + if (pipe(pipefd) < 0) + return -1; + + pid_t lhs_pid = fork(); + if (lhs_pid < 0) + { + (void)close(pipefd[0]); + (void)close(pipefd[1]); + return -1; + } + if (lhs_pid == 0) + { + (void)close(pipefd[0]); + (void)dup2(pipefd[1], STDOUT_FILENO); + (void)close(pipefd[1]); + auto argv = buildArgv(lhs); + execvp(argv[0], argv.data()); + _exit(127); + } + + pid_t rhs_pid = fork(); + if (rhs_pid < 0) + { + (void)close(pipefd[0]); + (void)close(pipefd[1]); + kill(lhs_pid, SIGTERM); + while (waitpid(lhs_pid, nullptr, 0) < 0 && errno == EINTR) {} + return -1; + } + if (rhs_pid == 0) + { + (void)close(pipefd[1]); + (void)dup2(pipefd[0], STDIN_FILENO); + (void)close(pipefd[0]); + auto argv = buildArgv(rhs); + execvp(argv[0], argv.data()); + _exit(127); + } + + (void)close(pipefd[0]); + (void)close(pipefd[1]); + + int lhs_status = 0; + int rhs_status = 0; + while (waitpid(lhs_pid, &lhs_status, 0) < 0 && errno == EINTR) {} + while (waitpid(rhs_pid, &rhs_status, 0) < 0 && errno == EINTR) {} + + return WIFEXITED(rhs_status) ? WEXITSTATUS(rhs_status) : -1; +} + +/// Returns true if the string is a safe ClickHouse identifier: +/// alphanumeric + underscore, not starting with a digit. +/// Used to validate CLICKHOUSE_USER and CLICKHOUSE_DB before embedding in SQL/XML. +bool isValidIdentifier(const std::string & s) +{ + if (s.empty()) + return false; + if (std::isdigit(static_cast(s[0]))) + return false; + for (unsigned char c : s) + if (!std::isalnum(c) && c != '_') + return false; + return true; +} + +/// Extract a single value from a ClickHouse config key via `clickhouse extract-from-config`. +/// Returns an empty string if the key is absent (--try flag suppresses errors). +std::string extractConfigValue(const std::string & config_file, const std::string & key, bool use_users = false) +{ + std::vector args = { + g_clickhouse_binary, "extract-from-config", + "--config-file", config_file, + "--key", key, + "--try", + }; + if (use_users) + args.emplace_back("--users"); + + auto [code, lines] = captureCommand(args); + return (code == 0 && !lines.empty()) ? lines[0] : std::string{}; +} + +/// Extract multiple values from a ClickHouse config key (wildcard patterns return multiple lines). +std::vector extractConfigValues(const std::string & config_file, const std::string & key) +{ + auto [code, lines] = captureCommand({ + g_clickhouse_binary, "extract-from-config", + "--config-file", config_file, + "--key", key, + "--try", + }); + return (code == 0) ? std::move(lines) : std::vector{}; +} + +/// Recursively chown a path. Logs warnings but does not abort on failure. +void recursiveChown(const std::string & path_str, uid_t uid, gid_t gid) +{ + if (lchown(path_str.c_str(), uid, gid) < 0) + std::cerr << "docker-init: warning: lchown " << path_str << ": " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) + + std::error_code ec; + if (!fs::is_directory(path_str, ec)) + return; + + for (const auto & entry : fs::recursive_directory_iterator(path_str, fs::directory_options::skip_permission_denied, ec)) + { + if (lchown(entry.path().c_str(), uid, gid) < 0) + std::cerr << "docker-init: warning: lchown " << entry.path() << ": " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) + } +} + +/// Create a directory (and all parents) and optionally chown it. +/// +/// Three cases: +/// 1. do_chown=true (root, normal mode): create with fs::create_directories, then chown. +/// 2. do_chown=false, running as root (CLICKHOUSE_DO_NOT_CHOWN=1): delegate to +/// `clickhouse su UID:GID` so the directory is created as the target user. +/// This handles NFS mounts where root is mapped to nobody. +/// 3. do_chown=false, running as non-root: create directly — we are already the target user. +bool createDirectoryAndChown(const std::string & dir, uid_t uid, gid_t gid, bool do_chown) +{ + if (dir.empty()) + return true; + + if (do_chown) + { + std::error_code ec; + fs::create_directories(dir, ec); + if (ec) + { + std::cerr << "docker-init: couldn't create directory " << dir << ": " << ec.message() << "\n"; + return false; + } + + /// Chown only if the owner needs to change (avoids slow recursive chown on already-correct dirs). + struct stat st{}; + if (stat(dir.c_str(), &st) == 0 && (st.st_uid != uid || st.st_gid != gid)) + recursiveChown(dir, uid, gid); + + return true; + } + + if (getuid() == 0) + { + /// Running as root with CLICKHOUSE_DO_NOT_CHOWN or CLICKHOUSE_RUN_AS_ROOT. + /// On NFS mounts root may be remapped to nobody, so create the directory as + /// the target user. Fork a child that drops privileges before calling + /// fs::create_directories — distroless has no mkdir binary. + pid_t pid = fork(); + if (pid < 0) + { + std::cerr << "docker-init: fork failed for directory creation: " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) + return false; + } + if (pid == 0) + { + if (setgroups(0, nullptr) < 0 || setgid(gid) < 0 || setuid(uid) < 0) + _exit(1); + std::error_code ec; + fs::create_directories(dir, ec); + _exit(ec ? 1 : 0); + } + int status = 0; + while (waitpid(pid, &status, 0) < 0 && errno == EINTR) {} + if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) + { + /// Fallback: try direct creation (works when root is not remapped). + std::error_code ec; + fs::create_directories(dir, ec); + if (ec) + { + std::cerr << "docker-init: couldn't create directory " << dir << ": " << ec.message() << "\n"; + return false; + } + } + return true; + } + + /// Non-root: we are already running as UID:GID, so create the directory directly. + std::error_code ec; + fs::create_directories(dir, ec); + if (ec) + { + std::cerr << "docker-init: couldn't create directory " << dir << ": " << ec.message() << "\n"; + return false; + } + return true; +} + +/// Write the user management XML to `/etc/clickhouse-server/users.d/default-user.xml`. +/// Returns false if a user-requested setup (CLICKHOUSE_USER/PASSWORD/ACCESS_MANAGEMENT) +/// is invalid — caller should treat this as fatal. +bool manageClickHouseUser( + const std::string & config_file, + const std::string & clickhouse_user, + const std::string & clickhouse_password, + const std::string & access_management, + bool skip_user_setup) +{ + if (skip_user_setup) + { + std::cerr << "docker-init: explicitly skip changing user 'default'\n"; + return true; + } + + const std::string users_d_dir = "/etc/clickhouse-server/users.d"; + const std::string default_user_xml = users_d_dir + "/default-user.xml"; + + std::error_code ec; + fs::create_directories(users_d_dir, ec); + + /// Detect whether the default user was customised via a mounted config file. + bool clickhouse_default_changed = false; + std::string users_xml_path = extractConfigValue(config_file, "user_directories.users_xml.path"); + if (!users_xml_path.empty()) + { + std::string abs_users_xml = (users_xml_path[0] == '/') + ? users_xml_path + : (fs::path(config_file).parent_path() / users_xml_path).string(); + + auto join = [](const std::vector & v) + { + std::string s; + for (const auto & line : v) + s += line + "\n"; + return s; + }; + + auto [c1, original] = captureCommand({ + g_clickhouse_binary, "extract-from-config", + "--config-file", abs_users_xml, + "--key", "users.default", "--try", + }); + auto [c2, processed] = captureCommand({ + g_clickhouse_binary, "extract-from-config", + "--config-file", config_file, + "--users", "--key", "users.default", "--try", + }); + + if (c1 == 0 && c2 == 0 && join(original) != join(processed)) + clickhouse_default_changed = true; + } + + bool has_custom_user = !clickhouse_user.empty() && clickhouse_user != "default"; + bool has_password = !clickhouse_password.empty(); + bool has_access_mgmt = access_management != "0"; + + if (has_custom_user || has_password || has_access_mgmt) + { + if (access_management != "0" && access_management != "1") + { + std::cerr << "docker-init: error: CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT must be '0' or '1', got '" + << access_management << "'\n"; + return false; + } + + if (!isValidIdentifier(clickhouse_user)) + { + std::cerr << "docker-init: error: CLICKHOUSE_USER '" << clickhouse_user + << "' contains characters not allowed in an XML element name; " + "use only alphanumeric characters and underscores\n"; + return false; + } + + std::cerr << "docker-init: create new user '" << clickhouse_user << "' instead 'default'\n"; + + /// Escape CDATA end marker: ]]> → ]]]]> + std::string escaped_password; + { + std::string_view src = clickhouse_password; + const std::string_view needle = "]]>"; + const std::string_view replacement = "]]]]>"; + size_t pos = 0; + size_t found; + while ((found = src.find(needle, pos)) != std::string_view::npos) + { + escaped_password.append(src, pos, found - pos); + escaped_password += replacement; + pos = found + needle.size(); + } + escaped_password.append(src, pos, src.size() - pos); + } + + { + std::ofstream f(default_user_xml); + f << "\n" + << " \n" + << " \n" + << " \n" + << " \n" + << " \n" + << "\n" + << " <" << clickhouse_user << ">\n" + << " default\n" + << " \n" + << " ::/0\n" + << " \n" + << " \n" + << " default\n" + << " " << access_management << "\n" + << " \n" + << " \n" + << "\n"; + if (!f.good()) + std::cerr << "docker-init: error: failed to write " << default_user_xml << "\n"; + } + } + else if (clickhouse_default_changed) + { + /// A mounted config already customised the user — leave it as-is. + } + else + { + std::cerr << "docker-init: neither CLICKHOUSE_USER nor CLICKHOUSE_PASSWORD is set, " + "disabling network access for user 'default'\n"; + { + std::ofstream f(default_user_xml); + f << "\n" + << " \n" + << " \n" + << " \n" + << " \n" + << " \n" + << " ::1\n" + << " 127.0.0.1\n" + << " \n" + << " \n" + << " \n" + << "\n"; + if (!f.good()) + std::cerr << "docker-init: error: failed to write " << default_user_xml << "\n"; + } + } + return true; +} + +/// Returns false on first error (fail-fast, matches shell `set -e`). +bool createClickHouseDatabase( + const std::vector & client_base, + const std::string & clickhouse_db) +{ + if (clickhouse_db.empty()) + return true; + if (!isValidIdentifier(clickhouse_db)) + { + std::cerr << "docker-init: error: CLICKHOUSE_DB '" << clickhouse_db + << "' contains characters not safe for use in SQL; " + "use only alphanumeric characters and underscores\n"; + return false; + } + std::cerr << "docker-init: create database '" << clickhouse_db << "'\n"; + std::vector args = client_base; + args.insert(args.end(), {"-q", "CREATE DATABASE IF NOT EXISTS " + clickhouse_db}); + if (runCommand(args) != 0) + { + std::cerr << "docker-init: error: failed to create database '" << clickhouse_db << "'\n"; + return false; + } + return true; +} + +/// Returns false on first script failure (fail-fast, matches shell `set -e`). +bool runInitScripts(const std::vector & client_base) +{ + std::error_code ec; + if (!fs::is_directory("/docker-entrypoint-initdb.d", ec)) + return true; + std::vector init_files; + for (const auto & entry : fs::directory_iterator("/docker-entrypoint-initdb.d", ec)) + init_files.push_back(entry.path()); + std::sort(init_files.begin(), init_files.end()); + + for (const auto & path : init_files) + { + std::string filename = path.filename().string(); + + if (filename.ends_with(".sql") && !filename.ends_with(".sql.gz")) + { + std::cerr << "docker-init: running " << path << "\n"; + std::vector args = client_base; + args.emplace_back("--queries-file"); + args.push_back(path.string()); + if (runCommand(args) != 0) + { + std::cerr << "docker-init: error: init script " << path << " failed\n"; + return false; + } + } + else if (filename.ends_with(".sql.gz")) + { + std::cerr << "docker-init: running " << path << " (decompressing)\n"; + /// Decompress via clickhouse-local (auto-detects .gz) and pipe to clickhouse-client. + /// Escape single quotes in the path to prevent SQL injection via crafted filenames. + std::string escaped_path; + for (char c : path.string()) + { + if (c == '\'') + escaped_path += "''"; + else + escaped_path += c; + } + std::vector decompress_args = { + g_clickhouse_binary, "local", + "--query", + "SELECT * FROM file('" + escaped_path + "', RawBLOB) FORMAT RawBLOB", + }; + if (runPipeline(decompress_args, client_base) != 0) + { + std::cerr << "docker-init: error: init script " << path << " failed\n"; + return false; + } + } + else if (filename.ends_with(".sh")) + { + std::cerr << "docker-init: WARNING: shell scripts cannot run in a distroless " + "environment, skipping " << path << "\n"; + } + else + { + std::cerr << "docker-init: ignoring " << path << "\n"; + } + } + return true; +} + +/// Start a temporary ClickHouse server, run init scripts, then stop it. +bool initClickHouseDB( + const std::string & config_file, + const std::string & data_dir, + const std::string & clickhouse_user, + const std::string & clickhouse_password, + uid_t run_uid, + gid_t run_gid, + const std::vector & extra_server_args, + bool always_run_initdb) +{ + /// Skip if data directory is already initialised and CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS is unset. + bool database_exists = fs::is_directory(data_dir + "/data"); + if (!always_run_initdb && database_exists) + { + std::cerr << "docker-init: ClickHouse data directory appears to contain a database; " + "skipping initialization\n"; + return true; + } + + std::string clickhouse_db = getEnv("CLICKHOUSE_DB"); + + /// Check whether /docker-entrypoint-initdb.d has any files. + std::error_code ec; + bool has_init_files = fs::is_directory("/docker-entrypoint-initdb.d", ec) + && fs::directory_iterator("/docker-entrypoint-initdb.d", ec) != fs::directory_iterator{}; + + if (!has_init_files && clickhouse_db.empty()) + return true; + + std::string native_port = extractConfigValue(config_file, "tcp_port"); + if (native_port.empty()) + native_port = "9000"; + + std::string run_as = std::to_string(run_uid) + ":" + std::to_string(run_gid); + + /// Start a temporary server bound only to localhost. + /// The "--" separator is required: positional arguments after "--" override config.xml + /// properties (e.g. --listen_host=127.0.0.1), while options before "--" are parsed by + /// Poco and must be registered. Without "--", Poco rejects "--listen_host" as unknown. + std::vector server_args = { + g_clickhouse_binary, "su", run_as, "clickhouse-server", + "--config-file=" + config_file, + "--", "--listen_host=127.0.0.1", + }; + for (const auto & arg : extra_server_args) + server_args.push_back(arg); + + if (g_shutdown_requested) + return true; + + pid_t server_pid = fork(); + if (server_pid < 0) + { + std::cerr << "docker-init: failed to fork temporary server\n"; + return false; + } + + if (server_pid == 0) + { + auto argv = buildArgv(server_args); + execvp(argv[0], argv.data()); + _exit(127); + } + + /// Allow the signal handler to forward SIGTERM to the temp server. + g_init_server_pid = server_pid; + + /// Poll until the server accepts connections. + /// This is a service-readiness wait, not a race condition workaround. + int tries = 1000; + { + std::string timeout_str = getEnv("CLICKHOUSE_INIT_TIMEOUT", "1000"); + try + { + tries = std::stoi(timeout_str); + } + catch (const std::exception &) + { + std::cerr << "docker-init: warning: invalid CLICKHOUSE_INIT_TIMEOUT '" + << timeout_str << "', using default 1000\n"; + } + } + bool server_ready = false; + + while (tries > 0 && !server_ready && !g_shutdown_requested) + { + pid_t check_pid = fork(); + if (check_pid < 0) + { + /// fork failed — skip this iteration and retry. + --tries; + sleep(1); // NOLINT(concurrency-mt-unsafe) + continue; + } + if (check_pid == 0) + { + int devnull = open("/dev/null", O_WRONLY); + if (devnull >= 0) + { + dup2(devnull, STDOUT_FILENO); + dup2(devnull, STDERR_FILENO); + close(devnull); + } + /// Keep args in a named variable so the strings outlive argv. + std::vector check_args = { + g_clickhouse_binary, "client", + "--host", "127.0.0.1", + "--port", native_port, + "-u", clickhouse_user, + "--password", clickhouse_password, + "--query", "SELECT 1", + }; + auto argv = buildArgv(check_args); + execvp(argv[0], argv.data()); + _exit(127); + } + + int check_status = 0; + while (waitpid(check_pid, &check_status, 0) < 0 && errno == EINTR) {} + if (WIFEXITED(check_status) && WEXITSTATUS(check_status) == 0) + { + server_ready = true; + } + else + { + --tries; + sleep(1); // NOLINT(concurrency-mt-unsafe) -- Wait between health-check retries — not a race condition fix. + } + } + + if (!server_ready) + { + if (g_shutdown_requested) + std::cerr << "docker-init: shutdown requested, stopping init server\n"; + else + std::cerr << "docker-init: ClickHouse init process timed out\n"; + kill(server_pid, SIGTERM); + while (waitpid(server_pid, nullptr, 0) < 0 && errno == EINTR) {} + g_init_server_pid = 0; + return false; + } + + std::vector client_base = { + g_clickhouse_binary, "client", + "--multiquery", + "--host", "127.0.0.1", + "--port", native_port, + "-u", clickhouse_user, + "--password", clickhouse_password, + }; + + const bool ok = createClickHouseDatabase(client_base, clickhouse_db) + && runInitScripts(client_base); + + /// Always stop the temporary server regardless of init result. + kill(server_pid, SIGTERM); + int server_status = 0; + while (waitpid(server_pid, &server_status, 0) < 0 && errno == EINTR) {} + g_init_server_pid = 0; + if (!WIFEXITED(server_status) || WEXITSTATUS(server_status) != 0) + std::cerr << "docker-init: warning: init server did not exit cleanly\n"; + return ok; +} + +} // anonymous namespace + + +int mainEntryClickHouseDockerInit(int argc, char ** argv) +{ + g_clickhouse_binary = (argc > 0 && argv[0][0] != '\0') ? argv[0] : "clickhouse"; + + bool keeper_mode = false; + bool show_help = false; + bool separator_seen = false; + std::vector extra_args; + + for (int i = 1; i < argc; ++i) + { + std::string_view arg = argv[i]; + + if (!separator_seen && (arg == "--help" || arg == "-h")) + { + show_help = true; + break; + } + else if (!separator_seen && arg == "--keeper") + keeper_mode = true; + else if (!separator_seen && arg == "--") + separator_seen = true; + else + extra_args.emplace_back(arg); + } + + if (show_help) + { + std::cout + << "Usage: clickhouse docker-init [--keeper] [-- ...]\n" + "Docker entrypoint for distroless ClickHouse images.\n" + "\nOptions:\n" + " --keeper Start ClickHouse Keeper instead of server\n" + " --help Show this help message\n" + "\nEnvironment variables (server mode):\n" + " CLICKHOUSE_CONFIG Path to config file " + "(default: /etc/clickhouse-server/config.xml)\n" + " CLICKHOUSE_RUN_AS_ROOT Run as root (0/1)\n" + " CLICKHOUSE_DO_NOT_CHOWN Skip chown operations (0/1)\n" + " CLICKHOUSE_UID Override UID to run as\n" + " CLICKHOUSE_GID Override GID to run as\n" + " CLICKHOUSE_USER Default user name (default: default)\n" + " CLICKHOUSE_PASSWORD Default user password\n" + " CLICKHOUSE_PASSWORD_FILE File containing password\n" + " CLICKHOUSE_DB Database to create on init\n" + " CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT Enable access management (0/1)\n" + " CLICKHOUSE_SKIP_USER_SETUP Skip user setup (0/1)\n" + " CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS Always run init scripts\n" + " CLICKHOUSE_INIT_TIMEOUT Max retries for server readiness (default: 1000)\n" + " CLICKHOUSE_WATCHDOG_ENABLE Enable watchdog (default: 0)\n" + "\nEnvironment variables (keeper mode):\n" + " KEEPER_CONFIG Path to keeper config file\n" + " CLICKHOUSE_DATA_DIR Data directory (default: /var/lib/clickhouse)\n" + " LOG_DIR Log directory (default: /var/log/clickhouse-keeper)\n"; + return 0; + } + + /// --- Passthrough mode --- + /// If the first extra argument does not start with '--', treat it as a command to exec + /// directly without server startup. This mirrors entrypoint.sh: + /// if [[ "$1" == "--"* ]]; then start server; fi; exec "$@" + /// + /// For recognized ClickHouse subcommand names (client, local, etc.) resolve the path + /// via bin_dir so that multi-tool dispatch (by argv[0] basename) works correctly. + /// For everything else (echo, date, bash, ...) let PATH resolution handle it. + if (!extra_args.empty() && !extra_args[0].starts_with("--")) + { + static constexpr std::array clickhouse_tools = { + "clickhouse-client", + "clickhouse-local", + "clickhouse-keeper-client", + "clickhouse-benchmark", + "clickhouse-format", + "clickhouse-compressor", + "clickhouse-obfuscator", + "clickhouse-extract-from-config", + "clickhouse-disks", + "client", + "local", + "keeper-client", + "benchmark", + "format", + "compressor", + "obfuscator", + "extract-from-config", + "disks", + }; + + std::string cmd = extra_args[0]; + if (std::find(clickhouse_tools.begin(), clickhouse_tools.end(), extra_args[0]) != clickhouse_tools.end()) + { + /// Build the full path to the symlink (e.g. /usr/bin/clickhouse-client). + /// The symlink points to the clickhouse binary; dispatching is done by argv[0]. + /// Short names like "client" must be resolved to "clickhouse-client" since the + /// distroless image only has "clickhouse-*" symlinks (not bare "client", "local", etc.). + fs::path bin_dir = fs::path(g_clickhouse_binary).parent_path(); + std::string link_name = extra_args[0]; + if (!link_name.starts_with("clickhouse-")) + link_name = "clickhouse-" + link_name; + cmd = (bin_dir / link_name).string(); + } + + std::vector exec_cmd = {cmd}; + for (std::size_t i = 1; i < extra_args.size(); ++i) + exec_cmd.push_back(extra_args[i]); + + auto exec_argv = buildArgv(exec_cmd); + execvp(exec_argv[0], exec_argv.data()); + std::cerr << "docker-init: failed to exec '" << extra_args[0] << "': " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) + return 1; + } + + /// --- Resolve identity --- + uid_t current_uid = getuid(); + uid_t run_uid; + gid_t run_gid; + bool do_chown = true; + + if (getEnv("CLICKHOUSE_RUN_AS_ROOT") == "1" || getEnv("CLICKHOUSE_DO_NOT_CHOWN") == "1") + do_chown = false; + + if (current_uid == 0) + { + if (getEnv("CLICKHOUSE_RUN_AS_ROOT") == "1") + { + run_uid = 0; + run_gid = 0; + } + else + { + /// Default to the `clickhouse` system user if it exists, otherwise fall back to UID 101. + uid_t default_uid = 101; + gid_t default_gid = 101; + const passwd * pw = getpwnam("clickhouse"); // NOLINT(concurrency-mt-unsafe) + if (pw) + { + default_uid = pw->pw_uid; + default_gid = pw->pw_gid; + } + + std::string uid_str = getEnv("CLICKHOUSE_UID"); + std::string gid_str = getEnv("CLICKHOUSE_GID"); + run_uid = default_uid; + run_gid = default_gid; + try + { + if (!uid_str.empty()) + run_uid = static_cast(std::stoul(uid_str)); + if (!gid_str.empty()) + run_gid = static_cast(std::stoul(gid_str)); + } + catch (const std::exception &) + { + std::cerr << "docker-init: warning: invalid CLICKHOUSE_UID/GID values, " + "using defaults\n"; + } + } + } + else + { + /// Non-root: cannot chown, run as current user. + run_uid = current_uid; + run_gid = getgid(); + do_chown = false; + } + + std::string run_as = std::to_string(run_uid) + ":" + std::to_string(run_gid); + + /// --- Keeper mode --- + if (keeper_mode) + { + std::string keeper_config = getEnv("KEEPER_CONFIG", "/etc/clickhouse-keeper/keeper_config.xml"); + std::string data_dir = getEnv("CLICKHOUSE_DATA_DIR", "/var/lib/clickhouse"); + std::string log_dir = getEnv("LOG_DIR", "/var/log/clickhouse-keeper"); + + for (const auto & dir : {data_dir, log_dir, + data_dir + "/coordination", + data_dir + "/coordination/log", + data_dir + "/coordination/snapshots"}) + { + if (!createDirectoryAndChown(dir, run_uid, run_gid, do_chown)) + return 1; + } + + /// Default to disabled so Ctrl+C works in Docker. Don't override if already set. + setenv("CLICKHOUSE_WATCHDOG_ENABLE", "0", 0); // NOLINT(concurrency-mt-unsafe) + + chdir(data_dir.c_str()); // NOLINT(bugprone-unused-return-value) + + std::vector exec_args = { + g_clickhouse_binary, "su", run_as, "clickhouse-keeper", + }; + + std::error_code ec; + if (!keeper_config.empty() && fs::exists(keeper_config, ec)) + exec_args.push_back("--config-file=" + keeper_config); + + for (const auto & arg : extra_args) + exec_args.push_back(arg); + + auto exec_argv = buildArgv(exec_args); + execvp(exec_argv[0], exec_argv.data()); + std::cerr << "docker-init: failed to exec clickhouse keeper: " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) + return 1; + } + + /// --- Server mode --- + std::string config_file = getEnv("CLICKHOUSE_CONFIG", "/etc/clickhouse-server/config.xml"); + + /// Extract all relevant paths from the config. + std::string data_dir = extractConfigValue(config_file, "path"); + std::string tmp_dir = extractConfigValue(config_file, "tmp_path"); + std::string user_files_path = extractConfigValue(config_file, "user_files_path"); + std::string format_schema_path = extractConfigValue(config_file, "format_schema_path"); + + std::string log_dir; + std::string log_path = extractConfigValue(config_file, "logger.log"); + if (!log_path.empty()) + log_dir = fs::path(log_path).parent_path().string(); + + std::string error_log_dir; + std::string error_log_path = extractConfigValue(config_file, "logger.errorlog"); + if (!error_log_path.empty()) + error_log_dir = fs::path(error_log_path).parent_path().string(); + + auto disk_paths = extractConfigValues(config_file, "storage_configuration.disks.*.path"); + auto disk_metadata_paths = extractConfigValues(config_file, "storage_configuration.disks.*.metadata_path"); + + /// Create and chown data directory first, then cd into it. + if (!data_dir.empty() && !createDirectoryAndChown(data_dir, run_uid, run_gid, do_chown)) + return 1; + + chdir(data_dir.empty() ? "/" : data_dir.c_str()); // NOLINT(bugprone-unused-return-value) + + for (const auto & dir : {error_log_dir, log_dir, tmp_dir, user_files_path, format_schema_path}) + { + if (!dir.empty() && !createDirectoryAndChown(dir, run_uid, run_gid, do_chown)) + return 1; + } + for (const auto & dir : disk_paths) + if (!createDirectoryAndChown(dir, run_uid, run_gid, do_chown)) + return 1; + for (const auto & dir : disk_metadata_paths) + if (!createDirectoryAndChown(dir, run_uid, run_gid, do_chown)) + return 1; + + /// Resolve password (from env or file). + std::string clickhouse_user = getEnv("CLICKHOUSE_USER", "default"); + std::string clickhouse_password = getEnv("CLICKHOUSE_PASSWORD"); + std::string password_file = getEnv("CLICKHOUSE_PASSWORD_FILE"); + if (!password_file.empty()) + { + std::ifstream pf(password_file); + if (pf.is_open()) + std::getline(pf, clickhouse_password); + else + std::cerr << "docker-init: warning: cannot read CLICKHOUSE_PASSWORD_FILE '" + << password_file << "': " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) + } + + std::string access_management = getEnv("CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT", "0"); + bool skip_user_setup = (getEnv("CLICKHOUSE_SKIP_USER_SETUP") == "1"); + + if (!manageClickHouseUser(config_file, clickhouse_user, clickhouse_password, access_management, skip_user_setup)) + return 1; + + /// Install signal handlers so `docker stop` during init triggers graceful shutdown. + /// As PID 1, signals without a handler are silently dropped by the kernel. + { + struct sigaction sa{}; + sa.sa_handler = shutdownHandler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + sigaction(SIGTERM, &sa, nullptr); + sigaction(SIGINT, &sa, nullptr); + } + + bool always_run_initdb = !getEnv("CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS").empty(); + if (!initClickHouseDB(config_file, data_dir, clickhouse_user, clickhouse_password, + run_uid, run_gid, extra_args, always_run_initdb)) + return 1; + + if (g_shutdown_requested) + { + std::cerr << "docker-init: shutdown requested during initialization, exiting\n"; + return 1; + } + + /// Reset signal handlers before exec — the server handles its own signals. + signal(SIGTERM, SIG_DFL); // NOLINT(cert-err33-c) + signal(SIGINT, SIG_DFL); // NOLINT(cert-err33-c) + + /// Set watchdog env — default to disabled so Ctrl+C works in Docker. + if (std::getenv("CLICKHOUSE_WATCHDOG_ENABLE") == nullptr) // NOLINT(concurrency-mt-unsafe) + setenv("CLICKHOUSE_WATCHDOG_ENABLE", "0", 0); // NOLINT(concurrency-mt-unsafe) + + /// Replace this process with clickhouse-server via `clickhouse su`. + std::vector exec_args = { + g_clickhouse_binary, "su", run_as, "clickhouse-server", + "--config-file=" + config_file, + }; + for (const auto & arg : extra_args) + exec_args.push_back(arg); + + auto exec_argv = buildArgv(exec_args); + execvp(exec_argv[0], exec_argv.data()); + std::cerr << "docker-init: failed to exec clickhouse server: " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe) + return 1; +} diff --git a/programs/main.cpp b/programs/main.cpp index af2faccf6129..d59bfd04bb65 100644 --- a/programs/main.cpp +++ b/programs/main.cpp @@ -71,6 +71,7 @@ int mainEntryClickHouseChecksumForCompressedBlock(int, char **); int mainEntryClickHouseClient(int argc, char ** argv); int mainEntryClickHouseCompressor(int argc, char ** argv); int mainEntryClickHouseDisks(int argc, char ** argv); +int mainEntryClickHouseDockerInit(int argc, char ** argv); int mainEntryClickHouseExtractFromConfig(int argc, char ** argv); int mainEntryClickHouseFormat(int argc, char ** argv); int mainEntryClickHouseFstDumpTree(int argc, char ** argv); @@ -151,6 +152,7 @@ std::pair clickhouse_applications[] = {"su", mainEntryClickHouseSU}, {"hash-binary", mainEntryClickHouseHashBinary}, {"disks", mainEntryClickHouseDisks}, + {"docker-init", mainEntryClickHouseDockerInit}, {"check-marks", mainEntryClickHouseCheckMarks}, {"checksum-for-compressed-block", mainEntryClickHouseChecksumForCompressedBlock}, {"zookeeper-dump-tree", mainEntryClickHouseZooKeeperDumpTree}, From af508eda0213cf65bb09026c84a6ca69bc8458a0 Mon Sep 17 00:00:00 2001 From: Rahul Nair <254529899+motsc@users.noreply.github.com> Date: Mon, 27 Apr 2026 01:31:39 -0700 Subject: [PATCH 51/70] Backport distroless CI integration to 26.3 (#103578) Add distroless to the CI Docker build pipeline: - Add distroless to default OS list in docker_server.py - Add --no-distroless flag - Add distroless test cases (initdb, no-shell) - Update test config dispatcher Depends on the docker-init binary backport. --- ci/jobs/docker_server.py | 41 +++++++++++++++-- ci/jobs/scripts/docker_server/config.sh | 7 ++- .../clickhouse-distroless-initdb/initdb.sql | 3 ++ .../tests/clickhouse-distroless-initdb/run.sh | 46 +++++++++++++++++++ .../clickhouse-distroless-no-shell/run.sh | 17 +++++++ 5 files changed, 107 insertions(+), 7 deletions(-) create mode 100644 ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/initdb.sql create mode 100755 ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/run.sh create mode 100755 ci/jobs/scripts/docker_server/tests/clickhouse-distroless-no-shell/run.sh diff --git a/ci/jobs/docker_server.py b/ci/jobs/docker_server.py index 44216b549b5f..bf1cdd71f005 100644 --- a/ci/jobs/docker_server.py +++ b/ci/jobs/docker_server.py @@ -101,7 +101,7 @@ def parse_args() -> argparse.Namespace: ) parser.add_argument("--reports", default=True, help=argparse.SUPPRESS) parser.add_argument("--push", action="store_true", help=argparse.SUPPRESS) - parser.add_argument("--os", default=["ubuntu", "alpine"], help=argparse.SUPPRESS) + parser.add_argument("--os", default=["ubuntu", "alpine", "distroless"], help=argparse.SUPPRESS) parser.add_argument( "--no-ubuntu", action=DelOS, @@ -116,6 +116,13 @@ def parse_args() -> argparse.Namespace: default=argparse.SUPPRESS, help="don't build alpine image", ) + parser.add_argument( + "--no-distroless", + action=DelOS, + nargs=0, + default=argparse.SUPPRESS, + help="don't build distroless image", + ) parser.add_argument( "--allow-build-reuse", action="store_true", @@ -215,10 +222,25 @@ def build_and_push_image( cmd_args = list(init_args) urls = [] if direct_urls: - if os == "ubuntu" and "clickhouse-server" in image.name: - urls = [url for url in direct_urls[arch] if ".deb" in url] + # distroless and ubuntu-server use an Ubuntu builder with dpkg, so they + # need .deb packages. alpine and ubuntu-keeper use .tgz packages. + uses_deb = os == "distroless" or ( + os == "ubuntu" and "clickhouse-server" in image.name + ) + if uses_deb: + urls = [ + url + for url in direct_urls[arch] + if ".deb" in url and "-dbg" not in url + ] else: - urls = [url for url in direct_urls[arch] if ".tgz" in url] + # For keeper/alpine tgz builds, only pass the keeper tgz. + # Excluding clickhouse-common-static.tgz avoids a large unnecessary download. + tgz_urls = [url for url in direct_urls[arch] if ".tgz" in url] + if "keeper" in image.name: + urls = [url for url in tgz_urls if "clickhouse-keeper" in url] + else: + urls = tgz_urls cmd_args.extend( buildx_args( repo_urls, @@ -384,7 +406,16 @@ def main(): "clickhouse-common-static", ] elif "clickhouse-keeper" in image_repo: - PACKAGES = ["clickhouse-keeper"] + # Both packages are needed to cover all three keeper image variants: + # distroless: installs from .deb via dpkg; clickhouse-common-static + # provides the clickhouse multi-tool binary (clickhouse-keeper + # is a symlink to it). clickhouse-keeper .deb is not published + # separately, so the common-static .deb is the only source. + # alpine/ubuntu: installs from .tgz; clickhouse-keeper provides the + # standalone keeper binary and its symlinks. The common-static + # .tgz is implicitly excluded because the url filter below + # keeps only urls containing "clickhouse-keeper" in the name. + PACKAGES = ["clickhouse-common-static", "clickhouse-keeper"] else: assert False, "BUG" urls = read_build_urls(build_name) diff --git a/ci/jobs/scripts/docker_server/config.sh b/ci/jobs/scripts/docker_server/config.sh index 1e69ca534b35..84882b1745df 100644 --- a/ci/jobs/scripts/docker_server/config.sh +++ b/ci/jobs/scripts/docker_server/config.sh @@ -3,11 +3,14 @@ # Get current file directory currentDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" -# interate over all directories in current path -clickhouseTests=$( find "$currentDir"/tests/ -maxdepth 1 -name 'clickhouse-*' -type d -exec basename {} \; ) +# iterate over all directories in current path +clickhouseTests=$( find "$currentDir"/tests/ -maxdepth 1 -name 'clickhouse-*' -not -name 'clickhouse-distroless-*' -type d -exec basename {} \; ) +clickhouseDistrolessTests=$( find "$currentDir"/tests/ -maxdepth 1 -name 'clickhouse-distroless-*' -type d -exec basename {} \; ) keeperTests=$( find "$currentDir"/tests/ -maxdepth 1 -name 'keeper-*' -type d -exec basename {} \; ) imageTests+=( ['clickhouse/clickhouse-server']="${clickhouseTests}" + ['clickhouse/clickhouse-server:distroless']="${clickhouseTests} ${clickhouseDistrolessTests}" ['clickhouse/clickhouse-keeper']="${keeperTests}" + ['clickhouse/clickhouse-keeper:distroless']="${keeperTests}" ) diff --git a/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/initdb.sql b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/initdb.sql new file mode 100644 index 000000000000..16304daf2aa6 --- /dev/null +++ b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/initdb.sql @@ -0,0 +1,3 @@ +CREATE DATABASE IF NOT EXISTS test_db; +CREATE TABLE IF NOT EXISTS test_db.test_table (id UInt32, value UInt32) ENGINE = MergeTree ORDER BY id; +INSERT INTO test_db.test_table VALUES (1, 100), (2, 200); diff --git a/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/run.sh b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/run.sh new file mode 100755 index 000000000000..597818de6c21 --- /dev/null +++ b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-initdb/run.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Verify that clickhouse docker-init executes SQL initdb scripts correctly. +# The distroless image has no shell so initdb scripts must be handled +# by the compiled docker-init entrypoint, not by entrypoint.sh. +set -eo pipefail + +dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +source "$dir/../lib.sh" + +image="$1" + +export CLICKHOUSE_USER='init_test_user' +export CLICKHOUSE_PASSWORD='init_test_password' + +cid="$( + docker run -d \ + -e CLICKHOUSE_USER \ + -e CLICKHOUSE_PASSWORD \ + -v "$dir/initdb.sql":/docker-entrypoint-initdb.d/initdb.sql:ro \ + --name "$(cname)" \ + "$image" +)" +trap 'docker rm -vf $cid > /dev/null' EXIT + +chCli() { + docker run --rm -i \ + --link "$cid":clickhouse \ + -e CLICKHOUSE_USER \ + -e CLICKHOUSE_PASSWORD \ + "$image" \ + clickhouse-client \ + --host clickhouse \ + --user "$CLICKHOUSE_USER" \ + --password "$CLICKHOUSE_PASSWORD" \ + --query "$*" +} + +# shellcheck source=../../../../../tmp/docker-library/official-images/test/retry.sh +. "$TESTS_LIB_DIR/retry.sh" \ + --tries "$CLICKHOUSE_TEST_TRIES" \ + --sleep "$CLICKHOUSE_TEST_SLEEP" \ + chCli SELECT 1 + +# Verify the initdb script ran and created the table with the expected data +chCli SHOW TABLES IN test_db | grep '^test_table$' >/dev/null +[ "$(chCli 'SELECT SUM(value) FROM test_db.test_table')" = 300 ] diff --git a/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-no-shell/run.sh b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-no-shell/run.sh new file mode 100755 index 000000000000..c5319f120446 --- /dev/null +++ b/ci/jobs/scripts/docker_server/tests/clickhouse-distroless-no-shell/run.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Verify the distroless production image contains no shell. +# This is the key property of a distroless image: /bin/sh, /bin/bash, +# and other shells must be absent to reduce the attack surface. +set -eo pipefail + +image="$1" + +if docker run --rm --entrypoint /bin/sh "$image" -c "echo bad" 2>/dev/null; then + echo "FAIL: /bin/sh should not exist in the distroless image" >&2 + exit 1 +fi + +if docker run --rm --entrypoint /bin/bash "$image" -c "echo bad" 2>/dev/null; then + echo "FAIL: /bin/bash should not exist in the distroless image" >&2 + exit 1 +fi From cc6419ff735c73bc05bbbfe222a9a6f0306a47e0 Mon Sep 17 00:00:00 2001 From: Rahul <254529899+motsc@users.noreply.github.com> Date: Mon, 27 Apr 2026 01:33:57 -0700 Subject: [PATCH 52/70] Refresh distroless base image digests to pick up libssl3t64 3.5.5-1~deb13u2 Mend.io scan found 1 CRITICAL + 4 HIGH CVEs in libssl3t64 3.5.5-1~deb13u1 (CVE-2026-31789, CVE-2026-28387..28390). All fixed in 3.5.5-1~deb13u2. Pin digests from 2026-04-26. --- docker/keeper/Dockerfile.distroless | 4 ++-- docker/server/Dockerfile.distroless | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/keeper/Dockerfile.distroless b/docker/keeper/Dockerfile.distroless index 5e849d048773..5d76502d1d25 100644 --- a/docker/keeper/Dockerfile.distroless +++ b/docker/keeper/Dockerfile.distroless @@ -139,7 +139,7 @@ RUN mkdir -p \ # Stage 2: Production distroless image. # ────────────────────────────────────────────────────────────────────────────── # Pinned 2026-04-02. Refresh: docker pull gcr.io/distroless/cc-debian13:nonroot && docker inspect --format='{{index .RepoDigests 0}}' gcr.io/distroless/cc-debian13:nonroot -FROM gcr.io/distroless/cc-debian13:nonroot@sha256:9c4fe2381c2e6d53c4cfdefeff6edbd2a67ec7713e2c3ca6653806cbdbf27a1e AS production +FROM gcr.io/distroless/cc-debian13:nonroot@sha256:8f960b7fc6a5d6e28bb07f982655925d6206678bd9a6cde2ad00ddb5e2077d78 AS production COPY --from=ch-builder /output/ / @@ -162,7 +162,7 @@ ENTRYPOINT ["/usr/bin/clickhouse", "docker-init", "--keeper"] # at /busybox/sh for interactive troubleshooting. # ────────────────────────────────────────────────────────────────────────────── # Pinned 2026-04-02. Refresh: docker pull gcr.io/distroless/cc-debian13:debug-nonroot && docker inspect --format='{{index .RepoDigests 0}}' gcr.io/distroless/cc-debian13:debug-nonroot -FROM gcr.io/distroless/cc-debian13:debug-nonroot@sha256:d47b319b1047dff7cdee335e3e61468f3610fac20060653aabe3786d6ecba621 AS debug +FROM gcr.io/distroless/cc-debian13:debug-nonroot@sha256:55dd32378f7562c890342098a04726f4ef386bb86c87bec3db6ed4eef27d99fb AS debug COPY --from=ch-builder /output/ / diff --git a/docker/server/Dockerfile.distroless b/docker/server/Dockerfile.distroless index 07da5d16fd08..3456ded334c8 100644 --- a/docker/server/Dockerfile.distroless +++ b/docker/server/Dockerfile.distroless @@ -157,7 +157,7 @@ RUN { \ # Stage 2: Production distroless image. # ────────────────────────────────────────────────────────────────────────────── # Pinned 2026-04-02. Refresh: docker pull gcr.io/distroless/cc-debian13:nonroot && docker inspect --format='{{index .RepoDigests 0}}' gcr.io/distroless/cc-debian13:nonroot -FROM gcr.io/distroless/cc-debian13:nonroot@sha256:9c4fe2381c2e6d53c4cfdefeff6edbd2a67ec7713e2c3ca6653806cbdbf27a1e AS production +FROM gcr.io/distroless/cc-debian13:nonroot@sha256:8f960b7fc6a5d6e28bb07f982655925d6206678bd9a6cde2ad00ddb5e2077d78 AS production COPY --from=ch-builder /output/ / @@ -180,7 +180,7 @@ ENTRYPOINT ["/usr/bin/clickhouse", "docker-init"] # at /busybox/sh for interactive troubleshooting. # ────────────────────────────────────────────────────────────────────────────── # Pinned 2026-04-02. Refresh: docker pull gcr.io/distroless/cc-debian13:debug-nonroot && docker inspect --format='{{index .RepoDigests 0}}' gcr.io/distroless/cc-debian13:debug-nonroot -FROM gcr.io/distroless/cc-debian13:debug-nonroot@sha256:d47b319b1047dff7cdee335e3e61468f3610fac20060653aabe3786d6ecba621 AS debug +FROM gcr.io/distroless/cc-debian13:debug-nonroot@sha256:55dd32378f7562c890342098a04726f4ef386bb86c87bec3db6ed4eef27d99fb AS debug COPY --from=ch-builder /output/ / From fac060e93b9eab99d00c3166485ebc4c1323f47f Mon Sep 17 00:00:00 2001 From: robot-ch-test-poll4 <69306974+robot-ch-test-poll4@users.noreply.github.com> Date: Tue, 28 Apr 2026 14:16:10 +0200 Subject: [PATCH 53/70] Backport #103334 to 26.3: Fix Parquet ColumnIndex stats min_value > max_value for String columns (#103666) Co-authored-by: robot-clickhouse --- src/Processors/Formats/Impl/Parquet/Write.cpp | 23 +++++----- src/Processors/Formats/Impl/Parquet/Write.h | 3 ++ .../tests/gtest_write_parquet_page_index.cpp | 42 +++++++++++++++++++ 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/src/Processors/Formats/Impl/Parquet/Write.cpp b/src/Processors/Formats/Impl/Parquet/Write.cpp index 99737d7ff3bd..abb1a7515699 100644 --- a/src/Processors/Formats/Impl/Parquet/Write.cpp +++ b/src/Processors/Formats/Impl/Parquet/Write.cpp @@ -223,14 +223,12 @@ struct StatisticsStringRef parq::Statistics s; if (min.ptr == nullptr) return s; - if (static_cast(min.len) <= options.max_statistics_size) + if (static_cast(min.len) <= options.max_statistics_size + && static_cast(max.len) <= options.max_statistics_size) { s.__set_min_value(std::string(reinterpret_cast(min.ptr), static_cast(min.len))); - s.__set_is_min_value_exact(true); - } - if (static_cast(max.len) <= options.max_statistics_size) - { s.__set_max_value(std::string(reinterpret_cast(max.ptr), static_cast(max.len))); + s.__set_is_min_value_exact(true); s.__set_is_max_value_exact(true); } return s; @@ -286,14 +284,12 @@ struct StatisticsStringCopy parq::Statistics s; if (empty) return s; - if (min.size() <= options.max_statistics_size) + if (min.size() <= options.max_statistics_size + && max.size() <= options.max_statistics_size) { s.__set_min_value(std::string(min.data(), min.size())); - s.__set_is_min_value_exact(true); - } - if (max.size() <= options.max_statistics_size) - { s.__set_max_value(std::string(max.data(), max.size())); + s.__set_is_min_value_exact(true); s.__set_is_max_value_exact(true); } return s; @@ -910,6 +906,10 @@ void writeColumnImpl( if (options.write_page_index) { bool all_null_page = data_count == 0; + bool has_stats = page_stats.__isset.min_value && page_stats.__isset.max_value; + if (!all_null_page && !has_stats) + s.indexes.column_index_valid = false; + s.indexes.column_index.min_values.push_back(page_stats.min_value); s.indexes.column_index.max_values.push_back(page_stats.max_value); if (has_null_count) @@ -1359,6 +1359,9 @@ static void writePageIndex(FileWriteState & file, WriteBuffer & out) chassert(rg.column_indexes.size() == rg.row_group.columns.size()); for (size_t j = 0; j < rg.column_indexes.size(); ++j) { + if (!rg.column_indexes.at(j).column_index_valid) + continue; + auto & column = rg.row_group.columns.at(j); column.__set_column_index_offset(file.offset); size_t length = serializeThriftStruct(rg.column_indexes.at(j).column_index, out); diff --git a/src/Processors/Formats/Impl/Parquet/Write.h b/src/Processors/Formats/Impl/Parquet/Write.h index 1571cada52d6..7db9118333ba 100644 --- a/src/Processors/Formats/Impl/Parquet/Write.h +++ b/src/Processors/Formats/Impl/Parquet/Write.h @@ -76,6 +76,9 @@ struct ColumnChunkIndexes { parq::ColumnIndex column_index; // if write_page_index parq::OffsetIndex offset_index; // if write_page_index + /// Set to false when a non-null page has stats dropped (e.g. value exceeded max_statistics_size). + /// When false, the column index must not be written because it would contain invalid bounds. + bool column_index_valid = true; parq::BloomFilterHeader bloom_filter_header; PODArray bloom_filter_data; // if write_bloom_filter, and not flushed yet }; diff --git a/src/Processors/tests/gtest_write_parquet_page_index.cpp b/src/Processors/tests/gtest_write_parquet_page_index.cpp index 789f3beca67a..9674703dcbfd 100644 --- a/src/Processors/tests/gtest_write_parquet_page_index.cpp +++ b/src/Processors/tests/gtest_write_parquet_page_index.cpp @@ -367,5 +367,47 @@ TEST(Parquet, WriteParquetPageIndexArrowEncoder) /// arrow doesn't write statistics to data page headers /*expect_statistics_in_page_headers*/ false); } + +/// Regression test for https://github.com/ClickHouse/ClickHouse/issues/103039 +/// When a page has a short min and a long max (exceeding max_statistics_size=4096), +/// the column index must not be written because it would contain invalid bounds +/// (e.g. min_value="a", max_value="" which violates min <= max). +TEST(Parquet, WriteParquetPageIndexOversizedStringStats) +{ + FormatSettings format_settings; + format_settings.parquet.row_group_rows = 10000; + format_settings.parquet.use_custom_encoder = true; + format_settings.parquet.parallel_encoding = false; + format_settings.parquet.write_page_index = true; + format_settings.parquet.data_page_size = 32; + + std::vector> values; + std::vector col; + col.push_back("a"); + col.push_back(String(5000, 'z')); + values.push_back(col); + + auto source = multiColumnsSource( + {std::make_shared()}, values, 1); + String path = "/tmp/test_oversized_stats.parquet"; + writeParquet(source, format_settings, path); + + auto reader = parquet::ParquetFileReader::OpenFile(path); + auto metadata = reader->metadata(); + + ASSERT_EQ(metadata->num_row_groups(), 1); + auto row_group = metadata->RowGroup(0); + ASSERT_EQ(row_group->num_columns(), 1); + + auto column_chunk = row_group->ColumnChunk(0); + auto column_index_location = column_chunk->GetColumnIndexLocation(); + auto offset_index_location = column_chunk->GetOffsetIndexLocation(); + + ASSERT_FALSE(column_index_location.has_value()); + + ASSERT_TRUE(offset_index_location.has_value()); + ASSERT_GT(offset_index_location.value().offset, 0); + ASSERT_GT(offset_index_location.value().length, 0); +} } #endif From d7e1dc8a4ebd16f1e9e6f8e1aa74bb0ebc537d57 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 29 Apr 2026 13:48:27 +0000 Subject: [PATCH 54/70] Backport #100777 to 26.3: Fix: Fix workload IO scheduling bypass in DiskObjectStorageTransaction write path --- .../DiskObjectStorage/DiskObjectStorage.cpp | 27 +--- .../DiskObjectStorage/DiskObjectStorage.h | 1 + .../DiskObjectStorageTransaction.cpp | 32 +++-- .../DiskObjectStorageTransaction.h | 10 +- .../IOSchedulingSettings.cpp | 41 ++++++ .../DiskObjectStorage/IOSchedulingSettings.h | 14 ++ .../configs/storage_configuration.xml | 43 ++++++ tests/integration/test_scheduler/test.py | 122 ++++++++++++++++++ 8 files changed, 256 insertions(+), 34 deletions(-) create mode 100644 src/Disks/DiskObjectStorage/IOSchedulingSettings.cpp create mode 100644 src/Disks/DiskObjectStorage/IOSchedulingSettings.h diff --git a/src/Disks/DiskObjectStorage/DiskObjectStorage.cpp b/src/Disks/DiskObjectStorage/DiskObjectStorage.cpp index 4b9c09b88565..4afdc245699f 100644 --- a/src/Disks/DiskObjectStorage/DiskObjectStorage.cpp +++ b/src/Disks/DiskObjectStorage/DiskObjectStorage.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -11,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -60,12 +60,12 @@ ObjectStoragePtr DiskObjectStorage::getObjectStorage() DiskTransactionPtr DiskObjectStorage::createObjectStorageTransaction() { - return std::make_shared(cluster, metadata_storage, object_storages, blob_killer, wait_blob_removal); + return std::make_shared(cluster, metadata_storage, object_storages, blob_killer, wait_blob_removal, getReadResourceName(), getWriteResourceName()); } DiskTransactionPtr DiskObjectStorage::createObjectStorageTransactionToAnotherDisk(DiskObjectStorage & to_disk) { - return std::make_shared(cluster, metadata_storage, object_storages, to_disk.cluster, to_disk.metadata_storage, to_disk.object_storages); + return std::make_shared(cluster, metadata_storage, object_storages, to_disk.cluster, to_disk.metadata_storage, to_disk.object_storages, getReadResourceName(), to_disk.getWriteResourceName()); } DiskObjectStorage::DiskObjectStorage( @@ -274,7 +274,7 @@ void DiskObjectStorage::copyFile( /// NOLINT /// It may use s3-server-side copy auto & to_disk_object_storage = dynamic_cast(to_disk); auto transaction = createObjectStorageTransactionToAnotherDisk(to_disk_object_storage); - transaction->copyFile(from_file_path, to_file_path, /*read_settings*/ {}, /*write_settings*/ {}); + transaction->copyFile(from_file_path, to_file_path, read_settings, write_settings); transaction->commit(); } else @@ -718,22 +718,6 @@ bool DiskObjectStorage::supportsHardLinks() const return !metadata_storage->isWriteOnce() && !metadata_storage->isPlain(); } -template -static inline Settings updateIOSchedulingSettings(const Settings & settings, const String & read_resource_name, const String & write_resource_name) -{ - if (read_resource_name.empty() && write_resource_name.empty()) - return settings; - if (auto query_context = CurrentThread::tryGetQueryContext()) - { - Settings result(settings); - if (!read_resource_name.empty()) - result.io_scheduling.read_resource_link = query_context->getWorkloadClassifier()->get(read_resource_name); - if (!write_resource_name.empty()) - result.io_scheduling.write_resource_link = query_context->getWorkloadClassifier()->get(write_resource_name); - return result; - } - return settings; -} String DiskObjectStorage::getReadResourceName() const { @@ -916,9 +900,8 @@ std::unique_ptr DiskObjectStorage::writeFile( { LOG_TEST(log, "Write file: {}", path); - WriteSettings write_settings = updateIOSchedulingSettings(settings, getReadResourceName(), getWriteResourceName()); auto transaction = createObjectStorageTransaction(); - return transaction->writeFileWithAutoCommit(path, buf_size, mode, write_settings); + return transaction->writeFileWithAutoCommit(path, buf_size, mode, settings); } Strings DiskObjectStorage::getBlobPath(const String & path) const diff --git a/src/Disks/DiskObjectStorage/DiskObjectStorage.h b/src/Disks/DiskObjectStorage/DiskObjectStorage.h index 1bfbcaf1e496..747c8cfb794b 100644 --- a/src/Disks/DiskObjectStorage/DiskObjectStorage.h +++ b/src/Disks/DiskObjectStorage/DiskObjectStorage.h @@ -7,6 +7,7 @@ #include #include #include +#include #include diff --git a/src/Disks/DiskObjectStorage/DiskObjectStorageTransaction.cpp b/src/Disks/DiskObjectStorage/DiskObjectStorageTransaction.cpp index f25ef65246ee..f1547c6d4e98 100644 --- a/src/Disks/DiskObjectStorage/DiskObjectStorageTransaction.cpp +++ b/src/Disks/DiskObjectStorage/DiskObjectStorageTransaction.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -72,12 +73,16 @@ DiskObjectStorageTransaction::DiskObjectStorageTransaction( MetadataStoragePtr metadata_storage_, ObjectStorageRouterPtr object_storages_, BlobKillerThreadPtr blob_killer_, - bool wait_blob_removal_) + bool wait_blob_removal_, + String read_resource_name_, + String write_resource_name_) : cluster(std::move(cluster_)) , metadata_storage(std::move(metadata_storage_)) , object_storages(std::move(object_storages_)) , blob_killer(std::move(blob_killer_)) , wait_blob_removal(wait_blob_removal_) + , read_resource_name(std::move(read_resource_name_)) + , write_resource_name(std::move(write_resource_name_)) , metadata_transaction(metadata_storage->createTransaction()) { } @@ -88,8 +93,10 @@ MultipleDisksObjectStorageTransaction::MultipleDisksObjectStorageTransaction( ObjectStorageRouterPtr source_object_storages_, ClusterConfigurationPtr destination_cluster_, MetadataStoragePtr destination_metadata_storage_, - ObjectStorageRouterPtr destination_object_storages_) - : DiskObjectStorageTransaction(destination_cluster_, destination_metadata_storage_, destination_object_storages_, /*blob_killer=*/nullptr, /*wait_blob_removal=*/false) + ObjectStorageRouterPtr destination_object_storages_, + std::string read_resource_name_, + std::string write_resource_name_) + : DiskObjectStorageTransaction(destination_cluster_, destination_metadata_storage_, destination_object_storages_, /*blob_killer=*/nullptr, /*wait_blob_removal=*/false, std::move(read_resource_name_), std::move(write_resource_name_)) , source_cluster(std::move(source_cluster_)) , source_metadata_storage(std::move(source_metadata_storage_)) , source_object_storages(std::move(source_object_storages_)) @@ -253,6 +260,8 @@ std::unique_ptr DiskObjectStorageTransaction::writeFile { LOG_TEST(getLogger("DiskObjectStorageTransaction"), "write file {} mode {} autocommit {}", path, mode, autocommit); + WriteSettings enriched_settings = updateIOSchedulingSettings(settings, read_resource_name, write_resource_name); + /// NOTE: We check it here and not after writing blob because in case of plain/plain-rewritable metadata storages /// undo of disk tx will actually remove existing data. if (mode == WriteMode::Append && !metadata_storage->supportWritingWithAppend()) @@ -271,10 +280,10 @@ std::unique_ptr DiskObjectStorageTransaction::writeFile ObjectStoragePtr object_storage = object_storages->takePointingTo(location); #if ENABLE_DISTRIBUTED_CACHE - bool use_distributed_cache = DistributedCache::canUseDistributedCacheForWrite(settings, *object_storage); + bool use_distributed_cache = DistributedCache::canUseDistributedCacheForWrite(enriched_settings, *object_storage); - if (use_distributed_cache && settings.distributed_cache_settings.write_through_cache_buffer_size) - use_buffer_size = settings.distributed_cache_settings.write_through_cache_buffer_size; + if (use_distributed_cache && enriched_settings.distributed_cache_settings.write_through_cache_buffer_size) + use_buffer_size = enriched_settings.distributed_cache_settings.write_through_cache_buffer_size; #endif writer = object_storage->writeObject( @@ -283,11 +292,11 @@ std::unique_ptr DiskObjectStorageTransaction::writeFile WriteMode::Rewrite, /*attributes=*/std::nullopt, use_buffer_size, - settings); + enriched_settings); #if ENABLE_DISTRIBUTED_CACHE if (use_distributed_cache) - writer = DistributedCache::writeWithDistributedCache(path, object, settings, *object_storage, std::move(writer)); + writer = DistributedCache::writeWithDistributedCache(path, object, enriched_settings, *object_storage, std::move(writer)); #endif } else @@ -298,7 +307,7 @@ std::unique_ptr DiskObjectStorageTransaction::writeFile WriteMode::Rewrite, /*attributes=*/std::nullopt, use_buffer_size, - settings); + enriched_settings); } writers.push_back(std::move(writer)); @@ -475,6 +484,9 @@ void DiskObjectStorageTransaction::copyFile(const std::string & from_file_path, void MultipleDisksObjectStorageTransaction::copyFile(const std::string & from_file_path, const std::string & to_file_path, const ReadSettings & read_settings, const WriteSettings & write_settings) { + auto enriched_read_settings = updateIOSchedulingSettings(read_settings, read_resource_name, write_resource_name); + auto enriched_write_settings = updateIOSchedulingSettings(write_settings, read_resource_name, write_resource_name); + const auto blobs_to_copy = source_metadata_storage->getStorageObjects(from_file_path); const auto blobs_to_create = blobs_to_copy | std::views::transform([&](const auto & from) { return StoredObject(metadata_transaction->generateObjectKeyForPath(to_file_path).serialize(), to_file_path, from.bytes_size); }) @@ -489,7 +501,7 @@ void MultipleDisksObjectStorageTransaction::copyFile(const std::string & from_fi for (const auto [src_blob, dst_blob] : std::views::zip(blobs_to_copy, blobs_to_create)) { written_blobs[location].push_back(dst_blob); - source_object_storages->takePointingTo(source_local_location)->copyObjectToAnotherObjectStorage(src_blob, dst_blob, read_settings, write_settings, *object_storages->takePointingTo(location)); + source_object_storages->takePointingTo(source_local_location)->copyObjectToAnotherObjectStorage(src_blob, dst_blob, enriched_read_settings, enriched_write_settings, *object_storages->takePointingTo(location)); } } diff --git a/src/Disks/DiskObjectStorage/DiskObjectStorageTransaction.h b/src/Disks/DiskObjectStorage/DiskObjectStorageTransaction.h index ecbd5f7e5f34..aa3fc3529b0f 100644 --- a/src/Disks/DiskObjectStorage/DiskObjectStorageTransaction.h +++ b/src/Disks/DiskObjectStorage/DiskObjectStorageTransaction.h @@ -28,6 +28,8 @@ struct DiskObjectStorageTransaction : public IDiskTransaction, public std::enabl const ObjectStorageRouterPtr object_storages; const BlobKillerThreadPtr blob_killer; const bool wait_blob_removal; + const std::string read_resource_name; + const std::string write_resource_name; MetadataTransactionPtr metadata_transaction; std::vector> operations_to_execute; @@ -39,7 +41,9 @@ struct DiskObjectStorageTransaction : public IDiskTransaction, public std::enabl MetadataStoragePtr metadata_storage_, ObjectStorageRouterPtr object_storages_, BlobKillerThreadPtr blob_killer_, - bool wait_blob_removal_); + bool wait_blob_removal_, + std::string read_resource_name_, + std::string write_resource_name_); void commit() override; TransactionCommitOutcomeVariant tryCommit(const TransactionCommitOptionsVariant & options) override; @@ -116,7 +120,9 @@ struct MultipleDisksObjectStorageTransaction final : public DiskObjectStorageTra ObjectStorageRouterPtr source_object_storages_, ClusterConfigurationPtr destination_cluster_, MetadataStoragePtr destination_metadata_storage_, - ObjectStorageRouterPtr destination_object_storages_); + ObjectStorageRouterPtr destination_object_storages_, + std::string read_resource_name_, + std::string write_resource_name_); void copyFile(const std::string & from_file_path, const std::string & to_file_path, const ReadSettings & read_settings, const WriteSettings &) override; }; diff --git a/src/Disks/DiskObjectStorage/IOSchedulingSettings.cpp b/src/Disks/DiskObjectStorage/IOSchedulingSettings.cpp new file mode 100644 index 000000000000..a5f6c86c6070 --- /dev/null +++ b/src/Disks/DiskObjectStorage/IOSchedulingSettings.cpp @@ -0,0 +1,41 @@ +#include +#include +#include +#include + +namespace DB +{ + +namespace +{ + +template +Settings updateIOSchedulingSettingsImpl(const Settings & settings, const std::string & read_resource_name, const std::string & write_resource_name) +{ + if (read_resource_name.empty() && write_resource_name.empty()) + return settings; + if (auto query_context = CurrentThread::tryGetQueryContext()) + { + Settings result(settings); + if (!read_resource_name.empty()) + result.io_scheduling.read_resource_link = query_context->getWorkloadClassifier()->get(read_resource_name); + if (!write_resource_name.empty()) + result.io_scheduling.write_resource_link = query_context->getWorkloadClassifier()->get(write_resource_name); + return result; + } + return settings; +} + +} + +ReadSettings updateIOSchedulingSettings(const ReadSettings & settings, const std::string & read_resource_name, const std::string & write_resource_name) +{ + return updateIOSchedulingSettingsImpl(settings, read_resource_name, write_resource_name); +} + +WriteSettings updateIOSchedulingSettings(const WriteSettings & settings, const std::string & read_resource_name, const std::string & write_resource_name) +{ + return updateIOSchedulingSettingsImpl(settings, read_resource_name, write_resource_name); +} + +} diff --git a/src/Disks/DiskObjectStorage/IOSchedulingSettings.h b/src/Disks/DiskObjectStorage/IOSchedulingSettings.h new file mode 100644 index 000000000000..9b29a737defc --- /dev/null +++ b/src/Disks/DiskObjectStorage/IOSchedulingSettings.h @@ -0,0 +1,14 @@ +#pragma once + +#include +#include + +#include + +namespace DB +{ + +ReadSettings updateIOSchedulingSettings(const ReadSettings & settings, const std::string & read_resource_name, const std::string & write_resource_name); +WriteSettings updateIOSchedulingSettings(const WriteSettings & settings, const std::string & read_resource_name, const std::string & write_resource_name); + +} diff --git a/tests/integration/test_scheduler/configs/storage_configuration.xml b/tests/integration/test_scheduler/configs/storage_configuration.xml index 385710326ae6..238ac70b70a7 100644 --- a/tests/integration/test_scheduler/configs/storage_configuration.xml +++ b/tests/integration/test_scheduler/configs/storage_configuration.xml @@ -22,6 +22,32 @@ 10 10 + + + s3 + http://minio1:9001/root/data/ + minio + ClickHouse_Minio_P@ssw0rd + 33554432 + 10 + 10 + network_read + network_write + false + + + s3 + http://minio1:9001/root/data2/ + minio + ClickHouse_Minio_P@ssw0rd + 33554432 + 10 + 10 + network_read + network_write + false + @@ -38,6 +64,23 @@ + + +
+ s3_no_fake_tx +
+
+
+ + + + s3_no_fake_tx + + + s3_no_fake_tx_2 + + +
diff --git a/tests/integration/test_scheduler/test.py b/tests/integration/test_scheduler/test.py index af97efbd5d0a..26cba12cc368 100644 --- a/tests/integration/test_scheduler/test.py +++ b/tests/integration/test_scheduler/test.py @@ -228,6 +228,128 @@ def test_s3_resource_request_granularity(): check_profile_event_for_query("admin", "SchedulerIOReadBytes", read_bytes) +def test_s3_disk_transaction_path_resource_scheduling(): + """ + Test that workload IO scheduling works when writes go through the real + `DiskObjectStorageTransaction` path (i.e. `use_fake_transaction=false`). + + With the regular `s3` disk, `use_fake_transaction` defaults to `true` and writes are + routed through `FakeDiskTransaction` -> `DiskObjectStorage::writeFile` -> + `updateIOSchedulingSettings`, so the resource link is always set correctly. + When `use_fake_transaction=false` (which is the default for `s3_with_keeper` / + Keeper metadata storage), writes go directly through + `DiskObjectStorageTransaction::writeFile`. Without the fix in + `DiskObjectStorageTransaction::writeFileImpl`, the `WriteSettings` passed by + `MergeTreeDataWriter::writeTempPart` had no resource link, so S3 uploads + bypassed the IO scheduler entirely. + """ + import uuid + + node.query( + """ + drop table if exists data; + create table data (key UInt64 CODEC(NONE), value String CODEC(NONE)) + engine=MergeTree() order by key + settings min_bytes_for_wide_part=1e9, storage_policy='s3_no_fake_tx'; + """ + ) + + total_bytes = 50000000 # ~50 MB of raw data + query_id = str(uuid.uuid4()) + node.query( + "insert into data select number, randomString(10000000) from numbers(5)" + " SETTINGS workload='admin'", + query_id=query_id, + ) + + node.query("system flush logs") + + write_requests = int( + node.query( + f"select ProfileEvents['SchedulerIOWriteRequests'] from system.query_log" + f" where query_id='{query_id}' and type='QueryFinish'" + ).strip() + ) + write_bytes = int( + node.query( + f"select ProfileEvents['SchedulerIOWriteBytes'] from system.query_log" + f" where query_id='{query_id}' and type='QueryFinish'" + ).strip() + ) + + assert ( + write_requests > 0 + ), "No write requests were scheduled through the workload IO scheduler (DiskObjectStorageTransaction path)" + assert write_bytes > total_bytes, ( + f"Expected at least {total_bytes} bytes to be scheduled, got {write_bytes}" + ) + + node.query("drop table data") + + +def test_s3_disk_move_partition_resource_scheduling(): + """ + Test that workload IO scheduling works when data is moved between S3 disks + via `ALTER TABLE ... MOVE PARTITION`, which goes through + `MultipleDisksObjectStorageTransaction::copyFile`. + """ + import uuid + + node.query( + """ + drop table if exists data_move; + create table data_move (key UInt64 CODEC(NONE), value String CODEC(NONE)) + engine=MergeTree() order by key partition by key + settings min_bytes_for_wide_part=1e9, storage_policy='s3_no_fake_tx_move'; + """ + ) + + node.query( + "insert into data_move select 0, randomString(10000000) from numbers(5)" + " SETTINGS workload='admin'" + ) + + query_id = str(uuid.uuid4()) + node.query( + "alter table data_move move partition 0 to disk 's3_no_fake_tx_2'" + " SETTINGS workload='admin'", + query_id=query_id, + ) + + node.query("system flush logs") + + read_requests = int( + node.query( + f"select ProfileEvents['SchedulerIOReadRequests'] from system.query_log" + f" where query_id='{query_id}' and type='QueryFinish'" + ).strip() + ) + write_requests = int( + node.query( + f"select ProfileEvents['SchedulerIOWriteRequests'] from system.query_log" + f" where query_id='{query_id}' and type='QueryFinish'" + ).strip() + ) + write_bytes = int( + node.query( + f"select ProfileEvents['SchedulerIOWriteBytes'] from system.query_log" + f" where query_id='{query_id}' and type='QueryFinish'" + ).strip() + ) + + assert ( + read_requests > 0 + ), "No read requests were scheduled through the workload IO scheduler (MultipleDisksObjectStorageTransaction path)" + assert ( + write_requests > 0 + ), "No write requests were scheduled through the workload IO scheduler (MultipleDisksObjectStorageTransaction path)" + assert ( + write_bytes > 0 + ), "No write bytes were scheduled through the workload IO scheduler (MultipleDisksObjectStorageTransaction path)" + + node.query("drop table data_move") + + def test_s3_disk(): node.query( f""" From 454d8a99d4c62443a02a088473187d7d37927050 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Thu, 30 Apr 2026 03:23:02 +0000 Subject: [PATCH 55/70] Backport #103552 to 26.3: Fix masking nested credentials in logs --- .../ASTFunctionWithKeyValueArguments.cpp | 2 +- .../test_mask_sensitive_info/test.py | 45 +++++++++++++++++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/Parsers/ASTFunctionWithKeyValueArguments.cpp b/src/Parsers/ASTFunctionWithKeyValueArguments.cpp index c4aaad68c1ae..c19e38a32687 100644 --- a/src/Parsers/ASTFunctionWithKeyValueArguments.cpp +++ b/src/Parsers/ASTFunctionWithKeyValueArguments.cpp @@ -59,7 +59,7 @@ void ASTPair::formatImpl(WriteBuffer & ostr, const FormatSettings & settings, Fo bool ASTPair::hasSecretParts() const { - return first == "password"; + return (first == "password") || second->hasSecretParts(); } diff --git a/tests/integration/test_mask_sensitive_info/test.py b/tests/integration/test_mask_sensitive_info/test.py index 96b60a0d53dc..b2a84eebe6d6 100644 --- a/tests/integration/test_mask_sensitive_info/test.py +++ b/tests/integration/test_mask_sensitive_info/test.py @@ -798,35 +798,74 @@ def test_encryption_functions(): def test_create_dictionary(): password = new_password() + # ClickHouse source. node.query( f"CREATE DICTIONARY dict1 (n int DEFAULT 0, m int DEFAULT 1) PRIMARY KEY n " f"SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'user1' TABLE 'test' PASSWORD '{password}' DB 'default')) " f"LIFETIME(MIN 0 MAX 10) LAYOUT(FLAT())" ) + # HTTP source with top-level USER/PASSWORD keys. + node.query( + f"CREATE DICTIONARY dict2 (n int DEFAULT 0) PRIMARY KEY n " + f"SOURCE(HTTP(url 'http://localhost:8123/dict.tsv' format 'TabSeparated' user 'huser' password '{password}')) " + f"LIFETIME(MIN 0 MAX 10) LAYOUT(FLAT())" + ) + + # HTTP source with nested CREDENTIALS(USER ... PASSWORD ...). + node.query( + f"CREATE DICTIONARY dict3 (n int DEFAULT 0) PRIMARY KEY n " + f"SOURCE(HTTP(url 'http://localhost:8123/dict.tsv' format 'TabSeparated' credentials(user 'huser' password '{password}'))) " + f"LIFETIME(MIN 0 MAX 10) LAYOUT(FLAT())" + ) + for toggle, secret in enumerate(["[HIDDEN]", password]): assert ( node.query(f"SHOW CREATE TABLE dict1 {show_secrets}={toggle}") == f"CREATE DICTIONARY default.dict1\\n(\\n `n` int DEFAULT 0,\\n `m` int DEFAULT 1\\n)\\nPRIMARY KEY n\\nSOURCE(CLICKHOUSE(HOST \\'localhost\\' PORT 9000 USER \\'user1\\' TABLE \\'test\\' PASSWORD \\'{secret}\\' DB \\'default\\'))\\nLIFETIME(MIN 0 MAX 10)\\nLAYOUT(FLAT())\n" ) + assert ( + node.query(f"SHOW CREATE TABLE dict2 {show_secrets}={toggle}") + == f"CREATE DICTIONARY default.dict2\\n(\\n `n` int DEFAULT 0\\n)\\nPRIMARY KEY n\\nSOURCE(HTTP(URL \\'http://localhost:8123/dict.tsv\\' FORMAT \\'TabSeparated\\' USER \\'huser\\' PASSWORD \\'{secret}\\'))\\nLIFETIME(MIN 0 MAX 10)\\nLAYOUT(FLAT())\n" + ) + + assert ( + node.query(f"SHOW CREATE TABLE dict3 {show_secrets}={toggle}") + == f"CREATE DICTIONARY default.dict3\\n(\\n `n` int DEFAULT 0\\n)\\nPRIMARY KEY n\\nSOURCE(HTTP(URL \\'http://localhost:8123/dict.tsv\\' FORMAT \\'TabSeparated\\' CREDENTIALS (USER \\'huser\\' PASSWORD \\'{secret}\\')))\\nLIFETIME(MIN 0 MAX 10)\\nLAYOUT(FLAT())\n" + ) + assert ( node.query( - f"SELECT create_table_query FROM system.tables WHERE name = 'dict1' {show_secrets}={toggle}" + f"SELECT create_table_query FROM system.tables WHERE name IN ['dict1', 'dict2', 'dict3'] ORDER BY name {show_secrets}={toggle}" + ) + == ( + f"CREATE DICTIONARY default.dict1 (`n` int DEFAULT 0, `m` int DEFAULT 1) PRIMARY KEY n SOURCE(CLICKHOUSE(HOST \\'localhost\\' PORT 9000 USER \\'user1\\' TABLE \\'test\\' PASSWORD \\'{secret}\\' DB \\'default\\')) LIFETIME(MIN 0 MAX 10) LAYOUT(FLAT())\n" + f"CREATE DICTIONARY default.dict2 (`n` int DEFAULT 0) PRIMARY KEY n SOURCE(HTTP(URL \\'http://localhost:8123/dict.tsv\\' FORMAT \\'TabSeparated\\' USER \\'huser\\' PASSWORD \\'{secret}\\')) LIFETIME(MIN 0 MAX 10) LAYOUT(FLAT())\n" + f"CREATE DICTIONARY default.dict3 (`n` int DEFAULT 0) PRIMARY KEY n SOURCE(HTTP(URL \\'http://localhost:8123/dict.tsv\\' FORMAT \\'TabSeparated\\' CREDENTIALS (USER \\'huser\\' PASSWORD \\'{secret}\\'))) LIFETIME(MIN 0 MAX 10) LAYOUT(FLAT())\n" ) - == f"CREATE DICTIONARY default.dict1 (`n` int DEFAULT 0, `m` int DEFAULT 1) PRIMARY KEY n SOURCE(CLICKHOUSE(HOST \\'localhost\\' PORT 9000 USER \\'user1\\' TABLE \\'test\\' PASSWORD \\'{secret}\\' DB \\'default\\')) LIFETIME(MIN 0 MAX 10) LAYOUT(FLAT())\n" ) check_logs( must_contain=[ "CREATE DICTIONARY dict1 (`n` int DEFAULT 0, `m` int DEFAULT 1) PRIMARY KEY n " "SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'user1' TABLE 'test' PASSWORD '[HIDDEN]' DB 'default')) " - "LIFETIME(MIN 0 MAX 10) LAYOUT(FLAT())" + "LIFETIME(MIN 0 MAX 10) LAYOUT(FLAT())", + + "CREATE DICTIONARY dict2 (`n` int DEFAULT 0) PRIMARY KEY n " + "SOURCE(HTTP(URL 'http://localhost:8123/dict.tsv' FORMAT 'TabSeparated' USER 'huser' PASSWORD '[HIDDEN]')) " + "LIFETIME(MIN 0 MAX 10) LAYOUT(FLAT())", + + "CREATE DICTIONARY dict3 (`n` int DEFAULT 0) PRIMARY KEY n " + "SOURCE(HTTP(URL 'http://localhost:8123/dict.tsv' FORMAT 'TabSeparated' CREDENTIALS (USER 'huser' PASSWORD '[HIDDEN]'))) " + "LIFETIME(MIN 0 MAX 10) LAYOUT(FLAT())", ], must_not_contain=[password], ) node.query("DROP DICTIONARY dict1") + node.query("DROP DICTIONARY dict2") + node.query("DROP DICTIONARY dict3") def test_backup_to_s3(): From fa4ac6c9630be7f00248b6867572ebab09e138d2 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Thu, 30 Apr 2026 14:58:38 +0000 Subject: [PATCH 56/70] Backport #103773 to 26.3: Fix UB while parsing dateTime --- src/IO/parseDateTimeBestEffort.cpp | 4 ++++ tests/queries/0_stateless/04143_ub_parsing_datetime.reference | 1 + tests/queries/0_stateless/04143_ub_parsing_datetime.sql | 1 + 3 files changed, 6 insertions(+) create mode 100644 tests/queries/0_stateless/04143_ub_parsing_datetime.reference create mode 100644 tests/queries/0_stateless/04143_ub_parsing_datetime.sql diff --git a/src/IO/parseDateTimeBestEffort.cpp b/src/IO/parseDateTimeBestEffort.cpp index a0b6cdf2d264..33be70954cad 100644 --- a/src/IO/parseDateTimeBestEffort.cpp +++ b/src/IO/parseDateTimeBestEffort.cpp @@ -120,6 +120,7 @@ ReturnType parseDateTimeBestEffortImpl( UInt8 second = 0; bool has_time = false; + bool has_fractional = false; bool has_time_zone_offset = false; bool time_zone_offset_negative = false; @@ -529,6 +530,9 @@ ReturnType parseDateTimeBestEffortImpl( { if (!has_time) return on_error(ErrorCodes::CANNOT_PARSE_DATETIME, "Cannot read DateTime: unexpected point symbol"); + if (has_fractional) + return on_error(ErrorCodes::CANNOT_PARSE_DATETIME, "Cannot read DateTime: duplicate fractional part"); + has_fractional = true; ++in.position(); num_digits = readDigits(digits, sizeof(digits), in); diff --git a/tests/queries/0_stateless/04143_ub_parsing_datetime.reference b/tests/queries/0_stateless/04143_ub_parsing_datetime.reference new file mode 100644 index 000000000000..dec7d2fabd2e --- /dev/null +++ b/tests/queries/0_stateless/04143_ub_parsing_datetime.reference @@ -0,0 +1 @@ +\N diff --git a/tests/queries/0_stateless/04143_ub_parsing_datetime.sql b/tests/queries/0_stateless/04143_ub_parsing_datetime.sql new file mode 100644 index 000000000000..100ef25a02c2 --- /dev/null +++ b/tests/queries/0_stateless/04143_ub_parsing_datetime.sql @@ -0,0 +1 @@ +SELECT parseDateTime64BestEffortOrNull('1970-01-01 00:00:00.99999999999999999.999999999999', 9); From 3ef9379ac6f94bea54a957451acc75b8a2fef06e Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Fri, 1 May 2026 05:32:04 +0000 Subject: [PATCH 57/70] Backport #101990 to 26.3: Fix Parquet metadata cache key collision for files in tar archives on S3 --- .../StorageObjectStorageSource.cpp | 4 +- ...4092_s3_tar_archive_union_schema.reference | 6 +++ .../04092_s3_tar_archive_union_schema.sh | 50 +++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/queries/0_stateless/04092_s3_tar_archive_union_schema.reference create mode 100755 tests/queries/0_stateless/04092_s3_tar_archive_union_schema.sh diff --git a/src/Storages/ObjectStorage/StorageObjectStorageSource.cpp b/src/Storages/ObjectStorage/StorageObjectStorageSource.cpp index 2a13d2d09603..015ddff8aefc 100644 --- a/src/Storages/ObjectStorage/StorageObjectStorageSource.cpp +++ b/src/Storages/ObjectStorage/StorageObjectStorageSource.cpp @@ -671,7 +671,9 @@ StorageObjectStorageSource::ReaderHolder StorageObjectStorageSource::createReade && (object_info->getFileFormat().value_or(configuration->format) == "Parquet") && !object_info->getObjectMetadata()->etag.empty()) { - const std::optional object_with_metadata = object_info->relative_path_with_metadata; + std::optional object_with_metadata = object_info->relative_path_with_metadata; + if (object_info->isArchive()) + object_with_metadata->relative_path = object_info->getPath(); input_format = FormatFactory::instance().getInputWithMetadata( object_info->getFileFormat().value_or(configuration->format), *read_buf, diff --git a/tests/queries/0_stateless/04092_s3_tar_archive_union_schema.reference b/tests/queries/0_stateless/04092_s3_tar_archive_union_schema.reference new file mode 100644 index 000000000000..1bcf93d21844 --- /dev/null +++ b/tests/queries/0_stateless/04092_s3_tar_archive_union_schema.reference @@ -0,0 +1,6 @@ +1 1 \N +2 2 \N +3 3 \N +4 4 hello +5 5 world +6 6 foo diff --git a/tests/queries/0_stateless/04092_s3_tar_archive_union_schema.sh b/tests/queries/0_stateless/04092_s3_tar_archive_union_schema.sh new file mode 100755 index 000000000000..d69e13e8ad13 --- /dev/null +++ b/tests/queries/0_stateless/04092_s3_tar_archive_union_schema.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Tags: no-fasttest +# Tag no-fasttest: Depends on S3 + +# Regression test for https://github.com/ClickHouse/ClickHouse/issues/101544 +# When reading a tar archive from S3 containing parquet files with different +# schemas using schema_inference_mode=union, columns present only in some +# files were silently returned as all-null due to Parquet metadata cache +# key collision: all files in the same archive shared the same cache key. + +set -e + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CUR_DIR"/../shell_config.sh + +S3_PATH="test/${CLICKHOUSE_DATABASE}_04092" + +# Create two parquet files with different schemas on S3 +$CLICKHOUSE_CLIENT -q " + INSERT INTO FUNCTION s3(s3_conn, url='http://localhost:11111/${S3_PATH}/test_1.parquet', format=Parquet) + SELECT number + 1 AS timestamp, number + 1.0 AS a + FROM numbers(3) + SETTINGS s3_truncate_on_insert=1 +" + +$CLICKHOUSE_CLIENT -q " + INSERT INTO FUNCTION s3(s3_conn, url='http://localhost:11111/${S3_PATH}/test_2.parquet', format=Parquet) + SELECT number + 4 AS timestamp, number + 4.0 AS a, toNullable(['hello', 'world', 'foo'][number + 1]) AS b + FROM numbers(3) + SETTINGS s3_truncate_on_insert=1 +" + +# Download the parquet files, create a tar archive, and upload it +TMP_DIR=$(mktemp -d) +trap "rm -rf $TMP_DIR" EXIT + +curl -s "http://localhost:11111/${S3_PATH}/test_1.parquet" -o "${TMP_DIR}/test_1.parquet" +curl -s "http://localhost:11111/${S3_PATH}/test_2.parquet" -o "${TMP_DIR}/test_2.parquet" +tar cf "${TMP_DIR}/test.parquet.tar" -C "${TMP_DIR}" test_1.parquet test_2.parquet +curl -s -X PUT "http://localhost:11111/${S3_PATH}/test.parquet.tar" --upload-file "${TMP_DIR}/test.parquet.tar" + +# Query with union mode — column b should have real values from test_2.parquet +$CLICKHOUSE_CLIENT -q " + SET schema_inference_mode = 'union'; + SET schema_inference_use_cache_for_s3 = 0; + SELECT * + FROM s3(s3_conn, url='http://localhost:11111/${S3_PATH}/test.parquet.tar :: *.parquet') + ORDER BY timestamp +" From 4bdc499fc97ec498c78a40736043dbb7f8bf53dc Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Fri, 1 May 2026 16:35:00 +0000 Subject: [PATCH 58/70] Backport #103834 to 26.3: Reliable key receiving from a chain of keyservers --- docker/keeper/Dockerfile.distroless | 15 +++++++++++---- docker/server/Dockerfile.distroless | 15 +++++++++++---- docker/server/Dockerfile.ubuntu | 15 +++++++++++---- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/docker/keeper/Dockerfile.distroless b/docker/keeper/Dockerfile.distroless index 5d76502d1d25..9b422b670f6a 100644 --- a/docker/keeper/Dockerfile.distroless +++ b/docker/keeper/Dockerfile.distroless @@ -80,10 +80,17 @@ RUN clickhouse local -q 'SELECT 1' >/dev/null 2>&1 && exit 0 || : \ && apt-get install --yes --no-install-recommends dirmngr gnupg2 \ && mkdir -p /etc/apt/sources.list.d \ && GNUPGHOME=$(mktemp -d) \ - && GNUPGHOME="$GNUPGHOME" gpg --batch --no-default-keyring \ - --keyring /usr/share/keyrings/clickhouse-keyring.gpg \ - --keyserver hkp://keyserver.ubuntu.com:80 \ - --recv-keys 3a9ea1193a97b548be1457d48919f6bd2b48d754 \ + && ( set +e; \ + for KEYSERVER in \ + hkp://keys.openpgp.org:80 \ + hkp://pgp.mit.edu:80 \ + hkp://keyserver.ubuntu.com:80; do \ + GNUPGHOME="$GNUPGHOME" gpg --batch --no-default-keyring \ + --keyring /usr/share/keyrings/clickhouse-keyring.gpg \ + --keyserver "$KEYSERVER" \ + --recv-keys 3a9ea1193a97b548be1457d48919f6bd2b48d754 && break; \ + done || exit 1 \ + ) \ && rm -rf "$GNUPGHOME" \ && chmod +r /usr/share/keyrings/clickhouse-keyring.gpg \ && echo "${REPOSITORY}" > /etc/apt/sources.list.d/clickhouse.list \ diff --git a/docker/server/Dockerfile.distroless b/docker/server/Dockerfile.distroless index 3456ded334c8..77f5f942409b 100644 --- a/docker/server/Dockerfile.distroless +++ b/docker/server/Dockerfile.distroless @@ -87,10 +87,17 @@ RUN clickhouse local -q 'SELECT 1' >/dev/null 2>&1 && exit 0 || : \ && apt-get install --yes --no-install-recommends dirmngr gnupg2 \ && mkdir -p /etc/apt/sources.list.d \ && GNUPGHOME=$(mktemp -d) \ - && GNUPGHOME="$GNUPGHOME" gpg --batch --no-default-keyring \ - --keyring /usr/share/keyrings/clickhouse-keyring.gpg \ - --keyserver hkp://keyserver.ubuntu.com:80 \ - --recv-keys 3a9ea1193a97b548be1457d48919f6bd2b48d754 \ + && ( set +e; \ + for KEYSERVER in \ + hkp://keys.openpgp.org:80 \ + hkp://pgp.mit.edu:80 \ + hkp://keyserver.ubuntu.com:80; do \ + GNUPGHOME="$GNUPGHOME" gpg --batch --no-default-keyring \ + --keyring /usr/share/keyrings/clickhouse-keyring.gpg \ + --keyserver "$KEYSERVER" \ + --recv-keys 3a9ea1193a97b548be1457d48919f6bd2b48d754 && break; \ + done || exit 1 \ + ) \ && rm -rf "$GNUPGHOME" \ && chmod +r /usr/share/keyrings/clickhouse-keyring.gpg \ && echo "${REPOSITORY}" > /etc/apt/sources.list.d/clickhouse.list \ diff --git a/docker/server/Dockerfile.ubuntu b/docker/server/Dockerfile.ubuntu index f2b64405c027..24798859239d 100644 --- a/docker/server/Dockerfile.ubuntu +++ b/docker/server/Dockerfile.ubuntu @@ -98,10 +98,17 @@ RUN clickhouse local -q 'SELECT 1' >/dev/null 2>&1 && exit 0 || : \ gnupg2 \ && mkdir -p /etc/apt/sources.list.d \ && GNUPGHOME=$(mktemp -d) \ - && GNUPGHOME="$GNUPGHOME" gpg --batch --no-default-keyring \ - --keyring /usr/share/keyrings/clickhouse-keyring.gpg \ - --keyserver hkp://keyserver.ubuntu.com:80 \ - --recv-keys 3a9ea1193a97b548be1457d48919f6bd2b48d754 \ + && ( set +e; \ + for KEYSERVER in \ + hkp://keys.openpgp.org:80 \ + hkp://pgp.mit.edu:80 \ + hkp://keyserver.ubuntu.com:80; do \ + GNUPGHOME="$GNUPGHOME" gpg --batch --no-default-keyring \ + --keyring /usr/share/keyrings/clickhouse-keyring.gpg \ + --keyserver "$KEYSERVER" \ + --recv-keys 3a9ea1193a97b548be1457d48919f6bd2b48d754 && break; \ + done || exit 1 \ + ) \ && rm -rf "$GNUPGHOME" \ && chmod +r /usr/share/keyrings/clickhouse-keyring.gpg \ && echo "${REPOSITORY}" > /etc/apt/sources.list.d/clickhouse.list \ From 393efb10d983d6db8577a02bc4ac8b88624f17cf Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Sun, 3 May 2026 14:33:32 +0000 Subject: [PATCH 59/70] Backport #102689 to 26.3: Fix columns_substreams.txt corruption during column rename in some cases --- .../Serializations/ISerialization.cpp | 4 +- ...lumn_corrupts_columns_substreams.reference | 38 ++++++++++ ...name_column_corrupts_columns_substreams.sh | 72 +++++++++++++++++++ 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 tests/queries/0_stateless/04093_rename_column_corrupts_columns_substreams.reference create mode 100755 tests/queries/0_stateless/04093_rename_column_corrupts_columns_substreams.sh diff --git a/src/DataTypes/Serializations/ISerialization.cpp b/src/DataTypes/Serializations/ISerialization.cpp index 485a49b8b02d..2c7d5662bb2c 100644 --- a/src/DataTypes/Serializations/ISerialization.cpp +++ b/src/DataTypes/Serializations/ISerialization.cpp @@ -425,11 +425,11 @@ String ISerialization::getFileNameForRenamedColumnStream(const String & name_fro { auto name_from_escaped = escapeForFileName(name_from); if (file_name.starts_with(name_from_escaped)) - return escapeForFileName(name_to) + file_name.substr(0, name_from_escaped.size()); + return escapeForFileName(name_to) + file_name.substr(name_from_escaped.size()); auto nested_storage_name_escaped = escapeForFileName(Nested::extractTableName(name_from)); if (file_name.starts_with(nested_storage_name_escaped)) - return escapeForFileName(Nested::extractTableName(name_to)) + file_name.substr(0, nested_storage_name_escaped.size()); + return escapeForFileName(Nested::extractTableName(name_to)) + file_name.substr(nested_storage_name_escaped.size()); throw Exception(ErrorCodes::LOGICAL_ERROR, "File name {} doesn't correspond to column {}", file_name, name_from); } diff --git a/tests/queries/0_stateless/04093_rename_column_corrupts_columns_substreams.reference b/tests/queries/0_stateless/04093_rename_column_corrupts_columns_substreams.reference new file mode 100644 index 000000000000..2284b9e556b9 --- /dev/null +++ b/tests/queries/0_stateless/04093_rename_column_corrupts_columns_substreams.reference @@ -0,0 +1,38 @@ +Before rename: +columns substreams version: 1 +2 columns: +1 substreams for column `id`: + id +2 substreams for column `arr`: + arr.size0 + arr +After rename arr -> brr: +columns substreams version: 1 +2 columns: +1 substreams for column `id`: + id +2 substreams for column `brr`: + brr.size0 + brr +Nested before rename: +columns substreams version: 1 +3 columns: +1 substreams for column `id`: + id +2 substreams for column `nested.a`: + nested.size0 + nested%2Ea +2 substreams for column `nested.b`: + nested.size0 + nested%2Eb +Nested after rename nested.a -> nested.aa: +columns substreams version: 1 +3 columns: +1 substreams for column `id`: + id +2 substreams for column `nested.aa`: + nested.size0 + nested%2Eaa +2 substreams for column `nested.b`: + nested.size0 + nested%2Eb diff --git a/tests/queries/0_stateless/04093_rename_column_corrupts_columns_substreams.sh b/tests/queries/0_stateless/04093_rename_column_corrupts_columns_substreams.sh new file mode 100755 index 000000000000..08fed87fd1da --- /dev/null +++ b/tests/queries/0_stateless/04093_rename_column_corrupts_columns_substreams.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +# Tags: no-shared-merge-tree, no-object-storage + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +${CLICKHOUSE_CLIENT} --query "DROP TABLE IF EXISTS test_rename_substreams" + +${CLICKHOUSE_CLIENT} --query " + CREATE TABLE test_rename_substreams + ( + id UInt32, + arr Array(UInt32) + ) + ENGINE = MergeTree + ORDER BY id + SETTINGS min_rows_for_wide_part = 1, min_bytes_for_wide_part = 1, + enable_block_number_column = 0, enable_block_offset_column = 0, + replace_long_file_name_to_hash = 0, ratio_of_defaults_for_sparse_serialization = 1; +" + +${CLICKHOUSE_CLIENT} --query "INSERT INTO test_rename_substreams SELECT number, [number, number + 1] FROM numbers(10)" + +# Get data path before rename to verify initial state +DATA_PATH=$(${CLICKHOUSE_CLIENT} --query "SELECT path FROM system.parts WHERE database = currentDatabase() AND table = 'test_rename_substreams' AND active") + +echo "Before rename:" +cat "${DATA_PATH}columns_substreams.txt" + +# Rename arr -> brr +${CLICKHOUSE_CLIENT} --query "ALTER TABLE test_rename_substreams RENAME COLUMN arr TO brr" + +# Get the new part path (mutation creates a new part) +DATA_PATH_NEW=$(${CLICKHOUSE_CLIENT} --query "SELECT path FROM system.parts WHERE database = currentDatabase() AND table = 'test_rename_substreams' AND active") + +echo "After rename arr -> brr:" +cat "${DATA_PATH_NEW}columns_substreams.txt" + +# Also rename a Nested column to test the second code path (line 450) +${CLICKHOUSE_CLIENT} --query "DROP TABLE IF EXISTS test_rename_nested_substreams" + +${CLICKHOUSE_CLIENT} --query " + CREATE TABLE test_rename_nested_substreams + ( + id UInt32, + nested Nested(a UInt32, b UInt32) + ) + ENGINE = MergeTree + ORDER BY id + SETTINGS min_rows_for_wide_part = 1, min_bytes_for_wide_part = 1, + enable_block_number_column = 0, enable_block_offset_column = 0, + replace_long_file_name_to_hash = 0, ratio_of_defaults_for_sparse_serialization = 1; +" + +${CLICKHOUSE_CLIENT} --query "INSERT INTO test_rename_nested_substreams SELECT number, [number], [number + 1] FROM numbers(10)" + +DATA_PATH_NESTED=$(${CLICKHOUSE_CLIENT} --query "SELECT path FROM system.parts WHERE database = currentDatabase() AND table = 'test_rename_nested_substreams' AND active") + +echo "Nested before rename:" +cat "${DATA_PATH_NESTED}columns_substreams.txt" + +# Rename nested.a -> nested.aa +${CLICKHOUSE_CLIENT} --query "ALTER TABLE test_rename_nested_substreams RENAME COLUMN nested.a TO nested.aa" + +DATA_PATH_NESTED_NEW=$(${CLICKHOUSE_CLIENT} --query "SELECT path FROM system.parts WHERE database = currentDatabase() AND table = 'test_rename_nested_substreams' AND active") + +echo "Nested after rename nested.a -> nested.aa:" +cat "${DATA_PATH_NESTED_NEW}columns_substreams.txt" + +${CLICKHOUSE_CLIENT} --query "DROP TABLE test_rename_substreams" +${CLICKHOUSE_CLIENT} --query "DROP TABLE test_rename_nested_substreams" From 91b5ef318565b54f47f03ec06b09717c7c5a601b Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Mon, 4 May 2026 03:23:52 +0000 Subject: [PATCH 60/70] Backport #103014 to 26.3: Fix `MULTIPLE_EXPRESSIONS_FOR_ALIAS` in `FuseFunctionsPass` for repeated `quantile` on distributed queries --- src/Analyzer/Passes/FuseFunctionsPass.cpp | 147 ++++++++++-------- ...uantiles_distributed_alias_clash.reference | 9 ++ ...fuse_quantiles_distributed_alias_clash.sql | 53 +++++++ 3 files changed, 140 insertions(+), 69 deletions(-) create mode 100644 tests/queries/0_stateless/04103_fuse_quantiles_distributed_alias_clash.reference create mode 100644 tests/queries/0_stateless/04103_fuse_quantiles_distributed_alias_clash.sql diff --git a/src/Analyzer/Passes/FuseFunctionsPass.cpp b/src/Analyzer/Passes/FuseFunctionsPass.cpp index b3bb97459c00..922e4598b79c 100644 --- a/src/Analyzer/Passes/FuseFunctionsPass.cpp +++ b/src/Analyzer/Passes/FuseFunctionsPass.cpp @@ -1,6 +1,5 @@ #include -#include #include #include #include @@ -21,9 +20,6 @@ #include #include -#include - - namespace DB { namespace Setting @@ -231,66 +227,6 @@ void replaceWithSumCount(QueryTreeNodePtr & node, const FunctionNodePtr & sum_co node->setAlias(original_column_name); } -/// Reorder nodes according to the value of the quantile level parameter. -/// Levels are sorted in ascending order to make pass result deterministic. -FunctionNodePtr createFusedQuantilesNode(std::vector & nodes, const QueryTreeNodePtr & argument) -{ - Array parameters; - parameters.reserve(nodes.size()); - - for (const auto * node : nodes) - { - const FunctionNode & function_node = (*node)->as(); - const auto & function_name = function_node.getFunctionName(); - - const auto & parameter_nodes = function_node.getParameters().getNodes(); - if (parameter_nodes.empty()) - { - parameters.push_back(Float64(0.5)); /// default value - continue; - } - - if (parameter_nodes.size() != 1) - throw Exception(ErrorCodes::BAD_ARGUMENTS, "Function '{}' should have exactly one parameter", function_name); - - const auto * constant_node = parameter_nodes.front()->as(); - if (!constant_node) - throw Exception(ErrorCodes::BAD_ARGUMENTS, "Function '{}' should have constant parameter", function_name); - - const auto & value = constant_node->getValue(); - if (value.getType() != Field::Types::Float64) - throw Exception(ErrorCodes::BAD_ARGUMENTS, - "Function '{}' should have parameter of type Float64, got '{}'", - function_name, value.getTypeName()); - - parameters.push_back(value); - } - - { - /// Sort nodes and parameters in ascending order of quantile level - std::vector permutation(nodes.size()); - iota(permutation.data(), permutation.size(), size_t(0)); - std::sort(permutation.begin(), permutation.end(), [&](size_t i, size_t j) { return parameters[i].safeGet() < parameters[j].safeGet(); }); - - std::vector new_nodes; - new_nodes.reserve(permutation.size()); - - Array new_parameters; - new_parameters.reserve(permutation.size()); - - for (size_t i : permutation) - { - new_nodes.emplace_back(nodes[i]); - new_parameters.emplace_back(std::move(parameters[i])); - } - nodes = std::move(new_nodes); - parameters = std::move(new_parameters); - } - - return createResolvedAggregateFunction("quantiles", argument, parameters); -} - - void tryFuseSumCountAvg(QueryTreeNodePtr query_tree_node, ContextPtr context) { FuseFunctionsVisitor visitor({"sum", "count", "avg"}, context); @@ -333,6 +269,67 @@ void tryFuseSumCountAvg(QueryTreeNodePtr query_tree_node, ContextPtr context) } } +/// Collect the distinct quantile levels requested across `nodes`, sorted ascending for determinism. +/// Returns the list of levels plus a parallel vector mapping each input node to its level's index. +struct QuantileLevelMapping +{ + Array unique_levels; + std::vector level_index_per_node; +}; + +QuantileLevelMapping collectUniqueQuantileLevels(const std::vector & nodes) +{ + std::vector levels_per_node; + levels_per_node.reserve(nodes.size()); + + for (const auto * node : nodes) + { + const FunctionNode & function_node = (*node)->as(); + const auto & function_name = function_node.getFunctionName(); + + const auto & parameter_nodes = function_node.getParameters().getNodes(); + if (parameter_nodes.empty()) + { + levels_per_node.push_back(0.5); /// default value + continue; + } + + if (parameter_nodes.size() != 1) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Function '{}' should have exactly one parameter", function_name); + + const auto * constant_node = parameter_nodes.front()->as(); + if (!constant_node) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Function '{}' should have constant parameter", function_name); + + const auto & value = constant_node->getValue(); + if (value.getType() != Field::Types::Float64) + throw Exception(ErrorCodes::BAD_ARGUMENTS, + "Function '{}' should have parameter of type Float64, got '{}'", + function_name, value.getTypeName()); + + levels_per_node.push_back(value.safeGet()); + } + + /// Build the unique, sorted list of levels. + std::vector sorted_unique_levels = levels_per_node; + std::sort(sorted_unique_levels.begin(), sorted_unique_levels.end()); + sorted_unique_levels.erase(std::unique(sorted_unique_levels.begin(), sorted_unique_levels.end()), sorted_unique_levels.end()); + + QuantileLevelMapping result; + result.unique_levels.reserve(sorted_unique_levels.size()); + for (Float64 level : sorted_unique_levels) + result.unique_levels.push_back(level); + + result.level_index_per_node.reserve(nodes.size()); + for (Float64 level : levels_per_node) + { + auto it = std::lower_bound(sorted_unique_levels.begin(), sorted_unique_levels.end(), level); + result.level_index_per_node.push_back(static_cast(it - sorted_unique_levels.begin())); + } + + return result; +} + void tryFuseQuantiles(QueryTreeNodePtr query_tree_node, ContextPtr context) { FuseFunctionsVisitor visitor_quantile({"quantile"}, context); @@ -340,23 +337,35 @@ void tryFuseQuantiles(QueryTreeNodePtr query_tree_node, ContextPtr context) for (auto & [argument, nodes_set] : visitor_quantile.argument_to_functions_mapping) { - size_t nodes_size = nodes_set.size(); - if (nodes_size < 2) + if (nodes_set.size() < 2) continue; std::vector nodes(nodes_set.begin(), nodes_set.end()); - auto quantiles_node = createFusedQuantilesNode(nodes, argument.first.node); + /// Group references by the requested quantile level. Multiple references to the same + /// level share the same `arrayElement` extraction from the fused `quantiles` call — this + /// keeps all copies structurally identical so they can co-exist under the same alias + /// (AST serialization for distributed dispatch checks `MULTIPLE_EXPRESSIONS_FOR_ALIAS` + /// by tree hash, which only trips when two nodes with the same alias differ). + auto mapping = collectUniqueQuantileLevels(nodes); + + /// Nothing to fuse if there is only one distinct level (e.g. the user wrote the same + /// `quantile(0.99)(x)` in SELECT, HAVING, and ORDER BY). Rewriting to + /// `arrayElement(quantiles(0.99)(x), 1)` is strictly worse than the original call. + if (mapping.unique_levels.size() < 2) + continue; + + auto quantiles_node = createResolvedAggregateFunction("quantiles", argument.first.node, mapping.unique_levels); auto result_array_type = std::dynamic_pointer_cast(quantiles_node->getResultType()); if (!result_array_type) throw Exception(ErrorCodes::LOGICAL_ERROR, "Unexpected return type '{}' of function '{}', should be array", quantiles_node->getResultType(), quantiles_node->getFunctionName()); - for (size_t i = 0; i < nodes_set.size(); ++i) + for (size_t i = 0; i < nodes.size(); ++i) { auto original_column_name = (*nodes[i])->formatConvertedASTForErrorMessage(); - size_t array_index = i + 1; + size_t array_index = mapping.level_index_per_node[i] + 1; *nodes[i] = createArrayElementFunction(context, quantiles_node, array_index); (*nodes[i])->setAlias(original_column_name); } diff --git a/tests/queries/0_stateless/04103_fuse_quantiles_distributed_alias_clash.reference b/tests/queries/0_stateless/04103_fuse_quantiles_distributed_alias_clash.reference new file mode 100644 index 000000000000..363db89ea133 --- /dev/null +++ b/tests/queries/0_stateless/04103_fuse_quantiles_distributed_alias_clash.reference @@ -0,0 +1,9 @@ +9 100 989.1 +8 100 988.1 +7 100 987.1000000000001 +9 989.1 +8 988.1 +7 987.1000000000001 +9 504 989.1 +8 503 988.1 +7 502 987.1000000000001 diff --git a/tests/queries/0_stateless/04103_fuse_quantiles_distributed_alias_clash.sql b/tests/queries/0_stateless/04103_fuse_quantiles_distributed_alias_clash.sql new file mode 100644 index 000000000000..da42933fff27 --- /dev/null +++ b/tests/queries/0_stateless/04103_fuse_quantiles_distributed_alias_clash.sql @@ -0,0 +1,53 @@ +-- Regression: `MULTIPLE_EXPRESSIONS_FOR_ALIAS` on distributed queries that reference the same +-- `quantile(p)(x)` in SELECT, HAVING, and ORDER BY when `optimize_syntax_fuse_functions = 1`. +-- +-- Before the fix, `FuseFunctionsPass` packed every reference to `quantile(0.99)(x)` into a +-- `quantiles(0.99, 0.99, 0.99)` call and assigned a distinct `arrayElement(..., i)` index to +-- each occurrence, then forced the same `quantile(0.99)(x)` alias onto all of them. When the +-- query tree was serialized back to SQL for distributed dispatch, the three `arrayElement` +-- nodes differed only in their index but shared the alias, and the analyzer tripped +-- `MULTIPLE_EXPRESSIONS_FOR_ALIAS`. +-- +-- The pass now deduplicates by quantile level, so identical references share the same +-- `arrayElement` extraction. +-- https://github.com/ClickHouse/ClickHouse/issues/102976 + +SET optimize_syntax_fuse_functions = 1; + +-- Same quantile referenced in SELECT, HAVING, and ORDER BY over a distributed table. +-- Should succeed, not throw `MULTIPLE_EXPRESSIONS_FOR_ALIAS`. +SELECT + number % 10 AS bucket, + count() AS c, + quantile(0.99)(number) AS p99 +FROM remote('127.0.0.1', system.numbers) +WHERE number < 1000 +GROUP BY bucket +HAVING p99 > 100 +ORDER BY p99 DESC +LIMIT 3; + +-- Repeating the aggregate expression (not the alias) in HAVING and ORDER BY used to hit the +-- same codepath because alias expansion runs before the fusion pass. +SELECT + number % 10 AS bucket, + quantile(0.99)(number) AS p99 +FROM remote('127.0.0.1', system.numbers) +WHERE number < 1000 +GROUP BY bucket +HAVING quantile(0.99)(number) > 100 +ORDER BY quantile(0.99)(number) DESC +LIMIT 3; + +-- Mixed levels still fuse into a single `quantiles` call, with each distinct level appearing +-- exactly once regardless of how many times it is referenced. +SELECT + number % 10 AS bucket, + quantile(0.5)(number) AS p50, + quantile(0.99)(number) AS p99 +FROM remote('127.0.0.1', system.numbers) +WHERE number < 1000 +GROUP BY bucket +HAVING quantile(0.99)(number) > 100 AND quantile(0.5)(number) > 10 +ORDER BY quantile(0.99)(number) DESC, quantile(0.5)(number) ASC +LIMIT 3; From 49096b3d9000b90b6b01e417deb4cdf43d1e8e5c Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Tue, 5 May 2026 03:21:44 +0000 Subject: [PATCH 61/70] Backport #103457 to 26.3: Fix potential out-of-bounds read in the `ALP` codec decompression --- src/Compression/CompressionCodecALP.cpp | 7 +++++++ tests/queries/0_stateless/04104_alp_bit_width.reference | 1 + tests/queries/0_stateless/04104_alp_bit_width.sh | 9 +++++++++ 3 files changed, 17 insertions(+) create mode 100644 tests/queries/0_stateless/04104_alp_bit_width.reference create mode 100755 tests/queries/0_stateless/04104_alp_bit_width.sh diff --git a/src/Compression/CompressionCodecALP.cpp b/src/Compression/CompressionCodecALP.cpp index 59aa83e2c87c..d9c4b425b2d2 100644 --- a/src/Compression/CompressionCodecALP.cpp +++ b/src/Compression/CompressionCodecALP.cpp @@ -633,6 +633,13 @@ class ALPCodecDecoder // Read bits const UInt8 bits = static_cast(*source++); + if (unlikely(bits > sizeof(UInt64) * 8)) + throw Exception( + ErrorCodes::CANNOT_DECOMPRESS, + "Cannot decompress ALP-encoded data, invalid bit-width: {}, max allowed: {}", + static_cast(bits), + static_cast(sizeof(UInt64) * 8)); + const UInt32 bitpacked_size = Compression::FFOR::calculateBitpackedBytes(bits); // Read frame of reference diff --git a/tests/queries/0_stateless/04104_alp_bit_width.reference b/tests/queries/0_stateless/04104_alp_bit_width.reference new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/tests/queries/0_stateless/04104_alp_bit_width.reference @@ -0,0 +1 @@ +1 diff --git a/tests/queries/0_stateless/04104_alp_bit_width.sh b/tests/queries/0_stateless/04104_alp_bit_width.sh new file mode 100755 index 000000000000..0778cf8ca9e9 --- /dev/null +++ b/tests/queries/0_stateless/04104_alp_bit_width.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CUR_DIR"/../shell_config.sh + +(printf '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\234\232\040\0\0\0\040\0\0\001\010\0\004\0\0\0\0A\0\0\0\0\0\0\0\0'; head -c 8320 /dev/zero) \ + | ${CLICKHOUSE_CURL} "${CLICKHOUSE_URL}&decompress=1&http_native_compression_disable_checksumming_on_decompress=1" --data-binary @- \ + | grep -c "Code: 271" From ed461e99836360bbfd92aa974964dcee77802c9b Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Tue, 5 May 2026 13:50:10 +0000 Subject: [PATCH 62/70] Backport #104047 to 26.3: Bump libarchive form 3.8.6 to 3.8.7 --- contrib/libarchive | 2 +- contrib/libarchive-cmake/config.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/libarchive b/contrib/libarchive index 3a9249b4eeb2..ded82291ab41 160000 --- a/contrib/libarchive +++ b/contrib/libarchive @@ -1 +1 @@ -Subproject commit 3a9249b4eeb2a101ca4e0d2b12e4007642bac126 +Subproject commit ded82291ab41d5e355831b96b0e1ff49e24d8939 diff --git a/contrib/libarchive-cmake/config.h b/contrib/libarchive-cmake/config.h index a75b9af42a2e..da7f950da3b7 100644 --- a/contrib/libarchive-cmake/config.h +++ b/contrib/libarchive-cmake/config.h @@ -1031,6 +1031,9 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 +/* Define to 1 if you have the header file. */ +#define HAVE_STDIO_H 1 + /* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 From d874c5a3d016aa3d9418f86ca969dd23ae402bd6 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Tue, 5 May 2026 20:39:09 +0000 Subject: [PATCH 63/70] Backport #104002 to 26.3: Tolerate oversized alpha_map on topK String state read --- src/Common/SpaceSaving.h | 27 +++- .../__init__.py | 0 .../test_topk_alpha_map_compatibility/test.py | 146 ++++++++++++++++++ .../0_stateless/03716_topk_bad_data.reference | 11 +- .../0_stateless/03716_topk_bad_data.sql | 11 +- 5 files changed, 188 insertions(+), 7 deletions(-) create mode 100644 tests/integration/test_topk_alpha_map_compatibility/__init__.py create mode 100644 tests/integration/test_topk_alpha_map_compatibility/test.py diff --git a/src/Common/SpaceSaving.h b/src/Common/SpaceSaving.h index 5c5dda0dbefe..e7f30da115d8 100644 --- a/src/Common/SpaceSaving.h +++ b/src/Common/SpaceSaving.h @@ -336,13 +336,38 @@ class SpaceSaving readVarUInt(alpha_size, rb); size_t expected_capacity = alpha_map.size(); - if (alpha_size != expected_capacity) + + /// A smaller-than-expected alpha map is not produced by any known + /// version (the writers always allocate at least nextAlphaSize(reserved) + /// before serialize), so treat it as data corruption. + if (alpha_size < expected_capacity) throw DB::Exception( DB::ErrorCodes::SIZES_OF_ARRAYS_DONT_MATCH, "Found incorrect alpha vector size (Passed: {}. Expected: {})", alpha_size, expected_capacity); + /// A larger-than-expected alpha map can come from states written by + /// versions before the readAlphaMap fix: those used `push_back` while + /// AggregateFunctionTopKGeneric::deserialize had already pre-allocated + /// the alpha map via `set.resize(...)`, so every read+rewrite cycle + /// grew alpha_size by `nextAlphaSize(min(size + 1, reserved))`. The + /// stored values are indexed against the writer's alpha_map.size(), + /// not ours, so they are no longer addressable by `hash & (size - 1)` + /// and would corrupt the algorithm. Drain them and start with the + /// zero-initialized alpha_map left by `resize(...)` — a valid (just + /// less precise) starting point. The next merge or rewrite re-emits + /// a state with the right size and self-heals the part. + if (alpha_size > expected_capacity) + { + for (size_t i = 0; i < alpha_size; ++i) + { + UInt64 alpha = 0; + readVarUInt(alpha, rb); + } + return; + } + for (size_t i = 0; i < alpha_size; ++i) { UInt64 alpha = 0; diff --git a/tests/integration/test_topk_alpha_map_compatibility/__init__.py b/tests/integration/test_topk_alpha_map_compatibility/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/integration/test_topk_alpha_map_compatibility/test.py b/tests/integration/test_topk_alpha_map_compatibility/test.py new file mode 100644 index 000000000000..6024f100ab9b --- /dev/null +++ b/tests/integration/test_topk_alpha_map_compatibility/test.py @@ -0,0 +1,146 @@ +""" +Regression test for `AggregateFunction(topK(N), String)` state compatibility +across versions. + +Background. Up to and including 25.10, `SpaceSaving::readAlphaMap` populated +the alpha map via `push_back` while `AggregateFunctionTopKGeneric::deserialize` +had already pre-allocated it through `set.resize(min(size + 1, reserved))`. +Every read+rewrite cycle therefore wrote + nextAlphaSize(min(size + 1, reserved)) + alpha_size_from_file +back to disk, so any `AggregateFunction(topK(N), String)` state that survived +even one merge or mutation under those versions ended up with an `alpha_size` +that is no longer a power of two. + +#90091 (shipped in 25.12) overwrites the alpha map in place and adds a strict +equality check between the on-disk `alpha_size` and `alpha_map.size()`. That +check rejects every part written by a pre-fix version, even though the +counter list itself is intact. + +Reproduction. The corruption only persists on disk when a state is +deserialized and re-serialized without `AggregateFunctionTopKGeneric::merge` +running in between (because that path calls `set.resize(reserved)`, which +truncates the corrupted alpha map back to the right size before write). +A regular merge of distinct primary keys hits `ColumnAggregateFunction:: +ensureOwnership` which calls `func->merge` for every row and washes the +corruption out before the data ever lands on disk. + +The pattern that does *not* go through `merge` is a mutation on a **compact** +part touching a *different* column: the layout forces a full read+write of +the aggregate state column, but no row is combined with another, so `merge` +is never called. We use that here: + + * write data on 25.10 (buggy `readAlphaMap`, no strict check) + * `ALTER TABLE ... UPDATE other_col = ...` on a compact part — this + rewrites every column including the topK state, propagating the + grown `alpha_size` onto disk + * upgrade to the latest binary + +Without the read-side compatibility fix the SELECT throws +`SIZES_OF_ARRAYS_DONT_MATCH`; with the fix it reads the 20 distinct keys +that were inserted into the state. +""" + +import pytest + +from helpers.cluster import ClickHouseCluster + +cluster = ClickHouseCluster(__file__) + +node = cluster.add_instance( + "node", + image="clickhouse/clickhouse-server", + tag="25.10", + with_installed_binary=True, + stay_alive=True, +) + + +@pytest.fixture(scope="module") +def started_cluster(): + try: + cluster.start() + yield cluster + finally: + cluster.shutdown() + + +def _create_and_corrupt(node): + node.query("DROP TABLE IF EXISTS t_topk SYNC;") + # Force the part into compact format so a mutation on `meta` rewrites the + # whole `data.bin`, including the `s` column. Wide parts would hardlink + # `s.bin` and never trigger the buggy deserialize+serialize cycle. + node.query( + """ + CREATE TABLE t_topk + ( + key UInt64, + meta UInt32, + s AggregateFunction(topK(20), String) + ) + ENGINE = MergeTree + ORDER BY key + SETTINGS min_bytes_for_wide_part = 999999999 + """ + ) + + # Initial state on disk has alpha_size = nextAlphaSize(60) = 512 + # (clean — the INSERT path goes through `add` which sizes alpha_map + # correctly). + node.query( + """ + INSERT INTO t_topk + SELECT 1, 0, topKState(20)(toString(number)) + FROM numbers(20) + """ + ) + + parts_before_alter = node.query( + "SELECT name, part_type FROM system.parts WHERE table = 't_topk' AND active" + ).strip() + assert "Compact" in parts_before_alter, ( + f"expected a compact part, got {parts_before_alter!r}" + ) + + # ALTER UPDATE on `meta` rewrites every column of the compact part. The + # `s` column is read into a `ColumnAggregateFunction` (each state is + # deserialized — the buggy `readAlphaMap` grows alpha_map by + # nextAlphaSize(min(20 + 1, 60)) = 128, leaving alpha_map.size() = 640 + # in memory) and serialized back into the new part as-is. No + # `IAggregateFunction::merge` runs in this single-source path, so + # `set.resize(reserved)` never restores the size before write. + node.query( + "ALTER TABLE t_topk UPDATE meta = 1 WHERE 1=1", + settings={"mutations_sync": 2}, + ) + + +def _read_back(node): + return node.query( + "SELECT length(topKMerge(20)(s)) FROM t_topk GROUP BY key ORDER BY key" + ).strip() + + +def test_topk_state_can_be_read_after_upgrade(started_cluster): + _create_and_corrupt(node) + + # Sanity: the buggy version itself reads the corrupted state without + # error (no strict check yet on this version). + assert _read_back(node) == "20" + + node.restart_with_latest_version() + + # On the upgraded binary the on-disk `alpha_size` is 640 while the + # reader expects nextAlphaSize(60) = 512. Without the compatibility + # fix this throws SIZES_OF_ARRAYS_DONT_MATCH. + assert _read_back(node) == "20" + + # Self-healing: a fresh mutation on the upgraded binary must succeed + # and re-serialize the state with a clean `alpha_size = 512`. + node.query( + "ALTER TABLE t_topk UPDATE meta = 2 WHERE 1=1", + settings={"mutations_sync": 2}, + ) + assert _read_back(node) == "20" + + node.query("DROP TABLE t_topk SYNC;") + node.restart_with_original_version() diff --git a/tests/queries/0_stateless/03716_topk_bad_data.reference b/tests/queries/0_stateless/03716_topk_bad_data.reference index df9d92202ecf..ec16c251dc13 100644 --- a/tests/queries/0_stateless/03716_topk_bad_data.reference +++ b/tests/queries/0_stateless/03716_topk_bad_data.reference @@ -1,6 +1,10 @@ -- {echo On} -SELECT finalizeAggregation(CAST(unhex('012A0300000000000000030000000000000043434303000000000000004141410400000000000000414141410100800200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'AggregateFunction(approx_top_k(3), Array(Array(String)))')); -- { serverError SIZES_OF_ARRAYS_DONT_MATCH } -SELECT finalizeAggregation(CAST(unhex('012A0300000000000000030000000000000043434303000000000000004141410400000000000000414141410100800200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'AggregateFunction(topK(3), Array(Array(String)))')); -- { serverError SIZES_OF_ARRAYS_DONT_MATCH } +-- alpha_map is oversized vs nextAlphaSize(reserved). The reader tolerates that +-- (and ignores the trailing alpha values) for backwards compatibility, so the +-- bad data is caught downstream when finalize tries to decode the malformed +-- Array(Array(String)) key. +SELECT finalizeAggregation(CAST(unhex('012A0300000000000000030000000000000043434303000000000000004141410400000000000000414141410100800200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'AggregateFunction(approx_top_k(3), Array(Array(String)))')); -- { serverError CANNOT_READ_ALL_DATA } +SELECT finalizeAggregation(CAST(unhex('012A0300000000000000030000000000000043434303000000000000004141410400000000000000414141410100800200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'AggregateFunction(topK(3), Array(Array(String)))')); -- { serverError CANNOT_READ_ALL_DATA } SELECT finalizeAggregation(CAST(unhex('012A0300000000000000030000000000000043434303000000000000004141410400000000000000414141410100800200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'AggregateFunction(approx_top_k(3), Array(Array(String)))')); -- { serverError BAD_ARGUMENTS } SELECT finalizeAggregation(CAST(unhex('012A0300000000000000030000000000000043434303000000000000004141410400000000000000414141410100800200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'AggregateFunction(topK(3), Array(Array(String)))')); -- { serverError BAD_ARGUMENTS } -- State: Select hex(topKState(3)((number, number)) as t) AS v, toTypeName(t) from numbers(1) @@ -9,4 +13,5 @@ SELECT finalizeAggregation(CAST(unhex('01100000000000000000000000000000000001004 [(0,0)] -- Add some extra bytes SELECT finalizeAggregation(CAST(unhex('01122000000000000000000000000000000000010040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002454'), 'AggregateFunction(topK(3), Tuple(UInt64, UInt64))')); -- { serverError SIZES_OF_ARRAYS_DONT_MATCH } -SELECT finalizeAggregation(CAST(unhex('012A03000000000000000300000000000000434343030000000000000041414104000000000000004141414101008002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001'), 'AggregateFunction(topK(3), Array(Array(String)))')); -- { serverError SIZES_OF_ARRAYS_DONT_MATCH } +-- Truncated payload: the oversized alpha_map drains past the end of the buffer. +SELECT finalizeAggregation(CAST(unhex('012A03000000000000000300000000000000434343030000000000000041414104000000000000004141414101008002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001'), 'AggregateFunction(topK(3), Array(Array(String)))')); -- { serverError ATTEMPT_TO_READ_AFTER_EOF } diff --git a/tests/queries/0_stateless/03716_topk_bad_data.sql b/tests/queries/0_stateless/03716_topk_bad_data.sql index 64a764c056df..c249d26d2061 100644 --- a/tests/queries/0_stateless/03716_topk_bad_data.sql +++ b/tests/queries/0_stateless/03716_topk_bad_data.sql @@ -1,6 +1,10 @@ -- {echo On} -SELECT finalizeAggregation(CAST(unhex('012A0300000000000000030000000000000043434303000000000000004141410400000000000000414141410100800200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'AggregateFunction(approx_top_k(3), Array(Array(String)))')); -- { serverError SIZES_OF_ARRAYS_DONT_MATCH } -SELECT finalizeAggregation(CAST(unhex('012A0300000000000000030000000000000043434303000000000000004141410400000000000000414141410100800200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'AggregateFunction(topK(3), Array(Array(String)))')); -- { serverError SIZES_OF_ARRAYS_DONT_MATCH } +-- alpha_map is oversized vs nextAlphaSize(reserved). The reader tolerates that +-- (and ignores the trailing alpha values) for backwards compatibility, so the +-- bad data is caught downstream when finalize tries to decode the malformed +-- Array(Array(String)) key. +SELECT finalizeAggregation(CAST(unhex('012A0300000000000000030000000000000043434303000000000000004141410400000000000000414141410100800200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'AggregateFunction(approx_top_k(3), Array(Array(String)))')); -- { serverError CANNOT_READ_ALL_DATA } +SELECT finalizeAggregation(CAST(unhex('012A0300000000000000030000000000000043434303000000000000004141410400000000000000414141410100800200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'AggregateFunction(topK(3), Array(Array(String)))')); -- { serverError CANNOT_READ_ALL_DATA } SELECT finalizeAggregation(CAST(unhex('012A0300000000000000030000000000000043434303000000000000004141410400000000000000414141410100800200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), 'AggregateFunction(approx_top_k(3), Array(Array(String)))')); -- { serverError BAD_ARGUMENTS } @@ -13,4 +17,5 @@ SELECT finalizeAggregation(CAST(unhex('01100000000000000000000000000000000001004 -- Add some extra bytes SELECT finalizeAggregation(CAST(unhex('01122000000000000000000000000000000000010040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002454'), 'AggregateFunction(topK(3), Tuple(UInt64, UInt64))')); -- { serverError SIZES_OF_ARRAYS_DONT_MATCH } -SELECT finalizeAggregation(CAST(unhex('012A03000000000000000300000000000000434343030000000000000041414104000000000000004141414101008002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001'), 'AggregateFunction(topK(3), Array(Array(String)))')); -- { serverError SIZES_OF_ARRAYS_DONT_MATCH } +-- Truncated payload: the oversized alpha_map drains past the end of the buffer. +SELECT finalizeAggregation(CAST(unhex('012A03000000000000000300000000000000434343030000000000000041414104000000000000004141414101008002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001'), 'AggregateFunction(topK(3), Array(Array(String)))')); -- { serverError ATTEMPT_TO_READ_AFTER_EOF } From ba3757a71a506df7f65abad4f6eb04dcf5424a0d Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Tue, 5 May 2026 20:41:22 +0000 Subject: [PATCH 64/70] Backport #102921 to 26.3: Disable trivial LIMIT optimization with row policies/additional_table_filters --- src/Planner/PlannerJoinTree.cpp | 86 +++++++++++++------ ...row_policy_trivial_limit_threads.reference | 22 +++++ ...04099_row_policy_trivial_limit_threads.sql | 65 ++++++++++++++ ...ial_count_with_additional_filter.reference | 9 ++ ...1_trivial_count_with_additional_filter.sql | 48 +++++++++++ 5 files changed, 204 insertions(+), 26 deletions(-) create mode 100644 tests/queries/0_stateless/04099_row_policy_trivial_limit_threads.reference create mode 100644 tests/queries/0_stateless/04099_row_policy_trivial_limit_threads.sql create mode 100644 tests/queries/0_stateless/04201_trivial_count_with_additional_filter.reference create mode 100644 tests/queries/0_stateless/04201_trivial_count_with_additional_filter.sql diff --git a/src/Planner/PlannerJoinTree.cpp b/src/Planner/PlannerJoinTree.cpp index 7e1a83373a04..eb2cc810e358 100644 --- a/src/Planner/PlannerJoinTree.cpp +++ b/src/Planner/PlannerJoinTree.cpp @@ -295,6 +295,22 @@ NameAndTypePair chooseSmallestColumnToReadFromStorage(const StoragePtr & storage return result; } +/// Returns the effective row policy filter for the table, or nullptr if the +/// table has no row policies for the current user or the combined filter is +/// always-true. Mirrors the effective-filter check used by +/// buildRowPolicyFilterIfNeeded. +RowPolicyFilterPtr getEffectiveRowPolicyFilter(const StoragePtr & storage, const ContextPtr & query_context) +{ + auto storage_id = storage->getStorageID(); + if (!storage_id.hasDatabase()) + return nullptr; + auto row_policy_filter = query_context->getRowPolicyFilter( + storage_id.getDatabaseName(), storage_id.getTableName(), RowPolicyFilterType::SELECT_FILTER); + if (!row_policy_filter || row_policy_filter->isAlwaysTrue()) + return nullptr; + return row_policy_filter; +} + bool applyTrivialCountIfPossible( QueryPlan & query_plan, SelectQueryInfo & select_query_info, @@ -313,12 +329,8 @@ bool applyTrivialCountIfPossible( table_node ? table_node->getStorageSnapshot() : table_function_node->getStorageSnapshot(), query_context)) return false; - auto storage_id = storage->getStorageID(); - auto row_policy_filter = query_context->getRowPolicyFilter(storage_id.getDatabaseName(), - storage_id.getTableName(), - RowPolicyFilterType::SELECT_FILTER); - if (row_policy_filter) - return {}; + if (getEffectiveRowPolicyFilter(storage, query_context)) + return false; if (select_query_info.additional_filter_ast) return false; @@ -560,11 +572,10 @@ std::optional buildRowPolicyFilterIfNeeded(const StoragePtr & sto PlannerContextPtr & planner_context, std::set & used_row_policies) { - auto storage_id = storage->getStorageID(); const auto & query_context = planner_context->getQueryContext(); - auto row_policy_filter = query_context->getRowPolicyFilter(storage_id.getDatabaseName(), storage_id.getTableName(), RowPolicyFilterType::SELECT_FILTER); - if (!row_policy_filter || row_policy_filter->isAlwaysTrue()) + auto row_policy_filter = getEffectiveRowPolicyFilter(storage, query_context); + if (!row_policy_filter) return {}; for (const auto & row_policy : row_policy_filter->policies) @@ -609,23 +620,24 @@ std::optional buildCustomKeyFilterIfNeeded(const StoragePtr & sto return buildFilterInfo(parallel_replicas_custom_filter_ast, table_expression_query_info.table_expression, planner_context); } -/// Apply filters from additional_table_filters setting -std::optional buildAdditionalFiltersIfNeeded(const StoragePtr & storage, +/// Parse `additional_table_filters` for this table expression and assign the AST into +/// `table_expression_query_info.additional_filter_ast`. This is the pure, side-effect-free +/// part of `buildAdditionalFiltersIfNeeded` — no planner-context mutation, no prewhere +/// touch — so it can be called early (before prewhere / row-policy / trivial-count / +/// trivial-limit decisions) and later consumers can simply read the parsed AST. +void parseAdditionalFilterAstIfNeeded(const StoragePtr & storage, const String & table_expression_alias, SelectQueryInfo & table_expression_query_info, - const PrewhereInfoPtr & prewhere_info, - PlannerContextPtr & planner_context) + const ContextPtr & query_context) { - const auto & query_context = planner_context->getQueryContext(); const auto & settings = query_context->getSettingsRef(); auto const & additional_filters = settings[Setting::additional_table_filters].value; if (additional_filters.empty()) - return {}; + return; auto const & storage_id = storage->getStorageID(); - ASTPtr additional_filter_ast; for (const auto & additional_filter : additional_filters) { const auto & tuple = additional_filter.safeGet(); @@ -637,7 +649,7 @@ std::optional buildAdditionalFiltersIfNeeded(const StoragePtr & s (table == storage_id.getFullNameNotQuoted())) { ParserExpression parser; - additional_filter_ast = parseQuery( + table_expression_query_info.additional_filter_ast = parseQuery( parser, filter.data(), filter.data() + filter.size(), @@ -645,14 +657,23 @@ std::optional buildAdditionalFiltersIfNeeded(const StoragePtr & s settings[Setting::max_query_size], settings[Setting::max_parser_depth], settings[Setting::max_parser_backtracks]); - break; + return; } } +} +/// Apply filters from additional_table_filters setting. Expects +/// `parseAdditionalFilterAstIfNeeded` to have been called earlier so +/// `table_expression_query_info.additional_filter_ast` is populated. +std::optional buildAdditionalFiltersIfNeeded( + SelectQueryInfo & table_expression_query_info, + const PrewhereInfoPtr & prewhere_info, + PlannerContextPtr & planner_context) +{ + const auto & additional_filter_ast = table_expression_query_info.additional_filter_ast; if (!additional_filter_ast) return {}; - table_expression_query_info.additional_filter_ast = additional_filter_ast; auto filter_info = buildFilterInfo(additional_filter_ast, table_expression_query_info.table_expression, planner_context); if (prewhere_info) { @@ -813,6 +834,15 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expres if (const auto & filter_actions = table_expression_data.getFilterActions()) table_expression_query_info.filter_actions_dag = std::make_shared(filter_actions->clone()); + /// Parse additional_table_filters early so that later decisions (trivial-count, + /// trivial-limit) can see `additional_filter_ast` before the actual filter DAG + /// is built further down + /// + /// Skip under `only_analyze`, since we may not have the database in case of Distributed. + if (!select_query_options.only_analyze) + parseAdditionalFilterAstIfNeeded( + storage, table_expression->getOriginalAlias(), table_expression_query_info, query_context); + size_t max_streams = settings[Setting::max_threads]; size_t max_threads_execute_query = settings[Setting::max_threads]; @@ -837,14 +867,20 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expres UInt64 max_block_size = settings[Setting::max_block_size]; UInt64 max_block_size_limited = 0; - if (is_single_table_expression) + if (is_single_table_expression && !select_query_options.only_analyze) { /** If not specified DISTINCT, WHERE, GROUP BY, HAVING, ORDER BY, JOIN, LIMIT BY, LIMIT WITH TIES * but LIMIT is specified, and limit + offset < max_block_size, * then as the block size we will use limit + offset (not to read more from the table than requested), * and also set the number of threads to 1. */ - max_block_size_limited = mainQueryNodeBlockSizeByLimit(select_query_info); + /// Use the same effective-filter checks as the row-policy / additional-filter + /// planning further down: the trivial-LIMIT optimization must be disabled + /// whenever those filters actually apply, so the flags must agree. + bool has_additional_filters = !!table_expression_query_info.additional_filter_ast + || !!getEffectiveRowPolicyFilter(storage, query_context); + if (!has_additional_filters) + max_block_size_limited = mainQueryNodeBlockSizeByLimit(select_query_info); if (max_block_size_limited) { if (max_block_size_limited < max_block_size) @@ -917,7 +953,7 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expres /// Apply trivial_count optimization if possible bool is_trivial_count_applied = !select_query_options.only_analyze && !select_query_options.build_logical_plan && is_single_table_expression - && (table_node || table_function_node) && select_query_info.has_aggregates && settings[Setting::additional_table_filters].value.empty() + && (table_node || table_function_node) && select_query_info.has_aggregates && applyTrivialCountIfPossible( query_plan, table_expression_query_info, @@ -948,9 +984,8 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expres NameSet columns_needed_by_other_filters; /// Pre-build additional table filter to know what columns it needs - const auto & table_expression_alias = table_expression->getOriginalAlias(); auto additional_filters_info_temp = buildAdditionalFiltersIfNeeded( - storage, table_expression_alias, table_expression_query_info, prewhere_info, planner_context); + table_expression_query_info, prewhere_info, planner_context); if (additional_filters_info_temp) { for (const auto * input : additional_filters_info_temp->actions.getInputs()) @@ -1034,8 +1069,7 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expres } } - const auto & table_expression_alias = table_expression->getOriginalAlias(); - if (auto additional_filters_info = buildAdditionalFiltersIfNeeded(storage, table_expression_alias, table_expression_query_info, prewhere_info, planner_context)) + if (auto additional_filters_info = buildAdditionalFiltersIfNeeded(table_expression_query_info, prewhere_info, planner_context)) { appendSetsFromActionsDAG(additional_filters_info->actions, useful_sets); where_filters.emplace_back(std::move(*additional_filters_info), makeDescription("additional filter")); diff --git a/tests/queries/0_stateless/04099_row_policy_trivial_limit_threads.reference b/tests/queries/0_stateless/04099_row_policy_trivial_limit_threads.reference new file mode 100644 index 000000000000..ac70543519a7 --- /dev/null +++ b/tests/queries/0_stateless/04099_row_policy_trivial_limit_threads.reference @@ -0,0 +1,22 @@ +no_row_policy + (Limit) + Limit + (ReadFromMergeTree) + Concat 4 → 1 + MergeTreeSelect(pool: ReadPoolInOrder, algorithm: InOrder) × 4 0 → 1 +row_policy + (Limit) + Limit 4 → 4 + (ReadFromMergeTree) + MergeTreeSelect(pool: ReadPool, algorithm: Thread) × 4 0 → 1 +row_policy_always_true + (Limit) + Limit + (ReadFromMergeTree) + Concat 4 → 1 + MergeTreeSelect(pool: ReadPoolInOrder, algorithm: InOrder) × 4 0 → 1 +additional_filter + (Limit) + Limit 4 → 4 + (ReadFromMergeTree) + MergeTreeSelect(pool: ReadPool, algorithm: Thread) × 4 0 → 1 diff --git a/tests/queries/0_stateless/04099_row_policy_trivial_limit_threads.sql b/tests/queries/0_stateless/04099_row_policy_trivial_limit_threads.sql new file mode 100644 index 000000000000..1e139e4d9202 --- /dev/null +++ b/tests/queries/0_stateless/04099_row_policy_trivial_limit_threads.sql @@ -0,0 +1,65 @@ +-- Tags: no-parallel-replicas, no-object-storage +-- -no-parallel-replicas - PR changes the EXPLAIN output +-- -no-object-storage - parts on remote FS use MergeTreeSelect(pool: ReadPool) over MergeTreeSelect(pool: ReadPoolInOrder) + +-- The trivial LIMIT optimization reduces max_streams to 1 for simple +-- SELECT ... LIMIT N queries without WHERE. When row policies or +-- additional table filters are active the optimization must not fire +-- because the filter still needs multi-threaded index analysis. + +SET merge_tree_read_split_ranges_into_intersecting_and_non_intersecting_injection_probability=0; + +DROP TABLE IF EXISTS t_row_policy_limit; +CREATE TABLE t_row_policy_limit (id UInt64) ENGINE = MergeTree ORDER BY id +SETTINGS index_granularity = 128; + +SYSTEM STOP MERGES t_row_policy_limit; + +-- Create enough parts so multiple streams are meaningful. +INSERT INTO t_row_policy_limit SELECT number FROM numbers(1000) SETTINGS insert_deduplicate=1; +INSERT INTO t_row_policy_limit SELECT number FROM numbers(1000) SETTINGS insert_deduplicate=1; +INSERT INTO t_row_policy_limit SELECT number FROM numbers(1000) SETTINGS insert_deduplicate=1; +INSERT INTO t_row_policy_limit SELECT number FROM numbers(1000) SETTINGS insert_deduplicate=1; + +SET enable_analyzer = 1; + +-- Case 0: no row policies +SELECT 'no_row_policy'; +SELECT * +FROM (EXPLAIN PIPELINE SELECT id FROM t_row_policy_limit LIMIT 1 + SETTINGS max_threads = 4) +WHERE explain LIKE '%Limit%' OR explain LIKE '%Concat%' OR explain LIKE '%ReadFromMergeTree%' OR explain LIKE '%MergeTreeSelect%'; + +-- Case 1: row policy prevents trivial-limit, keeps multiple streams. +DROP ROW POLICY IF EXISTS 04099_p1 ON t_row_policy_limit; +CREATE ROW POLICY 04099_p1 ON t_row_policy_limit USING id < 500 AS permissive TO ALL; + +SELECT 'row_policy'; +SELECT * +FROM (EXPLAIN PIPELINE SELECT id FROM t_row_policy_limit LIMIT 1 + SETTINGS max_threads = 4) +WHERE explain LIKE '%Limit%' OR explain LIKE '%Concat%' OR explain LIKE '%ReadFromMergeTree%' OR explain LIKE '%MergeTreeSelect%'; +DROP ROW POLICY 04099_p1 ON t_row_policy_limit; + +-- Case 2: always-true row policy adds no effective predicate, so the +-- trivial-limit optimization must still fire (max_streams = 1). +DROP ROW POLICY IF EXISTS 04099_p_true ON t_row_policy_limit; +CREATE ROW POLICY 04099_p_true ON t_row_policy_limit USING 1 AS permissive TO ALL; + +SELECT 'row_policy_always_true'; +SELECT * +FROM (EXPLAIN PIPELINE SELECT id FROM t_row_policy_limit LIMIT 1 + SETTINGS max_threads = 4) +WHERE explain LIKE '%Limit%' OR explain LIKE '%Concat%' OR explain LIKE '%ReadFromMergeTree%' OR explain LIKE '%MergeTreeSelect%'; + +DROP ROW POLICY 04099_p_true ON t_row_policy_limit; + +-- Case 3: additional_table_filters prevents trivial-limit. +SELECT 'additional_filter'; +SELECT * +FROM (EXPLAIN PIPELINE SELECT id FROM t_row_policy_limit LIMIT 1 + SETTINGS max_threads = 4, + additional_table_filters = {'t_row_policy_limit': 'id < 500'}) +WHERE explain LIKE '%Limit%' OR explain LIKE '%Concat%' OR explain LIKE '%ReadFromMergeTree%' OR explain LIKE '%MergeTreeSelect%'; + +DROP TABLE t_row_policy_limit; diff --git a/tests/queries/0_stateless/04201_trivial_count_with_additional_filter.reference b/tests/queries/0_stateless/04201_trivial_count_with_additional_filter.reference new file mode 100644 index 000000000000..b143e75ed95b --- /dev/null +++ b/tests/queries/0_stateless/04201_trivial_count_with_additional_filter.reference @@ -0,0 +1,9 @@ +baseline + (ReadFromPreparedSource) + SourceFromSingleChunk 0 → 1 +filtered_this_table + (ReadFromMergeTree) + MergeTreeSelect(pool: ReadPoolInOrder, algorithm: InOrder) 0 → 1 +filter_other_table + (ReadFromPreparedSource) + SourceFromSingleChunk 0 → 1 diff --git a/tests/queries/0_stateless/04201_trivial_count_with_additional_filter.sql b/tests/queries/0_stateless/04201_trivial_count_with_additional_filter.sql new file mode 100644 index 000000000000..8dceed682f8d --- /dev/null +++ b/tests/queries/0_stateless/04201_trivial_count_with_additional_filter.sql @@ -0,0 +1,48 @@ +-- Tags: no-object-storage +-- no-object-storage since the output of the pipeline depends on the read method. + +-- Verify that the trivial-count optimization correctly handles +-- `additional_table_filters`: +-- - DISABLED when the setting targets THIS table. +-- - STILL FIRES when the setting targets a different table only +-- (previously the pessimistic outer guard disabled the optimization +-- whenever any entry was present, regardless of the table). +-- +-- The fix moved `parseAdditionalFilterAstIfNeeded` earlier in +-- PlannerJoinTree so `applyTrivialCountIfPossible` sees the +-- already-matched per-table AST. +-- +-- Trivial-count signature in the pipeline: +-- (ReadFromPreparedSource) / SourceFromSingleChunk -> fired +-- (ReadFromMergeTree) / MergeTreeSelect -> did not fire + +DROP TABLE IF EXISTS t_trivial_count_filter; +CREATE TABLE t_trivial_count_filter (id UInt64) ENGINE = MergeTree ORDER BY id; +INSERT INTO t_trivial_count_filter SELECT number FROM numbers(100); + +SET enable_analyzer = 1; +SET optimize_trivial_count_query = 1; + +-- Baseline: no filter at all, trivial-count fires. +SELECT 'baseline'; +SELECT explain FROM (EXPLAIN PIPELINE SELECT count() FROM t_trivial_count_filter) +WHERE explain LIKE '%ReadFromPreparedSource%' OR explain LIKE '%ReadFromMergeTree%' + OR explain LIKE '%SourceFromSingleChunk%' OR explain LIKE '%MergeTreeSelect%'; + +-- Filter targets THIS table: trivial-count is disabled. +SELECT 'filtered_this_table'; +SELECT explain FROM (EXPLAIN PIPELINE SELECT count() FROM t_trivial_count_filter) +WHERE explain LIKE '%ReadFromPreparedSource%' OR explain LIKE '%ReadFromMergeTree%' + OR explain LIKE '%SourceFromSingleChunk%' OR explain LIKE '%MergeTreeSelect%' +SETTINGS additional_table_filters = {'t_trivial_count_filter': 'id < 5'}; + +-- Filter targets a DIFFERENT table only: trivial-count must still fire. +-- Without the fix the optimization was disabled whenever any +-- additional_table_filters entry was present. +SELECT 'filter_other_table'; +SELECT explain FROM (EXPLAIN PIPELINE SELECT count() FROM t_trivial_count_filter) +WHERE explain LIKE '%ReadFromPreparedSource%' OR explain LIKE '%ReadFromMergeTree%' + OR explain LIKE '%SourceFromSingleChunk%' OR explain LIKE '%MergeTreeSelect%' +SETTINGS additional_table_filters = {'some_other_table': 'id < 5'}; + +DROP TABLE t_trivial_count_filter; From ae336ae7e400ac22592f31d04b1cbce14888c6f2 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 6 May 2026 09:05:57 +0000 Subject: [PATCH 65/70] Backport #104141 to 26.3: Fix write out of bounds in quantileTiming deserialization --- src/AggregateFunctions/QuantileTiming.h | 2 + ...ntile_timing_deserialization_bug.reference | 0 ...12_quantile_timing_deserialization_bug.sql | 209 ++++++++++++++++++ 3 files changed, 211 insertions(+) create mode 100644 tests/queries/0_stateless/03812_quantile_timing_deserialization_bug.reference create mode 100644 tests/queries/0_stateless/03812_quantile_timing_deserialization_bug.sql diff --git a/src/AggregateFunctions/QuantileTiming.h b/src/AggregateFunctions/QuantileTiming.h index 8cb39cc967df..ccba0625b8c7 100644 --- a/src/AggregateFunctions/QuantileTiming.h +++ b/src/AggregateFunctions/QuantileTiming.h @@ -392,6 +392,8 @@ namespace detail readBinaryLittleEndian(index, buf); if (index == BIG_THRESHOLD) break; + if (index - SMALL_THRESHOLD >= BIG_SIZE) + throw Exception(ErrorCodes::INCORRECT_DATA, "Incorrect index {} in 'large' kind of quantileTiming deserialization", index); UInt64 elem_count = 0; readBinaryLittleEndian(elem_count, buf); diff --git a/tests/queries/0_stateless/03812_quantile_timing_deserialization_bug.reference b/tests/queries/0_stateless/03812_quantile_timing_deserialization_bug.reference new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/queries/0_stateless/03812_quantile_timing_deserialization_bug.sql b/tests/queries/0_stateless/03812_quantile_timing_deserialization_bug.sql new file mode 100644 index 000000000000..c125347f7e99 --- /dev/null +++ b/tests/queries/0_stateless/03812_quantile_timing_deserialization_bug.sql @@ -0,0 +1,209 @@ + +SET max_query_size=1000000000; + +SELECT + quantileTimingMerge(qt), + sumMapMerge(sm) +FROM +( + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('033200000000000000770bbebafecaefbeadde7f0bbebafecaefbeadde870bbebafecaefbeadde8f0bbebafecaefbeadde970bbebafecaefbeadde9f0bbebafecaefbeaddea70bbebafecaefbeaddeaf0bbebafecaefbeaddeb70bbebafecaefbeaddebf0bbebafecaefbeaddec70bbebafecaefbeaddecf0bbebafecaefbeadded70bbebafecaefbeaddedf0bbebafecaefbeaddee70bbebafecaefbeaddeef0bbebafecaefbeaddef70bbebafecaefbeaddeff0bbebafecaefbeadde070cbebafecaefbeadde0f0cbebafecaefbeadde170cbebafecaefbeadde1f0cbebafecaefbeadde270cbebafecaefbeadde2f0cbebafecaefbeadde370cbebafecaefbeadde3f0cbebafecaefbeadde470cbebafecaefbeadde4f0cbebafecaefbeadde570cbebafecaefbeadde5f0cbebafecaefbeadde670cbebafecaefbeadde6f0cbebafecaefbeadde770cbebafecaefbeadde7f0cbebafecaefbeadde870cbebafecaefbeadde8f0cbebafecaefbeadde970cbebafecaefbeadde9f0cbebafecaefbeaddea70cbebafecaefbeaddeaf0cbebafecaefbeaddeb70cbebafecaefbeaddebf0cbebafecaefbeaddec70cbebafecaefbeaddecf0cbebafecaefbeadded70cbebafecaefbeaddedf0cbebafecaefbeaddee70cbebafecaefbeaddeef0cbebafecaefbeaddef70cbebafecaefbeaddeff0cbebafecaefbeadde3075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm + UNION ALL + SELECT + materialize(CAST(unhex('0300000000000000003075'), 'AggregateFunction(quantileTiming, UInt64)')) AS qt, + materialize(CAST(unhex('f4010000000000000000000000100000000000000100000001100000000000000200000002100000000000000300000003100000000000000400000004100000000000000500000005100000000000000600000006100000000000000700000007100000000000000800000008100000000000000900000009100000000000000a0000000a100000000000000b0000000b100000000000000c0000000c100000000000000d0000000d100000000000000e0000000e100000000000000f0000000f100000000000001000000010100000000000001100000011100000000000001200000012100000000000001300000013100000000000001400000014100000000000001500000015100000000000001600000016100000000000001700000017100000000000001800000018100000000000001900000019100000000000001a0000001a100000000000001b0000001b100000000000001c0000001c100000000000001d0000001d100000000000001e0000001e100000000000001f0000001f100000000000002000000020100000000000002100000021100000000000002200000022100000000000002300000023100000000000002400000024100000000000002500000025100000000000002600000026100000000000002700000027100000000000002800000028100000000000002900000029100000000000002a0000002a100000000000002b0000002b100000000000002c0000002c100000000000002d0000002d100000000000002e0000002e100000000000002f0000002f100000000000003000000030100000000000003100000031100000000000003200000032100000000000003300000033100000000000003400000034100000000000003500000035100000000000003600000036100000000000003700000037100000000000003800000038100000000000003900000039100000000000003a0000003a100000000000003b0000003b100000000000003c0000003c100000000000003d0000003d100000000000003e0000003e100000000000003f0000003f100000000000004000000040100000000000004100000041100000000000004200000042100000000000004300000043100000000000004400000044100000000000004500000045100000000000004600000046100000000000004700000047100000000000004800000048100000000000004900000049100000000000004a0000004a100000000000004b0000004b100000000000004c0000004c100000000000004d0000004d100000000000004e0000004e100000000000004f0000004f100000000000005000000050100000000000005100000051100000000000005200000052100000000000005300000053100000000000005400000054100000000000005500000055100000000000005600000056100000000000005700000057100000000000005800000058100000000000005900000059100000000000005a0000005a100000000000005b0000005b100000000000005c0000005c100000000000005d0000005d100000000000005e0000005e100000000000005f0000005f100000000000006000000060100000000000006100000061100000000000006200000062100000000000006300000063100000000000006400000064100000000000006500000065100000000000006600000066100000000000006700000067100000000000006800000068100000000000006900000069100000000000006a0000006a100000000000006b0000006b100000000000006c0000006c100000000000006d0000006d100000000000006e0000006e100000000000006f0000006f100000000000007000000070100000000000007100000071100000000000007200000072100000000000007300000073100000000000007400000074100000000000007500000075100000000000007600000076100000000000007700000077100000000000007800000078100000000000007900000079100000000000007a0000007a100000000000007b0000007b100000000000007c0000007c100000000000007d0000007d100000000000007e0000007e100000000000007f0000007f100000000000008000000080100000000000008100000081100000000000008200000082100000000000008300000083100000000000008400000084100000000000008500000085100000000000008600000086100000000000008700000087100000000000008800000088100000000000008900000089100000000000008a0000008a100000000000008b0000008b100000000000008c0000008c100000000000008d0000008d100000000000008e0000008e100000000000008f0000008f100000000000009000000090100000000000009100000091100000000000009200000092100000000000009300000093100000000000009400000094100000000000009500000095100000000000009600000096100000000000009700000097100000000000009800000098100000000000009900000099100000000000009a0000009a100000000000009b0000009b100000000000009c0000009c100000000000009d0000009d100000000000009e0000009e100000000000009f0000009f10000000000000a0000000a010000000000000a1000000a110000000000000a2000000a210000000000000a3000000a310000000000000a4000000a410000000000000a5000000a510000000000000a6000000a610000000000000a7000000a710000000000000a8000000a810000000000000a9000000a910000000000000aa000000aa10000000000000ab000000ab10000000000000ac000000ac10000000000000ad000000ad10000000000000ae000000ae10000000000000af000000af10000000000000b0000000b010000000000000b1000000b110000000000000b2000000b210000000000000b3000000b310000000000000b4000000b410000000000000b5000000b510000000000000b6000000b610000000000000b7000000b710000000000000b8000000b810000000000000b9000000b910000000000000ba000000ba10000000000000bb000000bb10000000000000bc000000bc10000000000000bd000000bd10000000000000be000000be10000000000000bf000000bf10000000000000c0000000c010000000000000c1000000c110000000000000c2000000c210000000000000c3000000c310000000000000c4000000c410000000000000c5000000c510000000000000c6000000c610000000000000c7000000c710000000000000c8000000c810000000000000c9000000c910000000000000ca000000ca10000000000000cb000000cb10000000000000cc000000cc10000000000000cd000000cd10000000000000ce000000ce10000000000000cf000000cf10000000000000d0000000d010000000000000d1000000d110000000000000d2000000d210000000000000d3000000d310000000000000d4000000d410000000000000d5000000d510000000000000d6000000d610000000000000d7000000d710000000000000d8000000d810000000000000d9000000d910000000000000da000000da10000000000000db000000db10000000000000dc000000dc10000000000000dd000000dd10000000000000de000000de10000000000000df000000df10000000000000e0000000e010000000000000e1000000e110000000000000e2000000e210000000000000e3000000e310000000000000e4000000e410000000000000e5000000e510000000000000e6000000e610000000000000e7000000e710000000000000e8000000e810000000000000e9000000e910000000000000ea000000ea10000000000000eb000000eb10000000000000ec000000ec10000000000000ed000000ed10000000000000ee000000ee10000000000000ef000000ef10000000000000f0000000f010000000000000f1000000f110000000000000f2000000f210000000000000f3000000f310000000000000f4000000f410000000000000f5000000f510000000000000f6000000f610000000000000f7000000f710000000000000f8000000f810000000000000f9000000f910000000000000fa000000fa10000000000000fb000000fb10000000000000fc000000fc10000000000000fd000000fd10000000000000fe000000fe10000000000000ff000000ff100000000000000001000000110000000000000101000001110000000000000201000002110000000000000301000003110000000000000401000004110000000000000501000005110000000000000601000006110000000000000701000007110000000000000801000008110000000000000901000009110000000000000a0100000a110000000000000b0100000b110000000000000c0100000c110000000000000d0100000d110000000000000e0100000e110000000000000f0100000f110000000000001001000010110000000000001101000011110000000000001201000012110000000000001301000013110000000000001401000014110000000000001501000015110000000000001601000016110000000000001701000017110000000000001801000018110000000000001901000019110000000000001a0100001a110000000000001b0100001b110000000000001c0100001c110000000000001d0100001d110000000000001e0100001e110000000000001f0100001f110000000000002001000020110000000000002101000021110000000000002201000022110000000000002301000023110000000000002401000024110000000000002501000025110000000000002601000026110000000000002701000027110000000000002801000028110000000000002901000029110000000000002a0100002a110000000000002b0100002b110000000000002c0100002c110000000000002d0100002d110000000000002e0100002e110000000000002f0100002f110000000000003001000030110000000000003101000031110000000000003201000032110000000000003301000033110000000000003401000034110000000000003501000035110000000000003601000036110000000000003701000037110000000000003801000038110000000000003901000039110000000000003a0100003a110000000000003b0100003b110000000000003c0100003c110000000000003d0100003d110000000000003e0100003e110000000000003f0100003f110000000000004001000040110000000000004101000041110000000000004201000042110000000000004301000043110000000000004401000044110000000000004501000045110000000000004601000046110000000000004701000047110000000000004801000048110000000000004901000049110000000000004a0100004a110000000000004b0100004b110000000000004c0100004c110000000000004d0100004d110000000000004e0100004e110000000000004f0100004f110000000000005001000050110000000000005101000051110000000000005201000052110000000000005301000053110000000000005401000054110000000000005501000055110000000000005601000056110000000000005701000057110000000000005801000058110000000000005901000059110000000000005a0100005a110000000000005b0100005b110000000000005c0100005c110000000000005d0100005d110000000000005e0100005e110000000000005f0100005f110000000000006001000060110000000000006101000061110000000000006201000062110000000000006301000063110000000000006401000064110000000000006501000065110000000000006601000066110000000000006701000067110000000000006801000068110000000000006901000069110000000000006a0100006a110000000000006b0100006b110000000000006c0100006c110000000000006d0100006d110000000000006e0100006e110000000000006f0100006f110000000000007001000070110000000000007101000071110000000000007201000072110000000000007301000073110000000000007401000074110000000000007501000075110000000000007601000076110000000000007701000077110000000000007801000078110000000000007901000079110000000000007a0100007a110000000000007b0100007b110000000000007c0100007c110000000000007d0100007d110000000000007e0100007e110000000000007f0100007f110000000000008001000080110000000000008101000081110000000000008201000082110000000000008301000083110000000000008401000084110000000000008501000085110000000000008601000086110000000000008701000087110000000000008801000088110000000000008901000089110000000000008a0100008a110000000000008b0100008b110000000000008c0100008c110000000000008d0100008d110000000000008e0100008e110000000000008f0100008f110000000000009001000090110000000000009101000091110000000000009201000092110000000000009301000093110000000000009401000094110000000000009501000095110000000000009601000096110000000000009701000097110000000000009801000098110000000000009901000099110000000000009a0100009a110000000000009b0100009b110000000000009c0100009c110000000000009d0100009d110000000000009e0100009e110000000000009f0100009f11000000000000a0010000a011000000000000a1010000a111000000000000a2010000a211000000000000a3010000a311000000000000a4010000a411000000000000a5010000a511000000000000a6010000a611000000000000a7010000a711000000000000a8010000a811000000000000a9010000a911000000000000aa010000aa11000000000000ab010000ab11000000000000ac010000ac11000000000000ad010000ad11000000000000ae010000ae11000000000000af010000af11000000000000b0010000b011000000000000b1010000b111000000000000b2010000b211000000000000b3010000b311000000000000b4010000b411000000000000b5010000b511000000000000b6010000b611000000000000b7010000b711000000000000b8010000b811000000000000b9010000b911000000000000ba010000ba11000000000000bb010000bb11000000000000bc010000bc11000000000000bd010000bd11000000000000be010000be11000000000000bf010000bf11000000000000c0010000c011000000000000c1010000c111000000000000c2010000c211000000000000c3010000c311000000000000c4010000c411000000000000c5010000c511000000000000c6010000c611000000000000c7010000c711000000000000c8010000c811000000000000c9010000c911000000000000ca010000ca11000000000000cb010000cb11000000000000cc010000cc11000000000000cd010000cd11000000000000ce010000ce11000000000000cf010000cf11000000000000d0010000d011000000000000d1010000d111000000000000d2010000d211000000000000d3010000d311000000000000d4010000d411000000000000d5010000d511000000000000d6010000d611000000000000d7010000d711000000000000d8010000d811000000000000d9010000d911000000000000da010000da11000000000000db010000db11000000000000dc010000dc11000000000000dd010000dd11000000000000de010000de11000000000000df010000df11000000000000e0010000e011000000000000e1010000e111000000000000e2010000e211000000000000e3010000e311000000000000e4010000e411000000000000e5010000e511000000000000e6010000e611000000000000e7010000e711000000000000e8010000e811000000000000e9010000e911000000000000ea010000ea11000000000000eb010000eb11000000000000ec010000ec11000000000000ed010000ed11000000000000ee010000ee11000000000000ef010000ef11000000000000f0010000f011000000000000f1010000f111000000000000f2010000f211000000000000f3010000f311000000000000'), 'AggregateFunction(sumMap, Map(Int32, Int64))')) AS sm +) +SETTINGS max_threads = 1 -- { serverError INCORRECT_DATA }; \ No newline at end of file From a6bec34397d5760bd1d38943533fb89f555f53f2 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Wed, 6 May 2026 12:10:25 +0200 Subject: [PATCH 66/70] Fix reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104150&sha=ba3757a71a506df7f65abad4f6eb04dcf5424a0d&name_0=BackportPR&name_1=Stateless%20tests%20%28amd_asan%2C%20distributed%20plan%2C%20parallel%2C%202%2F2%29 2026-05-06 06:35:58 Reason: result differs with reference: 2026-05-06 06:35:58 --- /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/tests/queries/0_stateless/04201_trivial_count_with_additional_filter.reference 2026-05-06 06:26:44.480911341 +0930 2026-05-06 06:35:58 +++ /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/tests/queries/0_stateless/04201_trivial_count_with_additional_filter.stdout 2026-05-06 06:35:58.595674682 +0930 2026-05-06 06:35:58 @@ -1,9 +1,9 @@ 2026-05-06 06:35:58 baseline 2026-05-06 06:35:58 (ReadFromPreparedSource) 2026-05-06 06:35:58 SourceFromSingleChunk 0 → 1 2026-05-06 06:35:58 filtered_this_table 2026-05-06 06:35:58 - (ReadFromMergeTree) 2026-05-06 06:35:58 - MergeTreeSelect(pool: ReadPoolInOrder, algorithm: InOrder) 0 → 1 2026-05-06 06:35:58 + (ReadFromMergeTree) 2026-05-06 06:35:58 + MergeTreeSelect(pool: ReadPoolInOrder, algorithm: InOrder) 0 → 1 2026-05-06 06:35:58 filter_other_table 2026-05-06 06:35:58 (ReadFromPreparedSource) 2026-05-06 06:35:58 SourceFromSingleChunk 0 → 1 --- .../0_stateless/04201_trivial_count_with_additional_filter.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/queries/0_stateless/04201_trivial_count_with_additional_filter.sql b/tests/queries/0_stateless/04201_trivial_count_with_additional_filter.sql index 8dceed682f8d..637b23ff2010 100644 --- a/tests/queries/0_stateless/04201_trivial_count_with_additional_filter.sql +++ b/tests/queries/0_stateless/04201_trivial_count_with_additional_filter.sql @@ -22,6 +22,8 @@ INSERT INTO t_trivial_count_filter SELECT number FROM numbers(100); SET enable_analyzer = 1; SET optimize_trivial_count_query = 1; +-- Avoid extra Resize steps +SET max_threads = 1; -- Baseline: no filter at all, trivial-count fires. SELECT 'baseline'; From cc7b137b40210fb24f78feadce5ca3d345d81738 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 6 May 2026 12:54:52 +0000 Subject: [PATCH 67/70] Backport #104153 to 26.3: Fix memory leak with materialized CTE --- src/Interpreters/MaterializedCTE.h | 1 + src/Storages/StorageMemory.h | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Interpreters/MaterializedCTE.h b/src/Interpreters/MaterializedCTE.h index c06e1aca3c9c..6d250cbad35b 100644 --- a/src/Interpreters/MaterializedCTE.h +++ b/src/Interpreters/MaterializedCTE.h @@ -63,5 +63,6 @@ struct MaterializedCTE }; using MaterializedCTEPtr = std::shared_ptr; +using MaterializedCTEWeakPtr = std::weak_ptr; } diff --git a/src/Storages/StorageMemory.h b/src/Storages/StorageMemory.h index 3ed17a6eeda6..f50f2bb79226 100644 --- a/src/Storages/StorageMemory.h +++ b/src/Storages/StorageMemory.h @@ -127,8 +127,12 @@ friend class MemorySink; */ void delayReadForGlobalSubqueries() { delay_read_for_global_subqueries = true; } - void setMaterializedCTE(MaterializedCTEPtr materialized_cte_) { materialized_cte = std::move(materialized_cte_); } - const MaterializedCTEPtr & getMaterializedCTE() const { return materialized_cte; } + /// Stored as a weak_ptr to break the reference cycle: MaterializedCTE owns the StorageMemory + /// (via its `storage` and `table_holder` members), and this back-pointer lets us recover the + /// CTE descriptor from the storage. If we kept a shared_ptr here, neither object would ever + /// be destroyed, and the temporary table would never be removed from `DatabaseMemory`. + void setMaterializedCTE(MaterializedCTEPtr materialized_cte_) { materialized_cte = materialized_cte_; } + MaterializedCTEPtr getMaterializedCTE() const { return materialized_cte.lock(); } private: /// Restores the data of this table from backup. @@ -141,7 +145,7 @@ friend class MemorySink; mutable std::mutex mutex; bool delay_read_for_global_subqueries = false; - MaterializedCTEPtr materialized_cte; + MaterializedCTEWeakPtr materialized_cte; std::atomic total_size_bytes = 0; std::atomic total_size_rows = 0; From 69d680545e6f4a441b54af2a76b891982396ab05 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 6 May 2026 16:00:59 +0000 Subject: [PATCH 68/70] Backport #103809 to 26.3: Fix wrong values from JIT-compiled if/multiIf with Decimal result --- src/DataTypes/Native.cpp | 150 +++++++++ src/DataTypes/Native.h | 13 + src/Functions/FunctionIfBase.h | 9 +- ...04143_if_decimal_int_literal_jit.reference | 26 ++ .../04143_if_decimal_int_literal_jit.sql | 58 ++++ ...jit_decimal_cast_branches_parity.reference | 70 +++++ ...04205_jit_decimal_cast_branches_parity.sql | 287 ++++++++++++++++++ 7 files changed, 611 insertions(+), 2 deletions(-) create mode 100644 tests/queries/0_stateless/04143_if_decimal_int_literal_jit.reference create mode 100644 tests/queries/0_stateless/04143_if_decimal_int_literal_jit.sql create mode 100644 tests/queries/0_stateless/04205_jit_decimal_cast_branches_parity.reference create mode 100644 tests/queries/0_stateless/04205_jit_decimal_cast_branches_parity.sql diff --git a/src/DataTypes/Native.cpp b/src/DataTypes/Native.cpp index 9bcf21fdfac3..8672359dcd20 100644 --- a/src/DataTypes/Native.cpp +++ b/src/DataTypes/Native.cpp @@ -13,6 +13,7 @@ # include # include # include +# include # include # include @@ -216,6 +217,155 @@ llvm::Value * nativeCast(llvm::IRBuilderBase & b, const ValueWithType & value, c return nativeCast(b, value.type, value.value, to_type); } +llvm::Value * nativeCastWithDecimalScale( + llvm::IRBuilderBase & b, const DataTypePtr & from_type, llvm::Value * value, const DataTypePtr & to_type) +{ + if (from_type->equals(*to_type)) + return value; + + if (from_type->isNullable() && to_type->isNullable()) + { + auto * inner_value = b.CreateExtractValue(value, {0}); + auto * is_null = b.CreateExtractValue(value, {1}); + auto * inner = nativeCastWithDecimalScale(b, removeNullable(from_type), inner_value, removeNullable(to_type)); + auto * to_native_type = toNativeType(b, to_type); + llvm::Value * result = llvm::Constant::getNullValue(to_native_type); + result = b.CreateInsertValue(result, inner, {0}); + return b.CreateInsertValue(result, is_null, {1}); + } + if (from_type->isNullable()) + { + return nativeCastWithDecimalScale(b, removeNullable(from_type), b.CreateExtractValue(value, {0}), to_type); + } + if (to_type->isNullable()) + { + auto * to_native_type = toNativeType(b, to_type); + auto * inner = nativeCastWithDecimalScale(b, from_type, value, removeNullable(to_type)); + return b.CreateInsertValue(llvm::Constant::getNullValue(to_native_type), inner, {0}); + } + + WhichDataType from_w(*from_type); + WhichDataType to_w(*to_type); + + /// Only intercept conversions involving `Decimal` here. Everything else + /// — including `DateTime` / `DateTime64` / `Time` / `Time64` scale lifts — + /// is already handled correctly by `nativeCast`. + if (to_w.isDecimal() || from_w.isDecimal()) + { + auto * from_native_type = toNativeType(b, from_type); + auto * to_native_type = toNativeType(b, to_type); + const UInt32 to_scale = to_w.isDecimal() ? getDecimalScale(*to_type) : 0; + const UInt32 from_scale = from_w.isDecimal() ? getDecimalScale(*from_type) : 0; + + /// Build LLVM integer constant for `10^n` of the requested bit width. + auto pow10_int_const = [&](unsigned bit_width, UInt32 n) -> llvm::ConstantInt * + { + llvm::APInt v(bit_width, 1); + for (UInt32 i = 0; i < n; ++i) + v *= 10; + return llvm::cast(llvm::ConstantInt::get(b.getContext(), v)); + }; + + /// Build LLVM floating-point constant for `10^n` from an `APInt` of the requested bit width. + /// This goes through `APFloat::convertFromAPInt` rather than `APInt::getZExtValue` so that + /// it stays correct when `10^n` does not fit in 64 bits (e.g. `Decimal128` with `scale = 38`, + /// or `Decimal256` with even larger scales). + auto pow10_fp_const = [&](unsigned bit_width, UInt32 n, llvm::Type * fp_type) -> llvm::Constant * + { + llvm::APInt v(bit_width, 1); + for (UInt32 i = 0; i < n; ++i) + v *= 10; + llvm::APFloat fp(fp_type->getFltSemantics()); + fp.convertFromAPInt(v, /*IsSigned=*/false, llvm::APFloat::rmNearestTiesToEven); + return llvm::ConstantFP::get(b.getContext(), fp); + }; + + if (to_w.isDecimal()) + { + if (from_w.isDecimal()) + { + /// `Decimal` → `Decimal` (possibly different scale and/or precision). + /// Widen/narrow the integer storage first, then adjust scale. + auto * widened = (from_native_type == to_native_type) + ? value + : b.CreateIntCast(value, to_native_type, /*isSigned=*/true); + if (from_scale == to_scale) + return widened; + const UInt32 diff = (to_scale > from_scale) ? (to_scale - from_scale) : (from_scale - to_scale); + auto * factor = pow10_int_const(to_native_type->getIntegerBitWidth(), diff); + return (to_scale > from_scale) + ? b.CreateMul(widened, factor) + : b.CreateSDiv(widened, factor); + } + if (from_w.isInt() || from_w.isUInt() || from_w.isEnum() || from_w.isDate() || from_w.isDate32()) + { + /// Integer → `Decimal`: widen to `Decimal`'s underlying integer type, + /// then multiply by `10^to_scale` to lift the value into `Decimal` scale. + auto * widened = (from_native_type == to_native_type) + ? value + : b.CreateIntCast(value, to_native_type, typeIsSigned(*from_type)); + if (to_scale == 0) + return widened; + auto * factor = pow10_int_const(to_native_type->getIntegerBitWidth(), to_scale); + return b.CreateMul(widened, factor); + } + if (from_w.isFloat32() || from_w.isFloat64()) + { + /// Float → `Decimal`: multiply by `10^to_scale` in floating point first, + /// then truncate to the target integer storage type. + if (to_scale == 0) + return b.CreateFPToSI(value, to_native_type); + /// `10^to_scale` may not be exactly representable as a float for very large scales, + /// but this matches the precision of the non-JIT path which performs the same + /// `value * 10^scale` multiplication in `Float64`. Construct the multiplier through + /// `APFloat::convertFromAPInt` so it stays correct when `10^to_scale` exceeds 64 bits + /// (`Decimal128` with `to_scale >= 20`, `Decimal256` with even larger scales). + auto * factor_fp = pow10_fp_const(to_native_type->getIntegerBitWidth(), to_scale, value->getType()); + auto * multiplied = b.CreateFMul(value, factor_fp); + return b.CreateFPToSI(multiplied, to_native_type); + } + /// Fall through to `nativeCast` for unusual sources (e.g. `DateTime64` → `Decimal`). + } + else if (from_w.isDecimal()) + { + if (to_w.isInt() || to_w.isUInt() || to_w.isEnum() || to_w.isDate() || to_w.isDate32()) + { + /// `Decimal` → integer: divide by `10^from_scale`, then narrow. + if (from_scale == 0) + return (from_native_type == to_native_type) + ? value + : b.CreateIntCast(value, to_native_type, /*isSigned=*/true); + auto * factor = pow10_int_const(from_native_type->getIntegerBitWidth(), from_scale); + auto * divided = b.CreateSDiv(value, factor); + return (from_native_type == to_native_type) + ? divided + : b.CreateIntCast(divided, to_native_type, /*isSigned=*/true); + } + if (to_w.isFloat32() || to_w.isFloat64()) + { + /// `Decimal` → float: convert to `Float64`, divide by `10^from_scale`, + /// then narrow to the target float type if needed. Construct the divider through + /// `APFloat::convertFromAPInt` so it stays correct when `10^from_scale` exceeds + /// 64 bits (`Decimal128` with `from_scale >= 20`, `Decimal256` with even larger scales). + auto * as_double = b.CreateSIToFP(value, b.getDoubleTy()); + if (from_scale == 0) + return to_w.isFloat32() ? b.CreateFPCast(as_double, to_native_type) : as_double; + auto * divider = pow10_fp_const(from_native_type->getIntegerBitWidth(), from_scale, b.getDoubleTy()); + auto * divided = b.CreateFDiv(as_double, divider); + return to_w.isFloat32() ? b.CreateFPCast(divided, to_native_type) : divided; + } + /// Fall through to `nativeCast` for unusual targets. + } + } + + return nativeCast(b, from_type, value, to_type); +} + +llvm::Value * nativeCastWithDecimalScale(llvm::IRBuilderBase & b, const ValueWithType & value, const DataTypePtr & to_type) +{ + return nativeCastWithDecimalScale(b, value.type, value.value, to_type); +} + llvm::Constant * getColumnNativeValue(llvm::IRBuilderBase & builder, const DataTypePtr & column_type, const IColumn & column, size_t index) { if (const auto * constant = typeid_cast(&column)) diff --git a/src/DataTypes/Native.h b/src/DataTypes/Native.h index 96f872995868..37bec894c20d 100644 --- a/src/DataTypes/Native.h +++ b/src/DataTypes/Native.h @@ -107,6 +107,19 @@ static inline llvm::Value * nativeCast(llvm::IRBuilderBase & b, llvm::Value * va return nativeCast(b, native_data_type, value, to); } +/// Cast LLVM value with type to specified type with `Decimal` scale awareness. +/// Behaves identically to `nativeCast` for non-`Decimal` types but additionally +/// performs the `* 10^scale` / `/ 10^scale` adjustment when one side of the +/// conversion is a `Decimal` with a non-trivial scale. +/// +/// Use this in non-aggregate function compilers (e.g. `if`, `multiIf`, ...) +/// where the analyzer may leave a non-`Decimal` literal branch unconverted and +/// the result type is `Decimal`. JIT-compiled aggregate functions like `avg` +/// MUST keep using plain `nativeCast` because they intentionally treat the +/// `Decimal` storage as a raw integer accumulator. +llvm::Value * nativeCastWithDecimalScale(llvm::IRBuilderBase & b, const DataTypePtr & from_type, llvm::Value * value, const DataTypePtr & to_type); +llvm::Value * nativeCastWithDecimalScale(llvm::IRBuilderBase & b, const ValueWithType & value, const DataTypePtr & to_type); + /// Get column value for specified index as LLVM constant llvm::Constant * getColumnNativeValue(llvm::IRBuilderBase & builder, const DataTypePtr & column_type, const IColumn & column, size_t index); diff --git a/src/Functions/FunctionIfBase.h b/src/Functions/FunctionIfBase.h index b73d29860cdf..d35cac9ac8ad 100644 --- a/src/Functions/FunctionIfBase.h +++ b/src/Functions/FunctionIfBase.h @@ -63,13 +63,18 @@ class FunctionIfBase : public IFunction b.CreateCondBr(nativeBoolCast(b, cond), then, next); b.SetInsertPoint(then); - auto * value = nativeCast(b, arguments[i + 1], result_type); + /// Use `nativeCastWithDecimalScale` to correctly lift integer/float branches to a + /// `Decimal` `result_type` (and to convert between `Decimal` types of different scales). + /// Plain `nativeCast` reinterprets the integer bits without applying the `10^scale` + /// factor, which silently produces wrong values when the analyzer leaves a non-`Decimal` + /// branch unconverted (e.g. `if(cond, decimal_col, 1)` with `result_type = Decimal(P, S)`). + auto * value = nativeCastWithDecimalScale(b, arguments[i + 1], result_type); returns.emplace_back(b.GetInsertBlock(), value); b.CreateBr(join); b.SetInsertPoint(next); } - auto * else_value = nativeCast(b, arguments.back(), result_type); + auto * else_value = nativeCastWithDecimalScale(b, arguments.back(), result_type); returns.emplace_back(b.GetInsertBlock(), else_value); b.CreateBr(join); diff --git a/tests/queries/0_stateless/04143_if_decimal_int_literal_jit.reference b/tests/queries/0_stateless/04143_if_decimal_int_literal_jit.reference new file mode 100644 index 000000000000..84cf4d55c27f --- /dev/null +++ b/tests/queries/0_stateless/04143_if_decimal_int_literal_jit.reference @@ -0,0 +1,26 @@ +1 +2 +1 +1 +2 +1 +2 +3 +1 +1 +1 +1 +1 +1 +1 +1 +2 +1 +1 +2.5 +1 +2 +1 +1 +1 +1 diff --git a/tests/queries/0_stateless/04143_if_decimal_int_literal_jit.sql b/tests/queries/0_stateless/04143_if_decimal_int_literal_jit.sql new file mode 100644 index 000000000000..0900b1e0533e --- /dev/null +++ b/tests/queries/0_stateless/04143_if_decimal_int_literal_jit.sql @@ -0,0 +1,58 @@ +-- Regression test for https://github.com/ClickHouse/ClickHouse/issues/103808 +-- +-- After PR #88770 enabled JIT compilation for `Decimal` types, `if(cond, decimal_col, int_literal)` +-- (and the symmetric `if(cond, int_literal, decimal_col)`, plus `multiIf` with mixed branches) +-- silently returned a value `10^scale` too small. The JIT codegen for `if`/`multiIf` called +-- `nativeCast` to convert the integer-literal branch to the `Decimal` result type, but +-- `nativeCast` only reinterprets the integer bits — it does not multiply by `10^scale`. +-- Each query below must produce the same result as the non-JIT path. + +SET min_count_to_compile_expression = 0; +SET compile_expressions = 1; + +-- Original den-crane reproducer. +WITH materialize(1::Decimal(18, 7)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)) AS broken_sum; + +-- Both branches of `if` exercised, integer literal in else. +WITH materialize(2::Decimal(18, 7)) AS r, materialize(0) AS k SELECT sum(if(k != 1, r, 1)); +WITH materialize(2::Decimal(18, 7)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); + +-- Integer literal in then branch. +WITH materialize(2::Decimal(18, 7)) AS r, materialize(1) AS k SELECT sum(if(k = 1, 1, r)); +WITH materialize(2::Decimal(18, 7)) AS r, materialize(0) AS k SELECT sum(if(k = 1, 1, r)); + +-- `multiIf` with integer literals interleaved with a `Decimal` else branch. +WITH materialize(3::Decimal(18, 7)) AS r, materialize(1) AS k SELECT sum(multiIf(k = 1, 1, k = 2, 2, r)); +WITH materialize(3::Decimal(18, 7)) AS r, materialize(2) AS k SELECT sum(multiIf(k = 1, 1, k = 2, 2, r)); +WITH materialize(3::Decimal(18, 7)) AS r, materialize(0) AS k SELECT sum(multiIf(k = 1, 1, k = 2, 2, r)); + +-- All `Decimal` widths. +WITH materialize(1::Decimal(9, 4)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); +WITH materialize(1::Decimal(18, 7)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); +WITH materialize(1::Decimal(38, 7)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); +WITH materialize(1::Decimal(38, 11)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); + +-- High-scale `Decimal128`: `10^scale` exceeds 64 bits. The JIT helper builds the scale +-- factor as a `128`-bit `APInt`, so the multiplication has to stay correct without ever +-- narrowing to `uint64_t`. +WITH materialize(1::Decimal(38, 20)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); +WITH materialize(1::Decimal(38, 30)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); +WITH materialize(1::Decimal(38, 37)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); +WITH materialize(2::Decimal(38, 30)) AS r, materialize(1) AS k SELECT sum(if(k = 1, 1, r)); +WITH materialize(3::Decimal(38, 30)) AS r, materialize(2) AS k SELECT sum(multiIf(k = 1, 1, k = 2, 2, r)); + +-- `Decimal256` high scale: `10^scale` exceeds even 128 bits, exercising the `256`-bit `APInt` path. +WITH materialize(1::Decimal(76, 60)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); +WITH materialize(1::Decimal(76, 73)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); + +-- `Float` -> `Decimal` branch lift (the analyzer promotes the result to `Decimal`). +WITH materialize(toDecimal64(1.5, 4)) AS r, materialize(1) AS k SELECT if(k != 1, r, 2.5::Float64); + +-- Sanity check: the non-JIT path produces the same answers. +SET compile_expressions = 0; +WITH materialize(1::Decimal(18, 7)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); +WITH materialize(3::Decimal(18, 7)) AS r, materialize(2) AS k SELECT sum(multiIf(k = 1, 1, k = 2, 2, r)); +WITH materialize(1::Decimal(38, 11)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); +WITH materialize(1::Decimal(38, 30)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); +WITH materialize(1::Decimal(38, 37)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); +WITH materialize(1::Decimal(76, 73)) AS r, materialize(1) AS k SELECT sum(if(k != 1, r, 1)); diff --git a/tests/queries/0_stateless/04205_jit_decimal_cast_branches_parity.reference b/tests/queries/0_stateless/04205_jit_decimal_cast_branches_parity.reference new file mode 100644 index 000000000000..b3b90d1613a3 --- /dev/null +++ b/tests/queries/0_stateless/04205_jit_decimal_cast_branches_parity.reference @@ -0,0 +1,70 @@ +int8_to_dec9_0:jit 1 +int8_to_dec9_0:no_jit 1 +uint8_to_dec18_0:jit 255 +uint8_to_dec18_0:no_jit 255 +int64_to_dec38_0:jit -9223372036854775807 +int64_to_dec38_0:no_jit -9223372036854775807 +uint64_to_dec38_0:jit 18446744073709551615 +uint64_to_dec38_0:no_jit 18446744073709551615 +int8_to_dec9_4_pos:jit 7 +int8_to_dec9_4_pos:no_jit 7 +int8_to_dec9_4_neg:jit -7 +int8_to_dec9_4_neg:no_jit -7 +int16_to_dec18_4:jit -32000 +int16_to_dec18_4:no_jit -32000 +uint16_to_dec18_4:jit 65535 +uint16_to_dec18_4:no_jit 65535 +int32_to_dec18_7:jit -1234567890 +int32_to_dec18_7:no_jit -1234567890 +uint32_to_dec18_7:jit 4294967295 +uint32_to_dec18_7:no_jit 4294967295 +int64_to_dec38_11:jit 123456789 +int64_to_dec38_11:no_jit 123456789 +int8_to_dec38_35:jit 7 +int8_to_dec38_35:no_jit 7 +uint8_to_dec38_35:jit 7 +uint8_to_dec38_35:no_jit 7 +int16_to_dec38_33:jit -7 +int16_to_dec38_33:no_jit -7 +int32_to_dec38_28:jit 7 +int32_to_dec38_28:no_jit 7 +int32_to_dec38_30_via_dec76:jit -3 +int32_to_dec38_30_via_dec76:no_jit -3 +int8_to_dec38_37_via_dec76:jit 7 +int8_to_dec38_37_via_dec76:no_jit 7 +int32_to_dec76_50:jit 7 +int32_to_dec76_50:no_jit 7 +int8_to_dec76_73:jit -3 +int8_to_dec76_73:no_jit -3 +dec9_to_dec18_same_scale:jit 1.5 +dec9_to_dec18_same_scale:no_jit 1.5 +dec18_to_dec38_same_scale:jit 2.5 +dec18_to_dec38_same_scale:no_jit 2.5 +dec38_to_dec76_same_scale:jit 1.5 +dec38_to_dec76_same_scale:no_jit 1.5 +nullable_dec_int_jit 1.5 +nullable_dec_int_no_jit 1.5 +both_nullable_same_scale:jit 2.5 +both_nullable_same_scale:no_jit 2.5 +nullable_picks_null_jit \N +nullable_picks_null_no_jit \N +identity_dec18_4:jit 1.5 +identity_dec18_4:no_jit 1.5 +identity_dec76_60:jit 2.5 +identity_dec76_60:no_jit 2.5 +multiif_dec38_30_pick0:jit 1 +multiif_dec38_30_pick0:no_jit 1 +multiif_dec38_30_pickelse:jit 3.5 +multiif_dec38_30_pickelse:no_jit 3.5 +multiif_dec76_60:jit 1 +multiif_dec76_60:no_jit 1 +materialized_dec18_7:jit 1 +materialized_dec18_7:no_jit 1 +materialized_dec38_30:jit 1 +materialized_dec38_30:no_jit 1 +materialized_dec76_73:jit 1 +materialized_dec76_73:no_jit 1 +materialized_int_to_dec38_30:jit 1.5 +materialized_int_to_dec38_30:no_jit 1.5 +multirow_multiif:jit ['1','2','3','5.5','5.5'] +multirow_multiif:no_jit ['1','2','3','5.5','5.5'] diff --git a/tests/queries/0_stateless/04205_jit_decimal_cast_branches_parity.sql b/tests/queries/0_stateless/04205_jit_decimal_cast_branches_parity.sql new file mode 100644 index 000000000000..ca1d5926f830 --- /dev/null +++ b/tests/queries/0_stateless/04205_jit_decimal_cast_branches_parity.sql @@ -0,0 +1,287 @@ +-- Tags: no-fasttest +-- +-- Per-branch parity tests for `nativeCastWithDecimalScale`, used by JIT-compiled +-- `if`/`multiIf` when at least one branch has a `Decimal` type. +-- +-- Each block prints the same expression twice: once with `compile_expressions = 1` +-- (the JIT path that calls `nativeCastWithDecimalScale`) and once with +-- `compile_expressions = 0` (the interpreter path). Both must produce identical +-- output. The "jit" / "no_jit" label on every row makes a divergence trivially +-- visible in the diff against the reference file. +-- +-- IMPORTANT: every case wraps the `if`/`multiIf` condition in `materialize(...)`. +-- Without it, the analyzer constant-folds the entire expression at planning +-- time (a constant condition with constant branches collapses to a single +-- `Const` column) and the `if` function is never invoked, so the JIT path is +-- bypassed. `materialize` on the condition forces the function to be evaluated +-- per row, so `FunctionIfBase::compileImpl` runs and `nativeCastWithDecimalScale` +-- is called for each branch's cast to the result type. Verified via +-- `EXPLAIN actions = 1`: with `materialize` the action graph contains an +-- explicit `FUNCTION if(...)` node; without it, the entire expression collapses +-- to a single `COLUMN Const(...)` produced at planning time. +-- +-- Background: regression first reported in +-- https://github.com/ClickHouse/ClickHouse/issues/103808 and fixed in PR #103809 +-- ("Fix wrong values from JIT-compiled if/multiIf with Decimal result"). +-- +-- Branches of `nativeCastWithDecimalScale` exercised here: +-- * Integer -> `Decimal`, `to_scale = 0` (widen only) +-- * Integer -> `Decimal`, `to_scale > 0` (widen + multiply by `10^to_scale`) +-- - factors that fit in 64 bits (small precision targets) +-- - factors that exceed 64 bits, fit in 128 bits (`Decimal128` `to_scale >= 20`) +-- - factors that exceed 128 bits (`Decimal256` `to_scale >= 39`) +-- * `Decimal` -> `Decimal`, same scale, widen integer storage +-- * Identity (`from_type == to_type`) +-- * `Nullable` wrappers (`Nullable -> Nullable`, `T -> Nullable`) +-- +-- Branches NOT exercised here, with reasons: +-- +-- * `Float32`/`Float64` <-> `Decimal`, `Date`/`Date32` <-> `Decimal`: +-- the analyzer promotes the result type to `Variant` because +-- `use_variant_as_common_type = 1` by default, and `canBeNativeType` +-- excludes `Variant`. `FunctionIfBase::isCompilableImpl` returns `false` +-- and the helper is never called. The helper still has correct code paths +-- for these (the `pow10_fp_const` helper avoids 64-bit narrowing via +-- `APFloat::convertFromAPInt` so high-bit-width `Decimal128`/`Decimal256` +-- factors stay accurate) so it is forward-compatible if the analyzer ever +-- stops promoting to `Variant`. +-- +-- * `Decimal` -> `Decimal` with different scales (scale increase OR decrease): +-- `FunctionIf::executeImpl` rejects this with `NOT_IMPLEMENTED: +-- "Conditional functions with different Decimal scales"` at planning time +-- (via `executeDryRunImpl` from `ActionsDAG::updateHeader`). Even with +-- `compile_expressions = 1` the planner runs the interpreter to validate +-- types, so the JIT path is unreachable from `if`/`multiIf` for any +-- two-Decimal pair whose scales differ. The Dec->Dec scale-multiplier and +-- scale-divider paths in `nativeCastWithDecimalScale` are exercised +-- indirectly through the `Integer -> Decimal` arm above, which produces +-- the same `pow10_int_const(width, n)` factor on the same arithmetic IR. +-- The dedicated Dec->Dec scale-conversion case is only reachable through +-- explicit `cast(...)`, which uses different machinery. +-- +-- * `Decimal` -> integer (narrowing): unreachable through `if` typing because +-- the supertype always picks the wider type (Decimal). Same situation as +-- above. +-- +-- * Integer -> `Decimal` where the integer's digit count exceeds the target +-- precision's headroom: e.g. `if(Int8, Decimal(76, 74))` requires precision +-- >= 3 + 74 = 77 > 76 and the analyzer promotes to `Variant`. We pick +-- scales that leave just enough headroom for the source integer. +-- +-- Note on supertype promotion: `if(Int, Decimal(P, S))` picks the least +-- supertype, which often is wider than `P` because the integer needs digits +-- before the decimal point. For example `if(bool, Decimal(38, 30), Int32)` +-- promotes to `Decimal(76, 30)` (Int32 needs 10 digits + scale 30 = 40 > 38), +-- so its multiplier `10^30` actually runs in 256-bit `APInt` arithmetic. The +-- inline comment on each high-scale case names the actual JIT supertype. + +SET min_count_to_compile_expression = 0; + +-- ============================================================================ +-- Branch: Integer -> Decimal, to_scale = 0 (just widen integer storage) +-- ============================================================================ +SELECT 'int8_to_dec9_0:jit', toString(if(materialize(toBool(1)), 1::Decimal(9, 0), toInt8(7))) SETTINGS compile_expressions = 1; +SELECT 'int8_to_dec9_0:no_jit', toString(if(materialize(toBool(1)), 1::Decimal(9, 0), toInt8(7))) SETTINGS compile_expressions = 0; + +SELECT 'uint8_to_dec18_0:jit', toString(if(materialize(toBool(0)), 1::Decimal(18, 0), toUInt8(255))) SETTINGS compile_expressions = 1; +SELECT 'uint8_to_dec18_0:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(18, 0), toUInt8(255))) SETTINGS compile_expressions = 0; + +SELECT 'int64_to_dec38_0:jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 0), toInt64(-9223372036854775807))) SETTINGS compile_expressions = 1; +SELECT 'int64_to_dec38_0:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 0), toInt64(-9223372036854775807))) SETTINGS compile_expressions = 0; + +SELECT 'uint64_to_dec38_0:jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 0), toUInt64(18446744073709551615))) SETTINGS compile_expressions = 1; +SELECT 'uint64_to_dec38_0:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 0), toUInt64(18446744073709551615))) SETTINGS compile_expressions = 0; + +-- ============================================================================ +-- Branch: Integer -> Decimal, to_scale > 0, factor `10^to_scale` <= 64 bits +-- ============================================================================ +SELECT 'int8_to_dec9_4_pos:jit', toString(if(materialize(toBool(0)), 1::Decimal(9, 4), toInt8(7))) SETTINGS compile_expressions = 1; +SELECT 'int8_to_dec9_4_pos:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(9, 4), toInt8(7))) SETTINGS compile_expressions = 0; + +SELECT 'int8_to_dec9_4_neg:jit', toString(if(materialize(toBool(0)), 1::Decimal(9, 4), toInt8(-7))) SETTINGS compile_expressions = 1; +SELECT 'int8_to_dec9_4_neg:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(9, 4), toInt8(-7))) SETTINGS compile_expressions = 0; + +SELECT 'int16_to_dec18_4:jit', toString(if(materialize(toBool(0)), 1::Decimal(18, 4), toInt16(-32000))) SETTINGS compile_expressions = 1; +SELECT 'int16_to_dec18_4:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(18, 4), toInt16(-32000))) SETTINGS compile_expressions = 0; + +SELECT 'uint16_to_dec18_4:jit', toString(if(materialize(toBool(0)), 1::Decimal(18, 4), toUInt16(65535))) SETTINGS compile_expressions = 1; +SELECT 'uint16_to_dec18_4:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(18, 4), toUInt16(65535))) SETTINGS compile_expressions = 0; + +SELECT 'int32_to_dec18_7:jit', toString(if(materialize(toBool(0)), 1::Decimal(18, 7), toInt32(-1234567890))) SETTINGS compile_expressions = 1; +SELECT 'int32_to_dec18_7:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(18, 7), toInt32(-1234567890))) SETTINGS compile_expressions = 0; + +SELECT 'uint32_to_dec18_7:jit', toString(if(materialize(toBool(0)), 1::Decimal(18, 7), toUInt32(4294967295))) SETTINGS compile_expressions = 1; +SELECT 'uint32_to_dec18_7:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(18, 7), toUInt32(4294967295))) SETTINGS compile_expressions = 0; + +-- Decimal128 storage (128-bit), factor `10^to_scale` still <= 64 bits. +SELECT 'int64_to_dec38_11:jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 11), toInt64(123456789))) SETTINGS compile_expressions = 1; +SELECT 'int64_to_dec38_11:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 11), toInt64(123456789))) SETTINGS compile_expressions = 0; + +-- ============================================================================ +-- Branch: Integer -> Decimal128 (128-bit storage) with `10^to_scale` > 64 bits. +-- The `pow10_int_const` factor is constructed in 128-bit `APInt`. Supertype +-- stays `Decimal(38, S)` because the integer source's digit count fits in +-- 38 - S precision headroom (e.g. Int8 with scale 35: 3 digits + 35 = 38). +-- ============================================================================ +SELECT 'int8_to_dec38_35:jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 35), toInt8(7))) SETTINGS compile_expressions = 1; +SELECT 'int8_to_dec38_35:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 35), toInt8(7))) SETTINGS compile_expressions = 0; + +SELECT 'uint8_to_dec38_35:jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 35), toUInt8(7))) SETTINGS compile_expressions = 1; +SELECT 'uint8_to_dec38_35:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 35), toUInt8(7))) SETTINGS compile_expressions = 0; + +SELECT 'int16_to_dec38_33:jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 33), toInt16(-7))) SETTINGS compile_expressions = 1; +SELECT 'int16_to_dec38_33:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 33), toInt16(-7))) SETTINGS compile_expressions = 0; + +SELECT 'int32_to_dec38_28:jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 28), toInt32(7))) SETTINGS compile_expressions = 1; +SELECT 'int32_to_dec38_28:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 28), toInt32(7))) SETTINGS compile_expressions = 0; + +-- ============================================================================ +-- Branch: Integer -> Decimal256 (256-bit storage) with `10^to_scale` > 128 bits. +-- The `pow10_int_const` factor is constructed in 256-bit `APInt`. Supertype is +-- `Decimal(76, S)` either by direct request or by precision-headroom promotion. +-- ============================================================================ +-- `if(bool, Decimal(38, 30), Int32)` promotes to `Decimal(76, 30)` because +-- Int32 needs 10 digits + scale 30 = 40 > 38, exceeding Decimal128 precision. +SELECT 'int32_to_dec38_30_via_dec76:jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 30), toInt32(-3))) SETTINGS compile_expressions = 1; +SELECT 'int32_to_dec38_30_via_dec76:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 30), toInt32(-3))) SETTINGS compile_expressions = 0; + +-- `if(bool, Decimal(38, 37), Int8)` -> `Decimal(76, 37)` for the same reason. +SELECT 'int8_to_dec38_37_via_dec76:jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 37), toInt8(7))) SETTINGS compile_expressions = 1; +SELECT 'int8_to_dec38_37_via_dec76:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(38, 37), toInt8(7))) SETTINGS compile_expressions = 0; + +-- Direct Decimal256 supertype (no promotion), factor `10^50` ~ 167 bits. +SELECT 'int32_to_dec76_50:jit', toString(if(materialize(toBool(0)), 1::Decimal(76, 50), toInt32(7))) SETTINGS compile_expressions = 1; +SELECT 'int32_to_dec76_50:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(76, 50), toInt32(7))) SETTINGS compile_expressions = 0; + +-- Direct Decimal256, factor `10^73` ~ 243 bits. Int8 fits because 3 + 73 = 76. +SELECT 'int8_to_dec76_73:jit', toString(if(materialize(toBool(0)), 1::Decimal(76, 73), toInt8(-3))) SETTINGS compile_expressions = 1; +SELECT 'int8_to_dec76_73:no_jit', toString(if(materialize(toBool(0)), 1::Decimal(76, 73), toInt8(-3))) SETTINGS compile_expressions = 0; + +-- ============================================================================ +-- Branch: Decimal -> Decimal, same scale (only widen integer storage type). +-- Different precisions but identical scales pass `FunctionIf::decimalScale` +-- check (it requires `left_scale == right_scale`, not equal precisions). +-- ============================================================================ +-- 32-bit -> 64-bit storage transition. +SELECT 'dec9_to_dec18_same_scale:jit', toString(if(materialize(toBool(1)), 1.5::Decimal(18, 4), 2.5::Decimal(9, 4))) SETTINGS compile_expressions = 1; +SELECT 'dec9_to_dec18_same_scale:no_jit', toString(if(materialize(toBool(1)), 1.5::Decimal(18, 4), 2.5::Decimal(9, 4))) SETTINGS compile_expressions = 0; + +-- 64-bit -> 128-bit storage transition. +SELECT 'dec18_to_dec38_same_scale:jit', toString(if(materialize(toBool(0)), 1.5::Decimal(38, 4), 2.5::Decimal(18, 4))) SETTINGS compile_expressions = 1; +SELECT 'dec18_to_dec38_same_scale:no_jit', toString(if(materialize(toBool(0)), 1.5::Decimal(38, 4), 2.5::Decimal(18, 4))) SETTINGS compile_expressions = 0; + +-- 128-bit -> 256-bit storage transition. +SELECT 'dec38_to_dec76_same_scale:jit', toString(if(materialize(toBool(1)), 1.5::Decimal(76, 4), 2.5::Decimal(38, 4))) SETTINGS compile_expressions = 1; +SELECT 'dec38_to_dec76_same_scale:no_jit', toString(if(materialize(toBool(1)), 1.5::Decimal(76, 4), 2.5::Decimal(38, 4))) SETTINGS compile_expressions = 0; + +-- ============================================================================ +-- Branch: Nullable wrappers. +-- The reachable arms through `if`/`multiIf` are: +-- * `T -> Nullable(T)` (the supertype lifts non-Nullable side to Nullable) +-- * `Nullable(T) -> Nullable(T')` where `T` and `T'` have identical scales +-- (or one side is integer, which goes through the `Decimal <- Int` arm). +-- The pure `Nullable -> non-Nullable` arm is unreachable from `if` typing. +-- ============================================================================ +-- Nullable Decimal vs non-Nullable Int -> Nullable Decimal supertype. +-- Exercises `T -> Nullable(T)` arm of `nativeCastWithDecimalScale` (lifts the +-- inner Int -> Decimal cast and then wraps with null = 0 marker). +SELECT 'nullable_dec_int_jit', toString(if(materialize(toBool(1)), toNullable(1.5::Decimal(38, 30)), toInt32(7))) SETTINGS compile_expressions = 1; +SELECT 'nullable_dec_int_no_jit', toString(if(materialize(toBool(1)), toNullable(1.5::Decimal(38, 30)), toInt32(7))) SETTINGS compile_expressions = 0; + +-- Both sides Nullable, identical scales (different precisions). +-- Exercises `Nullable -> Nullable` arm of `nativeCastWithDecimalScale`. +SELECT 'both_nullable_same_scale:jit', toString(if(materialize(toBool(0)), toNullable(1.5::Decimal(38, 4)), toNullable(2.5::Decimal(18, 4)))) SETTINGS compile_expressions = 1; +SELECT 'both_nullable_same_scale:no_jit', toString(if(materialize(toBool(0)), toNullable(1.5::Decimal(38, 4)), toNullable(2.5::Decimal(18, 4)))) SETTINGS compile_expressions = 0; + +-- Non-Nullable Decimal vs typed-NULL Nullable Decimal, identical scales. +-- Exercises `T -> Nullable(T)` plus the null-mask propagation for the picked +-- NULL value. +SELECT 'nullable_picks_null_jit', toString(if(materialize(toBool(0)), 1.5::Decimal(38, 30), CAST(NULL, 'Nullable(Decimal(38, 30))'))) SETTINGS compile_expressions = 1; +SELECT 'nullable_picks_null_no_jit', toString(if(materialize(toBool(0)), 1.5::Decimal(38, 30), CAST(NULL, 'Nullable(Decimal(38, 30))'))) SETTINGS compile_expressions = 0; + +-- ============================================================================ +-- Branch: identity (`from_type == to_type`), short-circuit return of original +-- value. Triggered when both branches have IDENTICAL Decimal type (both +-- precision and scale match), so `nativeCastWithDecimalScale` returns the +-- input value unchanged. +-- ============================================================================ +SELECT 'identity_dec18_4:jit', toString(if(materialize(toBool(1)), 1.5::Decimal(18, 4), 2.5::Decimal(18, 4))) SETTINGS compile_expressions = 1; +SELECT 'identity_dec18_4:no_jit', toString(if(materialize(toBool(1)), 1.5::Decimal(18, 4), 2.5::Decimal(18, 4))) SETTINGS compile_expressions = 0; + +SELECT 'identity_dec76_60:jit', toString(if(materialize(toBool(0)), 1.5::Decimal(76, 60), 2.5::Decimal(76, 60))) SETTINGS compile_expressions = 1; +SELECT 'identity_dec76_60:no_jit', toString(if(materialize(toBool(0)), 1.5::Decimal(76, 60), 2.5::Decimal(76, 60))) SETTINGS compile_expressions = 0; + +-- ============================================================================ +-- Branch: `multiIf` with mixed integer literals + Decimal else +-- (the original failure mode from #103808). The integer arms exercise +-- `nativeCastWithDecimalScale` Int -> Decimal at the result type. +-- ============================================================================ +SELECT 'multiif_dec38_30_pick0:jit', toString(multiIf(materialize(toBool(1)), 1, toBool(0), 2, 3.5::Decimal(38, 30))) SETTINGS compile_expressions = 1; +SELECT 'multiif_dec38_30_pick0:no_jit', toString(multiIf(materialize(toBool(1)), 1, toBool(0), 2, 3.5::Decimal(38, 30))) SETTINGS compile_expressions = 0; + +SELECT 'multiif_dec38_30_pickelse:jit', toString(multiIf(materialize(toBool(0)), 1, toBool(0), 2, 3.5::Decimal(38, 30))) SETTINGS compile_expressions = 1; +SELECT 'multiif_dec38_30_pickelse:no_jit', toString(multiIf(materialize(toBool(0)), 1, toBool(0), 2, 3.5::Decimal(38, 30))) SETTINGS compile_expressions = 0; + +SELECT 'multiif_dec76_60:jit', toString(multiIf(materialize(toBool(1)), 1, toBool(0), 2, 3.5::Decimal(76, 60))) SETTINGS compile_expressions = 1; +SELECT 'multiif_dec76_60:no_jit', toString(multiIf(materialize(toBool(1)), 1, toBool(0), 2, 3.5::Decimal(76, 60))) SETTINGS compile_expressions = 0; + +-- ============================================================================ +-- Materialized columns from a subquery (the original failure from #103808). +-- ============================================================================ +SELECT 'materialized_dec18_7:jit', + toString(sum(if(k != 1, r, 1))) +FROM (SELECT materialize(1::Decimal(18, 7)) AS r, materialize(1) AS k) +SETTINGS compile_expressions = 1; +SELECT 'materialized_dec18_7:no_jit', + toString(sum(if(k != 1, r, 1))) +FROM (SELECT materialize(1::Decimal(18, 7)) AS r, materialize(1) AS k) +SETTINGS compile_expressions = 0; + +SELECT 'materialized_dec38_30:jit', + toString(sum(if(k != 1, r, 1))) +FROM (SELECT materialize(1::Decimal(38, 30)) AS r, materialize(1) AS k) +SETTINGS compile_expressions = 1; +SELECT 'materialized_dec38_30:no_jit', + toString(sum(if(k != 1, r, 1))) +FROM (SELECT materialize(1::Decimal(38, 30)) AS r, materialize(1) AS k) +SETTINGS compile_expressions = 0; + +SELECT 'materialized_dec76_73:jit', + toString(sum(if(k != 1, r, 1))) +FROM (SELECT materialize(1::Decimal(76, 73)) AS r, materialize(1) AS k) +SETTINGS compile_expressions = 1; +SELECT 'materialized_dec76_73:no_jit', + toString(sum(if(k != 1, r, 1))) +FROM (SELECT materialize(1::Decimal(76, 73)) AS r, materialize(1) AS k) +SETTINGS compile_expressions = 0; + +-- Materialized integer + materialized Decimal branch +-- (exercises Int -> Decimal helper with non-constant integer input). +SELECT 'materialized_int_to_dec38_30:jit', + toString(sum(if(k != 0, r, k))) +FROM (SELECT materialize(1.5::Decimal(38, 30)) AS r, materialize(toInt64(7)) AS k) +SETTINGS compile_expressions = 1; +SELECT 'materialized_int_to_dec38_30:no_jit', + toString(sum(if(k != 0, r, k))) +FROM (SELECT materialize(1.5::Decimal(38, 30)) AS r, materialize(toInt64(7)) AS k) +SETTINGS compile_expressions = 0; + +-- ============================================================================ +-- multiIf over a multi-row table with mixed branch types. +-- Each row picks a different branch, exercising the JIT path through +-- materialized integer keys with a high-scale Decimal else branch. +-- ============================================================================ +DROP TABLE IF EXISTS jit_decimal_parity_input; +CREATE TABLE jit_decimal_parity_input (idx UInt32, k Int64) ENGINE = MergeTree ORDER BY idx; +INSERT INTO jit_decimal_parity_input VALUES (0, 0), (1, 1), (2, 2), (3, -7), (4, 100); + +SELECT 'multirow_multiif:jit', + arraySort(groupArray(toString(multiIf(k = 0, 1, k = 1, 2, k = 2, 3, 5.5::Decimal(38, 30))))) +FROM jit_decimal_parity_input +SETTINGS compile_expressions = 1; +SELECT 'multirow_multiif:no_jit', + arraySort(groupArray(toString(multiIf(k = 0, 1, k = 1, 2, k = 2, 3, 5.5::Decimal(38, 30))))) +FROM jit_decimal_parity_input +SETTINGS compile_expressions = 0; + +DROP TABLE jit_decimal_parity_input; From e1c11930c28196f954a93287e43c1aa112c8c607 Mon Sep 17 00:00:00 2001 From: robot-ch-test-poll3 <69307580+robot-ch-test-poll3@users.noreply.github.com> Date: Thu, 7 May 2026 07:21:07 +0700 Subject: [PATCH 69/70] Backport #104063 to 26.3: Bypass index uncompressed cache when its size is zero (#104166) * Backport #104063 to 26.3: Bypass index uncompressed cache when its size is zero * Add reload_before/reload_after to with_replace_config Cherry-picked from b5149576b260 (the cluster.py portion). The whitespace-only KEEPER_PUBLISH_CLIENT hunk was skipped because that code does not exist on this branch. Co-Authored-By: Claude Opus 4.7 (1M context) --------- Co-authored-by: robot-clickhouse Co-authored-by: Michael Kolupaev Co-authored-by: Claude Opus 4.7 (1M context) --- src/Core/ServerSettings.cpp | 2 +- src/Interpreters/Context.cpp | 7 +- src/Interpreters/Context.h | 2 +- tests/integration/helpers/cluster.py | 6 +- .../__init__.py | 0 .../configs/cache_size.xml | 3 + .../test.py | 113 ++++++++++++++++++ 7 files changed, 129 insertions(+), 4 deletions(-) create mode 100644 tests/integration/test_index_uncompressed_cache_zero_size/__init__.py create mode 100644 tests/integration/test_index_uncompressed_cache_zero_size/configs/cache_size.xml create mode 100644 tests/integration/test_index_uncompressed_cache_zero_size/test.py diff --git a/src/Core/ServerSettings.cpp b/src/Core/ServerSettings.cpp index bd107f454af1..5bcc251f8e15 100644 --- a/src/Core/ServerSettings.cpp +++ b/src/Core/ServerSettings.cpp @@ -1739,7 +1739,7 @@ void ServerSettings::dumpToSystemServerSettingsColumns(ServerSettingColumnsParam {"mark_cache_size", {std::to_string(context->getMarkCache()->maxSizeInBytes()), ChangeableWithoutRestart::Yes}}, {"uncompressed_cache_size", {std::to_string(context->getUncompressedCache()->maxSizeInBytes()), ChangeableWithoutRestart::Yes}}, {"index_mark_cache_size", {std::to_string(context->getIndexMarkCache()->maxSizeInBytes()), ChangeableWithoutRestart::Yes}}, - {"index_uncompressed_cache_size", {std::to_string(context->getIndexUncompressedCache()->maxSizeInBytes()), ChangeableWithoutRestart::Yes}}, + {"index_uncompressed_cache_size", {std::to_string(context->getIndexUncompressedCache(/*only_if_enabled=*/ false)->maxSizeInBytes()), ChangeableWithoutRestart::Yes}}, {"mmap_cache_size", {std::to_string(context->getMMappedFileCache()->maxSizeInBytes()), ChangeableWithoutRestart::Yes}}, {"query_condition_cache_size", {std::to_string(context->getQueryConditionCache()->maxSizeInBytes()), ChangeableWithoutRestart::Yes}}, {"primary_index_cache_size", {std::to_string(context->getPrimaryIndexCache()->maxSizeInBytes()), ChangeableWithoutRestart::Yes}}, diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index b8dffbba52e7..a9b1a948f2ea 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -551,6 +551,7 @@ struct ContextSharedPart : boost::noncopyable mutable OnceFlag build_vector_similarity_index_threadpool_initialized; mutable std::unique_ptr build_vector_similarity_index_threadpool; /// Threadpool for vector-similarity index creation. mutable UncompressedCachePtr index_uncompressed_cache TSA_GUARDED_BY(mutex); /// The cache of decompressed blocks for MergeTree indices. + mutable bool index_uncompressed_cache_enabled TSA_GUARDED_BY(mutex) = false; /// Whether index_uncompressed_cache should be used. mutable VectorSimilarityIndexCachePtr vector_similarity_index_cache TSA_GUARDED_BY(mutex); /// Cache of deserialized secondary index granules. mutable TextIndexTokensCachePtr text_index_tokens_cache TSA_GUARDED_BY(mutex); /// Cache of deserialized text index tokens. mutable TextIndexHeaderCachePtr text_index_header_cache TSA_GUARDED_BY(mutex); /// Cache of deserialized text index headers. @@ -4038,6 +4039,7 @@ void Context::setIndexUncompressedCache(const String & cache_policy, size_t max_ throw Exception(ErrorCodes::LOGICAL_ERROR, "Index uncompressed cache has been already created."); shared->index_uncompressed_cache = std::make_shared(cache_policy, CurrentMetrics::IndexUncompressedCacheBytes, CurrentMetrics::IndexUncompressedCacheCells, max_size_in_bytes, size_ratio); + shared->index_uncompressed_cache_enabled = shared->index_uncompressed_cache->maxSizeInBytes() != 0; } void Context::updateIndexUncompressedCacheConfiguration(const Poco::Util::AbstractConfiguration & config) @@ -4049,11 +4051,14 @@ void Context::updateIndexUncompressedCacheConfiguration(const Poco::Util::Abstra size_t max_size_in_bytes = config.getUInt64("index_uncompressed_cache_size", DEFAULT_INDEX_UNCOMPRESSED_CACHE_MAX_SIZE); shared->index_uncompressed_cache->setMaxSizeInBytes(max_size_in_bytes); + shared->index_uncompressed_cache_enabled = shared->index_uncompressed_cache->maxSizeInBytes() != 0; } -UncompressedCachePtr Context::getIndexUncompressedCache() const +UncompressedCachePtr Context::getIndexUncompressedCache(bool only_if_enabled) const { SharedLockGuard lock(shared->mutex); + if (only_if_enabled && !shared->index_uncompressed_cache_enabled) + return nullptr; return shared->index_uncompressed_cache; } diff --git a/src/Interpreters/Context.h b/src/Interpreters/Context.h index a8ba3ebaec0c..9d24b4e9f187 100644 --- a/src/Interpreters/Context.h +++ b/src/Interpreters/Context.h @@ -1371,7 +1371,7 @@ class Context: public ContextData, public std::enable_shared_from_this void setIndexUncompressedCache(const String & cache_policy, size_t max_size_in_bytes, double size_ratio); void updateIndexUncompressedCacheConfiguration(const Poco::Util::AbstractConfiguration & config); - std::shared_ptr getIndexUncompressedCache() const; + std::shared_ptr getIndexUncompressedCache(bool only_if_enabled = true) const; void clearIndexUncompressedCache() const; void setIndexMarkCache(const String & cache_policy, size_t max_cache_size_in_bytes, double size_ratio); diff --git a/tests/integration/helpers/cluster.py b/tests/integration/helpers/cluster.py index defdd830e5ac..96287aea4c82 100644 --- a/tests/integration/helpers/cluster.py +++ b/tests/integration/helpers/cluster.py @@ -5504,7 +5504,7 @@ def _create_odbc_config_file(self): f.write(key + "=" + value + "\n") @contextmanager - def with_replace_config(self, path, replacement): + def with_replace_config(self, path, replacement, reload_before=False, reload_after=False): """Create a copy of existing config (if exists) and revert on leaving the context""" _directory, filename = os.path.split(path) basename, extension = os.path.splitext(filename) @@ -5516,12 +5516,16 @@ def with_replace_config(self, path, replacement): self.exec_in_container( ["bash", "-c", "echo '{}' > {}".format(replacement, path)] ) + if reload_before: + self.query("SYSTEM RELOAD CONFIG") try: yield finally: self.exec_in_container( ["bash", "-c", f"test ! -f {backup_path} || mv {backup_path} {path}"] ) + if reload_after: + self.query("SYSTEM RELOAD CONFIG") def replace_config(self, path_to_config, replacement): self.exec_in_container( diff --git a/tests/integration/test_index_uncompressed_cache_zero_size/__init__.py b/tests/integration/test_index_uncompressed_cache_zero_size/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/integration/test_index_uncompressed_cache_zero_size/configs/cache_size.xml b/tests/integration/test_index_uncompressed_cache_zero_size/configs/cache_size.xml new file mode 100644 index 000000000000..e05fcc7bc958 --- /dev/null +++ b/tests/integration/test_index_uncompressed_cache_zero_size/configs/cache_size.xml @@ -0,0 +1,3 @@ + + 0 + diff --git a/tests/integration/test_index_uncompressed_cache_zero_size/test.py b/tests/integration/test_index_uncompressed_cache_zero_size/test.py new file mode 100644 index 000000000000..38d60148fb64 --- /dev/null +++ b/tests/integration/test_index_uncompressed_cache_zero_size/test.py @@ -0,0 +1,113 @@ +import pytest + +from helpers.cluster import ClickHouseCluster + +CACHE_CONFIG_PATH = "/etc/clickhouse-server/config.d/cache_size.xml" + +cluster = ClickHouseCluster(__file__) +node = cluster.add_instance( + "node", + main_configs=["configs/cache_size.xml"], + stay_alive=True, +) + + +@pytest.fixture(scope="module", autouse=True) +def start_cluster(): + try: + cluster.start() + node.query( + """ + CREATE TABLE t ( + id UInt64, + s String, + INDEX bf s TYPE bloom_filter GRANULARITY 1 + ) + ENGINE = MergeTree + ORDER BY id + SETTINGS index_granularity = 1024 + """ + ) + # A single part keeps the bloom-filter file deterministic across phases. + node.query( + "INSERT INTO t SELECT number, toString(number) FROM numbers(200000)" + ) + yield + finally: + cluster.shutdown() + + +def run_skip_index_query(query_id): + # Filtering on `s` forces the bloom_filter skip index to be loaded for every + # mark range, which is the path that exhibited the bug. + node.query( + "SELECT count() FROM t WHERE s = '12345'", + query_id=query_id, + settings={"use_skip_indexes": 1}, + ) + + +def get_cache_events(query_id): + node.query("SYSTEM FLUSH LOGS") + row = node.query( + f""" + SELECT + ProfileEvents['UncompressedCacheHits'], + ProfileEvents['UncompressedCacheMisses'], + ProfileEvents['UncompressedCacheWeightLost'] + FROM system.query_log + WHERE query_id = '{query_id}' AND type = 'QueryFinish' + FORMAT TSV + """ + ).strip() + assert row, f"No QueryFinish entry in system.query_log for query_id={query_id}" + hits, misses, weight_lost = row.split("\t") + return int(hits), int(misses), int(weight_lost) + + +def test_index_uncompressed_cache_runtime_toggle(): + # Phase 1: cache disabled (size=0 from initial config). The skip-index read + # path must bypass the cache entirely - no profile events should fire. + run_skip_index_query("phase1_disabled") + hits, misses, weight_lost = get_cache_events("phase1_disabled") + assert (hits, misses, weight_lost) == (0, 0, 0), ( + f"Expected zero index-uncompressed-cache events when the cache is " + f"disabled, got hits={hits}, misses={misses}, weight_lost={weight_lost}" + ) + + # Phase 2: enable the cache via runtime SYSTEM RELOAD CONFIG, verify that + # the cache is now actually used (misses on first query, hits on second). + with node.with_replace_config( + CACHE_CONFIG_PATH, + "10485760", + reload_before=True, + reload_after=True, + ): + node.query("SYSTEM DROP INDEX UNCOMPRESSED CACHE") + + run_skip_index_query("phase2_first") + hits, misses, weight_lost = get_cache_events("phase2_first") + assert misses > 0, ( + f"Expected misses with the cache enabled, " + f"got hits={hits}, misses={misses}, weight_lost={weight_lost}" + ) + assert hits == 0, ( + f"Expected no hits on the first query after dropping the cache, " + f"got hits={hits}" + ) + + run_skip_index_query("phase2_second") + hits, misses, weight_lost = get_cache_events("phase2_second") + assert hits > 0, ( + f"Expected hits on the repeated query, " + f"got hits={hits}, misses={misses}, weight_lost={weight_lost}" + ) + + # Phase 3: original config restored and reloaded by `reload_after=True`. + # Disabling the cache at runtime must again bypass it for new queries. + run_skip_index_query("phase3_redisabled") + hits, misses, weight_lost = get_cache_events("phase3_redisabled") + assert (hits, misses, weight_lost) == (0, 0, 0), ( + f"Expected zero index-uncompressed-cache events after re-disabling at " + f"runtime, got hits={hits}, misses={misses}, weight_lost={weight_lost}" + ) From 4c2521b26edb6047dde1ff730bb17968b50094f4 Mon Sep 17 00:00:00 2001 From: Andrey Zvonov Date: Fri, 8 May 2026 00:57:32 +0200 Subject: [PATCH 70/70] fix build --- src/Storages/StorageReplicatedMergeTree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storages/StorageReplicatedMergeTree.cpp b/src/Storages/StorageReplicatedMergeTree.cpp index 28fa6772b0aa..073d44cccef8 100644 --- a/src/Storages/StorageReplicatedMergeTree.cpp +++ b/src/Storages/StorageReplicatedMergeTree.cpp @@ -8409,7 +8409,7 @@ void StorageReplicatedMergeTree::exportPartitionToTable(const PartitionCommand & MergeTreeData::IMutationsSnapshot::Params mutations_snapshot_params { .metadata_version = getInMemoryMetadataPtr()->getMetadataVersion(), - .min_part_metadata_version = MergeTreeData::getMinMetadataVersion(parts), + .min_part_metadata_version = MergeTreeData::getPartsSnapshotInfo(parts).min_metadata_version, .need_data_mutations = throw_on_pending_mutations, .need_alter_mutations = throw_on_pending_mutations || throw_on_pending_patch_parts, .need_patch_parts = throw_on_pending_patch_parts,