From 8c7c928f6223af56d1a8fd96ba4adc5f6f85f25e Mon Sep 17 00:00:00 2001 From: Alexey Date: Sat, 21 Aug 2021 12:38:19 +0000 Subject: [PATCH 001/102] Description draft --- .../statements/create/function.md | 42 +++++++++++++++++++ docs/en/sql-reference/statements/drop.md | 21 +++++++++- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 docs/en/sql-reference/statements/create/function.md diff --git a/docs/en/sql-reference/statements/create/function.md b/docs/en/sql-reference/statements/create/function.md new file mode 100644 index 00000000000..c48535c44d3 --- /dev/null +++ b/docs/en/sql-reference/statements/create/function.md @@ -0,0 +1,42 @@ +--- +toc_priority: 38 +toc_title: FUNCTION +--- + +# CREATE FUNCTION {#create-function} + +Creates a user defined function from a lambda expression. + +**Syntax** + +```sql +CREATE FUNCTION {function_name} as ({parameters}) -> {function core} +``` + +Errors are caused by + +- Creating a function with a name that already exists; +- Recursive function. +- An identifier not listed in function parameters is used inside a function. + +**Example** + + +Query: + +```sql +CREATE FUNCTION plus_one as (a) -> a + 1; +SELECT number, plus_one(number) FROM numbers(3); +``` + +Result: + +``` text +┌─number─┬─plus_one─┐ +│ 0 │ 1 │ +│ 1 │ 2 │ +│ 2 │ 3 │ +└────────┴──────────┘ +``` + +- [DROP](../../../sql-reference/statements/drop.md#drop-function) diff --git a/docs/en/sql-reference/statements/drop.md b/docs/en/sql-reference/statements/drop.md index 90a2a46c7cf..4919c00a3dc 100644 --- a/docs/en/sql-reference/statements/drop.md +++ b/docs/en/sql-reference/statements/drop.md @@ -97,4 +97,23 @@ Syntax: DROP VIEW [IF EXISTS] [db.]name [ON CLUSTER cluster] ``` -[Оriginal article](https://clickhouse.tech/docs/en/sql-reference/statements/drop/) +## DROP FUNCTION {#drop-function} + +Deletes a user defined function created by [CREATE FUNCTION](./create/function.md). +System functions can not be dropped. + +**Syntax** + +``` sql +DROP FUNCTION [IF EXISTS] function_name +``` + +**Example** + +``` sql +CREATE FUNCTION plus_one as (a) -> a + 1; +DROP FUNCTION plus_one; +``` + + + From 77a1a35a05fd36443447460bfb20d5bb658518b8 Mon Sep 17 00:00:00 2001 From: Alexey Date: Sat, 21 Aug 2021 12:38:44 +0000 Subject: [PATCH 002/102] Additional links to CREATE and DROP FUNCTION --- docs/en/sql-reference/statements/create/index.md | 1 + docs/en/sql-reference/statements/grant.md | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/en/sql-reference/statements/create/index.md b/docs/en/sql-reference/statements/create/index.md index 902a4348bac..5721130dd24 100644 --- a/docs/en/sql-reference/statements/create/index.md +++ b/docs/en/sql-reference/statements/create/index.md @@ -12,6 +12,7 @@ Create queries make a new entity of one of the following kinds: - [TABLE](../../../sql-reference/statements/create/table.md) - [VIEW](../../../sql-reference/statements/create/view.md) - [DICTIONARY](../../../sql-reference/statements/create/dictionary.md) +- [FUNCTION](../../../sql-reference/statements/create/function.md) - [USER](../../../sql-reference/statements/create/user.md) - [ROLE](../../../sql-reference/statements/create/role.md) - [ROW POLICY](../../../sql-reference/statements/create/row-policy.md) diff --git a/docs/en/sql-reference/statements/grant.md b/docs/en/sql-reference/statements/grant.md index 25dffc36954..2b3cd68fbb2 100644 --- a/docs/en/sql-reference/statements/grant.md +++ b/docs/en/sql-reference/statements/grant.md @@ -107,11 +107,13 @@ Hierarchy of privileges: - `CREATE TEMPORARY TABLE` - `CREATE VIEW` - `CREATE DICTIONARY` + - `CREATE FUNCTION` - [DROP](#grant-drop) - `DROP DATABASE` - `DROP TABLE` - `DROP VIEW` - `DROP DICTIONARY` + - `DROP FUNCTION` - [TRUNCATE](#grant-truncate) - [OPTIMIZE](#grant-optimize) - [SHOW](#grant-show) From 1e4b90f3513d154e5d2fab3e3b3b9e4558c5e1ee Mon Sep 17 00:00:00 2001 From: Alexey Date: Sun, 22 Aug 2021 19:57:59 +0000 Subject: [PATCH 003/102] Description improved First example changed, new example added --- .../statements/create/function.md | 46 +++++++++++++------ docs/en/sql-reference/statements/drop.md | 7 +-- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/docs/en/sql-reference/statements/create/function.md b/docs/en/sql-reference/statements/create/function.md index c48535c44d3..8de7e23cfb1 100644 --- a/docs/en/sql-reference/statements/create/function.md +++ b/docs/en/sql-reference/statements/create/function.md @@ -5,38 +5,54 @@ toc_title: FUNCTION # CREATE FUNCTION {#create-function} -Creates a user defined function from a lambda expression. +Creates a user defined function from a lambda expression. The expression must consist of function parameters, constants, operators or other function calls. **Syntax** ```sql -CREATE FUNCTION {function_name} as ({parameters}) -> {function core} +CREATE FUNCTION name AS (parameter0, ...) -> expression ``` +A function can have an arbitrary number of parameters. +There are a few restrictions. -Errors are caused by +- The name of a function must be unique among user defined and system functions. +- Recursive functions are not allowed. +- All variables used by a function must be specified in its parameter list. -- Creating a function with a name that already exists; -- Recursive function. -- An identifier not listed in function parameters is used inside a function. +If any restriction is violated then an exception is raised. **Example** - Query: ```sql -CREATE FUNCTION plus_one as (a) -> a + 1; -SELECT number, plus_one(number) FROM numbers(3); +CREATE FUNCTION linear_equation AS (x, k, b) -> k*x + b; +SELECT number, linear_equation(number, 2, 1) FROM numbers(3); ``` Result: ``` text -┌─number─┬─plus_one─┐ -│ 0 │ 1 │ -│ 1 │ 2 │ -│ 2 │ 3 │ -└────────┴──────────┘ +┌─number─┬─linear_equation(number, 2, 1)─┐ +│ 0 │ 1 │ +│ 1 │ 3 │ +│ 2 │ 5 │ +└────────┴───────────────────────────────┘ ``` -- [DROP](../../../sql-reference/statements/drop.md#drop-function) +A [conditional function](../../../sql-reference/functions/conditional-functions.md) is called in a user defined function in the following query: + +```sql +CREATE FUNCTION parity AS (n) -> if(number % 2, 'odd', 'even'); +SELECT number, parity(number) FROM numbers(3); +``` + +Result: + +``` text +┌─number─┬─parity(number)─┐ +│ 0 │ even │ +│ 1 │ odd │ +│ 2 │ even │ +└────────┴────────────────┘ +``` diff --git a/docs/en/sql-reference/statements/drop.md b/docs/en/sql-reference/statements/drop.md index 4919c00a3dc..552a7b5f1a9 100644 --- a/docs/en/sql-reference/statements/drop.md +++ b/docs/en/sql-reference/statements/drop.md @@ -111,9 +111,6 @@ DROP FUNCTION [IF EXISTS] function_name **Example** ``` sql -CREATE FUNCTION plus_one as (a) -> a + 1; -DROP FUNCTION plus_one; +CREATE FUNCTION linear_equation AS (x, k, b) -> k*x + b; +DROP FUNCTION linear_equation; ``` - - - From 7ba2e9df3e71dbde916a9a4f5d1e27a02a85dd06 Mon Sep 17 00:00:00 2001 From: lehasm Date: Mon, 23 Aug 2021 22:29:18 +0300 Subject: [PATCH 004/102] Update docs/en/sql-reference/statements/create/function.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> --- docs/en/sql-reference/statements/create/function.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/statements/create/function.md b/docs/en/sql-reference/statements/create/function.md index 8de7e23cfb1..3ba52aa7bd4 100644 --- a/docs/en/sql-reference/statements/create/function.md +++ b/docs/en/sql-reference/statements/create/function.md @@ -13,7 +13,7 @@ Creates a user defined function from a lambda expression. The expression must co CREATE FUNCTION name AS (parameter0, ...) -> expression ``` A function can have an arbitrary number of parameters. -There are a few restrictions. +There are a few restrictions: - The name of a function must be unique among user defined and system functions. - Recursive functions are not allowed. From 79c3b35c6e547e7571392d4bd1580dbfe6af2f2f Mon Sep 17 00:00:00 2001 From: lehasm Date: Mon, 23 Aug 2021 22:29:38 +0300 Subject: [PATCH 005/102] Update docs/en/sql-reference/statements/create/function.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> --- docs/en/sql-reference/statements/create/function.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/statements/create/function.md b/docs/en/sql-reference/statements/create/function.md index 3ba52aa7bd4..47f9a20e7de 100644 --- a/docs/en/sql-reference/statements/create/function.md +++ b/docs/en/sql-reference/statements/create/function.md @@ -5,7 +5,7 @@ toc_title: FUNCTION # CREATE FUNCTION {#create-function} -Creates a user defined function from a lambda expression. The expression must consist of function parameters, constants, operators or other function calls. +Creates a user defined function from a lambda expression. The expression must consist of function parameters, constants, operators, or other function calls. **Syntax** From f85e2e027c0a62223bd132c45ed5d76e60a55c5e Mon Sep 17 00:00:00 2001 From: Mike Kot Date: Tue, 24 Aug 2021 14:57:49 +0200 Subject: [PATCH 006/102] Optional semantics for [Detached]MergeTreePartInfo --- src/IO/ReadBufferFromString.h | 7 +- src/Storages/MergeTree/MergeTreeData.cpp | 70 +++++---- src/Storages/MergeTree/MergeTreePartInfo.cpp | 146 +++++++++++-------- src/Storages/MergeTree/MergeTreePartInfo.h | 23 ++- src/Storages/StorageReplicatedMergeTree.cpp | 28 ++-- 5 files changed, 165 insertions(+), 109 deletions(-) diff --git a/src/IO/ReadBufferFromString.h b/src/IO/ReadBufferFromString.h index fac1b230a2c..1f8319d9a33 100644 --- a/src/IO/ReadBufferFromString.h +++ b/src/IO/ReadBufferFromString.h @@ -2,18 +2,17 @@ #include - namespace DB { -/** Allows to read from std::string-like object. - */ +/// Allows to read from std::string-like object. class ReadBufferFromString : public ReadBufferFromMemory { public: /// std::string or something similar template ReadBufferFromString(const S & s) : ReadBufferFromMemory(s.data(), s.size()) {} -}; + explicit ReadBufferFromString(std::string_view s) : ReadBufferFromMemory(s.data(), s.size()) {} +}; } diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index 764f5d7adf7..d461d55d161 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -884,6 +884,7 @@ void MergeTreeData::loadDataParts(bool skip_sanity_checks) { /// Check extra parts at different disks, in order to not allow to miss data parts at undefined disks. std::unordered_set defined_disk_names; + for (const auto & disk_ptr : disks) defined_disk_names.insert(disk_ptr->getName()); @@ -893,9 +894,10 @@ void MergeTreeData::loadDataParts(bool skip_sanity_checks) { for (const auto it = disk->iterateDirectory(relative_data_path); it->isValid(); it->next()) { - MergeTreePartInfo part_info; - if (MergeTreePartInfo::tryParsePartName(it->name(), &part_info, format_version)) - throw Exception("Part " + backQuote(it->name()) + " was found on disk " + backQuote(disk_name) + " which is not defined in the storage policy", ErrorCodes::UNKNOWN_DISK); + if (MergeTreePartInfo::tryParsePartName(it->name(), format_version)) + throw Exception(ErrorCodes::UNKNOWN_DISK, + "Part {} was found on disk {} which is not defined in the storage policy", + backQuote(it->name()), backQuote(disk_name)); } } } @@ -906,10 +908,13 @@ void MergeTreeData::loadDataParts(bool skip_sanity_checks) for (auto disk_it = disks.rbegin(); disk_it != disks.rend(); ++disk_it) { auto disk_ptr = *disk_it; + for (auto it = disk_ptr->iterateDirectory(relative_data_path); it->isValid(); it->next()) { /// Skip temporary directories, file 'format_version.txt' and directory 'detached'. - if (startsWith(it->name(), "tmp") || it->name() == MergeTreeData::FORMAT_VERSION_FILE_NAME || it->name() == MergeTreeData::DETACHED_DIR_NAME) + if (startsWith(it->name(), "tmp") + || it->name() == MergeTreeData::FORMAT_VERSION_FILE_NAME + || it->name() == MergeTreeData::DETACHED_DIR_NAME) continue; if (!startsWith(it->name(), MergeTreeWriteAheadLog::WAL_FILE_NAME)) @@ -956,25 +961,34 @@ void MergeTreeData::loadDataParts(bool skip_sanity_checks) { pool.scheduleOrThrowOnError([&] { - const auto & part_name = part_names_with_disk.first; - const auto part_disk_ptr = part_names_with_disk.second; + const auto & [part_name, part_disk_ptr] = part_names_with_disk; - MergeTreePartInfo part_info; - if (!MergeTreePartInfo::tryParsePartName(part_name, &part_info, format_version)) + auto part_opt = MergeTreePartInfo::tryParsePartName(part_name, format_version); + + if (!part_opt) return; auto single_disk_volume = std::make_shared("volume_" + part_name, part_disk_ptr, 0); - auto part = createPart(part_name, part_info, single_disk_volume, part_name); + auto part = createPart(part_name, *part_opt, single_disk_volume, part_name); bool broken = false; String part_path = fs::path(relative_data_path) / part_name; String marker_path = fs::path(part_path) / IMergeTreeDataPart::DELETE_ON_DESTROY_MARKER_FILE_NAME; + if (part_disk_ptr->exists(marker_path)) { - LOG_WARNING(log, "Detaching stale part {}{}, which should have been deleted after a move. That can only happen after unclean restart of ClickHouse after move of a part having an operation blocking that stale copy of part.", getFullPathOnDisk(part_disk_ptr), part_name); + LOG_WARNING(log, + "Detaching stale part {}{}, which should have been deleted after a move. That can only happen " + "after unclean restart of ClickHouse after move of a part having an operation blocking that " + "stale copy of part.", + getFullPathOnDisk(part_disk_ptr), part_name); + std::lock_guard loading_lock(mutex); + broken_parts_to_detach.push_back(part); + ++suspicious_broken_parts; + return; } @@ -1002,25 +1016,34 @@ void MergeTreeData::loadDataParts(bool skip_sanity_checks) /// Ignore broken parts that can appear as a result of hard server restart. if (broken) { - LOG_ERROR(log, "Detaching broken part {}{}. If it happened after update, it is likely because of backward incompability. You need to resolve this manually", getFullPathOnDisk(part_disk_ptr), part_name); + LOG_ERROR(log, + "Detaching broken part {}{}. If it happened after update, it is likely because of backward " + "incompatibility. You need to resolve this manually", + getFullPathOnDisk(part_disk_ptr), part_name); + std::lock_guard loading_lock(mutex); + broken_parts_to_detach.push_back(part); + ++suspicious_broken_parts; return; } + if (!part->index_granularity_info.is_adaptive) has_non_adaptive_parts.store(true, std::memory_order_relaxed); else has_adaptive_parts.store(true, std::memory_order_relaxed); part->modification_time = part_disk_ptr->getLastModified(fs::path(relative_data_path) / part_name).epochTime(); + /// Assume that all parts are Committed, covered parts will be detected and marked as Outdated later part->setState(DataPartState::Committed); std::lock_guard loading_lock(mutex); + if (!data_parts_indexes.insert(part).second) - throw Exception("Part " + part->name + " already exists", ErrorCodes::DUPLICATE_DATA_PART); + throw Exception(ErrorCodes::DUPLICATE_DATA_PART, "Part {} already exists", part->name); addPartContributionToDataVolume(part); }); @@ -3292,11 +3315,12 @@ RestoreDataTasks MergeTreeData::restoreDataPartsFromBackup(const BackupPtr & bac Strings part_names = backup->list(data_path_in_backup); for (const String & part_name : part_names) { - MergeTreePartInfo part_info; - if (!MergeTreePartInfo::tryParsePartName(part_name, &part_info, format_version)) + const auto part_info = MergeTreePartInfo::tryParsePartName(part_name, format_version); + + if (!part_info) continue; - if (!partition_ids.empty() && !partition_ids.contains(part_info.partition_id)) + if (!partition_ids.empty() && !partition_ids.contains(part_info->partition_id)) continue; UInt64 total_size_of_part = 0; @@ -3333,7 +3357,7 @@ RestoreDataTasks MergeTreeData::restoreDataPartsFromBackup(const BackupPtr & bac } auto single_disk_volume = std::make_shared(disk->getName(), disk, 0); - auto part = createPart(part_name, part_info, single_disk_volume, relative_temp_part_dir); + auto part = createPart(part_name, *part_info, single_disk_volume, relative_temp_part_dir); part->loadColumnsChecksumsIndexes(false, true); renameTempPartAndAdd(part, increment); }; @@ -3545,11 +3569,8 @@ std::vector MergeTreeData::getDetachedParts() const { for (auto it = disk->iterateDirectory(detached_path); it->isValid(); it->next()) { - res.emplace_back(); - auto & part = res.back(); - - DetachedPartInfo::tryParseDetachedPartName(it->name(), part, format_version); - part.disk = disk->getName(); + auto res_it = res.emplace_back(DetachedPartInfo::parseDetachedPartName(it->name(), format_version)); + res_it.disk = disk->getName(); } } } @@ -3620,7 +3641,7 @@ MergeTreeData::MutableDataPartsVector MergeTreeData::tryLoadPartsToAttach(const validateDetachedPartName(part_id); renamed_parts.addPart(part_id, "attaching_" + part_id); - if (MergeTreePartInfo::tryParsePartName(part_id, nullptr, format_version)) + if (MergeTreePartInfo::tryParsePartName(part_id, format_version)) name_to_disk[part_id] = getDiskForPart(part_id, source_dir); } else @@ -3636,12 +3657,11 @@ MergeTreeData::MutableDataPartsVector MergeTreeData::tryLoadPartsToAttach(const for (auto it = disk->iterateDirectory(relative_data_path + source_dir); it->isValid(); it->next()) { const String & name = it->name(); - MergeTreePartInfo part_info; // TODO what if name contains "_tryN" suffix? /// Parts with prefix in name (e.g. attaching_1_3_3_0, deleting_1_3_3_0) will be ignored - if (!MergeTreePartInfo::tryParsePartName(name, &part_info, format_version) - || part_info.partition_id != partition_id) + if (auto part_opt = MergeTreePartInfo::tryParsePartName(name, format_version); + !part_opt || part_opt->partition_id != partition_id) { continue; } diff --git a/src/Storages/MergeTree/MergeTreePartInfo.cpp b/src/Storages/MergeTree/MergeTreePartInfo.cpp index 6a98e666c34..39337fbd4c3 100644 --- a/src/Storages/MergeTree/MergeTreePartInfo.cpp +++ b/src/Storages/MergeTree/MergeTreePartInfo.cpp @@ -15,13 +15,12 @@ namespace ErrorCodes MergeTreePartInfo MergeTreePartInfo::fromPartName(const String & part_name, MergeTreeDataFormatVersion format_version) { - MergeTreePartInfo part_info; - if (!tryParsePartName(part_name, &part_info, format_version)) - throw Exception("Unexpected part name: " + part_name, ErrorCodes::BAD_DATA_PART_NAME); - return part_info; + if (auto part_opt = tryParsePartName(part_name, format_version); !part_opt) + throw Exception(ErrorCodes::BAD_DATA_PART_NAME, "Unexpected part name: {}", part_name); + else + return *part_opt; } - void MergeTreePartInfo::validatePartitionID(const String & partition_id, MergeTreeDataFormatVersion format_version) { if (partition_id.empty()) @@ -43,22 +42,26 @@ void MergeTreePartInfo::validatePartitionID(const String & partition_id, MergeTr } -bool MergeTreePartInfo::tryParsePartName(const String & part_name, MergeTreePartInfo * part_info, MergeTreeDataFormatVersion format_version) +std::optional MergeTreePartInfo::tryParsePartName( + std::string_view part_name, MergeTreeDataFormatVersion format_version) { ReadBufferFromString in(part_name); String partition_id; + if (format_version < MERGE_TREE_DATA_MIN_FORMAT_VERSION_WITH_CUSTOM_PARTITIONING) { UInt32 min_yyyymmdd = 0; UInt32 max_yyyymmdd = 0; + if (!tryReadIntText(min_yyyymmdd, in) || !checkChar('_', in) || !tryReadIntText(max_yyyymmdd, in) || !checkChar('_', in)) { - return false; + return std::nullopt; } + partition_id = toString(min_yyyymmdd / 100); } else @@ -76,9 +79,7 @@ bool MergeTreePartInfo::tryParsePartName(const String & part_name, MergeTreePart /// Sanity check if (partition_id.empty()) - { - return false; - } + return std::nullopt; Int64 min_block_num = 0; Int64 max_block_num = 0; @@ -91,14 +92,12 @@ bool MergeTreePartInfo::tryParsePartName(const String & part_name, MergeTreePart || !checkChar('_', in) || !tryReadIntText(level, in)) { - return false; + return std::nullopt; } /// Sanity check if (min_block_num > max_block_num) - { - return false; - } + return std::nullopt; if (!in.eof()) { @@ -106,29 +105,30 @@ bool MergeTreePartInfo::tryParsePartName(const String & part_name, MergeTreePart || !tryReadIntText(mutation, in) || !in.eof()) { - return false; + return std::nullopt; } } - if (part_info) + MergeTreePartInfo part_info; + + part_info.partition_id = std::move(partition_id); + part_info.min_block = min_block_num; + part_info.max_block = max_block_num; + + if (level == LEGACY_MAX_LEVEL) { - part_info->partition_id = std::move(partition_id); - part_info->min_block = min_block_num; - part_info->max_block = max_block_num; - if (level == LEGACY_MAX_LEVEL) - { - /// We (accidentally) had two different max levels until 21.6 and it might cause logical errors like - /// "Part 20170601_20170630_0_2_999999999 intersects 201706_0_1_4294967295". - /// So we replace unexpected max level to make contains(...) method and comparison operators work - /// correctly with such virtual parts. On part name serialization we will use legacy max level to keep the name unchanged. - part_info->use_leagcy_max_level = true; - level = MAX_LEVEL; - } - part_info->level = level; - part_info->mutation = mutation; + /// We (accidentally) had two different max levels until 21.6 and it might cause logical errors like + /// "Part 20170601_20170630_0_2_999999999 intersects 201706_0_1_4294967295". + /// So we replace unexpected max level to make contains(...) method and comparison operators work + /// correctly with such virtual parts. On part name serialization we will use legacy max level to keep the name unchanged. + part_info.use_leagcy_max_level = true; + level = MAX_LEVEL; } - return true; + part_info.level = level; + part_info.mutation = mutation; + + return part_info; } @@ -235,55 +235,75 @@ String MergeTreePartInfo::getPartNameV0(DayNum left_date, DayNum right_date) con return wb.str(); } - -const std::vector DetachedPartInfo::DETACH_REASONS = - { - "broken", - "unexpected", - "noquorum", - "ignored", - "broken-on-start", - "clone", - "attaching", - "deleting", - "tmp-fetch", - }; - -bool DetachedPartInfo::tryParseDetachedPartName(const String & dir_name, DetachedPartInfo & part_info, - MergeTreeDataFormatVersion format_version) +DetachedPartInfo DetachedPartInfo::parseDetachedPartName( + std::string_view dir_name, MergeTreeDataFormatVersion format_version) { + DetachedPartInfo part_info; + part_info.dir_name = dir_name; - /// First, try to find known prefix and parse dir_name as _. + /// First, try to find known prefix and parse dir_name as _. /// Arbitrary strings are not allowed for partition_id, so known_prefix cannot be confused with partition_id. - for (const auto & known_prefix : DETACH_REASONS) + for (std::string_view known_prefix : DETACH_REASONS) { - if (dir_name.starts_with(known_prefix) && known_prefix.size() < dir_name.size() && dir_name[known_prefix.size()] == '_') + if (dir_name.starts_with(known_prefix) + && known_prefix.size() < dir_name.size() + && dir_name[known_prefix.size()] == '_') { part_info.prefix = known_prefix; - String part_name = dir_name.substr(known_prefix.size() + 1); - bool parsed = MergeTreePartInfo::tryParsePartName(part_name, &part_info, format_version); - return part_info.valid_name = parsed; + + const std::string_view part_name = dir_name.substr(known_prefix.size() + 1); + + if (auto part_opt = MergeTreePartInfo::tryParsePartName(part_name, format_version)) + { + part_info.valid_name = true; + part_info.addParsedPartInfo(*part_opt); + } + else + part_info.valid_name = false; + + return part_info; } } /// Next, try to parse dir_name as . - if (MergeTreePartInfo::tryParsePartName(dir_name, &part_info, format_version)) - return part_info.valid_name = true; + if (auto part_opt = MergeTreePartInfo::tryParsePartName(dir_name, format_version)) + { + part_info.valid_name = true; + part_info.addParsedPartInfo(*part_opt); + return part_info; + } /// Next, as _. Use entire name as prefix if it fails. part_info.prefix = dir_name; - const auto first_separator = dir_name.find_first_of('_'); + + const size_t first_separator = dir_name.find_first_of('_'); + if (first_separator == String::npos) - return part_info.valid_name = false; + { + part_info.valid_name = false; + return part_info; + } - const auto part_name = dir_name.substr(first_separator + 1, - dir_name.size() - first_separator - 1); - if (!MergeTreePartInfo::tryParsePartName(part_name, &part_info, format_version)) - return part_info.valid_name = false; + const std::string_view part_name = dir_name.substr( + first_separator + 1, + dir_name.size() - first_separator - 1); - part_info.prefix = dir_name.substr(0, first_separator); - return part_info.valid_name = true; + if (auto part_opt = MergeTreePartInfo::tryParsePartName(part_name, format_version)) + { + part_info.valid_name = true; + part_info.prefix = dir_name.substr(0, first_separator); + part_info.addParsedPartInfo(*part_opt); + } + else + part_info.valid_name = false; + + return part_info; } +void DetachedPartInfo::addParsedPartInfo(const MergeTreePartInfo& part) +{ + // Both class are aggregates so it's ok. + static_cast(*this) = part; +} } diff --git a/src/Storages/MergeTree/MergeTreePartInfo.h b/src/Storages/MergeTree/MergeTreePartInfo.h index 181fef7990c..58707b4dca3 100644 --- a/src/Storages/MergeTree/MergeTreePartInfo.h +++ b/src/Storages/MergeTree/MergeTreePartInfo.h @@ -1,8 +1,10 @@ #pragma once #include +#include #include #include +#include #include #include #include @@ -98,7 +100,8 @@ struct MergeTreePartInfo static MergeTreePartInfo fromPartName(const String & part_name, MergeTreeDataFormatVersion format_version); // -V1071 - static bool tryParsePartName(const String & part_name, MergeTreePartInfo * part_info, MergeTreeDataFormatVersion format_version); + static std::optional tryParsePartName( + std::string_view part_name, MergeTreeDataFormatVersion format_version); static void parseMinMaxDatesFromPartName(const String & part_name, DayNum & min_date, DayNum & max_date); @@ -122,11 +125,23 @@ struct DetachedPartInfo : public MergeTreePartInfo /// If false, MergeTreePartInfo is in invalid state (directory name was not successfully parsed). bool valid_name; - static const std::vector DETACH_REASONS; + static constexpr auto DETACH_REASONS = std::to_array({ + "broken", "unexpected", "noquorum", + "ignored", "broken-on-start", "clone", + "attaching", "deleting", "tmp-fetch" + }); /// NOTE: It may parse part info incorrectly. - /// For example, if prefix contain '_' or if DETACH_REASONS doesn't contain prefix. - static bool tryParseDetachedPartName(const String & dir_name, DetachedPartInfo & part_info, MergeTreeDataFormatVersion format_version); + /// For example, if prefix contains '_' or if DETACH_REASONS doesn't contain prefix. + // This method has different semantics with MergeTreePartInfo::tryParsePartName as + // the former is used for (1) verifying that a part can be parsed without using the result and (2) parsing part + // for later usage. + // Detached parts are always parsed regardless of their validity (valid_name is used to check that), so we do not + // need an std::optional + static DetachedPartInfo parseDetachedPartName(std::string_view dir_name, MergeTreeDataFormatVersion format_version); + +private: + void addParsedPartInfo(const MergeTreePartInfo& part); }; using DetachedPartsInfo = std::vector; diff --git a/src/Storages/StorageReplicatedMergeTree.cpp b/src/Storages/StorageReplicatedMergeTree.cpp index 3bdba5d1b35..27abc894354 100644 --- a/src/Storages/StorageReplicatedMergeTree.cpp +++ b/src/Storages/StorageReplicatedMergeTree.cpp @@ -1163,10 +1163,8 @@ void StorageReplicatedMergeTree::checkParts(bool skip_sanity_checks) const UInt64 parts_to_fetch_blocks = std::accumulate(parts_to_fetch.cbegin(), parts_to_fetch.cend(), 0, [&](UInt64 acc, const String& part_name) { - MergeTreePartInfo part_info; - - if (MergeTreePartInfo::tryParsePartName(part_name, &part_info, format_version)) - return acc + part_info.getBlocksCount(); + if (const auto part_info = MergeTreePartInfo::tryParsePartName(part_name, format_version)) + return acc + part_info->getBlocksCount(); LOG_ERROR(log, "Unexpected part name: {}", part_name); return acc; @@ -1456,13 +1454,12 @@ MergeTreeData::MutableDataPartPtr StorageReplicatedMergeTree::attachPartHelperFo for (const DiskPtr & disk : getStoragePolicy()->getDisks()) for (const auto it = disk->iterateDirectory(fs::path(relative_data_path) / "detached/"); it->isValid(); it->next()) { - MergeTreePartInfo part_info; + const auto part_info = MergeTreePartInfo::tryParsePartName(it->name(), format_version); - if (!MergeTreePartInfo::tryParsePartName(it->name(), &part_info, format_version) || - part_info.partition_id != actual_part_info.partition_id) + if (!part_info || part_info->partition_id != actual_part_info.partition_id) continue; - const String part_old_name = part_info.getPartName(); + const String part_old_name = part_info->getPartName(); const String part_path = fs::path("detached") / part_old_name; const VolumePtr volume = std::make_shared("volume_" + part_old_name, disk); @@ -6328,6 +6325,7 @@ void StorageReplicatedMergeTree::getClearBlocksInPartitionOps( String partition_prefix = partition_id + "_"; zkutil::AsyncResponses get_futures; + for (const String & block_id : blocks) { if (startsWith(block_id, partition_prefix)) @@ -6346,9 +6344,10 @@ void StorageReplicatedMergeTree::getClearBlocksInPartitionOps( continue; ReadBufferFromString buf(result.data); - MergeTreePartInfo part_info; - bool parsed = MergeTreePartInfo::tryParsePartName(result.data, &part_info, format_version); - if (!parsed || (min_block_num <= part_info.min_block && part_info.max_block <= max_block_num)) + + const auto part_info = MergeTreePartInfo::tryParsePartName(result.data, format_version); + + if (!part_info || (min_block_num <= part_info->min_block && part_info->max_block <= max_block_num)) ops.emplace_back(zkutil::makeRemoveRequest(path, -1)); } } @@ -7441,12 +7440,15 @@ bool StorageReplicatedMergeTree::checkIfDetachedPartExists(const String & part_n bool StorageReplicatedMergeTree::checkIfDetachedPartitionExists(const String & partition_name) { fs::directory_iterator dir_end; + for (const std::string & path : getDataPaths()) { for (fs::directory_iterator dir_it{fs::path(path) / "detached/"}; dir_it != dir_end; ++dir_it) { - MergeTreePartInfo part_info; - if (MergeTreePartInfo::tryParsePartName(dir_it->path().filename(), &part_info, format_version) && part_info.partition_id == partition_name) + const String file_name = dir_it->path().filename().string(); + auto part_info = MergeTreePartInfo::tryParsePartName(file_name, format_version); + + if (part_info && part_info->partition_id == partition_name) return true; } } From e6a1124ebe803509bca962be2388498973f7a1b7 Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Wed, 25 Aug 2021 21:05:48 +0800 Subject: [PATCH 007/102] Reload stacktrace cache. --- src/Common/StackTrace.cpp | 23 ++++++++++++++++------- src/Common/StackTrace.h | 1 + src/Common/SymbolIndex.cpp | 4 ++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/Common/StackTrace.cpp b/src/Common/StackTrace.cpp index 812f888b284..3fae1df0bfa 100644 --- a/src/Common/StackTrace.cpp +++ b/src/Common/StackTrace.cpp @@ -417,11 +417,7 @@ void StackTrace::toStringEveryLine(std::function call std::string StackTrace::toString() const { - /// Calculation of stack trace text is extremely slow. - /// We use simple cache because otherwise the server could be overloaded by trash queries. - - static SimpleCache func_cached; - return func_cached(frame_pointers, offset, size); + return toStringStatic(frame_pointers, offset, size); } std::string StackTrace::toString(void ** frame_pointers_, size_t offset, size_t size) @@ -432,6 +428,19 @@ std::string StackTrace::toString(void ** frame_pointers_, size_t offset, size_t for (size_t i = 0; i < size; ++i) frame_pointers_copy[i] = frame_pointers_[i]; - static SimpleCache func_cached; - return func_cached(frame_pointers_copy, offset, size); + return toStringStatic(frame_pointers_copy, offset, size); +} + +std::string StackTrace::toStringStatic(const StackTrace::FramePointers & frame_pointers, size_t offset, size_t size, bool reload) +{ + /// Calculation of stack trace text is extremely slow. + /// We use simple cache because otherwise the server could be overloaded by trash queries. + static SimpleCache func_cached; + /// Reload cached stacktrace instead. + if (reload) + { + func_cached.drop(); + return ""; + } + return func_cached(frame_pointers, offset, size); } diff --git a/src/Common/StackTrace.h b/src/Common/StackTrace.h index 8f8c88c29fe..7e6edabaf0d 100644 --- a/src/Common/StackTrace.h +++ b/src/Common/StackTrace.h @@ -61,6 +61,7 @@ public: std::string toString() const; static std::string toString(void ** frame_pointers, size_t offset, size_t size); + static std::string toStringStatic(const FramePointers & frame_pointers, size_t offset, size_t size, bool reload = false); static void symbolize(const FramePointers & frame_pointers, size_t offset, size_t size, StackTrace::Frames & frames); void toStringEveryLine(std::function callback) const; diff --git a/src/Common/SymbolIndex.cpp b/src/Common/SymbolIndex.cpp index a23184c9c0a..72ce51cccd0 100644 --- a/src/Common/SymbolIndex.cpp +++ b/src/Common/SymbolIndex.cpp @@ -466,7 +466,11 @@ MultiVersion::Version SymbolIndex::instance(bool reload) { static MultiVersion instance(std::unique_ptr(new SymbolIndex)); if (reload) + { instance.set(std::unique_ptr(new SymbolIndex)); + /// Also reload stacktrace cache. + StackTrace::toStringStatic({}, 0, 0, true); + } return instance.get(); } From 35fd0b80f481a50936815ae44ec2a84c925c9e18 Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Thu, 26 Aug 2021 11:16:05 +0000 Subject: [PATCH 008/102] Update bin/unbin fucntions --- .../functions/encoding-functions.md | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/docs/en/sql-reference/functions/encoding-functions.md b/docs/en/sql-reference/functions/encoding-functions.md index c22f041e0c3..6fd98510b3a 100644 --- a/docs/en/sql-reference/functions/encoding-functions.md +++ b/docs/en/sql-reference/functions/encoding-functions.md @@ -210,52 +210,52 @@ Result: Returns a string containing the argument’s binary representation. -Alias: `BIN`. - **Syntax** ``` sql bin(arg) ``` +Alias: `BIN`. + For integer arguments, it prints bin digits from the most significant to least significant (big-endian or “human-readable” order). It starts with the most significant non-zero byte (leading zero bytes are omitted) but always prints eight digits of every byte if the leading digit is zero. -**Example** - -Query: - -``` sql -SELECT bin(1); -``` - -Result: - -``` text -00000001 -``` - Values of type `Date` and `DateTime` are formatted as corresponding integers (the number of days since Epoch for Date and the value of Unix Timestamp for DateTime). For `String` and `FixedString`, all bytes are simply encoded as eight binary numbers. Zero bytes are not omitted. -Values of floating-point and Decimal types are encoded as their representation in memory. As we support little-endian architecture, they are encoded in little-endian. Zero leading/trailing bytes are not omitted. +Values of `floating-point` and `Decimal` types are encoded as their representation in memory. As we support little-endian architecture, they are encoded in little-endian. Zero leading/trailing bytes are not omitted. **Arguments** -- `arg` — A value to convert to binary. Types: [String](../../sql-reference/data-types/string.md), [UInt](../../sql-reference/data-types/int-uint.md), [Float](../../sql-reference/data-types/float.md), [Decimal](../../sql-reference/data-types/decimal.md), [Date](../../sql-reference/data-types/date.md) or [DateTime](../../sql-reference/data-types/datetime.md). +- `arg` — A value to convert to binary. [String](../../sql-reference/data-types/string.md), [UInt](../../sql-reference/data-types/int-uint.md), [Float](../../sql-reference/data-types/float.md), [Decimal](../../sql-reference/data-types/decimal.md), [Date](../../sql-reference/data-types/date.md), or [DateTime](../../sql-reference/data-types/datetime.md). **Returned value** - A string with the binary representation of the argument. -Type: `String`. +Type: [String](../../sql-reference/data-types/string.md). -**Example** +**Examples** Query: ``` sql -SELECT bin(toFloat32(number)) as bin_presentation FROM numbers(15, 2); +SELECT bin(14); +``` + +Result: + +``` text +┌─bin(14)──┐ +│ 00001110 │ +└──────────┘ +``` + +Query: + +``` sql +SELECT bin(toFloat32(number)) AS bin_presentation FROM numbers(15, 2); ``` Result: @@ -270,7 +270,7 @@ Result: Query: ``` sql -SELECT bin(toFloat64(number)) as bin_presentation FROM numbers(15, 2); +SELECT bin(toFloat64(number)) AS bin_presentation FROM numbers(15, 2); ``` Result: @@ -284,14 +284,7 @@ Result: ## unbin {#unbinstr} -Performs the opposite operation of [bin](#bin). It interprets each pair of binary digits (in the argument) as a number and converts it to the byte represented by the number. The return value is a binary string (BLOB). - -If you want to convert the result to a number, you can use the [reverse](../../sql-reference/functions/string-functions.md#reverse) and [reinterpretAs](../../sql-reference/functions/type-conversion-functions.md#type-conversion-functions) functions. - -!!! note "Note" - If `unbin` is invoked from within the `clickhouse-client`, binary strings display using UTF-8. - -Alias: `UNBIN`. +Interprets each pair of binary digits (in the argument) as a number and converts it to the byte represented by the number. The return value is a binary string (BLOB). The functions performs the opposite operation of [bin](#bin). **Syntax** @@ -299,19 +292,26 @@ Alias: `UNBIN`. unbin(arg) ``` -**Arguments** +Alias: `UNBIN`. -- `arg` — A string containing any number of binary digits. Type: [String](../../sql-reference/data-types/string.md). +If you want to convert the result to a number, you can use the [reverse](../../sql-reference/functions/string-functions.md#reverse) and [reinterpretAs](../../sql-reference/functions/type-conversion-functions.md#type-conversion-functions) functions. + +!!! note "Note" + If `unbin` is invoked from within the `clickhouse-client`, binary strings display using UTF-8. Supports binary digits `0-1`. The number of binary digits does not have to be multiples of eight. If the argument string contains anything other than binary digits, some implementation-defined result is returned (an exception isn’t thrown). For a numeric argument the inverse of bin(N) is not performed by unbin(). +**Arguments** + +- `arg` — A string containing any number of binary digits. [String](../../sql-reference/data-types/string.md). + **Returned value** - A binary string (BLOB). Type: [String](../../sql-reference/data-types/string.md). -**Example** +**Examples** Query: @@ -330,14 +330,14 @@ Result: Query: ``` sql -SELECT reinterpretAsUInt64(reverse(unbin('1010'))) AS num; +SELECT reinterpretAsUInt64(reverse(unbin('1110'))) AS num; ``` Result: ``` text ┌─num─┐ -│ 10 │ +│ 14 │ └─────┘ ``` From c3d9ba7fa2d8f15fffc6b9fa4280edf344ca36bf Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Thu, 26 Aug 2021 11:24:22 +0000 Subject: [PATCH 009/102] Update bin/unbin functions RU - draft --- .../functions/encoding-functions.md | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index 161c1304b7c..95fb8a3e25f 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -208,6 +208,128 @@ SELECT reinterpretAsUInt64(reverse(unhex('FFF'))) AS num; └──────┘ ``` +## bin {#bin} + +**Синтаксис** + +``` sql +bin(arg) +``` + +Алиас: `BIN`. + + +**Аргументы** + +- `arg` — + +**Возвращаемое значение** + +- Бинарная строка (BLOB). + +Тип: [String](../../sql-reference/data-types/string.md). + +**Примеры** + +Запрос: + +``` sql +SELECT bin(14); +``` + +Результат: + +``` text +┌─bin(14)──┐ +│ 00001110 │ +└──────────┘ +``` + +Запрос: + +``` sql +SELECT bin(toFloat32(number)) AS bin_presentation FROM numbers(15, 2); +``` + +Результат: + +``` text +┌─bin_presentation─────────────────┐ +│ 00000000000000000111000001000001 │ +│ 00000000000000001000000001000001 │ +└──────────────────────────────────┘ +``` + +Запрос: + +``` sql +SELECT bin(toFloat64(number)) AS bin_presentation FROM numbers(15, 2); +``` + +Результат: + +``` text +┌─bin_presentation─────────────────────────────────────────────────┐ +│ 0000000000000000000000000000000000000000000000000010111001000000 │ +│ 0000000000000000000000000000000000000000000000000011000001000000 │ +└──────────────────────────────────────────────────────────────────┘ +``` + +## unbin {#unbinstr} + + +**Синтаксис** + +``` sql +unbin(arg) +``` + +Алиас: `UNBIN`. + +**Аргументы** + +- `arg` — + +**Возвращаемое значение** + +- Бинарная строка (BLOB). + +Тип: [String](../../sql-reference/data-types/string.md). + + +**Примеры** + +Запрос: + +``` sql +SELECT UNBIN('001100000011000100110010'), UNBIN('0100110101111001010100110101000101001100'); +``` + +Результат: + +``` text +┌─unbin('001100000011000100110010')─┬─unbin('0100110101111001010100110101000101001100')─┐ +│ 012 │ MySQL │ +└───────────────────────────────────┴───────────────────────────────────────────────────┘ +``` + +Запрос: + +``` sql +SELECT reinterpretAsUInt64(reverse(unbin('1110'))) AS num; +``` + +Результат: + +``` text +┌─num─┐ +│ 14 │ +└─────┘ +``` + + + + ## UUIDStringToNum(str) {#uuidstringtonumstr} Принимает строку, содержащую 36 символов в формате `123e4567-e89b-12d3-a456-426655440000`, и возвращает в виде набора байт в FixedString(16). From 3a0baf0c81872f0eb1410df3229ee1e893901849 Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Thu, 26 Aug 2021 12:19:47 +0000 Subject: [PATCH 010/102] Update Unit tests RU. --- docs/en/development/tests.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/en/development/tests.md b/docs/en/development/tests.md index c7c0ec88be4..776843e53a6 100644 --- a/docs/en/development/tests.md +++ b/docs/en/development/tests.md @@ -66,13 +66,21 @@ See `tests/integration/README.md` on how to run these tests. Note that integration of ClickHouse with third-party drivers is not tested. Also, we currently do not have integration tests with our JDBC and ODBC drivers. -## Unit Tests {#unit-tests} +## Модульные тесты {#unit-tests} -Unit tests are useful when you want to test not the ClickHouse as a whole, but a single isolated library or class. You can enable or disable build of tests with `ENABLE_TESTS` CMake option. Unit tests (and other test programs) are located in `tests` subdirectories across the code. To run unit tests, type `ninja test`. Some tests use `gtest`, but some are just programs that return non-zero exit code on test failure. +Модульные тесты полезны, когда вы хотите протестировать не ClickHouse в целом, а отдельную изолированную библиотеку или класс. Вы можете включить или отключить выполнение тестов при сборке с помощью опции CMake `ENABLE_TESTS`. Модульные тесты (как и другие тестовые программы) расположены в подкаталогах `tests` по всему репозиторию. -It’s not necessary to have unit tests if the code is already covered by functional tests (and functional tests are usually much more simple to use). +Чтобы запустить модульные тесты введите: -You can run individual gtest checks by calling the executable directly, for example: +```bash +ninja test +``` + +Некоторые тесты используют `gtest`, но некоторые из них — это просто программы, которые возвращают ненулевой код выхода при сбое теста. + +Нет необходимости в модульных тестах, если код уже охвачен функциональными тестами (ведь функциональные тесты обычно намного проще в использовании). + +Вы можете запускать отдельные проверки `gtest`, вызвав исполняемый файл напрямую, например: ```bash $ ./src/unit_tests_dbms --gtest_filter=LocalAddress* From 1f3701d4851fd19c5fee2c61f155ec23d461bf7b Mon Sep 17 00:00:00 2001 From: Mike Kot Date: Wed, 25 Aug 2021 21:18:12 +0200 Subject: [PATCH 011/102] Disk empty name fix --- src/Storages/MergeTree/MergeTreeData.cpp | 8 +++++--- src/Storages/MergeTree/MergeTreePartInfo.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index d461d55d161..6cfa6ab70d7 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -895,7 +895,7 @@ void MergeTreeData::loadDataParts(bool skip_sanity_checks) for (const auto it = disk->iterateDirectory(relative_data_path); it->isValid(); it->next()) { if (MergeTreePartInfo::tryParsePartName(it->name(), format_version)) - throw Exception(ErrorCodes::UNKNOWN_DISK, + throw Exception(ErrorCodes::UNKNOWN_DISK, "Part {} was found on disk {} which is not defined in the storage policy", backQuote(it->name()), backQuote(disk_name)); } @@ -3569,8 +3569,10 @@ std::vector MergeTreeData::getDetachedParts() const { for (auto it = disk->iterateDirectory(detached_path); it->isValid(); it->next()) { - auto res_it = res.emplace_back(DetachedPartInfo::parseDetachedPartName(it->name(), format_version)); - res_it.disk = disk->getName(); + auto part = DetachedPartInfo::parseDetachedPartName(it->name(), format_version); + part.disk = disk->getName(); + + res.push_back(std::move(part)); } } } diff --git a/src/Storages/MergeTree/MergeTreePartInfo.h b/src/Storages/MergeTree/MergeTreePartInfo.h index 58707b4dca3..bda7c24bab8 100644 --- a/src/Storages/MergeTree/MergeTreePartInfo.h +++ b/src/Storages/MergeTree/MergeTreePartInfo.h @@ -125,7 +125,7 @@ struct DetachedPartInfo : public MergeTreePartInfo /// If false, MergeTreePartInfo is in invalid state (directory name was not successfully parsed). bool valid_name; - static constexpr auto DETACH_REASONS = std::to_array({ + static constexpr auto DETACH_REASONS = std::to_array({ "broken", "unexpected", "noquorum", "ignored", "broken-on-start", "clone", "attaching", "deleting", "tmp-fetch" From ff0f049af217fcd04716d7286962e0909e53ad03 Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Mon, 30 Aug 2021 09:15:31 +0000 Subject: [PATCH 012/102] revert tests.md --- docs/en/development/tests.md | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/docs/en/development/tests.md b/docs/en/development/tests.md index 776843e53a6..c7c0ec88be4 100644 --- a/docs/en/development/tests.md +++ b/docs/en/development/tests.md @@ -66,21 +66,13 @@ See `tests/integration/README.md` on how to run these tests. Note that integration of ClickHouse with third-party drivers is not tested. Also, we currently do not have integration tests with our JDBC and ODBC drivers. -## Модульные тесты {#unit-tests} +## Unit Tests {#unit-tests} -Модульные тесты полезны, когда вы хотите протестировать не ClickHouse в целом, а отдельную изолированную библиотеку или класс. Вы можете включить или отключить выполнение тестов при сборке с помощью опции CMake `ENABLE_TESTS`. Модульные тесты (как и другие тестовые программы) расположены в подкаталогах `tests` по всему репозиторию. +Unit tests are useful when you want to test not the ClickHouse as a whole, but a single isolated library or class. You can enable or disable build of tests with `ENABLE_TESTS` CMake option. Unit tests (and other test programs) are located in `tests` subdirectories across the code. To run unit tests, type `ninja test`. Some tests use `gtest`, but some are just programs that return non-zero exit code on test failure. -Чтобы запустить модульные тесты введите: +It’s not necessary to have unit tests if the code is already covered by functional tests (and functional tests are usually much more simple to use). -```bash -ninja test -``` - -Некоторые тесты используют `gtest`, но некоторые из них — это просто программы, которые возвращают ненулевой код выхода при сбое теста. - -Нет необходимости в модульных тестах, если код уже охвачен функциональными тестами (ведь функциональные тесты обычно намного проще в использовании). - -Вы можете запускать отдельные проверки `gtest`, вызвав исполняемый файл напрямую, например: +You can run individual gtest checks by calling the executable directly, for example: ```bash $ ./src/unit_tests_dbms --gtest_filter=LocalAddress* From 61091395cd476a6594970de9415f827459f7022a Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Mon, 30 Aug 2021 13:35:27 +0000 Subject: [PATCH 013/102] Update bin/unbin --- .../functions/encoding-functions.md | 6 ++--- .../functions/encoding-functions.md | 24 +++++++++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/docs/en/sql-reference/functions/encoding-functions.md b/docs/en/sql-reference/functions/encoding-functions.md index 6fd98510b3a..f34bd1aaf35 100644 --- a/docs/en/sql-reference/functions/encoding-functions.md +++ b/docs/en/sql-reference/functions/encoding-functions.md @@ -220,7 +220,7 @@ Alias: `BIN`. For integer arguments, it prints bin digits from the most significant to least significant (big-endian or “human-readable” order). It starts with the most significant non-zero byte (leading zero bytes are omitted) but always prints eight digits of every byte if the leading digit is zero. -Values of type `Date` and `DateTime` are formatted as corresponding integers (the number of days since Epoch for Date and the value of Unix Timestamp for DateTime). +Values of type [Date](../../sql-reference/data-types/date.md) and [DateTime](../../sql-reference/data-types/datetime.md) are formatted as corresponding integers (the number of days since Epoch for `Date` and the value of Unix Timestamp for `DateTime`). For `String` and `FixedString`, all bytes are simply encoded as eight binary numbers. Zero bytes are not omitted. @@ -284,7 +284,7 @@ Result: ## unbin {#unbinstr} -Interprets each pair of binary digits (in the argument) as a number and converts it to the byte represented by the number. The return value is a binary string (BLOB). The functions performs the opposite operation of [bin](#bin). +Interprets each pair of binary digits (in the argument) as a number and converts it to the byte represented by the number. The functions performs the opposite operation of [bin](#bin). **Syntax** @@ -299,7 +299,7 @@ If you want to convert the result to a number, you can use the [reverse](../../s !!! note "Note" If `unbin` is invoked from within the `clickhouse-client`, binary strings display using UTF-8. -Supports binary digits `0-1`. The number of binary digits does not have to be multiples of eight. If the argument string contains anything other than binary digits, some implementation-defined result is returned (an exception isn’t thrown). For a numeric argument the inverse of bin(N) is not performed by unbin(). +Supports binary digits `0-1`. The number of binary digits does not have to be multiples of eight. If the argument string contains anything other than binary digits, some implementation-defined result is returned (an exception isn’t thrown). For a numeric argument the inverse of `bin(N)` is not performed by `unbin()`. **Arguments** diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index 95fb8a3e25f..b041804b5f4 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -210,6 +210,8 @@ SELECT reinterpretAsUInt64(reverse(unhex('FFF'))) AS num; ## bin {#bin} +Возвращает строку, содержащую бинарное представление аргумента. + **Синтаксис** ``` sql @@ -218,14 +220,24 @@ bin(arg) Алиас: `BIN`. +Для целочисленных аргументов возвращаются двоичные числа от наиболее значимого до наименее значимого (`big-endian` или в понятном человеку порядке). Порядок начинается с самого значимого ненулевого байта (начальные нулевые байты опущены), но всегда возвращает восемь цифр каждого байта, если начальная цифра равна нулю. + +Значения типа [Date](../../sql-reference/data-types/date.md) и [DateTime](../../sql-reference/data-types/datetime.md) форматируются как соответствующие целые числа (количество дней с момента unix-эпохи для `Date` и значение Unix Timestamp для `DateTime`). + +Для `String` и `FixedString` все байты кодируются как восемь двоичных чисел. Нулевые байты не опущены. + +Значения `floating-point` and `Decimal` кодируются как их представление в памяти. Поскольку мы поддерживаем архитектуру `little-endian`, они кодируются от младшего к старшему байту. Нулевые начальные конечные байты не опущены. + + + **Аргументы** -- `arg` — +- `arg` — значение для преобразования в двоичный код. [String](../../sql-reference/data-types/string.md), [UInt](../../sql-reference/data-types/int-uint.md), [Float](../../sql-reference/data-types/float.md), [Decimal](../../sql-reference/data-types/decimal.md), [Date](../../sql-reference/data-types/date.md) или [DateTime](../../sql-reference/data-types/datetime.md). **Возвращаемое значение** -- Бинарная строка (BLOB). +- Бинарная строка (BLOB) — двоичное представление аргумента. Тип: [String](../../sql-reference/data-types/string.md). @@ -277,6 +289,7 @@ SELECT bin(toFloat64(number)) AS bin_presentation FROM numbers(15, 2); ## unbin {#unbinstr} +Интерпретирует каждую пару двоичных цифр аргумента как число и преобразует его в байт, представленный числом. Функция выполняет операцию, противоположную [bin](#bin). **Синтаксис** @@ -286,6 +299,13 @@ unbin(arg) Алиас: `UNBIN`. +Если вы хотите преобразовать результат в число, вы можете использовать [reverse](../../sql-reference/functions/string-functions.md#reverse)и [reinterpretAs](../../sql-reference/functions/type-conversion-functions.md#type-conversion-functions) функции. + +!!! note "Note" + Если `unbin` вызывается из клиента `clickhouse-client`, бинарная строка возвращается в кодировке UTF-8. + +Поддерживает двоичные цифры `0-1`. Количество двоичных цифр не обязательно должно быть кратно восьми. Если строка аргумента содержит что-либо, кроме двоичных цифр, возвращается некоторый результат, определенный реализацией (ошибки не возникает). Для числового аргумента обратное значение bin(N), функцией unbin() не выполняется. + **Аргументы** - `arg` — From 2ce6d2760f8ce28dddb8189a1925500b7cfb62ff Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Mon, 30 Aug 2021 14:10:13 +0000 Subject: [PATCH 014/102] Update bin/unbin --- .../functions/encoding-functions.md | 6 +++--- .../functions/encoding-functions.md | 18 ++++++------------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/docs/en/sql-reference/functions/encoding-functions.md b/docs/en/sql-reference/functions/encoding-functions.md index f34bd1aaf35..40402126587 100644 --- a/docs/en/sql-reference/functions/encoding-functions.md +++ b/docs/en/sql-reference/functions/encoding-functions.md @@ -222,13 +222,13 @@ For integer arguments, it prints bin digits from the most significant to least s Values of type [Date](../../sql-reference/data-types/date.md) and [DateTime](../../sql-reference/data-types/datetime.md) are formatted as corresponding integers (the number of days since Epoch for `Date` and the value of Unix Timestamp for `DateTime`). -For `String` and `FixedString`, all bytes are simply encoded as eight binary numbers. Zero bytes are not omitted. +For [String](../../sql-reference/data-types/string.md) and [FixedString](../../sql-reference/data-types/fixedstring.md), all bytes are simply encoded as eight binary numbers. Zero bytes are not omitted. -Values of `floating-point` and `Decimal` types are encoded as their representation in memory. As we support little-endian architecture, they are encoded in little-endian. Zero leading/trailing bytes are not omitted. +Values of [Float](../../sql-reference/data-types/float) and [Decimal](../../sql-reference/data-types/decimal.md) types are encoded as their representation in memory. As we support little-endian architecture, they are encoded in little-endian. Zero leading/trailing bytes are not omitted. **Arguments** -- `arg` — A value to convert to binary. [String](../../sql-reference/data-types/string.md), [UInt](../../sql-reference/data-types/int-uint.md), [Float](../../sql-reference/data-types/float.md), [Decimal](../../sql-reference/data-types/decimal.md), [Date](../../sql-reference/data-types/date.md), or [DateTime](../../sql-reference/data-types/datetime.md). +- `arg` — A value to convert to binary. [String](../../sql-reference/data-types/string.md), [FixedString](../../sql-reference/data-types/fixedstring.md), [UInt](../../sql-reference/data-types/int-uint.md), [Float](../../sql-reference/data-types/float.md), [Decimal](../../sql-reference/data-types/decimal.md), [Date](../../sql-reference/data-types/date.md), or [DateTime](../../sql-reference/data-types/datetime.md). **Returned value** diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index b041804b5f4..c67a8d7c23c 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -224,16 +224,13 @@ bin(arg) Значения типа [Date](../../sql-reference/data-types/date.md) и [DateTime](../../sql-reference/data-types/datetime.md) форматируются как соответствующие целые числа (количество дней с момента unix-эпохи для `Date` и значение Unix Timestamp для `DateTime`). -Для `String` и `FixedString` все байты кодируются как восемь двоичных чисел. Нулевые байты не опущены. - -Значения `floating-point` and `Decimal` кодируются как их представление в памяти. Поскольку мы поддерживаем архитектуру `little-endian`, они кодируются от младшего к старшему байту. Нулевые начальные конечные байты не опущены. - - +Для [String](../../sql-reference/data-types/string.md) и [FixedString](../../sql-reference/data-types/fixedstring.md) все байты кодируются как восемь двоичных чисел. Нулевые байты не опущены. +Значения [Float](../../sql-reference/data-types/float) and [Decimal](../../sql-reference/data-types/decimal.md) кодируются как их представление в памяти. Поскольку мы поддерживаем архитектуру `little-endian`, они кодируются от младшего к старшему байту. Нулевые начальные конечные байты не опущены. **Аргументы** -- `arg` — значение для преобразования в двоичный код. [String](../../sql-reference/data-types/string.md), [UInt](../../sql-reference/data-types/int-uint.md), [Float](../../sql-reference/data-types/float.md), [Decimal](../../sql-reference/data-types/decimal.md), [Date](../../sql-reference/data-types/date.md) или [DateTime](../../sql-reference/data-types/datetime.md). +- `arg` — значение для преобразования в двоичный код. [String](../../sql-reference/data-types/string.md), [FixedString](../../sql-reference/data-types/fixedstring.md), [UInt](../../sql-reference/data-types/int-uint.md), [Float](../../sql-reference/data-types/float.md), [Decimal](../../sql-reference/data-types/decimal.md), [Date](../../sql-reference/data-types/date.md) или [DateTime](../../sql-reference/data-types/datetime.md). **Возвращаемое значение** @@ -301,14 +298,14 @@ unbin(arg) Если вы хотите преобразовать результат в число, вы можете использовать [reverse](../../sql-reference/functions/string-functions.md#reverse)и [reinterpretAs](../../sql-reference/functions/type-conversion-functions.md#type-conversion-functions) функции. -!!! note "Note" +!!! note "Примечание" Если `unbin` вызывается из клиента `clickhouse-client`, бинарная строка возвращается в кодировке UTF-8. -Поддерживает двоичные цифры `0-1`. Количество двоичных цифр не обязательно должно быть кратно восьми. Если строка аргумента содержит что-либо, кроме двоичных цифр, возвращается некоторый результат, определенный реализацией (ошибки не возникает). Для числового аргумента обратное значение bin(N), функцией unbin() не выполняется. +Поддерживает двоичные цифры `0-1`. Количество двоичных цифр не обязательно должно быть кратно восьми. Если строка аргумента содержит что-либо, кроме двоичных цифр, возвращается некоторый результат, определенный реализацией (ошибки не возникает). Для числового аргумента обратное значение `bin(N)`, функцией `unbin()` не выполняется. **Аргументы** -- `arg` — +- `arg` — строка, содержащая любое количество двоичных цифр. [String](../../sql-reference/data-types/string.md). **Возвращаемое значение** @@ -347,9 +344,6 @@ SELECT reinterpretAsUInt64(reverse(unbin('1110'))) AS num; └─────┘ ``` - - - ## UUIDStringToNum(str) {#uuidstringtonumstr} Принимает строку, содержащую 36 символов в формате `123e4567-e89b-12d3-a456-426655440000`, и возвращает в виде набора байт в FixedString(16). From c54bf838b0fab6b7dead4fd2be0f4b613b12fc51 Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Mon, 30 Aug 2021 14:17:20 +0000 Subject: [PATCH 015/102] Update bin/unbin --- docs/ru/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index c67a8d7c23c..259a0e6c7cf 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -17,7 +17,7 @@ char(number_1, [number_2, ..., number_n]); **Аргументы** -- `number_1, number_2, ..., number_n` — числовые аргументы, которые интерпретируются как целые числа. Типы: [Int](../../sql-reference/functions/encoding-functions.md), [Float](../../sql-reference/functions/encoding-functions.md). +- `number_1, number_2, ..., number_n` — числовые аргументы, которые интерпретируются как целые числа. Типы: [Int](../../sql-reference/functions/encoding-functions.md), [Float](../../sql-reference/data-types/float.md). **Возвращаемое значение** From 4feafb43889b022c216617b96456bc3a7c6e45ad Mon Sep 17 00:00:00 2001 From: Roman Bug Date: Tue, 31 Aug 2021 09:32:06 +0300 Subject: [PATCH 016/102] Update docs/ru/sql-reference/functions/encoding-functions.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> --- docs/ru/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index 259a0e6c7cf..207a2f63737 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -17,7 +17,7 @@ char(number_1, [number_2, ..., number_n]); **Аргументы** -- `number_1, number_2, ..., number_n` — числовые аргументы, которые интерпретируются как целые числа. Типы: [Int](../../sql-reference/functions/encoding-functions.md), [Float](../../sql-reference/data-types/float.md). +- `number_1, number_2, ..., number_n` — числовые аргументы, которые интерпретируются как целые числа. Типы: [Int](../../sql-reference/data-types/int-uint.md), [Float](../../sql-reference/data-types/float.md). **Возвращаемое значение** From 3553ae3e13db70461eed73a532024db29d9e8ced Mon Sep 17 00:00:00 2001 From: Roman Bug Date: Tue, 31 Aug 2021 09:32:25 +0300 Subject: [PATCH 017/102] Update docs/ru/sql-reference/functions/encoding-functions.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> --- docs/ru/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index 207a2f63737..7b3b67533d1 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -226,7 +226,7 @@ bin(arg) Для [String](../../sql-reference/data-types/string.md) и [FixedString](../../sql-reference/data-types/fixedstring.md) все байты кодируются как восемь двоичных чисел. Нулевые байты не опущены. -Значения [Float](../../sql-reference/data-types/float) and [Decimal](../../sql-reference/data-types/decimal.md) кодируются как их представление в памяти. Поскольку мы поддерживаем архитектуру `little-endian`, они кодируются от младшего к старшему байту. Нулевые начальные конечные байты не опущены. +Значения [Float](../../sql-reference/data-types/float) и [Decimal](../../sql-reference/data-types/decimal.md) кодируются как их представление в памяти. Поскольку ClickHouse поддерживает архитектуру `little-endian`, они кодируются от младшего к старшему байту. Нулевые начальные конечные байты не опущены. **Аргументы** From 78d2bfeada1107cd112e27b28aff471a2b8910b3 Mon Sep 17 00:00:00 2001 From: Roman Bug Date: Tue, 31 Aug 2021 09:33:45 +0300 Subject: [PATCH 018/102] Update docs/ru/sql-reference/functions/encoding-functions.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> --- docs/ru/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index 7b3b67533d1..c125b8ec6c7 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -296,7 +296,7 @@ unbin(arg) Алиас: `UNBIN`. -Если вы хотите преобразовать результат в число, вы можете использовать [reverse](../../sql-reference/functions/string-functions.md#reverse)и [reinterpretAs](../../sql-reference/functions/type-conversion-functions.md#type-conversion-functions) функции. +Для числового аргумента `unbin()` не возвращает значение, обратное результату `bin()`. Чтобы преобразовать результат в число, используйте функции [reverse](../../sql-reference/functions/string-functions.md#reverse) и [reinterpretAs](../../sql-reference/functions/type-conversion-functions.md#reinterpretasuint8163264). !!! note "Примечание" Если `unbin` вызывается из клиента `clickhouse-client`, бинарная строка возвращается в кодировке UTF-8. From 952b993afe744e529ea4dd018cde01f81c2a36e2 Mon Sep 17 00:00:00 2001 From: Roman Bug Date: Tue, 31 Aug 2021 09:33:54 +0300 Subject: [PATCH 019/102] Update docs/ru/sql-reference/functions/encoding-functions.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> --- docs/ru/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index c125b8ec6c7..b9bd61ad891 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -301,7 +301,7 @@ unbin(arg) !!! note "Примечание" Если `unbin` вызывается из клиента `clickhouse-client`, бинарная строка возвращается в кодировке UTF-8. -Поддерживает двоичные цифры `0-1`. Количество двоичных цифр не обязательно должно быть кратно восьми. Если строка аргумента содержит что-либо, кроме двоичных цифр, возвращается некоторый результат, определенный реализацией (ошибки не возникает). Для числового аргумента обратное значение `bin(N)`, функцией `unbin()` не выполняется. +Поддерживает двоичные цифры `0-1`. Количество двоичных цифр не обязательно должно быть кратно восьми. Если строка аргумента содержит что-либо, кроме двоичных цифр, возвращается некоторый результат, определенный реализацией (ошибки не возникает). **Аргументы** From e0c643777ef1ea93deec8b997962e37558d07c54 Mon Sep 17 00:00:00 2001 From: Roman Bug Date: Tue, 31 Aug 2021 09:34:05 +0300 Subject: [PATCH 020/102] Update docs/ru/sql-reference/functions/encoding-functions.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> --- docs/ru/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index b9bd61ad891..7917c98567b 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -222,7 +222,7 @@ bin(arg) Для целочисленных аргументов возвращаются двоичные числа от наиболее значимого до наименее значимого (`big-endian` или в понятном человеку порядке). Порядок начинается с самого значимого ненулевого байта (начальные нулевые байты опущены), но всегда возвращает восемь цифр каждого байта, если начальная цифра равна нулю. -Значения типа [Date](../../sql-reference/data-types/date.md) и [DateTime](../../sql-reference/data-types/datetime.md) форматируются как соответствующие целые числа (количество дней с момента unix-эпохи для `Date` и значение Unix Timestamp для `DateTime`). +Значения типа [Date](../../sql-reference/data-types/date.md) и [DateTime](../../sql-reference/data-types/datetime.md) формируются как соответствующие целые числа (количество дней с момента Unix-эпохи для `Date` и значение Unix Timestamp для `DateTime`). Для [String](../../sql-reference/data-types/string.md) и [FixedString](../../sql-reference/data-types/fixedstring.md) все байты кодируются как восемь двоичных чисел. Нулевые байты не опущены. From 5bbeb0e9354953bf61c6afa9ed905aad601c7e60 Mon Sep 17 00:00:00 2001 From: Roman Bug Date: Tue, 31 Aug 2021 09:34:11 +0300 Subject: [PATCH 021/102] Update docs/en/sql-reference/functions/encoding-functions.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> --- docs/en/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/functions/encoding-functions.md b/docs/en/sql-reference/functions/encoding-functions.md index 40402126587..450c2bb18c4 100644 --- a/docs/en/sql-reference/functions/encoding-functions.md +++ b/docs/en/sql-reference/functions/encoding-functions.md @@ -294,7 +294,7 @@ unbin(arg) Alias: `UNBIN`. -If you want to convert the result to a number, you can use the [reverse](../../sql-reference/functions/string-functions.md#reverse) and [reinterpretAs](../../sql-reference/functions/type-conversion-functions.md#type-conversion-functions) functions. +For a numeric argument `unbin()` does not return the inverse of `bin()`. If you want to convert the result to a number, you can use the [reverse](../../sql-reference/functions/string-functions.md#reverse) and [reinterpretAs](../../sql-reference/functions/type-conversion-functions.md#type-conversion-functions) functions. !!! note "Note" If `unbin` is invoked from within the `clickhouse-client`, binary strings display using UTF-8. From 36e54621420aa70b306435a7e5a25f96903c4234 Mon Sep 17 00:00:00 2001 From: Roman Bug Date: Tue, 31 Aug 2021 09:34:18 +0300 Subject: [PATCH 022/102] Update docs/en/sql-reference/functions/encoding-functions.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> --- docs/en/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/functions/encoding-functions.md b/docs/en/sql-reference/functions/encoding-functions.md index 450c2bb18c4..f780f5ed9c7 100644 --- a/docs/en/sql-reference/functions/encoding-functions.md +++ b/docs/en/sql-reference/functions/encoding-functions.md @@ -299,7 +299,7 @@ For a numeric argument `unbin()` does not return the inverse of `bin()`. If you !!! note "Note" If `unbin` is invoked from within the `clickhouse-client`, binary strings display using UTF-8. -Supports binary digits `0-1`. The number of binary digits does not have to be multiples of eight. If the argument string contains anything other than binary digits, some implementation-defined result is returned (an exception isn’t thrown). For a numeric argument the inverse of `bin(N)` is not performed by `unbin()`. +Supports binary digits `0-1`. The number of binary digits does not have to be multiples of eight. If the argument string contains anything other than binary digits, some implementation-defined result is returned (an exception isn’t thrown). **Arguments** From 43529c4e094b323c849a44a75a34df2b939255c5 Mon Sep 17 00:00:00 2001 From: Roman Bug Date: Tue, 31 Aug 2021 09:34:25 +0300 Subject: [PATCH 023/102] Update docs/en/sql-reference/functions/encoding-functions.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> --- docs/en/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/functions/encoding-functions.md b/docs/en/sql-reference/functions/encoding-functions.md index f780f5ed9c7..163cf9fd597 100644 --- a/docs/en/sql-reference/functions/encoding-functions.md +++ b/docs/en/sql-reference/functions/encoding-functions.md @@ -284,7 +284,7 @@ Result: ## unbin {#unbinstr} -Interprets each pair of binary digits (in the argument) as a number and converts it to the byte represented by the number. The functions performs the opposite operation of [bin](#bin). +Interprets each pair of binary digits (in the argument) as a number and converts it to the byte represented by the number. The functions performs the opposite operation to [bin](#bin). **Syntax** From ff5f5e9f77156c3a0480d3fe4dcee6bd99a28236 Mon Sep 17 00:00:00 2001 From: Roman Bug Date: Tue, 31 Aug 2021 09:34:32 +0300 Subject: [PATCH 024/102] Update docs/en/sql-reference/functions/encoding-functions.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> --- docs/en/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/functions/encoding-functions.md b/docs/en/sql-reference/functions/encoding-functions.md index 163cf9fd597..3bb1211d08f 100644 --- a/docs/en/sql-reference/functions/encoding-functions.md +++ b/docs/en/sql-reference/functions/encoding-functions.md @@ -297,7 +297,7 @@ Alias: `UNBIN`. For a numeric argument `unbin()` does not return the inverse of `bin()`. If you want to convert the result to a number, you can use the [reverse](../../sql-reference/functions/string-functions.md#reverse) and [reinterpretAs](../../sql-reference/functions/type-conversion-functions.md#type-conversion-functions) functions. !!! note "Note" - If `unbin` is invoked from within the `clickhouse-client`, binary strings display using UTF-8. + If `unbin` is invoked from within the `clickhouse-client`, binary strings are displayed using UTF-8. Supports binary digits `0-1`. The number of binary digits does not have to be multiples of eight. If the argument string contains anything other than binary digits, some implementation-defined result is returned (an exception isn’t thrown). From b7d647d74b67db15595bd193499ecd9422fcfa68 Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Tue, 31 Aug 2021 06:45:22 +0000 Subject: [PATCH 025/102] Fix PR comments. --- docs/en/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/functions/encoding-functions.md b/docs/en/sql-reference/functions/encoding-functions.md index 3bb1211d08f..a9238d69fb2 100644 --- a/docs/en/sql-reference/functions/encoding-functions.md +++ b/docs/en/sql-reference/functions/encoding-functions.md @@ -294,7 +294,7 @@ unbin(arg) Alias: `UNBIN`. -For a numeric argument `unbin()` does not return the inverse of `bin()`. If you want to convert the result to a number, you can use the [reverse](../../sql-reference/functions/string-functions.md#reverse) and [reinterpretAs](../../sql-reference/functions/type-conversion-functions.md#type-conversion-functions) functions. +For a numeric argument `unbin()` does not return the inverse of `bin()`. If you want to convert the result to a number, you can use the [reverse](../../sql-reference/functions/string-functions.md#reverse) and [reinterpretAs](../../sql-reference/functions/type-conversion-functions.md#type-conversion-functions.md#reinterpretasuint8163264) functions. !!! note "Note" If `unbin` is invoked from within the `clickhouse-client`, binary strings are displayed using UTF-8. From 7c3a37ee375e86a371894b13f78b6ad55cd5023f Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Tue, 31 Aug 2021 07:25:05 +0000 Subject: [PATCH 026/102] Fix PR comments. --- docs/en/sql-reference/functions/encoding-functions.md | 2 +- docs/ru/sql-reference/functions/encoding-functions.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/sql-reference/functions/encoding-functions.md b/docs/en/sql-reference/functions/encoding-functions.md index a9238d69fb2..2ef0fda437d 100644 --- a/docs/en/sql-reference/functions/encoding-functions.md +++ b/docs/en/sql-reference/functions/encoding-functions.md @@ -224,7 +224,7 @@ Values of type [Date](../../sql-reference/data-types/date.md) and [DateTime](../ For [String](../../sql-reference/data-types/string.md) and [FixedString](../../sql-reference/data-types/fixedstring.md), all bytes are simply encoded as eight binary numbers. Zero bytes are not omitted. -Values of [Float](../../sql-reference/data-types/float) and [Decimal](../../sql-reference/data-types/decimal.md) types are encoded as their representation in memory. As we support little-endian architecture, they are encoded in little-endian. Zero leading/trailing bytes are not omitted. +Values of [Float](../../sql-reference/data-types/float.md) and [Decimal](../../sql-reference/data-types/decimal.md) types are encoded as their representation in memory. As we support little-endian architecture, they are encoded in little-endian. Zero leading/trailing bytes are not omitted. **Arguments** diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index 7917c98567b..3a05b461323 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -111,7 +111,7 @@ Values of floating point and Decimal types are encoded as their representation i **Parameters** -- `arg` — A value to convert to hexadecimal. Types: [String](../../sql-reference/functions/encoding-functions.md), [UInt](../../sql-reference/functions/encoding-functions.md), [Float](../../sql-reference/functions/encoding-functions.md), [Decimal](../../sql-reference/functions/encoding-functions.md), [Date](../../sql-reference/functions/encoding-functions.md) or [DateTime](../../sql-reference/functions/encoding-functions.md). +- `arg` — A value to convert to hexadecimal. Types: [String](../../sql-reference/data-types/string.md), [UInt](../../sql-reference/data-types/int-uint.md), [Float](../../sql-reference/data-types/float.md), [Decimal](../../sql-reference/data-types/decimal.md), [Date](../../sql-reference/data-types/date.md) or [DateTime](../../sql-reference/data-types/datetime.md). **Returned value** @@ -226,7 +226,7 @@ bin(arg) Для [String](../../sql-reference/data-types/string.md) и [FixedString](../../sql-reference/data-types/fixedstring.md) все байты кодируются как восемь двоичных чисел. Нулевые байты не опущены. -Значения [Float](../../sql-reference/data-types/float) и [Decimal](../../sql-reference/data-types/decimal.md) кодируются как их представление в памяти. Поскольку ClickHouse поддерживает архитектуру `little-endian`, они кодируются от младшего к старшему байту. Нулевые начальные конечные байты не опущены. +Значения [Float](../../sql-reference/data-types/float.md) и [Decimal](../../sql-reference/data-types/decimal.md) кодируются как их представление в памяти. Поскольку ClickHouse поддерживает архитектуру `little-endian`, они кодируются от младшего к старшему байту. Нулевые начальные конечные байты не опущены. **Аргументы** From 981fdadaa6ca96b84e06d7af7d579895aa98011f Mon Sep 17 00:00:00 2001 From: romanzhukov Date: Tue, 31 Aug 2021 14:24:56 +0300 Subject: [PATCH 027/102] Fix links errors. --- docs/en/sql-reference/functions/encoding-functions.md | 2 +- docs/ru/sql-reference/functions/encoding-functions.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/sql-reference/functions/encoding-functions.md b/docs/en/sql-reference/functions/encoding-functions.md index a9238d69fb2..2ef0fda437d 100644 --- a/docs/en/sql-reference/functions/encoding-functions.md +++ b/docs/en/sql-reference/functions/encoding-functions.md @@ -224,7 +224,7 @@ Values of type [Date](../../sql-reference/data-types/date.md) and [DateTime](../ For [String](../../sql-reference/data-types/string.md) and [FixedString](../../sql-reference/data-types/fixedstring.md), all bytes are simply encoded as eight binary numbers. Zero bytes are not omitted. -Values of [Float](../../sql-reference/data-types/float) and [Decimal](../../sql-reference/data-types/decimal.md) types are encoded as their representation in memory. As we support little-endian architecture, they are encoded in little-endian. Zero leading/trailing bytes are not omitted. +Values of [Float](../../sql-reference/data-types/float.md) and [Decimal](../../sql-reference/data-types/decimal.md) types are encoded as their representation in memory. As we support little-endian architecture, they are encoded in little-endian. Zero leading/trailing bytes are not omitted. **Arguments** diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index 7917c98567b..c5ac4e3eace 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -226,7 +226,7 @@ bin(arg) Для [String](../../sql-reference/data-types/string.md) и [FixedString](../../sql-reference/data-types/fixedstring.md) все байты кодируются как восемь двоичных чисел. Нулевые байты не опущены. -Значения [Float](../../sql-reference/data-types/float) и [Decimal](../../sql-reference/data-types/decimal.md) кодируются как их представление в памяти. Поскольку ClickHouse поддерживает архитектуру `little-endian`, они кодируются от младшего к старшему байту. Нулевые начальные конечные байты не опущены. +Значения [Float](../../sql-reference/data-types/float.md) и [Decimal](../../sql-reference/data-types/decimal.md) кодируются как их представление в памяти. Поскольку ClickHouse поддерживает архитектуру `little-endian`, они кодируются от младшего к старшему байту. Нулевые начальные конечные байты не опущены. **Аргументы** From 1b00ec99a9d6e668972c4e19685bf566c43a07f0 Mon Sep 17 00:00:00 2001 From: Roman Bug Date: Tue, 31 Aug 2021 15:42:10 +0300 Subject: [PATCH 028/102] Update docs/ru/sql-reference/functions/encoding-functions.md Co-authored-by: Alexey Boykov <33257111+mathalex@users.noreply.github.com> --- docs/ru/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index 3a05b461323..64c46d6bc50 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -226,7 +226,7 @@ bin(arg) Для [String](../../sql-reference/data-types/string.md) и [FixedString](../../sql-reference/data-types/fixedstring.md) все байты кодируются как восемь двоичных чисел. Нулевые байты не опущены. -Значения [Float](../../sql-reference/data-types/float.md) и [Decimal](../../sql-reference/data-types/decimal.md) кодируются как их представление в памяти. Поскольку ClickHouse поддерживает архитектуру `little-endian`, они кодируются от младшего к старшему байту. Нулевые начальные конечные байты не опущены. +Значения [Float](../../sql-reference/data-types/float.md) и [Decimal](../../sql-reference/data-types/decimal.md) кодируются как их представление в памяти. Поскольку ClickHouse поддерживает архитектуру `little-endian`, они кодируются от младшего к старшему байту. Нулевые начальные/конечные байты не опущены. **Аргументы** From 2cea77c39594b9ade9343991c373874b23ca16c3 Mon Sep 17 00:00:00 2001 From: romanzhukov Date: Tue, 31 Aug 2021 16:54:41 +0300 Subject: [PATCH 029/102] Fix PR comment. --- .../functions/encoding-functions.md | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index 64c46d6bc50..23d2424f79f 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -73,7 +73,7 @@ SELECT char(0xE4, 0xBD, 0xA0, 0xE5, 0xA5, 0xBD) AS hello; ## hex {#hex} -Returns a string containing the argument’s hexadecimal representation. +Возвращает строку, содержащую шестнадцатеричное представление аргумента. Синоним: `HEX`. @@ -83,25 +83,10 @@ Returns a string containing the argument’s hexadecimal representation. hex(arg) ``` -The function is using uppercase letters `A-F` and not using any prefixes (like `0x`) or suffixes (like `h`). +Функция использует прописные буквы `A-F` и не использует никаких префиксов (например, `0x`) или суффиксов (например, `h`). -For integer arguments, it prints hex digits («nibbles») from the most significant to least significant (big endian or «human readable» order). It starts with the most significant non-zero byte (leading zero bytes are omitted) but always prints both digits of every byte even if leading digit is zero. +Для целочисленных аргументов возвращает шестнадцатеричные цифры ("кусочки") от наиболее значимых до наименее значимых (`big endian` или в порядке, понятному человеку).Он начинается с самого значимого ненулевого байта (начальные нулевые байты опущены), но всегда выводит обе цифры каждого байта, даже если начальная цифра равна нулю. -Example: - -**Example** - -Query: - -``` sql -SELECT hex(1); -``` - -Result: - -``` text -01 -``` Values of type `Date` and `DateTime` are formatted as corresponding integers (the number of days since Epoch for Date and the value of Unix Timestamp for DateTime). @@ -109,25 +94,37 @@ For `String` and `FixedString`, all bytes are simply encoded as two hexadecimal Values of floating point and Decimal types are encoded as their representation in memory. As we support little endian architecture, they are encoded in little endian. Zero leading/trailing bytes are not omitted. -**Parameters** +**Аргументы** -- `arg` — A value to convert to hexadecimal. Types: [String](../../sql-reference/data-types/string.md), [UInt](../../sql-reference/data-types/int-uint.md), [Float](../../sql-reference/data-types/float.md), [Decimal](../../sql-reference/data-types/decimal.md), [Date](../../sql-reference/data-types/date.md) or [DateTime](../../sql-reference/data-types/datetime.md). +- `arg` — значение для преобразования в шестнадцатеричное. [String](../../sql-reference/functions/encoding-functions.md), [UInt](../../sql-reference/functions/encoding-functions.md), [Float](../../sql-reference/functions/encoding-functions.md), [Decimal](../../sql-reference/functions/encoding-functions.md), [Date](../../sql-reference/functions/encoding-functions.md) или [DateTime](../../sql-reference/functions/encoding-functions.md). -**Returned value** +**Возвращаемое значение** -- A string with the hexadecimal representation of the argument. +- Строка — шестнадцатеричное представление аргумента. -Type: `String`. +Тип: [String](../../sql-reference/functions/encoding-functions.md). -**Example** +**Примеры** -Query: +Запрос: ``` sql -SELECT hex(toFloat32(number)) as hex_presentation FROM numbers(15, 2); +SELECT hex(1); ``` -Result: +Результат: + +``` text +01 +``` + +Запрос: + +``` sql +SELECT hex(toFloat32(number)) AS hex_presentation FROM numbers(15, 2); +``` + +Результат: ``` text ┌─hex_presentation─┐ @@ -136,13 +133,13 @@ Result: └──────────────────┘ ``` -Query: +Запрос: ``` sql -SELECT hex(toFloat64(number)) as hex_presentation FROM numbers(15, 2); +SELECT hex(toFloat64(number)) AS hex_presentation FROM numbers(15, 2); ``` -Result: +Результат: ``` text ┌─hex_presentation─┐ From 42483d31b79e5da26dad429c74e2c6e653c60a2c Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Wed, 1 Sep 2021 13:53:12 +0000 Subject: [PATCH 030/102] Fix PR comments. --- docs/ru/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index 23d2424f79f..2671bfb533d 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -96,7 +96,7 @@ Values of floating point and Decimal types are encoded as their representation i **Аргументы** -- `arg` — значение для преобразования в шестнадцатеричное. [String](../../sql-reference/functions/encoding-functions.md), [UInt](../../sql-reference/functions/encoding-functions.md), [Float](../../sql-reference/functions/encoding-functions.md), [Decimal](../../sql-reference/functions/encoding-functions.md), [Date](../../sql-reference/functions/encoding-functions.md) или [DateTime](../../sql-reference/functions/encoding-functions.md). +- `arg` — значение для преобразования в шестнадцатеричное. [String](../../sql-reference/data-types/string.md), [UInt](../../sql-reference/data-types/int-uint.md), [Float](../../sql-reference/data-types/float.md), [Decimal](../../sql-reference/data-types/decimal.md), [Date](../../sql-reference/data-types/date.md) или [DateTime](../../sql-reference/data-types/datetime.md). **Возвращаемое значение** From 0726af6d0c3f7076652ba1a9d0213a567a99c1c4 Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Wed, 1 Sep 2021 14:08:34 +0000 Subject: [PATCH 031/102] Fix PR comments. --- .../sql-reference/functions/encoding-functions.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index 2671bfb533d..b37c4160558 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -77,7 +77,7 @@ SELECT char(0xE4, 0xBD, 0xA0, 0xE5, 0xA5, 0xBD) AS hello; Синоним: `HEX`. -**Syntax** +**Синтаксис** ``` sql hex(arg) @@ -87,12 +87,11 @@ hex(arg) Для целочисленных аргументов возвращает шестнадцатеричные цифры ("кусочки") от наиболее значимых до наименее значимых (`big endian` или в порядке, понятному человеку).Он начинается с самого значимого ненулевого байта (начальные нулевые байты опущены), но всегда выводит обе цифры каждого байта, даже если начальная цифра равна нулю. +Значения типа [Date](../../sql-reference/data-types/date.md) и [DateTime](../../sql-reference/data-types/datetime.md) формируются как соответствующие целые числа (количество дней с момента Unix-эпохи для `Date` и значение Unix Timestamp для `DateTime`). -Values of type `Date` and `DateTime` are formatted as corresponding integers (the number of days since Epoch for Date and the value of Unix Timestamp for DateTime). +Для [String](../../sql-reference/data-types/string.md) и [FixedString](../../sql-reference/data-types/fixedstring.md), все байты просто кодируются как два шестнадцатеричных числа. Нулевые байты не опущены. -For `String` and `FixedString`, all bytes are simply encoded as two hexadecimal numbers. Zero bytes are not omitted. - -Values of floating point and Decimal types are encoded as their representation in memory. As we support little endian architecture, they are encoded in little endian. Zero leading/trailing bytes are not omitted. +Значения [Float](../../sql-reference/data-types/float.md) и [Decimal](../../sql-reference/data-types/decimal.md) кодируются как их представление в памяти. Поскольку ClickHouse поддерживает архитектуру `little-endian`, они кодируются от младшего к старшему байту. Нулевые начальные/конечные байты не опущены. **Аргументы** @@ -215,7 +214,7 @@ SELECT reinterpretAsUInt64(reverse(unhex('FFF'))) AS num; bin(arg) ``` -Алиас: `BIN`. +Синоним: `BIN`. Для целочисленных аргументов возвращаются двоичные числа от наиболее значимого до наименее значимого (`big-endian` или в понятном человеку порядке). Порядок начинается с самого значимого ненулевого байта (начальные нулевые байты опущены), но всегда возвращает восемь цифр каждого байта, если начальная цифра равна нулю. @@ -291,7 +290,7 @@ SELECT bin(toFloat64(number)) AS bin_presentation FROM numbers(15, 2); unbin(arg) ``` -Алиас: `UNBIN`. +Синоним: `UNBIN`. Для числового аргумента `unbin()` не возвращает значение, обратное результату `bin()`. Чтобы преобразовать результат в число, используйте функции [reverse](../../sql-reference/functions/string-functions.md#reverse) и [reinterpretAs](../../sql-reference/functions/type-conversion-functions.md#reinterpretasuint8163264). @@ -396,7 +395,7 @@ SELECT bitPositionsToArray(toInt8(1)) AS bit_positions; Запрос: ``` sql -select bitPositionsToArray(toInt8(-1)) as bit_positions; +select bitPositionsToArray(toInt8(-1)) AS bit_positions; ``` Результат: From 248a97201c17879889184c712432aed93519e2e6 Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Wed, 1 Sep 2021 14:26:36 +0000 Subject: [PATCH 032/102] Fix PR comments. --- .../functions/encoding-functions.md | 42 +++++++++---------- .../functions/encoding-functions.md | 3 +- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/docs/en/sql-reference/functions/encoding-functions.md b/docs/en/sql-reference/functions/encoding-functions.md index 2ef0fda437d..0fccbb5cc09 100644 --- a/docs/en/sql-reference/functions/encoding-functions.md +++ b/docs/en/sql-reference/functions/encoding-functions.md @@ -87,7 +87,23 @@ The function is using uppercase letters `A-F` and not using any prefixes (like ` For integer arguments, it prints hex digits (“nibbles”) from the most significant to least significant (big-endian or “human-readable” order). It starts with the most significant non-zero byte (leading zero bytes are omitted) but always prints both digits of every byte even if the leading digit is zero. -**Example** +Values of type [Date](../../sql-reference/data-types/date.md) and [DateTime](../../sql-reference/data-types/datetime.md) are formatted as corresponding integers (the number of days since Epoch for Date and the value of Unix Timestamp for DateTime). + +For [String](../../sql-reference/data-types/string.md) and [FixedString](../../sql-reference/data-types/fixedstring.md), all bytes are simply encoded as two hexadecimal numbers. Zero bytes are not omitted. + +Values of [Float](../../sql-reference/data-types/float.md) and [Decimal](../../sql-reference/data-types/decimal.md) types are encoded as their representation in memory. As we support little-endian architecture, they are encoded in little-endian. Zero leading/trailing bytes are not omitted. + +**Arguments** + +- `arg` — A value to convert to hexadecimal. Types: [String](../../sql-reference/data-types/string.md), [UInt](../../sql-reference/data-types/int-uint.md), [Float](../../sql-reference/data-types/float.md), [Decimal](../../sql-reference/data-types/decimal.md), [Date](../../sql-reference/data-types/date.md) or [DateTime](../../sql-reference/data-types/datetime.md). + +**Returned value** + +- A string with the hexadecimal representation of the argument. + +Type: [String](../../sql-reference/data-types/string.md). + +**Examples** Query: @@ -101,28 +117,10 @@ Result: 01 ``` -Values of type `Date` and `DateTime` are formatted as corresponding integers (the number of days since Epoch for Date and the value of Unix Timestamp for DateTime). - -For `String` and `FixedString`, all bytes are simply encoded as two hexadecimal numbers. Zero bytes are not omitted. - -Values of floating point and Decimal types are encoded as their representation in memory. As we support little-endian architecture, they are encoded in little-endian. Zero leading/trailing bytes are not omitted. - -**Arguments** - -- `arg` — A value to convert to hexadecimal. Types: [String](../../sql-reference/data-types/string.md), [UInt](../../sql-reference/data-types/int-uint.md), [Float](../../sql-reference/data-types/float.md), [Decimal](../../sql-reference/data-types/decimal.md), [Date](../../sql-reference/data-types/date.md) or [DateTime](../../sql-reference/data-types/datetime.md). - -**Returned value** - -- A string with the hexadecimal representation of the argument. - -Type: `String`. - -**Example** - Query: ``` sql -SELECT hex(toFloat32(number)) as hex_presentation FROM numbers(15, 2); +SELECT hex(toFloat32(number)) AS hex_presentation FROM numbers(15, 2); ``` Result: @@ -137,7 +135,7 @@ Result: Query: ``` sql -SELECT hex(toFloat64(number)) as hex_presentation FROM numbers(15, 2); +SELECT hex(toFloat64(number)) AS hex_presentation FROM numbers(15, 2); ``` Result: @@ -396,7 +394,7 @@ Result: Query: ``` sql -select bitPositionsToArray(toInt8(-1)) as bit_positions; +SELECT bitPositionsToArray(toInt8(-1)) AS bit_positions; ``` Result: diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index b37c4160558..b0ba81aec06 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -309,7 +309,6 @@ unbin(arg) Тип: [String](../../sql-reference/data-types/string.md). - **Примеры** Запрос: @@ -395,7 +394,7 @@ SELECT bitPositionsToArray(toInt8(1)) AS bit_positions; Запрос: ``` sql -select bitPositionsToArray(toInt8(-1)) AS bit_positions; +SELECT bitPositionsToArray(toInt8(-1)) AS bit_positions; ``` Результат: From cce799d9b54a6a2f573fb65ff57db2c99f503055 Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Wed, 1 Sep 2021 14:28:23 +0000 Subject: [PATCH 033/102] Fix PR comments. --- docs/ru/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index b0ba81aec06..b0db509a797 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -101,7 +101,7 @@ hex(arg) - Строка — шестнадцатеричное представление аргумента. -Тип: [String](../../sql-reference/functions/encoding-functions.md). +Тип: [String](../../sql-reference/data-types/string.md). **Примеры** From 81a3ee6584c4c3ab1066b469991c9435ea0157d3 Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Wed, 1 Sep 2021 14:41:05 +0000 Subject: [PATCH 034/102] Fix PR comments. --- docs/ru/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index b0db509a797..ad3aa8d87e6 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -23,7 +23,7 @@ char(number_1, [number_2, ..., number_n]); - Строка из соответствующих байт. -Тип: `String`. +Тип: [String](../../sql-reference/data-types/string.md). **Пример** From f0414ed7f9f00ab23621c121ab86de21fc3f714d Mon Sep 17 00:00:00 2001 From: romanzhukov Date: Wed, 1 Sep 2021 21:05:22 +0300 Subject: [PATCH 035/102] Fix err arg. --- docs/en/sql-reference/functions/encoding-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/functions/encoding-functions.md b/docs/en/sql-reference/functions/encoding-functions.md index 0fccbb5cc09..0abf7bb7da9 100644 --- a/docs/en/sql-reference/functions/encoding-functions.md +++ b/docs/en/sql-reference/functions/encoding-functions.md @@ -292,7 +292,7 @@ unbin(arg) Alias: `UNBIN`. -For a numeric argument `unbin()` does not return the inverse of `bin()`. If you want to convert the result to a number, you can use the [reverse](../../sql-reference/functions/string-functions.md#reverse) and [reinterpretAs](../../sql-reference/functions/type-conversion-functions.md#type-conversion-functions.md#reinterpretasuint8163264) functions. +For a numeric argument `unbin()` does not return the inverse of `bin()`. If you want to convert the result to a number, you can use the [reverse](../../sql-reference/functions/string-functions.md#reverse) and [reinterpretAs](../../sql-reference/functions/type-conversion-functions.md#reinterpretasuint8163264) functions. !!! note "Note" If `unbin` is invoked from within the `clickhouse-client`, binary strings are displayed using UTF-8. From 299fc2604af575b058f996f32bde77c6f4c66a30 Mon Sep 17 00:00:00 2001 From: Alexey Date: Wed, 1 Sep 2021 18:36:35 +0000 Subject: [PATCH 036/102] Example fixed --- docs/en/sql-reference/statements/create/function.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/en/sql-reference/statements/create/function.md b/docs/en/sql-reference/statements/create/function.md index 8de7e23cfb1..b678d455a81 100644 --- a/docs/en/sql-reference/statements/create/function.md +++ b/docs/en/sql-reference/statements/create/function.md @@ -13,6 +13,7 @@ Creates a user defined function from a lambda expression. The expression must co CREATE FUNCTION name AS (parameter0, ...) -> expression ``` A function can have an arbitrary number of parameters. + There are a few restrictions. - The name of a function must be unique among user defined and system functions. @@ -43,7 +44,7 @@ Result: A [conditional function](../../../sql-reference/functions/conditional-functions.md) is called in a user defined function in the following query: ```sql -CREATE FUNCTION parity AS (n) -> if(number % 2, 'odd', 'even'); +CREATE FUNCTION parity AS (n) -> if(n % 2, 'odd', 'even'); SELECT number, parity(number) FROM numbers(3); ``` From 610257dcd2959f93e2f42fec34e52e35d01ca738 Mon Sep 17 00:00:00 2001 From: Alexey Date: Wed, 1 Sep 2021 18:36:47 +0000 Subject: [PATCH 037/102] Translated to Russian --- .../statements/create/function.md | 59 +++++++++++++++++++ .../sql-reference/statements/create/index.md | 1 + docs/ru/sql-reference/statements/drop.md | 17 ++++++ docs/ru/sql-reference/statements/grant.md | 2 + 4 files changed, 79 insertions(+) create mode 100644 docs/ru/sql-reference/statements/create/function.md diff --git a/docs/ru/sql-reference/statements/create/function.md b/docs/ru/sql-reference/statements/create/function.md new file mode 100644 index 00000000000..99c04c8af69 --- /dev/null +++ b/docs/ru/sql-reference/statements/create/function.md @@ -0,0 +1,59 @@ +--- +toc_priority: 38 +toc_title: FUNCTION +--- + +# CREATE FUNCTION {#create-function} + +Создает пользовательскую функцию из лямбда-выражения. Выражение должно состоять из параметров функции, констант, операторов и вызовов других функций. + +**Синтаксис** + +```sql +CREATE FUNCTION name AS (parameter0, ...) -> expression +``` +У функции может быть произвольное число параметров. + +Существует несколько ограничений на создаваемые функции. + +- Имя функции должно быть уникальным среди всех пользовательских и системных функций. +- Рекурсивные вызовы запрещены. +- Все переменные, используемые функцией, должны быть перечислены в списке ее параметров. + +Если какое-нибудь ограничение нарушается, то при попытке создать функцию возникает исключение. + +**Пример** + +Запрос: + +```sql +CREATE FUNCTION linear_equation AS (x, k, b) -> k*x + b; +SELECT number, linear_equation(number, 2, 1) FROM numbers(3); +``` + +Результат: + +``` text +┌─number─┬─linear_equation(number, 2, 1)─┐ +│ 0 │ 1 │ +│ 1 │ 3 │ +│ 2 │ 5 │ +└────────┴───────────────────────────────┘ +``` + +В следующем запросе пользовательская функция вызывает [условную функцию](../../../sql-reference/functions/conditional-functions.md): + +```sql +CREATE FUNCTION parity AS (n) -> if(n % 2, 'odd', 'even'); +SELECT number, parity(number) FROM numbers(3); +``` + +Результат: + +``` text +┌─number─┬─parity(number)─┐ +│ 0 │ even │ +│ 1 │ odd │ +│ 2 │ even │ +└────────┴────────────────┘ +``` diff --git a/docs/ru/sql-reference/statements/create/index.md b/docs/ru/sql-reference/statements/create/index.md index dfa5c28fff7..61d4d053fec 100644 --- a/docs/ru/sql-reference/statements/create/index.md +++ b/docs/ru/sql-reference/statements/create/index.md @@ -12,6 +12,7 @@ toc_title: "Обзор" - [TABLE](../../../sql-reference/statements/create/table.md) - [VIEW](../../../sql-reference/statements/create/view.md) - [DICTIONARY](../../../sql-reference/statements/create/dictionary.md) +- [FUNCTION](../../../sql-reference/statements/create/function.md) - [USER](../../../sql-reference/statements/create/user.md) - [ROLE](../../../sql-reference/statements/create/role.md) - [ROW POLICY](../../../sql-reference/statements/create/row-policy.md) diff --git a/docs/ru/sql-reference/statements/drop.md b/docs/ru/sql-reference/statements/drop.md index 118f8eb923a..437c2d02a94 100644 --- a/docs/ru/sql-reference/statements/drop.md +++ b/docs/ru/sql-reference/statements/drop.md @@ -97,3 +97,20 @@ DROP [SETTINGS] PROFILE [IF EXISTS] name [,...] [ON CLUSTER cluster_name] DROP VIEW [IF EXISTS] [db.]name [ON CLUSTER cluster] ``` +## DROP FUNCTION {#drop-function} + +Удаляет пользовательскую функцию, созданную с помощью [CREATE FUNCTION](./create/function.md). +Удалить системные функции нельзя. + +**Синтаксис** + +``` sql +DROP FUNCTION [IF EXISTS] function_name +``` + +**Пример** + +``` sql +CREATE FUNCTION linear_equation AS (x, k, b) -> k*x + b; +DROP FUNCTION linear_equation; +``` diff --git a/docs/ru/sql-reference/statements/grant.md b/docs/ru/sql-reference/statements/grant.md index 8d6605e1571..45ba9bb0343 100644 --- a/docs/ru/sql-reference/statements/grant.md +++ b/docs/ru/sql-reference/statements/grant.md @@ -109,11 +109,13 @@ GRANT SELECT(x,y) ON db.table TO john WITH GRANT OPTION - `CREATE TEMPORARY TABLE` - `CREATE VIEW` - `CREATE DICTIONARY` + - `CREATE FUNCTION` - [DROP](#grant-drop) - `DROP DATABASE` - `DROP TABLE` - `DROP VIEW` - `DROP DICTIONARY` + - `DROP FUNCTION` - [TRUNCATE](#grant-truncate) - [OPTIMIZE](#grant-optimize) - [SHOW](#grant-show) From 163a416366d8ac98171429a07f4fe460ea16af9d Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Sat, 28 Aug 2021 11:43:43 +0800 Subject: [PATCH 038/102] Refactor --- src/Common/StackTrace.cpp | 22 ++++++++++++--------- src/Common/StackTrace.h | 3 ++- src/Common/SymbolIndex.cpp | 22 +++++++++++++-------- src/Common/SymbolIndex.h | 4 +++- src/Interpreters/InterpreterSystemQuery.cpp | 2 +- 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/Common/StackTrace.cpp b/src/Common/StackTrace.cpp index 3fae1df0bfa..a9d4700490e 100644 --- a/src/Common/StackTrace.cpp +++ b/src/Common/StackTrace.cpp @@ -431,16 +431,20 @@ std::string StackTrace::toString(void ** frame_pointers_, size_t offset, size_t return toStringStatic(frame_pointers_copy, offset, size); } -std::string StackTrace::toStringStatic(const StackTrace::FramePointers & frame_pointers, size_t offset, size_t size, bool reload) +static SimpleCache & cacheInstance() +{ + static SimpleCache cache; + return cache; +} + +std::string StackTrace::toStringStatic(const StackTrace::FramePointers & frame_pointers, size_t offset, size_t size) { /// Calculation of stack trace text is extremely slow. /// We use simple cache because otherwise the server could be overloaded by trash queries. - static SimpleCache func_cached; - /// Reload cached stacktrace instead. - if (reload) - { - func_cached.drop(); - return ""; - } - return func_cached(frame_pointers, offset, size); + return cacheInstance()(frame_pointers, offset, size); +} + +void StackTrace::dropCache() +{ + cacheInstance().drop(); } diff --git a/src/Common/StackTrace.h b/src/Common/StackTrace.h index 7e6edabaf0d..62acb70563f 100644 --- a/src/Common/StackTrace.h +++ b/src/Common/StackTrace.h @@ -61,7 +61,8 @@ public: std::string toString() const; static std::string toString(void ** frame_pointers, size_t offset, size_t size); - static std::string toStringStatic(const FramePointers & frame_pointers, size_t offset, size_t size, bool reload = false); + static std::string toStringStatic(const FramePointers & frame_pointers, size_t offset, size_t size); + static void dropCache(); static void symbolize(const FramePointers & frame_pointers, size_t offset, size_t size, StackTrace::Frames & frames); void toStringEveryLine(std::function callback) const; diff --git a/src/Common/SymbolIndex.cpp b/src/Common/SymbolIndex.cpp index 72ce51cccd0..2d875b7042d 100644 --- a/src/Common/SymbolIndex.cpp +++ b/src/Common/SymbolIndex.cpp @@ -462,16 +462,22 @@ String SymbolIndex::getBuildIDHex() const return build_id_hex; } -MultiVersion::Version SymbolIndex::instance(bool reload) +MultiVersion & SymbolIndex::instanceImpl() { static MultiVersion instance(std::unique_ptr(new SymbolIndex)); - if (reload) - { - instance.set(std::unique_ptr(new SymbolIndex)); - /// Also reload stacktrace cache. - StackTrace::toStringStatic({}, 0, 0, true); - } - return instance.get(); + return instance; +} + +MultiVersion::Version SymbolIndex::instance() +{ + return instanceImpl().get(); +} + +void SymbolIndex::reload() +{ + instanceImpl().set(std::unique_ptr(new SymbolIndex)); + /// Also drop stacktrace cache. + StackTrace::dropCache(); } } diff --git a/src/Common/SymbolIndex.h b/src/Common/SymbolIndex.h index 65e446a7fc4..37862987bd2 100644 --- a/src/Common/SymbolIndex.h +++ b/src/Common/SymbolIndex.h @@ -22,7 +22,8 @@ protected: SymbolIndex() { update(); } public: - static MultiVersion::Version instance(bool reload = false); + static MultiVersion::Version instance(); + static void reload(); struct Symbol { @@ -60,6 +61,7 @@ private: Data data; void update(); + static MultiVersion & instanceImpl(); }; } diff --git a/src/Interpreters/InterpreterSystemQuery.cpp b/src/Interpreters/InterpreterSystemQuery.cpp index d4ac555add0..31c04a7b431 100644 --- a/src/Interpreters/InterpreterSystemQuery.cpp +++ b/src/Interpreters/InterpreterSystemQuery.cpp @@ -337,7 +337,7 @@ BlockIO InterpreterSystemQuery::execute() { #if defined(__ELF__) && !defined(__FreeBSD__) getContext()->checkAccess(AccessType::SYSTEM_RELOAD_SYMBOLS); - (void)SymbolIndex::instance(true); + SymbolIndex::reload(); break; #else throw Exception("SYSTEM RELOAD SYMBOLS is not supported on current platform", ErrorCodes::NOT_IMPLEMENTED); From 7667a209365c635f0ca157efd2bee33bdd133074 Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 2 Sep 2021 18:44:37 +0000 Subject: [PATCH 039/102] Russian fixes --- docs/ru/sql-reference/statements/create/function.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ru/sql-reference/statements/create/function.md b/docs/ru/sql-reference/statements/create/function.md index 99c04c8af69..2364425cdd2 100644 --- a/docs/ru/sql-reference/statements/create/function.md +++ b/docs/ru/sql-reference/statements/create/function.md @@ -14,10 +14,10 @@ CREATE FUNCTION name AS (parameter0, ...) -> expression ``` У функции может быть произвольное число параметров. -Существует несколько ограничений на создаваемые функции. +Существует несколько ограничений на создаваемые функции: - Имя функции должно быть уникальным среди всех пользовательских и системных функций. -- Рекурсивные вызовы запрещены. +- Рекурсивные функции запрещены. - Все переменные, используемые функцией, должны быть перечислены в списке ее параметров. Если какое-нибудь ограничение нарушается, то при попытке создать функцию возникает исключение. From 1f148719ce39aa9a4f493ed0ecc2ede3e9f12272 Mon Sep 17 00:00:00 2001 From: Mike Kot Date: Fri, 3 Sep 2021 13:33:40 +0200 Subject: [PATCH 040/102] Review fixes --- src/Storages/MergeTree/MergeTreePartInfo.cpp | 6 +++--- src/Storages/MergeTree/MergeTreePartInfo.h | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Storages/MergeTree/MergeTreePartInfo.cpp b/src/Storages/MergeTree/MergeTreePartInfo.cpp index 39337fbd4c3..7e140ec2375 100644 --- a/src/Storages/MergeTree/MergeTreePartInfo.cpp +++ b/src/Storages/MergeTree/MergeTreePartInfo.cpp @@ -15,10 +15,10 @@ namespace ErrorCodes MergeTreePartInfo MergeTreePartInfo::fromPartName(const String & part_name, MergeTreeDataFormatVersion format_version) { - if (auto part_opt = tryParsePartName(part_name, format_version); !part_opt) - throw Exception(ErrorCodes::BAD_DATA_PART_NAME, "Unexpected part name: {}", part_name); - else + if (auto part_opt = tryParsePartName(part_name, format_version)) return *part_opt; + else + throw Exception(ErrorCodes::BAD_DATA_PART_NAME, "Unexpected part name: {}", part_name); } void MergeTreePartInfo::validatePartitionID(const String & partition_id, MergeTreeDataFormatVersion format_version) diff --git a/src/Storages/MergeTree/MergeTreePartInfo.h b/src/Storages/MergeTree/MergeTreePartInfo.h index bda7c24bab8..73761048035 100644 --- a/src/Storages/MergeTree/MergeTreePartInfo.h +++ b/src/Storages/MergeTree/MergeTreePartInfo.h @@ -126,18 +126,22 @@ struct DetachedPartInfo : public MergeTreePartInfo bool valid_name; static constexpr auto DETACH_REASONS = std::to_array({ - "broken", "unexpected", "noquorum", - "ignored", "broken-on-start", "clone", - "attaching", "deleting", "tmp-fetch" + "broken", + "unexpected", + "noquorum", + "ignored", + "broken-on-start", + "clone", + "attaching", + "deleting", + "tmp-fetch" }); /// NOTE: It may parse part info incorrectly. /// For example, if prefix contains '_' or if DETACH_REASONS doesn't contain prefix. - // This method has different semantics with MergeTreePartInfo::tryParsePartName as - // the former is used for (1) verifying that a part can be parsed without using the result and (2) parsing part - // for later usage. - // Detached parts are always parsed regardless of their validity (valid_name is used to check that), so we do not - // need an std::optional + // This method has different semantics with MergeTreePartInfo::tryParsePartName. + // Detached parts are always parsed regardless of their validity. + // DetachedPartInfo::valid_name field specifies whether parsing was successful or not. static DetachedPartInfo parseDetachedPartName(std::string_view dir_name, MergeTreeDataFormatVersion format_version); private: From d738f45ec0d90020a7e2bc52f063713f56a80dbf Mon Sep 17 00:00:00 2001 From: Alexey Date: Sat, 4 Sep 2021 16:31:04 +0000 Subject: [PATCH 041/102] Examples fixed --- .../statements/create/function.md | 24 +++++++++---------- .../statements/create/function.md | 24 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/en/sql-reference/statements/create/function.md b/docs/en/sql-reference/statements/create/function.md index cab421adfc9..ddfcdfef521 100644 --- a/docs/en/sql-reference/statements/create/function.md +++ b/docs/en/sql-reference/statements/create/function.md @@ -34,26 +34,26 @@ SELECT number, linear_equation(number, 2, 1) FROM numbers(3); Result: ``` text -┌─number─┬─linear_equation(number, 2, 1)─┐ -│ 0 │ 1 │ -│ 1 │ 3 │ -│ 2 │ 5 │ -└────────┴───────────────────────────────┘ +┌─number─┬─plus(multiply(2, number), 1)─┐ +│ 0 │ 1 │ +│ 1 │ 3 │ +│ 2 │ 5 │ +└────────┴──────────────────────────────┘ ``` A [conditional function](../../../sql-reference/functions/conditional-functions.md) is called in a user defined function in the following query: ```sql -CREATE FUNCTION parity AS (n) -> if(n % 2, 'odd', 'even'); -SELECT number, parity(number) FROM numbers(3); +CREATE FUNCTION parity_str AS (n) -> if(n % 2, 'odd', 'even'); +SELECT number, parity_str(number) FROM numbers(3); ``` Result: ``` text -┌─number─┬─parity(number)─┐ -│ 0 │ even │ -│ 1 │ odd │ -│ 2 │ even │ -└────────┴────────────────┘ +┌─number─┬─if(modulo(number, 2), 'odd', 'even')─┐ +│ 0 │ even │ +│ 1 │ odd │ +│ 2 │ even │ +└────────┴──────────────────────────────────────┘ ``` diff --git a/docs/ru/sql-reference/statements/create/function.md b/docs/ru/sql-reference/statements/create/function.md index 2364425cdd2..90838b25744 100644 --- a/docs/ru/sql-reference/statements/create/function.md +++ b/docs/ru/sql-reference/statements/create/function.md @@ -34,26 +34,26 @@ SELECT number, linear_equation(number, 2, 1) FROM numbers(3); Результат: ``` text -┌─number─┬─linear_equation(number, 2, 1)─┐ -│ 0 │ 1 │ -│ 1 │ 3 │ -│ 2 │ 5 │ -└────────┴───────────────────────────────┘ +┌─number─┬─plus(multiply(2, number), 1)─┐ +│ 0 │ 1 │ +│ 1 │ 3 │ +│ 2 │ 5 │ +└────────┴──────────────────────────────┘ ``` В следующем запросе пользовательская функция вызывает [условную функцию](../../../sql-reference/functions/conditional-functions.md): ```sql -CREATE FUNCTION parity AS (n) -> if(n % 2, 'odd', 'even'); -SELECT number, parity(number) FROM numbers(3); +CREATE FUNCTION parity_str AS (n) -> if(n % 2, 'odd', 'even'); +SELECT number, parity_str(number) FROM numbers(3); ``` Результат: ``` text -┌─number─┬─parity(number)─┐ -│ 0 │ even │ -│ 1 │ odd │ -│ 2 │ even │ -└────────┴────────────────┘ +┌─number─┬─if(modulo(number, 2), 'odd', 'even')─┐ +│ 0 │ even │ +│ 1 │ odd │ +│ 2 │ even │ +└────────┴──────────────────────────────────────┘ ``` From e7ed98fa58806b83d7d0bcb18d798c8584635e34 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Tue, 31 Aug 2021 23:16:03 +0300 Subject: [PATCH 042/102] Do not allow ThreadFromGlobalPool::join() from the spawned/occupated thread v2: wrap with shared_ptr https://clickhouse-test-reports.s3.yandex.net/28431/f7b3a3e952038923b1347b3d461061326d0ffc27/functional_stateless_tests_(address).html#fail1 --- src/Common/ThreadPool.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Common/ThreadPool.h b/src/Common/ThreadPool.h index 1da5d25eef0..e7bd509d75a 100644 --- a/src/Common/ThreadPool.h +++ b/src/Common/ThreadPool.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -156,14 +157,16 @@ public: class ThreadFromGlobalPool { public: - ThreadFromGlobalPool() {} + ThreadFromGlobalPool() = default; template explicit ThreadFromGlobalPool(Function && func, Args &&... args) : state(std::make_shared()) + , thread_id(std::make_shared()) { /// NOTE: If this will throw an exception, the destructor won't be called. GlobalThreadPool::instance().scheduleOrThrow([ + thread_id = thread_id, state = state, func = std::forward(func), args = std::make_tuple(std::forward(args)...)]() mutable /// mutable is needed to destroy capture @@ -171,6 +174,8 @@ public: auto event = std::move(state); SCOPE_EXIT(event->set()); + thread_id = std::make_shared(std::this_thread::get_id()); + /// This moves are needed to destroy function and arguments before exit. /// It will guarantee that after ThreadFromGlobalPool::join all captured params are destroyed. auto function = std::move(func); @@ -193,6 +198,7 @@ public: if (joinable()) abort(); state = std::move(rhs.state); + thread_id = std::move(rhs.thread_id); return *this; } @@ -220,12 +226,18 @@ public: bool joinable() const { - return state != nullptr; + if (!state) + return false; + /// Thread cannot join itself. + if (*thread_id == std::this_thread::get_id()) + return false; + return true; } private: /// The state used in this object and inside the thread job. std::shared_ptr state; + std::shared_ptr thread_id; }; From 66efe4202c72625c955f5defaa09410c2a5d13e3 Mon Sep 17 00:00:00 2001 From: George Date: Mon, 6 Sep 2021 02:34:09 +0300 Subject: [PATCH 043/102] Fixed and updated --- .../functions/tuple-map-functions.md | 2 +- .../functions/tuple-map-functions.md | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/docs/en/sql-reference/functions/tuple-map-functions.md b/docs/en/sql-reference/functions/tuple-map-functions.md index ef5f5814017..04f02c3ead4 100644 --- a/docs/en/sql-reference/functions/tuple-map-functions.md +++ b/docs/en/sql-reference/functions/tuple-map-functions.md @@ -78,7 +78,7 @@ mapAdd(arg1, arg2 [, ...]) **Arguments** -Arguments are [maps](../../sql-reference/data-types/map.md) or [tuples](../../sql-reference/data-types/tuple.md#tuplet1-t2) of two [arrays](../../sql-reference/data-types/array.md#data-type-array), where items in the first array represent keys, and the second array contains values for the each key. All key arrays should have same type, and all value arrays should contain items which are promote to the one type ([Int64](../../sql-reference/data-types/int-uint.md#int-ranges), [UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges) or [Float64](../../sql-reference/data-types/float.md#float32-float64)). The common promoted type is used as a type for the result array. +Arguments are [maps](../../sql-reference/data-types/map.md) or [tuples](../../sql-reference/data-types/tuple.md#tuplet1-t2) of two [arrays](../../sql-reference/data-types/array.md#data-type-array), where items in the first array represent keys, and the second array contains values for the each key. All key arrays should have same type, and all value arrays should contain items which are promoted to the one type ([Int64](../../sql-reference/data-types/int-uint.md#int-ranges), [UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges) or [Float64](../../sql-reference/data-types/float.md#float32-float64)). The common promoted type is used as a type for the result array. **Returned value** diff --git a/docs/ru/sql-reference/functions/tuple-map-functions.md b/docs/ru/sql-reference/functions/tuple-map-functions.md index 4775152fb54..1cea3ca42c7 100644 --- a/docs/ru/sql-reference/functions/tuple-map-functions.md +++ b/docs/ru/sql-reference/functions/tuple-map-functions.md @@ -73,22 +73,22 @@ SELECT a['key2'] FROM table_map; **Синтаксис** ``` sql -mapAdd(Tuple(Array, Array), Tuple(Array, Array) [, ...]) +mapAdd(arg1, arg2 [, ...]) ``` **Аргументы** -Аргументами являются [кортежи](../../sql-reference/data-types/tuple.md#tuplet1-t2) из двух [массивов](../../sql-reference/data-types/array.md#data-type-array), где элементы в первом массиве представляют ключи, а второй массив содержит значения для каждого ключа. +Аргументами являются контейнеры [Map](../../sql-reference/data-types/map.md) или [кортежи](../../sql-reference/data-types/tuple.md#tuplet1-t2) из двух [массивов](../../sql-reference/data-types/array.md#data-type-array), где элементы в первом массиве представляют ключи, а второй массив содержит значения для каждого ключа. Все массивы ключей должны иметь один и тот же тип, а все массивы значений должны содержать элементы, которые можно приводить к одному типу ([Int64](../../sql-reference/data-types/int-uint.md#int-ranges), [UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges) или [Float64](../../sql-reference/data-types/float.md#float32-float64)). Общий приведенный тип используется в качестве типа для результирующего массива. **Возвращаемое значение** -- Возвращает один [кортеж](../../sql-reference/data-types/tuple.md#tuplet1-t2), в котором первый массив содержит отсортированные ключи, а второй — значения. +- В зависимости от аргументов возвращает один [Map](../../sql-reference/data-types/map.md) или [кортеж](../../sql-reference/data-types/tuple.md#tuplet1-t2), в котором первый массив содержит отсортированные ключи, а второй — значения. **Пример** -Запрос: +Запрос с кортежем: ``` sql SELECT mapAdd(([toUInt8(1), 2], [1, 1]), ([toUInt8(1), 2], [1, 1])) as res, toTypeName(res) as type; @@ -102,6 +102,20 @@ SELECT mapAdd(([toUInt8(1), 2], [1, 1]), ([toUInt8(1), 2], [1, 1])) as res, toTy └───────────────┴────────────────────────────────────┘ ``` +Запрос с типом `Map`: + +```sql +SELECT mapAdd(map(1,1), map(1,1)); +``` + +Result: + +```text +┌─mapAdd(map(1, 1), map(1, 1))─┐ +│ {1:2} │ +└──────────────────────────────┘ +``` + ## mapSubtract {#function-mapsubtract} Собирает все ключи и вычитает соответствующие значения. From a6e8f3fa01f624e9b326853bba5a5b997e3dba7c Mon Sep 17 00:00:00 2001 From: gyuton <40863448+gyuton@users.noreply.github.com> Date: Mon, 6 Sep 2021 13:58:34 +0300 Subject: [PATCH 044/102] Apply suggestions from code review Co-authored-by: Anna <42538400+adevyatova@users.noreply.github.com> --- docs/ru/sql-reference/functions/tuple-map-functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ru/sql-reference/functions/tuple-map-functions.md b/docs/ru/sql-reference/functions/tuple-map-functions.md index 1cea3ca42c7..e4cc1fefab4 100644 --- a/docs/ru/sql-reference/functions/tuple-map-functions.md +++ b/docs/ru/sql-reference/functions/tuple-map-functions.md @@ -84,7 +84,7 @@ mapAdd(arg1, arg2 [, ...]) **Возвращаемое значение** -- В зависимости от аргументов возвращает один [Map](../../sql-reference/data-types/map.md) или [кортеж](../../sql-reference/data-types/tuple.md#tuplet1-t2), в котором первый массив содержит отсортированные ключи, а второй — значения. +- В зависимости от типа аргументов возвращает один [Map](../../sql-reference/data-types/map.md) или [кортеж](../../sql-reference/data-types/tuple.md#tuplet1-t2), в котором первый массив содержит отсортированные ключи, а второй — значения. **Пример** @@ -102,7 +102,7 @@ SELECT mapAdd(([toUInt8(1), 2], [1, 1]), ([toUInt8(1), 2], [1, 1])) as res, toTy └───────────────┴────────────────────────────────────┘ ``` -Запрос с типом `Map`: +Запрос с контейнером `Map`: ```sql SELECT mapAdd(map(1,1), map(1,1)); From 0eac4529e0c82f1232b711e92052a1944acfaa36 Mon Sep 17 00:00:00 2001 From: alesapin Date: Mon, 6 Sep 2021 14:33:39 +0300 Subject: [PATCH 045/102] Preparation --- docker/images.json | 38 +++++++++++++++++-- docker/packager/binary/Dockerfile | 2 +- docker/packager/deb/Dockerfile | 2 +- docker/packager/packager | 6 +-- docker/packager/unbundled/Dockerfile | 4 +- docker/test/base/Dockerfile | 2 +- docker/test/codebrowser/Dockerfile | 6 +-- docker/test/compatibility/centos/Dockerfile | 2 +- docker/test/compatibility/ubuntu/Dockerfile | 2 +- docker/test/coverage/Dockerfile | 4 +- docker/test/fasttest/Dockerfile | 2 +- docker/test/fuzzer/Dockerfile | 6 +-- docker/test/integration/base/Dockerfile | 4 +- .../integration/helper_container/Dockerfile | 2 +- .../integration/kerberized_hadoop/Dockerfile | 2 +- .../test/integration/kerberos_kdc/Dockerfile | 2 +- .../mysql_golang_client/Dockerfile | 2 +- .../integration/mysql_java_client/Dockerfile | 2 +- .../integration/mysql_js_client/Dockerfile | 2 +- .../integration/mysql_php_client/Dockerfile | 2 +- .../postgresql_java_client/Dockerfile | 2 +- docker/test/integration/resolver/Dockerfile | 2 +- docker/test/integration/runner/Dockerfile | 2 +- .../compose/docker_compose_jdbc_bridge.yml | 2 +- .../runner/compose/docker_compose_keeper.yml | 6 +-- .../docker_compose_kerberized_hdfs.yml | 4 +- .../docker_compose_kerberized_kafka.yml | 2 +- .../runner/compose/docker_compose_minio.yml | 6 +-- .../docker_compose_mysql_golang_client.yml | 2 +- .../docker_compose_mysql_java_client.yml | 2 +- .../docker_compose_mysql_js_client.yml | 2 +- .../docker_compose_mysql_php_client.yml | 2 +- .../docker_compose_postgresql_java_client.yml | 2 +- docker/test/integration/s3_proxy/Dockerfile | 2 +- docker/test/keeper-jepsen/Dockerfile | 4 +- docker/test/performance-comparison/Dockerfile | 4 +- docker/test/performance-comparison/README.md | 2 +- docker/test/pvs/Dockerfile | 4 +- docker/test/split_build_smoke_test/Dockerfile | 4 +- docker/test/sqlancer/Dockerfile | 2 +- docker/test/stateful/Dockerfile | 4 +- docker/test/stateless/Dockerfile | 4 +- docker/test/stateless_pytest/Dockerfile | 4 +- docker/test/stateless_unbundled/Dockerfile | 4 +- docker/test/stress/Dockerfile | 4 +- docker/test/stress/README.md | 2 +- docker/test/style/Dockerfile | 2 +- docker/test/test_runner.sh | 2 +- docker/test/testflows/runner/Dockerfile | 2 +- docker/test/unit/Dockerfile | 4 +- 50 files changed, 107 insertions(+), 77 deletions(-) diff --git a/docker/images.json b/docker/images.json index e2e22468596..d072438688d 100644 --- a/docker/images.json +++ b/docker/images.json @@ -1,12 +1,14 @@ { "docker/packager/deb": { "name": "yandex/clickhouse-deb-builder", + "symlink_name": "clickhouse/deb-builder", "dependent": [ "docker/packager/unbundled" ] }, "docker/packager/binary": { "name": "yandex/clickhouse-binary-builder", + "symlink_name": "clickhouse/binary-builder", "dependent": [ "docker/test/split_build_smoke_test", "docker/test/pvs", @@ -15,26 +17,32 @@ }, "docker/packager/unbundled": { "name": "yandex/clickhouse-unbundled-builder", + "symlink_name": "clickhouse/unbundled-builder", "dependent": [] }, "docker/test/compatibility/centos": { "name": "yandex/clickhouse-test-old-centos", + "symlink_name": "clickhouse/test-old-centos", "dependent": [] }, "docker/test/compatibility/ubuntu": { "name": "yandex/clickhouse-test-old-ubuntu", + "symlink_name": "clickhouse/test-old-ubuntu", "dependent": [] }, "docker/test/integration/base": { "name": "yandex/clickhouse-integration-test", + "symlink_name": "clickhouse/integration-test", "dependent": [] }, "docker/test/fuzzer": { "name": "yandex/clickhouse-fuzzer", + "symlink_name": "clickhouse/fuzzer", "dependent": [] }, "docker/test/performance-comparison": { "name": "yandex/clickhouse-performance-comparison", + "symlink_name": "clickhouse/performance-comparison", "dependent": [] }, "docker/test/pvs": { @@ -43,96 +51,113 @@ }, "docker/test/stateless": { "name": "yandex/clickhouse-stateless-test", + "symlink_name": "clickhouse/stateless-test", "dependent": [ "docker/test/stateful", "docker/test/coverage", "docker/test/unit" ] }, - "docker/test/stateless_pytest": { - "name": "yandex/clickhouse-stateless-pytest", - "dependent": [] - }, "docker/test/stateful": { "name": "yandex/clickhouse-stateful-test", + "symlink_name": "clickhouse/stateful-test", "dependent": [ "docker/test/stress" ] }, "docker/test/coverage": { "name": "yandex/clickhouse-test-coverage", + "symlink_name": "clickhouse/test-coverage", "dependent": [] }, "docker/test/unit": { "name": "yandex/clickhouse-unit-test", + "symlink_name": "clickhouse/unit-test", "dependent": [] }, "docker/test/stress": { "name": "yandex/clickhouse-stress-test", + "symlink_name": "clickhouse/stress-test", "dependent": [] }, "docker/test/split_build_smoke_test": { "name": "yandex/clickhouse-split-build-smoke-test", + "symlink_name": "clickhouse/split-build-smoke-test", "dependent": [] }, "docker/test/codebrowser": { "name": "yandex/clickhouse-codebrowser", + "symlink_name": "clickhouse/codebrowser", "dependent": [] }, "docker/test/integration/runner": { "name": "yandex/clickhouse-integration-tests-runner", + "symlink_name": "clickhouse/integration-tests-runner", "dependent": [] }, "docker/test/testflows/runner": { "name": "yandex/clickhouse-testflows-runner", + "symlink_name": "clickhouse/testflows-runner", "dependent": [] }, "docker/test/fasttest": { "name": "yandex/clickhouse-fasttest", + "symlink_name": "clickhouse/fasttest", "dependent": [] }, "docker/test/style": { "name": "yandex/clickhouse-style-test", + "symlink_name": "clickhouse/style-test", "dependent": [] }, "docker/test/integration/s3_proxy": { "name": "yandex/clickhouse-s3-proxy", + "symlink_name": "clickhouse/s3-proxy", "dependent": [] }, "docker/test/integration/resolver": { "name": "yandex/clickhouse-python-bottle", + "symlink_name": "clickhouse/python-bottle", "dependent": [] }, "docker/test/integration/helper_container": { "name": "yandex/clickhouse-integration-helper", + "symlink_name": "clickhouse/integration-helper", "dependent": [] }, "docker/test/integration/mysql_golang_client": { "name": "yandex/clickhouse-mysql-golang-client", + "symlink_name": "clickhouse/mysql-golang-client", "dependent": [] }, "docker/test/integration/mysql_java_client": { "name": "yandex/clickhouse-mysql-java-client", + "symlink_name": "clickhouse/mysql-golang-client", "dependent": [] }, "docker/test/integration/mysql_js_client": { "name": "yandex/clickhouse-mysql-js-client", + "symlink_name": "clickhouse/mysql-js-client", "dependent": [] }, "docker/test/integration/mysql_php_client": { "name": "yandex/clickhouse-mysql-php-client", + "symlink_name": "clickhouse/mysql-php-client", "dependent": [] }, "docker/test/integration/postgresql_java_client": { "name": "yandex/clickhouse-postgresql-java-client", + "symlink_name": "clickhouse/postgresql-java-client", "dependent": [] }, "docker/test/integration/kerberos_kdc": { "name": "yandex/clickhouse-kerberos-kdc", + "symlink_name": "clickhouse/kerberos-kdc", "dependent": [] }, "docker/test/base": { "name": "yandex/clickhouse-test-base", + "symlink_name": "clickhouse/test-base", "dependent": [ "docker/test/stateless", "docker/test/stateless_unbundled", @@ -144,25 +169,30 @@ }, "docker/packager/unbundled": { "name": "yandex/clickhouse-unbundled-builder", + "symlink_name": "clickhouse/unbundled-builder", "dependent": [ "docker/test/stateless_unbundled" ] }, "docker/test/stateless_unbundled": { "name": "yandex/clickhouse-stateless-unbundled-test", + "symlink_name": "clickhouse/stateless-unbundled-test", "dependent": [ ] }, "docker/test/integration/kerberized_hadoop": { "name": "yandex/clickhouse-kerberized-hadoop", + "symlink_name": "clickhouse/kerberized-hadoop", "dependent": [] }, "docker/test/sqlancer": { "name": "yandex/clickhouse-sqlancer-test", + "symlink_name": "clickhouse/sqlancer-test", "dependent": [] }, "docker/test/keeper-jepsen": { "name": "yandex/clickhouse-keeper-jepsen-test", + "symlink_name": "clickhouse/keeper-jepsen-test", "dependent": [] } } diff --git a/docker/packager/binary/Dockerfile b/docker/packager/binary/Dockerfile index 0393669df48..605f1a853ff 100644 --- a/docker/packager/binary/Dockerfile +++ b/docker/packager/binary/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-binary-builder . +# docker build -t clickhouse/binary-builder . FROM ubuntu:20.04 ENV DEBIAN_FRONTEND=noninteractive LLVM_VERSION=11 diff --git a/docker/packager/deb/Dockerfile b/docker/packager/deb/Dockerfile index 294c8645455..74f3a4635b3 100644 --- a/docker/packager/deb/Dockerfile +++ b/docker/packager/deb/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-deb-builder . +# docker build -t clickhouse/deb-builder . FROM ubuntu:20.04 ENV DEBIAN_FRONTEND=noninteractive LLVM_VERSION=11 diff --git a/docker/packager/packager b/docker/packager/packager index 673878bce43..93737add301 100755 --- a/docker/packager/packager +++ b/docker/packager/packager @@ -9,9 +9,9 @@ import sys SCRIPT_PATH = os.path.realpath(__file__) IMAGE_MAP = { - "deb": "yandex/clickhouse-deb-builder", - "binary": "yandex/clickhouse-binary-builder", - "unbundled": "yandex/clickhouse-unbundled-builder" + "deb": "clickhouse/deb-builder", + "binary": "clickhouse/binary-builder", + "unbundled": "clickhouse/unbundled-builder" } def check_image_exists_locally(image_name): diff --git a/docker/packager/unbundled/Dockerfile b/docker/packager/unbundled/Dockerfile index b2d9f555f19..3527c105783 100644 --- a/docker/packager/unbundled/Dockerfile +++ b/docker/packager/unbundled/Dockerfile @@ -1,5 +1,5 @@ -# docker build -t yandex/clickhouse-unbundled-builder . -FROM yandex/clickhouse-deb-builder +# docker build -t clickhouse/unbundled-builder . +FROM clickhouse/deb-builder RUN export CODENAME="$(lsb_release --codename --short | tr 'A-Z' 'a-z')" \ && wget -nv -O /tmp/arrow-keyring.deb "https://apache.jfrog.io/artifactory/arrow/ubuntu/apache-arrow-apt-source-latest-${CODENAME}.deb" \ diff --git a/docker/test/base/Dockerfile b/docker/test/base/Dockerfile index 611ef6b7702..fbbc902f6b6 100644 --- a/docker/test/base/Dockerfile +++ b/docker/test/base/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-test-base . +# docker build -t clickhouse/test-base . FROM ubuntu:20.04 ENV DEBIAN_FRONTEND=noninteractive LLVM_VERSION=11 diff --git a/docker/test/codebrowser/Dockerfile b/docker/test/codebrowser/Dockerfile index 33173ab90f9..6ca5c891388 100644 --- a/docker/test/codebrowser/Dockerfile +++ b/docker/test/codebrowser/Dockerfile @@ -1,6 +1,6 @@ -# docker build --network=host -t yandex/clickhouse-codebrowser . -# docker run --volume=path_to_repo:/repo_folder --volume=path_to_result:/test_output yandex/clickhouse-codebrowser -FROM yandex/clickhouse-binary-builder +# docker build --network=host -t clickhouse/codebrowser . +# docker run --volume=path_to_repo:/repo_folder --volume=path_to_result:/test_output clickhouse/codebrowser +FROM clickhouse/binary-builder RUN sed -i 's|http://archive|http://ru.archive|g' /etc/apt/sources.list diff --git a/docker/test/compatibility/centos/Dockerfile b/docker/test/compatibility/centos/Dockerfile index 0ef119d1bb1..628609e374f 100644 --- a/docker/test/compatibility/centos/Dockerfile +++ b/docker/test/compatibility/centos/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-test-old-centos . +# docker build -t clickhouse/test-old-centos . FROM centos:5 CMD /bin/sh -c "/clickhouse server --config /config/config.xml > /var/log/clickhouse-server/stderr.log 2>&1 & \ diff --git a/docker/test/compatibility/ubuntu/Dockerfile b/docker/test/compatibility/ubuntu/Dockerfile index 28f89e47b95..ddd0a76bd44 100644 --- a/docker/test/compatibility/ubuntu/Dockerfile +++ b/docker/test/compatibility/ubuntu/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-test-old-ubuntu . +# docker build -t clickhouse/test-old-ubuntu . FROM ubuntu:12.04 CMD /bin/sh -c "/clickhouse server --config /config/config.xml > /var/log/clickhouse-server/stderr.log 2>&1 & \ diff --git a/docker/test/coverage/Dockerfile b/docker/test/coverage/Dockerfile index 681f65e0f6f..ccf0bbc7c83 100644 --- a/docker/test/coverage/Dockerfile +++ b/docker/test/coverage/Dockerfile @@ -1,5 +1,5 @@ -# docker build -t yandex/clickhouse-test-coverage . -FROM yandex/clickhouse-stateless-test +# docker build -t clickhouse/test-coverage . +FROM clickhouse/stateless-test RUN apt-get update -y \ && env DEBIAN_FRONTEND=noninteractive \ diff --git a/docker/test/fasttest/Dockerfile b/docker/test/fasttest/Dockerfile index 2e0bbcd350f..ab62ceeb2c0 100644 --- a/docker/test/fasttest/Dockerfile +++ b/docker/test/fasttest/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-fasttest . +# docker build -t clickhouse/fasttest . FROM ubuntu:20.04 ENV DEBIAN_FRONTEND=noninteractive LLVM_VERSION=11 diff --git a/docker/test/fuzzer/Dockerfile b/docker/test/fuzzer/Dockerfile index 9a96ac1dfa7..6444e745c47 100644 --- a/docker/test/fuzzer/Dockerfile +++ b/docker/test/fuzzer/Dockerfile @@ -1,5 +1,5 @@ -# docker build -t yandex/clickhouse-fuzzer . -FROM yandex/clickhouse-test-base +# docker build -t clickhouse/fuzzer . +FROM clickhouse/test-base ENV LANG=C.UTF-8 ENV TZ=Europe/Moscow @@ -36,5 +36,5 @@ CMD set -o pipefail \ && cd /workspace \ && /run-fuzzer.sh 2>&1 | ts "$(printf '%%Y-%%m-%%d %%H:%%M:%%S\t')" | tee main.log -# docker run --network=host --volume :/workspace -e PR_TO_TEST=<> -e SHA_TO_TEST=<> yandex/clickhouse-fuzzer +# docker run --network=host --volume :/workspace -e PR_TO_TEST=<> -e SHA_TO_TEST=<> clickhouse/fuzzer diff --git a/docker/test/integration/base/Dockerfile b/docker/test/integration/base/Dockerfile index 344c1b9a698..519c64297e5 100644 --- a/docker/test/integration/base/Dockerfile +++ b/docker/test/integration/base/Dockerfile @@ -1,5 +1,5 @@ -# docker build -t yandex/clickhouse-integration-test . -FROM yandex/clickhouse-test-base +# docker build -t clickhouse/integration-test . +FROM clickhouse/test-base SHELL ["/bin/bash", "-c"] diff --git a/docker/test/integration/helper_container/Dockerfile b/docker/test/integration/helper_container/Dockerfile index 922eb2c6f22..6a093081bf2 100644 --- a/docker/test/integration/helper_container/Dockerfile +++ b/docker/test/integration/helper_container/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-integration-helper . +# docker build -t clickhouse/integration-helper . # Helper docker container to run iptables without sudo FROM alpine diff --git a/docker/test/integration/kerberized_hadoop/Dockerfile b/docker/test/integration/kerberized_hadoop/Dockerfile index 6a2fd96e7a7..11da590f901 100644 --- a/docker/test/integration/kerberized_hadoop/Dockerfile +++ b/docker/test/integration/kerberized_hadoop/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-kerberized-hadoop . +# docker build -t clickhouse/kerberized-hadoop . FROM sequenceiq/hadoop-docker:2.7.0 RUN sed -i -e 's/^\#baseurl/baseurl/' /etc/yum.repos.d/CentOS-Base.repo diff --git a/docker/test/integration/kerberos_kdc/Dockerfile b/docker/test/integration/kerberos_kdc/Dockerfile index ea231b1191d..a33d1d24568 100644 --- a/docker/test/integration/kerberos_kdc/Dockerfile +++ b/docker/test/integration/kerberos_kdc/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-kerberos-kdc . +# docker build -t clickhouse/kerberos-kdc . FROM centos:6.6 # old OS to make is faster and smaller diff --git a/docker/test/integration/mysql_golang_client/Dockerfile b/docker/test/integration/mysql_golang_client/Dockerfile index 4380383d1fb..6e448b4c66a 100644 --- a/docker/test/integration/mysql_golang_client/Dockerfile +++ b/docker/test/integration/mysql_golang_client/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-mysql-golang-client . +# docker build -t clickhouse/mysql-golang-client . # MySQL golang client docker container FROM golang:1.12.2 diff --git a/docker/test/integration/mysql_java_client/Dockerfile b/docker/test/integration/mysql_java_client/Dockerfile index fcb6a39f33b..0abf50cd493 100644 --- a/docker/test/integration/mysql_java_client/Dockerfile +++ b/docker/test/integration/mysql_java_client/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-mysql-java-client . +# docker build -t clickhouse/mysql-java-client . # MySQL Java client docker container FROM ubuntu:18.04 diff --git a/docker/test/integration/mysql_js_client/Dockerfile b/docker/test/integration/mysql_js_client/Dockerfile index 4f12de004ac..b1397b40d38 100644 --- a/docker/test/integration/mysql_js_client/Dockerfile +++ b/docker/test/integration/mysql_js_client/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-mysql-js-client . +# docker build -t clickhouse/mysql-js-client . # MySQL JavaScript client docker container FROM node:8 diff --git a/docker/test/integration/mysql_php_client/Dockerfile b/docker/test/integration/mysql_php_client/Dockerfile index e2ceb62f44f..0fb77bf8ffb 100644 --- a/docker/test/integration/mysql_php_client/Dockerfile +++ b/docker/test/integration/mysql_php_client/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-mysql-php-client . +# docker build -t clickhouse/mysql-php-client . # MySQL PHP client docker container FROM php:7.3-cli diff --git a/docker/test/integration/postgresql_java_client/Dockerfile b/docker/test/integration/postgresql_java_client/Dockerfile index eab236c9590..f5484028ec9 100644 --- a/docker/test/integration/postgresql_java_client/Dockerfile +++ b/docker/test/integration/postgresql_java_client/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-postgresql-java-client . +# docker build -t clickhouse/postgresql-java-client . # PostgreSQL Java client docker container FROM ubuntu:18.04 diff --git a/docker/test/integration/resolver/Dockerfile b/docker/test/integration/resolver/Dockerfile index b0efb4b46d5..01b9b777614 100644 --- a/docker/test/integration/resolver/Dockerfile +++ b/docker/test/integration/resolver/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-python-bottle . +# docker build -t clickhouse/python-bottle . # Helper docker container to run python bottle apps FROM python:3 diff --git a/docker/test/integration/runner/Dockerfile b/docker/test/integration/runner/Dockerfile index ef333e461c5..06e1f64ced2 100644 --- a/docker/test/integration/runner/Dockerfile +++ b/docker/test/integration/runner/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-integration-tests-runner . +# docker build -t clickhouse/integration-tests-runner . FROM ubuntu:20.04 RUN sed -i 's|http://archive|http://ru.archive|g' /etc/apt/sources.list diff --git a/docker/test/integration/runner/compose/docker_compose_jdbc_bridge.yml b/docker/test/integration/runner/compose/docker_compose_jdbc_bridge.yml index a65ef629df6..b3686adc21c 100644 --- a/docker/test/integration/runner/compose/docker_compose_jdbc_bridge.yml +++ b/docker/test/integration/runner/compose/docker_compose_jdbc_bridge.yml @@ -1,7 +1,7 @@ version: '2.3' services: bridge1: - image: yandex/clickhouse-jdbc-bridge + image: clickhouse/jdbc-bridge command: | /bin/bash -c 'cat << EOF > config/datasources/self.json { diff --git a/docker/test/integration/runner/compose/docker_compose_keeper.yml b/docker/test/integration/runner/compose/docker_compose_keeper.yml index e11a13e6eab..134ffbff1f7 100644 --- a/docker/test/integration/runner/compose/docker_compose_keeper.yml +++ b/docker/test/integration/runner/compose/docker_compose_keeper.yml @@ -1,7 +1,7 @@ version: '2.3' services: zoo1: - image: ${image:-yandex/clickhouse-integration-test} + image: ${image:-clickhouse/integration-test} restart: always user: ${user:-} volumes: @@ -31,7 +31,7 @@ services: - inet6 - rotate zoo2: - image: ${image:-yandex/clickhouse-integration-test} + image: ${image:-clickhouse/integration-test} restart: always user: ${user:-} volumes: @@ -61,7 +61,7 @@ services: - inet6 - rotate zoo3: - image: ${image:-yandex/clickhouse-integration-test} + image: ${image:-clickhouse/integration-test} restart: always user: ${user:-} volumes: diff --git a/docker/test/integration/runner/compose/docker_compose_kerberized_hdfs.yml b/docker/test/integration/runner/compose/docker_compose_kerberized_hdfs.yml index b09e75a8515..236c4f10b01 100644 --- a/docker/test/integration/runner/compose/docker_compose_kerberized_hdfs.yml +++ b/docker/test/integration/runner/compose/docker_compose_kerberized_hdfs.yml @@ -4,7 +4,7 @@ services: kerberizedhdfs1: cap_add: - DAC_READ_SEARCH - image: yandex/clickhouse-kerberized-hadoop:16621 + image: clickhouse/kerberized-hadoop:16621 hostname: kerberizedhdfs1 restart: always volumes: @@ -22,7 +22,7 @@ services: entrypoint: /etc/bootstrap.sh -d hdfskerberos: - image: yandex/clickhouse-kerberos-kdc:${DOCKER_KERBEROS_KDC_TAG:-latest} + image: clickhouse/kerberos-kdc:${DOCKER_KERBEROS_KDC_TAG:-latest} hostname: hdfskerberos volumes: - ${KERBERIZED_HDFS_DIR}/secrets:/tmp/keytab diff --git a/docker/test/integration/runner/compose/docker_compose_kerberized_kafka.yml b/docker/test/integration/runner/compose/docker_compose_kerberized_kafka.yml index 081b90c4f27..d57e4e4d5be 100644 --- a/docker/test/integration/runner/compose/docker_compose_kerberized_kafka.yml +++ b/docker/test/integration/runner/compose/docker_compose_kerberized_kafka.yml @@ -50,7 +50,7 @@ services: - label:disable kafka_kerberos: - image: yandex/clickhouse-kerberos-kdc:${DOCKER_KERBEROS_KDC_TAG:-latest} + image: clickhouse/kerberos-kdc:${DOCKER_KERBEROS_KDC_TAG:-latest} hostname: kafka_kerberos volumes: - ${KERBERIZED_KAFKA_DIR}/secrets:/tmp/keytab diff --git a/docker/test/integration/runner/compose/docker_compose_minio.yml b/docker/test/integration/runner/compose/docker_compose_minio.yml index 96a5f8bdc31..4384c0868a5 100644 --- a/docker/test/integration/runner/compose/docker_compose_minio.yml +++ b/docker/test/integration/runner/compose/docker_compose_minio.yml @@ -19,14 +19,14 @@ services: # HTTP proxies for Minio. proxy1: - image: yandex/clickhouse-s3-proxy + image: clickhouse/s3-proxy expose: - "8080" # Redirect proxy port - "80" # Reverse proxy port - "443" # Reverse proxy port (secure) proxy2: - image: yandex/clickhouse-s3-proxy + image: clickhouse/s3-proxy expose: - "8080" - "80" @@ -34,7 +34,7 @@ services: # Empty container to run proxy resolver. resolver: - image: yandex/clickhouse-python-bottle + image: clickhouse/python-bottle expose: - "8080" tty: true diff --git a/docker/test/integration/runner/compose/docker_compose_mysql_golang_client.yml b/docker/test/integration/runner/compose/docker_compose_mysql_golang_client.yml index a6a338eb6a8..56cc0410574 100644 --- a/docker/test/integration/runner/compose/docker_compose_mysql_golang_client.yml +++ b/docker/test/integration/runner/compose/docker_compose_mysql_golang_client.yml @@ -1,6 +1,6 @@ version: '2.3' services: golang1: - image: yandex/clickhouse-mysql-golang-client:${DOCKER_MYSQL_GOLANG_CLIENT_TAG:-latest} + image: clickhouse/mysql-golang-client:${DOCKER_MYSQL_GOLANG_CLIENT_TAG:-latest} # to keep container running command: sleep infinity diff --git a/docker/test/integration/runner/compose/docker_compose_mysql_java_client.yml b/docker/test/integration/runner/compose/docker_compose_mysql_java_client.yml index 21d927df82c..eb5ffb01baa 100644 --- a/docker/test/integration/runner/compose/docker_compose_mysql_java_client.yml +++ b/docker/test/integration/runner/compose/docker_compose_mysql_java_client.yml @@ -1,6 +1,6 @@ version: '2.3' services: java1: - image: yandex/clickhouse-mysql-java-client:${DOCKER_MYSQL_JAVA_CLIENT_TAG:-latest} + image: clickhouse/mysql-java-client:${DOCKER_MYSQL_JAVA_CLIENT_TAG:-latest} # to keep container running command: sleep infinity diff --git a/docker/test/integration/runner/compose/docker_compose_mysql_js_client.yml b/docker/test/integration/runner/compose/docker_compose_mysql_js_client.yml index dbd85cf2382..90939449c5f 100644 --- a/docker/test/integration/runner/compose/docker_compose_mysql_js_client.yml +++ b/docker/test/integration/runner/compose/docker_compose_mysql_js_client.yml @@ -1,6 +1,6 @@ version: '2.3' services: mysqljs1: - image: yandex/clickhouse-mysql-js-client:${DOCKER_MYSQL_JS_CLIENT_TAG:-latest} + image: clickhouse/mysql-js-client:${DOCKER_MYSQL_JS_CLIENT_TAG:-latest} # to keep container running command: sleep infinity diff --git a/docker/test/integration/runner/compose/docker_compose_mysql_php_client.yml b/docker/test/integration/runner/compose/docker_compose_mysql_php_client.yml index f24f5337a7e..408b8ff089a 100644 --- a/docker/test/integration/runner/compose/docker_compose_mysql_php_client.yml +++ b/docker/test/integration/runner/compose/docker_compose_mysql_php_client.yml @@ -1,6 +1,6 @@ version: '2.3' services: php1: - image: yandex/clickhouse-mysql-php-client:${DOCKER_MYSQL_PHP_CLIENT_TAG:-latest} + image: clickhouse/mysql-php-client:${DOCKER_MYSQL_PHP_CLIENT_TAG:-latest} # to keep container running command: sleep infinity diff --git a/docker/test/integration/runner/compose/docker_compose_postgresql_java_client.yml b/docker/test/integration/runner/compose/docker_compose_postgresql_java_client.yml index 38191f1bdd6..904bfffdfd5 100644 --- a/docker/test/integration/runner/compose/docker_compose_postgresql_java_client.yml +++ b/docker/test/integration/runner/compose/docker_compose_postgresql_java_client.yml @@ -1,6 +1,6 @@ version: '2.2' services: java: - image: yandex/clickhouse-postgresql-java-client:${DOCKER_POSTGRESQL_JAVA_CLIENT_TAG:-latest} + image: clickhouse/postgresql-java-client:${DOCKER_POSTGRESQL_JAVA_CLIENT_TAG:-latest} # to keep container running command: sleep infinity diff --git a/docker/test/integration/s3_proxy/Dockerfile b/docker/test/integration/s3_proxy/Dockerfile index d8b1754fa71..5858218e4e4 100644 --- a/docker/test/integration/s3_proxy/Dockerfile +++ b/docker/test/integration/s3_proxy/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-s3-proxy . +# docker build -t clickhouse/s3-proxy . FROM nginx:alpine COPY run.sh /run.sh diff --git a/docker/test/keeper-jepsen/Dockerfile b/docker/test/keeper-jepsen/Dockerfile index 1a62d5e793f..5bb7f9433c2 100644 --- a/docker/test/keeper-jepsen/Dockerfile +++ b/docker/test/keeper-jepsen/Dockerfile @@ -1,5 +1,5 @@ -# docker build -t yandex/clickhouse-keeper-jepsen-test . -FROM yandex/clickhouse-test-base +# docker build -t clickhouse/keeper-jepsen-test . +FROM clickhouse/test-base ENV DEBIAN_FRONTEND=noninteractive ENV CLOJURE_VERSION=1.10.3.814 diff --git a/docker/test/performance-comparison/Dockerfile b/docker/test/performance-comparison/Dockerfile index 1a61c4b274a..88b66d42ecb 100644 --- a/docker/test/performance-comparison/Dockerfile +++ b/docker/test/performance-comparison/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-performance-comparison . +# docker build -t clickhouse/performance-comparison . FROM ubuntu:18.04 ENV LANG=C.UTF-8 @@ -54,4 +54,4 @@ COPY * / # it gives '/bin/sh: 1: [bash,: not found' otherwise. CMD ["bash", "-c", "node=$((RANDOM % $(numactl --hardware | sed -n 's/^.*available:\\(.*\\)nodes.*$/\\1/p'))); echo Will bind to NUMA node $node; numactl --cpunodebind=$node --membind=$node /entrypoint.sh"] -# docker run --network=host --volume :/workspace --volume=:/output -e PR_TO_TEST=<> -e SHA_TO_TEST=<> yandex/clickhouse-performance-comparison +# docker run --network=host --volume :/workspace --volume=:/output -e PR_TO_TEST=<> -e SHA_TO_TEST=<> clickhouse/performance-comparison diff --git a/docker/test/performance-comparison/README.md b/docker/test/performance-comparison/README.md index 782644a81dd..75213fad077 100644 --- a/docker/test/performance-comparison/README.md +++ b/docker/test/performance-comparison/README.md @@ -116,7 +116,7 @@ pull requests (0 for master) manually. docker run --network=host --volume=$(pwd)/workspace:/workspace --volume=$(pwd)/output:/output [-e REF_PR={} -e REF_SHA={}] -e PR_TO_TEST={} -e SHA_TO_TEST={} - yandex/clickhouse-performance-comparison + clickhouse/performance-comparison ``` Then see the `report.html` in the `output` directory. diff --git a/docker/test/pvs/Dockerfile b/docker/test/pvs/Dockerfile index 7bd45ba4018..4ef0f7c1475 100644 --- a/docker/test/pvs/Dockerfile +++ b/docker/test/pvs/Dockerfile @@ -1,6 +1,6 @@ -# docker build -t yandex/clickhouse-pvs-test . +# docker build -t clickhouse/pvs-test . -FROM yandex/clickhouse-binary-builder +FROM clickhouse/binary-builder RUN apt-get update --yes \ && apt-get install \ diff --git a/docker/test/split_build_smoke_test/Dockerfile b/docker/test/split_build_smoke_test/Dockerfile index 54a9eb17868..3cc2f26a507 100644 --- a/docker/test/split_build_smoke_test/Dockerfile +++ b/docker/test/split_build_smoke_test/Dockerfile @@ -1,5 +1,5 @@ -# docker build -t yandex/clickhouse-split-build-smoke-test . -FROM yandex/clickhouse-binary-builder +# docker build -t clickhouse/split-build-smoke-test . +FROM clickhouse/binary-builder COPY run.sh /run.sh COPY process_split_build_smoke_test_result.py / diff --git a/docker/test/sqlancer/Dockerfile b/docker/test/sqlancer/Dockerfile index 67236402352..f603b812408 100644 --- a/docker/test/sqlancer/Dockerfile +++ b/docker/test/sqlancer/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-sqlancer-test . +# docker build -t clickhouse/sqlancer-test . FROM ubuntu:20.04 RUN sed -i 's|http://archive|http://ru.archive|g' /etc/apt/sources.list diff --git a/docker/test/stateful/Dockerfile b/docker/test/stateful/Dockerfile index 07aad75a2ea..c237a712f52 100644 --- a/docker/test/stateful/Dockerfile +++ b/docker/test/stateful/Dockerfile @@ -1,5 +1,5 @@ -# docker build -t yandex/clickhouse-stateful-test . -FROM yandex/clickhouse-stateless-test +# docker build -t clickhouse/stateful-test . +FROM clickhouse/stateless-test RUN apt-get update -y \ && env DEBIAN_FRONTEND=noninteractive \ diff --git a/docker/test/stateless/Dockerfile b/docker/test/stateless/Dockerfile index b66fa055e7b..3b5edb2c869 100644 --- a/docker/test/stateless/Dockerfile +++ b/docker/test/stateless/Dockerfile @@ -1,5 +1,5 @@ -# docker build -t yandex/clickhouse-stateless-test . -FROM yandex/clickhouse-test-base +# docker build -t clickhouse/stateless-test . +FROM clickhouse/test-base ARG odbc_driver_url="https://github.com/ClickHouse/clickhouse-odbc/releases/download/v1.1.4.20200302/clickhouse-odbc-1.1.4-Linux.tar.gz" diff --git a/docker/test/stateless_pytest/Dockerfile b/docker/test/stateless_pytest/Dockerfile index 947a70426d6..c1e47523f6d 100644 --- a/docker/test/stateless_pytest/Dockerfile +++ b/docker/test/stateless_pytest/Dockerfile @@ -1,5 +1,5 @@ -# docker build -t yandex/clickhouse-stateless-pytest . -FROM yandex/clickhouse-test-base +# docker build -t clickhouse/stateless-pytest . +FROM clickhouse/test-base RUN apt-get update -y && \ apt-get install -y --no-install-recommends \ diff --git a/docker/test/stateless_unbundled/Dockerfile b/docker/test/stateless_unbundled/Dockerfile index 53857a90ac7..dfe441e08a6 100644 --- a/docker/test/stateless_unbundled/Dockerfile +++ b/docker/test/stateless_unbundled/Dockerfile @@ -1,5 +1,5 @@ -# docker build -t yandex/clickhouse-stateless-unbundled-test . -FROM yandex/clickhouse-test-base +# docker build -t clickhouse/stateless-unbundled-test . +FROM clickhouse/test-base ARG odbc_driver_url="https://github.com/ClickHouse/clickhouse-odbc/releases/download/v1.1.4.20200302/clickhouse-odbc-1.1.4-Linux.tar.gz" diff --git a/docker/test/stress/Dockerfile b/docker/test/stress/Dockerfile index e1df32ec3d7..3fe1b790d5a 100644 --- a/docker/test/stress/Dockerfile +++ b/docker/test/stress/Dockerfile @@ -1,5 +1,5 @@ -# docker build -t yandex/clickhouse-stress-test . -FROM yandex/clickhouse-stateful-test +# docker build -t clickhouse/stress-test . +FROM clickhouse/stateful-test RUN apt-get update -y \ && env DEBIAN_FRONTEND=noninteractive \ diff --git a/docker/test/stress/README.md b/docker/test/stress/README.md index f747996fa2d..b1519e7968d 100644 --- a/docker/test/stress/README.md +++ b/docker/test/stress/README.md @@ -6,7 +6,7 @@ Usage: ``` $ ls $HOME/someclickhouse clickhouse-client_18.14.9_all.deb clickhouse-common-static_18.14.9_amd64.deb clickhouse-server_18.14.9_all.deb clickhouse-test_18.14.9_all.deb -$ docker run --volume=$HOME/someclickhouse:/package_folder --volume=$HOME/test_output:/test_output yandex/clickhouse-stress-test +$ docker run --volume=$HOME/someclickhouse:/package_folder --volume=$HOME/test_output:/test_output clickhouse/stress-test Selecting previously unselected package clickhouse-common-static. (Reading database ... 14442 files and directories currently installed.) ... diff --git a/docker/test/style/Dockerfile b/docker/test/style/Dockerfile index c0b3b0102cf..33cdb9db57a 100644 --- a/docker/test/style/Dockerfile +++ b/docker/test/style/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-style-test . +# docker build -t clickhouse/style-test . FROM ubuntu:20.04 RUN sed -i 's|http://archive|http://ru.archive|g' /etc/apt/sources.list diff --git a/docker/test/test_runner.sh b/docker/test/test_runner.sh index cd6367b2964..0c99c8c2b32 100755 --- a/docker/test/test_runner.sh +++ b/docker/test/test_runner.sh @@ -49,7 +49,7 @@ fi # Build server image (optional) from local packages if [ -z "${CLICKHOUSE_SERVER_IMAGE}" ]; then - CLICKHOUSE_SERVER_IMAGE="yandex/clickhouse-server:local" + CLICKHOUSE_SERVER_IMAGE="clickhouse/server:local" if [ "${CLICKHOUSE_PACKAGES_ARG}" != "${NO_REBUILD_FLAG}" ]; then docker build --network=host \ diff --git a/docker/test/testflows/runner/Dockerfile b/docker/test/testflows/runner/Dockerfile index 81d431635b7..91d0eb844d9 100644 --- a/docker/test/testflows/runner/Dockerfile +++ b/docker/test/testflows/runner/Dockerfile @@ -1,4 +1,4 @@ -# docker build -t yandex/clickhouse-testflows-runner . +# docker build -t clickhouse/testflows-runner . FROM ubuntu:20.04 RUN sed -i 's|http://archive|http://ru.archive|g' /etc/apt/sources.list diff --git a/docker/test/unit/Dockerfile b/docker/test/unit/Dockerfile index e111611eecd..20d67773363 100644 --- a/docker/test/unit/Dockerfile +++ b/docker/test/unit/Dockerfile @@ -1,5 +1,5 @@ -# docker build -t yandex/clickhouse-unit-test . -FROM yandex/clickhouse-stateless-test +# docker build -t clickhouse/unit-test . +FROM clickhouse/stateless-test RUN apt-get install gdb From 714b2a3c19c722cffc0f6cd7ba2aec7cc7099da5 Mon Sep 17 00:00:00 2001 From: alesapin Date: Mon, 6 Sep 2021 14:33:49 +0300 Subject: [PATCH 046/102] More --- docker/images.json | 140 ++++++++++++++++++++++----------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/docker/images.json b/docker/images.json index d072438688d..ea410848871 100644 --- a/docker/images.json +++ b/docker/images.json @@ -1,14 +1,14 @@ { "docker/packager/deb": { - "name": "yandex/clickhouse-deb-builder", - "symlink_name": "clickhouse/deb-builder", + "name": "clickhouse/deb-builder", + "symlink_name": "yandex/clickhouse-deb-builder", "dependent": [ "docker/packager/unbundled" ] }, "docker/packager/binary": { - "name": "yandex/clickhouse-binary-builder", - "symlink_name": "clickhouse/binary-builder", + "name": "clickhouse/binary-builder", + "symlink_name": "yandex/clickhouse-binary-builder", "dependent": [ "docker/test/split_build_smoke_test", "docker/test/pvs", @@ -16,42 +16,43 @@ ] }, "docker/packager/unbundled": { - "name": "yandex/clickhouse-unbundled-builder", - "symlink_name": "clickhouse/unbundled-builder", + "name": "clickhouse/unbundled-builder", + "symlink_name": "yandex/clickhouse-unbundled-builder", "dependent": [] }, "docker/test/compatibility/centos": { - "name": "yandex/clickhouse-test-old-centos", - "symlink_name": "clickhouse/test-old-centos", + "name": "clickhouse/test-old-centos", + "symlink_name": "yandex/clickhouse-test-old-centos", "dependent": [] }, "docker/test/compatibility/ubuntu": { - "name": "yandex/clickhouse-test-old-ubuntu", - "symlink_name": "clickhouse/test-old-ubuntu", + "name": "clickhouse/test-old-ubuntu", + "symlink_name": "yandex/clickhouse-test-old-ubuntu", "dependent": [] }, "docker/test/integration/base": { - "name": "yandex/clickhouse-integration-test", - "symlink_name": "clickhouse/integration-test", + "name": "clickhouse/integration-test", + "symlink_name": "yandex/clickhouse-integration-test", "dependent": [] }, "docker/test/fuzzer": { - "name": "yandex/clickhouse-fuzzer", - "symlink_name": "clickhouse/fuzzer", + "name": "clickhouse/fuzzer", + "symlink_name": "yandex/clickhouse-fuzzer", "dependent": [] }, "docker/test/performance-comparison": { - "name": "yandex/clickhouse-performance-comparison", - "symlink_name": "clickhouse/performance-comparison", + "name": "clickhouse/performance-comparison", + "symlink_name": "yandex/clickhouse-performance-comparison", "dependent": [] }, "docker/test/pvs": { - "name": "yandex/clickhouse-pvs-test", + "name": "clickhouse/pvs-test", + "symlink_name": "yandex/clickhouse-pvs-test", "dependent": [] }, "docker/test/stateless": { - "name": "yandex/clickhouse-stateless-test", - "symlink_name": "clickhouse/stateless-test", + "name": "clickhouse/stateless-test", + "symlink_name": "yandex/clickhouse-stateless-test", "dependent": [ "docker/test/stateful", "docker/test/coverage", @@ -59,140 +60,139 @@ ] }, "docker/test/stateful": { - "name": "yandex/clickhouse-stateful-test", - "symlink_name": "clickhouse/stateful-test", + "name": "clickhouse/stateful-test", + "symlink_name": "yandex/clickhouse-stateful-test", "dependent": [ "docker/test/stress" ] }, "docker/test/coverage": { - "name": "yandex/clickhouse-test-coverage", - "symlink_name": "clickhouse/test-coverage", + "name": "clickhouse/test-coverage", + "symlink_name": "yandex/clickhouse-test-coverage", "dependent": [] }, "docker/test/unit": { - "name": "yandex/clickhouse-unit-test", - "symlink_name": "clickhouse/unit-test", + "name": "clickhouse/unit-test", + "symlink_name": "yandex/clickhouse-unit-test", "dependent": [] }, "docker/test/stress": { - "name": "yandex/clickhouse-stress-test", - "symlink_name": "clickhouse/stress-test", + "name": "clickhouse/stress-test", + "symlink_name": "yandex/clickhouse-stress-test", "dependent": [] }, "docker/test/split_build_smoke_test": { - "name": "yandex/clickhouse-split-build-smoke-test", - "symlink_name": "clickhouse/split-build-smoke-test", + "symlink_name": "yandex/clickhouse-split-build-smoke-test", + "name": "clickhouse/split-build-smoke-test", "dependent": [] }, "docker/test/codebrowser": { - "name": "yandex/clickhouse-codebrowser", - "symlink_name": "clickhouse/codebrowser", + "name": "clickhouse/codebrowser", + "symlink_name": "yandex/clickhouse-codebrowser", "dependent": [] }, "docker/test/integration/runner": { - "name": "yandex/clickhouse-integration-tests-runner", - "symlink_name": "clickhouse/integration-tests-runner", + "name": "clickhouse/integration-tests-runner", + "symlink_name": "yandex/clickhouse-integration-tests-runner", "dependent": [] }, "docker/test/testflows/runner": { - "name": "yandex/clickhouse-testflows-runner", - "symlink_name": "clickhouse/testflows-runner", + "name": "clickhouse/testflows-runner", + "symlink_name": "yandex/clickhouse-testflows-runner", "dependent": [] }, "docker/test/fasttest": { - "name": "yandex/clickhouse-fasttest", - "symlink_name": "clickhouse/fasttest", + "name": "clickhouse/fasttest", + "symlink_name": "yandex/clickhouse-fasttest", "dependent": [] }, "docker/test/style": { - "name": "yandex/clickhouse-style-test", - "symlink_name": "clickhouse/style-test", + "name": "clickhouse/style-test", + "symlink_name": "yandex/clickhouse-style-test", "dependent": [] }, "docker/test/integration/s3_proxy": { - "name": "yandex/clickhouse-s3-proxy", - "symlink_name": "clickhouse/s3-proxy", + "symlink_name": "yandex/clickhouse-s3-proxy", + "name": "clickhouse/s3-proxy", "dependent": [] }, "docker/test/integration/resolver": { - "name": "yandex/clickhouse-python-bottle", - "symlink_name": "clickhouse/python-bottle", + "name": "clickhouse/python-bottle", + "symlink_name": "yandex/clickhouse-python-bottle", "dependent": [] }, "docker/test/integration/helper_container": { - "name": "yandex/clickhouse-integration-helper", - "symlink_name": "clickhouse/integration-helper", + "name": "clickhouse/integration-helper", + "symlink_name": "yandex/clickhouse-integration-helper", "dependent": [] }, "docker/test/integration/mysql_golang_client": { - "name": "yandex/clickhouse-mysql-golang-client", - "symlink_name": "clickhouse/mysql-golang-client", + "name": "clickhouse/mysql-golang-client", + "symlink_name": "yandex/clickhouse-mysql-golang-client", "dependent": [] }, "docker/test/integration/mysql_java_client": { - "name": "yandex/clickhouse-mysql-java-client", - "symlink_name": "clickhouse/mysql-golang-client", + "name": "clickhouse/clickhouse-mysql-java-client", + "symlink_name": "yandex/clickhouse-mysql-java-client", "dependent": [] }, "docker/test/integration/mysql_js_client": { - "name": "yandex/clickhouse-mysql-js-client", - "symlink_name": "clickhouse/mysql-js-client", + "name": "clickhouse/mysql-js-client", + "symlink_name": "yandex/clickhouse-mysql-js-client", "dependent": [] }, "docker/test/integration/mysql_php_client": { - "name": "yandex/clickhouse-mysql-php-client", - "symlink_name": "clickhouse/mysql-php-client", + "name": "clickhouse/mysql-php-client", + "symlink_name": "yandex/clickhouse-mysql-php-client", "dependent": [] }, "docker/test/integration/postgresql_java_client": { - "name": "yandex/clickhouse-postgresql-java-client", - "symlink_name": "clickhouse/postgresql-java-client", + "name": "clickhouse/postgresql-java-client", + "symlink_name": "yandex/clickhouse-postgresql-java-client", "dependent": [] }, "docker/test/integration/kerberos_kdc": { - "name": "yandex/clickhouse-kerberos-kdc", - "symlink_name": "clickhouse/kerberos-kdc", + "name": "clickhouse/kerberos-kdc", + "symlink_name": "yandex/clickhouse-kerberos-kdc", "dependent": [] }, "docker/test/base": { - "name": "yandex/clickhouse-test-base", - "symlink_name": "clickhouse/test-base", + "name": "clickhouse/test-base", + "symlink_name": "yandex/clickhouse-test-base", "dependent": [ "docker/test/stateless", "docker/test/stateless_unbundled", - "docker/test/stateless_pytest", "docker/test/integration/base", "docker/test/fuzzer", "docker/test/keeper-jepsen" ] }, "docker/packager/unbundled": { - "name": "yandex/clickhouse-unbundled-builder", - "symlink_name": "clickhouse/unbundled-builder", + "name": "clickhouse/unbundled-builder", + "symlink_name": "yandex/clickhouse-unbundled-builder", "dependent": [ "docker/test/stateless_unbundled" ] }, "docker/test/stateless_unbundled": { - "name": "yandex/clickhouse-stateless-unbundled-test", - "symlink_name": "clickhouse/stateless-unbundled-test", + "name": "clickhouse/stateless-unbundled-test", + "symlink_name": "yandex/clickhouse-stateless-unbundled-test", "dependent": [ ] }, "docker/test/integration/kerberized_hadoop": { - "name": "yandex/clickhouse-kerberized-hadoop", - "symlink_name": "clickhouse/kerberized-hadoop", + "name": "clickhouse/kerberized-hadoop", + "symlink_name": "yandex/clickhouse-kerberized-hadoop", "dependent": [] }, "docker/test/sqlancer": { - "name": "yandex/clickhouse-sqlancer-test", - "symlink_name": "clickhouse/sqlancer-test", + "name": "clickhouse/sqlancer-test", + "symlink_name": "yandex/clickhouse-sqlancer-test", "dependent": [] }, "docker/test/keeper-jepsen": { - "name": "yandex/clickhouse-keeper-jepsen-test", - "symlink_name": "clickhouse/keeper-jepsen-test", + "name": "clickhouse/keeper-jepsen-test", + "symlink_name": "yandex/clickhouse-keeper-jepsen-test", "dependent": [] } } From 861258ecc0afce8940b95c57c4a1335973c3c1f6 Mon Sep 17 00:00:00 2001 From: alesapin Date: Mon, 6 Sep 2021 15:06:41 +0300 Subject: [PATCH 047/102] Simplier --- docker/images.json | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/docker/images.json b/docker/images.json index ea410848871..795ca47be00 100644 --- a/docker/images.json +++ b/docker/images.json @@ -1,14 +1,12 @@ { "docker/packager/deb": { "name": "clickhouse/deb-builder", - "symlink_name": "yandex/clickhouse-deb-builder", "dependent": [ "docker/packager/unbundled" ] }, "docker/packager/binary": { "name": "clickhouse/binary-builder", - "symlink_name": "yandex/clickhouse-binary-builder", "dependent": [ "docker/test/split_build_smoke_test", "docker/test/pvs", @@ -17,42 +15,34 @@ }, "docker/packager/unbundled": { "name": "clickhouse/unbundled-builder", - "symlink_name": "yandex/clickhouse-unbundled-builder", "dependent": [] }, "docker/test/compatibility/centos": { "name": "clickhouse/test-old-centos", - "symlink_name": "yandex/clickhouse-test-old-centos", "dependent": [] }, "docker/test/compatibility/ubuntu": { "name": "clickhouse/test-old-ubuntu", - "symlink_name": "yandex/clickhouse-test-old-ubuntu", "dependent": [] }, "docker/test/integration/base": { "name": "clickhouse/integration-test", - "symlink_name": "yandex/clickhouse-integration-test", "dependent": [] }, "docker/test/fuzzer": { "name": "clickhouse/fuzzer", - "symlink_name": "yandex/clickhouse-fuzzer", "dependent": [] }, "docker/test/performance-comparison": { "name": "clickhouse/performance-comparison", - "symlink_name": "yandex/clickhouse-performance-comparison", "dependent": [] }, "docker/test/pvs": { "name": "clickhouse/pvs-test", - "symlink_name": "yandex/clickhouse-pvs-test", "dependent": [] }, "docker/test/stateless": { "name": "clickhouse/stateless-test", - "symlink_name": "yandex/clickhouse-stateless-test", "dependent": [ "docker/test/stateful", "docker/test/coverage", @@ -61,104 +51,84 @@ }, "docker/test/stateful": { "name": "clickhouse/stateful-test", - "symlink_name": "yandex/clickhouse-stateful-test", "dependent": [ "docker/test/stress" ] }, "docker/test/coverage": { "name": "clickhouse/test-coverage", - "symlink_name": "yandex/clickhouse-test-coverage", "dependent": [] }, "docker/test/unit": { "name": "clickhouse/unit-test", - "symlink_name": "yandex/clickhouse-unit-test", "dependent": [] }, "docker/test/stress": { "name": "clickhouse/stress-test", - "symlink_name": "yandex/clickhouse-stress-test", "dependent": [] }, "docker/test/split_build_smoke_test": { - "symlink_name": "yandex/clickhouse-split-build-smoke-test", "name": "clickhouse/split-build-smoke-test", "dependent": [] }, "docker/test/codebrowser": { "name": "clickhouse/codebrowser", - "symlink_name": "yandex/clickhouse-codebrowser", "dependent": [] }, "docker/test/integration/runner": { "name": "clickhouse/integration-tests-runner", - "symlink_name": "yandex/clickhouse-integration-tests-runner", "dependent": [] }, "docker/test/testflows/runner": { "name": "clickhouse/testflows-runner", - "symlink_name": "yandex/clickhouse-testflows-runner", "dependent": [] }, "docker/test/fasttest": { "name": "clickhouse/fasttest", - "symlink_name": "yandex/clickhouse-fasttest", "dependent": [] }, "docker/test/style": { "name": "clickhouse/style-test", - "symlink_name": "yandex/clickhouse-style-test", "dependent": [] }, "docker/test/integration/s3_proxy": { - "symlink_name": "yandex/clickhouse-s3-proxy", "name": "clickhouse/s3-proxy", "dependent": [] }, "docker/test/integration/resolver": { "name": "clickhouse/python-bottle", - "symlink_name": "yandex/clickhouse-python-bottle", "dependent": [] }, "docker/test/integration/helper_container": { "name": "clickhouse/integration-helper", - "symlink_name": "yandex/clickhouse-integration-helper", "dependent": [] }, "docker/test/integration/mysql_golang_client": { "name": "clickhouse/mysql-golang-client", - "symlink_name": "yandex/clickhouse-mysql-golang-client", "dependent": [] }, "docker/test/integration/mysql_java_client": { "name": "clickhouse/clickhouse-mysql-java-client", - "symlink_name": "yandex/clickhouse-mysql-java-client", "dependent": [] }, "docker/test/integration/mysql_js_client": { "name": "clickhouse/mysql-js-client", - "symlink_name": "yandex/clickhouse-mysql-js-client", "dependent": [] }, "docker/test/integration/mysql_php_client": { "name": "clickhouse/mysql-php-client", - "symlink_name": "yandex/clickhouse-mysql-php-client", "dependent": [] }, "docker/test/integration/postgresql_java_client": { "name": "clickhouse/postgresql-java-client", - "symlink_name": "yandex/clickhouse-postgresql-java-client", "dependent": [] }, "docker/test/integration/kerberos_kdc": { "name": "clickhouse/kerberos-kdc", - "symlink_name": "yandex/clickhouse-kerberos-kdc", "dependent": [] }, "docker/test/base": { "name": "clickhouse/test-base", - "symlink_name": "yandex/clickhouse-test-base", "dependent": [ "docker/test/stateless", "docker/test/stateless_unbundled", @@ -169,30 +139,25 @@ }, "docker/packager/unbundled": { "name": "clickhouse/unbundled-builder", - "symlink_name": "yandex/clickhouse-unbundled-builder", "dependent": [ "docker/test/stateless_unbundled" ] }, "docker/test/stateless_unbundled": { "name": "clickhouse/stateless-unbundled-test", - "symlink_name": "yandex/clickhouse-stateless-unbundled-test", "dependent": [ ] }, "docker/test/integration/kerberized_hadoop": { "name": "clickhouse/kerberized-hadoop", - "symlink_name": "yandex/clickhouse-kerberized-hadoop", "dependent": [] }, "docker/test/sqlancer": { "name": "clickhouse/sqlancer-test", - "symlink_name": "yandex/clickhouse-sqlancer-test", "dependent": [] }, "docker/test/keeper-jepsen": { "name": "clickhouse/keeper-jepsen-test", - "symlink_name": "yandex/clickhouse-keeper-jepsen-test", "dependent": [] } } From 27876193fc89c5ba5a53e3fe116b9c6129303f46 Mon Sep 17 00:00:00 2001 From: George Date: Mon, 6 Sep 2021 15:36:20 +0300 Subject: [PATCH 048/102] Small fix --- docs/en/sql-reference/functions/tuple-map-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/functions/tuple-map-functions.md b/docs/en/sql-reference/functions/tuple-map-functions.md index 04f02c3ead4..8a2be922ec7 100644 --- a/docs/en/sql-reference/functions/tuple-map-functions.md +++ b/docs/en/sql-reference/functions/tuple-map-functions.md @@ -86,7 +86,7 @@ Arguments are [maps](../../sql-reference/data-types/map.md) or [tuples](../../sq **Example** -Query with a tuple map: +Query with a Tuple: ```sql SELECT mapAdd(([toUInt8(1), 2], [1, 1]), ([toUInt8(1), 2], [1, 1])) as res, toTypeName(res) as type; From 46638f1290e9a249eeaaf416f55df010d9080672 Mon Sep 17 00:00:00 2001 From: Alexey Date: Tue, 7 Sep 2021 19:32:12 +0000 Subject: [PATCH 049/102] Links to CREATE FUNCTION and DROP FUNCTION from function Introduction --- docs/en/sql-reference/functions/index.md | 4 ++++ docs/ru/sql-reference/functions/index.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/docs/en/sql-reference/functions/index.md b/docs/en/sql-reference/functions/index.md index 54afd461e1d..47da4e6f3cc 100644 --- a/docs/en/sql-reference/functions/index.md +++ b/docs/en/sql-reference/functions/index.md @@ -59,6 +59,10 @@ A lambda function that accepts multiple arguments can also be passed to a higher For some functions the first argument (the lambda function) can be omitted. In this case, identical mapping is assumed. +## User Defined Functions {#user-defined-functions} + +Custom functions can be created using the [CREATE FUNCTION](../statements/create/function.md) statement. To delete these functions use the [DROP FUNCTION](../statements/drop.md#drop-function) statement. + ## Error Handling {#error-handling} Some functions might throw an exception if the data is invalid. In this case, the query is canceled and an error text is returned to the client. For distributed processing, when an exception occurs on one of the servers, the other servers also attempt to abort the query. diff --git a/docs/ru/sql-reference/functions/index.md b/docs/ru/sql-reference/functions/index.md index 15da9d36ef5..92bd1c1c2f8 100644 --- a/docs/ru/sql-reference/functions/index.md +++ b/docs/ru/sql-reference/functions/index.md @@ -58,6 +58,10 @@ str -> str != Referer Для некоторых функций первый аргумент (лямбда-функция) может отсутствовать. В этом случае подразумевается тождественное отображение. +## Пользовательские функции {#user-defined-functions} + +Функции можно создавать с помощью выражения [CREATE FUNCTION](../statements/create/function.md). Для удаления таких функций используется выражение [DROP FUNCTION](../statements/drop.md#drop-function). + ## Обработка ошибок {#obrabotka-oshibok} Некоторые функции могут кидать исключения в случае ошибочных данных. В этом случае, выполнение запроса прерывается, и текст ошибки выводится клиенту. При распределённой обработке запроса, при возникновении исключения на одном из серверов, на другие серверы пытается отправиться просьба тоже прервать выполнение запроса. From cd038979d4cf5a529baf9b29a3ec6ebb646c7713 Mon Sep 17 00:00:00 2001 From: Olga Revyakina Date: Wed, 8 Sep 2021 05:32:02 +0300 Subject: [PATCH 050/102] Initial (en) --- .../engines/table-engines/integrations/s3.md | 2 +- docs/en/sql-reference/table-functions/s3.md | 26 ++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/docs/en/engines/table-engines/integrations/s3.md b/docs/en/engines/table-engines/integrations/s3.md index 7249e24aff9..e494e9aec6a 100644 --- a/docs/en/engines/table-engines/integrations/s3.md +++ b/docs/en/engines/table-engines/integrations/s3.md @@ -210,4 +210,4 @@ ENGINE = S3('https://storage.yandexcloud.net/my-test-bucket-768/big_prefix/file- ## See also -- [S3 table function](../../../sql-reference/table-functions/s3.md) +- [s3 table function](../../../sql-reference/table-functions/s3.md) diff --git a/docs/en/sql-reference/table-functions/s3.md b/docs/en/sql-reference/table-functions/s3.md index d84edb3f46e..de3e442fa79 100644 --- a/docs/en/sql-reference/table-functions/s3.md +++ b/docs/en/sql-reference/table-functions/s3.md @@ -3,7 +3,7 @@ toc_priority: 45 toc_title: s3 --- -# S3 Table Function {#s3-table-function} +# s3 Table Function {#s3-table-function} Provides table-like interface to select/insert files in [Amazon S3](https://aws.amazon.com/s3/). This table function is similar to [hdfs](../../sql-reference/table-functions/hdfs.md), but provides S3-specific features. @@ -125,6 +125,30 @@ INSERT INTO FUNCTION s3('https://storage.yandexcloud.net/my-test-bucket-768/test SELECT name, value FROM existing_table; ``` +## Partitioned Write {#partitioned-write} + +When inserting data into S3 table, you can split it into several files by specifying `PARTITION BY` expression. In this case a separate file is created for each partition value. Splitting the data helps to improve reading operations efficiency. + +**Examples** + +Using wildcards in a file name creates separate files: + +```sql +INSERT INTO TABLE FUNCTION + s3('http://bucket.amazonaws.com/my_bucket/file_{_partition_id}.csv', 'CSV', 'a UInt32, b UInt32, c UInt32') + PARTITION BY a VALUES (1, 2, 3), (1, 4, 5), (10, 11, 12), (10, 13, 14), (20, 21, 22), (20, 23, 24) +``` +As a result, the data is written into three files: `file_1.csv`, `file_10.csv`, and `file_20.csv`. + +Using wildcards in a bucket name creates files in different buckets: + +```sql +INSERT INTO TABLE FUNCTION + s3('http://bucket.amazonaws.com/my_bucket_{_partition_id}/file.csv', 'CSV', 'a UInt32, b UInt32, c UInt32') + PARTITION BY a VALUES (1, 2, 3), (1, 4, 5), (10, 11, 12), (10, 13, 14), (20, 21, 22), (20, 23, 24) +``` +As a result, the data is written into three files in different buckets: `my_bucket_1/file.csv`, `my_bucket_10/file.csv`, and `my_bucket_20/file.csv`. + **See Also** - [S3 engine](../../engines/table-engines/integrations/s3.md) From a62c428291dabfa7848ecc81829623da7763237d Mon Sep 17 00:00:00 2001 From: Olga Revyakina Date: Wed, 8 Sep 2021 05:52:17 +0300 Subject: [PATCH 051/102] Translated and minor fixes --- docs/en/sql-reference/table-functions/s3.md | 4 ++-- .../engines/table-engines/integrations/s3.md | 2 +- docs/ru/sql-reference/table-functions/s3.md | 24 +++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/docs/en/sql-reference/table-functions/s3.md b/docs/en/sql-reference/table-functions/s3.md index de3e442fa79..12d39a2b324 100644 --- a/docs/en/sql-reference/table-functions/s3.md +++ b/docs/en/sql-reference/table-functions/s3.md @@ -131,7 +131,7 @@ When inserting data into S3 table, you can split it into several files by specif **Examples** -Using wildcards in a file name creates separate files: +1. Using partition ID in a file name creates separate files: ```sql INSERT INTO TABLE FUNCTION @@ -140,7 +140,7 @@ INSERT INTO TABLE FUNCTION ``` As a result, the data is written into three files: `file_1.csv`, `file_10.csv`, and `file_20.csv`. -Using wildcards in a bucket name creates files in different buckets: +2. Using partition ID in a bucket name creates files in different buckets: ```sql INSERT INTO TABLE FUNCTION diff --git a/docs/ru/engines/table-engines/integrations/s3.md b/docs/ru/engines/table-engines/integrations/s3.md index 5895bd43d2f..c90b7293e1c 100644 --- a/docs/ru/engines/table-engines/integrations/s3.md +++ b/docs/ru/engines/table-engines/integrations/s3.md @@ -151,4 +151,4 @@ ENGINE = S3('https://storage.yandexcloud.net/my-test-bucket-768/big_prefix/file- **Смотрите также** -- [Табличная функция S3](../../../sql-reference/table-functions/s3.md) +- [Табличная функция s3](../../../sql-reference/table-functions/s3.md) diff --git a/docs/ru/sql-reference/table-functions/s3.md b/docs/ru/sql-reference/table-functions/s3.md index 597f145c096..3a671e2029f 100644 --- a/docs/ru/sql-reference/table-functions/s3.md +++ b/docs/ru/sql-reference/table-functions/s3.md @@ -133,6 +133,30 @@ INSERT INTO FUNCTION s3('https://storage.yandexcloud.net/my-test-bucket-768/test SELECT name, value FROM existing_table; ``` +## Партиционирование при записи данных {#partitioned-write} + +При добавлении данных в таблицу S3 вы можете сохранить таблицу в нескольких файлах, указав выражение `PARTITION BY`. В этом случае для каждого значения выражения партиционирования создается отдельный файл. Сохранение таблицы в нескольких отдельных файлах повышает эффективность операций чтения. + +**Примеры** + +1. При использовании ID партиции в названии файла создаются отдельные файлы: + +```sql +INSERT INTO TABLE FUNCTION + s3('http://bucket.amazonaws.com/my_bucket/file_{_partition_id}.csv', 'CSV', 'a UInt32, b UInt32, c UInt32') + PARTITION BY a VALUES (1, 2, 3), (1, 4, 5), (10, 11, 12), (10, 13, 14), (20, 21, 22), (20, 23, 24) +``` +В результате данные будут записаны в три файла: `file_1.csv`, `file_10.csv` и `file_20.csv`. + +2. При использовании ID партиции в названии бакета создаются файлы в разных бакетах: + +```sql +INSERT INTO TABLE FUNCTION + s3('http://bucket.amazonaws.com/my_bucket_{_partition_id}/file.csv', 'CSV', 'a UInt32, b UInt32, c UInt32') + PARTITION BY a VALUES (1, 2, 3), (1, 4, 5), (10, 11, 12), (10, 13, 14), (20, 21, 22), (20, 23, 24) +``` +В результате будут созданы три файла в разных бакетах: `my_bucket_1/file.csv`, `my_bucket_10/file.csv` и `my_bucket_20/file.csv`. + **Смотрите также** - [Движок таблиц S3](../../engines/table-engines/integrations/s3.md) From cbbc5b2ee546e5a3efced7cb9f2cbf350183c7a0 Mon Sep 17 00:00:00 2001 From: alesapin Date: Wed, 8 Sep 2021 12:58:17 +0300 Subject: [PATCH 052/102] Fix some broken images --- docker/test/integration/kerberos_kdc/Dockerfile | 6 ++---- docker/test/integration/mysql_golang_client/Dockerfile | 2 +- docker/test/sqlancer/Dockerfile | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docker/test/integration/kerberos_kdc/Dockerfile b/docker/test/integration/kerberos_kdc/Dockerfile index a33d1d24568..7805d8f1d1c 100644 --- a/docker/test/integration/kerberos_kdc/Dockerfile +++ b/docker/test/integration/kerberos_kdc/Dockerfile @@ -1,9 +1,7 @@ # docker build -t clickhouse/kerberos-kdc . +FROM centos:7 -FROM centos:6.6 -# old OS to make is faster and smaller - -RUN yum install -y krb5-server krb5-libs krb5-auth-dialog krb5-workstation +RUN yum install -y ca-certificates krb5-server krb5-libs krb5-auth-dialog krb5-workstation EXPOSE 88 749 diff --git a/docker/test/integration/mysql_golang_client/Dockerfile b/docker/test/integration/mysql_golang_client/Dockerfile index 6e448b4c66a..68b0aaab42c 100644 --- a/docker/test/integration/mysql_golang_client/Dockerfile +++ b/docker/test/integration/mysql_golang_client/Dockerfile @@ -1,7 +1,7 @@ # docker build -t clickhouse/mysql-golang-client . # MySQL golang client docker container -FROM golang:1.12.2 +FROM golang:1.13 RUN go get "github.com/go-sql-driver/mysql" diff --git a/docker/test/sqlancer/Dockerfile b/docker/test/sqlancer/Dockerfile index f603b812408..e73fd03fb6d 100644 --- a/docker/test/sqlancer/Dockerfile +++ b/docker/test/sqlancer/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:20.04 RUN sed -i 's|http://archive|http://ru.archive|g' /etc/apt/sources.list -RUN apt-get update --yes && env DEBIAN_FRONTEND=noninteractive apt-get install wget unzip git openjdk-14-jdk maven python3 --yes --no-install-recommends +RUN apt-get update --yes && env DEBIAN_FRONTEND=noninteractive apt-get install wget unzip git default-jdk maven python3 --yes --no-install-recommends RUN wget https://github.com/sqlancer/sqlancer/archive/master.zip -O /sqlancer.zip RUN mkdir /sqlancer && \ cd /sqlancer && \ From 3f11cbd31bd2f97d460b52c2c7e39f48bf600ccf Mon Sep 17 00:00:00 2001 From: alesapin Date: Wed, 8 Sep 2021 13:03:54 +0300 Subject: [PATCH 053/102] Rename more images --- tests/integration/README.md | 4 ++-- tests/integration/ci-runner.py | 12 ++++++------ tests/integration/helpers/cluster.py | 6 +++--- tests/integration/helpers/network.py | 8 ++++---- tests/integration/runner | 16 ++++++++-------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/tests/integration/README.md b/tests/integration/README.md index ed96eafdef8..1b1e7f3e052 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -66,7 +66,7 @@ For tests that use common docker compose files you may need to set up their path ### Running with runner script The only requirement is fresh configured docker and -docker pull yandex/clickhouse-integration-tests-runner +docker pull clickhouse/integration-tests-runner Notes: * If you want to run integration tests without `sudo` you have to add your user to docker group `sudo usermod -aG docker $USER`. [More information](https://docs.docker.com/install/linux/linux-postinstall/) about docker configuration. @@ -122,7 +122,7 @@ You can just open shell inside a container by overwritting the command: The main container used for integration tests lives in `docker/test/integration/Dockerfile`. Rebuild it with ``` cd docker/test/integration -docker build -t yandex/clickhouse-integration-test . +docker build -t clickhouse/integration-test . ``` The helper container used by the `runner` script is in `docker/test/integration/runner/Dockerfile`. diff --git a/tests/integration/ci-runner.py b/tests/integration/ci-runner.py index bf7549a83c4..f17eb84e5f3 100755 --- a/tests/integration/ci-runner.py +++ b/tests/integration/ci-runner.py @@ -207,11 +207,11 @@ class ClickhouseIntegrationTestsRunner: @staticmethod def get_images_names(): - return ["yandex/clickhouse-integration-tests-runner", "yandex/clickhouse-mysql-golang-client", - "yandex/clickhouse-mysql-java-client", "yandex/clickhouse-mysql-js-client", - "yandex/clickhouse-mysql-php-client", "yandex/clickhouse-postgresql-java-client", - "yandex/clickhouse-integration-test", "yandex/clickhouse-kerberos-kdc", - "yandex/clickhouse-integration-helper", ] + return ["clickhouse/integration-tests-runner", "clickhouse/mysql-golang-client", + "clickhouse/mysql-java-client", "clickhouse/mysql-js-client", + "clickhouse/mysql-php-client", "clickhouse/postgresql-java-client", + "clickhouse/integration-test", "clickhouse/kerberos-kdc", + "clickhouse/integration-helper", ] def _can_run_with(self, path, opt): @@ -343,7 +343,7 @@ class ClickhouseIntegrationTestsRunner: image_cmd = '' if self._can_run_with(os.path.join(repo_path, "tests/integration", "runner"), '--docker-image-version'): for img in self.get_images_names(): - if img == "yandex/clickhouse-integration-tests-runner": + if img == "clickhouse/integration-tests-runner": runner_version = self.get_single_image_version() logging.info("Can run with custom docker image version %s", runner_version) image_cmd += ' --docker-image-version={} '.format(runner_version) diff --git a/tests/integration/helpers/cluster.py b/tests/integration/helpers/cluster.py index 165e2175cf2..d1240999274 100644 --- a/tests/integration/helpers/cluster.py +++ b/tests/integration/helpers/cluster.py @@ -532,7 +532,7 @@ class ClickHouseCluster: binary_path = binary_path[:-len('-server')] env_variables['keeper_binary'] = binary_path - env_variables['image'] = "yandex/clickhouse-integration-test:" + self.docker_base_tag + env_variables['image'] = "clickhouse/integration-test:" + self.docker_base_tag env_variables['user'] = str(os.getuid()) env_variables['keeper_fs'] = 'bind' for i in range(1, 4): @@ -757,7 +757,7 @@ class ClickHouseCluster: with_odbc_drivers=False, with_postgres=False, with_postgres_cluster=False, with_hdfs=False, with_kerberized_hdfs=False, with_mongo=False, with_mongo_secure=False, with_nginx=False, with_redis=False, with_minio=False, with_cassandra=False, with_jdbc_bridge=False, - hostname=None, env_variables=None, image="yandex/clickhouse-integration-test", tag=None, + hostname=None, env_variables=None, image="clickhouse/integration-test", tag=None, stay_alive=False, ipv4_address=None, ipv6_address=None, with_installed_binary=False, tmpfs=None, zookeeper_docker_compose_path=None, minio_certs_dir=None, use_keeper=True, main_config_name="config.xml", users_config_name="users.xml", copy_common_configs=True): @@ -1801,7 +1801,7 @@ class ClickHouseInstance: clickhouse_start_command=CLICKHOUSE_START_COMMAND, main_config_name="config.xml", users_config_name="users.xml", copy_common_configs=True, hostname=None, env_variables=None, - image="yandex/clickhouse-integration-test", tag="latest", + image="clickhouse/integration-test", tag="latest", stay_alive=False, ipv4_address=None, ipv6_address=None, with_installed_binary=False, tmpfs=None): self.name = name diff --git a/tests/integration/helpers/network.py b/tests/integration/helpers/network.py index 040d49b992f..af0942c9b94 100644 --- a/tests/integration/helpers/network.py +++ b/tests/integration/helpers/network.py @@ -195,21 +195,21 @@ class _NetworkManager: print("Error removing network blocade container, will try again", str(ex)) time.sleep(i) - image = subprocess.check_output("docker images -q yandex/clickhouse-integration-helper 2>/dev/null", shell=True) + image = subprocess.check_output("docker images -q clickhouse/integration-helper 2>/dev/null", shell=True) if not image.strip(): print("No network image helper, will try download") # for some reason docker api may hang if image doesn't exist, so we download it # before running for i in range(5): try: - subprocess.check_call("docker pull yandex/clickhouse-integration-helper", shell=True) # STYLE_CHECK_ALLOW_SUBPROCESS_CHECK_CALL + subprocess.check_call("docker pull clickhouse/integration-helper", shell=True) # STYLE_CHECK_ALLOW_SUBPROCESS_CHECK_CALL break except: time.sleep(i) else: - raise Exception("Cannot pull yandex/clickhouse-integration-helper image") + raise Exception("Cannot pull clickhouse/integration-helper image") - self._container = self._docker_client.containers.run('yandex/clickhouse-integration-helper', + self._container = self._docker_client.containers.run('clickhouse/integration-helper', auto_remove=True, command=('sleep %s' % self.container_exit_timeout), detach=True, network_mode='host') diff --git a/tests/integration/runner b/tests/integration/runner index 2143d7ebf29..3ff982a9913 100755 --- a/tests/integration/runner +++ b/tests/integration/runner @@ -19,7 +19,7 @@ CONFIG_DIR_IN_REPO = "programs/server" INTERGATION_DIR_IN_REPO = "tests/integration" SRC_DIR_IN_REPO = "src" -DIND_INTEGRATION_TESTS_IMAGE_NAME = "yandex/clickhouse-integration-tests-runner" +DIND_INTEGRATION_TESTS_IMAGE_NAME = "clickhouse/integration-tests-runner" def check_args_and_update_paths(args): if args.clickhouse_root: @@ -225,19 +225,19 @@ if __name__ == "__main__": if args.docker_compose_images_tags is not None: for img_tag in args.docker_compose_images_tags: [image, tag] = img_tag.split(":") - if image == "yandex/clickhouse-mysql-golang-client": + if image == "clickhouse/mysql-golang-client": env_tags += "-e {}={} ".format("DOCKER_MYSQL_GOLANG_CLIENT_TAG", tag) - elif image == "yandex/clickhouse-mysql-java-client": + elif image == "clickhouse/mysql-java-client": env_tags += "-e {}={} ".format("DOCKER_MYSQL_JAVA_CLIENT_TAG", tag) - elif image == "yandex/clickhouse-mysql-js-client": + elif image == "clickhouse/mysql-js-client": env_tags += "-e {}={} ".format("DOCKER_MYSQL_JS_CLIENT_TAG", tag) - elif image == "yandex/clickhouse-mysql-php-client": + elif image == "clickhouse/mysql-php-client": env_tags += "-e {}={} ".format("DOCKER_MYSQL_PHP_CLIENT_TAG", tag) - elif image == "yandex/clickhouse-postgresql-java-client": + elif image == "clickhouse/postgresql-java-client": env_tags += "-e {}={} ".format("DOCKER_POSTGRESQL_JAVA_CLIENT_TAG", tag) - elif image == "yandex/clickhouse-integration-test": + elif image == "clickhouse/integration-test": env_tags += "-e {}={} ".format("DOCKER_BASE_TAG", tag) - elif image == "yandex/clickhouse-kerberos-kdc": + elif image == "clickhouse/kerberos-kdc": env_tags += "-e {}={}".format("DOCKER_KERBEROS_KDC_TAG", tag) else: logging.info("Unknown image %s" % (image)) From b8cfad4ba2d0e1fb4518a01a537e0dd6660ce9cb Mon Sep 17 00:00:00 2001 From: alesapin Date: Wed, 8 Sep 2021 13:06:03 +0300 Subject: [PATCH 054/102] Renames for testflows --- .../aes_encryption/aes_encryption_env/clickhouse-service.yml | 2 +- .../datetime64_extended_range_env/clickhouse-service.yml | 2 +- tests/testflows/example/example_env/clickhouse-service.yml | 2 +- .../extended-precision-data-type_env/clickhouse-service.yml | 2 +- tests/testflows/kerberos/kerberos_env/clickhouse-service.yml | 2 +- .../ldap_authentication_env/clickhouse-service.yml | 2 +- .../ldap_external_user_directory_env/clickhouse-service.yml | 2 +- .../role_mapping/ldap_role_mapping_env/clickhouse-service.yml | 2 +- tests/testflows/map_type/map_type_env/clickhouse-service.yml | 2 +- tests/testflows/rbac/rbac_env/clickhouse-service.yml | 2 +- tests/testflows/runner | 2 +- .../window_functions_env/clickhouse-service.yml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/testflows/aes_encryption/aes_encryption_env/clickhouse-service.yml b/tests/testflows/aes_encryption/aes_encryption_env/clickhouse-service.yml index 0789decf022..0c9352dbc0b 100644 --- a/tests/testflows/aes_encryption/aes_encryption_env/clickhouse-service.yml +++ b/tests/testflows/aes_encryption/aes_encryption_env/clickhouse-service.yml @@ -2,7 +2,7 @@ version: '2.3' services: clickhouse: - image: yandex/clickhouse-integration-test + image: clickhouse/integration-test expose: - "9000" - "9009" diff --git a/tests/testflows/datetime64_extended_range/datetime64_extended_range_env/clickhouse-service.yml b/tests/testflows/datetime64_extended_range/datetime64_extended_range_env/clickhouse-service.yml index 0789decf022..0c9352dbc0b 100644 --- a/tests/testflows/datetime64_extended_range/datetime64_extended_range_env/clickhouse-service.yml +++ b/tests/testflows/datetime64_extended_range/datetime64_extended_range_env/clickhouse-service.yml @@ -2,7 +2,7 @@ version: '2.3' services: clickhouse: - image: yandex/clickhouse-integration-test + image: clickhouse/integration-test expose: - "9000" - "9009" diff --git a/tests/testflows/example/example_env/clickhouse-service.yml b/tests/testflows/example/example_env/clickhouse-service.yml index 0789decf022..0c9352dbc0b 100644 --- a/tests/testflows/example/example_env/clickhouse-service.yml +++ b/tests/testflows/example/example_env/clickhouse-service.yml @@ -2,7 +2,7 @@ version: '2.3' services: clickhouse: - image: yandex/clickhouse-integration-test + image: clickhouse/integration-test expose: - "9000" - "9009" diff --git a/tests/testflows/extended_precision_data_types/extended-precision-data-type_env/clickhouse-service.yml b/tests/testflows/extended_precision_data_types/extended-precision-data-type_env/clickhouse-service.yml index fdd4a8057a9..afb31f77c94 100644 --- a/tests/testflows/extended_precision_data_types/extended-precision-data-type_env/clickhouse-service.yml +++ b/tests/testflows/extended_precision_data_types/extended-precision-data-type_env/clickhouse-service.yml @@ -2,7 +2,7 @@ version: '2.3' services: clickhouse: - image: yandex/clickhouse-integration-test + image: clickhouse/integration-test expose: - "9000" - "9009" diff --git a/tests/testflows/kerberos/kerberos_env/clickhouse-service.yml b/tests/testflows/kerberos/kerberos_env/clickhouse-service.yml index 14736a264b8..9f30ca3039a 100644 --- a/tests/testflows/kerberos/kerberos_env/clickhouse-service.yml +++ b/tests/testflows/kerberos/kerberos_env/clickhouse-service.yml @@ -2,7 +2,7 @@ version: '2.3' services: clickhouse: - image: yandex/clickhouse-integration-test:21454 + image: clickhouse/integration-test:21454 expose: - "9000" - "9009" diff --git a/tests/testflows/ldap/authentication/ldap_authentication_env/clickhouse-service.yml b/tests/testflows/ldap/authentication/ldap_authentication_env/clickhouse-service.yml index 0789decf022..0c9352dbc0b 100644 --- a/tests/testflows/ldap/authentication/ldap_authentication_env/clickhouse-service.yml +++ b/tests/testflows/ldap/authentication/ldap_authentication_env/clickhouse-service.yml @@ -2,7 +2,7 @@ version: '2.3' services: clickhouse: - image: yandex/clickhouse-integration-test + image: clickhouse/integration-test expose: - "9000" - "9009" diff --git a/tests/testflows/ldap/external_user_directory/ldap_external_user_directory_env/clickhouse-service.yml b/tests/testflows/ldap/external_user_directory/ldap_external_user_directory_env/clickhouse-service.yml index 0789decf022..0c9352dbc0b 100644 --- a/tests/testflows/ldap/external_user_directory/ldap_external_user_directory_env/clickhouse-service.yml +++ b/tests/testflows/ldap/external_user_directory/ldap_external_user_directory_env/clickhouse-service.yml @@ -2,7 +2,7 @@ version: '2.3' services: clickhouse: - image: yandex/clickhouse-integration-test + image: clickhouse/integration-test expose: - "9000" - "9009" diff --git a/tests/testflows/ldap/role_mapping/ldap_role_mapping_env/clickhouse-service.yml b/tests/testflows/ldap/role_mapping/ldap_role_mapping_env/clickhouse-service.yml index 0789decf022..0c9352dbc0b 100644 --- a/tests/testflows/ldap/role_mapping/ldap_role_mapping_env/clickhouse-service.yml +++ b/tests/testflows/ldap/role_mapping/ldap_role_mapping_env/clickhouse-service.yml @@ -2,7 +2,7 @@ version: '2.3' services: clickhouse: - image: yandex/clickhouse-integration-test + image: clickhouse/integration-test expose: - "9000" - "9009" diff --git a/tests/testflows/map_type/map_type_env/clickhouse-service.yml b/tests/testflows/map_type/map_type_env/clickhouse-service.yml index fdd4a8057a9..afb31f77c94 100755 --- a/tests/testflows/map_type/map_type_env/clickhouse-service.yml +++ b/tests/testflows/map_type/map_type_env/clickhouse-service.yml @@ -2,7 +2,7 @@ version: '2.3' services: clickhouse: - image: yandex/clickhouse-integration-test + image: clickhouse/integration-test expose: - "9000" - "9009" diff --git a/tests/testflows/rbac/rbac_env/clickhouse-service.yml b/tests/testflows/rbac/rbac_env/clickhouse-service.yml index 2d79443dcbb..ac52e3b83eb 100755 --- a/tests/testflows/rbac/rbac_env/clickhouse-service.yml +++ b/tests/testflows/rbac/rbac_env/clickhouse-service.yml @@ -2,7 +2,7 @@ version: '2.3' services: clickhouse: - image: yandex/clickhouse-integration-test + image: clickhouse/integration-test expose: - "9000" - "9009" diff --git a/tests/testflows/runner b/tests/testflows/runner index 772a4d01a84..0208512762c 100755 --- a/tests/testflows/runner +++ b/tests/testflows/runner @@ -14,7 +14,7 @@ DEFAULT_CLICKHOUSE_ROOT = os.path.abspath(os.path.join(CUR_FILE_DIR, "../../")) CURRENT_WORK_DIR = os.getcwd() CONTAINER_NAME = "clickhouse_testflows_tests" -DIND_TESTFLOWS_TESTS_IMAGE_NAME = "yandex/clickhouse-testflows-runner" +DIND_TESTFLOWS_TESTS_IMAGE_NAME = "clickhouse/testflows-runner" def check_args_and_update_paths(args): if not os.path.isabs(args.binary): diff --git a/tests/testflows/window_functions/window_functions_env/clickhouse-service.yml b/tests/testflows/window_functions/window_functions_env/clickhouse-service.yml index fdd4a8057a9..afb31f77c94 100755 --- a/tests/testflows/window_functions/window_functions_env/clickhouse-service.yml +++ b/tests/testflows/window_functions/window_functions_env/clickhouse-service.yml @@ -2,7 +2,7 @@ version: '2.3' services: clickhouse: - image: yandex/clickhouse-integration-test + image: clickhouse/integration-test expose: - "9000" - "9009" From b073d5a4b4280c1f6d94596205e288f13722ed28 Mon Sep 17 00:00:00 2001 From: Dmitrii Kovalkov Date: Wed, 8 Sep 2021 13:11:38 +0300 Subject: [PATCH 055/102] Default argument for Pool.get() --- base/mysqlxx/Pool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/mysqlxx/Pool.h b/base/mysqlxx/Pool.h index 08d8b85b4ac..f542c3d3b76 100644 --- a/base/mysqlxx/Pool.h +++ b/base/mysqlxx/Pool.h @@ -189,7 +189,7 @@ public: ~Pool(); /// Allocates connection. - Entry get(uint64_t wait_timeout); + Entry get(uint64_t wait_timeout = UINT64_MAX); /// Allocates connection. /// If database is not accessible, returns empty Entry object. From 9816014f6c08d2e6132f71ae5b06cdf2a2586886 Mon Sep 17 00:00:00 2001 From: Anton Popov Date: Wed, 8 Sep 2021 21:42:34 +0300 Subject: [PATCH 056/102] fix nested and scalar columns with dot, which is missed in part --- src/Storages/MergeTree/IMergeTreeReader.cpp | 5 +++-- .../02017_columns_with_dot_2.reference | 2 ++ .../0_stateless/02017_columns_with_dot_2.sql | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tests/queries/0_stateless/02017_columns_with_dot_2.reference create mode 100644 tests/queries/0_stateless/02017_columns_with_dot_2.sql diff --git a/src/Storages/MergeTree/IMergeTreeReader.cpp b/src/Storages/MergeTree/IMergeTreeReader.cpp index d659259e1a9..41de5784d55 100644 --- a/src/Storages/MergeTree/IMergeTreeReader.cpp +++ b/src/Storages/MergeTree/IMergeTreeReader.cpp @@ -135,10 +135,11 @@ void IMergeTreeReader::fillMissingColumns(Columns & res_columns, bool & should_e String offsets_name = Nested::extractTableName(name); auto offset_it = offset_columns.find(offsets_name); - if (offset_it != offset_columns.end()) + const auto * array_type = typeid_cast(type.get()); + if (offset_it != offset_columns.end() && array_type) { ColumnPtr offsets_column = offset_it->second; - DataTypePtr nested_type = typeid_cast(*type).getNestedType(); + DataTypePtr nested_type = array_type->getNestedType(); size_t nested_rows = typeid_cast(*offsets_column).getData().back(); ColumnPtr nested_column = diff --git a/tests/queries/0_stateless/02017_columns_with_dot_2.reference b/tests/queries/0_stateless/02017_columns_with_dot_2.reference new file mode 100644 index 00000000000..8d43601632c --- /dev/null +++ b/tests/queries/0_stateless/02017_columns_with_dot_2.reference @@ -0,0 +1,2 @@ +123 asd [1,2] +123 asd [1,2] 0 diff --git a/tests/queries/0_stateless/02017_columns_with_dot_2.sql b/tests/queries/0_stateless/02017_columns_with_dot_2.sql new file mode 100644 index 00000000000..eefe52b74f3 --- /dev/null +++ b/tests/queries/0_stateless/02017_columns_with_dot_2.sql @@ -0,0 +1,18 @@ +DROP TABLE IF EXISTS test_nested; + +CREATE TABLE test_nested +( + `id` String, + `with_dot.str` String, + `with_dot.array` Array(Int32) +) +ENGINE = MergeTree() +ORDER BY id; + +INSERT INTO test_nested VALUES('123', 'asd', [1,2]); +SELECT * FROM test_nested; + +ALTER TABLE test_nested ADD COLUMN `with_dot.bool` UInt8; +SELECT * FROM test_nested; + +DROP TABLE test_nested; From 4d49e6da58f93e1499c7984e5c86bd36d664d3af Mon Sep 17 00:00:00 2001 From: alesapin Date: Wed, 8 Sep 2021 22:23:06 +0300 Subject: [PATCH 057/102] Fix build image name --- docker/images.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/images.json b/docker/images.json index 795ca47be00..96424bb9432 100644 --- a/docker/images.json +++ b/docker/images.json @@ -108,7 +108,7 @@ "dependent": [] }, "docker/test/integration/mysql_java_client": { - "name": "clickhouse/clickhouse-mysql-java-client", + "name": "clickhouse/mysql-java-client", "dependent": [] }, "docker/test/integration/mysql_js_client": { From 63cc735b8fc9b8fbe1123f158e081a3d24528d54 Mon Sep 17 00:00:00 2001 From: alesapin Date: Thu, 9 Sep 2021 10:41:55 +0300 Subject: [PATCH 058/102] Revert jdbc-bridge image --- .../integration/runner/compose/docker_compose_jdbc_bridge.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/test/integration/runner/compose/docker_compose_jdbc_bridge.yml b/docker/test/integration/runner/compose/docker_compose_jdbc_bridge.yml index b3686adc21c..eb70fea607b 100644 --- a/docker/test/integration/runner/compose/docker_compose_jdbc_bridge.yml +++ b/docker/test/integration/runner/compose/docker_compose_jdbc_bridge.yml @@ -1,7 +1,7 @@ version: '2.3' services: bridge1: - image: clickhouse/jdbc-bridge + image: yandex/clickhouse-jdbc-bridge command: | /bin/bash -c 'cat << EOF > config/datasources/self.json { @@ -24,4 +24,4 @@ services: volumes: - type: ${JDBC_BRIDGE_FS:-tmpfs} source: ${JDBC_BRIDGE_LOGS:-} - target: /app/logs \ No newline at end of file + target: /app/logs From 1297e95e4a08bd00d0ed5e88dc46ba297fbce8b1 Mon Sep 17 00:00:00 2001 From: alesapin Date: Thu, 9 Sep 2021 10:45:04 +0300 Subject: [PATCH 059/102] Revert "Revert jdbc-bridge image" This reverts commit 63cc735b8fc9b8fbe1123f158e081a3d24528d54. --- .../integration/runner/compose/docker_compose_jdbc_bridge.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/test/integration/runner/compose/docker_compose_jdbc_bridge.yml b/docker/test/integration/runner/compose/docker_compose_jdbc_bridge.yml index eb70fea607b..b3686adc21c 100644 --- a/docker/test/integration/runner/compose/docker_compose_jdbc_bridge.yml +++ b/docker/test/integration/runner/compose/docker_compose_jdbc_bridge.yml @@ -1,7 +1,7 @@ version: '2.3' services: bridge1: - image: yandex/clickhouse-jdbc-bridge + image: clickhouse/jdbc-bridge command: | /bin/bash -c 'cat << EOF > config/datasources/self.json { @@ -24,4 +24,4 @@ services: volumes: - type: ${JDBC_BRIDGE_FS:-tmpfs} source: ${JDBC_BRIDGE_LOGS:-} - target: /app/logs + target: /app/logs \ No newline at end of file From 2ccdb6c22d428b3b774a1b30725e48c2be061480 Mon Sep 17 00:00:00 2001 From: Anton Popov Date: Thu, 9 Sep 2021 12:40:26 +0300 Subject: [PATCH 060/102] fix clang-tidy --- src/Storages/MergeTree/IMergeTreeReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storages/MergeTree/IMergeTreeReader.cpp b/src/Storages/MergeTree/IMergeTreeReader.cpp index 41de5784d55..d0d845ed6a3 100644 --- a/src/Storages/MergeTree/IMergeTreeReader.cpp +++ b/src/Storages/MergeTree/IMergeTreeReader.cpp @@ -138,8 +138,8 @@ void IMergeTreeReader::fillMissingColumns(Columns & res_columns, bool & should_e const auto * array_type = typeid_cast(type.get()); if (offset_it != offset_columns.end() && array_type) { + const auto & nested_type = array_type->getNestedType(); ColumnPtr offsets_column = offset_it->second; - DataTypePtr nested_type = array_type->getNestedType(); size_t nested_rows = typeid_cast(*offsets_column).getData().back(); ColumnPtr nested_column = From 0e0c136d4385813fafc40264ceeb9ac74b6e57b0 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Thu, 9 Sep 2021 15:31:29 +0300 Subject: [PATCH 061/102] Fix error code of clickhouse-test if server is dead. --- tests/clickhouse-test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/clickhouse-test b/tests/clickhouse-test index f3a41ba6a25..c3136c4fd52 100755 --- a/tests/clickhouse-test +++ b/tests/clickhouse-test @@ -1162,6 +1162,9 @@ def main(args): total_tests_run += do_run_tests( jobs, suite, suite_dir, suite_tmp_dir, all_tests, parallel_tests, sequential_tests, args.parallel) + if server_died.is_set(): + exit_code.value = 1 + if args.hung_check: # Some queries may execute in background for some time after test was finished. This is normal. From 47e1ecc05a9aa544b31e0853ebee2ff666e66e1c Mon Sep 17 00:00:00 2001 From: gyuton <40863448+gyuton@users.noreply.github.com> Date: Thu, 9 Sep 2021 18:40:02 +0300 Subject: [PATCH 062/102] Update docs/en/sql-reference/functions/tuple-map-functions.md Co-authored-by: Nikolay Degterinsky <43110995+evillique@users.noreply.github.com> --- docs/en/sql-reference/functions/tuple-map-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/functions/tuple-map-functions.md b/docs/en/sql-reference/functions/tuple-map-functions.md index 8a2be922ec7..6e91419b04f 100644 --- a/docs/en/sql-reference/functions/tuple-map-functions.md +++ b/docs/en/sql-reference/functions/tuple-map-functions.md @@ -86,7 +86,7 @@ Arguments are [maps](../../sql-reference/data-types/map.md) or [tuples](../../sq **Example** -Query with a Tuple: +Query with a tuple: ```sql SELECT mapAdd(([toUInt8(1), 2], [1, 1]), ([toUInt8(1), 2], [1, 1])) as res, toTypeName(res) as type; From e244239238e192b3a7704d8a79923993f8e3333c Mon Sep 17 00:00:00 2001 From: Maksim Kita Date: Thu, 9 Sep 2021 19:35:06 +0300 Subject: [PATCH 063/102] Lower compiled_expression_cache_size to 128MB --- programs/server/Server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/server/Server.cpp b/programs/server/Server.cpp index 4a6d1e206e7..0c834174519 100644 --- a/programs/server/Server.cpp +++ b/programs/server/Server.cpp @@ -962,7 +962,7 @@ if (ThreadFuzzer::instance().isEffective()) global_context->setMMappedFileCache(mmap_cache_size); #if USE_EMBEDDED_COMPILER - constexpr size_t compiled_expression_cache_size_default = 1024 * 1024 * 1024; + constexpr size_t compiled_expression_cache_size_default = 1024 * 1024 * 128; size_t compiled_expression_cache_size = config().getUInt64("compiled_expression_cache_size", compiled_expression_cache_size_default); CompiledExpressionCacheFactory::instance().init(compiled_expression_cache_size); #endif From e419614d322392d47e6f6b1301efb75f6ee647bb Mon Sep 17 00:00:00 2001 From: tavplubix Date: Thu, 9 Sep 2021 21:31:15 +0300 Subject: [PATCH 064/102] remove incorrect code --- src/Storages/StorageDictionary.cpp | 4 ---- src/Storages/StorageDictionary.h | 1 - 2 files changed, 5 deletions(-) diff --git a/src/Storages/StorageDictionary.cpp b/src/Storages/StorageDictionary.cpp index c8bbb703999..c8bc215dd6c 100644 --- a/src/Storages/StorageDictionary.cpp +++ b/src/Storages/StorageDictionary.cpp @@ -193,10 +193,6 @@ void StorageDictionary::startup() void StorageDictionary::removeDictionaryConfigurationFromRepository() { - if (remove_repository_callback_executed) - return; - - remove_repository_callback_executed = true; remove_repository_callback.reset(); } diff --git a/src/Storages/StorageDictionary.h b/src/Storages/StorageDictionary.h index d074dec2c34..c7693bdae9a 100644 --- a/src/Storages/StorageDictionary.h +++ b/src/Storages/StorageDictionary.h @@ -73,7 +73,6 @@ private: Poco::Timestamp update_time; LoadablesConfigurationPtr configuration; - std::atomic remove_repository_callback_executed = false; scope_guard remove_repository_callback; void removeDictionaryConfigurationFromRepository(); From c76d40443214eb2809603014cabad74f543a79bb Mon Sep 17 00:00:00 2001 From: Maksim Kita Date: Thu, 9 Sep 2021 21:36:15 +0300 Subject: [PATCH 065/102] Fix compiled_expression_cache_size setting default value in configuration files --- programs/server/config.xml | 2 +- programs/server/config.yaml.example | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/server/config.xml b/programs/server/config.xml index 32207e2b6b3..b8ef17458be 100644 --- a/programs/server/config.xml +++ b/programs/server/config.xml @@ -331,7 +331,7 @@ 1000 - 1073741824 + 134217728 /var/lib/clickhouse/ diff --git a/programs/server/config.yaml.example b/programs/server/config.yaml.example index 5b2da1d3128..ae4eac49a64 100644 --- a/programs/server/config.yaml.example +++ b/programs/server/config.yaml.example @@ -280,7 +280,7 @@ mark_cache_size: 5368709120 mmap_cache_size: 1000 # Cache size for compiled expressions. -compiled_expression_cache_size: 1073741824 +compiled_expression_cache_size: 134217728 # Path to data directory, with trailing slash. path: /var/lib/clickhouse/ From e160f649171da1337eb3411a7981581ff0e21369 Mon Sep 17 00:00:00 2001 From: olgarev <56617294+olgarev@users.noreply.github.com> Date: Thu, 9 Sep 2021 22:23:02 +0300 Subject: [PATCH 066/102] Apply suggestions from code review Co-authored-by: Anna <42538400+adevyatova@users.noreply.github.com> --- docs/en/sql-reference/table-functions/s3.md | 2 +- docs/ru/sql-reference/table-functions/s3.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/sql-reference/table-functions/s3.md b/docs/en/sql-reference/table-functions/s3.md index 12d39a2b324..215c9409416 100644 --- a/docs/en/sql-reference/table-functions/s3.md +++ b/docs/en/sql-reference/table-functions/s3.md @@ -127,7 +127,7 @@ SELECT name, value FROM existing_table; ## Partitioned Write {#partitioned-write} -When inserting data into S3 table, you can split it into several files by specifying `PARTITION BY` expression. In this case a separate file is created for each partition value. Splitting the data helps to improve reading operations efficiency. +If you will specify `PARTITION BY` expression when inserting data into `S3` table, a separate file is created for each partition value. Splitting the data helps to improve reading operations efficiency. **Examples** diff --git a/docs/ru/sql-reference/table-functions/s3.md b/docs/ru/sql-reference/table-functions/s3.md index 3a671e2029f..316bab9bf69 100644 --- a/docs/ru/sql-reference/table-functions/s3.md +++ b/docs/ru/sql-reference/table-functions/s3.md @@ -135,7 +135,7 @@ SELECT name, value FROM existing_table; ## Партиционирование при записи данных {#partitioned-write} -При добавлении данных в таблицу S3 вы можете сохранить таблицу в нескольких файлах, указав выражение `PARTITION BY`. В этом случае для каждого значения выражения партиционирования создается отдельный файл. Сохранение таблицы в нескольких отдельных файлах повышает эффективность операций чтения. +Если при добавлении данных в таблицу S3 вы укажете выражение `PARTITION BY`, то для каждого значения выражения партиционирования будет создан отдельный файл. Это повышает эффективность операций чтения. **Примеры** From cd687614fa5e6a5efc6fef636da3094e649f7fc3 Mon Sep 17 00:00:00 2001 From: olgarev <56617294+olgarev@users.noreply.github.com> Date: Thu, 9 Sep 2021 22:25:04 +0300 Subject: [PATCH 067/102] Apply suggestions from code review --- docs/en/sql-reference/table-functions/s3.md | 2 +- docs/ru/sql-reference/table-functions/s3.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/sql-reference/table-functions/s3.md b/docs/en/sql-reference/table-functions/s3.md index 215c9409416..1d38d4586e3 100644 --- a/docs/en/sql-reference/table-functions/s3.md +++ b/docs/en/sql-reference/table-functions/s3.md @@ -127,7 +127,7 @@ SELECT name, value FROM existing_table; ## Partitioned Write {#partitioned-write} -If you will specify `PARTITION BY` expression when inserting data into `S3` table, a separate file is created for each partition value. Splitting the data helps to improve reading operations efficiency. +If you specify `PARTITION BY` expression when inserting data into `S3` table, a separate file is created for each partition value. Splitting the data helps to improve reading operations efficiency. **Examples** diff --git a/docs/ru/sql-reference/table-functions/s3.md b/docs/ru/sql-reference/table-functions/s3.md index 316bab9bf69..9eec0ab05d2 100644 --- a/docs/ru/sql-reference/table-functions/s3.md +++ b/docs/ru/sql-reference/table-functions/s3.md @@ -135,7 +135,7 @@ SELECT name, value FROM existing_table; ## Партиционирование при записи данных {#partitioned-write} -Если при добавлении данных в таблицу S3 вы укажете выражение `PARTITION BY`, то для каждого значения выражения партиционирования будет создан отдельный файл. Это повышает эффективность операций чтения. +Если при добавлении данных в таблицу S3 указать выражение `PARTITION BY`, то для каждого значения выражения партиционирования создается отдельный файл. Это повышает эффективность операций чтения. **Примеры** From 89744e908c5c6ef3baf390e5b4c7951d3d7dc3b7 Mon Sep 17 00:00:00 2001 From: olgarev <56617294+olgarev@users.noreply.github.com> Date: Thu, 9 Sep 2021 22:26:51 +0300 Subject: [PATCH 068/102] Update docs/en/sql-reference/table-functions/s3.md --- docs/en/sql-reference/table-functions/s3.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/table-functions/s3.md b/docs/en/sql-reference/table-functions/s3.md index 1d38d4586e3..f864ca7eed2 100644 --- a/docs/en/sql-reference/table-functions/s3.md +++ b/docs/en/sql-reference/table-functions/s3.md @@ -127,7 +127,7 @@ SELECT name, value FROM existing_table; ## Partitioned Write {#partitioned-write} -If you specify `PARTITION BY` expression when inserting data into `S3` table, a separate file is created for each partition value. Splitting the data helps to improve reading operations efficiency. +If you specify `PARTITION BY` expression when inserting data into `S3` table, a separate file is created for each partition value. Splitting the data into separate files helps to improve reading operations efficiency. **Examples** From b6dea3e8e3b5e174eccf8bd1c78692549868f19d Mon Sep 17 00:00:00 2001 From: olgarev <56617294+olgarev@users.noreply.github.com> Date: Thu, 9 Sep 2021 22:33:59 +0300 Subject: [PATCH 069/102] Apply suggestions from code review --- docs/en/sql-reference/table-functions/s3.md | 8 ++++---- docs/ru/sql-reference/table-functions/s3.md | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/en/sql-reference/table-functions/s3.md b/docs/en/sql-reference/table-functions/s3.md index f864ca7eed2..a0176f0151c 100644 --- a/docs/en/sql-reference/table-functions/s3.md +++ b/docs/en/sql-reference/table-functions/s3.md @@ -135,17 +135,17 @@ If you specify `PARTITION BY` expression when inserting data into `S3` table, a ```sql INSERT INTO TABLE FUNCTION - s3('http://bucket.amazonaws.com/my_bucket/file_{_partition_id}.csv', 'CSV', 'a UInt32, b UInt32, c UInt32') - PARTITION BY a VALUES (1, 2, 3), (1, 4, 5), (10, 11, 12), (10, 13, 14), (20, 21, 22), (20, 23, 24) + s3('http://bucket.amazonaws.com/my_bucket/file_{_partition_id}.csv', 'CSV', 'a String, b UInt32, c UInt32') + PARTITION BY a VALUES ('x', 2, 3), ('x', 4, 5), ('y', 11, 12), ('y', 13, 14), ('z', 21, 22), ('z', 23, 24); ``` -As a result, the data is written into three files: `file_1.csv`, `file_10.csv`, and `file_20.csv`. +As a result, the data is written into three files: `file_x.csv`, `file_y.csv`, and `file_z.csv`. 2. Using partition ID in a bucket name creates files in different buckets: ```sql INSERT INTO TABLE FUNCTION s3('http://bucket.amazonaws.com/my_bucket_{_partition_id}/file.csv', 'CSV', 'a UInt32, b UInt32, c UInt32') - PARTITION BY a VALUES (1, 2, 3), (1, 4, 5), (10, 11, 12), (10, 13, 14), (20, 21, 22), (20, 23, 24) + PARTITION BY a VALUES (1, 2, 3), (1, 4, 5), (10, 11, 12), (10, 13, 14), (20, 21, 22), (20, 23, 24); ``` As a result, the data is written into three files in different buckets: `my_bucket_1/file.csv`, `my_bucket_10/file.csv`, and `my_bucket_20/file.csv`. diff --git a/docs/ru/sql-reference/table-functions/s3.md b/docs/ru/sql-reference/table-functions/s3.md index 9eec0ab05d2..a4e6151d711 100644 --- a/docs/ru/sql-reference/table-functions/s3.md +++ b/docs/ru/sql-reference/table-functions/s3.md @@ -144,16 +144,16 @@ SELECT name, value FROM existing_table; ```sql INSERT INTO TABLE FUNCTION s3('http://bucket.amazonaws.com/my_bucket/file_{_partition_id}.csv', 'CSV', 'a UInt32, b UInt32, c UInt32') - PARTITION BY a VALUES (1, 2, 3), (1, 4, 5), (10, 11, 12), (10, 13, 14), (20, 21, 22), (20, 23, 24) + PARTITION BY a VALUES ('x', 2, 3), ('x', 4, 5), ('y', 11, 12), ('y', 13, 14), ('z', 21, 22), ('z', 23, 24); ``` -В результате данные будут записаны в три файла: `file_1.csv`, `file_10.csv` и `file_20.csv`. +В результате данные будут записаны в три файла: `file_x.csv`, `file_y.csv` и `file_z.csv`. 2. При использовании ID партиции в названии бакета создаются файлы в разных бакетах: ```sql INSERT INTO TABLE FUNCTION s3('http://bucket.amazonaws.com/my_bucket_{_partition_id}/file.csv', 'CSV', 'a UInt32, b UInt32, c UInt32') - PARTITION BY a VALUES (1, 2, 3), (1, 4, 5), (10, 11, 12), (10, 13, 14), (20, 21, 22), (20, 23, 24) + PARTITION BY a VALUES (1, 2, 3), (1, 4, 5), (10, 11, 12), (10, 13, 14), (20, 21, 22), (20, 23, 24); ``` В результате будут созданы три файла в разных бакетах: `my_bucket_1/file.csv`, `my_bucket_10/file.csv` и `my_bucket_20/file.csv`. From c89bb46a20796b6ac20767cdff2c4d64fa5f577c Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 9 Sep 2021 22:41:26 +0300 Subject: [PATCH 070/102] Fix shared build with ENABLE_EMBEDDED_COMPILER --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 40b8526e103..b4d4f3a5de3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -261,7 +261,7 @@ dbms_target_include_directories (PUBLIC "${ClickHouse_SOURCE_DIR}/src" "${ClickH target_include_directories (clickhouse_common_io PUBLIC "${ClickHouse_SOURCE_DIR}/src" "${ClickHouse_BINARY_DIR}/src") if (USE_EMBEDDED_COMPILER) - dbms_target_link_libraries (PRIVATE ${REQUIRED_LLVM_LIBRARIES}) + dbms_target_link_libraries (PUBLIC ${REQUIRED_LLVM_LIBRARIES}) dbms_target_include_directories (SYSTEM BEFORE PUBLIC ${LLVM_INCLUDE_DIRS}) endif () From 0562d643687622e6c530f530a9361ed40fd2f239 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 9 Sep 2021 22:41:26 +0300 Subject: [PATCH 071/102] Do not override ENABLE_EMBEDDED_COMPILER each time --- cmake/find/llvm.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/find/llvm.cmake b/cmake/find/llvm.cmake index 816164bef10..23b61ab5c68 100644 --- a/cmake/find/llvm.cmake +++ b/cmake/find/llvm.cmake @@ -1,8 +1,10 @@ if (APPLE OR SPLIT_SHARED_LIBRARIES OR NOT ARCH_AMD64 OR SANITIZE STREQUAL "undefined") - set (ENABLE_EMBEDDED_COMPILER OFF CACHE INTERNAL "") + set (ENABLE_EMBEDDED_COMPILER_DEFAULT OFF) +else() + set (ENABLE_EMBEDDED_COMPILER_DEFAULT ON) endif() -option (ENABLE_EMBEDDED_COMPILER "Enable support for 'compile_expressions' option for query execution" ON) +option (ENABLE_EMBEDDED_COMPILER "Enable support for 'compile_expressions' option for query execution" ${ENABLE_EMBEDDED_COMPILER_DEFAULT}) if (NOT ENABLE_EMBEDDED_COMPILER) set (USE_EMBEDDED_COMPILER 0) From 784d468f4b7b038dda654e21ee9af0e2c650e89b Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 9 Sep 2021 22:41:26 +0300 Subject: [PATCH 072/102] Include llvm from function to guard CMAKE_CXX_STANDARD scope --- contrib/CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index e6e098a05b3..b2e97343442 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -206,7 +206,7 @@ elseif(GTEST_SRC_DIR) target_compile_definitions(gtest INTERFACE GTEST_HAS_POSIX_RE=0) endif() -if (USE_EMBEDDED_COMPILER) +function(add_llvm) # ld: unknown option: --color-diagnostics if (APPLE) set (LINKER_SUPPORTS_COLOR_DIAGNOSTICS 0 CACHE INTERNAL "") @@ -219,13 +219,12 @@ if (USE_EMBEDDED_COMPILER) # Need to use C++17 since the compilation is not possible with C++20 currently, due to ambiguous operator != etc. # LLVM project will set its default value for the -std=... but our global setting from CMake will override it. - set (CMAKE_CXX_STANDARD_bak ${CMAKE_CXX_STANDARD}) set (CMAKE_CXX_STANDARD 17) add_subdirectory (llvm/llvm) - - set (CMAKE_CXX_STANDARD ${CMAKE_CXX_STANDARD_bak}) - unset (CMAKE_CXX_STANDARD_bak) +endfunction() +if (USE_EMBEDDED_COMPILER) + add_llvm() endif () if (USE_INTERNAL_LIBGSASL_LIBRARY) From 0d0c19c6170fd33bd536ad16498c8640765bafd4 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 9 Sep 2021 22:41:27 +0300 Subject: [PATCH 073/102] Fix RPATH for llvm in shared build Before this patch: $ readelf -d contrib/llvm/llvm/bin/llvm-tblgen | fgrep -i runpath 0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/../lib] After: $ readelf -d contrib/llvm/llvm/bin/llvm-tblgen | fgrep -i runpath 0x000000000000001d (RUNPATH) Library runpath: [/src/ch/clickhouse/.cmake/contrib/llvm/llvm/lib:/src/ch/clickhouse/.cmake/contrib/libcxx-cmake:/src/ch/clickhouse/.cmake/contrib/libcxxabi-cmake:/src/ch/clickhouse/.cmake/contrib/libunwind-cmake] --- contrib/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index b2e97343442..383a8510035 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -212,6 +212,8 @@ function(add_llvm) set (LINKER_SUPPORTS_COLOR_DIAGNOSTICS 0 CACHE INTERNAL "") endif () + # Do not adjust RPATH in llvm, since then it will not be able to find libcxx/libcxxabi/libunwind + set (CMAKE_INSTALL_RPATH "ON") set (LLVM_ENABLE_EH 1 CACHE INTERNAL "") set (LLVM_ENABLE_RTTI 1 CACHE INTERNAL "") set (LLVM_ENABLE_PIC 0 CACHE INTERNAL "") From c24a3bb67d9eb55ca0dbec3d333bec1f22b39663 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 9 Sep 2021 22:42:47 +0300 Subject: [PATCH 074/102] FIx formatting for getCompilableDAG() --- src/Interpreters/ExpressionJIT.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Interpreters/ExpressionJIT.cpp b/src/Interpreters/ExpressionJIT.cpp index 27089ab8d37..de31d8cd7c5 100644 --- a/src/Interpreters/ExpressionJIT.cpp +++ b/src/Interpreters/ExpressionJIT.cpp @@ -380,25 +380,25 @@ static CompileDAG getCompilableDAG( if (!is_compilable_function || is_compilable_constant) { - CompileDAG::Node compile_node; - compile_node.function = node->function_base; - compile_node.result_type = node->result_type; + CompileDAG::Node compile_node; + compile_node.function = node->function_base; + compile_node.result_type = node->result_type; - if (is_compilable_constant) - { - compile_node.type = CompileDAG::CompileType::CONSTANT; - compile_node.column = node->column; - } - else - { + if (is_compilable_constant) + { + compile_node.type = CompileDAG::CompileType::CONSTANT; + compile_node.column = node->column; + } + else + { compile_node.type = CompileDAG::CompileType::INPUT; children.emplace_back(node); - } + } - visited_node_to_compile_dag_position[node] = dag.getNodesCount(); - dag.addNode(std::move(compile_node)); - stack.pop(); - continue; + visited_node_to_compile_dag_position[node] = dag.getNodesCount(); + dag.addNode(std::move(compile_node)); + stack.pop(); + continue; } while (frame.next_child_to_visit < node->children.size()) From 63e14fc38901ebea3aca530169b3012dbe7f8768 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Wed, 8 Sep 2021 22:23:57 +0300 Subject: [PATCH 075/102] Fix expressions compilation with short circuit evaluation Before this patch, you may get the following error: Column Function is not a contiguous block of memory Since under short circuit evaluation you may get Function not the result. --- src/Interpreters/ExpressionJIT.cpp | 7 ++++--- ...ile_expressions_with_short_circuit_evaluation.reference | 3 +++ ...4_compile_expressions_with_short_circuit_evaluation.sql | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 tests/queries/0_stateless/02024_compile_expressions_with_short_circuit_evaluation.reference create mode 100644 tests/queries/0_stateless/02024_compile_expressions_with_short_circuit_evaluation.sql diff --git a/src/Interpreters/ExpressionJIT.cpp b/src/Interpreters/ExpressionJIT.cpp index de31d8cd7c5..9005b24b044 100644 --- a/src/Interpreters/ExpressionJIT.cpp +++ b/src/Interpreters/ExpressionJIT.cpp @@ -353,7 +353,8 @@ static bool isCompilableFunction(const ActionsDAG::Node & node, const std::unord static CompileDAG getCompilableDAG( const ActionsDAG::Node * root, - ActionsDAG::NodeRawConstPtrs & children) + ActionsDAG::NodeRawConstPtrs & children, + const std::unordered_set & lazy_executed_nodes) { /// Extract CompileDAG from root actions dag node. @@ -376,7 +377,7 @@ static CompileDAG getCompilableDAG( const auto * node = frame.node; bool is_compilable_constant = isCompilableConstant(*node); - bool is_compilable_function = isCompilableFunction(*node, {}); + bool is_compilable_function = isCompilableFunction(*node, lazy_executed_nodes); if (!is_compilable_function || is_compilable_constant) { @@ -568,7 +569,7 @@ void ActionsDAG::compileFunctions(size_t min_count_to_compile_expression, const for (auto & node : nodes_to_compile) { NodeRawConstPtrs new_children; - auto dag = getCompilableDAG(node, new_children); + auto dag = getCompilableDAG(node, new_children, lazy_executed_nodes); if (dag.getInputNodesCount() == 0) continue; diff --git a/tests/queries/0_stateless/02024_compile_expressions_with_short_circuit_evaluation.reference b/tests/queries/0_stateless/02024_compile_expressions_with_short_circuit_evaluation.reference new file mode 100644 index 00000000000..af23232bb2e --- /dev/null +++ b/tests/queries/0_stateless/02024_compile_expressions_with_short_circuit_evaluation.reference @@ -0,0 +1,3 @@ +-- { echo } +select 1+number+multiIf(number == 1, cityHash64(number), number) from numbers(1) settings compile_expressions=1, min_count_to_compile_expression=0; +1 diff --git a/tests/queries/0_stateless/02024_compile_expressions_with_short_circuit_evaluation.sql b/tests/queries/0_stateless/02024_compile_expressions_with_short_circuit_evaluation.sql new file mode 100644 index 00000000000..113d0d9d4f7 --- /dev/null +++ b/tests/queries/0_stateless/02024_compile_expressions_with_short_circuit_evaluation.sql @@ -0,0 +1,2 @@ +-- { echo } +select 1+number+multiIf(number == 1, cityHash64(number), number) from numbers(1) settings compile_expressions=1, min_count_to_compile_expression=0; From 2359a222ff10789b8c43515bde1133242ff08313 Mon Sep 17 00:00:00 2001 From: alesapin Date: Thu, 9 Sep 2021 23:29:42 +0300 Subject: [PATCH 076/102] Fix more tests --- docker/test/integration/kerberos_kdc/Dockerfile | 4 +++- .../runner/compose/docker_compose_kerberized_hdfs.yml | 2 +- tests/integration/test_mysql_protocol/golang.reference | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docker/test/integration/kerberos_kdc/Dockerfile b/docker/test/integration/kerberos_kdc/Dockerfile index 7805d8f1d1c..a203c33a331 100644 --- a/docker/test/integration/kerberos_kdc/Dockerfile +++ b/docker/test/integration/kerberos_kdc/Dockerfile @@ -1,5 +1,7 @@ # docker build -t clickhouse/kerberos-kdc . -FROM centos:7 +FROM centos:6 + +RUN sed -i '/^mirrorlist/s/^/#/;/^#baseurl/{s/#//;s/mirror.centos.org\/centos\/$releasever/vault.centos.org\/6.10/}' /etc/yum.repos.d/*B* RUN yum install -y ca-certificates krb5-server krb5-libs krb5-auth-dialog krb5-workstation diff --git a/docker/test/integration/runner/compose/docker_compose_kerberized_hdfs.yml b/docker/test/integration/runner/compose/docker_compose_kerberized_hdfs.yml index 236c4f10b01..88be3e45085 100644 --- a/docker/test/integration/runner/compose/docker_compose_kerberized_hdfs.yml +++ b/docker/test/integration/runner/compose/docker_compose_kerberized_hdfs.yml @@ -4,7 +4,7 @@ services: kerberizedhdfs1: cap_add: - DAC_READ_SEARCH - image: clickhouse/kerberized-hadoop:16621 + image: clickhouse/kerberized-hadoop hostname: kerberizedhdfs1 restart: always volumes: diff --git a/tests/integration/test_mysql_protocol/golang.reference b/tests/integration/test_mysql_protocol/golang.reference index 082149b4644..4069b2a086a 100644 --- a/tests/integration/test_mysql_protocol/golang.reference +++ b/tests/integration/test_mysql_protocol/golang.reference @@ -1,7 +1,7 @@ Columns: a Column types: -a BIGINT +a UNSIGNED BIGINT Result: 0 1 @@ -10,14 +10,15 @@ name a Column types: name CHAR -a TINYINT +a UNSIGNED TINYINT Result: tables 1 +tables 1 Columns: a b Column types: a CHAR -b TINYINT +b UNSIGNED TINYINT Result: тест 1 From 62b15122ff33482db71e21f5a9bf9dc454a97df9 Mon Sep 17 00:00:00 2001 From: Dmitriy <72220289+sevirov@users.noreply.github.com> Date: Thu, 9 Sep 2021 23:33:08 +0300 Subject: [PATCH 077/102] DOCSUP-13875: Document the replication_wait_for_inactive_replica_timeout setting (#28464) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add documentation of settings Задокументировал две настройки. * Fix links Поправил ссылки. * Update docs/en/operations/settings/settings.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Update docs/en/operations/settings/settings.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Update docs/en/operations/settings/settings.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Update docs/en/operations/settings/settings.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Update docs/en/sql-reference/statements/alter/index.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Update docs/en/sql-reference/statements/alter/index.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Update docs/en/sql-reference/statements/optimize.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Update docs/en/sql-reference/statements/truncate.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Update docs/en/sql-reference/statements/truncate.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Translate to Russian Выполнил перевод на русский язык. * Fix links Поправил ссылки. * Update settings.md Поправил перевод. * Update docs/en/operations/settings/settings.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Update docs/en/sql-reference/statements/alter/index.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Update docs/en/sql-reference/statements/optimize.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Update docs/en/sql-reference/statements/truncate.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Update docs/ru/operations/settings/settings.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Update docs/ru/operations/settings/settings.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Update docs/en/operations/settings/settings.md Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> * Fix errors Исправил неточности в описании. * Update optimize.md Поправил описание запроса OPTIMIZE. Co-authored-by: Dmitriy Co-authored-by: olgarev <56617294+olgarev@users.noreply.github.com> --- docs/en/operations/settings/settings.md | 24 +++++++++++++++++ .../sql-reference/statements/alter/index.md | 8 ++++-- docs/en/sql-reference/statements/optimize.md | 6 ++++- docs/en/sql-reference/statements/truncate.md | 7 +++++ docs/ru/operations/settings/settings.md | 26 ++++++++++++++++++- .../sql-reference/statements/alter/index.md | 9 ++++--- docs/ru/sql-reference/statements/optimize.md | 7 ++++- docs/ru/sql-reference/statements/truncate.md | 5 ++++ 8 files changed, 84 insertions(+), 8 deletions(-) diff --git a/docs/en/operations/settings/settings.md b/docs/en/operations/settings/settings.md index 7bd08549cb8..6c5767d28e0 100644 --- a/docs/en/operations/settings/settings.md +++ b/docs/en/operations/settings/settings.md @@ -3499,6 +3499,30 @@ Possible values: Default value: `0`. +## replication_alter_partitions_sync {#replication-alter-partitions-sync} + +Allows to set up waiting for actions to be executed on replicas by [ALTER](../../sql-reference/statements/alter/index.md), [OPTIMIZE](../../sql-reference/statements/optimize.md) or [TRUNCATE](../../sql-reference/statements/truncate.md) queries. + +Possible values: + +- 0 — Do not wait. +- 1 — Wait for own execution. +- 2 — Wait for everyone. + +Default value: `1`. + +## replication_wait_for_inactive_replica_timeout {#replication-wait-for-inactive-replica-timeout} + +Specifies how long (in seconds) to wait for inactive replicas to execute [ALTER](../../sql-reference/statements/alter/index.md), [OPTIMIZE](../../sql-reference/statements/optimize.md) or [TRUNCATE](../../sql-reference/statements/truncate.md) queries. + +Possible values: + +- 0 — Do not wait. +- Negative integer — Wait for unlimited time. +- Positive integer — The number of seconds to wait. + +Default value: `120` seconds. + ## regexp_max_matches_per_row {#regexp-max-matches-per-row} Sets the maximum number of matches for a single regular expression per row. Use it to protect against memory overload when using greedy regular expression in the [extractAllGroupsHorizontal](../../sql-reference/functions/string-search-functions.md#extractallgroups-horizontal) function. diff --git a/docs/en/sql-reference/statements/alter/index.md b/docs/en/sql-reference/statements/alter/index.md index 71333e6fcce..382306016e6 100644 --- a/docs/en/sql-reference/statements/alter/index.md +++ b/docs/en/sql-reference/statements/alter/index.md @@ -43,7 +43,11 @@ Entries for finished mutations are not deleted right away (the number of preserv For non-replicated tables, all `ALTER` queries are performed synchronously. For replicated tables, the query just adds instructions for the appropriate actions to `ZooKeeper`, and the actions themselves are performed as soon as possible. However, the query can wait for these actions to be completed on all the replicas. -For `ALTER ... ATTACH|DETACH|DROP` queries, you can use the `replication_alter_partitions_sync` setting to set up waiting. Possible values: `0` – do not wait; `1` – only wait for own execution (default); `2` – wait for all. +For all `ALTER` queries, you can use the [replication_alter_partitions_sync](../../../operations/settings/settings.md#replication-alter-partitions-sync) setting to set up waiting. + +You can specify how long (in seconds) to wait for inactive replicas to execute all `ALTER` queries with the [replication_wait_for_inactive_replica_timeout](../../../operations/settings/settings.md#replication-wait-for-inactive-replica-timeout) setting. + +!!! info "Note" + For all `ALTER` queries, if `replication_alter_partitions_sync = 2` and some replicas are not active for more than the time, specified in the `replication_wait_for_inactive_replica_timeout` setting, then an exception `UNFINISHED` is thrown. For `ALTER TABLE ... UPDATE|DELETE` queries the synchronicity is defined by the [mutations_sync](../../../operations/settings/settings.md#mutations_sync) setting. - diff --git a/docs/en/sql-reference/statements/optimize.md b/docs/en/sql-reference/statements/optimize.md index 864509cec94..4054f373cc1 100644 --- a/docs/en/sql-reference/statements/optimize.md +++ b/docs/en/sql-reference/statements/optimize.md @@ -18,13 +18,17 @@ OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION I The `OPTMIZE` query is supported for [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) family, the [MaterializedView](../../engines/table-engines/special/materializedview.md) and the [Buffer](../../engines/table-engines/special/buffer.md) engines. Other table engines aren’t supported. -When `OPTIMIZE` is used with the [ReplicatedMergeTree](../../engines/table-engines/mergetree-family/replication.md) family of table engines, ClickHouse creates a task for merging and waits for execution on all nodes (if the `replication_alter_partitions_sync` setting is enabled). +When `OPTIMIZE` is used with the [ReplicatedMergeTree](../../engines/table-engines/mergetree-family/replication.md) family of table engines, ClickHouse creates a task for merging and waits for execution on all replicas (if the [replication_alter_partitions_sync](../../operations/settings/settings.md#replication-alter-partitions-sync) setting is set to `2`) or on current replica (if the [replication_alter_partitions_sync](../../operations/settings/settings.md#replication-alter-partitions-sync) setting is set to `1`). - If `OPTIMIZE` does not perform a merge for any reason, it does not notify the client. To enable notifications, use the [optimize_throw_if_noop](../../operations/settings/settings.md#setting-optimize_throw_if_noop) setting. - If you specify a `PARTITION`, only the specified partition is optimized. [How to set partition expression](../../sql-reference/statements/alter/index.md#alter-how-to-specify-part-expr). - If you specify `FINAL`, optimization is performed even when all the data is already in one part. Also merge is forced even if concurrent merges are performed. - If you specify `DEDUPLICATE`, then completely identical rows (unless by-clause is specified) will be deduplicated (all columns are compared), it makes sense only for the MergeTree engine. +You can specify how long (in seconds) to wait for inactive replicas to execute `OPTIMIZE` queries by the [replication_wait_for_inactive_replica_timeout](../../operations/settings/settings.md#replication-wait-for-inactive-replica-timeout) setting. + +!!! info "Note" + If the `replication_alter_partitions_sync` is set to `2` and some replicas are not active for more than the time, specified by the `replication_wait_for_inactive_replica_timeout` setting, then an exception `UNFINISHED` is thrown. ## BY expression {#by-expression} diff --git a/docs/en/sql-reference/statements/truncate.md b/docs/en/sql-reference/statements/truncate.md index f302a8605e2..b5354196fa4 100644 --- a/docs/en/sql-reference/statements/truncate.md +++ b/docs/en/sql-reference/statements/truncate.md @@ -12,3 +12,10 @@ TRUNCATE TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] Removes all data from a table. When the clause `IF EXISTS` is omitted, the query returns an error if the table does not exist. The `TRUNCATE` query is not supported for [View](../../engines/table-engines/special/view.md), [File](../../engines/table-engines/special/file.md), [URL](../../engines/table-engines/special/url.md), [Buffer](../../engines/table-engines/special/buffer.md) and [Null](../../engines/table-engines/special/null.md) table engines. + +You can use the [replication_alter_partitions_sync](../../operations/settings/settings.md#replication-alter-partitions-sync) setting to set up waiting for actions to be executed on replicas. + +You can specify how long (in seconds) to wait for inactive replicas to execute `TRUNCATE` queries with the [replication_wait_for_inactive_replica_timeout](../../operations/settings/settings.md#replication-wait-for-inactive-replica-timeout) setting. + +!!! info "Note" + If the `replication_alter_partitions_sync` is set to `2` and some replicas are not active for more than the time, specified by the `replication_wait_for_inactive_replica_timeout` setting, then an exception `UNFINISHED` is thrown. diff --git a/docs/ru/operations/settings/settings.md b/docs/ru/operations/settings/settings.md index 9ad300b8c9c..f55edec62d1 100644 --- a/docs/ru/operations/settings/settings.md +++ b/docs/ru/operations/settings/settings.md @@ -3308,6 +3308,30 @@ SETTINGS index_granularity = 8192 │ Значение по умолчанию: `0`. +## replication_alter_partitions_sync {#replication-alter-partitions-sync} + +Позволяет настроить ожидание выполнения действий на репликах запросами [ALTER](../../sql-reference/statements/alter/index.md), [OPTIMIZE](../../sql-reference/statements/optimize.md) или [TRUNCATE](../../sql-reference/statements/truncate.md). + +Возможные значения: + +- 0 — не ждать. +- 1 — ждать выполнения действий на своей реплике. +- 2 — ждать выполнения действий на всех репликах. + +Значение по умолчанию: `1`. + +## replication_wait_for_inactive_replica_timeout {#replication-wait-for-inactive-replica-timeout} + +Указывает время ожидания (в секундах) выполнения запросов [ALTER](../../sql-reference/statements/alter/index.md), [OPTIMIZE](../../sql-reference/statements/optimize.md) или [TRUNCATE](../../sql-reference/statements/truncate.md) для неактивных реплик. + +Возможные значения: + +- 0 — не ждать. +- Отрицательное целое число — ждать неограниченное время. +- Положительное целое число — установить соответствующее количество секунд ожидания. + +Значение по умолчанию: `120` секунд. + ## regexp_max_matches_per_row {#regexp-max-matches-per-row} Задает максимальное количество совпадений для регулярного выражения. Настройка применяется для защиты памяти от перегрузки при использовании "жадных" квантификаторов в регулярном выражении для функции [extractAllGroupsHorizontal](../../sql-reference/functions/string-search-functions.md#extractallgroups-horizontal). @@ -3316,4 +3340,4 @@ SETTINGS index_granularity = 8192 │ - Положительное целое число. -Значение по умолчанию: `1000`. \ No newline at end of file +Значение по умолчанию: `1000`. diff --git a/docs/ru/sql-reference/statements/alter/index.md b/docs/ru/sql-reference/statements/alter/index.md index 043ac3839d9..2b7caa5ad5b 100644 --- a/docs/ru/sql-reference/statements/alter/index.md +++ b/docs/ru/sql-reference/statements/alter/index.md @@ -64,8 +64,11 @@ ALTER TABLE [db.]table MATERIALIZE INDEX name IN PARTITION partition_name Для нереплицируемых таблиц, все запросы `ALTER` выполняются синхронно. Для реплицируемых таблиц, запрос всего лишь добавляет инструкцию по соответствующим действиям в `ZooKeeper`, а сами действия осуществляются при первой возможности. Но при этом, запрос может ждать завершения выполнения этих действий на всех репликах. -Для запросов `ALTER ... ATTACH|DETACH|DROP` можно настроить ожидание, с помощью настройки `replication_alter_partitions_sync`. -Возможные значения: `0` - не ждать, `1` - ждать выполнения только у себя (по умолчанию), `2` - ждать всех. +Для всех запросов `ALTER` можно настроить ожидание с помощью настройки [replication_alter_partitions_sync](../../../operations/settings/settings.md#replication-alter-partitions-sync). + +Вы можете указать время ожидания (в секундах) выполнения всех запросов `ALTER` для неактивных реплик с помощью настройки [replication_wait_for_inactive_replica_timeout](../../../operations/settings/settings.md#replication-wait-for-inactive-replica-timeout). + +!!! info "Примечание" + Для всех запросов `ALTER` при `replication_alter_partitions_sync = 2` и неактивности некоторых реплик больше времени, заданного настройкой `replication_wait_for_inactive_replica_timeout`, генерируется исключение `UNFINISHED`. Для запросов `ALTER TABLE ... UPDATE|DELETE` синхронность выполнения определяется настройкой [mutations_sync](../../../operations/settings/settings.md#mutations_sync). - diff --git a/docs/ru/sql-reference/statements/optimize.md b/docs/ru/sql-reference/statements/optimize.md index 1f0c5a0ebe9..e6a71c4f611 100644 --- a/docs/ru/sql-reference/statements/optimize.md +++ b/docs/ru/sql-reference/statements/optimize.md @@ -18,7 +18,7 @@ OPTIMIZE TABLE [db.]name [ON CLUSTER cluster] [PARTITION partition | PARTITION I Может применяться к таблицам семейства [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md), [MaterializedView](../../engines/table-engines/special/materializedview.md) и [Buffer](../../engines/table-engines/special/buffer.md). Другие движки таблиц не поддерживаются. -Если запрос `OPTIMIZE` применяется к таблицам семейства [ReplicatedMergeTree](../../engines/table-engines/mergetree-family/replication.md), ClickHouse создаёт задачу на слияние и ожидает её исполнения на всех узлах (если активирована настройка `replication_alter_partitions_sync`). +Если запрос `OPTIMIZE` применяется к таблицам семейства [ReplicatedMergeTree](../../engines/table-engines/mergetree-family/replication.md), ClickHouse создаёт задачу на слияние и ожидает её исполнения на всех репликах (если значение настройки [replication_alter_partitions_sync](../../operations/settings/settings.md#replication-alter-partitions-sync) равно `2`) или на текущей реплике (если значение настройки [replication_alter_partitions_sync](../../operations/settings/settings.md#replication-alter-partitions-sync) равно `1`). - По умолчанию, если запросу `OPTIMIZE` не удалось выполнить слияние, то ClickHouse не оповещает клиента. Чтобы включить оповещения, используйте настройку [optimize_throw_if_noop](../../operations/settings/settings.md#setting-optimize_throw_if_noop). @@ -26,6 +26,11 @@ ClickHouse не оповещает клиента. Чтобы включить - Если указать `FINAL`, то оптимизация выполняется даже в том случае, если все данные уже лежат в одном куске данных. Кроме того, слияние является принудительным, даже если выполняются параллельные слияния. - Если указать `DEDUPLICATE`, то произойдет схлопывание полностью одинаковых строк (сравниваются значения во всех столбцах), имеет смысл только для движка MergeTree. +Вы можете указать время ожидания (в секундах) выполнения запросов `OPTIMIZE` для неактивных реплик с помощью настройки [replication_wait_for_inactive_replica_timeout](../../operations/settings/settings.md#replication-wait-for-inactive-replica-timeout). + +!!! info "Примечание" + Если значение настройки `replication_alter_partitions_sync` равно `2` и некоторые реплики не активны больше времени, заданного настройкой `replication_wait_for_inactive_replica_timeout`, то генерируется исключение `UNFINISHED`. + ## Выражение BY {#by-expression} Чтобы выполнить дедупликацию по произвольному набору столбцов, вы можете явно указать список столбцов или использовать любую комбинацию подстановки [`*`](../../sql-reference/statements/select/index.md#asterisk), выражений [`COLUMNS`](../../sql-reference/statements/select/index.md#columns-expression) и [`EXCEPT`](../../sql-reference/statements/select/index.md#except-modifier). diff --git a/docs/ru/sql-reference/statements/truncate.md b/docs/ru/sql-reference/statements/truncate.md index 63f7fa86ea5..028959690cd 100644 --- a/docs/ru/sql-reference/statements/truncate.md +++ b/docs/ru/sql-reference/statements/truncate.md @@ -13,4 +13,9 @@ TRUNCATE TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] Запрос `TRUNCATE` не поддерживается для следующих движков: [View](../../engines/table-engines/special/view.md), [File](../../engines/table-engines/special/file.md), [URL](../../engines/table-engines/special/url.md), [Buffer](../../engines/table-engines/special/buffer.md) и [Null](../../engines/table-engines/special/null.md). +Вы можете настроить ожидание выполнения действий на репликах с помощью настройки [replication_alter_partitions_sync](../../operations/settings/settings.md#replication-alter-partitions-sync). +Вы можете указать время ожидания (в секундах) выполнения запросов `TRUNCATE` для неактивных реплик с помощью настройки [replication_wait_for_inactive_replica_timeout](../../operations/settings/settings.md#replication-wait-for-inactive-replica-timeout). + +!!! info "Примечание" + Если значение настройки `replication_alter_partitions_sync` равно `2` и некоторые реплики не активны больше времени, заданного настройкой `replication_wait_for_inactive_replica_timeout`, то генерируется исключение `UNFINISHED`. From b1edf77904300e2439f5ff7de76cff6bfd015d91 Mon Sep 17 00:00:00 2001 From: Maksim Kita Date: Fri, 10 Sep 2021 01:04:52 +0300 Subject: [PATCH 078/102] Executable added option send_chunk_header --- .../ExecutableDictionarySource.cpp | 10 ++++++- src/Dictionaries/ExecutableDictionarySource.h | 12 +++++---- .../ExecutablePoolDictionarySource.cpp | 10 ++++++- .../ExecutablePoolDictionarySource.h | 14 +++++----- ...oolSettings.cpp => ExecutableSettings.cpp} | 6 ++--- ...blePoolSettings.h => ExecutableSettings.h} | 7 ++--- src/Storages/StorageExecutable.cpp | 26 +++++++++++++------ src/Storages/StorageExecutable.h | 6 ++--- 8 files changed, 61 insertions(+), 30 deletions(-) rename src/Storages/{ExecutablePoolSettings.cpp => ExecutableSettings.cpp} (79%) rename src/Storages/{ExecutablePoolSettings.h => ExecutableSettings.h} (62%) diff --git a/src/Dictionaries/ExecutableDictionarySource.cpp b/src/Dictionaries/ExecutableDictionarySource.cpp index a274e820e65..ba624f8e2a2 100644 --- a/src/Dictionaries/ExecutableDictionarySource.cpp +++ b/src/Dictionaries/ExecutableDictionarySource.cpp @@ -120,6 +120,13 @@ Pipe ExecutableDictionarySource::getStreamForBlock(const Block & block) ShellCommandSource::SendDataTask task = {[process_in, block, this]() { auto & out = *process_in; + + if (configuration.send_chunk_header) + { + writeText(block.rows(), out); + writeChar('\n', out); + } + auto output_stream = context->getOutputStream(configuration.format, out, block.cloneEmpty()); formatBlock(output_stream, block); out.close(); @@ -188,7 +195,8 @@ void registerDictionarySourceExecutable(DictionarySourceFactory & factory) .format = config.getString(settings_config_prefix + ".format"), .update_field = config.getString(settings_config_prefix + ".update_field", ""), .update_lag = config.getUInt64(settings_config_prefix + ".update_lag", 1), - .implicit_key = config.getBool(settings_config_prefix + ".implicit_key", false) + .implicit_key = config.getBool(settings_config_prefix + ".implicit_key", false), + .send_chunk_header = config.getBool(settings_config_prefix + ".implicit_key", false) }; return std::make_unique(dict_struct, configuration, sample_block, context); diff --git a/src/Dictionaries/ExecutableDictionarySource.h b/src/Dictionaries/ExecutableDictionarySource.h index 3133bc12b09..5b20deceb28 100644 --- a/src/Dictionaries/ExecutableDictionarySource.h +++ b/src/Dictionaries/ExecutableDictionarySource.h @@ -19,13 +19,15 @@ public: struct Configuration { - const std::string command; - const std::string format; - const std::string update_field; - const UInt64 update_lag; + std::string command; + std::string format; + std::string update_field; + UInt64 update_lag; /// Implicit key means that the source script will return only values, /// and the correspondence to the requested keys is determined implicitly - by the order of rows in the result. - const bool implicit_key; + bool implicit_key; + /// Send number_of_rows\n before sending chunk to process + bool send_chunk_header; }; ExecutableDictionarySource( diff --git a/src/Dictionaries/ExecutablePoolDictionarySource.cpp b/src/Dictionaries/ExecutablePoolDictionarySource.cpp index c5d081bb3e6..0981fb762c8 100644 --- a/src/Dictionaries/ExecutablePoolDictionarySource.cpp +++ b/src/Dictionaries/ExecutablePoolDictionarySource.cpp @@ -100,7 +100,7 @@ Pipe ExecutablePoolDictionarySource::getStreamForBlock(const Block & block) config.terminate_in_destructor_strategy = ShellCommand::DestructorStrategy{ true /*terminate_in_destructor*/, configuration.command_termination_timeout }; auto shell_command = ShellCommand::execute(config); return shell_command; - }, configuration.max_command_execution_time * 10000); + }, configuration.max_command_execution_time * 1000); if (!result) throw Exception(ErrorCodes::TIMEOUT_EXCEEDED, @@ -112,6 +112,13 @@ Pipe ExecutablePoolDictionarySource::getStreamForBlock(const Block & block) ShellCommandSource::SendDataTask task = [process_in, block, this]() mutable { auto & out = *process_in; + + if (configuration.send_chunk_header) + { + writeText(block.rows(), out); + writeChar('\n', out); + } + auto output_stream = context->getOutputStream(configuration.format, out, block.cloneEmpty()); formatBlock(output_stream, block); }; @@ -190,6 +197,7 @@ void registerDictionarySourceExecutablePool(DictionarySourceFactory & factory) .command_termination_timeout = config.getUInt64(settings_config_prefix + ".command_termination_timeout", 10), .max_command_execution_time = max_command_execution_time, .implicit_key = config.getBool(settings_config_prefix + ".implicit_key", false), + .send_chunk_header = config.getBool(settings_config_prefix + ".send_chunk_header", false) }; return std::make_unique(dict_struct, configuration, sample_block, context); diff --git a/src/Dictionaries/ExecutablePoolDictionarySource.h b/src/Dictionaries/ExecutablePoolDictionarySource.h index b80122fb56f..2ccb4ce4b8d 100644 --- a/src/Dictionaries/ExecutablePoolDictionarySource.h +++ b/src/Dictionaries/ExecutablePoolDictionarySource.h @@ -27,14 +27,16 @@ class ExecutablePoolDictionarySource final : public IDictionarySource public: struct Configuration { - const String command; - const String format; - const size_t pool_size; - const size_t command_termination_timeout; - const size_t max_command_execution_time; + String command; + String format; + size_t pool_size; + size_t command_termination_timeout; + size_t max_command_execution_time; /// Implicit key means that the source script will return only values, /// and the correspondence to the requested keys is determined implicitly - by the order of rows in the result. - const bool implicit_key; + bool implicit_key; + /// Send number_of_rows\n before sending chunk to process + bool send_chunk_header; }; ExecutablePoolDictionarySource( diff --git a/src/Storages/ExecutablePoolSettings.cpp b/src/Storages/ExecutableSettings.cpp similarity index 79% rename from src/Storages/ExecutablePoolSettings.cpp rename to src/Storages/ExecutableSettings.cpp index 8951c8edabf..136357eb6f8 100644 --- a/src/Storages/ExecutablePoolSettings.cpp +++ b/src/Storages/ExecutableSettings.cpp @@ -1,4 +1,4 @@ -#include "ExecutablePoolSettings.h" +#include "ExecutableSettings.h" #include @@ -14,9 +14,9 @@ namespace ErrorCodes extern const int UNKNOWN_SETTING; } -IMPLEMENT_SETTINGS_TRAITS(ExecutablePoolSettingsTraits, LIST_OF_EXECUTABLE_POOL_SETTINGS); +IMPLEMENT_SETTINGS_TRAITS(ExecutableSettingsTraits, LIST_OF_EXECUTABLE_SETTINGS); -void ExecutablePoolSettings::loadFromQuery(ASTStorage & storage_def) +void ExecutableSettings::loadFromQuery(ASTStorage & storage_def) { if (storage_def.settings) { diff --git a/src/Storages/ExecutablePoolSettings.h b/src/Storages/ExecutableSettings.h similarity index 62% rename from src/Storages/ExecutablePoolSettings.h rename to src/Storages/ExecutableSettings.h index 6de9b0f0e6c..9c0cfc05fa5 100644 --- a/src/Storages/ExecutablePoolSettings.h +++ b/src/Storages/ExecutableSettings.h @@ -8,15 +8,16 @@ namespace DB class ASTStorage; -#define LIST_OF_EXECUTABLE_POOL_SETTINGS(M) \ +#define LIST_OF_EXECUTABLE_SETTINGS(M) \ + M(UInt64, send_chunk_header, false, "Send number_of_rows\n before sending chunk to process", 0) \ M(UInt64, pool_size, 16, "Processes pool size. If size == 0, then there is no size restrictions", 0) \ M(UInt64, max_command_execution_time, 10, "Max command execution time in seconds.", 0) \ M(UInt64, command_termination_timeout, 10, "Command termination timeout in seconds.", 0) \ -DECLARE_SETTINGS_TRAITS(ExecutablePoolSettingsTraits, LIST_OF_EXECUTABLE_POOL_SETTINGS) +DECLARE_SETTINGS_TRAITS(ExecutableSettingsTraits, LIST_OF_EXECUTABLE_SETTINGS) /// Settings for ExecutablePool engine. -struct ExecutablePoolSettings : public BaseSettings +struct ExecutableSettings : public BaseSettings { void loadFromQuery(ASTStorage & storage_def); }; diff --git a/src/Storages/StorageExecutable.cpp b/src/Storages/StorageExecutable.cpp index 4b0aaf6caea..2af2661d8af 100644 --- a/src/Storages/StorageExecutable.cpp +++ b/src/Storages/StorageExecutable.cpp @@ -56,7 +56,7 @@ StorageExecutable::StorageExecutable( const std::vector & arguments_, const String & format_, const std::vector & input_queries_, - const ExecutablePoolSettings & pool_settings_, + const ExecutableSettings & settings_, const ColumnsDescription & columns, const ConstraintsDescription & constraints) : IStorage(table_id_) @@ -64,9 +64,9 @@ StorageExecutable::StorageExecutable( , arguments(arguments_) , format(format_) , input_queries(input_queries_) - , pool_settings(pool_settings_) + , settings(settings_) /// If pool size == 0 then there is no size restrictions. Poco max size of semaphore is integer type. - , process_pool(std::make_shared(pool_settings.pool_size == 0 ? std::numeric_limits::max() : pool_settings.pool_size)) + , process_pool(std::make_shared(settings.pool_size == 0 ? std::numeric_limits::max() : settings.pool_size)) , log(&Poco::Logger::get("StorageExecutablePool")) { StorageInMemoryMetadata storage_metadata; @@ -114,15 +114,15 @@ Pipe StorageExecutable::read( { bool result = process_pool->tryBorrowObject(process, [&config, this]() { - config.terminate_in_destructor_strategy = ShellCommand::DestructorStrategy{ true /*terminate_in_destructor*/, pool_settings.command_termination_timeout }; + config.terminate_in_destructor_strategy = ShellCommand::DestructorStrategy{ true /*terminate_in_destructor*/, settings.command_termination_timeout }; auto shell_command = ShellCommand::execute(config); return shell_command; - }, pool_settings.max_command_execution_time * 10000); + }, settings.max_command_execution_time * 1000); if (!result) throw Exception(ErrorCodes::TIMEOUT_EXCEEDED, "Could not get process from pool, max command execution timeout exceeded {} seconds", - pool_settings.max_command_execution_time); + settings.max_command_execution_time); } else { @@ -137,6 +137,8 @@ Pipe StorageExecutable::read( BlockInputStreamPtr input_stream = inputs[i]; WriteBufferFromFile * write_buffer = nullptr; + bool send_chunk_header = settings.send_chunk_header; + if (i == 0) { write_buffer = &process->in; @@ -151,14 +153,22 @@ Pipe StorageExecutable::read( write_buffer = &it->second; } - ShellCommandSource::SendDataTask task = [input_stream, write_buffer, context, is_executable_pool, this]() + ShellCommandSource::SendDataTask task = [input_stream, write_buffer, context, is_executable_pool, send_chunk_header, this]() { auto output_stream = context->getOutputStream(format, *write_buffer, input_stream->getHeader().cloneEmpty()); input_stream->readPrefix(); output_stream->writePrefix(); while (auto block = input_stream->read()) + { + if (send_chunk_header) + { + writeText(block.rows(), *write_buffer); + writeChar('\n', *write_buffer); + } + output_stream->write(block); + } input_stream->readSuffix(); output_stream->writeSuffix(); @@ -232,7 +242,7 @@ void registerStorageExecutable(StorageFactory & factory) if (max_execution_time_seconds != 0 && max_command_execution_time > max_execution_time_seconds) max_command_execution_time = max_execution_time_seconds; - ExecutablePoolSettings pool_settings; + ExecutableSettings pool_settings; pool_settings.max_command_execution_time = max_command_execution_time; if (args.storage_def->settings) pool_settings.loadFromQuery(*args.storage_def); diff --git a/src/Storages/StorageExecutable.h b/src/Storages/StorageExecutable.h index dd986ee3956..c67891d876f 100644 --- a/src/Storages/StorageExecutable.h +++ b/src/Storages/StorageExecutable.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include namespace DB @@ -55,7 +55,7 @@ protected: const std::vector & arguments_, const String & format_, const std::vector & input_queries_, - const ExecutablePoolSettings & pool_settings_, + const ExecutableSettings & settings_, const ColumnsDescription & columns, const ConstraintsDescription & constraints); @@ -64,7 +64,7 @@ private: std::vector arguments; String format; std::vector input_queries; - ExecutablePoolSettings pool_settings; + ExecutableSettings settings; std::shared_ptr process_pool; Poco::Logger * log; }; From a8c61f1d63bc69ffbe2c283a5e0a54fbc92c1780 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 10 Sep 2021 01:10:57 +0300 Subject: [PATCH 079/102] Build w/ ENABLE_EMBEDDED_COMPILER in shared build on CI --- cmake/find/llvm.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/find/llvm.cmake b/cmake/find/llvm.cmake index 23b61ab5c68..84ac29991ab 100644 --- a/cmake/find/llvm.cmake +++ b/cmake/find/llvm.cmake @@ -1,4 +1,4 @@ -if (APPLE OR SPLIT_SHARED_LIBRARIES OR NOT ARCH_AMD64 OR SANITIZE STREQUAL "undefined") +if (APPLE OR NOT ARCH_AMD64 OR SANITIZE STREQUAL "undefined") set (ENABLE_EMBEDDED_COMPILER_DEFAULT OFF) else() set (ENABLE_EMBEDDED_COMPILER_DEFAULT ON) From 21d33c3c2ee20d1220c56527161457825a7e1f9e Mon Sep 17 00:00:00 2001 From: Maksim Kita Date: Fri, 10 Sep 2021 01:28:22 +0300 Subject: [PATCH 080/102] ShellCommandSource fix logging --- src/DataStreams/ShellCommandSource.h | 5 ----- src/Dictionaries/ExecutableDictionarySource.cpp | 6 +++--- src/Dictionaries/ExecutablePoolDictionarySource.cpp | 2 +- src/Storages/StorageExecutable.cpp | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/DataStreams/ShellCommandSource.h b/src/DataStreams/ShellCommandSource.h index befdbc796ba..21d0acaf81a 100644 --- a/src/DataStreams/ShellCommandSource.h +++ b/src/DataStreams/ShellCommandSource.h @@ -52,14 +52,12 @@ public: const std::string & format, const Block & sample_block, std::unique_ptr && command_, - Poco::Logger * log_, std::vector && send_data_tasks = {}, const ShellCommandSourceConfiguration & configuration_ = {}, std::shared_ptr process_pool_ = nullptr) : SourceWithProgress(sample_block) , command(std::move(command_)) , configuration(configuration_) - , log(log_) , process_pool(process_pool_) { for (auto && send_data_task : send_data_tasks) @@ -133,7 +131,6 @@ protected: } catch (...) { - tryLogCurrentException(log); command = nullptr; throw; } @@ -176,8 +173,6 @@ private: size_t current_read_rows = 0; - Poco::Logger * log; - std::shared_ptr process_pool; QueryPipeline pipeline; diff --git a/src/Dictionaries/ExecutableDictionarySource.cpp b/src/Dictionaries/ExecutableDictionarySource.cpp index a274e820e65..ca0c45a9b6c 100644 --- a/src/Dictionaries/ExecutableDictionarySource.cpp +++ b/src/Dictionaries/ExecutableDictionarySource.cpp @@ -72,7 +72,7 @@ Pipe ExecutableDictionarySource::loadAll() ShellCommand::Config config(configuration.command); auto process = ShellCommand::execute(config); - Pipe pipe(std::make_unique(context, configuration.format, sample_block, std::move(process), log)); + Pipe pipe(std::make_unique(context, configuration.format, sample_block, std::move(process))); return pipe; } @@ -91,7 +91,7 @@ Pipe ExecutableDictionarySource::loadUpdatedAll() LOG_TRACE(log, "loadUpdatedAll {}", command_with_update_field); ShellCommand::Config config(command_with_update_field); auto process = ShellCommand::execute(config); - Pipe pipe(std::make_unique(context, configuration.format, sample_block, std::move(process), log)); + Pipe pipe(std::make_unique(context, configuration.format, sample_block, std::move(process))); return pipe; } @@ -126,7 +126,7 @@ Pipe ExecutableDictionarySource::getStreamForBlock(const Block & block) }}; std::vector tasks = {std::move(task)}; - Pipe pipe(std::make_unique(context, configuration.format, sample_block, std::move(process), log, std::move(tasks))); + Pipe pipe(std::make_unique(context, configuration.format, sample_block, std::move(process), std::move(tasks))); if (configuration.implicit_key) pipe.addTransform(std::make_shared(block, pipe.getHeader())); diff --git a/src/Dictionaries/ExecutablePoolDictionarySource.cpp b/src/Dictionaries/ExecutablePoolDictionarySource.cpp index c5d081bb3e6..160ac022a70 100644 --- a/src/Dictionaries/ExecutablePoolDictionarySource.cpp +++ b/src/Dictionaries/ExecutablePoolDictionarySource.cpp @@ -120,7 +120,7 @@ Pipe ExecutablePoolDictionarySource::getStreamForBlock(const Block & block) ShellCommandSourceConfiguration command_configuration; command_configuration.read_fixed_number_of_rows = true; command_configuration.number_of_rows_to_read = rows_to_read; - Pipe pipe(std::make_unique(context, configuration.format, sample_block, std::move(process), log, std::move(tasks), command_configuration, process_pool)); + Pipe pipe(std::make_unique(context, configuration.format, sample_block, std::move(process), std::move(tasks), command_configuration, process_pool)); if (configuration.implicit_key) pipe.addTransform(std::make_shared(block, pipe.getHeader())); diff --git a/src/Storages/StorageExecutable.cpp b/src/Storages/StorageExecutable.cpp index 4b0aaf6caea..3a14c16bae4 100644 --- a/src/Storages/StorageExecutable.cpp +++ b/src/Storages/StorageExecutable.cpp @@ -183,7 +183,7 @@ Pipe StorageExecutable::read( configuration.read_number_of_rows_from_process_output = true; } - Pipe pipe(std::make_unique(context, format, std::move(sample_block), std::move(process), log, std::move(tasks), configuration, process_pool)); + Pipe pipe(std::make_unique(context, format, std::move(sample_block), std::move(process), std::move(tasks), configuration, process_pool)); return pipe; } From ac7330b805df8b9be829aec1b43e533eb86126e3 Mon Sep 17 00:00:00 2001 From: yeer Date: Fri, 10 Sep 2021 11:41:46 +0800 Subject: [PATCH 081/102] Update where.md type: expluded => excluded --- docs/en/sql-reference/statements/select/where.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/statements/select/where.md b/docs/en/sql-reference/statements/select/where.md index f1532115e55..69505a51db4 100644 --- a/docs/en/sql-reference/statements/select/where.md +++ b/docs/en/sql-reference/statements/select/where.md @@ -6,7 +6,7 @@ toc_title: WHERE `WHERE` clause allows to filter the data that is coming from [FROM](../../../sql-reference/statements/select/from.md) clause of `SELECT`. -If there is a `WHERE` clause, it must contain an expression with the `UInt8` type. This is usually an expression with comparison and logical operators. Rows where this expression evaluates to 0 are expluded from further transformations or result. +If there is a `WHERE` clause, it must contain an expression with the `UInt8` type. This is usually an expression with comparison and logical operators. Rows where this expression evaluates to 0 are excluded from further transformations or result. `WHERE` expression is evaluated on the ability to use indexes and partition pruning, if the underlying table engine supports that. From 4d82e8918bbd325b8f06b9e27f1790436be06f70 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 10 Sep 2021 08:39:56 +0300 Subject: [PATCH 082/102] Update comments for ENABLE_CHECK_HEAVY_BUILDS --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e765ca02a4f..972c47fe666 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ include (cmake/find/ccache.cmake) # ccache ignore it. option(ENABLE_CHECK_HEAVY_BUILDS "Don't allow C++ translation units to compile too long or to take too much memory while compiling." OFF) if (ENABLE_CHECK_HEAVY_BUILDS) - # set DATA (since RSS does not work since 2.6.x+) to 2G + # set DATA (since RSS does not work since 2.6.x+) to 5G set (RLIMIT_DATA 5000000000) # set VIRT (RLIMIT_AS) to 10G (DATA*10) set (RLIMIT_AS 10000000000) @@ -89,7 +89,7 @@ if (ENABLE_CHECK_HEAVY_BUILDS) # gcc10/gcc10/clang -fsanitize=memory is too heavy if (SANITIZE STREQUAL "memory" OR COMPILER_GCC) - set (RLIMIT_DATA 10000000000) + set (RLIMIT_DATA 10000000000) # 10G endif() set (CMAKE_CXX_COMPILER_LAUNCHER prlimit --as=${RLIMIT_AS} --data=${RLIMIT_DATA} --cpu=${RLIMIT_CPU} ${CMAKE_CXX_COMPILER_LAUNCHER}) From 1ec0295c6f35480f64903853acb97401221c4c1b Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 10 Sep 2021 08:51:43 +0300 Subject: [PATCH 083/102] Increase RLIMIT_CPU for ENABLE_CHECK_HEAVY_BUILDS to fix UBsan build Right now CI fails to compile UBsan while trying to compile src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionSumMap.cpp.o: 2021-09-09 23:02:28 FAILED: src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionSumMap.cpp.o 2021-09-09 23:02:28 prlimit --as=10000000000 --data=5000000000 --cpu=600 /usr/bin/ccache /usr/bin/clang++-12 -DAWS_SDK_VERSION_MAJOR=1 -DAWS_SDK_VERSION_MINOR=7 -DAWS_SDK_VERSION_PATCH=231 -DBOOST_ASIO_STANDALONE=1 -DCARES_STATICLIB -DENABLE_OPENSSL_ENCRYPTION -DPOCO_ENABLE_CPP11 -DPOCO_HAVE_FD_EPOLL -DPOCO_OS_FAMILY_UNIX -DSTD_EXCEPTION_HAS_STACK_TRACE=1 -DUNALIGNED_OK -DUSE_REPLXX=1 -DWITH_COVERAGE=0 -DWITH_GZFILEOP -DX86_64 -DZLIB_COMPAT -DZ_TLS=__thread -D__CLANG_SUPPORT_DYN_ANNOTATION__ -I../contrib/sentry-native/include -Iincludes/configs -I../base/glibc-compatibility/memcpy -I../src -Isrc -Isrc/Core/include -I../base/common/.. -Ibase/common/.. -I../contrib/cityhash102/include -I../contrib/cctz/include -Icontrib/zlib-ng -I../contrib/zlib-ng -I../base/pcg-random/. -I../contrib/aws-c-common/include -I../contrib/aws-c-event-stream/include -Icontrib/aws-s3-cmake/include -I../base/mysqlxx/.. -I../contrib/mariadb-connector-c/include -Icontrib/mariadb-connector-c/include -Icontrib/grpc/third_party/cares/cares -I../contrib/grpc/third_party/cares/cares -I../contrib/abseil-cpp -I../contrib/libpq -I../contrib/libpq/include -I../contrib/libstemmer_c/include -I../contrib/wordnet-blast -I../contrib/lemmagen-c/include -isystem ../contrib/datasketches-cpp/common/include -isystem ../contrib/datasketches-cpp/theta/include -isystem ../contrib/libcxx/include -isystem ../contrib/libcxxabi/include -isystem ../contrib/libunwind/include -isystem ../contrib/libpqxx/include -isystem ../contrib/rocksdb/include -isystem ../contrib/orc/c++/include -isystem contrib/orc/c++/include -isystem ../contrib/AMQP-CPP/include -isystem ../contrib/libuv/include -isystem ../contrib/AMQP-CPP -isystem ../contrib/s2geometry/src/s2 -isystem ../contrib/libhdfs3/include -isystem ../contrib/miniselect/include -isystem ../contrib/pdqsort -isystem ../contrib/croaring/cpp -isystem ../contrib/croaring/include -isystem ../contrib/fast_float/include -isystem ../contrib/msgpack-c/include -isystem ../contrib/aws/aws-cpp-sdk-s3/include -isystem ../contrib/aws/aws-cpp-sdk-core/include -isystem ../contrib/xz/src/liblzma/api -isystem ../contrib/zstd/lib -isystem ../contrib/re2 -isystem ../contrib/boost -isystem ../contrib/poco/Net/include -isystem ../contrib/poco/Foundation/include -isystem ../contrib/poco/NetSSL_OpenSSL/include -isystem ../contrib/poco/Crypto/include -isystem ../contrib/boringssl/include -isystem ../contrib/poco/Util/include -isystem ../contrib/poco/JSON/include -isystem ../contrib/poco/XML/include -isystem ../contrib/replxx/include -isystem ../contrib/fmtlib-cmake/../fmtlib/include -isystem ../contrib/double-conversion -isystem ../contrib/dragonbox/include -isystem contrib/re2_st -isystem ../contrib/NuRaft/include -isystem ../contrib/grpc/include -isystem ../contrib/protobuf/src -isystem src/Server/grpc_protos -isystem ../contrib/s2geometry/src -isystem ../contrib/sqlite-amalgamation -isystem ../contrib/libc-headers/x86_64-linux-gnu -isystem ../contrib/libc-headers -g -O2 -fdebug-prefix-map=/build=. -specs=/usr/share/dpkg/no-pie-compile.specs -Wdate-time -g -fno-omit-frame-pointer -DSANITIZER -fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=float-divide-by-zero -fsanitize-blacklist=/build/tests/ubsan_suppressions.txt -fdiagnostics-color=always -Xclang -fuse-ctor-homing -fsized-deallocation -gdwarf-aranges -pipe -mssse3 -msse4.1 -msse4.2 -mpclmul -mpopcnt -fasynchronous-unwind-tables -falign-functions=32 -Wall -Wno-unused-command-line-argument -fdiagnostics-absolute-paths -fexperimental-new-pass-manager -Werror -Wextra -Wpedantic -Wno-vla-extension -Wno-zero-length-array -Wno-c11-extensions -Wcomma -Wconditional-uninitialized -Wcovered-switch-default -Wdeprecated -Wembedded-directive -Wempty-init-stmt -Wextra-semi-stmt -Wextra-semi -Wgnu-case-range -Winconsistent-missing-destructor-override -Wnewline-eof -Wold-style-cast -Wrange-loop-analysis -Wredundant-parens -Wreserved-id-macro -Wshadow-field -Wshadow-uncaptured-local -Wshadow -Wstring-plus-int -Wundef -Wunreachable-code-return -Wunreachable-code -Wunused-exception-parameter -Wunused-macros -Wunused-member-function -Wzero-as-null-pointer-constant -Weverything -Wno-c++98-compat-pedantic -Wno-c++98-compat -Wno-c99-extensions -Wno-conversion -Wno-ctad-maybe-unsupported -Wno-deprecated-dynamic-exception-spec -Wno-disabled-macro-expansion -Wno-documentation-unknown-command -Wno-double-promotion -Wno-exit-time-destructors -Wno-float-equal -Wno-global-constructors -Wno-missing-prototypes -Wno-missing-variable-declarations -Wno-nested-anon-types -Wno-packed -Wno-padded -Wno-return-std-move-in-c++11 -Wno-shift-sign-overflow -Wno-sign-conversion -Wno-switch-enum -Wno-undefined-func-template -Wno-unused-template -Wno-vla -Wno-weak-template-vtables -Wno-weak-vtables -O2 -g -DNDEBUG -O3 -fno-pie -D OS_LINUX -nostdinc++ -std=gnu++2a -MD -MT src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionSumMap.cpp.o -MF src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionSumMap.cpp.o.d -o src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionSumMap.cpp.o -c ../src/AggregateFunctions/AggregateFunctionSumMap.cpp I guess the problem is CPU time, since looks like memory is fine (I cannot reproduce it right now locally, maybe because I have clang-11). --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 972c47fe666..ddb7c85d539 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,8 +84,8 @@ if (ENABLE_CHECK_HEAVY_BUILDS) set (RLIMIT_DATA 5000000000) # set VIRT (RLIMIT_AS) to 10G (DATA*10) set (RLIMIT_AS 10000000000) - # set CPU time limit to 600 seconds - set (RLIMIT_CPU 600) + # set CPU time limit to 800 seconds + set (RLIMIT_CPU 800) # gcc10/gcc10/clang -fsanitize=memory is too heavy if (SANITIZE STREQUAL "memory" OR COMPILER_GCC) From 27cd75eaa17db73ee4754debe1b51ed5ba613b21 Mon Sep 17 00:00:00 2001 From: Vladimir C Date: Fri, 10 Sep 2021 09:31:49 +0300 Subject: [PATCH 084/102] Apply suggestions from code review --- docs/en/sql-reference/table-functions/s3.md | 2 +- docs/ru/sql-reference/table-functions/s3.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/sql-reference/table-functions/s3.md b/docs/en/sql-reference/table-functions/s3.md index a0176f0151c..ffba8f5c6d3 100644 --- a/docs/en/sql-reference/table-functions/s3.md +++ b/docs/en/sql-reference/table-functions/s3.md @@ -131,7 +131,7 @@ If you specify `PARTITION BY` expression when inserting data into `S3` table, a **Examples** -1. Using partition ID in a file name creates separate files: +1. Using partition ID in a key creates separate files: ```sql INSERT INTO TABLE FUNCTION diff --git a/docs/ru/sql-reference/table-functions/s3.md b/docs/ru/sql-reference/table-functions/s3.md index a4e6151d711..c8dbcf81559 100644 --- a/docs/ru/sql-reference/table-functions/s3.md +++ b/docs/ru/sql-reference/table-functions/s3.md @@ -135,11 +135,11 @@ SELECT name, value FROM existing_table; ## Партиционирование при записи данных {#partitioned-write} -Если при добавлении данных в таблицу S3 указать выражение `PARTITION BY`, то для каждого значения выражения партиционирования создается отдельный файл. Это повышает эффективность операций чтения. +Если при добавлении данных в таблицу S3 указать выражение `PARTITION BY`, то для каждого значения ключа партиционирования создается отдельный файл. Это повышает эффективность операций чтения. **Примеры** -1. При использовании ID партиции в названии файла создаются отдельные файлы: +1. При использовании ID партиции в имени ключа создаются отдельные файлы: ```sql INSERT INTO TABLE FUNCTION From 0b37de02e069086f16cc56e012ee97066388f197 Mon Sep 17 00:00:00 2001 From: Maksim Kita Date: Fri, 10 Sep 2021 12:47:12 +0300 Subject: [PATCH 085/102] Fixed tests --- src/Dictionaries/ExecutableDictionarySource.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dictionaries/ExecutableDictionarySource.cpp b/src/Dictionaries/ExecutableDictionarySource.cpp index ba624f8e2a2..06ded2d3bd3 100644 --- a/src/Dictionaries/ExecutableDictionarySource.cpp +++ b/src/Dictionaries/ExecutableDictionarySource.cpp @@ -196,7 +196,7 @@ void registerDictionarySourceExecutable(DictionarySourceFactory & factory) .update_field = config.getString(settings_config_prefix + ".update_field", ""), .update_lag = config.getUInt64(settings_config_prefix + ".update_lag", 1), .implicit_key = config.getBool(settings_config_prefix + ".implicit_key", false), - .send_chunk_header = config.getBool(settings_config_prefix + ".implicit_key", false) + .send_chunk_header = config.getBool(settings_config_prefix + ".send_chunk_header", false) }; return std::make_unique(dict_struct, configuration, sample_block, context); From af5072db5067dd87164188bdcf47d9773fb10461 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 9 Sep 2021 23:39:37 +0300 Subject: [PATCH 086/102] client: print full query in case of test hints failures --- programs/client/Client.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/programs/client/Client.cpp b/programs/client/Client.cpp index 87ae03161a9..58fc80ef958 100644 --- a/programs/client/Client.cpp +++ b/programs/client/Client.cpp @@ -1244,13 +1244,17 @@ private: if (!server_exception) { error_matches_hint = false; - fmt::print(stderr, "Expected server error code '{}' but got no server error.\n", test_hint.serverError()); + fmt::print(stderr, "Expected server error code '{}' but got no server error (query: {}).\n", + test_hint.serverError(), + full_query); } else if (server_exception->code() != test_hint.serverError()) { error_matches_hint = false; - std::cerr << "Expected server error code: " << test_hint.serverError() << " but got: " << server_exception->code() - << "." << std::endl; + fmt::print(stderr, "Expected server error code: {} but got: {} (query: {}).\n", + test_hint.serverError(), + server_exception->code(), + full_query); } } @@ -1259,13 +1263,17 @@ private: if (!client_exception) { error_matches_hint = false; - fmt::print(stderr, "Expected client error code '{}' but got no client error.\n", test_hint.clientError()); + fmt::print(stderr, "Expected client error code '{}' but got no client error (query: {}).\n", + test_hint.clientError(), + full_query); } else if (client_exception->code() != test_hint.clientError()) { error_matches_hint = false; - fmt::print( - stderr, "Expected client error code '{}' but got '{}'.\n", test_hint.clientError(), client_exception->code()); + fmt::print(stderr, "Expected client error code '{}' but got '{}' (query: {}).\n", + test_hint.clientError(), + client_exception->code(), + full_query); } } @@ -1281,13 +1289,17 @@ private: { if (test_hint.clientError()) { - fmt::print(stderr, "The query succeeded but the client error '{}' was expected.\n", test_hint.clientError()); + fmt::print(stderr, "The query succeeded but the client error '{}' was expected (query: {}).\n", + test_hint.clientError(), + full_query); error_matches_hint = false; } if (test_hint.serverError()) { - fmt::print(stderr, "The query succeeded but the server error '{}' was expected.\n", test_hint.serverError()); + fmt::print(stderr, "The query succeeded but the server error '{}' was expected (query: {}).\n", + test_hint.serverError(), + full_query); error_matches_hint = false; } } From f0f31ab8f39a11670f87a54e86869831d8d4aab2 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 9 Sep 2021 23:53:24 +0300 Subject: [PATCH 087/102] client: print full query in case of server exception --- programs/client/Client.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/programs/client/Client.cpp b/programs/client/Client.cpp index 58fc80ef958..4e59cca2024 100644 --- a/programs/client/Client.cpp +++ b/programs/client/Client.cpp @@ -1031,10 +1031,17 @@ private: if (server_exception) { bool print_stack_trace = config().getBool("stacktrace", false); - std::cerr << "Received exception from server (version " << server_version << "):" << std::endl - << getExceptionMessage(*server_exception, print_stack_trace, true) << std::endl; + fmt::print(stderr, "Received exception from server (version {}):\n{}\n", + server_version, + getExceptionMessage(*server_exception, print_stack_trace, true)); if (is_interactive) - std::cerr << std::endl; + { + fmt::print(stderr, "\n"); + } + else + { + fmt::print(stderr, "(query: {})\n", full_query); + } } if (client_exception) From 09f43d21a843d10cd0d8f0e5430ac083598714e3 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 10 Sep 2021 00:02:04 +0300 Subject: [PATCH 088/102] client: print query on client exception only in non-interactive mode --- programs/client/Client.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/programs/client/Client.cpp b/programs/client/Client.cpp index 4e59cca2024..c594f01861b 100644 --- a/programs/client/Client.cpp +++ b/programs/client/Client.cpp @@ -1046,11 +1046,15 @@ private: if (client_exception) { - fmt::print(stderr, "Error on processing query '{}':\n{}\n", full_query, client_exception->message()); + fmt::print(stderr, "Error on processing query: {}\n", client_exception->message()); if (is_interactive) { fmt::print(stderr, "\n"); } + else + { + fmt::print(stderr, "(query: {})\n", full_query); + } } // A debug check -- at least some exception must be set, if the error From c4a24c7696ce5a70aaa8cf5ec1702a305710e54d Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 10 Sep 2021 21:02:31 +0300 Subject: [PATCH 089/102] tests: update reference after client started printing query --- tests/queries/0_stateless/00602_throw_if.sh | 2 +- tests/queries/0_stateless/00763_lock_buffer.sh | 2 +- .../0_stateless/00956_sensitive_data_masking.sh | 6 +++--- tests/queries/0_stateless/01150_ddl_guard_rwr.sh | 12 ++++++------ .../queries/0_stateless/01529_bad_memory_tracking.sh | 3 ++- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/queries/0_stateless/00602_throw_if.sh b/tests/queries/0_stateless/00602_throw_if.sh index fe8feab0303..1e8850028c4 100755 --- a/tests/queries/0_stateless/00602_throw_if.sh +++ b/tests/queries/0_stateless/00602_throw_if.sh @@ -8,5 +8,5 @@ default_exception_message="Value passed to 'throwIf' function is non zero" custom_exception_message="Number equals 1000000" ${CLICKHOUSE_CLIENT} --server_logs_file /dev/null --query="SELECT throwIf(number = 1000000) FROM system.numbers" 2>&1 | grep -cF "$default_exception_message" -${CLICKHOUSE_CLIENT} --server_logs_file /dev/null --query="SELECT throwIf(number = 1000000, '$custom_exception_message') FROM system.numbers" 2>&1 | grep -cF "$custom_exception_message" +${CLICKHOUSE_CLIENT} --server_logs_file /dev/null --query="SELECT throwIf(number = 1000000, '$custom_exception_message') FROM system.numbers" 2>&1 | grep -v '^(query: ' | grep -cF "$custom_exception_message" ${CLICKHOUSE_CLIENT} --server_logs_file /dev/null --query="SELECT sum(x = 0) FROM (SELECT throwIf(number = 1000000) AS x FROM numbers(1000000))" 2>&1 diff --git a/tests/queries/0_stateless/00763_lock_buffer.sh b/tests/queries/0_stateless/00763_lock_buffer.sh index 44660035208..363e3803983 100755 --- a/tests/queries/0_stateless/00763_lock_buffer.sh +++ b/tests/queries/0_stateless/00763_lock_buffer.sh @@ -18,7 +18,7 @@ function thread1() function thread2() { - seq 1 1000 | sed -r -e 's/.+/SELECT count() FROM buffer_00763_2;/' | ${CLICKHOUSE_CLIENT} --multiquery --server_logs_file='/dev/null' --ignore-error 2>&1 | grep -vP '^0$|^10$|^Received exception|^Code: 60|^Code: 218|^Code: 473' + seq 1 1000 | sed -r -e 's/.+/SELECT count() FROM buffer_00763_2;/' | ${CLICKHOUSE_CLIENT} --multiquery --server_logs_file='/dev/null' --ignore-error 2>&1 | grep -vP '^0$|^10$|^Received exception|^Code: 60|^Code: 218|^Code: 473' | grep -v '(query: ' } thread1 & diff --git a/tests/queries/0_stateless/00956_sensitive_data_masking.sh b/tests/queries/0_stateless/00956_sensitive_data_masking.sh index 7462dfd5585..e7179e1e002 100755 --- a/tests/queries/0_stateless/00956_sensitive_data_masking.sh +++ b/tests/queries/0_stateless/00956_sensitive_data_masking.sh @@ -37,7 +37,7 @@ echo 3 # failure at before query start $CLICKHOUSE_CLIENT \ --query="SELECT 'find_me_TOPSECRET=TOPSECRET' FROM non_existing_table FORMAT Null" \ - --log_queries=1 --ignore-error --multiquery >"$tmp_file" 2>&1 + --log_queries=1 --ignore-error --multiquery |& grep -v '^(query: ' > "$tmp_file" grep -F 'find_me_[hidden]' "$tmp_file" >/dev/null || echo 'fail 3a' grep -F 'TOPSECRET' "$tmp_file" && echo 'fail 3b' @@ -47,7 +47,7 @@ echo 4 # failure at the end of query $CLICKHOUSE_CLIENT \ --query="SELECT 'find_me_TOPSECRET=TOPSECRET', intDiv( 100, number - 10) FROM numbers(11) FORMAT Null" \ - --log_queries=1 --ignore-error --max_block_size=2 --multiquery >"$tmp_file" 2>&1 + --log_queries=1 --ignore-error --max_block_size=2 --multiquery |& grep -v '^(query: ' > "$tmp_file" grep -F 'find_me_[hidden]' "$tmp_file" >/dev/null || echo 'fail 4a' grep -F 'TOPSECRET' "$tmp_file" && echo 'fail 4b' @@ -57,7 +57,7 @@ echo 5 rm -f "$tmp_file2" >/dev/null 2>&1 bash -c "$CLICKHOUSE_CLIENT \ --query=\"select sleepEachRow(1) from numbers(10) where ignore('find_me_TOPSECRET=TOPSECRET')=0 and ignore('fwerkh_that_magic_string_make_me_unique') = 0 FORMAT Null\" \ - --log_queries=1 --ignore-error --multiquery >$tmp_file2 2>&1" & + --log_queries=1 --ignore-error --multiquery |& grep -v '^(query: ' > $tmp_file2" & rm -f "$tmp_file" >/dev/null 2>&1 # check that executing query doesn't expose secrets in processlist diff --git a/tests/queries/0_stateless/01150_ddl_guard_rwr.sh b/tests/queries/0_stateless/01150_ddl_guard_rwr.sh index 6355f790e23..27c9ba55858 100755 --- a/tests/queries/0_stateless/01150_ddl_guard_rwr.sh +++ b/tests/queries/0_stateless/01150_ddl_guard_rwr.sh @@ -14,20 +14,20 @@ $CLICKHOUSE_CLIENT --query "CREATE TABLE test_01150.t2 (x UInt64, s Array(Nullab function thread_detach_attach { while true; do - $CLICKHOUSE_CLIENT --query "DETACH DATABASE test_01150" 2>&1 | grep -v -F 'Received exception from server' | grep -v -P 'Code: (219)' + $CLICKHOUSE_CLIENT --query "DETACH DATABASE test_01150" 2>&1 | grep -v -F -e 'Received exception from server' -e 'Code: (219)' -e '(query: ' sleep 0.0$RANDOM - $CLICKHOUSE_CLIENT --query "ATTACH DATABASE test_01150" 2>&1 | grep -v -F 'Received exception from server' | grep -v -P 'Code: (82)' + $CLICKHOUSE_CLIENT --query "ATTACH DATABASE test_01150" 2>&1 | grep -v -F -e 'Received exception from server' -e 'Code: (219)' -e '(query: ' sleep 0.0$RANDOM done } function thread_rename { while true; do - $CLICKHOUSE_CLIENT --query "RENAME TABLE test_01150.t1 TO test_01150.t2_tmp, test_01150.t2 TO test_01150.t1, test_01150.t2_tmp TO test_01150.t2" 2>&1 | grep -v -F 'Received exception from server' | grep -v -P 'Code: (81|60|57|521)' + $CLICKHOUSE_CLIENT --query "RENAME TABLE test_01150.t1 TO test_01150.t2_tmp, test_01150.t2 TO test_01150.t1, test_01150.t2_tmp TO test_01150.t2" 2>&1 | grep -v -F -e 'Received exception from server' -e '(query: ' | grep -v -P 'Code: (81|60|57|521)' sleep 0.0$RANDOM - $CLICKHOUSE_CLIENT --query "RENAME TABLE test_01150.t2 TO test_01150.t1, test_01150.t2_tmp TO test_01150.t2" 2>&1 | grep -v -F 'Received exception from server' | grep -v -P 'Code: (81|60|57|521)' + $CLICKHOUSE_CLIENT --query "RENAME TABLE test_01150.t2 TO test_01150.t1, test_01150.t2_tmp TO test_01150.t2" 2>&1 | grep -v -F -e 'Received exception from server' -e '(query: ' | grep -v -P 'Code: (81|60|57|521)' sleep 0.0$RANDOM - $CLICKHOUSE_CLIENT --query "RENAME TABLE test_01150.t2_tmp TO test_01150.t2" 2>&1 | grep -v -F 'Received exception from server' | grep -v -P 'Code: (81|60|57|521)' + $CLICKHOUSE_CLIENT --query "RENAME TABLE test_01150.t2_tmp TO test_01150.t2" 2>&1 | grep -v -F -e 'Received exception from server' -e '(query: ' | grep -v -P 'Code: (81|60|57|521)' sleep 0.0$RANDOM done } @@ -42,4 +42,4 @@ sleep 1 $CLICKHOUSE_CLIENT --query "DETACH DATABASE IF EXISTS test_01150" $CLICKHOUSE_CLIENT --query "ATTACH DATABASE IF NOT EXISTS test_01150" -$CLICKHOUSE_CLIENT --query "DROP DATABASE test_01150"; +$CLICKHOUSE_CLIENT --query "DROP DATABASE test_01150" diff --git a/tests/queries/0_stateless/01529_bad_memory_tracking.sh b/tests/queries/0_stateless/01529_bad_memory_tracking.sh index 5ad2535074a..6f614d8329f 100755 --- a/tests/queries/0_stateless/01529_bad_memory_tracking.sh +++ b/tests/queries/0_stateless/01529_bad_memory_tracking.sh @@ -7,5 +7,6 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) . "$CURDIR"/../shell_config.sh for _ in {1..10}; do - ${CLICKHOUSE_CLIENT} --max_memory_usage '10G' --query "SELECT i FROM generateRandom('i Array(Int8)', 1, 1, 1048577) LIMIT 65536" 2>&1 | grep -v -P '^(Received exception from server|Code: 241)' ||: + ${CLICKHOUSE_CLIENT} --max_memory_usage '10G' --query "SELECT i FROM generateRandom('i Array(Int8)', 1, 1, 1048577) LIMIT 65536" |& grep -v -e 'Received exception from server' -e 'Code: 241' -e '(query: ' done +exit 0 From 60df1e880029120221fd1be20ff9db8294dec188 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 10 Sep 2021 00:10:25 +0300 Subject: [PATCH 090/102] Relax nested function for If-combinator check Second If combinator can be useful to add condition based on another column, when Merge combinator is applied for example (i.e. uniqCombinedIfMergeIf(state_of_merge_that_is_stored_in_table, event_date = today())). --- src/AggregateFunctions/AggregateFunctionIf.cpp | 4 ---- .../0_stateless/02001_select_with_filter.reference | 2 ++ tests/queries/0_stateless/02001_select_with_filter.sql | 3 ++- .../02025_nested_func_for_if_combinator.reference | 9 +++++++++ .../0_stateless/02025_nested_func_for_if_combinator.sql | 7 +++++++ 5 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 tests/queries/0_stateless/02025_nested_func_for_if_combinator.reference create mode 100644 tests/queries/0_stateless/02025_nested_func_for_if_combinator.sql diff --git a/src/AggregateFunctions/AggregateFunctionIf.cpp b/src/AggregateFunctions/AggregateFunctionIf.cpp index 5082952f386..4ed4b5552e0 100644 --- a/src/AggregateFunctions/AggregateFunctionIf.cpp +++ b/src/AggregateFunctions/AggregateFunctionIf.cpp @@ -37,10 +37,6 @@ public: const DataTypes & arguments, const Array & params) const override { - if (nested_function->getName().find(getName()) != String::npos) - { - throw Exception(ErrorCodes::ILLEGAL_AGGREGATION, "nested function for {0}-combinator must not have {0}-combinator", getName()); - } return std::make_shared(nested_function, arguments, params); } }; diff --git a/tests/queries/0_stateless/02001_select_with_filter.reference b/tests/queries/0_stateless/02001_select_with_filter.reference index 9d104af5e8c..92af7d1d38f 100644 --- a/tests/queries/0_stateless/02001_select_with_filter.reference +++ b/tests/queries/0_stateless/02001_select_with_filter.reference @@ -1,2 +1,4 @@ 98 2450 +\N +2500 diff --git a/tests/queries/0_stateless/02001_select_with_filter.sql b/tests/queries/0_stateless/02001_select_with_filter.sql index 4d10f86ed96..70152db83f8 100644 --- a/tests/queries/0_stateless/02001_select_with_filter.sql +++ b/tests/queries/0_stateless/02001_select_with_filter.sql @@ -1,3 +1,4 @@ SELECT argMax(number, number + 1) FILTER(WHERE number != 99) FROM numbers(100) ; SELECT sum(number) FILTER(WHERE number % 2 == 0) FROM numbers(100); -SELECT sumIfOrNull(number, number % 2 == 1) FILTER(WHERE number % 2 == 0) FROM numbers(100); -- { serverError 184 } +SELECT sumIfOrNull(number, number % 2 == 1) FILTER(WHERE 0) FROM numbers(100); +SELECT sumIfOrNull(number, number % 2 == 1) FILTER(WHERE 1) FROM numbers(100); diff --git a/tests/queries/0_stateless/02025_nested_func_for_if_combinator.reference b/tests/queries/0_stateless/02025_nested_func_for_if_combinator.reference new file mode 100644 index 00000000000..292da6c5525 --- /dev/null +++ b/tests/queries/0_stateless/02025_nested_func_for_if_combinator.reference @@ -0,0 +1,9 @@ +-- { echo } +SELECT uniqCombinedIfMerge(n) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); +5 +SELECT uniqCombinedIfMergeIf(n, last > 50) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); +0 +SELECT uniqCombinedIfMergeIf(n, last > 50) FILTER(WHERE last>50) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); +0 +SELECT uniqCombinedIfMergeIf(n, last > 5) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); +5 diff --git a/tests/queries/0_stateless/02025_nested_func_for_if_combinator.sql b/tests/queries/0_stateless/02025_nested_func_for_if_combinator.sql new file mode 100644 index 00000000000..0b5bb54b121 --- /dev/null +++ b/tests/queries/0_stateless/02025_nested_func_for_if_combinator.sql @@ -0,0 +1,7 @@ +-- { echo } +SELECT uniqCombinedIfMerge(n) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); +SELECT uniqCombinedIfMergeIf(n, last > 50) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); +SELECT uniqCombinedIfMergeIf(n, last > 50) FILTER(WHERE last>50) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); +SELECT uniqCombinedIfMergeIf(n, last > 5) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); +SELECT uniqCombinedIfMergeIfIf(n, last > 5) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT } +SELECT uniqCombinedIfMergeIfIf(n, last > 5, 1) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); -- { serverError ILLEGAL_AGGREGATION } From 1e7714d56d21ed8a225c59d0ce3e0c013e356bf6 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 10 Sep 2021 00:10:25 +0300 Subject: [PATCH 091/102] Forbid nested identical (only) combinators Nested identical combinators (i.e. uniqCombinedIfIf) is not supported (since they even don't work -- silently). But non-identical does supported and works, for example uniqCombinedIfMergeIf, it is useful in case when the underlying storage stores AggregateFunction(uniqCombinedIf) and in SELECT you need to filter aggregation result based on another column for example. --- .../AggregateFunctionFactory.cpp | 24 ++++++++++++++++--- ...25_nested_func_for_if_combinator.reference | 5 +++- .../02025_nested_func_for_if_combinator.sql | 5 ++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/AggregateFunctions/AggregateFunctionFactory.cpp b/src/AggregateFunctions/AggregateFunctionFactory.cpp index c9dcdb54424..d295fb1e85a 100644 --- a/src/AggregateFunctions/AggregateFunctionFactory.cpp +++ b/src/AggregateFunctions/AggregateFunctionFactory.cpp @@ -29,6 +29,7 @@ namespace ErrorCodes { extern const int UNKNOWN_AGGREGATE_FUNCTION; extern const int LOGICAL_ERROR; + extern const int ILLEGAL_AGGREGATION; } const String & getAggregateFunctionCanonicalNameIfAny(const String & name) @@ -159,13 +160,30 @@ AggregateFunctionPtr AggregateFunctionFactory::getImpl( if (AggregateFunctionCombinatorPtr combinator = AggregateFunctionCombinatorFactory::instance().tryFindSuffix(name)) { + const std::string & combinator_name = combinator->getName(); + if (combinator->isForInternalUsageOnly()) - throw Exception("Aggregate function combinator '" + combinator->getName() + "' is only for internal usage", ErrorCodes::UNKNOWN_AGGREGATE_FUNCTION); + throw Exception(ErrorCodes::UNKNOWN_AGGREGATE_FUNCTION, + "Aggregate function combinator '{}' is only for internal usage", + combinator_name); if (query_context && query_context->getSettingsRef().log_queries) - query_context->addQueryFactoriesInfo(Context::QueryLogFactories::AggregateFunctionCombinator, combinator->getName()); + query_context->addQueryFactoriesInfo(Context::QueryLogFactories::AggregateFunctionCombinator, combinator_name); + + String nested_name = name.substr(0, name.size() - combinator_name.size()); + /// Nested identical combinators (i.e. uniqCombinedIfIf) is not + /// supported (since they even don't work -- silently). + /// + /// But non-identical does supported and works, for example + /// uniqCombinedIfMergeIf, it is useful in case when the underlying + /// storage stores AggregateFunction(uniqCombinedIf) and in SELECT you + /// need to filter aggregation result based on another column for + /// example. + if (nested_name.ends_with(combinator_name)) + throw Exception(ErrorCodes::ILLEGAL_AGGREGATION, + "Nested identical combinator '{}' is not supported", + combinator_name); - String nested_name = name.substr(0, name.size() - combinator->getName().size()); DataTypes nested_types = combinator->transformArguments(argument_types); Array nested_parameters = combinator->transformParameters(parameters); diff --git a/tests/queries/0_stateless/02025_nested_func_for_if_combinator.reference b/tests/queries/0_stateless/02025_nested_func_for_if_combinator.reference index 292da6c5525..2b3b5b30715 100644 --- a/tests/queries/0_stateless/02025_nested_func_for_if_combinator.reference +++ b/tests/queries/0_stateless/02025_nested_func_for_if_combinator.reference @@ -3,7 +3,10 @@ SELECT uniqCombinedIfMerge(n) FROM (SELECT uniqCombinedIfState(number, number % 5 SELECT uniqCombinedIfMergeIf(n, last > 50) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); 0 -SELECT uniqCombinedIfMergeIf(n, last > 50) FILTER(WHERE last>50) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); +SELECT uniqCombinedIfMergeIf(n, last > 50) FILTER(WHERE last>50) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); -- { serverError ILLEGAL_AGGREGATION } +SELECT uniqCombinedIfMerge(n) FILTER(WHERE last>50) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); 0 SELECT uniqCombinedIfMergeIf(n, last > 5) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); 5 +SELECT uniqCombinedIfMergeIfIf(n, last > 5) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); -- { serverError ILLEGAL_AGGREGATION } +SELECT uniqCombinedIfMergeIfIf(n, last > 5, 1) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); -- { serverError ILLEGAL_AGGREGATION } diff --git a/tests/queries/0_stateless/02025_nested_func_for_if_combinator.sql b/tests/queries/0_stateless/02025_nested_func_for_if_combinator.sql index 0b5bb54b121..4811023c198 100644 --- a/tests/queries/0_stateless/02025_nested_func_for_if_combinator.sql +++ b/tests/queries/0_stateless/02025_nested_func_for_if_combinator.sql @@ -1,7 +1,8 @@ -- { echo } SELECT uniqCombinedIfMerge(n) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); SELECT uniqCombinedIfMergeIf(n, last > 50) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); -SELECT uniqCombinedIfMergeIf(n, last > 50) FILTER(WHERE last>50) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); +SELECT uniqCombinedIfMergeIf(n, last > 50) FILTER(WHERE last>50) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); -- { serverError ILLEGAL_AGGREGATION } +SELECT uniqCombinedIfMerge(n) FILTER(WHERE last>50) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); SELECT uniqCombinedIfMergeIf(n, last > 5) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); -SELECT uniqCombinedIfMergeIfIf(n, last > 5) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT } +SELECT uniqCombinedIfMergeIfIf(n, last > 5) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); -- { serverError ILLEGAL_AGGREGATION } SELECT uniqCombinedIfMergeIfIf(n, last > 5, 1) FROM (SELECT uniqCombinedIfState(number, number % 2) AS n, max(number) AS last FROM numbers(10)); -- { serverError ILLEGAL_AGGREGATION } From 4e9b2c5d69b6e803d2fe3ee0d96db41e6914e58f Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 10 Sep 2021 21:02:18 +0300 Subject: [PATCH 092/102] Relax ENABLE_CHECK_HEAVY_BUILDS restrictions on systems under pressure (increase RLIMIT_CPU) The problem was with compiling src/AggregateFunctions/AggregateFunctionQuantile.cpp --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddb7c85d539..e0fa6d8e197 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,8 +84,8 @@ if (ENABLE_CHECK_HEAVY_BUILDS) set (RLIMIT_DATA 5000000000) # set VIRT (RLIMIT_AS) to 10G (DATA*10) set (RLIMIT_AS 10000000000) - # set CPU time limit to 800 seconds - set (RLIMIT_CPU 800) + # set CPU time limit to 1000 seconds + set (RLIMIT_CPU 1000) # gcc10/gcc10/clang -fsanitize=memory is too heavy if (SANITIZE STREQUAL "memory" OR COMPILER_GCC) From d8bf2f81ec04cceb1211030807925fe3f7503604 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 10 Sep 2021 21:03:15 +0300 Subject: [PATCH 093/102] Allow Array/OrNull combinators regardless nesting --- .../AggregateFunctionFactory.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/AggregateFunctions/AggregateFunctionFactory.cpp b/src/AggregateFunctions/AggregateFunctionFactory.cpp index d295fb1e85a..875c505df03 100644 --- a/src/AggregateFunctions/AggregateFunctionFactory.cpp +++ b/src/AggregateFunctions/AggregateFunctionFactory.cpp @@ -180,9 +180,21 @@ AggregateFunctionPtr AggregateFunctionFactory::getImpl( /// need to filter aggregation result based on another column for /// example. if (nested_name.ends_with(combinator_name)) - throw Exception(ErrorCodes::ILLEGAL_AGGREGATION, - "Nested identical combinator '{}' is not supported", - combinator_name); + { + /// But the following combinators are allowed regardless nesting: + /// - Array + /// - OrNull (due to aggregate_functions_null_for_empty) + if (combinator_name == "Array" || combinator_name == "OrNull") + { + /// Is supported. + } + else + { + throw Exception(ErrorCodes::ILLEGAL_AGGREGATION, + "Nested identical combinator '{}' is not supported", + combinator_name); + } + } DataTypes nested_types = combinator->transformArguments(argument_types); Array nested_parameters = combinator->transformParameters(parameters); From c362e7c54119e0536aabb9aeb90592e109bdbdd0 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 10 Sep 2021 22:40:13 +0300 Subject: [PATCH 094/102] Introduce IAggregateFunctionCombinator::supportsNesting() --- .../AggregateFunctionArray.cpp | 2 ++ .../AggregateFunctionFactory.cpp | 18 ++++-------------- .../AggregateFunctionOrFill.cpp | 3 +++ .../IAggregateFunctionCombinator.h | 4 ++++ 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/AggregateFunctions/AggregateFunctionArray.cpp b/src/AggregateFunctions/AggregateFunctionArray.cpp index 982180ab50c..3591bea5f9e 100644 --- a/src/AggregateFunctions/AggregateFunctionArray.cpp +++ b/src/AggregateFunctions/AggregateFunctionArray.cpp @@ -21,6 +21,8 @@ class AggregateFunctionCombinatorArray final : public IAggregateFunctionCombinat public: String getName() const override { return "Array"; } + bool supportsNesting() const override { return true; } + DataTypes transformArguments(const DataTypes & arguments) const override { if (arguments.empty()) diff --git a/src/AggregateFunctions/AggregateFunctionFactory.cpp b/src/AggregateFunctions/AggregateFunctionFactory.cpp index 875c505df03..c9a44dba6f2 100644 --- a/src/AggregateFunctions/AggregateFunctionFactory.cpp +++ b/src/AggregateFunctions/AggregateFunctionFactory.cpp @@ -179,21 +179,11 @@ AggregateFunctionPtr AggregateFunctionFactory::getImpl( /// storage stores AggregateFunction(uniqCombinedIf) and in SELECT you /// need to filter aggregation result based on another column for /// example. - if (nested_name.ends_with(combinator_name)) + if (!combinator->supportsNesting() && nested_name.ends_with(combinator_name)) { - /// But the following combinators are allowed regardless nesting: - /// - Array - /// - OrNull (due to aggregate_functions_null_for_empty) - if (combinator_name == "Array" || combinator_name == "OrNull") - { - /// Is supported. - } - else - { - throw Exception(ErrorCodes::ILLEGAL_AGGREGATION, - "Nested identical combinator '{}' is not supported", - combinator_name); - } + throw Exception(ErrorCodes::ILLEGAL_AGGREGATION, + "Nested identical combinator '{}' is not supported", + combinator_name); } DataTypes nested_types = combinator->transformArguments(argument_types); diff --git a/src/AggregateFunctions/AggregateFunctionOrFill.cpp b/src/AggregateFunctions/AggregateFunctionOrFill.cpp index 3ba20e65e32..7aee0289879 100644 --- a/src/AggregateFunctions/AggregateFunctionOrFill.cpp +++ b/src/AggregateFunctions/AggregateFunctionOrFill.cpp @@ -23,6 +23,9 @@ private: public: explicit AggregateFunctionCombinatorOrFill(Kind kind_) : kind(kind_) {} + /// Due to aggregate_functions_null_for_empty + bool supportsNesting() const override { return true; } + String getName() const override { return kind == Kind::OrNull ? "OrNull" : "OrDefault"; diff --git a/src/AggregateFunctions/IAggregateFunctionCombinator.h b/src/AggregateFunctions/IAggregateFunctionCombinator.h index f9953c83a95..37fcfe42c10 100644 --- a/src/AggregateFunctions/IAggregateFunctionCombinator.h +++ b/src/AggregateFunctions/IAggregateFunctionCombinator.h @@ -35,6 +35,10 @@ public: virtual bool isForInternalUsageOnly() const { return false; } + /** Does combinator supports nesting (of itself, i.e. ArrayArray or IfIf) + */ + virtual bool supportsNesting() const { return false; } + /** From the arguments for combined function (ex: UInt64, UInt8 for sumIf), * get the arguments for nested function (ex: UInt64 for sum). * If arguments are not suitable for combined function, throw an exception. From 43360387116674e6a7699d479920a72276e6490b Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 10 Sep 2021 23:14:05 +0300 Subject: [PATCH 095/102] tests: update more references after client started printing query --- .../0_stateless/00336_shard_stack_trace.reference | 4 ++-- .../0_stateless/00921_datetime64_compatibility_long.sh | 2 +- .../01175_distributed_ddl_output_mode_long.reference | 5 +++++ .../0_stateless/01502_log_tinylog_deadlock_race.sh | 8 ++++---- .../01502_long_log_tinylog_deadlock_race.sh | 10 +++++----- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/tests/queries/0_stateless/00336_shard_stack_trace.reference b/tests/queries/0_stateless/00336_shard_stack_trace.reference index ca4011b20db..a956634eefc 100644 --- a/tests/queries/0_stateless/00336_shard_stack_trace.reference +++ b/tests/queries/0_stateless/00336_shard_stack_trace.reference @@ -2,6 +2,6 @@ 1 Ok 1 -2 +3 Ok -2 +3 diff --git a/tests/queries/0_stateless/00921_datetime64_compatibility_long.sh b/tests/queries/0_stateless/00921_datetime64_compatibility_long.sh index 52a29c19be1..df2ac2cece8 100755 --- a/tests/queries/0_stateless/00921_datetime64_compatibility_long.sh +++ b/tests/queries/0_stateless/00921_datetime64_compatibility_long.sh @@ -13,4 +13,4 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) python3 "${CURDIR}"/00921_datetime64_compatibility_long.python \ | ${CLICKHOUSE_CLIENT} --ignore-error -T -nm --calculate_text_stack_trace 0 --log-level 'error' 2>&1 \ - | grep -v 'Received exception .*$' | sed 's/^\(Code: [0-9]\+\).*$/\1/g' + | grep -v -e 'Received exception .*$' -e '^(query: ' | sed 's/^\(Code: [0-9]\+\).*$/\1/g' diff --git a/tests/queries/0_stateless/01175_distributed_ddl_output_mode_long.reference b/tests/queries/0_stateless/01175_distributed_ddl_output_mode_long.reference index 29f6f801044..11c8996c021 100644 --- a/tests/queries/0_stateless/01175_distributed_ddl_output_mode_long.reference +++ b/tests/queries/0_stateless/01175_distributed_ddl_output_mode_long.reference @@ -1,19 +1,24 @@ none Received exception from server: Code: 57. Error: Received from localhost:9000. Error: There was an error on [localhost:9000]: Code: 57. Error: Table default.none already exists. (TABLE_ALREADY_EXISTS) +(query: create table none on cluster test_shard_localhost (n int) engine=Memory;) Received exception from server: Code: 159. Error: Received from localhost:9000. Error: Watching task is executing longer than distributed_ddl_task_timeout (=1) seconds. There are 1 unfinished hosts (0 of them are currently active), they are going to execute the query in background. (TIMEOUT_EXCEEDED) +(query: drop table if exists none on cluster test_unavailable_shard;) throw localhost 9000 0 0 0 Received exception from server: Code: 57. Error: Received from localhost:9000. Error: There was an error on [localhost:9000]: Code: 57. Error: Table default.throw already exists. (TABLE_ALREADY_EXISTS) +(query: create table throw on cluster test_shard_localhost (n int) engine=Memory format Null;) localhost 9000 0 1 0 Received exception from server: Code: 159. Error: Received from localhost:9000. Error: Watching task is executing longer than distributed_ddl_task_timeout (=1) seconds. There are 1 unfinished hosts (0 of them are currently active), they are going to execute the query in background. (TIMEOUT_EXCEEDED) +(query: drop table if exists throw on cluster test_unavailable_shard;) null_status_on_timeout localhost 9000 0 0 0 Received exception from server: Code: 57. Error: Received from localhost:9000. Error: There was an error on [localhost:9000]: Code: 57. Error: Table default.null_status already exists. (TABLE_ALREADY_EXISTS) +(query: create table null_status on cluster test_shard_localhost (n int) engine=Memory format Null;) localhost 9000 0 1 0 localhost 1 \N \N 1 0 never_throw diff --git a/tests/queries/0_stateless/01502_log_tinylog_deadlock_race.sh b/tests/queries/0_stateless/01502_log_tinylog_deadlock_race.sh index 667a612ff23..8bcb5f8a7e8 100755 --- a/tests/queries/0_stateless/01502_log_tinylog_deadlock_race.sh +++ b/tests/queries/0_stateless/01502_log_tinylog_deadlock_race.sh @@ -25,28 +25,28 @@ function thread_drop { function thread_rename { while true; do - $CLICKHOUSE_CLIENT --query "RENAME TABLE $1 TO $2" 2>&1 | grep -v -F 'Received exception from server' | grep -v -P 'Code: (60|57)' + $CLICKHOUSE_CLIENT --query "RENAME TABLE $1 TO $2" 2>&1 | grep -v -e 'Received exception from server' -e '^(query: ' | grep -v -P 'Code: (60|57)' sleep 0.0$RANDOM done } function thread_select { while true; do - $CLICKHOUSE_CLIENT --query "SELECT * FROM $1 FORMAT Null" 2>&1 | grep -v -F 'Received exception from server' | grep -v -P 'Code: (60|218)' + $CLICKHOUSE_CLIENT --query "SELECT * FROM $1 FORMAT Null" 2>&1 | grep -v -e 'Received exception from server' -e '^(query: ' | grep -v -P 'Code: (60|218)' sleep 0.0$RANDOM done } function thread_insert { while true; do - $CLICKHOUSE_CLIENT --query "INSERT INTO $1 SELECT rand64(1), [toString(rand64(2))] FROM numbers($2)" 2>&1 | grep -v -F 'Received exception from server' | grep -v -P 'Code: (60|218)' + $CLICKHOUSE_CLIENT --query "INSERT INTO $1 SELECT rand64(1), [toString(rand64(2))] FROM numbers($2)" 2>&1 | grep -v -e 'Received exception from server' -e '^(query: '| grep -v -P 'Code: (60|218)' sleep 0.0$RANDOM done } function thread_insert_select { while true; do - $CLICKHOUSE_CLIENT --query "INSERT INTO $1 SELECT * FROM $2" 2>&1 | grep -v -F 'Received exception from server' | grep -v -P 'Code: (60|218)' + $CLICKHOUSE_CLIENT --query "INSERT INTO $1 SELECT * FROM $2" 2>&1 | grep -v -e 'Received exception from server' -e '^(query: ' | grep -v -P 'Code: (60|218)' sleep 0.0$RANDOM done } diff --git a/tests/queries/0_stateless/01502_long_log_tinylog_deadlock_race.sh b/tests/queries/0_stateless/01502_long_log_tinylog_deadlock_race.sh index 9f31fcb6da1..441399a500e 100755 --- a/tests/queries/0_stateless/01502_long_log_tinylog_deadlock_race.sh +++ b/tests/queries/0_stateless/01502_long_log_tinylog_deadlock_race.sh @@ -18,35 +18,35 @@ function thread_create { function thread_drop { while true; do - $CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS $1" 2>&1 | grep -v -F 'Received exception from server' | grep -v -P 'Code: (60|57)' + $CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS $1" 2>&1 | grep -v -e 'Received exception from server' -e '^(query: ' | grep -v -P 'Code: (60|57)' sleep 0.0$RANDOM done } function thread_rename { while true; do - $CLICKHOUSE_CLIENT --query "RENAME TABLE $1 TO $2" 2>&1 | grep -v -F 'Received exception from server' | grep -v -P 'Code: (60|57)' + $CLICKHOUSE_CLIENT --query "RENAME TABLE $1 TO $2" 2>&1 | grep -v -e 'Received exception from server' -e '^(query: ' | grep -v -P 'Code: (60|57)' sleep 0.0$RANDOM done } function thread_select { while true; do - $CLICKHOUSE_CLIENT --query "SELECT * FROM $1 FORMAT Null" 2>&1 | grep -v -F 'Received exception from server' | grep -v -P 'Code: (60|218)' + $CLICKHOUSE_CLIENT --query "SELECT * FROM $1 FORMAT Null" 2>&1 | grep -v -e 'Received exception from server' -e '^(query: ' | grep -v -P 'Code: (60|218)' sleep 0.0$RANDOM done } function thread_insert { while true; do - $CLICKHOUSE_CLIENT --query "INSERT INTO $1 SELECT rand64(1), [toString(rand64(2))] FROM numbers($2)" 2>&1 | grep -v -F 'Received exception from server' | grep -v -P 'Code: (60|218)' + $CLICKHOUSE_CLIENT --query "INSERT INTO $1 SELECT rand64(1), [toString(rand64(2))] FROM numbers($2)" 2>&1 | grep -v -e 'Received exception from server' -e '^(query: ' | grep -v -P 'Code: (60|218)' sleep 0.0$RANDOM done } function thread_insert_select { while true; do - $CLICKHOUSE_CLIENT --query "INSERT INTO $1 SELECT * FROM $2" 2>&1 | grep -v -F 'Received exception from server' | grep -v -P 'Code: (60|218)' + $CLICKHOUSE_CLIENT --query "INSERT INTO $1 SELECT * FROM $2" 2>&1 | grep -v -e 'Received exception from server' -e '^(query: ' | grep -v -P 'Code: (60|218)' sleep 0.0$RANDOM done } From 58266e4ed6db77109e6237ecd2612d34c0b19516 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 10 Sep 2021 23:23:24 +0300 Subject: [PATCH 096/102] tests/queries/0_stateless/01175_distributed_ddl_output_mode_long: use unique tmp file --- .../01175_distributed_ddl_output_mode_long.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/queries/0_stateless/01175_distributed_ddl_output_mode_long.sh b/tests/queries/0_stateless/01175_distributed_ddl_output_mode_long.sh index 483979d00db..319b9928e75 100755 --- a/tests/queries/0_stateless/01175_distributed_ddl_output_mode_long.sh +++ b/tests/queries/0_stateless/01175_distributed_ddl_output_mode_long.sh @@ -6,6 +6,8 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) # shellcheck source=../shell_config.sh . "$CURDIR"/../shell_config.sh +TMP_OUT=$(mktemp "$CURDIR/01175_distributed_ddl_output_mode_long.XXXXXX") +trap 'rm -f ${TMP_OUT:?}' EXIT # We execute a distributed DDL query with timeout 1 to check that one host is unavailable and will time out and other complete successfully. # But sometimes one second is not enough even for healthy host to succeed. Repeat the test in this case. @@ -16,11 +18,11 @@ function run_until_out_contains() for _ in {1..20} do - "$@" > "${CLICKHOUSE_TMP}/out" 2>&1 - if grep -q "$PATTERN" "${CLICKHOUSE_TMP}/out" + "$@" > "$TMP_OUT" 2>&1 + if grep -q "$PATTERN" "$TMP_OUT" then - cat "${CLICKHOUSE_TMP}/out" - break; + cat "$TMP_OUT" + break fi done } From 017dc9fa2a5654fc3d785b2488b056ed15646449 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 11 Sep 2021 00:48:17 +0300 Subject: [PATCH 097/102] Remove unused ILLEGAL_AGGREGATION from AggregateFunctionIf --- src/AggregateFunctions/AggregateFunctionIf.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/AggregateFunctions/AggregateFunctionIf.cpp b/src/AggregateFunctions/AggregateFunctionIf.cpp index 4ed4b5552e0..4ac6a2dce21 100644 --- a/src/AggregateFunctions/AggregateFunctionIf.cpp +++ b/src/AggregateFunctions/AggregateFunctionIf.cpp @@ -10,7 +10,6 @@ namespace ErrorCodes extern const int LOGICAL_ERROR; extern const int ILLEGAL_TYPE_OF_ARGUMENT; extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; - extern const int ILLEGAL_AGGREGATION; } class AggregateFunctionCombinatorIf final : public IAggregateFunctionCombinator From f7540dad5646b9ee9e745b983806069df7e80991 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 11 Sep 2021 09:13:23 +0300 Subject: [PATCH 098/102] tests: update 01305_replica_create_drop_zookeeper after client query printing --- .../queries/0_stateless/01305_replica_create_drop_zookeeper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/queries/0_stateless/01305_replica_create_drop_zookeeper.sh b/tests/queries/0_stateless/01305_replica_create_drop_zookeeper.sh index 6248813c9ba..b7cc7a3bc32 100755 --- a/tests/queries/0_stateless/01305_replica_create_drop_zookeeper.sh +++ b/tests/queries/0_stateless/01305_replica_create_drop_zookeeper.sh @@ -11,7 +11,7 @@ function thread() while true; do $CLICKHOUSE_CLIENT -n -q "DROP TABLE IF EXISTS test_table_$1 SYNC; CREATE TABLE test_table_$1 (a UInt8) ENGINE = ReplicatedMergeTree('/clickhouse/tables/$CLICKHOUSE_TEST_ZOOKEEPER_PREFIX/alter_table', 'r_$1') ORDER BY tuple();" 2>&1 | - grep -vP '(^$)|(^Received exception from server)|(^\d+\. )|because the last replica of the table was dropped right now|is already started to be removing by another replica right now| were removed by another replica|Removing leftovers from table|Another replica was suddenly created|was created by another server at the same moment|was suddenly removed|some other replicas were created at the same time' + grep -vP '(^$)|(^Received exception from server)|(^\d+\. )|because the last replica of the table was dropped right now|is already started to be removing by another replica right now| were removed by another replica|Removing leftovers from table|Another replica was suddenly created|was created by another server at the same moment|was suddenly removed|some other replicas were created at the same time|^\(query: ' done } From c6b9816d45e3e8255eb1aee9b9059dfe7397fdab Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 11 Sep 2021 09:15:38 +0300 Subject: [PATCH 099/102] tests: mark 00763_lock_buffer as long https://clickhouse-test-reports.s3.yandex.net/28827/58266e4ed6db77109e6237ecd2612d34c0b19516/functional_stateless_tests_flaky_check_(address).html#fail1 --- ...763_lock_buffer.reference => 00763_lock_buffer_long.reference} | 0 .../{00763_lock_buffer.sh => 00763_lock_buffer_long.sh} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/queries/0_stateless/{00763_lock_buffer.reference => 00763_lock_buffer_long.reference} (100%) rename tests/queries/0_stateless/{00763_lock_buffer.sh => 00763_lock_buffer_long.sh} (100%) diff --git a/tests/queries/0_stateless/00763_lock_buffer.reference b/tests/queries/0_stateless/00763_lock_buffer_long.reference similarity index 100% rename from tests/queries/0_stateless/00763_lock_buffer.reference rename to tests/queries/0_stateless/00763_lock_buffer_long.reference diff --git a/tests/queries/0_stateless/00763_lock_buffer.sh b/tests/queries/0_stateless/00763_lock_buffer_long.sh similarity index 100% rename from tests/queries/0_stateless/00763_lock_buffer.sh rename to tests/queries/0_stateless/00763_lock_buffer_long.sh From ff17de531c2bb652d88ce5cc9e5821291f5cb70c Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 10 Sep 2021 00:18:52 +0300 Subject: [PATCH 100/102] Join MaterializedMySQLSyncThread only if it is joinable It is possible to trigger MaterializedMySQLSyncThread::stopSynchronization() from the same thread in case of some exception at startup, when some interpreter holds the storage refcnt, and later MaterializedMySQLSyncThread will try to join itself from the main thread. Here is a stack trace for example:
4 0x000000000f7ae45c in Poco::Event::wait (this=0x7f1b90c38170) at ../contrib/poco/Foundation/include/Poco/Event.h:97 5 ThreadFromGlobalPool::join (this=0x7f1b90c23120) at ../src/Common/ThreadPool.h:210 6 DB::MaterializeMySQLSyncThread::stopSynchronization (this=0x7f1b8024ca68) at ../src/Databases/MySQL/MaterializeMySQLSyncThread.cpp:229 7 DB::MaterializeMySQLSyncThread::~MaterializeMySQLSyncThread (this=0x7f1b8024ca68) at ../src/Databases/MySQL/MaterializeMySQLSyncThread.cpp:85 8 0x000000000f816dc8 in DB::DatabaseMaterializeMySQL::~DatabaseMaterializeMySQL (this=0x7f1b8024c918) at ../src/Databases/MySQL/DatabaseMaterializeMySQL.h:21 11 std::__1::shared_ptr::~shared_ptr (this=) at ../contrib/libcxx/include/memory:3212 12 0x000000000f8726a6 in DB::InterpreterCreateQuery::createTable (this=, create=...) at ../src/Interpreters/InterpreterCreateQuery.cpp:952 13 0x000000000f87735c in DB::InterpreterCreateQuery::execute (this=0x7f1aeef59860) at ../src/Interpreters/InterpreterCreateQuery.cpp:1225 14 0x000000000fe22253 in DB::executeQueryImpl (begin=, end=, context=..., internal=true, stage=DB::QueryProcessingStage::Complete, has_query_tail=, istr=) at ../src/Interpreters/executeQuery.cpp:574 15 0x000000000fe208e3 in DB::executeQuery (query=..., context=..., internal=, stage=DB::QueryProcessingStage::FetchColumns, may_have_embedded_data=) at ../src/Interpreters/executeQuery.cpp:933 16 0x000000000faafcde in DB::MySQLInterpreter::InterpreterMySQLDDLQuery::execute (this=) at ../src/Interpreters/MySQL/InterpretersMySQLDDLQuery.h:75 17 0x000000000faade78 in DB::InterpreterExternalDDLQuery::execute (this=) at ../src/Interpreters/InterpreterExternalDDLQuery.cpp:64 18 0x000000000fe22253 in DB::executeQueryImpl (begin=, end=, context=..., internal=true, stage=DB::QueryProcessingStage::Complete, has_query_tail=, istr=) at ../src/Interpreters/executeQuery.cpp:574 19 0x000000000fe208e3 in DB::executeQuery (query=..., context=..., internal=, stage=DB::QueryProcessingStage::FetchColumns, may_have_embedded_data=) at ../src/Interpreters/executeQuery.cpp:933 20 0x000000000f7ba406 in DB::tryToExecuteQuery (query_to_execute=..., query_context=..., database=..., comment=...) at ../src/Databases/MySQL/MaterializeMySQLSyncThread.cpp:69 21 0x000000000f7d4b88 in DB::dumpDataForTables() (connection=..., query_prefix=..., database_name=..., mysql_database_name=..., context=..., is_cancelled=..., need_dumping_tables=...) at ../src/Databases/MySQL/MaterializeMySQLSyncThread.cpp:326 22 DB::MaterializeMySQLSyncThread::prepareSynchronized(DB::MaterializeMetadata&)::$_1::operator()() const (this=) at ../src/Databases/MySQL/MaterializeMySQLSyncThread.cpp:391 29 DB::commitMetadata() (function=..., persistent_tmp_path=..., persistent_path=...) at ../src/Databases/MySQL/MaterializeMetadata.cpp:197 30 0x000000000f80a000 in DB::MaterializeMetadata::transaction(DB::MySQLReplication::Position const&, std::__1::function const&) (this=0x7f1b6375c3d8, position=..., fun=...) at ../src/Databases/MySQL/MaterializeMetadata.cpp:230 31 0x000000000f7b2231 in DB::MaterializeMySQLSyncThread::prepareSynchronized (this=0x7f1b8024ca68, metadata=...) at ../src/Databases/MySQL/MaterializeMySQLSyncThread.cpp:388 32 0x000000000f7b169c in DB::MaterializeMySQLSyncThread::synchronization (this=0x7f1b8024ca68) at ../src/Databases/MySQL/MaterializeMySQLSyncThread.cpp:180 33 0x000000000f7d4074 in DB::MaterializeMySQLSyncThread::startSynchronization()::$_0::operator()() const (this=) at ../src/Databases/MySQL/MaterializeMySQLSyncThread.cpp:236
--- src/Databases/MySQL/MaterializedMySQLSyncThread.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Databases/MySQL/MaterializedMySQLSyncThread.cpp b/src/Databases/MySQL/MaterializedMySQLSyncThread.cpp index 560d2d716c9..5a51704e98b 100644 --- a/src/Databases/MySQL/MaterializedMySQLSyncThread.cpp +++ b/src/Databases/MySQL/MaterializedMySQLSyncThread.cpp @@ -233,7 +233,8 @@ void MaterializedMySQLSyncThread::stopSynchronization() if (!sync_quit && background_thread_pool) { sync_quit = true; - background_thread_pool->join(); + if (background_thread_pool->joinable()) + background_thread_pool->join(); client.disconnect(); } } From 7e084304fbf954f630df786314c028b8c4e4c63d Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 11 Sep 2021 10:03:06 +0300 Subject: [PATCH 101/102] Skip "no data" exception when reading thermal sensors --- src/Interpreters/AsynchronousMetrics.cpp | 6 ++++-- src/Storages/StorageS3Cluster.cpp | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Interpreters/AsynchronousMetrics.cpp b/src/Interpreters/AsynchronousMetrics.cpp index fd02aa4abec..c1e4bb86895 100644 --- a/src/Interpreters/AsynchronousMetrics.cpp +++ b/src/Interpreters/AsynchronousMetrics.cpp @@ -1105,7 +1105,8 @@ void AsynchronousMetrics::update(std::chrono::system_clock::time_point update_ti } catch (...) { - tryLogCurrentException(__PRETTY_FUNCTION__); + if (errno != ENODATA) /// Ok for thermal sensors. + tryLogCurrentException(__PRETTY_FUNCTION__); /// Files maybe re-created on module load/unload try @@ -1144,7 +1145,8 @@ void AsynchronousMetrics::update(std::chrono::system_clock::time_point update_ti } catch (...) { - tryLogCurrentException(__PRETTY_FUNCTION__); + if (errno != ENODATA) /// Ok for thermal sensors. + tryLogCurrentException(__PRETTY_FUNCTION__); /// Files can be re-created on: /// - module load/unload diff --git a/src/Storages/StorageS3Cluster.cpp b/src/Storages/StorageS3Cluster.cpp index ba2ed4c55cd..a278b9d3dec 100644 --- a/src/Storages/StorageS3Cluster.cpp +++ b/src/Storages/StorageS3Cluster.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include From a581603964d25b78ae1140d8d2b694408dd40e84 Mon Sep 17 00:00:00 2001 From: Vladimir C Date: Sat, 11 Sep 2021 10:46:55 +0300 Subject: [PATCH 102/102] Apply suggestions from code review --- docs/en/sql-reference/functions/encoding-functions.md | 2 +- docs/ru/sql-reference/functions/encoding-functions.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/en/sql-reference/functions/encoding-functions.md b/docs/en/sql-reference/functions/encoding-functions.md index 0abf7bb7da9..69dd14da1bf 100644 --- a/docs/en/sql-reference/functions/encoding-functions.md +++ b/docs/en/sql-reference/functions/encoding-functions.md @@ -297,7 +297,7 @@ For a numeric argument `unbin()` does not return the inverse of `bin()`. If you !!! note "Note" If `unbin` is invoked from within the `clickhouse-client`, binary strings are displayed using UTF-8. -Supports binary digits `0-1`. The number of binary digits does not have to be multiples of eight. If the argument string contains anything other than binary digits, some implementation-defined result is returned (an exception isn’t thrown). +Supports binary digits `0` and `1`. The number of binary digits does not have to be multiples of eight. If the argument string contains anything other than binary digits, some implementation-defined result is returned (an exception isn’t thrown). **Arguments** diff --git a/docs/ru/sql-reference/functions/encoding-functions.md b/docs/ru/sql-reference/functions/encoding-functions.md index ad3aa8d87e6..694dfef7d75 100644 --- a/docs/ru/sql-reference/functions/encoding-functions.md +++ b/docs/ru/sql-reference/functions/encoding-functions.md @@ -85,7 +85,7 @@ hex(arg) Функция использует прописные буквы `A-F` и не использует никаких префиксов (например, `0x`) или суффиксов (например, `h`). -Для целочисленных аргументов возвращает шестнадцатеричные цифры ("кусочки") от наиболее значимых до наименее значимых (`big endian` или в порядке, понятному человеку).Он начинается с самого значимого ненулевого байта (начальные нулевые байты опущены), но всегда выводит обе цифры каждого байта, даже если начальная цифра равна нулю. +Для целочисленных аргументов возвращает шестнадцатеричные цифры от наиболее до наименее значимых (`big endian`, человекочитаемый порядок).Он начинается с самого значимого ненулевого байта (начальные нулевые байты опущены), но всегда выводит обе цифры каждого байта, даже если начальная цифра равна нулю. Значения типа [Date](../../sql-reference/data-types/date.md) и [DateTime](../../sql-reference/data-types/datetime.md) формируются как соответствующие целые числа (количество дней с момента Unix-эпохи для `Date` и значение Unix Timestamp для `DateTime`). @@ -216,7 +216,7 @@ bin(arg) Синоним: `BIN`. -Для целочисленных аргументов возвращаются двоичные числа от наиболее значимого до наименее значимого (`big-endian` или в понятном человеку порядке). Порядок начинается с самого значимого ненулевого байта (начальные нулевые байты опущены), но всегда возвращает восемь цифр каждого байта, если начальная цифра равна нулю. +Для целочисленных аргументов возвращаются двоичные числа от наиболее значимого до наименее значимого (`big-endian`, человекочитаемый порядок). Порядок начинается с самого значимого ненулевого байта (начальные нулевые байты опущены), но всегда возвращает восемь цифр каждого байта, если начальная цифра равна нулю. Значения типа [Date](../../sql-reference/data-types/date.md) и [DateTime](../../sql-reference/data-types/datetime.md) формируются как соответствующие целые числа (количество дней с момента Unix-эпохи для `Date` и значение Unix Timestamp для `DateTime`). @@ -297,7 +297,7 @@ unbin(arg) !!! note "Примечание" Если `unbin` вызывается из клиента `clickhouse-client`, бинарная строка возвращается в кодировке UTF-8. -Поддерживает двоичные цифры `0-1`. Количество двоичных цифр не обязательно должно быть кратно восьми. Если строка аргумента содержит что-либо, кроме двоичных цифр, возвращается некоторый результат, определенный реализацией (ошибки не возникает). +Поддерживает двоичные цифры `0` и `1`. Количество двоичных цифр не обязательно должно быть кратно восьми. Если строка аргумента содержит что-либо, кроме двоичных цифр, возвращается некоторый результат, определенный реализацией (ошибки не возникает). **Аргументы**