From 3f527d1d344f2a636ef327a51f639fa0c52a4ca5 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Sat, 24 Oct 2020 00:41:21 +0300 Subject: [PATCH 01/95] Update order-by.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Задокументировал параметры OFFSET и FETCH. --- .../statements/select/order-by.md | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/docs/en/sql-reference/statements/select/order-by.md b/docs/en/sql-reference/statements/select/order-by.md index a4e5e3655c6..4be49fe18d8 100644 --- a/docs/en/sql-reference/statements/select/order-by.md +++ b/docs/en/sql-reference/statements/select/order-by.md @@ -221,3 +221,70 @@ returns │ 1970-03-12 │ 1970-01-08 │ original │ └────────────┴────────────┴──────────┘ ``` + +## OFFSET FETCH Clause {#offset-fetch} + +`OFFSET` and `FETCH` allow you to retrieve just a portion of the rows that are generated by the rest of the query. + +``` sql +OFFSET offset_row_count {ROW | ROWS} FETCH {FIRST | NEXT} fetch_row_count {ROW | ROWS} {ONLY | WITH TIES} +``` + +The `FETCH` is an alternative to the [LIMIT] (https://clickhouse.tech/docs/en/sql-reference/statements/select/limit/#limit-clause) clause and retrieves rows from a query `SELECT` type. + +The `OFFSET` says to skip that many rows before beginning to return rows. + +For example, the following query + +``` sql +SELECT * FROM test_fetch ORDER BY a OFFSET 1 ROW FETCH FIRST 3 ROWS ONLY +``` + +is identical to the query + +``` sql +SELECT * FROM test_fetch ORDER BY a LIMIT 3 OFFSET 1 +``` + +When using `FETCH`, it is important to use an [ORDER BY] (https://clickhouse.tech/docs/en/sql-reference/statements/select/order-by/#select-order-by) clause that constrains the result rows into a unique order. Otherwise, you will get an unpredictable subset of the query's rows. + +`ROW` and `ROWS` as well as `FIRST` and `NEXT` are noise words that don't influence the effects of these conditions. + +The `ONLY` option is used to return rows that immediately follow the rows omitted by the `OFFSET`. + +The `WITH TIES` option is used to return any additional rows that tie for the last place in the result set according to the `ORDER BY` clause. The `ORDER BY` is mandatory in this case. + +!!! note "Note" + According to the standard, the `OFFSET` clause must come before the `FETCH` clause if both are present. + +### Example {#example} + +Input table: + +``` text +┌─a─┬─b─┐ +│ 1 │ 1 │ +│ 2 │ 1 │ +│ 3 │ 4 │ +│ 1 │ 3 │ +│ 5 │ 4 │ +│ 0 │ 6 │ +│ 5 │ 7 │ +└───┴───┘ +``` + +Query: + +``` sql +SELECT * FROM test_fetch ORDER BY a OFFSET 1 ROW FETCH FIRST 3 ROWS ONLY +``` + +Result: + +``` text +┌─a─┬─b─┐ +│ 1 │ 1 │ +│ 1 │ 3 │ +│ 2 │ 1 │ +└───┴───┘ +``` \ No newline at end of file From b6198d2af698d01e7a7f6b27e4bbb00ac72a9349 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Sat, 24 Oct 2020 13:09:53 +0300 Subject: [PATCH 02/95] Update prewhere.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Поправляю битые ссылки. --- docs/en/sql-reference/statements/select/prewhere.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/statements/select/prewhere.md b/docs/en/sql-reference/statements/select/prewhere.md index fc43d1de0a1..2cc66e45610 100644 --- a/docs/en/sql-reference/statements/select/prewhere.md +++ b/docs/en/sql-reference/statements/select/prewhere.md @@ -2,7 +2,7 @@ toc_title: PREWHERE --- -# PREWHERE Clause {#prewhere-clause} +# PREWHERE Clause {#prewhere} Prewhere is an optimization to apply filtering more efficiently. It is enabled by default even if `PREWHERE` clause is not specified explicitly. It works by automatically moving part of [WHERE](../../../sql-reference/statements/select/where.md) condition to prewhere stage. The role of `PREWHERE` clause is only to control this optimization if you think that you know how to do it better than it happens by default. From 5c11925830ce2b0f74f5804c83aa7f666d4aa9a6 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Sat, 24 Oct 2020 13:17:48 +0300 Subject: [PATCH 03/95] Update prewhere.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Вернул изменения назад. --- docs/en/sql-reference/statements/select/prewhere.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/statements/select/prewhere.md b/docs/en/sql-reference/statements/select/prewhere.md index 2cc66e45610..fc43d1de0a1 100644 --- a/docs/en/sql-reference/statements/select/prewhere.md +++ b/docs/en/sql-reference/statements/select/prewhere.md @@ -2,7 +2,7 @@ toc_title: PREWHERE --- -# PREWHERE Clause {#prewhere} +# PREWHERE Clause {#prewhere-clause} Prewhere is an optimization to apply filtering more efficiently. It is enabled by default even if `PREWHERE` clause is not specified explicitly. It works by automatically moving part of [WHERE](../../../sql-reference/statements/select/where.md) condition to prewhere stage. The role of `PREWHERE` clause is only to control this optimization if you think that you know how to do it better than it happens by default. From 3da09371dc366bff81d79e4818e9cfdab239b88d Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Sat, 24 Oct 2020 13:24:40 +0300 Subject: [PATCH 04/95] Update order-by.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Пытаюсь исправить битые ссылки. --- docs/en/sql-reference/statements/select/order-by.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/sql-reference/statements/select/order-by.md b/docs/en/sql-reference/statements/select/order-by.md index 4be49fe18d8..314f41e6e5f 100644 --- a/docs/en/sql-reference/statements/select/order-by.md +++ b/docs/en/sql-reference/statements/select/order-by.md @@ -230,7 +230,7 @@ returns OFFSET offset_row_count {ROW | ROWS} FETCH {FIRST | NEXT} fetch_row_count {ROW | ROWS} {ONLY | WITH TIES} ``` -The `FETCH` is an alternative to the [LIMIT] (https://clickhouse.tech/docs/en/sql-reference/statements/select/limit/#limit-clause) clause and retrieves rows from a query `SELECT` type. +The `FETCH` is an alternative to the [LIMIT] (../../../sql-reference/statements/select/limit.md) clause and retrieves rows from a query `SELECT` type. The `OFFSET` says to skip that many rows before beginning to return rows. @@ -246,7 +246,7 @@ is identical to the query SELECT * FROM test_fetch ORDER BY a LIMIT 3 OFFSET 1 ``` -When using `FETCH`, it is important to use an [ORDER BY] (https://clickhouse.tech/docs/en/sql-reference/statements/select/order-by/#select-order-by) clause that constrains the result rows into a unique order. Otherwise, you will get an unpredictable subset of the query's rows. +When using `FETCH`, it is important to use an [ORDER BY] (../../../sql-reference/statements/select/order-by.md) clause that constrains the result rows into a unique order. Otherwise, you will get an unpredictable subset of the query's rows. `ROW` and `ROWS` as well as `FIRST` and `NEXT` are noise words that don't influence the effects of these conditions. From ce016ba8c930707f9a53ed712fb786e213a8045f Mon Sep 17 00:00:00 2001 From: ana-uvarova Date: Tue, 27 Oct 2020 10:22:14 +0300 Subject: [PATCH 05/95] Draft --- docs/en/operations/system-tables/asynchronous_metric_log.md | 2 +- docs/en/operations/system-tables/metric_log.md | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/en/operations/system-tables/asynchronous_metric_log.md b/docs/en/operations/system-tables/asynchronous_metric_log.md index 75607cc30b0..e1eabdefa2f 100644 --- a/docs/en/operations/system-tables/asynchronous_metric_log.md +++ b/docs/en/operations/system-tables/asynchronous_metric_log.md @@ -1,6 +1,6 @@ ## system.asynchronous_metric_log {#system-tables-async-log} -Contains the historical values for `system.asynchronous_metrics`, which are saved once per minute. This feature is enabled by default. +Contains the historical values for `system.asynchronous_metrics`, which are saved once per minute. Enabled by default. Columns: diff --git a/docs/en/operations/system-tables/metric_log.md b/docs/en/operations/system-tables/metric_log.md index f1910407949..c6aefc5034f 100644 --- a/docs/en/operations/system-tables/metric_log.md +++ b/docs/en/operations/system-tables/metric_log.md @@ -1,6 +1,7 @@ # system.metric_log {#system_tables-metric_log} Contains history of metrics values from tables `system.metrics` and `system.events`, periodically flushed to disk. + To turn on metrics history collection on `system.metric_log`, create `/etc/clickhouse-server/config.d/metric_log.xml` with following content: ``` xml @@ -14,6 +15,11 @@ To turn on metrics history collection on `system.metric_log`, create `/etc/click ``` +Columns: +- `event_date` ([Date](../../sql-reference/data-types/date.md)) — Event date. +- `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — Event time. +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — Event time with microseconds resolution. + **Example** ``` sql From 3fb8d08dd41bab1d05def74749486cabcc746994 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Mon, 12 Oct 2020 21:22:09 +0300 Subject: [PATCH 06/95] Add errorCodeToName() function This patch adds errorCode() function that will return macro name by the exception code, useful for analyzing query_log and similar. Later some descriptions can be added. v2: replace hana::map/fusion::vector with external script v3: - use binary cmake dir for .sh - use jump table over suboptimal std::unordered_map (with very poor hash function for int -- std::hash) - cleanup errorCodeToName (drop extra templates and headers) - rename errorCode -> errorCodeToName - fix arcadia build (by not providing those helpers there) - fix build on CI, by using CMAKE_CXX_COMPILER for parsing the file --- .../functions/other-functions.md | 20 ++++++ src/Functions/.gitignore | 1 + src/Functions/CMakeLists.txt | 16 +++++ src/Functions/errorCodeToName.cpp | 66 +++++++++++++++++++ src/Functions/errorCodes.sh | 61 +++++++++++++++++ .../registerFunctionsMiscellaneous.cpp | 6 ++ src/Functions/ya.make.in | 2 +- .../01544_errorCodeToName.reference | 3 + .../0_stateless/01544_errorCodeToName.sql | 3 + 9 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 src/Functions/.gitignore create mode 100644 src/Functions/errorCodeToName.cpp create mode 100755 src/Functions/errorCodes.sh create mode 100644 tests/queries/0_stateless/01544_errorCodeToName.reference create mode 100644 tests/queries/0_stateless/01544_errorCodeToName.sql diff --git a/docs/en/sql-reference/functions/other-functions.md b/docs/en/sql-reference/functions/other-functions.md index 2cc80dcffc1..dd5df19d40f 100644 --- a/docs/en/sql-reference/functions/other-functions.md +++ b/docs/en/sql-reference/functions/other-functions.md @@ -1657,4 +1657,24 @@ Result: 10 10 19 19 39 39 ``` +## errorCodeToName {#error-code-to-name} + +**Returned value** + +- Variable name for the error code. + +Type: [String](../../sql-reference/data-types/string.md). + +**Syntax** + +``` sql +errorCodeToName(1) +``` + +Result: + +``` text +UNSUPPORTED_METHOD +``` + [Original article](https://clickhouse.tech/docs/en/query_language/functions/other_functions/) diff --git a/src/Functions/.gitignore b/src/Functions/.gitignore new file mode 100644 index 00000000000..25db3625c77 --- /dev/null +++ b/src/Functions/.gitignore @@ -0,0 +1 @@ +/errorCodes.generated.cpp diff --git a/src/Functions/CMakeLists.txt b/src/Functions/CMakeLists.txt index bdf89c983f1..d949ab8283f 100644 --- a/src/Functions/CMakeLists.txt +++ b/src/Functions/CMakeLists.txt @@ -6,6 +6,20 @@ add_headers_and_sources(clickhouse_functions .) list(REMOVE_ITEM clickhouse_functions_sources IFunctionImpl.cpp FunctionFactory.cpp FunctionHelpers.cpp) list(REMOVE_ITEM clickhouse_functions_headers IFunctionImpl.h FunctionFactory.h FunctionHelpers.h) +set(ERROR_CODES_IN ${CMAKE_CURRENT_SOURCE_DIR}/../Common/ErrorCodes.cpp) +set(ERROR_CODES_OUT ${CMAKE_CURRENT_BINARY_DIR}/errorCodes.generated.cpp) +add_custom_target(generate-error-codes + env + ERROR_CODES_IN_FILE=${ERROR_CODES_IN} + ERROR_CODES_OUT_FILE=${ERROR_CODES_OUT} + CXX=${CMAKE_CXX_COMPILER} + ${CMAKE_CURRENT_SOURCE_DIR}/errorCodes.sh + SOURCES errorCodes.sh + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + BYPRODUCTS ${ERROR_CODES_OUT} +) +list(APPEND clickhouse_functions_sources ${ERROR_CODES_OUT}) + if (NOT USE_H3) list (REMOVE_ITEM clickhouse_functions_sources geoToH3.cpp @@ -53,6 +67,8 @@ endif() target_include_directories(clickhouse_functions SYSTEM PRIVATE ${SPARSEHASH_INCLUDE_DIR}) +add_dependencies(clickhouse_functions generate-error-codes) + if (CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE" OR CMAKE_BUILD_TYPE_UC STREQUAL "RELWITHDEBINFO" OR CMAKE_BUILD_TYPE_UC STREQUAL "MINSIZEREL") diff --git a/src/Functions/errorCodeToName.cpp b/src/Functions/errorCodeToName.cpp new file mode 100644 index 00000000000..6621a6f20bb --- /dev/null +++ b/src/Functions/errorCodeToName.cpp @@ -0,0 +1,66 @@ +#if !defined(ARCADIA_BUILD) + +#include +#include +#include +#include +#include + +extern std::string_view errorCodeToName(int code); + +namespace DB +{ + +namespace ErrorCodes +{ + extern const int BAD_ARGUMENTS; +} + +/** errorCodeToName() - returns the variable name for the error code. + */ +class FunctionErrorCodeToName : public IFunction +{ +public: + static constexpr auto name = "errorCodeToName"; + static FunctionPtr create(const Context &) + { + return std::make_shared(); + } + + String getName() const override { return name; } + size_t getNumberOfArguments() const override { return 1; } + bool useDefaultImplementationForConstants() const override { return true; } + + DataTypePtr getReturnTypeImpl(const DataTypes & types) const override + { + if (!isNumber(types.at(0))) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "The argument of function {} must have simple numeric type, possibly Nullable", name); + + return std::make_shared(); + } + + ColumnPtr executeImpl(ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override + { + auto & input_column = *arguments[0].column; + auto col_res = ColumnString::create(); + + for (size_t i = 0; i < input_rows_count; ++i) + { + const Int64 error_code = input_column.getInt(i); + std::string_view error_name = errorCodeToName(error_code); + col_res->insertData(error_name.data(), error_name.size()); + } + + return col_res; + } +}; + + +void registerFunctionErrorCodeToName(FunctionFactory & factory) +{ + factory.registerFunction(); +} + +} + +#endif diff --git a/src/Functions/errorCodes.sh b/src/Functions/errorCodes.sh new file mode 100755 index 00000000000..711465be614 --- /dev/null +++ b/src/Functions/errorCodes.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +# Parse src/Common/ErrorCodes.cpp +# And generate src/Functions/errorCodes.generated.cpp +# For errorCode() function. +# +# Later it may contain some description of the error. + +set -e +set -o pipefail + +CUR_DIR="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")" +ERROR_CODES_IN_FILE=${ERROR_CODES_IN_FILE=$CUR_DIR/../Common/ErrorCodes.cpp} +ERROR_CODES_OUT_FILE=${ERROR_CODES_OUT_FILE=$CUR_DIR/errorCodes.generated.cpp} +CXX=${CXX=g++} + +trap 'rm -f $TMP_FILE' EXIT +TMP_FILE="$(mktemp clichouse_generate_errorCodes_XXXXXXXX.cpp)" + +function parse_for_errorCodeToName() +{ + # This is the simplest command that can be written to parse the file + # And it does not requires any extra tools and works everywhere where you have g++/clang++ + $CXX -E "$ERROR_CODES_IN_FILE" | { + awk -F '[ =;]*' '/extern const int / { printf(" case %s: return std::string_view(\"%s\");\n", $(NF-1), $(NF-2)); }' + } +} + +function generate_errorCodeToName() +{ + cat < + +std::string_view errorCodeToName(int code) +{ + switch (code) + { + case 0: return std::string_view("OK"); +$(parse_for_errorCodeToName) + default: return std::string_view(""); + } +}; + +EOL +} + +function main() +{ + generate_errorCodeToName > "$TMP_FILE" + + if [[ ! -e $ERROR_CODES_OUT_FILE ]]; then + cp -a "$TMP_FILE" "$ERROR_CODES_OUT_FILE" + fi + # update it only if it differs, to avoid costly recompilation + if ! diff -q "$TMP_FILE" "$ERROR_CODES_OUT_FILE"; then + cp -a "$TMP_FILE" "$ERROR_CODES_OUT_FILE" + fi +} +main "$@" diff --git a/src/Functions/registerFunctionsMiscellaneous.cpp b/src/Functions/registerFunctionsMiscellaneous.cpp index 414f6ec5f8e..4a989831b48 100644 --- a/src/Functions/registerFunctionsMiscellaneous.cpp +++ b/src/Functions/registerFunctionsMiscellaneous.cpp @@ -64,6 +64,9 @@ void registerFunctionCountDigits(FunctionFactory &); void registerFunctionGlobalVariable(FunctionFactory &); void registerFunctionHasThreadFuzzer(FunctionFactory &); void registerFunctionInitializeAggregation(FunctionFactory &); +#if !defined(ARCADIA_BUILD) +void registerFunctionErrorCodeToName(FunctionFactory &); +#endif #if USE_ICU void registerFunctionConvertCharset(FunctionFactory &); @@ -128,6 +131,9 @@ void registerFunctionsMiscellaneous(FunctionFactory & factory) registerFunctionGlobalVariable(factory); registerFunctionHasThreadFuzzer(factory); registerFunctionInitializeAggregation(factory); +#if !defined(ARCADIA_BUILD) + registerFunctionErrorCodeToName(factory); +#endif #if USE_ICU registerFunctionConvertCharset(factory); diff --git a/src/Functions/ya.make.in b/src/Functions/ya.make.in index 2a66aa5553e..e70658bb79d 100644 --- a/src/Functions/ya.make.in +++ b/src/Functions/ya.make.in @@ -34,7 +34,7 @@ PEERDIR( CFLAGS(-g0) SRCS( - + ) END() diff --git a/tests/queries/0_stateless/01544_errorCodeToName.reference b/tests/queries/0_stateless/01544_errorCodeToName.reference new file mode 100644 index 00000000000..4f0073384d9 --- /dev/null +++ b/tests/queries/0_stateless/01544_errorCodeToName.reference @@ -0,0 +1,3 @@ + +OK +UNSUPPORTED_METHOD diff --git a/tests/queries/0_stateless/01544_errorCodeToName.sql b/tests/queries/0_stateless/01544_errorCodeToName.sql new file mode 100644 index 00000000000..07b46767b73 --- /dev/null +++ b/tests/queries/0_stateless/01544_errorCodeToName.sql @@ -0,0 +1,3 @@ +SELECT errorCodeToName(toUInt32(-1)); +SELECT errorCodeToName(0); +SELECT errorCodeToName(1); From b2e232289507b18ce09861d9cc339d7094606fd4 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 29 Oct 2020 01:00:04 +0300 Subject: [PATCH 07/95] Add system.errors table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contains error codes with number of times they have been triggered. Columns: - `name` ([String](../../sql-reference/data-types/string.md)) — name of the error (`errorCodeToName`). - `code` ([Int32](../../sql-reference/data-types/int-uint.md)) — code number of the error. - `value` ([UInt64](../../sql-reference/data-types/int-uint.md)) - number of times this error has been happened. **Example** ``` sql SELECT * FROM system.errors WHERE value > 0 ORDER BY code ASC LIMIT 1 ┌─name─────────────┬─code─┬─value─┐ │ CANNOT_OPEN_FILE │ 76 │ 1 │ └──────────────────┴──────┴───────┘ --- docker/test/fasttest/run.sh | 2 + docs/en/operations/system-tables/errors.md | 23 ++++++++++ src/CMakeLists.txt | 15 +++++++ src/Common/Exception.cpp | 6 +++ src/{Functions => Common}/errorCodes.sh | 44 ++++++++++++++++--- src/Common/ya.make.in | 2 +- src/Functions/CMakeLists.txt | 14 ------ src/Storages/System/StorageSystemErrors.cpp | 43 ++++++++++++++++++ src/Storages/System/StorageSystemErrors.h | 29 ++++++++++++ src/Storages/System/attachSystemTables.cpp | 2 + src/Storages/ya.make | 1 + .../0_stateless/01545_system_errors.reference | 1 + .../0_stateless/01545_system_errors.sh | 9 ++++ 13 files changed, 170 insertions(+), 21 deletions(-) create mode 100644 docs/en/operations/system-tables/errors.md rename src/{Functions => Common}/errorCodes.sh (58%) create mode 100644 src/Storages/System/StorageSystemErrors.cpp create mode 100644 src/Storages/System/StorageSystemErrors.h create mode 100644 tests/queries/0_stateless/01545_system_errors.reference create mode 100755 tests/queries/0_stateless/01545_system_errors.sh diff --git a/docker/test/fasttest/run.sh b/docker/test/fasttest/run.sh index 8300c31681e..bcba50e9d81 100755 --- a/docker/test/fasttest/run.sh +++ b/docker/test/fasttest/run.sh @@ -277,6 +277,8 @@ TESTS_TO_SKIP=( # Require python libraries like scipy, pandas and numpy 01322_ttest_scipy + + 01545_system_errors ) time clickhouse-test -j 8 --order=random --no-long --testname --shard --zookeeper --skip "${TESTS_TO_SKIP[@]}" 2>&1 | ts '%Y-%m-%d %H:%M:%S' | tee "$FASTTEST_OUTPUT/test_log.txt" diff --git a/docs/en/operations/system-tables/errors.md b/docs/en/operations/system-tables/errors.md new file mode 100644 index 00000000000..53e8a397217 --- /dev/null +++ b/docs/en/operations/system-tables/errors.md @@ -0,0 +1,23 @@ +# system.errors {#system_tables-errors} + +Contains error codes with number of times they have been triggered. + +Columns: + +- `name` ([String](../../sql-reference/data-types/string.md)) — name of the error (`errorCodeToName`). +- `code` ([Int32](../../sql-reference/data-types/int-uint.md)) — code number of the error. +- `value` ([UInt64](../../sql-reference/data-types/int-uint.md)) - number of times this error has been happened. + +**Example** + +``` sql +SELECT * +FROM system.errors +WHERE value > 0 +ORDER BY code ASC +LIMIT 1 + +┌─name─────────────┬─code─┬─value─┐ +│ CANNOT_OPEN_FILE │ 76 │ 1 │ +└──────────────────┴──────┴───────┘ +``` diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 085269847e4..86c78d9309a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -86,6 +86,21 @@ endif() list (APPEND clickhouse_common_io_sources ${CONFIG_BUILD}) list (APPEND clickhouse_common_io_headers ${CONFIG_VERSION} ${CONFIG_COMMON}) +# ErrorCodes +set(ERROR_CODES_IN ${CMAKE_CURRENT_SOURCE_DIR}/Common/ErrorCodes.cpp) +set(ERROR_CODES_OUT ${CMAKE_CURRENT_BINARY_DIR}/Common/errorCodes.generated.cpp) +add_custom_target(generate-error-codes + env + ERROR_CODES_IN_FILE=${ERROR_CODES_IN} + ERROR_CODES_OUT_FILE=${ERROR_CODES_OUT} + CXX=${CMAKE_CXX_COMPILER} + ${CMAKE_CURRENT_SOURCE_DIR}/Common/errorCodes.sh + SOURCES Common/errorCodes.sh + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + BYPRODUCTS ${ERROR_CODES_OUT} +) +list(APPEND clickhouse_common_io_sources ${ERROR_CODES_OUT}) + list (APPEND dbms_sources Functions/IFunction.cpp Functions/FunctionFactory.cpp Functions/FunctionHelpers.cpp Functions/extractTimeZoneFromFunctionArguments.cpp) list (APPEND dbms_headers Functions/IFunctionImpl.h Functions/FunctionFactory.h Functions/FunctionHelpers.h Functions/extractTimeZoneFromFunctionArguments.h) diff --git a/src/Common/Exception.cpp b/src/Common/Exception.cpp index 716938eb3d6..4b9bb595ce6 100644 --- a/src/Common/Exception.cpp +++ b/src/Common/Exception.cpp @@ -12,14 +12,19 @@ #include #include #include +#include #include #include +#include #include +#include #if !defined(ARCADIA_BUILD) # include #endif +extern HashMap, DefaultHash> error_codes_count; + namespace DB { @@ -45,6 +50,7 @@ Exception::Exception(const std::string & msg, int code) LOG_FATAL(&Poco::Logger::root(), "Logical error: '{}'.", msg); abort(); } + ++error_codes_count[code]; #endif } diff --git a/src/Functions/errorCodes.sh b/src/Common/errorCodes.sh similarity index 58% rename from src/Functions/errorCodes.sh rename to src/Common/errorCodes.sh index 711465be614..3a4520e2dad 100755 --- a/src/Functions/errorCodes.sh +++ b/src/Common/errorCodes.sh @@ -17,20 +17,26 @@ CXX=${CXX=g++} trap 'rm -f $TMP_FILE' EXIT TMP_FILE="$(mktemp clichouse_generate_errorCodes_XXXXXXXX.cpp)" -function parse_for_errorCodeToName() +function parse_ErrorCodes() { # This is the simplest command that can be written to parse the file # And it does not requires any extra tools and works everywhere where you have g++/clang++ + # + # Generate: + # + # CODE VAR_NAME + # $CXX -E "$ERROR_CODES_IN_FILE" | { - awk -F '[ =;]*' '/extern const int / { printf(" case %s: return std::string_view(\"%s\");\n", $(NF-1), $(NF-2)); }' + awk -F '[ =;]*' '/extern const int / { print $(NF-1), $(NF-2); }' } } - +function parse_for_errorCodeToName() +{ + parse_ErrorCodes | awk '{ printf(" case %s: return std::string_view(\"%s\");\n", $1, $2); }' +} function generate_errorCodeToName() { cat < std::string_view errorCodeToName(int code) @@ -46,9 +52,35 @@ $(parse_for_errorCodeToName) EOL } +function parse_for_error_codes_count() +{ + parse_ErrorCodes | awk '{ printf(" error_codes_count[%s] = 0; /* %s */\n", $1, $2); }' +} +function generate_error_codes_count() +{ + cat < +#include +#include +#include + +HashMap, DefaultHash> error_codes_count; + +struct InitializeErrorCodesCount +{ + InitializeErrorCodesCount() + { +$(parse_for_error_codes_count) + } +} error_codes_count_initialize; +EOL +} + function main() { - generate_errorCodeToName > "$TMP_FILE" + echo "// autogenerated by ${BASH_SOURCE[0]}" > "$TMP_FILE" + generate_errorCodeToName >> "$TMP_FILE" + generate_error_codes_count >> "$TMP_FILE" if [[ ! -e $ERROR_CODES_OUT_FILE ]]; then cp -a "$TMP_FILE" "$ERROR_CODES_OUT_FILE" diff --git a/src/Common/ya.make.in b/src/Common/ya.make.in index f8b7601e215..e0e3fd9a944 100644 --- a/src/Common/ya.make.in +++ b/src/Common/ya.make.in @@ -23,7 +23,7 @@ INCLUDE(${ARCADIA_ROOT}/clickhouse/cmake/yandex/ya.make.versions.inc) CFLAGS(-g0) SRCS( - + ) END() diff --git a/src/Functions/CMakeLists.txt b/src/Functions/CMakeLists.txt index d949ab8283f..b528b3a276f 100644 --- a/src/Functions/CMakeLists.txt +++ b/src/Functions/CMakeLists.txt @@ -6,20 +6,6 @@ add_headers_and_sources(clickhouse_functions .) list(REMOVE_ITEM clickhouse_functions_sources IFunctionImpl.cpp FunctionFactory.cpp FunctionHelpers.cpp) list(REMOVE_ITEM clickhouse_functions_headers IFunctionImpl.h FunctionFactory.h FunctionHelpers.h) -set(ERROR_CODES_IN ${CMAKE_CURRENT_SOURCE_DIR}/../Common/ErrorCodes.cpp) -set(ERROR_CODES_OUT ${CMAKE_CURRENT_BINARY_DIR}/errorCodes.generated.cpp) -add_custom_target(generate-error-codes - env - ERROR_CODES_IN_FILE=${ERROR_CODES_IN} - ERROR_CODES_OUT_FILE=${ERROR_CODES_OUT} - CXX=${CMAKE_CXX_COMPILER} - ${CMAKE_CURRENT_SOURCE_DIR}/errorCodes.sh - SOURCES errorCodes.sh - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - BYPRODUCTS ${ERROR_CODES_OUT} -) -list(APPEND clickhouse_functions_sources ${ERROR_CODES_OUT}) - if (NOT USE_H3) list (REMOVE_ITEM clickhouse_functions_sources geoToH3.cpp diff --git a/src/Storages/System/StorageSystemErrors.cpp b/src/Storages/System/StorageSystemErrors.cpp new file mode 100644 index 00000000000..5ab6d02a78f --- /dev/null +++ b/src/Storages/System/StorageSystemErrors.cpp @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern std::string_view errorCodeToName(int code); +extern HashMap, DefaultHash> error_codes_count; + +namespace DB +{ + +NamesAndTypesList StorageSystemErrors::getNamesAndTypes() +{ + return { + { "name", std::make_shared() }, + { "code", std::make_shared() }, + { "value", std::make_shared() }, + }; +} + + +void StorageSystemErrors::fillData(MutableColumns & res_columns, const Context &, const SelectQueryInfo &) const +{ + for (const auto & error_code_pair : error_codes_count) + { + size_t col_num = 0; + res_columns[col_num++]->insert(errorCodeToName(error_code_pair.getKey())); + res_columns[col_num++]->insert(error_code_pair.getKey()); + res_columns[col_num++]->insert(uint64_t(error_code_pair.getMapped())); + } +} + +} diff --git a/src/Storages/System/StorageSystemErrors.h b/src/Storages/System/StorageSystemErrors.h new file mode 100644 index 00000000000..3f2d3020bcd --- /dev/null +++ b/src/Storages/System/StorageSystemErrors.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include + + +namespace DB +{ + +class Context; + + +/** Implements the `distribution_queue` system table, which allows you to view the INSERT queues for the Distributed tables. + */ +class StorageSystemErrors final : public ext::shared_ptr_helper, public IStorageSystemOneBlock +{ + friend struct ext::shared_ptr_helper; +public: + std::string getName() const override { return "SystemErrors"; } + + static NamesAndTypesList getNamesAndTypes(); + +protected: + using IStorageSystemOneBlock::IStorageSystemOneBlock; + + void fillData(MutableColumns & res_columns, const Context &, const SelectQueryInfo &) const override; +}; + +} diff --git a/src/Storages/System/attachSystemTables.cpp b/src/Storages/System/attachSystemTables.cpp index 2b7ee363f05..1ea24c1c4ba 100644 --- a/src/Storages/System/attachSystemTables.cpp +++ b/src/Storages/System/attachSystemTables.cpp @@ -41,6 +41,7 @@ #include #include #endif +#include #include #include #include @@ -110,6 +111,7 @@ void attachSystemTablesLocal(IDatabase & system_database) #if !defined(ARCADIA_BUILD) attach(system_database, "licenses"); attach(system_database, "time_zones"); + attach(system_database, "errors"); #endif #ifdef OS_LINUX attach(system_database, "stack_trace"); diff --git a/src/Storages/ya.make b/src/Storages/ya.make index 107433b5e73..a196b2f4fda 100644 --- a/src/Storages/ya.make +++ b/src/Storages/ya.make @@ -154,6 +154,7 @@ SRCS( System/StorageSystemDisks.cpp System/StorageSystemDistributionQueue.cpp System/StorageSystemEnabledRoles.cpp + System/StorageSystemErrors.cpp System/StorageSystemEvents.cpp System/StorageSystemFormats.cpp System/StorageSystemFunctions.cpp diff --git a/tests/queries/0_stateless/01545_system_errors.reference b/tests/queries/0_stateless/01545_system_errors.reference new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/tests/queries/0_stateless/01545_system_errors.reference @@ -0,0 +1 @@ +1 diff --git a/tests/queries/0_stateless/01545_system_errors.sh b/tests/queries/0_stateless/01545_system_errors.sh new file mode 100755 index 00000000000..402c4e34116 --- /dev/null +++ b/tests/queries/0_stateless/01545_system_errors.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. "$CURDIR"/../shell_config.sh + +prev="$(${CLICKHOUSE_CLIENT} -q "SELECT value FROM system.errors WHERE name = 'FUNCTION_THROW_IF_VALUE_IS_NON_ZERO'")" +$CLICKHOUSE_CLIENT -q 'SELECT throwIf(1)' >& /dev/null +cur="$(${CLICKHOUSE_CLIENT} -q "SELECT value FROM system.errors WHERE name = 'FUNCTION_THROW_IF_VALUE_IS_NON_ZERO'")" +echo $((cur - prev)) From a81b0418acdfdfce2c4a9078dfe71808e430a38f Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 29 Oct 2020 09:42:08 +0300 Subject: [PATCH 08/95] Make errorCodeToName() return LowCardinality(String) --- docs/en/sql-reference/functions/other-functions.md | 2 +- src/Functions/errorCodeToName.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/en/sql-reference/functions/other-functions.md b/docs/en/sql-reference/functions/other-functions.md index dd5df19d40f..31ed47c3195 100644 --- a/docs/en/sql-reference/functions/other-functions.md +++ b/docs/en/sql-reference/functions/other-functions.md @@ -1663,7 +1663,7 @@ Result: - Variable name for the error code. -Type: [String](../../sql-reference/data-types/string.md). +Type: [LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md). **Syntax** diff --git a/src/Functions/errorCodeToName.cpp b/src/Functions/errorCodeToName.cpp index 6621a6f20bb..e8f34c5edd0 100644 --- a/src/Functions/errorCodeToName.cpp +++ b/src/Functions/errorCodeToName.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -36,13 +37,13 @@ public: if (!isNumber(types.at(0))) throw Exception(ErrorCodes::BAD_ARGUMENTS, "The argument of function {} must have simple numeric type, possibly Nullable", name); - return std::make_shared(); + return std::make_shared(std::make_shared()); } - ColumnPtr executeImpl(ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override + ColumnPtr executeImpl(ColumnsWithTypeAndName & arguments, const DataTypePtr & res_type, size_t input_rows_count) const override { auto & input_column = *arguments[0].column; - auto col_res = ColumnString::create(); + auto col_res = res_type->createColumn(); for (size_t i = 0; i < input_rows_count; ++i) { From b7eac807f59f74036adf164b261952acfb47a53b Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 29 Oct 2020 10:35:16 +0300 Subject: [PATCH 09/95] Fix readability-qualified-auto in errorCodeToName() --- src/Functions/errorCodeToName.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Functions/errorCodeToName.cpp b/src/Functions/errorCodeToName.cpp index e8f34c5edd0..8c9f49b2ac8 100644 --- a/src/Functions/errorCodeToName.cpp +++ b/src/Functions/errorCodeToName.cpp @@ -42,7 +42,7 @@ public: ColumnPtr executeImpl(ColumnsWithTypeAndName & arguments, const DataTypePtr & res_type, size_t input_rows_count) const override { - auto & input_column = *arguments[0].column; + const auto & input_column = *arguments[0].column; auto col_res = res_type->createColumn(); for (size_t i = 0; i < input_rows_count; ++i) From b42f77a791f74b1a2ffd5cd84fb7bf7cbc78c8d9 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 29 Oct 2020 10:07:42 +0300 Subject: [PATCH 10/95] Covert error codes list to lookup table and drop generation of them. --- src/CMakeLists.txt | 15 - src/Common/ErrorCodes.cpp | 1069 +++++++++-------- src/Common/ErrorCodes.h | 41 + src/Common/Exception.cpp | 8 +- src/Common/errorCodes.sh | 93 -- src/Functions/CMakeLists.txt | 2 - src/Functions/errorCodeToName.cpp | 6 +- src/Storages/System/StorageSystemErrors.cpp | 37 +- .../01544_errorCodeToName.reference | 1 + .../0_stateless/01544_errorCodeToName.sql | 1 + 10 files changed, 618 insertions(+), 655 deletions(-) create mode 100644 src/Common/ErrorCodes.h delete mode 100755 src/Common/errorCodes.sh diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 86c78d9309a..085269847e4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -86,21 +86,6 @@ endif() list (APPEND clickhouse_common_io_sources ${CONFIG_BUILD}) list (APPEND clickhouse_common_io_headers ${CONFIG_VERSION} ${CONFIG_COMMON}) -# ErrorCodes -set(ERROR_CODES_IN ${CMAKE_CURRENT_SOURCE_DIR}/Common/ErrorCodes.cpp) -set(ERROR_CODES_OUT ${CMAKE_CURRENT_BINARY_DIR}/Common/errorCodes.generated.cpp) -add_custom_target(generate-error-codes - env - ERROR_CODES_IN_FILE=${ERROR_CODES_IN} - ERROR_CODES_OUT_FILE=${ERROR_CODES_OUT} - CXX=${CMAKE_CXX_COMPILER} - ${CMAKE_CURRENT_SOURCE_DIR}/Common/errorCodes.sh - SOURCES Common/errorCodes.sh - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - BYPRODUCTS ${ERROR_CODES_OUT} -) -list(APPEND clickhouse_common_io_sources ${ERROR_CODES_OUT}) - list (APPEND dbms_sources Functions/IFunction.cpp Functions/FunctionFactory.cpp Functions/FunctionHelpers.cpp Functions/extractTimeZoneFromFunctionArguments.cpp) list (APPEND dbms_headers Functions/IFunctionImpl.h Functions/FunctionFactory.h Functions/FunctionHelpers.h Functions/extractTimeZoneFromFunctionArguments.h) diff --git a/src/Common/ErrorCodes.cpp b/src/Common/ErrorCodes.cpp index b14c090c848..7b671427753 100644 --- a/src/Common/ErrorCodes.cpp +++ b/src/Common/ErrorCodes.cpp @@ -1,526 +1,565 @@ +#include + +/** Previously, these constants were located in one enum. + * But in this case there is a problem: when you add a new constant, you need to recompile + * all translation units that use at least one constant (almost the whole project). + * Therefore it is made so that definitions of constants are located here, in one file, + * and their declaration are in different files, at the place of use. + * + * Later it was converted to the lookup table, to provide: + * - errorCodeToName() + * - system.errors table + */ + +#define APPLY_FOR_ERROR_CODES(M) \ + M(OK, 0) \ + M(UNSUPPORTED_METHOD, 1) \ + M(UNSUPPORTED_PARAMETER, 2) \ + M(UNEXPECTED_END_OF_FILE, 3) \ + M(EXPECTED_END_OF_FILE, 4) \ + M(CANNOT_PARSE_TEXT, 6) \ + M(INCORRECT_NUMBER_OF_COLUMNS, 7) \ + M(THERE_IS_NO_COLUMN, 8) \ + M(SIZES_OF_COLUMNS_DOESNT_MATCH, 9) \ + M(NOT_FOUND_COLUMN_IN_BLOCK, 10) \ + M(POSITION_OUT_OF_BOUND, 11) \ + M(PARAMETER_OUT_OF_BOUND, 12) \ + M(SIZES_OF_COLUMNS_IN_TUPLE_DOESNT_MATCH, 13) \ + M(DUPLICATE_COLUMN, 15) \ + M(NO_SUCH_COLUMN_IN_TABLE, 16) \ + M(DELIMITER_IN_STRING_LITERAL_DOESNT_MATCH, 17) \ + M(CANNOT_INSERT_ELEMENT_INTO_CONSTANT_COLUMN, 18) \ + M(SIZE_OF_FIXED_STRING_DOESNT_MATCH, 19) \ + M(NUMBER_OF_COLUMNS_DOESNT_MATCH, 20) \ + M(CANNOT_READ_ALL_DATA_FROM_TAB_SEPARATED_INPUT, 21) \ + M(CANNOT_PARSE_ALL_VALUE_FROM_TAB_SEPARATED_INPUT, 22) \ + M(CANNOT_READ_FROM_ISTREAM, 23) \ + M(CANNOT_WRITE_TO_OSTREAM, 24) \ + M(CANNOT_PARSE_ESCAPE_SEQUENCE, 25) \ + M(CANNOT_PARSE_QUOTED_STRING, 26) \ + M(CANNOT_PARSE_INPUT_ASSERTION_FAILED, 27) \ + M(CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER, 28) \ + M(CANNOT_PRINT_INTEGER, 29) \ + M(CANNOT_READ_SIZE_OF_COMPRESSED_CHUNK, 30) \ + M(CANNOT_READ_COMPRESSED_CHUNK, 31) \ + M(ATTEMPT_TO_READ_AFTER_EOF, 32) \ + M(CANNOT_READ_ALL_DATA, 33) \ + M(TOO_MANY_ARGUMENTS_FOR_FUNCTION, 34) \ + M(TOO_FEW_ARGUMENTS_FOR_FUNCTION, 35) \ + M(BAD_ARGUMENTS, 36) \ + M(UNKNOWN_ELEMENT_IN_AST, 37) \ + M(CANNOT_PARSE_DATE, 38) \ + M(TOO_LARGE_SIZE_COMPRESSED, 39) \ + M(CHECKSUM_DOESNT_MATCH, 40) \ + M(CANNOT_PARSE_DATETIME, 41) \ + M(NUMBER_OF_ARGUMENTS_DOESNT_MATCH, 42) \ + M(ILLEGAL_TYPE_OF_ARGUMENT, 43) \ + M(ILLEGAL_COLUMN, 44) \ + M(ILLEGAL_NUMBER_OF_RESULT_COLUMNS, 45) \ + M(UNKNOWN_FUNCTION, 46) \ + M(UNKNOWN_IDENTIFIER, 47) \ + M(NOT_IMPLEMENTED, 48) \ + M(LOGICAL_ERROR, 49) \ + M(UNKNOWN_TYPE, 50) \ + M(EMPTY_LIST_OF_COLUMNS_QUERIED, 51) \ + M(COLUMN_QUERIED_MORE_THAN_ONCE, 52) \ + M(TYPE_MISMATCH, 53) \ + M(STORAGE_DOESNT_ALLOW_PARAMETERS, 54) \ + M(STORAGE_REQUIRES_PARAMETER, 55) \ + M(UNKNOWN_STORAGE, 56) \ + M(TABLE_ALREADY_EXISTS, 57) \ + M(TABLE_METADATA_ALREADY_EXISTS, 58) \ + M(ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER, 59) \ + M(UNKNOWN_TABLE, 60) \ + M(ONLY_FILTER_COLUMN_IN_BLOCK, 61) \ + M(SYNTAX_ERROR, 62) \ + M(UNKNOWN_AGGREGATE_FUNCTION, 63) \ + M(CANNOT_READ_AGGREGATE_FUNCTION_FROM_TEXT, 64) \ + M(CANNOT_WRITE_AGGREGATE_FUNCTION_AS_TEXT, 65) \ + M(NOT_A_COLUMN, 66) \ + M(ILLEGAL_KEY_OF_AGGREGATION, 67) \ + M(CANNOT_GET_SIZE_OF_FIELD, 68) \ + M(ARGUMENT_OUT_OF_BOUND, 69) \ + M(CANNOT_CONVERT_TYPE, 70) \ + M(CANNOT_WRITE_AFTER_END_OF_BUFFER, 71) \ + M(CANNOT_PARSE_NUMBER, 72) \ + M(UNKNOWN_FORMAT, 73) \ + M(CANNOT_READ_FROM_FILE_DESCRIPTOR, 74) \ + M(CANNOT_WRITE_TO_FILE_DESCRIPTOR, 75) \ + M(CANNOT_OPEN_FILE, 76) \ + M(CANNOT_CLOSE_FILE, 77) \ + M(UNKNOWN_TYPE_OF_QUERY, 78) \ + M(INCORRECT_FILE_NAME, 79) \ + M(INCORRECT_QUERY, 80) \ + M(UNKNOWN_DATABASE, 81) \ + M(DATABASE_ALREADY_EXISTS, 82) \ + M(DIRECTORY_DOESNT_EXIST, 83) \ + M(DIRECTORY_ALREADY_EXISTS, 84) \ + M(FORMAT_IS_NOT_SUITABLE_FOR_INPUT, 85) \ + M(RECEIVED_ERROR_FROM_REMOTE_IO_SERVER, 86) \ + M(CANNOT_SEEK_THROUGH_FILE, 87) \ + M(CANNOT_TRUNCATE_FILE, 88) \ + M(UNKNOWN_COMPRESSION_METHOD, 89) \ + M(EMPTY_LIST_OF_COLUMNS_PASSED, 90) \ + M(SIZES_OF_MARKS_FILES_ARE_INCONSISTENT, 91) \ + M(EMPTY_DATA_PASSED, 92) \ + M(UNKNOWN_AGGREGATED_DATA_VARIANT, 93) \ + M(CANNOT_MERGE_DIFFERENT_AGGREGATED_DATA_VARIANTS, 94) \ + M(CANNOT_READ_FROM_SOCKET, 95) \ + M(CANNOT_WRITE_TO_SOCKET, 96) \ + M(CANNOT_READ_ALL_DATA_FROM_CHUNKED_INPUT, 97) \ + M(CANNOT_WRITE_TO_EMPTY_BLOCK_OUTPUT_STREAM, 98) \ + M(UNKNOWN_PACKET_FROM_CLIENT, 99) \ + M(UNKNOWN_PACKET_FROM_SERVER, 100) \ + M(UNEXPECTED_PACKET_FROM_CLIENT, 101) \ + M(UNEXPECTED_PACKET_FROM_SERVER, 102) \ + M(RECEIVED_DATA_FOR_WRONG_QUERY_ID, 103) \ + M(TOO_SMALL_BUFFER_SIZE, 104) \ + M(CANNOT_READ_HISTORY, 105) \ + M(CANNOT_APPEND_HISTORY, 106) \ + M(FILE_DOESNT_EXIST, 107) \ + M(NO_DATA_TO_INSERT, 108) \ + M(CANNOT_BLOCK_SIGNAL, 109) \ + M(CANNOT_UNBLOCK_SIGNAL, 110) \ + M(CANNOT_MANIPULATE_SIGSET, 111) \ + M(CANNOT_WAIT_FOR_SIGNAL, 112) \ + M(THERE_IS_NO_SESSION, 113) \ + M(CANNOT_CLOCK_GETTIME, 114) \ + M(UNKNOWN_SETTING, 115) \ + M(THERE_IS_NO_DEFAULT_VALUE, 116) \ + M(INCORRECT_DATA, 117) \ + M(ENGINE_REQUIRED, 119) \ + M(CANNOT_INSERT_VALUE_OF_DIFFERENT_SIZE_INTO_TUPLE, 120) \ + M(UNSUPPORTED_JOIN_KEYS, 121) \ + M(INCOMPATIBLE_COLUMNS, 122) \ + M(UNKNOWN_TYPE_OF_AST_NODE, 123) \ + M(INCORRECT_ELEMENT_OF_SET, 124) \ + M(INCORRECT_RESULT_OF_SCALAR_SUBQUERY, 125) \ + M(CANNOT_GET_RETURN_TYPE, 126) \ + M(ILLEGAL_INDEX, 127) \ + M(TOO_LARGE_ARRAY_SIZE, 128) \ + M(FUNCTION_IS_SPECIAL, 129) \ + M(CANNOT_READ_ARRAY_FROM_TEXT, 130) \ + M(TOO_LARGE_STRING_SIZE, 131) \ + M(AGGREGATE_FUNCTION_DOESNT_ALLOW_PARAMETERS, 133) \ + M(PARAMETERS_TO_AGGREGATE_FUNCTIONS_MUST_BE_LITERALS, 134) \ + M(ZERO_ARRAY_OR_TUPLE_INDEX, 135) \ + M(UNKNOWN_ELEMENT_IN_CONFIG, 137) \ + M(EXCESSIVE_ELEMENT_IN_CONFIG, 138) \ + M(NO_ELEMENTS_IN_CONFIG, 139) \ + M(ALL_REQUESTED_COLUMNS_ARE_MISSING, 140) \ + M(SAMPLING_NOT_SUPPORTED, 141) \ + M(NOT_FOUND_NODE, 142) \ + M(FOUND_MORE_THAN_ONE_NODE, 143) \ + M(FIRST_DATE_IS_BIGGER_THAN_LAST_DATE, 144) \ + M(UNKNOWN_OVERFLOW_MODE, 145) \ + M(QUERY_SECTION_DOESNT_MAKE_SENSE, 146) \ + M(NOT_FOUND_FUNCTION_ELEMENT_FOR_AGGREGATE, 147) \ + M(NOT_FOUND_RELATION_ELEMENT_FOR_CONDITION, 148) \ + M(NOT_FOUND_RHS_ELEMENT_FOR_CONDITION, 149) \ + M(EMPTY_LIST_OF_ATTRIBUTES_PASSED, 150) \ + M(INDEX_OF_COLUMN_IN_SORT_CLAUSE_IS_OUT_OF_RANGE, 151) \ + M(UNKNOWN_DIRECTION_OF_SORTING, 152) \ + M(ILLEGAL_DIVISION, 153) \ + M(AGGREGATE_FUNCTION_NOT_APPLICABLE, 154) \ + M(UNKNOWN_RELATION, 155) \ + M(DICTIONARIES_WAS_NOT_LOADED, 156) \ + M(ILLEGAL_OVERFLOW_MODE, 157) \ + M(TOO_MANY_ROWS, 158) \ + M(TIMEOUT_EXCEEDED, 159) \ + M(TOO_SLOW, 160) \ + M(TOO_MANY_COLUMNS, 161) \ + M(TOO_DEEP_SUBQUERIES, 162) \ + M(TOO_DEEP_PIPELINE, 163) \ + M(READONLY, 164) \ + M(TOO_MANY_TEMPORARY_COLUMNS, 165) \ + M(TOO_MANY_TEMPORARY_NON_CONST_COLUMNS, 166) \ + M(TOO_DEEP_AST, 167) \ + M(TOO_BIG_AST, 168) \ + M(BAD_TYPE_OF_FIELD, 169) \ + M(BAD_GET, 170) \ + M(CANNOT_CREATE_DIRECTORY, 172) \ + M(CANNOT_ALLOCATE_MEMORY, 173) \ + M(CYCLIC_ALIASES, 174) \ + M(CHUNK_NOT_FOUND, 176) \ + M(DUPLICATE_CHUNK_NAME, 177) \ + M(MULTIPLE_ALIASES_FOR_EXPRESSION, 178) \ + M(MULTIPLE_EXPRESSIONS_FOR_ALIAS, 179) \ + M(THERE_IS_NO_PROFILE, 180) \ + M(ILLEGAL_FINAL, 181) \ + M(ILLEGAL_PREWHERE, 182) \ + M(UNEXPECTED_EXPRESSION, 183) \ + M(ILLEGAL_AGGREGATION, 184) \ + M(UNSUPPORTED_MYISAM_BLOCK_TYPE, 185) \ + M(UNSUPPORTED_COLLATION_LOCALE, 186) \ + M(COLLATION_COMPARISON_FAILED, 187) \ + M(UNKNOWN_ACTION, 188) \ + M(TABLE_MUST_NOT_BE_CREATED_MANUALLY, 189) \ + M(SIZES_OF_ARRAYS_DOESNT_MATCH, 190) \ + M(SET_SIZE_LIMIT_EXCEEDED, 191) \ + M(UNKNOWN_USER, 192) \ + M(WRONG_PASSWORD, 193) \ + M(REQUIRED_PASSWORD, 194) \ + M(IP_ADDRESS_NOT_ALLOWED, 195) \ + M(UNKNOWN_ADDRESS_PATTERN_TYPE, 196) \ + M(SERVER_REVISION_IS_TOO_OLD, 197) \ + M(DNS_ERROR, 198) \ + M(UNKNOWN_QUOTA, 199) \ + M(QUOTA_DOESNT_ALLOW_KEYS, 200) \ + M(QUOTA_EXPIRED, 201) \ + M(TOO_MANY_SIMULTANEOUS_QUERIES, 202) \ + M(NO_FREE_CONNECTION, 203) \ + M(CANNOT_FSYNC, 204) \ + M(NESTED_TYPE_TOO_DEEP, 205) \ + M(ALIAS_REQUIRED, 206) \ + M(AMBIGUOUS_IDENTIFIER, 207) \ + M(EMPTY_NESTED_TABLE, 208) \ + M(SOCKET_TIMEOUT, 209) \ + M(NETWORK_ERROR, 210) \ + M(EMPTY_QUERY, 211) \ + M(UNKNOWN_LOAD_BALANCING, 212) \ + M(UNKNOWN_TOTALS_MODE, 213) \ + M(CANNOT_STATVFS, 214) \ + M(NOT_AN_AGGREGATE, 215) \ + M(QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING, 216) \ + M(CLIENT_HAS_CONNECTED_TO_WRONG_PORT, 217) \ + M(TABLE_IS_DROPPED, 218) \ + M(DATABASE_NOT_EMPTY, 219) \ + M(DUPLICATE_INTERSERVER_IO_ENDPOINT, 220) \ + M(NO_SUCH_INTERSERVER_IO_ENDPOINT, 221) \ + M(ADDING_REPLICA_TO_NON_EMPTY_TABLE, 222) \ + M(UNEXPECTED_AST_STRUCTURE, 223) \ + M(REPLICA_IS_ALREADY_ACTIVE, 224) \ + M(NO_ZOOKEEPER, 225) \ + M(NO_FILE_IN_DATA_PART, 226) \ + M(UNEXPECTED_FILE_IN_DATA_PART, 227) \ + M(BAD_SIZE_OF_FILE_IN_DATA_PART, 228) \ + M(QUERY_IS_TOO_LARGE, 229) \ + M(NOT_FOUND_EXPECTED_DATA_PART, 230) \ + M(TOO_MANY_UNEXPECTED_DATA_PARTS, 231) \ + M(NO_SUCH_DATA_PART, 232) \ + M(BAD_DATA_PART_NAME, 233) \ + M(NO_REPLICA_HAS_PART, 234) \ + M(DUPLICATE_DATA_PART, 235) \ + M(ABORTED, 236) \ + M(NO_REPLICA_NAME_GIVEN, 237) \ + M(FORMAT_VERSION_TOO_OLD, 238) \ + M(CANNOT_MUNMAP, 239) \ + M(CANNOT_MREMAP, 240) \ + M(MEMORY_LIMIT_EXCEEDED, 241) \ + M(TABLE_IS_READ_ONLY, 242) \ + M(NOT_ENOUGH_SPACE, 243) \ + M(UNEXPECTED_ZOOKEEPER_ERROR, 244) \ + M(CORRUPTED_DATA, 246) \ + M(INCORRECT_MARK, 247) \ + M(INVALID_PARTITION_VALUE, 248) \ + M(NOT_ENOUGH_BLOCK_NUMBERS, 250) \ + M(NO_SUCH_REPLICA, 251) \ + M(TOO_MANY_PARTS, 252) \ + M(REPLICA_IS_ALREADY_EXIST, 253) \ + M(NO_ACTIVE_REPLICAS, 254) \ + M(TOO_MANY_RETRIES_TO_FETCH_PARTS, 255) \ + M(PARTITION_ALREADY_EXISTS, 256) \ + M(PARTITION_DOESNT_EXIST, 257) \ + M(UNION_ALL_RESULT_STRUCTURES_MISMATCH, 258) \ + M(CLIENT_OUTPUT_FORMAT_SPECIFIED, 260) \ + M(UNKNOWN_BLOCK_INFO_FIELD, 261) \ + M(BAD_COLLATION, 262) \ + M(CANNOT_COMPILE_CODE, 263) \ + M(INCOMPATIBLE_TYPE_OF_JOIN, 264) \ + M(NO_AVAILABLE_REPLICA, 265) \ + M(MISMATCH_REPLICAS_DATA_SOURCES, 266) \ + M(STORAGE_DOESNT_SUPPORT_PARALLEL_REPLICAS, 267) \ + M(CPUID_ERROR, 268) \ + M(INFINITE_LOOP, 269) \ + M(CANNOT_COMPRESS, 270) \ + M(CANNOT_DECOMPRESS, 271) \ + M(CANNOT_IO_SUBMIT, 272) \ + M(CANNOT_IO_GETEVENTS, 273) \ + M(AIO_READ_ERROR, 274) \ + M(AIO_WRITE_ERROR, 275) \ + M(INDEX_NOT_USED, 277) \ + M(ALL_CONNECTION_TRIES_FAILED, 279) \ + M(NO_AVAILABLE_DATA, 280) \ + M(DICTIONARY_IS_EMPTY, 281) \ + M(INCORRECT_INDEX, 282) \ + M(UNKNOWN_DISTRIBUTED_PRODUCT_MODE, 283) \ + M(WRONG_GLOBAL_SUBQUERY, 284) \ + M(TOO_FEW_LIVE_REPLICAS, 285) \ + M(UNSATISFIED_QUORUM_FOR_PREVIOUS_WRITE, 286) \ + M(UNKNOWN_FORMAT_VERSION, 287) \ + M(DISTRIBUTED_IN_JOIN_SUBQUERY_DENIED, 288) \ + M(REPLICA_IS_NOT_IN_QUORUM, 289) \ + M(LIMIT_EXCEEDED, 290) \ + M(DATABASE_ACCESS_DENIED, 291) \ + M(MONGODB_CANNOT_AUTHENTICATE, 293) \ + M(INVALID_BLOCK_EXTRA_INFO, 294) \ + M(RECEIVED_EMPTY_DATA, 295) \ + M(NO_REMOTE_SHARD_FOUND, 296) \ + M(SHARD_HAS_NO_CONNECTIONS, 297) \ + M(CANNOT_PIPE, 298) \ + M(CANNOT_FORK, 299) \ + M(CANNOT_DLSYM, 300) \ + M(CANNOT_CREATE_CHILD_PROCESS, 301) \ + M(CHILD_WAS_NOT_EXITED_NORMALLY, 302) \ + M(CANNOT_SELECT, 303) \ + M(CANNOT_WAITPID, 304) \ + M(TABLE_WAS_NOT_DROPPED, 305) \ + M(TOO_DEEP_RECURSION, 306) \ + M(TOO_MANY_BYTES, 307) \ + M(UNEXPECTED_NODE_IN_ZOOKEEPER, 308) \ + M(FUNCTION_CANNOT_HAVE_PARAMETERS, 309) \ + M(INVALID_SHARD_WEIGHT, 317) \ + M(INVALID_CONFIG_PARAMETER, 318) \ + M(UNKNOWN_STATUS_OF_INSERT, 319) \ + M(VALUE_IS_OUT_OF_RANGE_OF_DATA_TYPE, 321) \ + M(BARRIER_TIMEOUT, 335) \ + M(UNKNOWN_DATABASE_ENGINE, 336) \ + M(DDL_GUARD_IS_ACTIVE, 337) \ + M(UNFINISHED, 341) \ + M(METADATA_MISMATCH, 342) \ + M(SUPPORT_IS_DISABLED, 344) \ + M(TABLE_DIFFERS_TOO_MUCH, 345) \ + M(CANNOT_CONVERT_CHARSET, 346) \ + M(CANNOT_LOAD_CONFIG, 347) \ + M(CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN, 349) \ + M(INCOMPATIBLE_SOURCE_TABLES, 350) \ + M(AMBIGUOUS_TABLE_NAME, 351) \ + M(AMBIGUOUS_COLUMN_NAME, 352) \ + M(INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE, 353) \ + M(ZLIB_INFLATE_FAILED, 354) \ + M(ZLIB_DEFLATE_FAILED, 355) \ + M(BAD_LAMBDA, 356) \ + M(RESERVED_IDENTIFIER_NAME, 357) \ + M(INTO_OUTFILE_NOT_ALLOWED, 358) \ + M(TABLE_SIZE_EXCEEDS_MAX_DROP_SIZE_LIMIT, 359) \ + M(CANNOT_CREATE_CHARSET_CONVERTER, 360) \ + M(SEEK_POSITION_OUT_OF_BOUND, 361) \ + M(CURRENT_WRITE_BUFFER_IS_EXHAUSTED, 362) \ + M(CANNOT_CREATE_IO_BUFFER, 363) \ + M(RECEIVED_ERROR_TOO_MANY_REQUESTS, 364) \ + M(SIZES_OF_NESTED_COLUMNS_ARE_INCONSISTENT, 366) \ + M(TOO_MANY_FETCHES, 367) \ + M(ALL_REPLICAS_ARE_STALE, 369) \ + M(DATA_TYPE_CANNOT_BE_USED_IN_TABLES, 370) \ + M(INCONSISTENT_CLUSTER_DEFINITION, 371) \ + M(SESSION_NOT_FOUND, 372) \ + M(SESSION_IS_LOCKED, 373) \ + M(INVALID_SESSION_TIMEOUT, 374) \ + M(CANNOT_DLOPEN, 375) \ + M(CANNOT_PARSE_UUID, 376) \ + M(ILLEGAL_SYNTAX_FOR_DATA_TYPE, 377) \ + M(DATA_TYPE_CANNOT_HAVE_ARGUMENTS, 378) \ + M(UNKNOWN_STATUS_OF_DISTRIBUTED_DDL_TASK, 379) \ + M(CANNOT_KILL, 380) \ + M(HTTP_LENGTH_REQUIRED, 381) \ + M(CANNOT_LOAD_CATBOOST_MODEL, 382) \ + M(CANNOT_APPLY_CATBOOST_MODEL, 383) \ + M(PART_IS_TEMPORARILY_LOCKED, 384) \ + M(MULTIPLE_STREAMS_REQUIRED, 385) \ + M(NO_COMMON_TYPE, 386) \ + M(DICTIONARY_ALREADY_EXISTS, 387) \ + M(CANNOT_ASSIGN_OPTIMIZE, 388) \ + M(INSERT_WAS_DEDUPLICATED, 389) \ + M(CANNOT_GET_CREATE_TABLE_QUERY, 390) \ + M(EXTERNAL_LIBRARY_ERROR, 391) \ + M(QUERY_IS_PROHIBITED, 392) \ + M(THERE_IS_NO_QUERY, 393) \ + M(QUERY_WAS_CANCELLED, 394) \ + M(FUNCTION_THROW_IF_VALUE_IS_NON_ZERO, 395) \ + M(TOO_MANY_ROWS_OR_BYTES, 396) \ + M(QUERY_IS_NOT_SUPPORTED_IN_MATERIALIZED_VIEW, 397) \ + M(UNKNOWN_MUTATION_COMMAND, 398) \ + M(FORMAT_IS_NOT_SUITABLE_FOR_OUTPUT, 399) \ + M(CANNOT_STAT, 400) \ + M(FEATURE_IS_NOT_ENABLED_AT_BUILD_TIME, 401) \ + M(CANNOT_IOSETUP, 402) \ + M(INVALID_JOIN_ON_EXPRESSION, 403) \ + M(BAD_ODBC_CONNECTION_STRING, 404) \ + M(PARTITION_SIZE_EXCEEDS_MAX_DROP_SIZE_LIMIT, 405) \ + M(TOP_AND_LIMIT_TOGETHER, 406) \ + M(DECIMAL_OVERFLOW, 407) \ + M(BAD_REQUEST_PARAMETER, 408) \ + M(EXTERNAL_EXECUTABLE_NOT_FOUND, 409) \ + M(EXTERNAL_SERVER_IS_NOT_RESPONDING, 410) \ + M(PTHREAD_ERROR, 411) \ + M(NETLINK_ERROR, 412) \ + M(CANNOT_SET_SIGNAL_HANDLER, 413) \ + M(ALL_REPLICAS_LOST, 415) \ + M(REPLICA_STATUS_CHANGED, 416) \ + M(EXPECTED_ALL_OR_ANY, 417) \ + M(UNKNOWN_JOIN, 418) \ + M(MULTIPLE_ASSIGNMENTS_TO_COLUMN, 419) \ + M(CANNOT_UPDATE_COLUMN, 420) \ + M(CANNOT_ADD_DIFFERENT_AGGREGATE_STATES, 421) \ + M(UNSUPPORTED_URI_SCHEME, 422) \ + M(CANNOT_GETTIMEOFDAY, 423) \ + M(CANNOT_LINK, 424) \ + M(SYSTEM_ERROR, 425) \ + M(CANNOT_COMPILE_REGEXP, 427) \ + M(UNKNOWN_LOG_LEVEL, 428) \ + M(FAILED_TO_GETPWUID, 429) \ + M(MISMATCHING_USERS_FOR_PROCESS_AND_DATA, 430) \ + M(ILLEGAL_SYNTAX_FOR_CODEC_TYPE, 431) \ + M(UNKNOWN_CODEC, 432) \ + M(ILLEGAL_CODEC_PARAMETER, 433) \ + M(CANNOT_PARSE_PROTOBUF_SCHEMA, 434) \ + M(NO_DATA_FOR_REQUIRED_PROTOBUF_FIELD, 435) \ + M(PROTOBUF_BAD_CAST, 436) \ + M(PROTOBUF_FIELD_NOT_REPEATED, 437) \ + M(DATA_TYPE_CANNOT_BE_PROMOTED, 438) \ + M(CANNOT_SCHEDULE_TASK, 439) \ + M(INVALID_LIMIT_EXPRESSION, 440) \ + M(CANNOT_PARSE_DOMAIN_VALUE_FROM_STRING, 441) \ + M(BAD_DATABASE_FOR_TEMPORARY_TABLE, 442) \ + M(NO_COMMON_COLUMNS_WITH_PROTOBUF_SCHEMA, 443) \ + M(UNKNOWN_PROTOBUF_FORMAT, 444) \ + M(CANNOT_MPROTECT, 445) \ + M(FUNCTION_NOT_ALLOWED, 446) \ + M(HYPERSCAN_CANNOT_SCAN_TEXT, 447) \ + M(BROTLI_READ_FAILED, 448) \ + M(BROTLI_WRITE_FAILED, 449) \ + M(BAD_TTL_EXPRESSION, 450) \ + M(BAD_TTL_FILE, 451) \ + M(SETTING_CONSTRAINT_VIOLATION, 452) \ + M(MYSQL_CLIENT_INSUFFICIENT_CAPABILITIES, 453) \ + M(OPENSSL_ERROR, 454) \ + M(SUSPICIOUS_TYPE_FOR_LOW_CARDINALITY, 455) \ + M(UNKNOWN_QUERY_PARAMETER, 456) \ + M(BAD_QUERY_PARAMETER, 457) \ + M(CANNOT_UNLINK, 458) \ + M(CANNOT_SET_THREAD_PRIORITY, 459) \ + M(CANNOT_CREATE_TIMER, 460) \ + M(CANNOT_SET_TIMER_PERIOD, 461) \ + M(CANNOT_DELETE_TIMER, 462) \ + M(CANNOT_FCNTL, 463) \ + M(CANNOT_PARSE_ELF, 464) \ + M(CANNOT_PARSE_DWARF, 465) \ + M(INSECURE_PATH, 466) \ + M(CANNOT_PARSE_BOOL, 467) \ + M(CANNOT_PTHREAD_ATTR, 468) \ + M(VIOLATED_CONSTRAINT, 469) \ + M(QUERY_IS_NOT_SUPPORTED_IN_LIVE_VIEW, 470) \ + M(INVALID_SETTING_VALUE, 471) \ + M(READONLY_SETTING, 472) \ + M(DEADLOCK_AVOIDED, 473) \ + M(INVALID_TEMPLATE_FORMAT, 474) \ + M(INVALID_WITH_FILL_EXPRESSION, 475) \ + M(WITH_TIES_WITHOUT_ORDER_BY, 476) \ + M(INVALID_USAGE_OF_INPUT, 477) \ + M(UNKNOWN_POLICY, 478) \ + M(UNKNOWN_DISK, 479) \ + M(UNKNOWN_PROTOCOL, 480) \ + M(PATH_ACCESS_DENIED, 481) \ + M(DICTIONARY_ACCESS_DENIED, 482) \ + M(TOO_MANY_REDIRECTS, 483) \ + M(INTERNAL_REDIS_ERROR, 484) \ + M(SCALAR_ALREADY_EXISTS, 485) \ + M(CANNOT_GET_CREATE_DICTIONARY_QUERY, 487) \ + M(UNKNOWN_DICTIONARY, 488) \ + M(INCORRECT_DICTIONARY_DEFINITION, 489) \ + M(CANNOT_FORMAT_DATETIME, 490) \ + M(UNACCEPTABLE_URL, 491) \ + M(ACCESS_ENTITY_NOT_FOUND, 492) \ + M(ACCESS_ENTITY_ALREADY_EXISTS, 493) \ + M(ACCESS_ENTITY_FOUND_DUPLICATES, 494) \ + M(ACCESS_STORAGE_READONLY, 495) \ + M(QUOTA_REQUIRES_CLIENT_KEY, 496) \ + M(ACCESS_DENIED, 497) \ + M(LIMIT_BY_WITH_TIES_IS_NOT_SUPPORTED, 498) \ + M(S3_ERROR, 499) \ + M(CANNOT_CREATE_DATABASE, 501) \ + M(CANNOT_SIGQUEUE, 502) \ + M(AGGREGATE_FUNCTION_THROW, 503) \ + M(FILE_ALREADY_EXISTS, 504) \ + M(CANNOT_DELETE_DIRECTORY, 505) \ + M(UNEXPECTED_ERROR_CODE, 506) \ + M(UNABLE_TO_SKIP_UNUSED_SHARDS, 507) \ + M(UNKNOWN_ACCESS_TYPE, 508) \ + M(INVALID_GRANT, 509) \ + M(CACHE_DICTIONARY_UPDATE_FAIL, 510) \ + M(UNKNOWN_ROLE, 511) \ + M(SET_NON_GRANTED_ROLE, 512) \ + M(UNKNOWN_PART_TYPE, 513) \ + M(ACCESS_STORAGE_FOR_INSERTION_NOT_FOUND, 514) \ + M(INCORRECT_ACCESS_ENTITY_DEFINITION, 515) \ + M(AUTHENTICATION_FAILED, 516) \ + M(CANNOT_ASSIGN_ALTER, 517) \ + M(CANNOT_COMMIT_OFFSET, 518) \ + M(NO_REMOTE_SHARD_AVAILABLE, 519) \ + M(CANNOT_DETACH_DICTIONARY_AS_TABLE, 520) \ + M(ATOMIC_RENAME_FAIL, 521) \ + M(UNKNOWN_ROW_POLICY, 523) \ + M(ALTER_OF_COLUMN_IS_FORBIDDEN, 524) \ + M(INCORRECT_DISK_INDEX, 525) \ + M(UNKNOWN_VOLUME_TYPE, 526) \ + M(NO_SUITABLE_FUNCTION_IMPLEMENTATION, 527) \ + M(CASSANDRA_INTERNAL_ERROR, 528) \ + M(NOT_A_LEADER, 529) \ + M(CANNOT_CONNECT_RABBITMQ, 530) \ + M(CANNOT_FSTAT, 531) \ + M(LDAP_ERROR, 532) \ + M(INCONSISTENT_RESERVATIONS, 533) \ + M(NO_RESERVATIONS_PROVIDED, 534) \ + M(UNKNOWN_RAID_TYPE, 535) \ + M(CANNOT_RESTORE_FROM_FIELD_DUMP, 536) \ + M(ILLEGAL_MYSQL_VARIABLE, 537) \ + M(MYSQL_SYNTAX_ERROR, 538) \ + M(CANNOT_BIND_RABBITMQ_EXCHANGE, 539) \ + M(CANNOT_DECLARE_RABBITMQ_EXCHANGE, 540) \ + M(CANNOT_CREATE_RABBITMQ_QUEUE_BINDING, 541) \ + M(CANNOT_REMOVE_RABBITMQ_EXCHANGE, 542) \ + M(UNKNOWN_MYSQL_DATATYPES_SUPPORT_LEVEL, 543) \ + M(ROW_AND_ROWS_TOGETHER, 544) \ + M(FIRST_AND_NEXT_TOGETHER, 545) \ + M(NO_ROW_DELIMITER, 546) \ + M(INVALID_RAID_TYPE, 547) \ + M(UNKNOWN_VOLUME, 548) \ + \ + M(KEEPER_EXCEPTION, 999) \ + M(POCO_EXCEPTION, 1000) \ + M(STD_EXCEPTION, 1001) \ + M(UNKNOWN_EXCEPTION, 1002) \ + \ + M(CONDITIONAL_TREE_PARENT_NOT_FOUND, 2001) \ + M(ILLEGAL_PROJECTION_MANIPULATOR, 2002) \ + M(UNRECOGNIZED_ARGUMENTS, 2003) +/* See DB::ErrorCodes::END */ + namespace DB { namespace ErrorCodes { - /** Previously, these constants were located in one enum. - * But in this case there is a problem: when you add a new constant, you need to recompile - * all translation units that use at least one constant (almost the whole project). - * Therefore it is made so that definitions of constants are located here, in one file, - * and their declaration are in different files, at the place of use. - */ + #define M(NAME, VALUE) extern const Value NAME = VALUE; + APPLY_FOR_ERROR_CODES(M) + #undef M - extern const int UNSUPPORTED_METHOD = 1; - extern const int UNSUPPORTED_PARAMETER = 2; - extern const int UNEXPECTED_END_OF_FILE = 3; - extern const int EXPECTED_END_OF_FILE = 4; - extern const int CANNOT_PARSE_TEXT = 6; - extern const int INCORRECT_NUMBER_OF_COLUMNS = 7; - extern const int THERE_IS_NO_COLUMN = 8; - extern const int SIZES_OF_COLUMNS_DOESNT_MATCH = 9; - extern const int NOT_FOUND_COLUMN_IN_BLOCK = 10; - extern const int POSITION_OUT_OF_BOUND = 11; - extern const int PARAMETER_OUT_OF_BOUND = 12; - extern const int SIZES_OF_COLUMNS_IN_TUPLE_DOESNT_MATCH = 13; - extern const int DUPLICATE_COLUMN = 15; - extern const int NO_SUCH_COLUMN_IN_TABLE = 16; - extern const int DELIMITER_IN_STRING_LITERAL_DOESNT_MATCH = 17; - extern const int CANNOT_INSERT_ELEMENT_INTO_CONSTANT_COLUMN = 18; - extern const int SIZE_OF_FIXED_STRING_DOESNT_MATCH = 19; - extern const int NUMBER_OF_COLUMNS_DOESNT_MATCH = 20; - extern const int CANNOT_READ_ALL_DATA_FROM_TAB_SEPARATED_INPUT = 21; - extern const int CANNOT_PARSE_ALL_VALUE_FROM_TAB_SEPARATED_INPUT = 22; - extern const int CANNOT_READ_FROM_ISTREAM = 23; - extern const int CANNOT_WRITE_TO_OSTREAM = 24; - extern const int CANNOT_PARSE_ESCAPE_SEQUENCE = 25; - extern const int CANNOT_PARSE_QUOTED_STRING = 26; - extern const int CANNOT_PARSE_INPUT_ASSERTION_FAILED = 27; - extern const int CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER = 28; - extern const int CANNOT_PRINT_INTEGER = 29; - extern const int CANNOT_READ_SIZE_OF_COMPRESSED_CHUNK = 30; - extern const int CANNOT_READ_COMPRESSED_CHUNK = 31; - extern const int ATTEMPT_TO_READ_AFTER_EOF = 32; - extern const int CANNOT_READ_ALL_DATA = 33; - extern const int TOO_MANY_ARGUMENTS_FOR_FUNCTION = 34; - extern const int TOO_FEW_ARGUMENTS_FOR_FUNCTION = 35; - extern const int BAD_ARGUMENTS = 36; - extern const int UNKNOWN_ELEMENT_IN_AST = 37; - extern const int CANNOT_PARSE_DATE = 38; - extern const int TOO_LARGE_SIZE_COMPRESSED = 39; - extern const int CHECKSUM_DOESNT_MATCH = 40; - extern const int CANNOT_PARSE_DATETIME = 41; - extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH = 42; - extern const int ILLEGAL_TYPE_OF_ARGUMENT = 43; - extern const int ILLEGAL_COLUMN = 44; - extern const int ILLEGAL_NUMBER_OF_RESULT_COLUMNS = 45; - extern const int UNKNOWN_FUNCTION = 46; - extern const int UNKNOWN_IDENTIFIER = 47; - extern const int NOT_IMPLEMENTED = 48; - extern const int LOGICAL_ERROR = 49; - extern const int UNKNOWN_TYPE = 50; - extern const int EMPTY_LIST_OF_COLUMNS_QUERIED = 51; - extern const int COLUMN_QUERIED_MORE_THAN_ONCE = 52; - extern const int TYPE_MISMATCH = 53; - extern const int STORAGE_DOESNT_ALLOW_PARAMETERS = 54; - extern const int STORAGE_REQUIRES_PARAMETER = 55; - extern const int UNKNOWN_STORAGE = 56; - extern const int TABLE_ALREADY_EXISTS = 57; - extern const int TABLE_METADATA_ALREADY_EXISTS = 58; - extern const int ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER = 59; - extern const int UNKNOWN_TABLE = 60; - extern const int ONLY_FILTER_COLUMN_IN_BLOCK = 61; - extern const int SYNTAX_ERROR = 62; - extern const int UNKNOWN_AGGREGATE_FUNCTION = 63; - extern const int CANNOT_READ_AGGREGATE_FUNCTION_FROM_TEXT = 64; - extern const int CANNOT_WRITE_AGGREGATE_FUNCTION_AS_TEXT = 65; - extern const int NOT_A_COLUMN = 66; - extern const int ILLEGAL_KEY_OF_AGGREGATION = 67; - extern const int CANNOT_GET_SIZE_OF_FIELD = 68; - extern const int ARGUMENT_OUT_OF_BOUND = 69; - extern const int CANNOT_CONVERT_TYPE = 70; - extern const int CANNOT_WRITE_AFTER_END_OF_BUFFER = 71; - extern const int CANNOT_PARSE_NUMBER = 72; - extern const int UNKNOWN_FORMAT = 73; - extern const int CANNOT_READ_FROM_FILE_DESCRIPTOR = 74; - extern const int CANNOT_WRITE_TO_FILE_DESCRIPTOR = 75; - extern const int CANNOT_OPEN_FILE = 76; - extern const int CANNOT_CLOSE_FILE = 77; - extern const int UNKNOWN_TYPE_OF_QUERY = 78; - extern const int INCORRECT_FILE_NAME = 79; - extern const int INCORRECT_QUERY = 80; - extern const int UNKNOWN_DATABASE = 81; - extern const int DATABASE_ALREADY_EXISTS = 82; - extern const int DIRECTORY_DOESNT_EXIST = 83; - extern const int DIRECTORY_ALREADY_EXISTS = 84; - extern const int FORMAT_IS_NOT_SUITABLE_FOR_INPUT = 85; - extern const int RECEIVED_ERROR_FROM_REMOTE_IO_SERVER = 86; - extern const int CANNOT_SEEK_THROUGH_FILE = 87; - extern const int CANNOT_TRUNCATE_FILE = 88; - extern const int UNKNOWN_COMPRESSION_METHOD = 89; - extern const int EMPTY_LIST_OF_COLUMNS_PASSED = 90; - extern const int SIZES_OF_MARKS_FILES_ARE_INCONSISTENT = 91; - extern const int EMPTY_DATA_PASSED = 92; - extern const int UNKNOWN_AGGREGATED_DATA_VARIANT = 93; - extern const int CANNOT_MERGE_DIFFERENT_AGGREGATED_DATA_VARIANTS = 94; - extern const int CANNOT_READ_FROM_SOCKET = 95; - extern const int CANNOT_WRITE_TO_SOCKET = 96; - extern const int CANNOT_READ_ALL_DATA_FROM_CHUNKED_INPUT = 97; - extern const int CANNOT_WRITE_TO_EMPTY_BLOCK_OUTPUT_STREAM = 98; - extern const int UNKNOWN_PACKET_FROM_CLIENT = 99; - extern const int UNKNOWN_PACKET_FROM_SERVER = 100; - extern const int UNEXPECTED_PACKET_FROM_CLIENT = 101; - extern const int UNEXPECTED_PACKET_FROM_SERVER = 102; - extern const int RECEIVED_DATA_FOR_WRONG_QUERY_ID = 103; - extern const int TOO_SMALL_BUFFER_SIZE = 104; - extern const int CANNOT_READ_HISTORY = 105; - extern const int CANNOT_APPEND_HISTORY = 106; - extern const int FILE_DOESNT_EXIST = 107; - extern const int NO_DATA_TO_INSERT = 108; - extern const int CANNOT_BLOCK_SIGNAL = 109; - extern const int CANNOT_UNBLOCK_SIGNAL = 110; - extern const int CANNOT_MANIPULATE_SIGSET = 111; - extern const int CANNOT_WAIT_FOR_SIGNAL = 112; - extern const int THERE_IS_NO_SESSION = 113; - extern const int CANNOT_CLOCK_GETTIME = 114; - extern const int UNKNOWN_SETTING = 115; - extern const int THERE_IS_NO_DEFAULT_VALUE = 116; - extern const int INCORRECT_DATA = 117; - extern const int ENGINE_REQUIRED = 119; - extern const int CANNOT_INSERT_VALUE_OF_DIFFERENT_SIZE_INTO_TUPLE = 120; - extern const int UNSUPPORTED_JOIN_KEYS = 121; - extern const int INCOMPATIBLE_COLUMNS = 122; - extern const int UNKNOWN_TYPE_OF_AST_NODE = 123; - extern const int INCORRECT_ELEMENT_OF_SET = 124; - extern const int INCORRECT_RESULT_OF_SCALAR_SUBQUERY = 125; - extern const int CANNOT_GET_RETURN_TYPE = 126; - extern const int ILLEGAL_INDEX = 127; - extern const int TOO_LARGE_ARRAY_SIZE = 128; - extern const int FUNCTION_IS_SPECIAL = 129; - extern const int CANNOT_READ_ARRAY_FROM_TEXT = 130; - extern const int TOO_LARGE_STRING_SIZE = 131; - extern const int AGGREGATE_FUNCTION_DOESNT_ALLOW_PARAMETERS = 133; - extern const int PARAMETERS_TO_AGGREGATE_FUNCTIONS_MUST_BE_LITERALS = 134; - extern const int ZERO_ARRAY_OR_TUPLE_INDEX = 135; - extern const int UNKNOWN_ELEMENT_IN_CONFIG = 137; - extern const int EXCESSIVE_ELEMENT_IN_CONFIG = 138; - extern const int NO_ELEMENTS_IN_CONFIG = 139; - extern const int ALL_REQUESTED_COLUMNS_ARE_MISSING = 140; - extern const int SAMPLING_NOT_SUPPORTED = 141; - extern const int NOT_FOUND_NODE = 142; - extern const int FOUND_MORE_THAN_ONE_NODE = 143; - extern const int FIRST_DATE_IS_BIGGER_THAN_LAST_DATE = 144; - extern const int UNKNOWN_OVERFLOW_MODE = 145; - extern const int QUERY_SECTION_DOESNT_MAKE_SENSE = 146; - extern const int NOT_FOUND_FUNCTION_ELEMENT_FOR_AGGREGATE = 147; - extern const int NOT_FOUND_RELATION_ELEMENT_FOR_CONDITION = 148; - extern const int NOT_FOUND_RHS_ELEMENT_FOR_CONDITION = 149; - extern const int EMPTY_LIST_OF_ATTRIBUTES_PASSED = 150; - extern const int INDEX_OF_COLUMN_IN_SORT_CLAUSE_IS_OUT_OF_RANGE = 151; - extern const int UNKNOWN_DIRECTION_OF_SORTING = 152; - extern const int ILLEGAL_DIVISION = 153; - extern const int AGGREGATE_FUNCTION_NOT_APPLICABLE = 154; - extern const int UNKNOWN_RELATION = 155; - extern const int DICTIONARIES_WAS_NOT_LOADED = 156; - extern const int ILLEGAL_OVERFLOW_MODE = 157; - extern const int TOO_MANY_ROWS = 158; - extern const int TIMEOUT_EXCEEDED = 159; - extern const int TOO_SLOW = 160; - extern const int TOO_MANY_COLUMNS = 161; - extern const int TOO_DEEP_SUBQUERIES = 162; - extern const int TOO_DEEP_PIPELINE = 163; - extern const int READONLY = 164; - extern const int TOO_MANY_TEMPORARY_COLUMNS = 165; - extern const int TOO_MANY_TEMPORARY_NON_CONST_COLUMNS = 166; - extern const int TOO_DEEP_AST = 167; - extern const int TOO_BIG_AST = 168; - extern const int BAD_TYPE_OF_FIELD = 169; - extern const int BAD_GET = 170; - extern const int CANNOT_CREATE_DIRECTORY = 172; - extern const int CANNOT_ALLOCATE_MEMORY = 173; - extern const int CYCLIC_ALIASES = 174; - extern const int CHUNK_NOT_FOUND = 176; - extern const int DUPLICATE_CHUNK_NAME = 177; - extern const int MULTIPLE_ALIASES_FOR_EXPRESSION = 178; - extern const int MULTIPLE_EXPRESSIONS_FOR_ALIAS = 179; - extern const int THERE_IS_NO_PROFILE = 180; - extern const int ILLEGAL_FINAL = 181; - extern const int ILLEGAL_PREWHERE = 182; - extern const int UNEXPECTED_EXPRESSION = 183; - extern const int ILLEGAL_AGGREGATION = 184; - extern const int UNSUPPORTED_MYISAM_BLOCK_TYPE = 185; - extern const int UNSUPPORTED_COLLATION_LOCALE = 186; - extern const int COLLATION_COMPARISON_FAILED = 187; - extern const int UNKNOWN_ACTION = 188; - extern const int TABLE_MUST_NOT_BE_CREATED_MANUALLY = 189; - extern const int SIZES_OF_ARRAYS_DOESNT_MATCH = 190; - extern const int SET_SIZE_LIMIT_EXCEEDED = 191; - extern const int UNKNOWN_USER = 192; - extern const int WRONG_PASSWORD = 193; - extern const int REQUIRED_PASSWORD = 194; - extern const int IP_ADDRESS_NOT_ALLOWED = 195; - extern const int UNKNOWN_ADDRESS_PATTERN_TYPE = 196; - extern const int SERVER_REVISION_IS_TOO_OLD = 197; - extern const int DNS_ERROR = 198; - extern const int UNKNOWN_QUOTA = 199; - extern const int QUOTA_DOESNT_ALLOW_KEYS = 200; - extern const int QUOTA_EXPIRED = 201; - extern const int TOO_MANY_SIMULTANEOUS_QUERIES = 202; - extern const int NO_FREE_CONNECTION = 203; - extern const int CANNOT_FSYNC = 204; - extern const int NESTED_TYPE_TOO_DEEP = 205; - extern const int ALIAS_REQUIRED = 206; - extern const int AMBIGUOUS_IDENTIFIER = 207; - extern const int EMPTY_NESTED_TABLE = 208; - extern const int SOCKET_TIMEOUT = 209; - extern const int NETWORK_ERROR = 210; - extern const int EMPTY_QUERY = 211; - extern const int UNKNOWN_LOAD_BALANCING = 212; - extern const int UNKNOWN_TOTALS_MODE = 213; - extern const int CANNOT_STATVFS = 214; - extern const int NOT_AN_AGGREGATE = 215; - extern const int QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING = 216; - extern const int CLIENT_HAS_CONNECTED_TO_WRONG_PORT = 217; - extern const int TABLE_IS_DROPPED = 218; - extern const int DATABASE_NOT_EMPTY = 219; - extern const int DUPLICATE_INTERSERVER_IO_ENDPOINT = 220; - extern const int NO_SUCH_INTERSERVER_IO_ENDPOINT = 221; - extern const int ADDING_REPLICA_TO_NON_EMPTY_TABLE = 222; - extern const int UNEXPECTED_AST_STRUCTURE = 223; - extern const int REPLICA_IS_ALREADY_ACTIVE = 224; - extern const int NO_ZOOKEEPER = 225; - extern const int NO_FILE_IN_DATA_PART = 226; - extern const int UNEXPECTED_FILE_IN_DATA_PART = 227; - extern const int BAD_SIZE_OF_FILE_IN_DATA_PART = 228; - extern const int QUERY_IS_TOO_LARGE = 229; - extern const int NOT_FOUND_EXPECTED_DATA_PART = 230; - extern const int TOO_MANY_UNEXPECTED_DATA_PARTS = 231; - extern const int NO_SUCH_DATA_PART = 232; - extern const int BAD_DATA_PART_NAME = 233; - extern const int NO_REPLICA_HAS_PART = 234; - extern const int DUPLICATE_DATA_PART = 235; - extern const int ABORTED = 236; - extern const int NO_REPLICA_NAME_GIVEN = 237; - extern const int FORMAT_VERSION_TOO_OLD = 238; - extern const int CANNOT_MUNMAP = 239; - extern const int CANNOT_MREMAP = 240; - extern const int MEMORY_LIMIT_EXCEEDED = 241; - extern const int TABLE_IS_READ_ONLY = 242; - extern const int NOT_ENOUGH_SPACE = 243; - extern const int UNEXPECTED_ZOOKEEPER_ERROR = 244; - extern const int CORRUPTED_DATA = 246; - extern const int INCORRECT_MARK = 247; - extern const int INVALID_PARTITION_VALUE = 248; - extern const int NOT_ENOUGH_BLOCK_NUMBERS = 250; - extern const int NO_SUCH_REPLICA = 251; - extern const int TOO_MANY_PARTS = 252; - extern const int REPLICA_IS_ALREADY_EXIST = 253; - extern const int NO_ACTIVE_REPLICAS = 254; - extern const int TOO_MANY_RETRIES_TO_FETCH_PARTS = 255; - extern const int PARTITION_ALREADY_EXISTS = 256; - extern const int PARTITION_DOESNT_EXIST = 257; - extern const int UNION_ALL_RESULT_STRUCTURES_MISMATCH = 258; - extern const int CLIENT_OUTPUT_FORMAT_SPECIFIED = 260; - extern const int UNKNOWN_BLOCK_INFO_FIELD = 261; - extern const int BAD_COLLATION = 262; - extern const int CANNOT_COMPILE_CODE = 263; - extern const int INCOMPATIBLE_TYPE_OF_JOIN = 264; - extern const int NO_AVAILABLE_REPLICA = 265; - extern const int MISMATCH_REPLICAS_DATA_SOURCES = 266; - extern const int STORAGE_DOESNT_SUPPORT_PARALLEL_REPLICAS = 267; - extern const int CPUID_ERROR = 268; - extern const int INFINITE_LOOP = 269; - extern const int CANNOT_COMPRESS = 270; - extern const int CANNOT_DECOMPRESS = 271; - extern const int CANNOT_IO_SUBMIT = 272; - extern const int CANNOT_IO_GETEVENTS = 273; - extern const int AIO_READ_ERROR = 274; - extern const int AIO_WRITE_ERROR = 275; - extern const int INDEX_NOT_USED = 277; - extern const int ALL_CONNECTION_TRIES_FAILED = 279; - extern const int NO_AVAILABLE_DATA = 280; - extern const int DICTIONARY_IS_EMPTY = 281; - extern const int INCORRECT_INDEX = 282; - extern const int UNKNOWN_DISTRIBUTED_PRODUCT_MODE = 283; - extern const int WRONG_GLOBAL_SUBQUERY = 284; - extern const int TOO_FEW_LIVE_REPLICAS = 285; - extern const int UNSATISFIED_QUORUM_FOR_PREVIOUS_WRITE = 286; - extern const int UNKNOWN_FORMAT_VERSION = 287; - extern const int DISTRIBUTED_IN_JOIN_SUBQUERY_DENIED = 288; - extern const int REPLICA_IS_NOT_IN_QUORUM = 289; - extern const int LIMIT_EXCEEDED = 290; - extern const int DATABASE_ACCESS_DENIED = 291; - extern const int MONGODB_CANNOT_AUTHENTICATE = 293; - extern const int INVALID_BLOCK_EXTRA_INFO = 294; - extern const int RECEIVED_EMPTY_DATA = 295; - extern const int NO_REMOTE_SHARD_FOUND = 296; - extern const int SHARD_HAS_NO_CONNECTIONS = 297; - extern const int CANNOT_PIPE = 298; - extern const int CANNOT_FORK = 299; - extern const int CANNOT_DLSYM = 300; - extern const int CANNOT_CREATE_CHILD_PROCESS = 301; - extern const int CHILD_WAS_NOT_EXITED_NORMALLY = 302; - extern const int CANNOT_SELECT = 303; - extern const int CANNOT_WAITPID = 304; - extern const int TABLE_WAS_NOT_DROPPED = 305; - extern const int TOO_DEEP_RECURSION = 306; - extern const int TOO_MANY_BYTES = 307; - extern const int UNEXPECTED_NODE_IN_ZOOKEEPER = 308; - extern const int FUNCTION_CANNOT_HAVE_PARAMETERS = 309; - extern const int INVALID_SHARD_WEIGHT = 317; - extern const int INVALID_CONFIG_PARAMETER = 318; - extern const int UNKNOWN_STATUS_OF_INSERT = 319; - extern const int VALUE_IS_OUT_OF_RANGE_OF_DATA_TYPE = 321; - extern const int BARRIER_TIMEOUT = 335; - extern const int UNKNOWN_DATABASE_ENGINE = 336; - extern const int DDL_GUARD_IS_ACTIVE = 337; - extern const int UNFINISHED = 341; - extern const int METADATA_MISMATCH = 342; - extern const int SUPPORT_IS_DISABLED = 344; - extern const int TABLE_DIFFERS_TOO_MUCH = 345; - extern const int CANNOT_CONVERT_CHARSET = 346; - extern const int CANNOT_LOAD_CONFIG = 347; - extern const int CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN = 349; - extern const int INCOMPATIBLE_SOURCE_TABLES = 350; - extern const int AMBIGUOUS_TABLE_NAME = 351; - extern const int AMBIGUOUS_COLUMN_NAME = 352; - extern const int INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE = 353; - extern const int ZLIB_INFLATE_FAILED = 354; - extern const int ZLIB_DEFLATE_FAILED = 355; - extern const int BAD_LAMBDA = 356; - extern const int RESERVED_IDENTIFIER_NAME = 357; - extern const int INTO_OUTFILE_NOT_ALLOWED = 358; - extern const int TABLE_SIZE_EXCEEDS_MAX_DROP_SIZE_LIMIT = 359; - extern const int CANNOT_CREATE_CHARSET_CONVERTER = 360; - extern const int SEEK_POSITION_OUT_OF_BOUND = 361; - extern const int CURRENT_WRITE_BUFFER_IS_EXHAUSTED = 362; - extern const int CANNOT_CREATE_IO_BUFFER = 363; - extern const int RECEIVED_ERROR_TOO_MANY_REQUESTS = 364; - extern const int SIZES_OF_NESTED_COLUMNS_ARE_INCONSISTENT = 366; - extern const int TOO_MANY_FETCHES = 367; - extern const int ALL_REPLICAS_ARE_STALE = 369; - extern const int DATA_TYPE_CANNOT_BE_USED_IN_TABLES = 370; - extern const int INCONSISTENT_CLUSTER_DEFINITION = 371; - extern const int SESSION_NOT_FOUND = 372; - extern const int SESSION_IS_LOCKED = 373; - extern const int INVALID_SESSION_TIMEOUT = 374; - extern const int CANNOT_DLOPEN = 375; - extern const int CANNOT_PARSE_UUID = 376; - extern const int ILLEGAL_SYNTAX_FOR_DATA_TYPE = 377; - extern const int DATA_TYPE_CANNOT_HAVE_ARGUMENTS = 378; - extern const int UNKNOWN_STATUS_OF_DISTRIBUTED_DDL_TASK = 379; - extern const int CANNOT_KILL = 380; - extern const int HTTP_LENGTH_REQUIRED = 381; - extern const int CANNOT_LOAD_CATBOOST_MODEL = 382; - extern const int CANNOT_APPLY_CATBOOST_MODEL = 383; - extern const int PART_IS_TEMPORARILY_LOCKED = 384; - extern const int MULTIPLE_STREAMS_REQUIRED = 385; - extern const int NO_COMMON_TYPE = 386; - extern const int DICTIONARY_ALREADY_EXISTS = 387; - extern const int CANNOT_ASSIGN_OPTIMIZE = 388; - extern const int INSERT_WAS_DEDUPLICATED = 389; - extern const int CANNOT_GET_CREATE_TABLE_QUERY = 390; - extern const int EXTERNAL_LIBRARY_ERROR = 391; - extern const int QUERY_IS_PROHIBITED = 392; - extern const int THERE_IS_NO_QUERY = 393; - extern const int QUERY_WAS_CANCELLED = 394; - extern const int FUNCTION_THROW_IF_VALUE_IS_NON_ZERO = 395; - extern const int TOO_MANY_ROWS_OR_BYTES = 396; - extern const int QUERY_IS_NOT_SUPPORTED_IN_MATERIALIZED_VIEW = 397; - extern const int UNKNOWN_MUTATION_COMMAND = 398; - extern const int FORMAT_IS_NOT_SUITABLE_FOR_OUTPUT = 399; - extern const int CANNOT_STAT = 400; - extern const int FEATURE_IS_NOT_ENABLED_AT_BUILD_TIME = 401; - extern const int CANNOT_IOSETUP = 402; - extern const int INVALID_JOIN_ON_EXPRESSION = 403; - extern const int BAD_ODBC_CONNECTION_STRING = 404; - extern const int PARTITION_SIZE_EXCEEDS_MAX_DROP_SIZE_LIMIT = 405; - extern const int TOP_AND_LIMIT_TOGETHER = 406; - extern const int DECIMAL_OVERFLOW = 407; - extern const int BAD_REQUEST_PARAMETER = 408; - extern const int EXTERNAL_EXECUTABLE_NOT_FOUND = 409; - extern const int EXTERNAL_SERVER_IS_NOT_RESPONDING = 410; - extern const int PTHREAD_ERROR = 411; - extern const int NETLINK_ERROR = 412; - extern const int CANNOT_SET_SIGNAL_HANDLER = 413; - extern const int ALL_REPLICAS_LOST = 415; - extern const int REPLICA_STATUS_CHANGED = 416; - extern const int EXPECTED_ALL_OR_ANY = 417; - extern const int UNKNOWN_JOIN = 418; - extern const int MULTIPLE_ASSIGNMENTS_TO_COLUMN = 419; - extern const int CANNOT_UPDATE_COLUMN = 420; - extern const int CANNOT_ADD_DIFFERENT_AGGREGATE_STATES = 421; - extern const int UNSUPPORTED_URI_SCHEME = 422; - extern const int CANNOT_GETTIMEOFDAY = 423; - extern const int CANNOT_LINK = 424; - extern const int SYSTEM_ERROR = 425; - extern const int CANNOT_COMPILE_REGEXP = 427; - extern const int UNKNOWN_LOG_LEVEL = 428; - extern const int FAILED_TO_GETPWUID = 429; - extern const int MISMATCHING_USERS_FOR_PROCESS_AND_DATA = 430; - extern const int ILLEGAL_SYNTAX_FOR_CODEC_TYPE = 431; - extern const int UNKNOWN_CODEC = 432; - extern const int ILLEGAL_CODEC_PARAMETER = 433; - extern const int CANNOT_PARSE_PROTOBUF_SCHEMA = 434; - extern const int NO_DATA_FOR_REQUIRED_PROTOBUF_FIELD = 435; - extern const int PROTOBUF_BAD_CAST = 436; - extern const int PROTOBUF_FIELD_NOT_REPEATED = 437; - extern const int DATA_TYPE_CANNOT_BE_PROMOTED = 438; - extern const int CANNOT_SCHEDULE_TASK = 439; - extern const int INVALID_LIMIT_EXPRESSION = 440; - extern const int CANNOT_PARSE_DOMAIN_VALUE_FROM_STRING = 441; - extern const int BAD_DATABASE_FOR_TEMPORARY_TABLE = 442; - extern const int NO_COMMON_COLUMNS_WITH_PROTOBUF_SCHEMA = 443; - extern const int UNKNOWN_PROTOBUF_FORMAT = 444; - extern const int CANNOT_MPROTECT = 445; - extern const int FUNCTION_NOT_ALLOWED = 446; - extern const int HYPERSCAN_CANNOT_SCAN_TEXT = 447; - extern const int BROTLI_READ_FAILED = 448; - extern const int BROTLI_WRITE_FAILED = 449; - extern const int BAD_TTL_EXPRESSION = 450; - extern const int BAD_TTL_FILE = 451; - extern const int SETTING_CONSTRAINT_VIOLATION = 452; - extern const int MYSQL_CLIENT_INSUFFICIENT_CAPABILITIES = 453; - extern const int OPENSSL_ERROR = 454; - extern const int SUSPICIOUS_TYPE_FOR_LOW_CARDINALITY = 455; - extern const int UNKNOWN_QUERY_PARAMETER = 456; - extern const int BAD_QUERY_PARAMETER = 457; - extern const int CANNOT_UNLINK = 458; - extern const int CANNOT_SET_THREAD_PRIORITY = 459; - extern const int CANNOT_CREATE_TIMER = 460; - extern const int CANNOT_SET_TIMER_PERIOD = 461; - extern const int CANNOT_DELETE_TIMER = 462; - extern const int CANNOT_FCNTL = 463; - extern const int CANNOT_PARSE_ELF = 464; - extern const int CANNOT_PARSE_DWARF = 465; - extern const int INSECURE_PATH = 466; - extern const int CANNOT_PARSE_BOOL = 467; - extern const int CANNOT_PTHREAD_ATTR = 468; - extern const int VIOLATED_CONSTRAINT = 469; - extern const int QUERY_IS_NOT_SUPPORTED_IN_LIVE_VIEW = 470; - extern const int INVALID_SETTING_VALUE = 471; - extern const int READONLY_SETTING = 472; - extern const int DEADLOCK_AVOIDED = 473; - extern const int INVALID_TEMPLATE_FORMAT = 474; - extern const int INVALID_WITH_FILL_EXPRESSION = 475; - extern const int WITH_TIES_WITHOUT_ORDER_BY = 476; - extern const int INVALID_USAGE_OF_INPUT = 477; - extern const int UNKNOWN_POLICY = 478; - extern const int UNKNOWN_DISK = 479; - extern const int UNKNOWN_PROTOCOL = 480; - extern const int PATH_ACCESS_DENIED = 481; - extern const int DICTIONARY_ACCESS_DENIED = 482; - extern const int TOO_MANY_REDIRECTS = 483; - extern const int INTERNAL_REDIS_ERROR = 484; - extern const int SCALAR_ALREADY_EXISTS = 485; - extern const int CANNOT_GET_CREATE_DICTIONARY_QUERY = 487; - extern const int UNKNOWN_DICTIONARY = 488; - extern const int INCORRECT_DICTIONARY_DEFINITION = 489; - extern const int CANNOT_FORMAT_DATETIME = 490; - extern const int UNACCEPTABLE_URL = 491; - extern const int ACCESS_ENTITY_NOT_FOUND = 492; - extern const int ACCESS_ENTITY_ALREADY_EXISTS = 493; - extern const int ACCESS_ENTITY_FOUND_DUPLICATES = 494; - extern const int ACCESS_STORAGE_READONLY = 495; - extern const int QUOTA_REQUIRES_CLIENT_KEY = 496; - extern const int ACCESS_DENIED = 497; - extern const int LIMIT_BY_WITH_TIES_IS_NOT_SUPPORTED = 498; - extern const int S3_ERROR = 499; - extern const int CANNOT_CREATE_DATABASE = 501; - extern const int CANNOT_SIGQUEUE = 502; - extern const int AGGREGATE_FUNCTION_THROW = 503; - extern const int FILE_ALREADY_EXISTS = 504; - extern const int CANNOT_DELETE_DIRECTORY = 505; - extern const int UNEXPECTED_ERROR_CODE = 506; - extern const int UNABLE_TO_SKIP_UNUSED_SHARDS = 507; - extern const int UNKNOWN_ACCESS_TYPE = 508; - extern const int INVALID_GRANT = 509; - extern const int CACHE_DICTIONARY_UPDATE_FAIL = 510; - extern const int UNKNOWN_ROLE = 511; - extern const int SET_NON_GRANTED_ROLE = 512; - extern const int UNKNOWN_PART_TYPE = 513; - extern const int ACCESS_STORAGE_FOR_INSERTION_NOT_FOUND = 514; - extern const int INCORRECT_ACCESS_ENTITY_DEFINITION = 515; - extern const int AUTHENTICATION_FAILED = 516; - extern const int CANNOT_ASSIGN_ALTER = 517; - extern const int CANNOT_COMMIT_OFFSET = 518; - extern const int NO_REMOTE_SHARD_AVAILABLE = 519; - extern const int CANNOT_DETACH_DICTIONARY_AS_TABLE = 520; - extern const int ATOMIC_RENAME_FAIL = 521; - extern const int UNKNOWN_ROW_POLICY = 523; - extern const int ALTER_OF_COLUMN_IS_FORBIDDEN = 524; - extern const int INCORRECT_DISK_INDEX = 525; - extern const int UNKNOWN_VOLUME_TYPE = 526; - extern const int NO_SUITABLE_FUNCTION_IMPLEMENTATION = 527; - extern const int CASSANDRA_INTERNAL_ERROR = 528; - extern const int NOT_A_LEADER = 529; - extern const int CANNOT_CONNECT_RABBITMQ = 530; - extern const int CANNOT_FSTAT = 531; - extern const int LDAP_ERROR = 532; - extern const int INCONSISTENT_RESERVATIONS = 533; - extern const int NO_RESERVATIONS_PROVIDED = 534; - extern const int UNKNOWN_RAID_TYPE = 535; - extern const int CANNOT_RESTORE_FROM_FIELD_DUMP = 536; - extern const int ILLEGAL_MYSQL_VARIABLE = 537; - extern const int MYSQL_SYNTAX_ERROR = 538; - extern const int CANNOT_BIND_RABBITMQ_EXCHANGE = 539; - extern const int CANNOT_DECLARE_RABBITMQ_EXCHANGE = 540; - extern const int CANNOT_CREATE_RABBITMQ_QUEUE_BINDING = 541; - extern const int CANNOT_REMOVE_RABBITMQ_EXCHANGE = 542; - extern const int UNKNOWN_MYSQL_DATATYPES_SUPPORT_LEVEL = 543; - extern const int ROW_AND_ROWS_TOGETHER = 544; - extern const int FIRST_AND_NEXT_TOGETHER = 545; - extern const int NO_ROW_DELIMITER = 546; - extern const int INVALID_RAID_TYPE = 547; - extern const int UNKNOWN_VOLUME = 548; + constexpr Value END = 3000; + std::atomic values[END+1] {}; - extern const int KEEPER_EXCEPTION = 999; - extern const int POCO_EXCEPTION = 1000; - extern const int STD_EXCEPTION = 1001; - extern const int UNKNOWN_EXCEPTION = 1002; + struct ErrorCodesNames + { + const char * strings[END+1]; + ErrorCodesNames() + { + #define M(NAME, VALUE) strings[VALUE] = #NAME; + APPLY_FOR_ERROR_CODES(M) + #undef M + } + } error_codes_names; - extern const int CONDITIONAL_TREE_PARENT_NOT_FOUND = 2001; - extern const int ILLEGAL_PROJECTION_MANIPULATOR = 2002; - extern const int UNRECOGNIZED_ARGUMENTS = 2003; + std::string_view getName(ErrorCode error_code) + { + if (error_code >= END) + return std::string_view(); + const char * name = error_codes_names.strings[error_code]; + if (!name) + return std::string_view(); + return std::string_view(name); + } + + ErrorCode end() { return END+1; } } } diff --git a/src/Common/ErrorCodes.h b/src/Common/ErrorCodes.h new file mode 100644 index 00000000000..008cf018bd6 --- /dev/null +++ b/src/Common/ErrorCodes.h @@ -0,0 +1,41 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +/** Allows to count number of simultaneously happening error codes. + * See also Exception.cpp for incrementing part. + */ + +namespace DB +{ + +namespace ErrorCodes +{ + /// ErrorCode identifier (index in array). + using ErrorCode = size_t; + using Value = int; + + /// Get name of error_code by identifier. + /// Returns statically allocated string. + std::string_view getName(ErrorCode event); + + /// ErrorCode identifier -> current value of error_code. + extern std::atomic values[]; + + /// Get index just after last error_code identifier. + ErrorCode end(); + + /// Add value for specified error_code. + inline void increment(ErrorCode error_code) + { + error_code = std::min(error_code, end()-1); + values[error_code].fetch_add(1, std::memory_order_relaxed); + } +} + +} diff --git a/src/Common/Exception.cpp b/src/Common/Exception.cpp index 4b9bb595ce6..c57726faa7c 100644 --- a/src/Common/Exception.cpp +++ b/src/Common/Exception.cpp @@ -12,19 +12,15 @@ #include #include #include -#include #include #include -#include +#include #include -#include #if !defined(ARCADIA_BUILD) # include #endif -extern HashMap, DefaultHash> error_codes_count; - namespace DB { @@ -50,7 +46,7 @@ Exception::Exception(const std::string & msg, int code) LOG_FATAL(&Poco::Logger::root(), "Logical error: '{}'.", msg); abort(); } - ++error_codes_count[code]; + ErrorCodes::increment(code); #endif } diff --git a/src/Common/errorCodes.sh b/src/Common/errorCodes.sh deleted file mode 100755 index 3a4520e2dad..00000000000 --- a/src/Common/errorCodes.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env bash - -# Parse src/Common/ErrorCodes.cpp -# And generate src/Functions/errorCodes.generated.cpp -# For errorCode() function. -# -# Later it may contain some description of the error. - -set -e -set -o pipefail - -CUR_DIR="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")" -ERROR_CODES_IN_FILE=${ERROR_CODES_IN_FILE=$CUR_DIR/../Common/ErrorCodes.cpp} -ERROR_CODES_OUT_FILE=${ERROR_CODES_OUT_FILE=$CUR_DIR/errorCodes.generated.cpp} -CXX=${CXX=g++} - -trap 'rm -f $TMP_FILE' EXIT -TMP_FILE="$(mktemp clichouse_generate_errorCodes_XXXXXXXX.cpp)" - -function parse_ErrorCodes() -{ - # This is the simplest command that can be written to parse the file - # And it does not requires any extra tools and works everywhere where you have g++/clang++ - # - # Generate: - # - # CODE VAR_NAME - # - $CXX -E "$ERROR_CODES_IN_FILE" | { - awk -F '[ =;]*' '/extern const int / { print $(NF-1), $(NF-2); }' - } -} -function parse_for_errorCodeToName() -{ - parse_ErrorCodes | awk '{ printf(" case %s: return std::string_view(\"%s\");\n", $1, $2); }' -} -function generate_errorCodeToName() -{ - cat < - -std::string_view errorCodeToName(int code) -{ - switch (code) - { - case 0: return std::string_view("OK"); -$(parse_for_errorCodeToName) - default: return std::string_view(""); - } -}; - -EOL -} - -function parse_for_error_codes_count() -{ - parse_ErrorCodes | awk '{ printf(" error_codes_count[%s] = 0; /* %s */\n", $1, $2); }' -} -function generate_error_codes_count() -{ - cat < -#include -#include -#include - -HashMap, DefaultHash> error_codes_count; - -struct InitializeErrorCodesCount -{ - InitializeErrorCodesCount() - { -$(parse_for_error_codes_count) - } -} error_codes_count_initialize; -EOL -} - -function main() -{ - echo "// autogenerated by ${BASH_SOURCE[0]}" > "$TMP_FILE" - generate_errorCodeToName >> "$TMP_FILE" - generate_error_codes_count >> "$TMP_FILE" - - if [[ ! -e $ERROR_CODES_OUT_FILE ]]; then - cp -a "$TMP_FILE" "$ERROR_CODES_OUT_FILE" - fi - # update it only if it differs, to avoid costly recompilation - if ! diff -q "$TMP_FILE" "$ERROR_CODES_OUT_FILE"; then - cp -a "$TMP_FILE" "$ERROR_CODES_OUT_FILE" - fi -} -main "$@" diff --git a/src/Functions/CMakeLists.txt b/src/Functions/CMakeLists.txt index b528b3a276f..bdf89c983f1 100644 --- a/src/Functions/CMakeLists.txt +++ b/src/Functions/CMakeLists.txt @@ -53,8 +53,6 @@ endif() target_include_directories(clickhouse_functions SYSTEM PRIVATE ${SPARSEHASH_INCLUDE_DIR}) -add_dependencies(clickhouse_functions generate-error-codes) - if (CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE" OR CMAKE_BUILD_TYPE_UC STREQUAL "RELWITHDEBINFO" OR CMAKE_BUILD_TYPE_UC STREQUAL "MINSIZEREL") diff --git a/src/Functions/errorCodeToName.cpp b/src/Functions/errorCodeToName.cpp index 8c9f49b2ac8..6591e46d338 100644 --- a/src/Functions/errorCodeToName.cpp +++ b/src/Functions/errorCodeToName.cpp @@ -5,9 +5,7 @@ #include #include #include -#include - -extern std::string_view errorCodeToName(int code); +#include namespace DB { @@ -48,7 +46,7 @@ public: for (size_t i = 0; i < input_rows_count; ++i) { const Int64 error_code = input_column.getInt(i); - std::string_view error_name = errorCodeToName(error_code); + std::string_view error_name = ErrorCodes::getName(error_code); col_res->insertData(error_name.data(), error_name.size()); } diff --git a/src/Storages/System/StorageSystemErrors.cpp b/src/Storages/System/StorageSystemErrors.cpp index 5ab6d02a78f..675bf7556de 100644 --- a/src/Storages/System/StorageSystemErrors.cpp +++ b/src/Storages/System/StorageSystemErrors.cpp @@ -1,20 +1,8 @@ -#include -#include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern std::string_view errorCodeToName(int code); -extern HashMap, DefaultHash> error_codes_count; +#include +#include namespace DB { @@ -29,14 +17,23 @@ NamesAndTypesList StorageSystemErrors::getNamesAndTypes() } -void StorageSystemErrors::fillData(MutableColumns & res_columns, const Context &, const SelectQueryInfo &) const +void StorageSystemErrors::fillData(MutableColumns & res_columns, const Context & context, const SelectQueryInfo &) const { - for (const auto & error_code_pair : error_codes_count) + for (size_t i = 0, end = ErrorCodes::end(); i < end; ++i) { - size_t col_num = 0; - res_columns[col_num++]->insert(errorCodeToName(error_code_pair.getKey())); - res_columns[col_num++]->insert(error_code_pair.getKey()); - res_columns[col_num++]->insert(uint64_t(error_code_pair.getMapped())); + UInt64 value = ErrorCodes::values[i]; + std::string_view name = ErrorCodes::getName(i); + + if (!name.size()) + continue; + + if (value || context.getSettingsRef().system_events_show_zero_values) + { + size_t col_num = 0; + res_columns[col_num++]->insert(name); + res_columns[col_num++]->insert(i); + res_columns[col_num++]->insert(value); + } } } diff --git a/tests/queries/0_stateless/01544_errorCodeToName.reference b/tests/queries/0_stateless/01544_errorCodeToName.reference index 4f0073384d9..ace588644e1 100644 --- a/tests/queries/0_stateless/01544_errorCodeToName.reference +++ b/tests/queries/0_stateless/01544_errorCodeToName.reference @@ -1,3 +1,4 @@ + OK UNSUPPORTED_METHOD diff --git a/tests/queries/0_stateless/01544_errorCodeToName.sql b/tests/queries/0_stateless/01544_errorCodeToName.sql index 07b46767b73..9e28ed1116c 100644 --- a/tests/queries/0_stateless/01544_errorCodeToName.sql +++ b/tests/queries/0_stateless/01544_errorCodeToName.sql @@ -1,3 +1,4 @@ SELECT errorCodeToName(toUInt32(-1)); +SELECT errorCodeToName(600); /* gap in error codes */ SELECT errorCodeToName(0); SELECT errorCodeToName(1); From 3bded85c4fcd185731a8577d0cd0a70b190d7022 Mon Sep 17 00:00:00 2001 From: ana-uvarova Date: Thu, 29 Oct 2020 15:43:18 +0300 Subject: [PATCH 11/95] Details --- docs/en/operations/system-tables/asynchronous_metric_log.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/operations/system-tables/asynchronous_metric_log.md b/docs/en/operations/system-tables/asynchronous_metric_log.md index e1eabdefa2f..5dcfca5fbda 100644 --- a/docs/en/operations/system-tables/asynchronous_metric_log.md +++ b/docs/en/operations/system-tables/asynchronous_metric_log.md @@ -33,7 +33,7 @@ SELECT * FROM system.asynchronous_metric_log LIMIT 10 **See Also** -- [system.asynchronous_metrics](../system-tables/asynchronous_metrics.md) — Contains metrics that are calculated periodically in the background. +- [system.asynchronous_metrics](../system-tables/asynchronous_metrics.md) — Contains metrics, calculated periodically in the background. - [system.metric_log](../system-tables/metric_log.md) — Contains history of metrics values from tables `system.metrics` and `system.events`, periodically flushed to disk. [Original article](https://clickhouse.tech/docs/en/operations/system_tables/asynchronous_metric_log) From 7e79769ae47e6802188c5221f1fe2992792f6a4a Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 29 Oct 2020 21:08:09 +0300 Subject: [PATCH 12/95] Fix readability-inconsistent-declaration-parameter-name in ErrorCodes.h --- src/Common/ErrorCodes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Common/ErrorCodes.h b/src/Common/ErrorCodes.h index 008cf018bd6..9afa4daae90 100644 --- a/src/Common/ErrorCodes.h +++ b/src/Common/ErrorCodes.h @@ -22,7 +22,7 @@ namespace ErrorCodes /// Get name of error_code by identifier. /// Returns statically allocated string. - std::string_view getName(ErrorCode event); + std::string_view getName(ErrorCode error_code); /// ErrorCode identifier -> current value of error_code. extern std::atomic values[]; From 04bff595d3639585a713249a9994f894f80117de Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 29 Oct 2020 21:10:08 +0300 Subject: [PATCH 13/95] Make check-style happy (by not using DB::ErrorCodes:: in comments) --- src/Common/ErrorCodes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Common/ErrorCodes.cpp b/src/Common/ErrorCodes.cpp index 7b671427753..3b3f9af9d5e 100644 --- a/src/Common/ErrorCodes.cpp +++ b/src/Common/ErrorCodes.cpp @@ -524,7 +524,7 @@ M(CONDITIONAL_TREE_PARENT_NOT_FOUND, 2001) \ M(ILLEGAL_PROJECTION_MANIPULATOR, 2002) \ M(UNRECOGNIZED_ARGUMENTS, 2003) -/* See DB::ErrorCodes::END */ +/* See END */ namespace DB { From cb50886ef1436d100c0388f88ff4c50cae19a50d Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 29 Oct 2020 21:24:52 +0300 Subject: [PATCH 14/95] Fix ErrorCodes increment on error --- src/Common/Exception.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Common/Exception.cpp b/src/Common/Exception.cpp index c57726faa7c..0214fa7b065 100644 --- a/src/Common/Exception.cpp +++ b/src/Common/Exception.cpp @@ -46,8 +46,8 @@ Exception::Exception(const std::string & msg, int code) LOG_FATAL(&Poco::Logger::root(), "Logical error: '{}'.", msg); abort(); } - ErrorCodes::increment(code); #endif + ErrorCodes::increment(code); } Exception::Exception(CreateFromPocoTag, const Poco::Exception & exc) From 0cd79de632047a3cbecd829616abb1456ca3a96e Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 29 Oct 2020 21:53:09 +0300 Subject: [PATCH 15/95] Eliminate extra strlen() in errorCodeToName() --- src/Common/ErrorCodes.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Common/ErrorCodes.cpp b/src/Common/ErrorCodes.cpp index 3b3f9af9d5e..73b19aa4354 100644 --- a/src/Common/ErrorCodes.cpp +++ b/src/Common/ErrorCodes.cpp @@ -540,10 +540,10 @@ namespace ErrorCodes struct ErrorCodesNames { - const char * strings[END+1]; + std::string_view names[END+1]; ErrorCodesNames() { - #define M(NAME, VALUE) strings[VALUE] = #NAME; + #define M(NAME, VALUE) names[VALUE] = std::string_view(#NAME); APPLY_FOR_ERROR_CODES(M) #undef M } @@ -553,10 +553,7 @@ namespace ErrorCodes { if (error_code >= END) return std::string_view(); - const char * name = error_codes_names.strings[error_code]; - if (!name) - return std::string_view(); - return std::string_view(name); + return error_codes_names.names[error_code]; } ErrorCode end() { return END+1; } From 70e61362465a6b61ae34800ada213d710182b47b Mon Sep 17 00:00:00 2001 From: ana-uvarova Date: Thu, 29 Oct 2020 21:56:00 +0300 Subject: [PATCH 16/95] Russian --- docs/ru/operations/system-tables/asynchronous_metric_log.md | 1 + docs/ru/operations/system-tables/metric_log.md | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/docs/ru/operations/system-tables/asynchronous_metric_log.md b/docs/ru/operations/system-tables/asynchronous_metric_log.md index 719e965ebe4..eded0ba7b28 100644 --- a/docs/ru/operations/system-tables/asynchronous_metric_log.md +++ b/docs/ru/operations/system-tables/asynchronous_metric_log.md @@ -5,6 +5,7 @@ Столбцы: - `event_date` ([Date](../../sql-reference/data-types/date.md)) — дата события. - `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — время события. +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — время события в секундах. - `name` ([String](../../sql-reference/data-types/string.md)) — название метрики. - `value` ([Float64](../../sql-reference/data-types/float.md)) — значение метрики. diff --git a/docs/ru/operations/system-tables/metric_log.md b/docs/ru/operations/system-tables/metric_log.md index 32ebe91dd91..fff5c57a113 100644 --- a/docs/ru/operations/system-tables/metric_log.md +++ b/docs/ru/operations/system-tables/metric_log.md @@ -1,6 +1,7 @@ # system.metric_log {#system_tables-metric_log} Содержит историю значений метрик из таблиц `system.metrics` и `system.events`, периодически сбрасываемую на диск. + Для включения сбора истории метрик в таблице `system.metric_log` создайте `/etc/clickhouse-server/config.d/metric_log.xml` следующего содержания: ``` xml @@ -14,6 +15,11 @@ ``` +Столбцы: +- `event_date` ([Date](../../sql-reference/data-types/date.md)) — дата события. +- `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — время события. +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — время события в секундах. + **Пример** ``` sql From ce9897bfd8054f8b382b8a69fe1747fbbddb6523 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 30 Oct 2020 00:07:40 +0300 Subject: [PATCH 17/95] Fix readability-container-size-empty in StorageSystemErrors.cpp --- src/Storages/System/StorageSystemErrors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storages/System/StorageSystemErrors.cpp b/src/Storages/System/StorageSystemErrors.cpp index 675bf7556de..89df058900b 100644 --- a/src/Storages/System/StorageSystemErrors.cpp +++ b/src/Storages/System/StorageSystemErrors.cpp @@ -24,7 +24,7 @@ void StorageSystemErrors::fillData(MutableColumns & res_columns, const Context & UInt64 value = ErrorCodes::values[i]; std::string_view name = ErrorCodes::getName(i); - if (!name.size()) + if (name.empty()) continue; if (value || context.getSettingsRef().system_events_show_zero_values) From 98f701dbfcfdde171a3c3fedaffc28723a7fb6b4 Mon Sep 17 00:00:00 2001 From: Olga Revyakina Date: Fri, 30 Oct 2020 04:09:42 +0300 Subject: [PATCH 18/95] Docs in English --- docs/en/sql-reference/table-functions/null.md | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 docs/en/sql-reference/table-functions/null.md diff --git a/docs/en/sql-reference/table-functions/null.md b/docs/en/sql-reference/table-functions/null.md new file mode 100644 index 00000000000..988ba18d709 --- /dev/null +++ b/docs/en/sql-reference/table-functions/null.md @@ -0,0 +1,39 @@ +--- +toc_priority: 53 +toc_title: null function +--- + +# null {#null-function} + +Accepts an inserted data of the specified structure and immediately drops it away. The function is used for convenience writing tests and demos. + +**Syntax** + +``` sql +null('structure') +``` + +**Parameter** + +- `structure` — A list of columns and column types. [String](../../sql-reference/data-types/string.md). + +**Returned value** + +A table with the specified structure, which is dropped right after the query execution. + +**Example** + +Query with the `null` function: + +``` sql +INSERT INTO function null('x UInt64') SELECT * FROM numbers_mt(1000000000); +``` +can replace three queries: + +```sql +CREATE TABLE t (x UInt64) ENGINE = Null; +INSERT INTO t SELECT * FROM numbers_mt(1000000000); +DROP TABLE IF EXISTS t; +``` + +[Original article](https://clickhouse.tech/docs/en/sql-reference/table-functions/null/) From 3661769e1b4fef9f89be6b562c2bdd4595301ff8 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 30 Oct 2020 08:55:40 +0300 Subject: [PATCH 19/95] Remove some absolute changes for errorCodeToName/system.errors --- src/Common/ya.make.in | 2 +- src/Functions/.gitignore | 1 - src/Functions/errorCodeToName.cpp | 4 ---- src/Functions/registerFunctionsMiscellaneous.cpp | 4 ---- src/Functions/ya.make | 1 + src/Functions/ya.make.in | 2 +- src/Storages/System/attachSystemTables.cpp | 4 ++-- 7 files changed, 5 insertions(+), 13 deletions(-) delete mode 100644 src/Functions/.gitignore diff --git a/src/Common/ya.make.in b/src/Common/ya.make.in index e0e3fd9a944..f8b7601e215 100644 --- a/src/Common/ya.make.in +++ b/src/Common/ya.make.in @@ -23,7 +23,7 @@ INCLUDE(${ARCADIA_ROOT}/clickhouse/cmake/yandex/ya.make.versions.inc) CFLAGS(-g0) SRCS( - + ) END() diff --git a/src/Functions/.gitignore b/src/Functions/.gitignore deleted file mode 100644 index 25db3625c77..00000000000 --- a/src/Functions/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/errorCodes.generated.cpp diff --git a/src/Functions/errorCodeToName.cpp b/src/Functions/errorCodeToName.cpp index 6591e46d338..01fd5632288 100644 --- a/src/Functions/errorCodeToName.cpp +++ b/src/Functions/errorCodeToName.cpp @@ -1,5 +1,3 @@ -#if !defined(ARCADIA_BUILD) - #include #include #include @@ -61,5 +59,3 @@ void registerFunctionErrorCodeToName(FunctionFactory & factory) } } - -#endif diff --git a/src/Functions/registerFunctionsMiscellaneous.cpp b/src/Functions/registerFunctionsMiscellaneous.cpp index 4a989831b48..86c06b47b1d 100644 --- a/src/Functions/registerFunctionsMiscellaneous.cpp +++ b/src/Functions/registerFunctionsMiscellaneous.cpp @@ -64,9 +64,7 @@ void registerFunctionCountDigits(FunctionFactory &); void registerFunctionGlobalVariable(FunctionFactory &); void registerFunctionHasThreadFuzzer(FunctionFactory &); void registerFunctionInitializeAggregation(FunctionFactory &); -#if !defined(ARCADIA_BUILD) void registerFunctionErrorCodeToName(FunctionFactory &); -#endif #if USE_ICU void registerFunctionConvertCharset(FunctionFactory &); @@ -131,9 +129,7 @@ void registerFunctionsMiscellaneous(FunctionFactory & factory) registerFunctionGlobalVariable(factory); registerFunctionHasThreadFuzzer(factory); registerFunctionInitializeAggregation(factory); -#if !defined(ARCADIA_BUILD) registerFunctionErrorCodeToName(factory); -#endif #if USE_ICU registerFunctionConvertCharset(factory); diff --git a/src/Functions/ya.make b/src/Functions/ya.make index ed03f5175ab..4229190ba6c 100644 --- a/src/Functions/ya.make +++ b/src/Functions/ya.make @@ -156,6 +156,7 @@ SRCS( equals.cpp erfc.cpp erf.cpp + errorCodeToName.cpp evalMLMethod.cpp exp10.cpp exp2.cpp diff --git a/src/Functions/ya.make.in b/src/Functions/ya.make.in index e70658bb79d..2a66aa5553e 100644 --- a/src/Functions/ya.make.in +++ b/src/Functions/ya.make.in @@ -34,7 +34,7 @@ PEERDIR( CFLAGS(-g0) SRCS( - + ) END() diff --git a/src/Storages/System/attachSystemTables.cpp b/src/Storages/System/attachSystemTables.cpp index 1ea24c1c4ba..210ed355e47 100644 --- a/src/Storages/System/attachSystemTables.cpp +++ b/src/Storages/System/attachSystemTables.cpp @@ -37,11 +37,11 @@ #include #include #include +#include #if !defined(ARCADIA_BUILD) #include #include #endif -#include #include #include #include @@ -108,10 +108,10 @@ void attachSystemTablesLocal(IDatabase & system_database) attach(system_database, "quotas_usage"); attach(system_database, "user_directories"); attach(system_database, "privileges"); + attach(system_database, "errors"); #if !defined(ARCADIA_BUILD) attach(system_database, "licenses"); attach(system_database, "time_zones"); - attach(system_database, "errors"); #endif #ifdef OS_LINUX attach(system_database, "stack_trace"); From 5481fcdf4211eec9751cd792e9d862c38328a942 Mon Sep 17 00:00:00 2001 From: Ivan Lezhankin Date: Fri, 30 Oct 2020 20:56:14 +0300 Subject: [PATCH 20/95] Fix script --- utils/make_changelog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/make_changelog.py b/utils/make_changelog.py index 5a5c82e5ab6..9120267e3b0 100755 --- a/utils/make_changelog.py +++ b/utils/make_changelog.py @@ -262,7 +262,7 @@ def process_unknown_commits(commits, commits_info, users): # Returns False if the PR should not be mentioned changelog. def parse_one_pull_request(item): description = item['description'] - lines = [line for line in [x.strip() for x in description.split('\n') if description else []] if line] + lines = [line for line in [x.strip() for x in description.split('\n') if description] if line] lines = [re.sub(r'\s+', ' ', l) for l in lines] cat_pos = None From 1b60d1156c022d0ba879800f9612693c0f7a0cb7 Mon Sep 17 00:00:00 2001 From: ana-uvarova Date: Fri, 30 Oct 2020 21:06:29 +0300 Subject: [PATCH 21/95] MICRO back --- docs/ru/operations/system-tables/asynchronous_metric_log.md | 2 +- docs/ru/operations/system-tables/metric_log.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ru/operations/system-tables/asynchronous_metric_log.md b/docs/ru/operations/system-tables/asynchronous_metric_log.md index eded0ba7b28..2fe617e48af 100644 --- a/docs/ru/operations/system-tables/asynchronous_metric_log.md +++ b/docs/ru/operations/system-tables/asynchronous_metric_log.md @@ -5,7 +5,7 @@ Столбцы: - `event_date` ([Date](../../sql-reference/data-types/date.md)) — дата события. - `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — время события. -- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — время события в секундах. +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — время события в микросекундах. - `name` ([String](../../sql-reference/data-types/string.md)) — название метрики. - `value` ([Float64](../../sql-reference/data-types/float.md)) — значение метрики. diff --git a/docs/ru/operations/system-tables/metric_log.md b/docs/ru/operations/system-tables/metric_log.md index fff5c57a113..ad25e8d5cfd 100644 --- a/docs/ru/operations/system-tables/metric_log.md +++ b/docs/ru/operations/system-tables/metric_log.md @@ -18,7 +18,7 @@ Столбцы: - `event_date` ([Date](../../sql-reference/data-types/date.md)) — дата события. - `event_time` ([DateTime](../../sql-reference/data-types/datetime.md)) — время события. -- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — время события в секундах. +- `event_time_microseconds` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — время события в микросекундах. **Пример** From 9828ed95504fb1a78380d47c8590a07bf8d4c884 Mon Sep 17 00:00:00 2001 From: Ivan <5627721+abyss7@users.noreply.github.com> Date: Fri, 30 Oct 2020 21:16:50 +0300 Subject: [PATCH 22/95] Update utils/make_changelog.py Co-authored-by: Azat Khuzhin --- utils/make_changelog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/make_changelog.py b/utils/make_changelog.py index 9120267e3b0..4f703108d38 100755 --- a/utils/make_changelog.py +++ b/utils/make_changelog.py @@ -262,7 +262,7 @@ def process_unknown_commits(commits, commits_info, users): # Returns False if the PR should not be mentioned changelog. def parse_one_pull_request(item): description = item['description'] - lines = [line for line in [x.strip() for x in description.split('\n') if description] if line] + lines = [line for line in [x.strip() for x in description.split('\n')] if line] if description else [] lines = [re.sub(r'\s+', ' ', l) for l in lines] cat_pos = None From 2832255164979b72fcb1fabd4592a613abb74bd4 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 30 Oct 2020 22:02:02 +0300 Subject: [PATCH 23/95] Increase asynchronous_metrics_update_period_s to avoid syncing MemoryTracking with RSS --- .../configs/asynchronous_metrics_update_period_s.xml | 4 ++++ .../test.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/integration/test_input_format_parallel_parsing_memory_tracking/configs/asynchronous_metrics_update_period_s.xml diff --git a/tests/integration/test_input_format_parallel_parsing_memory_tracking/configs/asynchronous_metrics_update_period_s.xml b/tests/integration/test_input_format_parallel_parsing_memory_tracking/configs/asynchronous_metrics_update_period_s.xml new file mode 100644 index 00000000000..ed131f41ede --- /dev/null +++ b/tests/integration/test_input_format_parallel_parsing_memory_tracking/configs/asynchronous_metrics_update_period_s.xml @@ -0,0 +1,4 @@ + + + 86400 + diff --git a/tests/integration/test_input_format_parallel_parsing_memory_tracking/test.py b/tests/integration/test_input_format_parallel_parsing_memory_tracking/test.py index 69c7a5821fd..e8866d3a235 100644 --- a/tests/integration/test_input_format_parallel_parsing_memory_tracking/test.py +++ b/tests/integration/test_input_format_parallel_parsing_memory_tracking/test.py @@ -8,7 +8,10 @@ from helpers.cluster import ClickHouseCluster cluster = ClickHouseCluster(__file__) -instance = cluster.add_instance('instance', main_configs=['configs/conf.xml']) +instance = cluster.add_instance('instance', main_configs=[ + 'configs/conf.xml', + 'configs/asynchronous_metrics_update_period_s.xml', +]) @pytest.fixture(scope='module', autouse=True) From 831208e2cf90db994fca0055241e496e21a8281c Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Fri, 30 Oct 2020 22:02:02 +0300 Subject: [PATCH 24/95] Log the difference between process RSS and MemoryTracking metric --- src/Interpreters/AsynchronousMetrics.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Interpreters/AsynchronousMetrics.cpp b/src/Interpreters/AsynchronousMetrics.cpp index e1a9a820ebb..4e052349b6b 100644 --- a/src/Interpreters/AsynchronousMetrics.cpp +++ b/src/Interpreters/AsynchronousMetrics.cpp @@ -207,8 +207,22 @@ void AsynchronousMetrics::update() /// We must update the value of total_memory_tracker periodically. /// Otherwise it might be calculated incorrectly - it can include a "drift" of memory amount. /// See https://github.com/ClickHouse/ClickHouse/issues/10293 - total_memory_tracker.set(data.resident); - CurrentMetrics::set(CurrentMetrics::MemoryTracking, data.resident); + { + Int64 amount = total_memory_tracker.get(); + Int64 peak = total_memory_tracker.getPeak(); + Int64 new_peak = data.resident; + + LOG_DEBUG(&Poco::Logger::get("AsynchronousMetrics"), + "MemoryTracking: was {}, peak {}, will set to {} (RSS), difference: {}", + ReadableSize(amount), + ReadableSize(peak), + ReadableSize(new_peak), + ReadableSize(new_peak - peak) + ); + + total_memory_tracker.set(new_peak); + CurrentMetrics::set(CurrentMetrics::MemoryTracking, new_peak); + } } #endif From e07473f1ea35c60441ee5d1c48feecb6341c9a8e Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 31 Oct 2020 11:29:17 +0300 Subject: [PATCH 25/95] Update comment for StorageSystemErrors --- src/Storages/System/StorageSystemErrors.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Storages/System/StorageSystemErrors.h b/src/Storages/System/StorageSystemErrors.h index 3f2d3020bcd..569a7a998b7 100644 --- a/src/Storages/System/StorageSystemErrors.h +++ b/src/Storages/System/StorageSystemErrors.h @@ -10,8 +10,10 @@ namespace DB class Context; -/** Implements the `distribution_queue` system table, which allows you to view the INSERT queues for the Distributed tables. - */ +/** + * Implements the `errors` system table, which shows the error code and the number of times it happens + * (i.e. Exception with this code had been thrown). + */ class StorageSystemErrors final : public ext::shared_ptr_helper, public IStorageSystemOneBlock { friend struct ext::shared_ptr_helper; From c8f756707f751ffa6aeddf437900155f1b934b62 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 31 Oct 2020 11:31:59 +0300 Subject: [PATCH 26/95] Swap name and value in ErrorCodes definition --- src/Common/ErrorCodes.cpp | 1024 ++++++++++++++++++------------------- 1 file changed, 512 insertions(+), 512 deletions(-) diff --git a/src/Common/ErrorCodes.cpp b/src/Common/ErrorCodes.cpp index 73b19aa4354..968b847d686 100644 --- a/src/Common/ErrorCodes.cpp +++ b/src/Common/ErrorCodes.cpp @@ -12,518 +12,518 @@ */ #define APPLY_FOR_ERROR_CODES(M) \ - M(OK, 0) \ - M(UNSUPPORTED_METHOD, 1) \ - M(UNSUPPORTED_PARAMETER, 2) \ - M(UNEXPECTED_END_OF_FILE, 3) \ - M(EXPECTED_END_OF_FILE, 4) \ - M(CANNOT_PARSE_TEXT, 6) \ - M(INCORRECT_NUMBER_OF_COLUMNS, 7) \ - M(THERE_IS_NO_COLUMN, 8) \ - M(SIZES_OF_COLUMNS_DOESNT_MATCH, 9) \ - M(NOT_FOUND_COLUMN_IN_BLOCK, 10) \ - M(POSITION_OUT_OF_BOUND, 11) \ - M(PARAMETER_OUT_OF_BOUND, 12) \ - M(SIZES_OF_COLUMNS_IN_TUPLE_DOESNT_MATCH, 13) \ - M(DUPLICATE_COLUMN, 15) \ - M(NO_SUCH_COLUMN_IN_TABLE, 16) \ - M(DELIMITER_IN_STRING_LITERAL_DOESNT_MATCH, 17) \ - M(CANNOT_INSERT_ELEMENT_INTO_CONSTANT_COLUMN, 18) \ - M(SIZE_OF_FIXED_STRING_DOESNT_MATCH, 19) \ - M(NUMBER_OF_COLUMNS_DOESNT_MATCH, 20) \ - M(CANNOT_READ_ALL_DATA_FROM_TAB_SEPARATED_INPUT, 21) \ - M(CANNOT_PARSE_ALL_VALUE_FROM_TAB_SEPARATED_INPUT, 22) \ - M(CANNOT_READ_FROM_ISTREAM, 23) \ - M(CANNOT_WRITE_TO_OSTREAM, 24) \ - M(CANNOT_PARSE_ESCAPE_SEQUENCE, 25) \ - M(CANNOT_PARSE_QUOTED_STRING, 26) \ - M(CANNOT_PARSE_INPUT_ASSERTION_FAILED, 27) \ - M(CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER, 28) \ - M(CANNOT_PRINT_INTEGER, 29) \ - M(CANNOT_READ_SIZE_OF_COMPRESSED_CHUNK, 30) \ - M(CANNOT_READ_COMPRESSED_CHUNK, 31) \ - M(ATTEMPT_TO_READ_AFTER_EOF, 32) \ - M(CANNOT_READ_ALL_DATA, 33) \ - M(TOO_MANY_ARGUMENTS_FOR_FUNCTION, 34) \ - M(TOO_FEW_ARGUMENTS_FOR_FUNCTION, 35) \ - M(BAD_ARGUMENTS, 36) \ - M(UNKNOWN_ELEMENT_IN_AST, 37) \ - M(CANNOT_PARSE_DATE, 38) \ - M(TOO_LARGE_SIZE_COMPRESSED, 39) \ - M(CHECKSUM_DOESNT_MATCH, 40) \ - M(CANNOT_PARSE_DATETIME, 41) \ - M(NUMBER_OF_ARGUMENTS_DOESNT_MATCH, 42) \ - M(ILLEGAL_TYPE_OF_ARGUMENT, 43) \ - M(ILLEGAL_COLUMN, 44) \ - M(ILLEGAL_NUMBER_OF_RESULT_COLUMNS, 45) \ - M(UNKNOWN_FUNCTION, 46) \ - M(UNKNOWN_IDENTIFIER, 47) \ - M(NOT_IMPLEMENTED, 48) \ - M(LOGICAL_ERROR, 49) \ - M(UNKNOWN_TYPE, 50) \ - M(EMPTY_LIST_OF_COLUMNS_QUERIED, 51) \ - M(COLUMN_QUERIED_MORE_THAN_ONCE, 52) \ - M(TYPE_MISMATCH, 53) \ - M(STORAGE_DOESNT_ALLOW_PARAMETERS, 54) \ - M(STORAGE_REQUIRES_PARAMETER, 55) \ - M(UNKNOWN_STORAGE, 56) \ - M(TABLE_ALREADY_EXISTS, 57) \ - M(TABLE_METADATA_ALREADY_EXISTS, 58) \ - M(ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER, 59) \ - M(UNKNOWN_TABLE, 60) \ - M(ONLY_FILTER_COLUMN_IN_BLOCK, 61) \ - M(SYNTAX_ERROR, 62) \ - M(UNKNOWN_AGGREGATE_FUNCTION, 63) \ - M(CANNOT_READ_AGGREGATE_FUNCTION_FROM_TEXT, 64) \ - M(CANNOT_WRITE_AGGREGATE_FUNCTION_AS_TEXT, 65) \ - M(NOT_A_COLUMN, 66) \ - M(ILLEGAL_KEY_OF_AGGREGATION, 67) \ - M(CANNOT_GET_SIZE_OF_FIELD, 68) \ - M(ARGUMENT_OUT_OF_BOUND, 69) \ - M(CANNOT_CONVERT_TYPE, 70) \ - M(CANNOT_WRITE_AFTER_END_OF_BUFFER, 71) \ - M(CANNOT_PARSE_NUMBER, 72) \ - M(UNKNOWN_FORMAT, 73) \ - M(CANNOT_READ_FROM_FILE_DESCRIPTOR, 74) \ - M(CANNOT_WRITE_TO_FILE_DESCRIPTOR, 75) \ - M(CANNOT_OPEN_FILE, 76) \ - M(CANNOT_CLOSE_FILE, 77) \ - M(UNKNOWN_TYPE_OF_QUERY, 78) \ - M(INCORRECT_FILE_NAME, 79) \ - M(INCORRECT_QUERY, 80) \ - M(UNKNOWN_DATABASE, 81) \ - M(DATABASE_ALREADY_EXISTS, 82) \ - M(DIRECTORY_DOESNT_EXIST, 83) \ - M(DIRECTORY_ALREADY_EXISTS, 84) \ - M(FORMAT_IS_NOT_SUITABLE_FOR_INPUT, 85) \ - M(RECEIVED_ERROR_FROM_REMOTE_IO_SERVER, 86) \ - M(CANNOT_SEEK_THROUGH_FILE, 87) \ - M(CANNOT_TRUNCATE_FILE, 88) \ - M(UNKNOWN_COMPRESSION_METHOD, 89) \ - M(EMPTY_LIST_OF_COLUMNS_PASSED, 90) \ - M(SIZES_OF_MARKS_FILES_ARE_INCONSISTENT, 91) \ - M(EMPTY_DATA_PASSED, 92) \ - M(UNKNOWN_AGGREGATED_DATA_VARIANT, 93) \ - M(CANNOT_MERGE_DIFFERENT_AGGREGATED_DATA_VARIANTS, 94) \ - M(CANNOT_READ_FROM_SOCKET, 95) \ - M(CANNOT_WRITE_TO_SOCKET, 96) \ - M(CANNOT_READ_ALL_DATA_FROM_CHUNKED_INPUT, 97) \ - M(CANNOT_WRITE_TO_EMPTY_BLOCK_OUTPUT_STREAM, 98) \ - M(UNKNOWN_PACKET_FROM_CLIENT, 99) \ - M(UNKNOWN_PACKET_FROM_SERVER, 100) \ - M(UNEXPECTED_PACKET_FROM_CLIENT, 101) \ - M(UNEXPECTED_PACKET_FROM_SERVER, 102) \ - M(RECEIVED_DATA_FOR_WRONG_QUERY_ID, 103) \ - M(TOO_SMALL_BUFFER_SIZE, 104) \ - M(CANNOT_READ_HISTORY, 105) \ - M(CANNOT_APPEND_HISTORY, 106) \ - M(FILE_DOESNT_EXIST, 107) \ - M(NO_DATA_TO_INSERT, 108) \ - M(CANNOT_BLOCK_SIGNAL, 109) \ - M(CANNOT_UNBLOCK_SIGNAL, 110) \ - M(CANNOT_MANIPULATE_SIGSET, 111) \ - M(CANNOT_WAIT_FOR_SIGNAL, 112) \ - M(THERE_IS_NO_SESSION, 113) \ - M(CANNOT_CLOCK_GETTIME, 114) \ - M(UNKNOWN_SETTING, 115) \ - M(THERE_IS_NO_DEFAULT_VALUE, 116) \ - M(INCORRECT_DATA, 117) \ - M(ENGINE_REQUIRED, 119) \ - M(CANNOT_INSERT_VALUE_OF_DIFFERENT_SIZE_INTO_TUPLE, 120) \ - M(UNSUPPORTED_JOIN_KEYS, 121) \ - M(INCOMPATIBLE_COLUMNS, 122) \ - M(UNKNOWN_TYPE_OF_AST_NODE, 123) \ - M(INCORRECT_ELEMENT_OF_SET, 124) \ - M(INCORRECT_RESULT_OF_SCALAR_SUBQUERY, 125) \ - M(CANNOT_GET_RETURN_TYPE, 126) \ - M(ILLEGAL_INDEX, 127) \ - M(TOO_LARGE_ARRAY_SIZE, 128) \ - M(FUNCTION_IS_SPECIAL, 129) \ - M(CANNOT_READ_ARRAY_FROM_TEXT, 130) \ - M(TOO_LARGE_STRING_SIZE, 131) \ - M(AGGREGATE_FUNCTION_DOESNT_ALLOW_PARAMETERS, 133) \ - M(PARAMETERS_TO_AGGREGATE_FUNCTIONS_MUST_BE_LITERALS, 134) \ - M(ZERO_ARRAY_OR_TUPLE_INDEX, 135) \ - M(UNKNOWN_ELEMENT_IN_CONFIG, 137) \ - M(EXCESSIVE_ELEMENT_IN_CONFIG, 138) \ - M(NO_ELEMENTS_IN_CONFIG, 139) \ - M(ALL_REQUESTED_COLUMNS_ARE_MISSING, 140) \ - M(SAMPLING_NOT_SUPPORTED, 141) \ - M(NOT_FOUND_NODE, 142) \ - M(FOUND_MORE_THAN_ONE_NODE, 143) \ - M(FIRST_DATE_IS_BIGGER_THAN_LAST_DATE, 144) \ - M(UNKNOWN_OVERFLOW_MODE, 145) \ - M(QUERY_SECTION_DOESNT_MAKE_SENSE, 146) \ - M(NOT_FOUND_FUNCTION_ELEMENT_FOR_AGGREGATE, 147) \ - M(NOT_FOUND_RELATION_ELEMENT_FOR_CONDITION, 148) \ - M(NOT_FOUND_RHS_ELEMENT_FOR_CONDITION, 149) \ - M(EMPTY_LIST_OF_ATTRIBUTES_PASSED, 150) \ - M(INDEX_OF_COLUMN_IN_SORT_CLAUSE_IS_OUT_OF_RANGE, 151) \ - M(UNKNOWN_DIRECTION_OF_SORTING, 152) \ - M(ILLEGAL_DIVISION, 153) \ - M(AGGREGATE_FUNCTION_NOT_APPLICABLE, 154) \ - M(UNKNOWN_RELATION, 155) \ - M(DICTIONARIES_WAS_NOT_LOADED, 156) \ - M(ILLEGAL_OVERFLOW_MODE, 157) \ - M(TOO_MANY_ROWS, 158) \ - M(TIMEOUT_EXCEEDED, 159) \ - M(TOO_SLOW, 160) \ - M(TOO_MANY_COLUMNS, 161) \ - M(TOO_DEEP_SUBQUERIES, 162) \ - M(TOO_DEEP_PIPELINE, 163) \ - M(READONLY, 164) \ - M(TOO_MANY_TEMPORARY_COLUMNS, 165) \ - M(TOO_MANY_TEMPORARY_NON_CONST_COLUMNS, 166) \ - M(TOO_DEEP_AST, 167) \ - M(TOO_BIG_AST, 168) \ - M(BAD_TYPE_OF_FIELD, 169) \ - M(BAD_GET, 170) \ - M(CANNOT_CREATE_DIRECTORY, 172) \ - M(CANNOT_ALLOCATE_MEMORY, 173) \ - M(CYCLIC_ALIASES, 174) \ - M(CHUNK_NOT_FOUND, 176) \ - M(DUPLICATE_CHUNK_NAME, 177) \ - M(MULTIPLE_ALIASES_FOR_EXPRESSION, 178) \ - M(MULTIPLE_EXPRESSIONS_FOR_ALIAS, 179) \ - M(THERE_IS_NO_PROFILE, 180) \ - M(ILLEGAL_FINAL, 181) \ - M(ILLEGAL_PREWHERE, 182) \ - M(UNEXPECTED_EXPRESSION, 183) \ - M(ILLEGAL_AGGREGATION, 184) \ - M(UNSUPPORTED_MYISAM_BLOCK_TYPE, 185) \ - M(UNSUPPORTED_COLLATION_LOCALE, 186) \ - M(COLLATION_COMPARISON_FAILED, 187) \ - M(UNKNOWN_ACTION, 188) \ - M(TABLE_MUST_NOT_BE_CREATED_MANUALLY, 189) \ - M(SIZES_OF_ARRAYS_DOESNT_MATCH, 190) \ - M(SET_SIZE_LIMIT_EXCEEDED, 191) \ - M(UNKNOWN_USER, 192) \ - M(WRONG_PASSWORD, 193) \ - M(REQUIRED_PASSWORD, 194) \ - M(IP_ADDRESS_NOT_ALLOWED, 195) \ - M(UNKNOWN_ADDRESS_PATTERN_TYPE, 196) \ - M(SERVER_REVISION_IS_TOO_OLD, 197) \ - M(DNS_ERROR, 198) \ - M(UNKNOWN_QUOTA, 199) \ - M(QUOTA_DOESNT_ALLOW_KEYS, 200) \ - M(QUOTA_EXPIRED, 201) \ - M(TOO_MANY_SIMULTANEOUS_QUERIES, 202) \ - M(NO_FREE_CONNECTION, 203) \ - M(CANNOT_FSYNC, 204) \ - M(NESTED_TYPE_TOO_DEEP, 205) \ - M(ALIAS_REQUIRED, 206) \ - M(AMBIGUOUS_IDENTIFIER, 207) \ - M(EMPTY_NESTED_TABLE, 208) \ - M(SOCKET_TIMEOUT, 209) \ - M(NETWORK_ERROR, 210) \ - M(EMPTY_QUERY, 211) \ - M(UNKNOWN_LOAD_BALANCING, 212) \ - M(UNKNOWN_TOTALS_MODE, 213) \ - M(CANNOT_STATVFS, 214) \ - M(NOT_AN_AGGREGATE, 215) \ - M(QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING, 216) \ - M(CLIENT_HAS_CONNECTED_TO_WRONG_PORT, 217) \ - M(TABLE_IS_DROPPED, 218) \ - M(DATABASE_NOT_EMPTY, 219) \ - M(DUPLICATE_INTERSERVER_IO_ENDPOINT, 220) \ - M(NO_SUCH_INTERSERVER_IO_ENDPOINT, 221) \ - M(ADDING_REPLICA_TO_NON_EMPTY_TABLE, 222) \ - M(UNEXPECTED_AST_STRUCTURE, 223) \ - M(REPLICA_IS_ALREADY_ACTIVE, 224) \ - M(NO_ZOOKEEPER, 225) \ - M(NO_FILE_IN_DATA_PART, 226) \ - M(UNEXPECTED_FILE_IN_DATA_PART, 227) \ - M(BAD_SIZE_OF_FILE_IN_DATA_PART, 228) \ - M(QUERY_IS_TOO_LARGE, 229) \ - M(NOT_FOUND_EXPECTED_DATA_PART, 230) \ - M(TOO_MANY_UNEXPECTED_DATA_PARTS, 231) \ - M(NO_SUCH_DATA_PART, 232) \ - M(BAD_DATA_PART_NAME, 233) \ - M(NO_REPLICA_HAS_PART, 234) \ - M(DUPLICATE_DATA_PART, 235) \ - M(ABORTED, 236) \ - M(NO_REPLICA_NAME_GIVEN, 237) \ - M(FORMAT_VERSION_TOO_OLD, 238) \ - M(CANNOT_MUNMAP, 239) \ - M(CANNOT_MREMAP, 240) \ - M(MEMORY_LIMIT_EXCEEDED, 241) \ - M(TABLE_IS_READ_ONLY, 242) \ - M(NOT_ENOUGH_SPACE, 243) \ - M(UNEXPECTED_ZOOKEEPER_ERROR, 244) \ - M(CORRUPTED_DATA, 246) \ - M(INCORRECT_MARK, 247) \ - M(INVALID_PARTITION_VALUE, 248) \ - M(NOT_ENOUGH_BLOCK_NUMBERS, 250) \ - M(NO_SUCH_REPLICA, 251) \ - M(TOO_MANY_PARTS, 252) \ - M(REPLICA_IS_ALREADY_EXIST, 253) \ - M(NO_ACTIVE_REPLICAS, 254) \ - M(TOO_MANY_RETRIES_TO_FETCH_PARTS, 255) \ - M(PARTITION_ALREADY_EXISTS, 256) \ - M(PARTITION_DOESNT_EXIST, 257) \ - M(UNION_ALL_RESULT_STRUCTURES_MISMATCH, 258) \ - M(CLIENT_OUTPUT_FORMAT_SPECIFIED, 260) \ - M(UNKNOWN_BLOCK_INFO_FIELD, 261) \ - M(BAD_COLLATION, 262) \ - M(CANNOT_COMPILE_CODE, 263) \ - M(INCOMPATIBLE_TYPE_OF_JOIN, 264) \ - M(NO_AVAILABLE_REPLICA, 265) \ - M(MISMATCH_REPLICAS_DATA_SOURCES, 266) \ - M(STORAGE_DOESNT_SUPPORT_PARALLEL_REPLICAS, 267) \ - M(CPUID_ERROR, 268) \ - M(INFINITE_LOOP, 269) \ - M(CANNOT_COMPRESS, 270) \ - M(CANNOT_DECOMPRESS, 271) \ - M(CANNOT_IO_SUBMIT, 272) \ - M(CANNOT_IO_GETEVENTS, 273) \ - M(AIO_READ_ERROR, 274) \ - M(AIO_WRITE_ERROR, 275) \ - M(INDEX_NOT_USED, 277) \ - M(ALL_CONNECTION_TRIES_FAILED, 279) \ - M(NO_AVAILABLE_DATA, 280) \ - M(DICTIONARY_IS_EMPTY, 281) \ - M(INCORRECT_INDEX, 282) \ - M(UNKNOWN_DISTRIBUTED_PRODUCT_MODE, 283) \ - M(WRONG_GLOBAL_SUBQUERY, 284) \ - M(TOO_FEW_LIVE_REPLICAS, 285) \ - M(UNSATISFIED_QUORUM_FOR_PREVIOUS_WRITE, 286) \ - M(UNKNOWN_FORMAT_VERSION, 287) \ - M(DISTRIBUTED_IN_JOIN_SUBQUERY_DENIED, 288) \ - M(REPLICA_IS_NOT_IN_QUORUM, 289) \ - M(LIMIT_EXCEEDED, 290) \ - M(DATABASE_ACCESS_DENIED, 291) \ - M(MONGODB_CANNOT_AUTHENTICATE, 293) \ - M(INVALID_BLOCK_EXTRA_INFO, 294) \ - M(RECEIVED_EMPTY_DATA, 295) \ - M(NO_REMOTE_SHARD_FOUND, 296) \ - M(SHARD_HAS_NO_CONNECTIONS, 297) \ - M(CANNOT_PIPE, 298) \ - M(CANNOT_FORK, 299) \ - M(CANNOT_DLSYM, 300) \ - M(CANNOT_CREATE_CHILD_PROCESS, 301) \ - M(CHILD_WAS_NOT_EXITED_NORMALLY, 302) \ - M(CANNOT_SELECT, 303) \ - M(CANNOT_WAITPID, 304) \ - M(TABLE_WAS_NOT_DROPPED, 305) \ - M(TOO_DEEP_RECURSION, 306) \ - M(TOO_MANY_BYTES, 307) \ - M(UNEXPECTED_NODE_IN_ZOOKEEPER, 308) \ - M(FUNCTION_CANNOT_HAVE_PARAMETERS, 309) \ - M(INVALID_SHARD_WEIGHT, 317) \ - M(INVALID_CONFIG_PARAMETER, 318) \ - M(UNKNOWN_STATUS_OF_INSERT, 319) \ - M(VALUE_IS_OUT_OF_RANGE_OF_DATA_TYPE, 321) \ - M(BARRIER_TIMEOUT, 335) \ - M(UNKNOWN_DATABASE_ENGINE, 336) \ - M(DDL_GUARD_IS_ACTIVE, 337) \ - M(UNFINISHED, 341) \ - M(METADATA_MISMATCH, 342) \ - M(SUPPORT_IS_DISABLED, 344) \ - M(TABLE_DIFFERS_TOO_MUCH, 345) \ - M(CANNOT_CONVERT_CHARSET, 346) \ - M(CANNOT_LOAD_CONFIG, 347) \ - M(CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN, 349) \ - M(INCOMPATIBLE_SOURCE_TABLES, 350) \ - M(AMBIGUOUS_TABLE_NAME, 351) \ - M(AMBIGUOUS_COLUMN_NAME, 352) \ - M(INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE, 353) \ - M(ZLIB_INFLATE_FAILED, 354) \ - M(ZLIB_DEFLATE_FAILED, 355) \ - M(BAD_LAMBDA, 356) \ - M(RESERVED_IDENTIFIER_NAME, 357) \ - M(INTO_OUTFILE_NOT_ALLOWED, 358) \ - M(TABLE_SIZE_EXCEEDS_MAX_DROP_SIZE_LIMIT, 359) \ - M(CANNOT_CREATE_CHARSET_CONVERTER, 360) \ - M(SEEK_POSITION_OUT_OF_BOUND, 361) \ - M(CURRENT_WRITE_BUFFER_IS_EXHAUSTED, 362) \ - M(CANNOT_CREATE_IO_BUFFER, 363) \ - M(RECEIVED_ERROR_TOO_MANY_REQUESTS, 364) \ - M(SIZES_OF_NESTED_COLUMNS_ARE_INCONSISTENT, 366) \ - M(TOO_MANY_FETCHES, 367) \ - M(ALL_REPLICAS_ARE_STALE, 369) \ - M(DATA_TYPE_CANNOT_BE_USED_IN_TABLES, 370) \ - M(INCONSISTENT_CLUSTER_DEFINITION, 371) \ - M(SESSION_NOT_FOUND, 372) \ - M(SESSION_IS_LOCKED, 373) \ - M(INVALID_SESSION_TIMEOUT, 374) \ - M(CANNOT_DLOPEN, 375) \ - M(CANNOT_PARSE_UUID, 376) \ - M(ILLEGAL_SYNTAX_FOR_DATA_TYPE, 377) \ - M(DATA_TYPE_CANNOT_HAVE_ARGUMENTS, 378) \ - M(UNKNOWN_STATUS_OF_DISTRIBUTED_DDL_TASK, 379) \ - M(CANNOT_KILL, 380) \ - M(HTTP_LENGTH_REQUIRED, 381) \ - M(CANNOT_LOAD_CATBOOST_MODEL, 382) \ - M(CANNOT_APPLY_CATBOOST_MODEL, 383) \ - M(PART_IS_TEMPORARILY_LOCKED, 384) \ - M(MULTIPLE_STREAMS_REQUIRED, 385) \ - M(NO_COMMON_TYPE, 386) \ - M(DICTIONARY_ALREADY_EXISTS, 387) \ - M(CANNOT_ASSIGN_OPTIMIZE, 388) \ - M(INSERT_WAS_DEDUPLICATED, 389) \ - M(CANNOT_GET_CREATE_TABLE_QUERY, 390) \ - M(EXTERNAL_LIBRARY_ERROR, 391) \ - M(QUERY_IS_PROHIBITED, 392) \ - M(THERE_IS_NO_QUERY, 393) \ - M(QUERY_WAS_CANCELLED, 394) \ - M(FUNCTION_THROW_IF_VALUE_IS_NON_ZERO, 395) \ - M(TOO_MANY_ROWS_OR_BYTES, 396) \ - M(QUERY_IS_NOT_SUPPORTED_IN_MATERIALIZED_VIEW, 397) \ - M(UNKNOWN_MUTATION_COMMAND, 398) \ - M(FORMAT_IS_NOT_SUITABLE_FOR_OUTPUT, 399) \ - M(CANNOT_STAT, 400) \ - M(FEATURE_IS_NOT_ENABLED_AT_BUILD_TIME, 401) \ - M(CANNOT_IOSETUP, 402) \ - M(INVALID_JOIN_ON_EXPRESSION, 403) \ - M(BAD_ODBC_CONNECTION_STRING, 404) \ - M(PARTITION_SIZE_EXCEEDS_MAX_DROP_SIZE_LIMIT, 405) \ - M(TOP_AND_LIMIT_TOGETHER, 406) \ - M(DECIMAL_OVERFLOW, 407) \ - M(BAD_REQUEST_PARAMETER, 408) \ - M(EXTERNAL_EXECUTABLE_NOT_FOUND, 409) \ - M(EXTERNAL_SERVER_IS_NOT_RESPONDING, 410) \ - M(PTHREAD_ERROR, 411) \ - M(NETLINK_ERROR, 412) \ - M(CANNOT_SET_SIGNAL_HANDLER, 413) \ - M(ALL_REPLICAS_LOST, 415) \ - M(REPLICA_STATUS_CHANGED, 416) \ - M(EXPECTED_ALL_OR_ANY, 417) \ - M(UNKNOWN_JOIN, 418) \ - M(MULTIPLE_ASSIGNMENTS_TO_COLUMN, 419) \ - M(CANNOT_UPDATE_COLUMN, 420) \ - M(CANNOT_ADD_DIFFERENT_AGGREGATE_STATES, 421) \ - M(UNSUPPORTED_URI_SCHEME, 422) \ - M(CANNOT_GETTIMEOFDAY, 423) \ - M(CANNOT_LINK, 424) \ - M(SYSTEM_ERROR, 425) \ - M(CANNOT_COMPILE_REGEXP, 427) \ - M(UNKNOWN_LOG_LEVEL, 428) \ - M(FAILED_TO_GETPWUID, 429) \ - M(MISMATCHING_USERS_FOR_PROCESS_AND_DATA, 430) \ - M(ILLEGAL_SYNTAX_FOR_CODEC_TYPE, 431) \ - M(UNKNOWN_CODEC, 432) \ - M(ILLEGAL_CODEC_PARAMETER, 433) \ - M(CANNOT_PARSE_PROTOBUF_SCHEMA, 434) \ - M(NO_DATA_FOR_REQUIRED_PROTOBUF_FIELD, 435) \ - M(PROTOBUF_BAD_CAST, 436) \ - M(PROTOBUF_FIELD_NOT_REPEATED, 437) \ - M(DATA_TYPE_CANNOT_BE_PROMOTED, 438) \ - M(CANNOT_SCHEDULE_TASK, 439) \ - M(INVALID_LIMIT_EXPRESSION, 440) \ - M(CANNOT_PARSE_DOMAIN_VALUE_FROM_STRING, 441) \ - M(BAD_DATABASE_FOR_TEMPORARY_TABLE, 442) \ - M(NO_COMMON_COLUMNS_WITH_PROTOBUF_SCHEMA, 443) \ - M(UNKNOWN_PROTOBUF_FORMAT, 444) \ - M(CANNOT_MPROTECT, 445) \ - M(FUNCTION_NOT_ALLOWED, 446) \ - M(HYPERSCAN_CANNOT_SCAN_TEXT, 447) \ - M(BROTLI_READ_FAILED, 448) \ - M(BROTLI_WRITE_FAILED, 449) \ - M(BAD_TTL_EXPRESSION, 450) \ - M(BAD_TTL_FILE, 451) \ - M(SETTING_CONSTRAINT_VIOLATION, 452) \ - M(MYSQL_CLIENT_INSUFFICIENT_CAPABILITIES, 453) \ - M(OPENSSL_ERROR, 454) \ - M(SUSPICIOUS_TYPE_FOR_LOW_CARDINALITY, 455) \ - M(UNKNOWN_QUERY_PARAMETER, 456) \ - M(BAD_QUERY_PARAMETER, 457) \ - M(CANNOT_UNLINK, 458) \ - M(CANNOT_SET_THREAD_PRIORITY, 459) \ - M(CANNOT_CREATE_TIMER, 460) \ - M(CANNOT_SET_TIMER_PERIOD, 461) \ - M(CANNOT_DELETE_TIMER, 462) \ - M(CANNOT_FCNTL, 463) \ - M(CANNOT_PARSE_ELF, 464) \ - M(CANNOT_PARSE_DWARF, 465) \ - M(INSECURE_PATH, 466) \ - M(CANNOT_PARSE_BOOL, 467) \ - M(CANNOT_PTHREAD_ATTR, 468) \ - M(VIOLATED_CONSTRAINT, 469) \ - M(QUERY_IS_NOT_SUPPORTED_IN_LIVE_VIEW, 470) \ - M(INVALID_SETTING_VALUE, 471) \ - M(READONLY_SETTING, 472) \ - M(DEADLOCK_AVOIDED, 473) \ - M(INVALID_TEMPLATE_FORMAT, 474) \ - M(INVALID_WITH_FILL_EXPRESSION, 475) \ - M(WITH_TIES_WITHOUT_ORDER_BY, 476) \ - M(INVALID_USAGE_OF_INPUT, 477) \ - M(UNKNOWN_POLICY, 478) \ - M(UNKNOWN_DISK, 479) \ - M(UNKNOWN_PROTOCOL, 480) \ - M(PATH_ACCESS_DENIED, 481) \ - M(DICTIONARY_ACCESS_DENIED, 482) \ - M(TOO_MANY_REDIRECTS, 483) \ - M(INTERNAL_REDIS_ERROR, 484) \ - M(SCALAR_ALREADY_EXISTS, 485) \ - M(CANNOT_GET_CREATE_DICTIONARY_QUERY, 487) \ - M(UNKNOWN_DICTIONARY, 488) \ - M(INCORRECT_DICTIONARY_DEFINITION, 489) \ - M(CANNOT_FORMAT_DATETIME, 490) \ - M(UNACCEPTABLE_URL, 491) \ - M(ACCESS_ENTITY_NOT_FOUND, 492) \ - M(ACCESS_ENTITY_ALREADY_EXISTS, 493) \ - M(ACCESS_ENTITY_FOUND_DUPLICATES, 494) \ - M(ACCESS_STORAGE_READONLY, 495) \ - M(QUOTA_REQUIRES_CLIENT_KEY, 496) \ - M(ACCESS_DENIED, 497) \ - M(LIMIT_BY_WITH_TIES_IS_NOT_SUPPORTED, 498) \ - M(S3_ERROR, 499) \ - M(CANNOT_CREATE_DATABASE, 501) \ - M(CANNOT_SIGQUEUE, 502) \ - M(AGGREGATE_FUNCTION_THROW, 503) \ - M(FILE_ALREADY_EXISTS, 504) \ - M(CANNOT_DELETE_DIRECTORY, 505) \ - M(UNEXPECTED_ERROR_CODE, 506) \ - M(UNABLE_TO_SKIP_UNUSED_SHARDS, 507) \ - M(UNKNOWN_ACCESS_TYPE, 508) \ - M(INVALID_GRANT, 509) \ - M(CACHE_DICTIONARY_UPDATE_FAIL, 510) \ - M(UNKNOWN_ROLE, 511) \ - M(SET_NON_GRANTED_ROLE, 512) \ - M(UNKNOWN_PART_TYPE, 513) \ - M(ACCESS_STORAGE_FOR_INSERTION_NOT_FOUND, 514) \ - M(INCORRECT_ACCESS_ENTITY_DEFINITION, 515) \ - M(AUTHENTICATION_FAILED, 516) \ - M(CANNOT_ASSIGN_ALTER, 517) \ - M(CANNOT_COMMIT_OFFSET, 518) \ - M(NO_REMOTE_SHARD_AVAILABLE, 519) \ - M(CANNOT_DETACH_DICTIONARY_AS_TABLE, 520) \ - M(ATOMIC_RENAME_FAIL, 521) \ - M(UNKNOWN_ROW_POLICY, 523) \ - M(ALTER_OF_COLUMN_IS_FORBIDDEN, 524) \ - M(INCORRECT_DISK_INDEX, 525) \ - M(UNKNOWN_VOLUME_TYPE, 526) \ - M(NO_SUITABLE_FUNCTION_IMPLEMENTATION, 527) \ - M(CASSANDRA_INTERNAL_ERROR, 528) \ - M(NOT_A_LEADER, 529) \ - M(CANNOT_CONNECT_RABBITMQ, 530) \ - M(CANNOT_FSTAT, 531) \ - M(LDAP_ERROR, 532) \ - M(INCONSISTENT_RESERVATIONS, 533) \ - M(NO_RESERVATIONS_PROVIDED, 534) \ - M(UNKNOWN_RAID_TYPE, 535) \ - M(CANNOT_RESTORE_FROM_FIELD_DUMP, 536) \ - M(ILLEGAL_MYSQL_VARIABLE, 537) \ - M(MYSQL_SYNTAX_ERROR, 538) \ - M(CANNOT_BIND_RABBITMQ_EXCHANGE, 539) \ - M(CANNOT_DECLARE_RABBITMQ_EXCHANGE, 540) \ - M(CANNOT_CREATE_RABBITMQ_QUEUE_BINDING, 541) \ - M(CANNOT_REMOVE_RABBITMQ_EXCHANGE, 542) \ - M(UNKNOWN_MYSQL_DATATYPES_SUPPORT_LEVEL, 543) \ - M(ROW_AND_ROWS_TOGETHER, 544) \ - M(FIRST_AND_NEXT_TOGETHER, 545) \ - M(NO_ROW_DELIMITER, 546) \ - M(INVALID_RAID_TYPE, 547) \ - M(UNKNOWN_VOLUME, 548) \ + M(0, OK) \ + M(1, UNSUPPORTED_METHOD) \ + M(2, UNSUPPORTED_PARAMETER) \ + M(3, UNEXPECTED_END_OF_FILE) \ + M(4, EXPECTED_END_OF_FILE) \ + M(6, CANNOT_PARSE_TEXT) \ + M(7, INCORRECT_NUMBER_OF_COLUMNS) \ + M(8, THERE_IS_NO_COLUMN) \ + M(9, SIZES_OF_COLUMNS_DOESNT_MATCH) \ + M(10, NOT_FOUND_COLUMN_IN_BLOCK) \ + M(11, POSITION_OUT_OF_BOUND) \ + M(12, PARAMETER_OUT_OF_BOUND) \ + M(13, SIZES_OF_COLUMNS_IN_TUPLE_DOESNT_MATCH) \ + M(15, DUPLICATE_COLUMN) \ + M(16, NO_SUCH_COLUMN_IN_TABLE) \ + M(17, DELIMITER_IN_STRING_LITERAL_DOESNT_MATCH) \ + M(18, CANNOT_INSERT_ELEMENT_INTO_CONSTANT_COLUMN) \ + M(19, SIZE_OF_FIXED_STRING_DOESNT_MATCH) \ + M(20, NUMBER_OF_COLUMNS_DOESNT_MATCH) \ + M(21, CANNOT_READ_ALL_DATA_FROM_TAB_SEPARATED_INPUT) \ + M(22, CANNOT_PARSE_ALL_VALUE_FROM_TAB_SEPARATED_INPUT) \ + M(23, CANNOT_READ_FROM_ISTREAM) \ + M(24, CANNOT_WRITE_TO_OSTREAM) \ + M(25, CANNOT_PARSE_ESCAPE_SEQUENCE) \ + M(26, CANNOT_PARSE_QUOTED_STRING) \ + M(27, CANNOT_PARSE_INPUT_ASSERTION_FAILED) \ + M(28, CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER) \ + M(29, CANNOT_PRINT_INTEGER) \ + M(30, CANNOT_READ_SIZE_OF_COMPRESSED_CHUNK) \ + M(31, CANNOT_READ_COMPRESSED_CHUNK) \ + M(32, ATTEMPT_TO_READ_AFTER_EOF) \ + M(33, CANNOT_READ_ALL_DATA) \ + M(34, TOO_MANY_ARGUMENTS_FOR_FUNCTION) \ + M(35, TOO_FEW_ARGUMENTS_FOR_FUNCTION) \ + M(36, BAD_ARGUMENTS) \ + M(37, UNKNOWN_ELEMENT_IN_AST) \ + M(38, CANNOT_PARSE_DATE) \ + M(39, TOO_LARGE_SIZE_COMPRESSED) \ + M(40, CHECKSUM_DOESNT_MATCH) \ + M(41, CANNOT_PARSE_DATETIME) \ + M(42, NUMBER_OF_ARGUMENTS_DOESNT_MATCH) \ + M(43, ILLEGAL_TYPE_OF_ARGUMENT) \ + M(44, ILLEGAL_COLUMN) \ + M(45, ILLEGAL_NUMBER_OF_RESULT_COLUMNS) \ + M(46, UNKNOWN_FUNCTION) \ + M(47, UNKNOWN_IDENTIFIER) \ + M(48, NOT_IMPLEMENTED) \ + M(49, LOGICAL_ERROR) \ + M(50, UNKNOWN_TYPE) \ + M(51, EMPTY_LIST_OF_COLUMNS_QUERIED) \ + M(52, COLUMN_QUERIED_MORE_THAN_ONCE) \ + M(53, TYPE_MISMATCH) \ + M(54, STORAGE_DOESNT_ALLOW_PARAMETERS) \ + M(55, STORAGE_REQUIRES_PARAMETER) \ + M(56, UNKNOWN_STORAGE) \ + M(57, TABLE_ALREADY_EXISTS) \ + M(58, TABLE_METADATA_ALREADY_EXISTS) \ + M(59, ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER) \ + M(60, UNKNOWN_TABLE) \ + M(61, ONLY_FILTER_COLUMN_IN_BLOCK) \ + M(62, SYNTAX_ERROR) \ + M(63, UNKNOWN_AGGREGATE_FUNCTION) \ + M(64, CANNOT_READ_AGGREGATE_FUNCTION_FROM_TEXT) \ + M(65, CANNOT_WRITE_AGGREGATE_FUNCTION_AS_TEXT) \ + M(66, NOT_A_COLUMN) \ + M(67, ILLEGAL_KEY_OF_AGGREGATION) \ + M(68, CANNOT_GET_SIZE_OF_FIELD) \ + M(69, ARGUMENT_OUT_OF_BOUND) \ + M(70, CANNOT_CONVERT_TYPE) \ + M(71, CANNOT_WRITE_AFTER_END_OF_BUFFER) \ + M(72, CANNOT_PARSE_NUMBER) \ + M(73, UNKNOWN_FORMAT) \ + M(74, CANNOT_READ_FROM_FILE_DESCRIPTOR) \ + M(75, CANNOT_WRITE_TO_FILE_DESCRIPTOR) \ + M(76, CANNOT_OPEN_FILE) \ + M(77, CANNOT_CLOSE_FILE) \ + M(78, UNKNOWN_TYPE_OF_QUERY) \ + M(79, INCORRECT_FILE_NAME) \ + M(80, INCORRECT_QUERY) \ + M(81, UNKNOWN_DATABASE) \ + M(82, DATABASE_ALREADY_EXISTS) \ + M(83, DIRECTORY_DOESNT_EXIST) \ + M(84, DIRECTORY_ALREADY_EXISTS) \ + M(85, FORMAT_IS_NOT_SUITABLE_FOR_INPUT) \ + M(86, RECEIVED_ERROR_FROM_REMOTE_IO_SERVER) \ + M(87, CANNOT_SEEK_THROUGH_FILE) \ + M(88, CANNOT_TRUNCATE_FILE) \ + M(89, UNKNOWN_COMPRESSION_METHOD) \ + M(90, EMPTY_LIST_OF_COLUMNS_PASSED) \ + M(91, SIZES_OF_MARKS_FILES_ARE_INCONSISTENT) \ + M(92, EMPTY_DATA_PASSED) \ + M(93, UNKNOWN_AGGREGATED_DATA_VARIANT) \ + M(94, CANNOT_MERGE_DIFFERENT_AGGREGATED_DATA_VARIANTS) \ + M(95, CANNOT_READ_FROM_SOCKET) \ + M(96, CANNOT_WRITE_TO_SOCKET) \ + M(97, CANNOT_READ_ALL_DATA_FROM_CHUNKED_INPUT) \ + M(98, CANNOT_WRITE_TO_EMPTY_BLOCK_OUTPUT_STREAM) \ + M(99, UNKNOWN_PACKET_FROM_CLIENT) \ + M(100, UNKNOWN_PACKET_FROM_SERVER) \ + M(101, UNEXPECTED_PACKET_FROM_CLIENT) \ + M(102, UNEXPECTED_PACKET_FROM_SERVER) \ + M(103, RECEIVED_DATA_FOR_WRONG_QUERY_ID) \ + M(104, TOO_SMALL_BUFFER_SIZE) \ + M(105, CANNOT_READ_HISTORY) \ + M(106, CANNOT_APPEND_HISTORY) \ + M(107, FILE_DOESNT_EXIST) \ + M(108, NO_DATA_TO_INSERT) \ + M(109, CANNOT_BLOCK_SIGNAL) \ + M(110, CANNOT_UNBLOCK_SIGNAL) \ + M(111, CANNOT_MANIPULATE_SIGSET) \ + M(112, CANNOT_WAIT_FOR_SIGNAL) \ + M(113, THERE_IS_NO_SESSION) \ + M(114, CANNOT_CLOCK_GETTIME) \ + M(115, UNKNOWN_SETTING) \ + M(116, THERE_IS_NO_DEFAULT_VALUE) \ + M(117, INCORRECT_DATA) \ + M(119, ENGINE_REQUIRED) \ + M(120, CANNOT_INSERT_VALUE_OF_DIFFERENT_SIZE_INTO_TUPLE) \ + M(121, UNSUPPORTED_JOIN_KEYS) \ + M(122, INCOMPATIBLE_COLUMNS) \ + M(123, UNKNOWN_TYPE_OF_AST_NODE) \ + M(124, INCORRECT_ELEMENT_OF_SET) \ + M(125, INCORRECT_RESULT_OF_SCALAR_SUBQUERY) \ + M(126, CANNOT_GET_RETURN_TYPE) \ + M(127, ILLEGAL_INDEX) \ + M(128, TOO_LARGE_ARRAY_SIZE) \ + M(129, FUNCTION_IS_SPECIAL) \ + M(130, CANNOT_READ_ARRAY_FROM_TEXT) \ + M(131, TOO_LARGE_STRING_SIZE) \ + M(133, AGGREGATE_FUNCTION_DOESNT_ALLOW_PARAMETERS) \ + M(134, PARAMETERS_TO_AGGREGATE_FUNCTIONS_MUST_BE_LITERALS) \ + M(135, ZERO_ARRAY_OR_TUPLE_INDEX) \ + M(137, UNKNOWN_ELEMENT_IN_CONFIG) \ + M(138, EXCESSIVE_ELEMENT_IN_CONFIG) \ + M(139, NO_ELEMENTS_IN_CONFIG) \ + M(140, ALL_REQUESTED_COLUMNS_ARE_MISSING) \ + M(141, SAMPLING_NOT_SUPPORTED) \ + M(142, NOT_FOUND_NODE) \ + M(143, FOUND_MORE_THAN_ONE_NODE) \ + M(144, FIRST_DATE_IS_BIGGER_THAN_LAST_DATE) \ + M(145, UNKNOWN_OVERFLOW_MODE) \ + M(146, QUERY_SECTION_DOESNT_MAKE_SENSE) \ + M(147, NOT_FOUND_FUNCTION_ELEMENT_FOR_AGGREGATE) \ + M(148, NOT_FOUND_RELATION_ELEMENT_FOR_CONDITION) \ + M(149, NOT_FOUND_RHS_ELEMENT_FOR_CONDITION) \ + M(150, EMPTY_LIST_OF_ATTRIBUTES_PASSED) \ + M(151, INDEX_OF_COLUMN_IN_SORT_CLAUSE_IS_OUT_OF_RANGE) \ + M(152, UNKNOWN_DIRECTION_OF_SORTING) \ + M(153, ILLEGAL_DIVISION) \ + M(154, AGGREGATE_FUNCTION_NOT_APPLICABLE) \ + M(155, UNKNOWN_RELATION) \ + M(156, DICTIONARIES_WAS_NOT_LOADED) \ + M(157, ILLEGAL_OVERFLOW_MODE) \ + M(158, TOO_MANY_ROWS) \ + M(159, TIMEOUT_EXCEEDED) \ + M(160, TOO_SLOW) \ + M(161, TOO_MANY_COLUMNS) \ + M(162, TOO_DEEP_SUBQUERIES) \ + M(163, TOO_DEEP_PIPELINE) \ + M(164, READONLY) \ + M(165, TOO_MANY_TEMPORARY_COLUMNS) \ + M(166, TOO_MANY_TEMPORARY_NON_CONST_COLUMNS) \ + M(167, TOO_DEEP_AST) \ + M(168, TOO_BIG_AST) \ + M(169, BAD_TYPE_OF_FIELD) \ + M(170, BAD_GET) \ + M(172, CANNOT_CREATE_DIRECTORY) \ + M(173, CANNOT_ALLOCATE_MEMORY) \ + M(174, CYCLIC_ALIASES) \ + M(176, CHUNK_NOT_FOUND) \ + M(177, DUPLICATE_CHUNK_NAME) \ + M(178, MULTIPLE_ALIASES_FOR_EXPRESSION) \ + M(179, MULTIPLE_EXPRESSIONS_FOR_ALIAS) \ + M(180, THERE_IS_NO_PROFILE) \ + M(181, ILLEGAL_FINAL) \ + M(182, ILLEGAL_PREWHERE) \ + M(183, UNEXPECTED_EXPRESSION) \ + M(184, ILLEGAL_AGGREGATION) \ + M(185, UNSUPPORTED_MYISAM_BLOCK_TYPE) \ + M(186, UNSUPPORTED_COLLATION_LOCALE) \ + M(187, COLLATION_COMPARISON_FAILED) \ + M(188, UNKNOWN_ACTION) \ + M(189, TABLE_MUST_NOT_BE_CREATED_MANUALLY) \ + M(190, SIZES_OF_ARRAYS_DOESNT_MATCH) \ + M(191, SET_SIZE_LIMIT_EXCEEDED) \ + M(192, UNKNOWN_USER) \ + M(193, WRONG_PASSWORD) \ + M(194, REQUIRED_PASSWORD) \ + M(195, IP_ADDRESS_NOT_ALLOWED) \ + M(196, UNKNOWN_ADDRESS_PATTERN_TYPE) \ + M(197, SERVER_REVISION_IS_TOO_OLD) \ + M(198, DNS_ERROR) \ + M(199, UNKNOWN_QUOTA) \ + M(200, QUOTA_DOESNT_ALLOW_KEYS) \ + M(201, QUOTA_EXPIRED) \ + M(202, TOO_MANY_SIMULTANEOUS_QUERIES) \ + M(203, NO_FREE_CONNECTION) \ + M(204, CANNOT_FSYNC) \ + M(205, NESTED_TYPE_TOO_DEEP) \ + M(206, ALIAS_REQUIRED) \ + M(207, AMBIGUOUS_IDENTIFIER) \ + M(208, EMPTY_NESTED_TABLE) \ + M(209, SOCKET_TIMEOUT) \ + M(210, NETWORK_ERROR) \ + M(211, EMPTY_QUERY) \ + M(212, UNKNOWN_LOAD_BALANCING) \ + M(213, UNKNOWN_TOTALS_MODE) \ + M(214, CANNOT_STATVFS) \ + M(215, NOT_AN_AGGREGATE) \ + M(216, QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING) \ + M(217, CLIENT_HAS_CONNECTED_TO_WRONG_PORT) \ + M(218, TABLE_IS_DROPPED) \ + M(219, DATABASE_NOT_EMPTY) \ + M(220, DUPLICATE_INTERSERVER_IO_ENDPOINT) \ + M(221, NO_SUCH_INTERSERVER_IO_ENDPOINT) \ + M(222, ADDING_REPLICA_TO_NON_EMPTY_TABLE) \ + M(223, UNEXPECTED_AST_STRUCTURE) \ + M(224, REPLICA_IS_ALREADY_ACTIVE) \ + M(225, NO_ZOOKEEPER) \ + M(226, NO_FILE_IN_DATA_PART) \ + M(227, UNEXPECTED_FILE_IN_DATA_PART) \ + M(228, BAD_SIZE_OF_FILE_IN_DATA_PART) \ + M(229, QUERY_IS_TOO_LARGE) \ + M(230, NOT_FOUND_EXPECTED_DATA_PART) \ + M(231, TOO_MANY_UNEXPECTED_DATA_PARTS) \ + M(232, NO_SUCH_DATA_PART) \ + M(233, BAD_DATA_PART_NAME) \ + M(234, NO_REPLICA_HAS_PART) \ + M(235, DUPLICATE_DATA_PART) \ + M(236, ABORTED) \ + M(237, NO_REPLICA_NAME_GIVEN) \ + M(238, FORMAT_VERSION_TOO_OLD) \ + M(239, CANNOT_MUNMAP) \ + M(240, CANNOT_MREMAP) \ + M(241, MEMORY_LIMIT_EXCEEDED) \ + M(242, TABLE_IS_READ_ONLY) \ + M(243, NOT_ENOUGH_SPACE) \ + M(244, UNEXPECTED_ZOOKEEPER_ERROR) \ + M(246, CORRUPTED_DATA) \ + M(247, INCORRECT_MARK) \ + M(248, INVALID_PARTITION_VALUE) \ + M(250, NOT_ENOUGH_BLOCK_NUMBERS) \ + M(251, NO_SUCH_REPLICA) \ + M(252, TOO_MANY_PARTS) \ + M(253, REPLICA_IS_ALREADY_EXIST) \ + M(254, NO_ACTIVE_REPLICAS) \ + M(255, TOO_MANY_RETRIES_TO_FETCH_PARTS) \ + M(256, PARTITION_ALREADY_EXISTS) \ + M(257, PARTITION_DOESNT_EXIST) \ + M(258, UNION_ALL_RESULT_STRUCTURES_MISMATCH) \ + M(260, CLIENT_OUTPUT_FORMAT_SPECIFIED) \ + M(261, UNKNOWN_BLOCK_INFO_FIELD) \ + M(262, BAD_COLLATION) \ + M(263, CANNOT_COMPILE_CODE) \ + M(264, INCOMPATIBLE_TYPE_OF_JOIN) \ + M(265, NO_AVAILABLE_REPLICA) \ + M(266, MISMATCH_REPLICAS_DATA_SOURCES) \ + M(267, STORAGE_DOESNT_SUPPORT_PARALLEL_REPLICAS) \ + M(268, CPUID_ERROR) \ + M(269, INFINITE_LOOP) \ + M(270, CANNOT_COMPRESS) \ + M(271, CANNOT_DECOMPRESS) \ + M(272, CANNOT_IO_SUBMIT) \ + M(273, CANNOT_IO_GETEVENTS) \ + M(274, AIO_READ_ERROR) \ + M(275, AIO_WRITE_ERROR) \ + M(277, INDEX_NOT_USED) \ + M(279, ALL_CONNECTION_TRIES_FAILED) \ + M(280, NO_AVAILABLE_DATA) \ + M(281, DICTIONARY_IS_EMPTY) \ + M(282, INCORRECT_INDEX) \ + M(283, UNKNOWN_DISTRIBUTED_PRODUCT_MODE) \ + M(284, WRONG_GLOBAL_SUBQUERY) \ + M(285, TOO_FEW_LIVE_REPLICAS) \ + M(286, UNSATISFIED_QUORUM_FOR_PREVIOUS_WRITE) \ + M(287, UNKNOWN_FORMAT_VERSION) \ + M(288, DISTRIBUTED_IN_JOIN_SUBQUERY_DENIED) \ + M(289, REPLICA_IS_NOT_IN_QUORUM) \ + M(290, LIMIT_EXCEEDED) \ + M(291, DATABASE_ACCESS_DENIED) \ + M(293, MONGODB_CANNOT_AUTHENTICATE) \ + M(294, INVALID_BLOCK_EXTRA_INFO) \ + M(295, RECEIVED_EMPTY_DATA) \ + M(296, NO_REMOTE_SHARD_FOUND) \ + M(297, SHARD_HAS_NO_CONNECTIONS) \ + M(298, CANNOT_PIPE) \ + M(299, CANNOT_FORK) \ + M(300, CANNOT_DLSYM) \ + M(301, CANNOT_CREATE_CHILD_PROCESS) \ + M(302, CHILD_WAS_NOT_EXITED_NORMALLY) \ + M(303, CANNOT_SELECT) \ + M(304, CANNOT_WAITPID) \ + M(305, TABLE_WAS_NOT_DROPPED) \ + M(306, TOO_DEEP_RECURSION) \ + M(307, TOO_MANY_BYTES) \ + M(308, UNEXPECTED_NODE_IN_ZOOKEEPER) \ + M(309, FUNCTION_CANNOT_HAVE_PARAMETERS) \ + M(317, INVALID_SHARD_WEIGHT) \ + M(318, INVALID_CONFIG_PARAMETER) \ + M(319, UNKNOWN_STATUS_OF_INSERT) \ + M(321, VALUE_IS_OUT_OF_RANGE_OF_DATA_TYPE) \ + M(335, BARRIER_TIMEOUT) \ + M(336, UNKNOWN_DATABASE_ENGINE) \ + M(337, DDL_GUARD_IS_ACTIVE) \ + M(341, UNFINISHED) \ + M(342, METADATA_MISMATCH) \ + M(344, SUPPORT_IS_DISABLED) \ + M(345, TABLE_DIFFERS_TOO_MUCH) \ + M(346, CANNOT_CONVERT_CHARSET) \ + M(347, CANNOT_LOAD_CONFIG) \ + M(349, CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN) \ + M(350, INCOMPATIBLE_SOURCE_TABLES) \ + M(351, AMBIGUOUS_TABLE_NAME) \ + M(352, AMBIGUOUS_COLUMN_NAME) \ + M(353, INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE) \ + M(354, ZLIB_INFLATE_FAILED) \ + M(355, ZLIB_DEFLATE_FAILED) \ + M(356, BAD_LAMBDA) \ + M(357, RESERVED_IDENTIFIER_NAME) \ + M(358, INTO_OUTFILE_NOT_ALLOWED) \ + M(359, TABLE_SIZE_EXCEEDS_MAX_DROP_SIZE_LIMIT) \ + M(360, CANNOT_CREATE_CHARSET_CONVERTER) \ + M(361, SEEK_POSITION_OUT_OF_BOUND) \ + M(362, CURRENT_WRITE_BUFFER_IS_EXHAUSTED) \ + M(363, CANNOT_CREATE_IO_BUFFER) \ + M(364, RECEIVED_ERROR_TOO_MANY_REQUESTS) \ + M(366, SIZES_OF_NESTED_COLUMNS_ARE_INCONSISTENT) \ + M(367, TOO_MANY_FETCHES) \ + M(369, ALL_REPLICAS_ARE_STALE) \ + M(370, DATA_TYPE_CANNOT_BE_USED_IN_TABLES) \ + M(371, INCONSISTENT_CLUSTER_DEFINITION) \ + M(372, SESSION_NOT_FOUND) \ + M(373, SESSION_IS_LOCKED) \ + M(374, INVALID_SESSION_TIMEOUT) \ + M(375, CANNOT_DLOPEN) \ + M(376, CANNOT_PARSE_UUID) \ + M(377, ILLEGAL_SYNTAX_FOR_DATA_TYPE) \ + M(378, DATA_TYPE_CANNOT_HAVE_ARGUMENTS) \ + M(379, UNKNOWN_STATUS_OF_DISTRIBUTED_DDL_TASK) \ + M(380, CANNOT_KILL) \ + M(381, HTTP_LENGTH_REQUIRED) \ + M(382, CANNOT_LOAD_CATBOOST_MODEL) \ + M(383, CANNOT_APPLY_CATBOOST_MODEL) \ + M(384, PART_IS_TEMPORARILY_LOCKED) \ + M(385, MULTIPLE_STREAMS_REQUIRED) \ + M(386, NO_COMMON_TYPE) \ + M(387, DICTIONARY_ALREADY_EXISTS) \ + M(388, CANNOT_ASSIGN_OPTIMIZE) \ + M(389, INSERT_WAS_DEDUPLICATED) \ + M(390, CANNOT_GET_CREATE_TABLE_QUERY) \ + M(391, EXTERNAL_LIBRARY_ERROR) \ + M(392, QUERY_IS_PROHIBITED) \ + M(393, THERE_IS_NO_QUERY) \ + M(394, QUERY_WAS_CANCELLED) \ + M(395, FUNCTION_THROW_IF_VALUE_IS_NON_ZERO) \ + M(396, TOO_MANY_ROWS_OR_BYTES) \ + M(397, QUERY_IS_NOT_SUPPORTED_IN_MATERIALIZED_VIEW) \ + M(398, UNKNOWN_MUTATION_COMMAND) \ + M(399, FORMAT_IS_NOT_SUITABLE_FOR_OUTPUT) \ + M(400, CANNOT_STAT) \ + M(401, FEATURE_IS_NOT_ENABLED_AT_BUILD_TIME) \ + M(402, CANNOT_IOSETUP) \ + M(403, INVALID_JOIN_ON_EXPRESSION) \ + M(404, BAD_ODBC_CONNECTION_STRING) \ + M(405, PARTITION_SIZE_EXCEEDS_MAX_DROP_SIZE_LIMIT) \ + M(406, TOP_AND_LIMIT_TOGETHER) \ + M(407, DECIMAL_OVERFLOW) \ + M(408, BAD_REQUEST_PARAMETER) \ + M(409, EXTERNAL_EXECUTABLE_NOT_FOUND) \ + M(410, EXTERNAL_SERVER_IS_NOT_RESPONDING) \ + M(411, PTHREAD_ERROR) \ + M(412, NETLINK_ERROR) \ + M(413, CANNOT_SET_SIGNAL_HANDLER) \ + M(415, ALL_REPLICAS_LOST) \ + M(416, REPLICA_STATUS_CHANGED) \ + M(417, EXPECTED_ALL_OR_ANY) \ + M(418, UNKNOWN_JOIN) \ + M(419, MULTIPLE_ASSIGNMENTS_TO_COLUMN) \ + M(420, CANNOT_UPDATE_COLUMN) \ + M(421, CANNOT_ADD_DIFFERENT_AGGREGATE_STATES) \ + M(422, UNSUPPORTED_URI_SCHEME) \ + M(423, CANNOT_GETTIMEOFDAY) \ + M(424, CANNOT_LINK) \ + M(425, SYSTEM_ERROR) \ + M(427, CANNOT_COMPILE_REGEXP) \ + M(428, UNKNOWN_LOG_LEVEL) \ + M(429, FAILED_TO_GETPWUID) \ + M(430, MISMATCHING_USERS_FOR_PROCESS_AND_DATA) \ + M(431, ILLEGAL_SYNTAX_FOR_CODEC_TYPE) \ + M(432, UNKNOWN_CODEC) \ + M(433, ILLEGAL_CODEC_PARAMETER) \ + M(434, CANNOT_PARSE_PROTOBUF_SCHEMA) \ + M(435, NO_DATA_FOR_REQUIRED_PROTOBUF_FIELD) \ + M(436, PROTOBUF_BAD_CAST) \ + M(437, PROTOBUF_FIELD_NOT_REPEATED) \ + M(438, DATA_TYPE_CANNOT_BE_PROMOTED) \ + M(439, CANNOT_SCHEDULE_TASK) \ + M(440, INVALID_LIMIT_EXPRESSION) \ + M(441, CANNOT_PARSE_DOMAIN_VALUE_FROM_STRING) \ + M(442, BAD_DATABASE_FOR_TEMPORARY_TABLE) \ + M(443, NO_COMMON_COLUMNS_WITH_PROTOBUF_SCHEMA) \ + M(444, UNKNOWN_PROTOBUF_FORMAT) \ + M(445, CANNOT_MPROTECT) \ + M(446, FUNCTION_NOT_ALLOWED) \ + M(447, HYPERSCAN_CANNOT_SCAN_TEXT) \ + M(448, BROTLI_READ_FAILED) \ + M(449, BROTLI_WRITE_FAILED) \ + M(450, BAD_TTL_EXPRESSION) \ + M(451, BAD_TTL_FILE) \ + M(452, SETTING_CONSTRAINT_VIOLATION) \ + M(453, MYSQL_CLIENT_INSUFFICIENT_CAPABILITIES) \ + M(454, OPENSSL_ERROR) \ + M(455, SUSPICIOUS_TYPE_FOR_LOW_CARDINALITY) \ + M(456, UNKNOWN_QUERY_PARAMETER) \ + M(457, BAD_QUERY_PARAMETER) \ + M(458, CANNOT_UNLINK) \ + M(459, CANNOT_SET_THREAD_PRIORITY) \ + M(460, CANNOT_CREATE_TIMER) \ + M(461, CANNOT_SET_TIMER_PERIOD) \ + M(462, CANNOT_DELETE_TIMER) \ + M(463, CANNOT_FCNTL) \ + M(464, CANNOT_PARSE_ELF) \ + M(465, CANNOT_PARSE_DWARF) \ + M(466, INSECURE_PATH) \ + M(467, CANNOT_PARSE_BOOL) \ + M(468, CANNOT_PTHREAD_ATTR) \ + M(469, VIOLATED_CONSTRAINT) \ + M(470, QUERY_IS_NOT_SUPPORTED_IN_LIVE_VIEW) \ + M(471, INVALID_SETTING_VALUE) \ + M(472, READONLY_SETTING) \ + M(473, DEADLOCK_AVOIDED) \ + M(474, INVALID_TEMPLATE_FORMAT) \ + M(475, INVALID_WITH_FILL_EXPRESSION) \ + M(476, WITH_TIES_WITHOUT_ORDER_BY) \ + M(477, INVALID_USAGE_OF_INPUT) \ + M(478, UNKNOWN_POLICY) \ + M(479, UNKNOWN_DISK) \ + M(480, UNKNOWN_PROTOCOL) \ + M(481, PATH_ACCESS_DENIED) \ + M(482, DICTIONARY_ACCESS_DENIED) \ + M(483, TOO_MANY_REDIRECTS) \ + M(484, INTERNAL_REDIS_ERROR) \ + M(485, SCALAR_ALREADY_EXISTS) \ + M(487, CANNOT_GET_CREATE_DICTIONARY_QUERY) \ + M(488, UNKNOWN_DICTIONARY) \ + M(489, INCORRECT_DICTIONARY_DEFINITION) \ + M(490, CANNOT_FORMAT_DATETIME) \ + M(491, UNACCEPTABLE_URL) \ + M(492, ACCESS_ENTITY_NOT_FOUND) \ + M(493, ACCESS_ENTITY_ALREADY_EXISTS) \ + M(494, ACCESS_ENTITY_FOUND_DUPLICATES) \ + M(495, ACCESS_STORAGE_READONLY) \ + M(496, QUOTA_REQUIRES_CLIENT_KEY) \ + M(497, ACCESS_DENIED) \ + M(498, LIMIT_BY_WITH_TIES_IS_NOT_SUPPORTED) \ + M(499, S3_ERROR) \ + M(501, CANNOT_CREATE_DATABASE) \ + M(502, CANNOT_SIGQUEUE) \ + M(503, AGGREGATE_FUNCTION_THROW) \ + M(504, FILE_ALREADY_EXISTS) \ + M(505, CANNOT_DELETE_DIRECTORY) \ + M(506, UNEXPECTED_ERROR_CODE) \ + M(507, UNABLE_TO_SKIP_UNUSED_SHARDS) \ + M(508, UNKNOWN_ACCESS_TYPE) \ + M(509, INVALID_GRANT) \ + M(510, CACHE_DICTIONARY_UPDATE_FAIL) \ + M(511, UNKNOWN_ROLE) \ + M(512, SET_NON_GRANTED_ROLE) \ + M(513, UNKNOWN_PART_TYPE) \ + M(514, ACCESS_STORAGE_FOR_INSERTION_NOT_FOUND) \ + M(515, INCORRECT_ACCESS_ENTITY_DEFINITION) \ + M(516, AUTHENTICATION_FAILED) \ + M(517, CANNOT_ASSIGN_ALTER) \ + M(518, CANNOT_COMMIT_OFFSET) \ + M(519, NO_REMOTE_SHARD_AVAILABLE) \ + M(520, CANNOT_DETACH_DICTIONARY_AS_TABLE) \ + M(521, ATOMIC_RENAME_FAIL) \ + M(523, UNKNOWN_ROW_POLICY) \ + M(524, ALTER_OF_COLUMN_IS_FORBIDDEN) \ + M(525, INCORRECT_DISK_INDEX) \ + M(526, UNKNOWN_VOLUME_TYPE) \ + M(527, NO_SUITABLE_FUNCTION_IMPLEMENTATION) \ + M(528, CASSANDRA_INTERNAL_ERROR) \ + M(529, NOT_A_LEADER) \ + M(530, CANNOT_CONNECT_RABBITMQ) \ + M(531, CANNOT_FSTAT) \ + M(532, LDAP_ERROR) \ + M(533, INCONSISTENT_RESERVATIONS) \ + M(534, NO_RESERVATIONS_PROVIDED) \ + M(535, UNKNOWN_RAID_TYPE) \ + M(536, CANNOT_RESTORE_FROM_FIELD_DUMP) \ + M(537, ILLEGAL_MYSQL_VARIABLE) \ + M(538, MYSQL_SYNTAX_ERROR) \ + M(539, CANNOT_BIND_RABBITMQ_EXCHANGE) \ + M(540, CANNOT_DECLARE_RABBITMQ_EXCHANGE) \ + M(541, CANNOT_CREATE_RABBITMQ_QUEUE_BINDING) \ + M(542, CANNOT_REMOVE_RABBITMQ_EXCHANGE) \ + M(543, UNKNOWN_MYSQL_DATATYPES_SUPPORT_LEVEL) \ + M(544, ROW_AND_ROWS_TOGETHER) \ + M(545, FIRST_AND_NEXT_TOGETHER) \ + M(546, NO_ROW_DELIMITER) \ + M(547, INVALID_RAID_TYPE) \ + M(548, UNKNOWN_VOLUME) \ \ - M(KEEPER_EXCEPTION, 999) \ - M(POCO_EXCEPTION, 1000) \ - M(STD_EXCEPTION, 1001) \ - M(UNKNOWN_EXCEPTION, 1002) \ + M(999, KEEPER_EXCEPTION) \ + M(1000, POCO_EXCEPTION) \ + M(1001, STD_EXCEPTION) \ + M(1002, UNKNOWN_EXCEPTION) \ \ - M(CONDITIONAL_TREE_PARENT_NOT_FOUND, 2001) \ - M(ILLEGAL_PROJECTION_MANIPULATOR, 2002) \ - M(UNRECOGNIZED_ARGUMENTS, 2003) + M(2001, CONDITIONAL_TREE_PARENT_NOT_FOUND) \ + M(2002, ILLEGAL_PROJECTION_MANIPULATOR) \ + M(2003, UNRECOGNIZED_ARGUMENTS) /* See END */ namespace DB @@ -531,7 +531,7 @@ namespace DB namespace ErrorCodes { - #define M(NAME, VALUE) extern const Value NAME = VALUE; + #define M(VALUE, NAME) extern const Value NAME = VALUE; APPLY_FOR_ERROR_CODES(M) #undef M @@ -543,7 +543,7 @@ namespace ErrorCodes std::string_view names[END+1]; ErrorCodesNames() { - #define M(NAME, VALUE) names[VALUE] = std::string_view(#NAME); + #define M(VALUE, NAME) names[VALUE] = std::string_view(#NAME); APPLY_FOR_ERROR_CODES(M) #undef M } From 2a747ce5af22fde28cfb811abf5a772f8d0a2781 Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Sun, 1 Nov 2020 00:02:52 +0800 Subject: [PATCH 27/95] Allow WITH subqueries to take effect immediately --- src/Interpreters/ApplyWithSubqueryVisitor.cpp | 3 +-- .../01495_subqueries_in_with_statement.reference | 1 + .../0_stateless/01495_subqueries_in_with_statement.sql | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Interpreters/ApplyWithSubqueryVisitor.cpp b/src/Interpreters/ApplyWithSubqueryVisitor.cpp index 805f425beac..d8ddbd2c2fa 100644 --- a/src/Interpreters/ApplyWithSubqueryVisitor.cpp +++ b/src/Interpreters/ApplyWithSubqueryVisitor.cpp @@ -16,10 +16,9 @@ void ApplyWithSubqueryVisitor::visit(ASTPtr & ast, const Data & data) std::optional new_data; if (auto with = node_select->with()) { - for (auto & child : with->children) - visit(child, data); for (auto & child : with->children) { + visit(child, new_data ? *new_data: data); if (auto * ast_with_elem = child->as()) { if (!new_data) diff --git a/tests/queries/0_stateless/01495_subqueries_in_with_statement.reference b/tests/queries/0_stateless/01495_subqueries_in_with_statement.reference index 16ca3450a74..c494604b4df 100644 --- a/tests/queries/0_stateless/01495_subqueries_in_with_statement.reference +++ b/tests/queries/0_stateless/01495_subqueries_in_with_statement.reference @@ -30,3 +30,4 @@ \N 42 42 +1764 diff --git a/tests/queries/0_stateless/01495_subqueries_in_with_statement.sql b/tests/queries/0_stateless/01495_subqueries_in_with_statement.sql index 8102ed29fa8..819346be129 100644 --- a/tests/queries/0_stateless/01495_subqueries_in_with_statement.sql +++ b/tests/queries/0_stateless/01495_subqueries_in_with_statement.sql @@ -70,4 +70,10 @@ SELECT max(n) m FROM test1 where test1.m=43 having max(n)=42; WITH test1 AS (SELECT n, null b, n+1 m FROM with_test where n = 42 order by n limit 4) SELECT max(n) m FROM test1 where b is null and test1.m=43 having m=42 limit 4; +with + test1 as (select n, null b, n+1 m from with_test where n = 42 order by n limit 4), + test2 as (select n + 1 as x, n - 1 as y from test1), + test3 as (select x * y as z from test2) +select z + 1 as q from test3; + drop table with_test ; From 73cfe76c49b49c7098abbeefff551e062772ff4f Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Sat, 31 Oct 2020 20:16:49 +0300 Subject: [PATCH 28/95] Update order-by.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Удалил изменения. --- .../statements/select/order-by.md | 67 ------------------- 1 file changed, 67 deletions(-) diff --git a/docs/en/sql-reference/statements/select/order-by.md b/docs/en/sql-reference/statements/select/order-by.md index 314f41e6e5f..a4e5e3655c6 100644 --- a/docs/en/sql-reference/statements/select/order-by.md +++ b/docs/en/sql-reference/statements/select/order-by.md @@ -221,70 +221,3 @@ returns │ 1970-03-12 │ 1970-01-08 │ original │ └────────────┴────────────┴──────────┘ ``` - -## OFFSET FETCH Clause {#offset-fetch} - -`OFFSET` and `FETCH` allow you to retrieve just a portion of the rows that are generated by the rest of the query. - -``` sql -OFFSET offset_row_count {ROW | ROWS} FETCH {FIRST | NEXT} fetch_row_count {ROW | ROWS} {ONLY | WITH TIES} -``` - -The `FETCH` is an alternative to the [LIMIT] (../../../sql-reference/statements/select/limit.md) clause and retrieves rows from a query `SELECT` type. - -The `OFFSET` says to skip that many rows before beginning to return rows. - -For example, the following query - -``` sql -SELECT * FROM test_fetch ORDER BY a OFFSET 1 ROW FETCH FIRST 3 ROWS ONLY -``` - -is identical to the query - -``` sql -SELECT * FROM test_fetch ORDER BY a LIMIT 3 OFFSET 1 -``` - -When using `FETCH`, it is important to use an [ORDER BY] (../../../sql-reference/statements/select/order-by.md) clause that constrains the result rows into a unique order. Otherwise, you will get an unpredictable subset of the query's rows. - -`ROW` and `ROWS` as well as `FIRST` and `NEXT` are noise words that don't influence the effects of these conditions. - -The `ONLY` option is used to return rows that immediately follow the rows omitted by the `OFFSET`. - -The `WITH TIES` option is used to return any additional rows that tie for the last place in the result set according to the `ORDER BY` clause. The `ORDER BY` is mandatory in this case. - -!!! note "Note" - According to the standard, the `OFFSET` clause must come before the `FETCH` clause if both are present. - -### Example {#example} - -Input table: - -``` text -┌─a─┬─b─┐ -│ 1 │ 1 │ -│ 2 │ 1 │ -│ 3 │ 4 │ -│ 1 │ 3 │ -│ 5 │ 4 │ -│ 0 │ 6 │ -│ 5 │ 7 │ -└───┴───┘ -``` - -Query: - -``` sql -SELECT * FROM test_fetch ORDER BY a OFFSET 1 ROW FETCH FIRST 3 ROWS ONLY -``` - -Result: - -``` text -┌─a─┬─b─┐ -│ 1 │ 1 │ -│ 1 │ 3 │ -│ 2 │ 1 │ -└───┴───┘ -``` \ No newline at end of file From 5363c62fc5af620dc020ded9711818a20f5d89c2 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sun, 1 Nov 2020 08:56:30 +0300 Subject: [PATCH 29/95] Fix overflow check in ErrorCodes --- src/Common/ErrorCodes.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Common/ErrorCodes.h b/src/Common/ErrorCodes.h index 9afa4daae90..cc610c5d927 100644 --- a/src/Common/ErrorCodes.h +++ b/src/Common/ErrorCodes.h @@ -33,7 +33,12 @@ namespace ErrorCodes /// Add value for specified error_code. inline void increment(ErrorCode error_code) { - error_code = std::min(error_code, end()-1); + if (error_code >= end()) + { + /// For everything outside the range, use END. + /// (end() is the pointer pass the end, while END is the last value that has an element in values array). + error_code = end() - 1; + } values[error_code].fetch_add(1, std::memory_order_relaxed); } } From 08e523d5dea0bcb9a887ff8db400147b4a773870 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Sun, 1 Nov 2020 17:58:37 +0300 Subject: [PATCH 30/95] Update settings.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавил описание настройки max_concurrent_queries_for_all_users. --- .../settings.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/en/operations/server-configuration-parameters/settings.md b/docs/en/operations/server-configuration-parameters/settings.md index 368ef8e6f7c..dbece2d0cee 100644 --- a/docs/en/operations/server-configuration-parameters/settings.md +++ b/docs/en/operations/server-configuration-parameters/settings.md @@ -479,6 +479,24 @@ The maximum number of simultaneously processed requests. 100 ``` +## max_concurrent_queries_for_all_users {#max-concurrent-queries-for-all-users} + +The maximum number of simultaneously processed requests for all users. + +Default value: `0`. + +**Example** + +``` xml +99 +``` + +`max_concurrent_queries_for_all_users` can be set to 99 for all users and database administrator can set it to 100 for itself to run queries for investigation even when the server is overloaded. + +**See Also** + +- [max_concurrent_queries](#max-concurrent-queries) + ## max_connections {#max-connections} The maximum number of inbound connections. From 13fee1977877b2e262200c4cfbb28cb3c55fb5b1 Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Mon, 2 Nov 2020 11:10:20 +0800 Subject: [PATCH 31/95] Allow parameterized functions in APPLY --- src/Parsers/ASTColumnsTransformers.cpp | 11 ++++++++--- src/Parsers/ASTColumnsTransformers.h | 3 +++ src/Parsers/ExpressionElementParsers.cpp | 19 ++++++++++++++++--- .../01470_columns_transformers.reference | 6 ++++++ .../01470_columns_transformers.sql | 4 ++++ 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/Parsers/ASTColumnsTransformers.cpp b/src/Parsers/ASTColumnsTransformers.cpp index fee606aec26..a8f39079902 100644 --- a/src/Parsers/ASTColumnsTransformers.cpp +++ b/src/Parsers/ASTColumnsTransformers.cpp @@ -30,16 +30,21 @@ void IASTColumnsTransformer::transform(const ASTPtr & transformer, ASTs & nodes) } } -void ASTColumnsApplyTransformer::formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const +void ASTColumnsApplyTransformer::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const { - settings.ostr << (settings.hilite ? hilite_keyword : "") << "APPLY" << (settings.hilite ? hilite_none : "") << "(" << func_name << ")"; + settings.ostr << (settings.hilite ? hilite_keyword : "") << "APPLY" << (settings.hilite ? hilite_none : "") << "(" << func_name; + if (parameters) + parameters->formatImpl(settings, state, frame); + settings.ostr << ")"; } void ASTColumnsApplyTransformer::transform(ASTs & nodes) const { for (auto & column : nodes) { - column = makeASTFunction(func_name, column); + auto function = makeASTFunction(func_name, column); + function->parameters = parameters; + column = function; } } diff --git a/src/Parsers/ASTColumnsTransformers.h b/src/Parsers/ASTColumnsTransformers.h index 4b7a933647e..38dbb80d7f8 100644 --- a/src/Parsers/ASTColumnsTransformers.h +++ b/src/Parsers/ASTColumnsTransformers.h @@ -18,10 +18,13 @@ public: ASTPtr clone() const override { auto res = std::make_shared(*this); + if (parameters) + res->parameters = parameters->clone(); return res; } void transform(ASTs & nodes) const override; String func_name; + ASTPtr parameters; protected: void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override; diff --git a/src/Parsers/ExpressionElementParsers.cpp b/src/Parsers/ExpressionElementParsers.cpp index 3c45bd005a9..9abcf073e21 100644 --- a/src/Parsers/ExpressionElementParsers.cpp +++ b/src/Parsers/ExpressionElementParsers.cpp @@ -1229,16 +1229,29 @@ bool ParserColumnsTransformers::parseImpl(Pos & pos, ASTPtr & node, Expected & e return false; ++pos; - String func_name; - if (!parseIdentifierOrStringLiteral(pos, expected, func_name)) + ASTPtr func_name; + if (!ParserIdentifier().parse(pos, func_name, expected)) return false; + ASTPtr expr_list_args; + if (pos->type == TokenType::OpeningRoundBracket) + { + ++pos; + if (!ParserExpressionList(false).parse(pos, expr_list_args, expected)) + return false; + + if (pos->type != TokenType::ClosingRoundBracket) + return false; + ++pos; + } + if (pos->type != TokenType::ClosingRoundBracket) return false; ++pos; auto res = std::make_shared(); - res->func_name = func_name; + res->func_name = getIdentifierName(func_name); + res->parameters = expr_list_args; node = std::move(res); return true; } diff --git a/tests/queries/0_stateless/01470_columns_transformers.reference b/tests/queries/0_stateless/01470_columns_transformers.reference index 2d8a1802289..a3b04de231a 100644 --- a/tests/queries/0_stateless/01470_columns_transformers.reference +++ b/tests/queries/0_stateless/01470_columns_transformers.reference @@ -77,3 +77,9 @@ SELECT toFloat64(k), j FROM columns_transformers +[110] [9] [173.5] +SELECT + quantiles(0.5)(i), + quantiles(0.5)(j), + quantiles(0.5)(k) +FROM columns_transformers diff --git a/tests/queries/0_stateless/01470_columns_transformers.sql b/tests/queries/0_stateless/01470_columns_transformers.sql index f95cee51fb0..f5178d139ac 100644 --- a/tests/queries/0_stateless/01470_columns_transformers.sql +++ b/tests/queries/0_stateless/01470_columns_transformers.sql @@ -41,4 +41,8 @@ EXPLAIN SYNTAX SELECT COLUMNS(i, j, k) APPLY(sum) from columns_transformers; SELECT i, j, COLUMNS(i, j, k) APPLY(toFloat64), COLUMNS(i, j) EXCEPT (i) from columns_transformers; EXPLAIN SYNTAX SELECT i, j, COLUMNS(i, j, k) APPLY(toFloat64), COLUMNS(i, j) EXCEPT (i) from columns_transformers; +-- APPLY with parameterized function +SELECT COLUMNS(i, j, k) APPLY(quantiles(0.5)) from columns_transformers; +EXPLAIN SYNTAX SELECT COLUMNS(i, j, k) APPLY(quantiles(0.5)) from columns_transformers; + DROP TABLE columns_transformers; From 4cfae808faa8b7158a5f7cae7ee124eefd16102a Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Mon, 2 Nov 2020 18:03:52 +0800 Subject: [PATCH 32/95] Query parameter type : Identifier --- .../ReplaceQueryParameterVisitor.cpp | 27 ++++++++ .../ReplaceQueryParameterVisitor.h | 2 + src/Parsers/ASTIdentifier.cpp | 62 +++++++++++++----- src/Parsers/ASTIdentifier.h | 9 ++- src/Parsers/ExpressionElementParsers.cpp | 65 ++++++++++++++++--- src/Parsers/ExpressionElementParsers.h | 22 ++++++- src/Parsers/ParserTablesInSelectQuery.cpp | 2 +- ...1550_query_identifier_parameters.reference | 5 ++ .../01550_query_identifier_parameters.sh | 10 +++ 9 files changed, 176 insertions(+), 28 deletions(-) create mode 100644 tests/queries/0_stateless/01550_query_identifier_parameters.reference create mode 100755 tests/queries/0_stateless/01550_query_identifier_parameters.sh diff --git a/src/Interpreters/ReplaceQueryParameterVisitor.cpp b/src/Interpreters/ReplaceQueryParameterVisitor.cpp index 3dabfb06770..9b4223b8947 100644 --- a/src/Interpreters/ReplaceQueryParameterVisitor.cpp +++ b/src/Interpreters/ReplaceQueryParameterVisitor.cpp @@ -5,8 +5,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -25,6 +27,8 @@ void ReplaceQueryParameterVisitor::visit(ASTPtr & ast) { if (ast->as()) visitQueryParameter(ast); + else if (ast->as()) + visitIdentifier(ast); else visitChildren(ast); } @@ -71,4 +75,27 @@ void ReplaceQueryParameterVisitor::visitQueryParameter(ASTPtr & ast) ast->setAlias(alias); } +void ReplaceQueryParameterVisitor::visitIdentifier(ASTPtr & ast) +{ + auto & ast_identifier = ast->as(); + if (ast_identifier.children.empty()) + return; + + auto & name_parts = ast_identifier.name_parts; + for (size_t i = 0, j = 0, size = name_parts.size(); i < size; ++i) + { + if (name_parts[i].empty()) + { + const auto & ast_param = ast_identifier.children[j++]->as(); + name_parts[i] = getParamValue(ast_param.name); + } + } + + if (!ast_identifier.semantic->special && name_parts.size() >= 2) + ast_identifier.semantic->table = ast_identifier.name_parts.end()[-2]; + + ast_identifier.resetFullName(); + ast_identifier.children.clear(); +} + } diff --git a/src/Interpreters/ReplaceQueryParameterVisitor.h b/src/Interpreters/ReplaceQueryParameterVisitor.h index 3a84cd22acd..23e36df3fee 100644 --- a/src/Interpreters/ReplaceQueryParameterVisitor.h +++ b/src/Interpreters/ReplaceQueryParameterVisitor.h @@ -9,6 +9,7 @@ namespace DB class ASTQueryParameter; /// Visit substitutions in a query, replace ASTQueryParameter with ASTLiteral. +/// Rebuild ASTIdentifiers if some parts are ASTQueryParameter. class ReplaceQueryParameterVisitor { public: @@ -21,6 +22,7 @@ public: private: const NameToNameMap & query_parameters; const String & getParamValue(const String & name); + void visitIdentifier(ASTPtr & ast); void visitQueryParameter(ASTPtr & ast); void visitChildren(ASTPtr & ast); }; diff --git a/src/Parsers/ASTIdentifier.cpp b/src/Parsers/ASTIdentifier.cpp index d980300a22a..5a66bc7891d 100644 --- a/src/Parsers/ASTIdentifier.cpp +++ b/src/Parsers/ASTIdentifier.cpp @@ -16,26 +16,48 @@ namespace ErrorCodes extern const int SYNTAX_ERROR; } -ASTIdentifier::ASTIdentifier(const String & short_name) +ASTIdentifier::ASTIdentifier(const String & short_name, ASTPtr && name_param) : full_name(short_name), name_parts{short_name}, semantic(std::make_shared()) { - assert(!full_name.empty()); + if (name_param == nullptr) + assert(!full_name.empty()); + else + children.push_back(std::move(name_param)); } -ASTIdentifier::ASTIdentifier(std::vector && name_parts_, bool special) +ASTIdentifier::ASTIdentifier(std::vector && name_parts_, bool special, std::vector && name_params) : name_parts(name_parts_), semantic(std::make_shared()) { assert(!name_parts.empty()); - for (const auto & part [[maybe_unused]] : name_parts) - assert(!part.empty()); - semantic->special = special; semantic->legacy_compound = true; + if (!name_params.empty()) + { + size_t params = 0; + for (const auto & part [[maybe_unused]] : name_parts) + { + if (part.empty()) + ++params; + } + assert(params == name_params.size()); + children = std::move(name_params); + } + else + { + for (const auto & part [[maybe_unused]] : name_parts) + assert(!part.empty()); - if (!special && name_parts.size() >= 2) - semantic->table = name_parts.end()[-2]; + if (!special && name_parts.size() >= 2) + semantic->table = name_parts.end()[-2]; - resetFullName(); + resetFullName(); + } +} + +ASTPtr ASTIdentifier::getParam() const +{ + assert(full_name.empty() && children.size() == 1); + return children.front()->clone(); } ASTPtr ASTIdentifier::clone() const @@ -64,13 +86,16 @@ void ASTIdentifier::setShortName(const String & new_name) const String & ASTIdentifier::name() const { - assert(!name_parts.empty()); - assert(!full_name.empty()); + if (children.empty()) + { + assert(!name_parts.empty()); + assert(!full_name.empty()); + } return full_name; } -void ASTIdentifier::formatImplWithoutAlias(const FormatSettings & settings, FormatState &, FormatStateStacked) const +void ASTIdentifier::formatImplWithoutAlias(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const { auto format_element = [&](const String & elem_name) { @@ -82,17 +107,24 @@ void ASTIdentifier::formatImplWithoutAlias(const FormatSettings & settings, Form /// It could be compound but short if (!isShort()) { - for (size_t i = 0, size = name_parts.size(); i < size; ++i) + for (size_t i = 0, j = 0, size = name_parts.size(); i < size; ++i) { if (i != 0) settings.ostr << '.'; - format_element(name_parts[i]); + if (name_parts[i].empty()) + children[j++]->formatImpl(settings, state, frame); + else + format_element(name_parts[i]); } } else { - format_element(shortName()); + const auto & name = shortName(); + if (name.empty()) + children.front()->formatImpl(settings, state, frame); + else + format_element(name); } } diff --git a/src/Parsers/ASTIdentifier.h b/src/Parsers/ASTIdentifier.h index 59f698eab1c..205b3bb9ad1 100644 --- a/src/Parsers/ASTIdentifier.h +++ b/src/Parsers/ASTIdentifier.h @@ -2,6 +2,7 @@ #include +#include #include #include @@ -17,15 +18,19 @@ struct StorageID; /// Identifier (column, table or alias) class ASTIdentifier : public ASTWithAlias { + friend class ReplaceQueryParameterVisitor; public: UUID uuid = UUIDHelpers::Nil; - explicit ASTIdentifier(const String & short_name); - explicit ASTIdentifier(std::vector && name_parts, bool special = false); + explicit ASTIdentifier(const String & short_name, ASTPtr && name_param = {}); + explicit ASTIdentifier(std::vector && name_parts, bool special = false, std::vector && name_params = {}); /** Get the text that identifies this element. */ String getID(char delim) const override { return "Identifier" + (delim + name()); } + /** Get the query param out of a non-compound identifier. */ + ASTPtr getParam() const; + ASTPtr clone() const override; void collectIdentifierNames(IdentifierNameSet & set) const override { set.insert(name()); } diff --git a/src/Parsers/ExpressionElementParsers.cpp b/src/Parsers/ExpressionElementParsers.cpp index 3c45bd005a9..1761b0b4358 100644 --- a/src/Parsers/ExpressionElementParsers.cpp +++ b/src/Parsers/ExpressionElementParsers.cpp @@ -146,7 +146,7 @@ bool ParserSubquery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) } -bool ParserIdentifier::parseImpl(Pos & pos, ASTPtr & node, Expected &) +bool ParserIdentifier::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) { /// Identifier in backquotes or in double quotes if (pos->type == TokenType::QuotedIdentifier) @@ -172,7 +172,51 @@ bool ParserIdentifier::parseImpl(Pos & pos, ASTPtr & node, Expected &) ++pos; return true; } + else if (allow_query_parameter && pos->type == TokenType::OpeningCurlyBrace) + { + ++pos; + if (pos->type != TokenType::BareWord) + { + expected.add(pos, "substitution name (identifier)"); + return false; + } + String name(pos->begin, pos->end); + ++pos; + + if (pos->type != TokenType::Colon) + { + expected.add(pos, "colon between name and type"); + return false; + } + + ++pos; + + if (pos->type != TokenType::BareWord) + { + expected.add(pos, "substitution type (identifier)"); + return false; + } + + String type(pos->begin, pos->end); + ++pos; + + if (type != "Identifier") + { + expected.add(pos, "substitution type (identifier)"); + return false; + } + + if (pos->type != TokenType::ClosingCurlyBrace) + { + expected.add(pos, "closing curly brace"); + return false; + } + ++pos; + + node = std::make_shared("", std::make_shared(name, type)); + return true; + } return false; } @@ -180,14 +224,19 @@ bool ParserIdentifier::parseImpl(Pos & pos, ASTPtr & node, Expected &) bool ParserCompoundIdentifier::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) { ASTPtr id_list; - if (!ParserList(std::make_unique(), std::make_unique(TokenType::Dot), false) - .parse(pos, id_list, expected)) + if (!ParserList(std::make_unique(allow_query_parameter), std::make_unique(TokenType::Dot), false) + .parse(pos, id_list, expected)) return false; std::vector parts; + std::vector params; const auto & list = id_list->as(); for (const auto & child : list.children) + { parts.emplace_back(getIdentifierName(child)); + if (parts.back() == "") + params.push_back(child->as()->getParam()); + } ParserKeyword s_uuid("UUID"); UUID uuid = UUIDHelpers::Nil; @@ -201,7 +250,7 @@ bool ParserCompoundIdentifier::parseImpl(Pos & pos, ASTPtr & node, Expected & ex uuid = parseFromString(ast_uuid->as()->value.get()); } - node = std::make_shared(std::move(parts)); + node = std::make_shared(std::move(parts), false, std::move(params)); node->as()->uuid = uuid; return true; @@ -1174,7 +1223,7 @@ bool ParserAlias::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) bool ParserColumnsMatcher::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) { ParserKeyword columns("COLUMNS"); - ParserList columns_p(std::make_unique(), std::make_unique(TokenType::Comma), false); + ParserList columns_p(std::make_unique(true), std::make_unique(TokenType::Comma), false); ParserStringLiteral regex; if (!columns.ignore(pos, expected)) @@ -1252,7 +1301,7 @@ bool ParserColumnsTransformers::parseImpl(Pos & pos, ASTPtr & node, Expected & e auto parse_id = [&identifiers, &pos, &expected] { ASTPtr identifier; - if (!ParserIdentifier().parse(pos, identifier, expected)) + if (!ParserIdentifier(true).parse(pos, identifier, expected)) return false; identifiers.emplace_back(std::move(identifier)); @@ -1338,7 +1387,7 @@ bool ParserAsterisk::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) bool ParserQualifiedAsterisk::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) { - if (!ParserCompoundIdentifier().parse(pos, node, expected)) + if (!ParserCompoundIdentifier(false, true).parse(pos, node, expected)) return false; if (pos->type != TokenType::Dot) @@ -1475,7 +1524,7 @@ bool ParserExpressionElement::parseImpl(Pos & pos, ASTPtr & node, Expected & exp || ParserFunction().parse(pos, node, expected) || ParserQualifiedAsterisk().parse(pos, node, expected) || ParserAsterisk().parse(pos, node, expected) - || ParserCompoundIdentifier().parse(pos, node, expected) + || ParserCompoundIdentifier(false, true).parse(pos, node, expected) || ParserSubstitution().parse(pos, node, expected) || ParserMySQLGlobalVariable().parse(pos, node, expected); } diff --git a/src/Parsers/ExpressionElementParsers.h b/src/Parsers/ExpressionElementParsers.h index 702d757761a..86cc3db538c 100644 --- a/src/Parsers/ExpressionElementParsers.h +++ b/src/Parsers/ExpressionElementParsers.h @@ -42,9 +42,12 @@ protected: */ class ParserIdentifier : public IParserBase { +public: + ParserIdentifier(bool allow_query_parameter_ = false) : allow_query_parameter(allow_query_parameter_) {} protected: const char * getName() const override { return "identifier"; } bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override; + bool allow_query_parameter; }; @@ -54,12 +57,16 @@ protected: class ParserCompoundIdentifier : public IParserBase { public: - ParserCompoundIdentifier(bool table_name_with_optional_uuid_ = false) - : table_name_with_optional_uuid(table_name_with_optional_uuid_) {} + ParserCompoundIdentifier(bool table_name_with_optional_uuid_ = false, bool allow_query_parameter_ = false) + : table_name_with_optional_uuid(table_name_with_optional_uuid_), allow_query_parameter(allow_query_parameter_) + { + } + protected: const char * getName() const override { return "compound identifier"; } bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override; bool table_name_with_optional_uuid; + bool allow_query_parameter; }; /// Just * @@ -299,6 +306,17 @@ private: }; +/** Prepared statements. + * Parse query with parameter expression {name:type}. + */ +class ParserIdentifierOrSubstitution : public IParserBase +{ +protected: + const char * getName() const override { return "identifier substitution"; } + bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override; +}; + + /** Prepared statements. * Parse query with parameter expression {name:type}. */ diff --git a/src/Parsers/ParserTablesInSelectQuery.cpp b/src/Parsers/ParserTablesInSelectQuery.cpp index a13baf69420..1264acefe64 100644 --- a/src/Parsers/ParserTablesInSelectQuery.cpp +++ b/src/Parsers/ParserTablesInSelectQuery.cpp @@ -23,7 +23,7 @@ bool ParserTableExpression::parseImpl(Pos & pos, ASTPtr & node, Expected & expec if (!ParserWithOptionalAlias(std::make_unique(), true).parse(pos, res->subquery, expected) && !ParserWithOptionalAlias(std::make_unique(), true).parse(pos, res->table_function, expected) - && !ParserWithOptionalAlias(std::make_unique(), true).parse(pos, res->database_and_table_name, expected)) + && !ParserWithOptionalAlias(std::make_unique(false, true), true).parse(pos, res->database_and_table_name, expected)) return false; /// FINAL diff --git a/tests/queries/0_stateless/01550_query_identifier_parameters.reference b/tests/queries/0_stateless/01550_query_identifier_parameters.reference new file mode 100644 index 00000000000..751ee1ae00e --- /dev/null +++ b/tests/queries/0_stateless/01550_query_identifier_parameters.reference @@ -0,0 +1,5 @@ +0 +0 +0 +0 +45 diff --git a/tests/queries/0_stateless/01550_query_identifier_parameters.sh b/tests/queries/0_stateless/01550_query_identifier_parameters.sh new file mode 100755 index 00000000000..85ca67e4e3c --- /dev/null +++ b/tests/queries/0_stateless/01550_query_identifier_parameters.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. "$CURDIR"/../shell_config.sh + +$CLICKHOUSE_CLIENT --param_tbl 'numbers' --query 'select * from system.{tbl:Identifier} limit 1' +$CLICKHOUSE_CLIENT --param_db 'system' --param_tbl 'numbers' --query 'select * from {db:Identifier}.{tbl:Identifier} limit 1' +$CLICKHOUSE_CLIENT --param_col 'number' --query 'select {col:Identifier} from system.numbers limit 1' +$CLICKHOUSE_CLIENT --param_col 'number' --query 'select a.{col:Identifier} from system.numbers a limit 1' +$CLICKHOUSE_CLIENT --param_tbl 'numbers' --param_col 'number' --query 'select sum({tbl:Identifier}.{col:Identifier}) FROM (select * from system.{tbl:Identifier} limit 10) numbers' From 5633dfb402eb1a0da62656efc9946d273a4dec30 Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Mon, 2 Nov 2020 16:15:40 +0300 Subject: [PATCH 33/95] Update ExpressionElementParsers.h --- src/Parsers/ExpressionElementParsers.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Parsers/ExpressionElementParsers.h b/src/Parsers/ExpressionElementParsers.h index 86cc3db538c..09c43a1f769 100644 --- a/src/Parsers/ExpressionElementParsers.h +++ b/src/Parsers/ExpressionElementParsers.h @@ -39,6 +39,7 @@ protected: /** An identifier, for example, x_yz123 or `something special` + * If allow_query_parameter_ = true, also parses substitutions in form {name:Identifier} */ class ParserIdentifier : public IParserBase { @@ -312,7 +313,7 @@ private: class ParserIdentifierOrSubstitution : public IParserBase { protected: - const char * getName() const override { return "identifier substitution"; } + const char * getName() const override { return "identifier or substitution"; } bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override; }; From 5e512568977143f2a5172363a1b85d54d615eb4c Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Mon, 2 Nov 2020 23:04:18 +0800 Subject: [PATCH 34/95] Fix warning --- src/Parsers/ExpressionElementParsers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parsers/ExpressionElementParsers.cpp b/src/Parsers/ExpressionElementParsers.cpp index 1761b0b4358..d69e421e6cf 100644 --- a/src/Parsers/ExpressionElementParsers.cpp +++ b/src/Parsers/ExpressionElementParsers.cpp @@ -234,7 +234,7 @@ bool ParserCompoundIdentifier::parseImpl(Pos & pos, ASTPtr & node, Expected & ex for (const auto & child : list.children) { parts.emplace_back(getIdentifierName(child)); - if (parts.back() == "") + if (parts.back().empty()) params.push_back(child->as()->getParam()); } From 347782966b14c5c97fef505383a8b12371cb9181 Mon Sep 17 00:00:00 2001 From: Fabiano Francesconi Date: Mon, 2 Nov 2020 18:36:54 +0100 Subject: [PATCH 35/95] Added Teralytics to adopters.md Added Teralytics to list of adopters. --- docs/en/introduction/adopters.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/introduction/adopters.md b/docs/en/introduction/adopters.md index 24705a52a9a..d08e7833b33 100644 --- a/docs/en/introduction/adopters.md +++ b/docs/en/introduction/adopters.md @@ -90,6 +90,7 @@ toc_title: Adopters | Splunk | Business Analytics | Main product | — | — | [Slides in English, January 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup12/splunk.pdf) | | Spotify | Music | Experimentation | — | — | [Slides, July 2018](https://www.slideshare.net/glebus/using-clickhouse-for-experimentation-104247173) | | Staffcop | Information Security | Main Product | — | — | [Official website, Documentation](https://www.staffcop.ru/sce43) | +| Teralytics | Mobility | Analytics | — | — | [Tech blog](https://www.teralytics.net/knowledge-hub/visualizing-mobility-data-the-scalability-challenge) | | Tencent | Big Data | Data processing | — | — | [Slides in Chinese, October 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup19/5.%20ClickHouse大数据集群应用_李俊飞腾讯网媒事业部.pdf) | | Tencent | Messaging | Logging | — | — | [Talk in Chinese, November 2019](https://youtu.be/T-iVQRuw-QY?t=5050) | | Traffic Stars | AD network | — | — | — | [Slides in Russian, May 2018](https://github.com/ClickHouse/clickhouse-presentations/blob/master/meetup15/lightning/ninja.pdf) | From 3be8a56f5cdad9f1b514127a93f97f82509edda7 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 29 Oct 2020 22:28:46 +0300 Subject: [PATCH 36/95] Add log_queries_min_query_duration_ms Only queries slower then the value of this setting will go to system.query_log, i.e. something like slow_query_log in mysql. v2: log_queries_min_time renamed to log_queries_min_query_duration_ms v3: add current_database into system.query_thread_log v4: rewrite test using current_database v5: fix query_duration_ms in system.query_thread_log --- docs/en/operations/settings/settings.md | 15 ++++++ src/Common/ThreadStatus.h | 2 +- src/Core/Settings.h | 1 + src/Interpreters/ThreadStatusExt.cpp | 18 ++++--- src/Interpreters/executeQuery.cpp | 23 +++++--- ...og_queries_min_query_duration_ms.reference | 4 ++ ...1546_log_queries_min_query_duration_ms.sql | 54 +++++++++++++++++++ 7 files changed, 102 insertions(+), 15 deletions(-) create mode 100644 tests/queries/0_stateless/01546_log_queries_min_query_duration_ms.reference create mode 100644 tests/queries/0_stateless/01546_log_queries_min_query_duration_ms.sql diff --git a/docs/en/operations/settings/settings.md b/docs/en/operations/settings/settings.md index a4bd7d77bfc..359a3579e46 100644 --- a/docs/en/operations/settings/settings.md +++ b/docs/en/operations/settings/settings.md @@ -680,6 +680,21 @@ Example: log_queries=1 ``` +## log_queries_min_query_duration_ms {#settings-log-queries-min-query-duration-ms} + +Minimal time for the query to run to get to the following tables: + +- `system.query_log` +- `system.query_thread_log` + +Only the queries with the following type will get to the log: + +- `QUERY_FINISH` +- `EXCEPTION_WHILE_PROCESSING` + +- Type: milliseconds +- Default value: 0 (any query) + ## log_queries_min_type {#settings-log-queries-min-type} `query_log` minimal type to log. diff --git a/src/Common/ThreadStatus.h b/src/Common/ThreadStatus.h index 820ea449d66..1b4d20e9721 100644 --- a/src/Common/ThreadStatus.h +++ b/src/Common/ThreadStatus.h @@ -172,7 +172,7 @@ protected: void finalizeQueryProfiler(); - void logToQueryThreadLog(QueryThreadLog & thread_log, const String & current_database); + void logToQueryThreadLog(QueryThreadLog & thread_log, const String & current_database, std::chrono::time_point now); void assertState(const std::initializer_list & permitted_states, const char * description = nullptr) const; diff --git a/src/Core/Settings.h b/src/Core/Settings.h index 896fcaaca82..dabd3ed8b45 100644 --- a/src/Core/Settings.h +++ b/src/Core/Settings.h @@ -150,6 +150,7 @@ class IColumn; \ M(Bool, log_queries, 1, "Log requests and write the log to the system table.", 0) \ M(LogQueriesType, log_queries_min_type, QueryLogElementType::QUERY_START, "Minimal type in query_log to log, possible values (from low to high): QUERY_START, QUERY_FINISH, EXCEPTION_BEFORE_START, EXCEPTION_WHILE_PROCESSING.", 0) \ + M(Milliseconds, log_queries_min_query_duration_ms, 0, "Minimal time for the query to run, to get to the query_log/query_thread_log.", 0) \ M(UInt64, log_queries_cut_to_length, 100000, "If query length is greater than specified threshold (in bytes), then cut query when writing to query log. Also limit length of printed query in ordinary text log.", 0) \ \ M(DistributedProductMode, distributed_product_mode, DistributedProductMode::DENY, "How are distributed subqueries performed inside IN or JOIN sections?", IMPORTANT) \ diff --git a/src/Interpreters/ThreadStatusExt.cpp b/src/Interpreters/ThreadStatusExt.cpp index ffb9e140ce6..adb9a38b10d 100644 --- a/src/Interpreters/ThreadStatusExt.cpp +++ b/src/Interpreters/ThreadStatusExt.cpp @@ -242,8 +242,15 @@ void ThreadStatus::finalizePerformanceCounters() { const auto & settings = query_context->getSettingsRef(); if (settings.log_queries && settings.log_query_threads) - if (auto thread_log = global_context->getQueryThreadLog()) - logToQueryThreadLog(*thread_log, query_context->getCurrentDatabase()); + { + const auto now = std::chrono::system_clock::now(); + Int64 query_duration_ms = (time_in_microseconds(now) - query_start_time_microseconds) / 1000; + if (query_duration_ms >= settings.log_queries_min_query_duration_ms.totalMilliseconds()) + { + if (auto thread_log = global_context->getQueryThreadLog()) + logToQueryThreadLog(*thread_log, query_context->getCurrentDatabase(), now); + } + } } } catch (...) @@ -322,15 +329,14 @@ void ThreadStatus::detachQuery(bool exit_if_already_detached, bool thread_exits) #endif } -void ThreadStatus::logToQueryThreadLog(QueryThreadLog & thread_log, const String & current_database) +void ThreadStatus::logToQueryThreadLog(QueryThreadLog & thread_log, const String & current_database, std::chrono::time_point now) { QueryThreadLogElement elem; // construct current_time and current_time_microseconds using the same time point // so that the two times will always be equal up to a precision of a second. - const auto now = std::chrono::system_clock::now(); - auto current_time = time_in_seconds(now); - auto current_time_microseconds = time_in_microseconds(now); + auto current_time = time_in_seconds(now); + auto current_time_microseconds = time_in_microseconds(now); elem.event_time = current_time; elem.event_time_microseconds = current_time_microseconds; diff --git a/src/Interpreters/executeQuery.cpp b/src/Interpreters/executeQuery.cpp index 5feff841ca9..52940a337cb 100644 --- a/src/Interpreters/executeQuery.cpp +++ b/src/Interpreters/executeQuery.cpp @@ -241,7 +241,7 @@ static void onExceptionBeforeStart(const String & query_for_logging, Context & c /// Update performance counters before logging to query_log CurrentThread::finalizePerformanceCounters(); - if (settings.log_queries && elem.type >= settings.log_queries_min_type) + if (settings.log_queries && elem.type >= settings.log_queries_min_type && !settings.log_queries_min_query_duration_ms.totalMilliseconds()) if (auto query_log = context.getQueryLog()) query_log->add(elem); @@ -552,7 +552,7 @@ static std::tuple executeQueryImpl( if (settings.log_query_settings) elem.query_settings = std::make_shared(context.getSettingsRef()); - if (elem.type >= settings.log_queries_min_type) + if (elem.type >= settings.log_queries_min_type && !settings.log_queries_min_query_duration_ms.totalMilliseconds()) { if (auto query_log = context.getQueryLog()) query_log->add(elem); @@ -588,8 +588,12 @@ static std::tuple executeQueryImpl( }; /// Also make possible for caller to log successful query finish and exception during execution. - auto finish_callback = [elem, &context, ast, log_queries, log_queries_min_type = settings.log_queries_min_type, - status_info_to_query_log] + auto finish_callback = [elem, &context, ast, + log_queries, + log_queries_min_type = settings.log_queries_min_type, + log_queries_min_query_duration_ms = settings.log_queries_min_query_duration_ms.totalMilliseconds(), + status_info_to_query_log + ] (IBlockInputStream * stream_in, IBlockOutputStream * stream_out, QueryPipeline * query_pipeline) mutable { QueryStatus * process_list_elem = context.getProcessListElement(); @@ -655,7 +659,7 @@ static std::tuple executeQueryImpl( elem.thread_ids = std::move(info.thread_ids); elem.profile_counters = std::move(info.profile_counters); - if (log_queries && elem.type >= log_queries_min_type) + if (log_queries && elem.type >= log_queries_min_type && Int64(elem.query_duration_ms) >= log_queries_min_query_duration_ms) { if (auto query_log = context.getQueryLog()) query_log->add(elem); @@ -694,8 +698,11 @@ static std::tuple executeQueryImpl( } }; - auto exception_callback = [elem, &context, ast, log_queries, log_queries_min_type = settings.log_queries_min_type, quota(quota), - status_info_to_query_log] () mutable + auto exception_callback = [elem, &context, ast, + log_queries, + log_queries_min_type = settings.log_queries_min_type, + log_queries_min_query_duration_ms = settings.log_queries_min_query_duration_ms.totalMilliseconds(), + quota(quota), status_info_to_query_log] () mutable { if (quota) quota->used(Quota::ERRORS, 1, /* check_exceeded = */ false); @@ -729,7 +736,7 @@ static std::tuple executeQueryImpl( logException(context, elem); /// In case of exception we log internal queries also - if (log_queries && elem.type >= log_queries_min_type) + if (log_queries && elem.type >= log_queries_min_type && Int64(elem.query_duration_ms) >= log_queries_min_query_duration_ms) { if (auto query_log = context.getQueryLog()) query_log->add(elem); diff --git a/tests/queries/0_stateless/01546_log_queries_min_query_duration_ms.reference b/tests/queries/0_stateless/01546_log_queries_min_query_duration_ms.reference new file mode 100644 index 00000000000..0463db26710 --- /dev/null +++ b/tests/queries/0_stateless/01546_log_queries_min_query_duration_ms.reference @@ -0,0 +1,4 @@ +0 +0 +1 +1 diff --git a/tests/queries/0_stateless/01546_log_queries_min_query_duration_ms.sql b/tests/queries/0_stateless/01546_log_queries_min_query_duration_ms.sql new file mode 100644 index 00000000000..f0f681288cf --- /dev/null +++ b/tests/queries/0_stateless/01546_log_queries_min_query_duration_ms.sql @@ -0,0 +1,54 @@ +set log_queries_min_query_duration_ms=300000; +set log_query_threads=1; +set log_queries=1; + +-- +-- fast -- no logging +-- +select '01546_log_queries_min_query_duration_ms-fast' format Null; +system flush logs; + +-- No logging, since the query is fast enough. +select count() +from system.query_log +where + query like '%01546_log_queries_min_query_duration_ms-fast%' + and query not like '%system.query_log%' + and current_database = currentDatabase() + and event_date = today() + and event_time >= now() - interval 1 minute; +select count() +from system.query_thread_log +where + query like '%01546_log_queries_min_query_duration_ms-fast%' + and query not like '%system.query_thread_log%' + and current_database = currentDatabase() + and event_date = today() + and event_time >= now() - interval 1 minute; + +-- +-- slow -- query logged +-- +set log_queries_min_query_duration_ms=300; +select '01546_log_queries_min_query_duration_ms-slow', sleep(0.4) format Null; +system flush logs; + +-- With the limit on minimum execution time, "query start" and "exception before start" events are not logged, only query finish. +select count() +from system.query_log +where + query like '%01546_log_queries_min_query_duration_ms-slow%' + and query not like '%system.query_log%' + and current_database = currentDatabase() + and event_date = today() + and event_time >= now() - interval 1 minute; +-- There at least two threads involved in a simple query +-- (one thread just waits another, sigh) +select count() == 2 +from system.query_thread_log +where + query like '%01546_log_queries_min_query_duration_ms-slow%' + and query not like '%system.query_thread_log%' + and current_database = currentDatabase() + and event_date = today() + and event_time >= now() - interval 1 minute; From e6d8ab2270532e3ed5171d9ee1e8b52ca2843f82 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 2 Nov 2020 21:37:23 +0300 Subject: [PATCH 37/95] Fix possible name collision in ALTER --- src/Interpreters/InterpreterCreateQuery.cpp | 3 ++- src/Storages/AlterCommands.cpp | 9 ++++----- .../0_stateless/01552_alter_name_collision.reference | 0 tests/queries/0_stateless/01552_alter_name_collision.sql | 3 +++ 4 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 tests/queries/0_stateless/01552_alter_name_collision.reference create mode 100644 tests/queries/0_stateless/01552_alter_name_collision.sql diff --git a/src/Interpreters/InterpreterCreateQuery.cpp b/src/Interpreters/InterpreterCreateQuery.cpp index ddb1d738031..6a8bdbea1ec 100644 --- a/src/Interpreters/InterpreterCreateQuery.cpp +++ b/src/Interpreters/InterpreterCreateQuery.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -362,7 +363,7 @@ ColumnsDescription InterpreterCreateQuery::getColumnsDescription( if (col_decl.type) { const auto & final_column_name = col_decl.name; - const auto tmp_column_name = final_column_name + "_tmp"; + const auto tmp_column_name = final_column_name + "_tmp_alter" + toString(randomSeed()); const auto * data_type_ptr = column_names_and_types.back().type.get(); default_expr_list->children.emplace_back( diff --git a/src/Storages/AlterCommands.cpp b/src/Storages/AlterCommands.cpp index 8cae7866748..559121d6911 100644 --- a/src/Storages/AlterCommands.cpp +++ b/src/Storages/AlterCommands.cpp @@ -22,12 +22,11 @@ #include #include #include +#include #include #include #include - - -#include +#include namespace DB @@ -1117,7 +1116,7 @@ void AlterCommands::validate(const StorageInMemoryMetadata & metadata, const Con data_type_ptr = command.data_type; const auto & final_column_name = column_name; - const auto tmp_column_name = final_column_name + "_tmp"; + const auto tmp_column_name = final_column_name + "_tmp_alter" + toString(randomSeed()); default_expr_list->children.emplace_back(setAlias( addTypeConversionToAST(std::make_shared(tmp_column_name), data_type_ptr->getName()), @@ -1133,7 +1132,7 @@ void AlterCommands::validate(const StorageInMemoryMetadata & metadata, const Con continue; const auto & final_column_name = column_name; - const auto tmp_column_name = final_column_name + "_tmp"; + const auto tmp_column_name = final_column_name + "_tmp_alter" + toString(randomSeed()); const auto data_type_ptr = command.data_type; default_expr_list->children.emplace_back(setAlias( diff --git a/tests/queries/0_stateless/01552_alter_name_collision.reference b/tests/queries/0_stateless/01552_alter_name_collision.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/01552_alter_name_collision.sql b/tests/queries/0_stateless/01552_alter_name_collision.sql new file mode 100644 index 00000000000..dc717f1071a --- /dev/null +++ b/tests/queries/0_stateless/01552_alter_name_collision.sql @@ -0,0 +1,3 @@ +DROP TABLE IF EXISTS test; +CREATE TABLE test(test String DEFAULT 'test', test_tmp Int DEFAULT 1)ENGINE = Memory; +DROP TABLE test; From 3bc8ff6af6b2e8ccbbb1b74f2819bf6d9e266643 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 2 Nov 2020 21:52:04 +0300 Subject: [PATCH 38/95] Add a test for #1148 --- .../01552_dict_fixedstring.reference | 2 ++ .../0_stateless/01552_dict_fixedstring.sql | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/queries/0_stateless/01552_dict_fixedstring.reference create mode 100644 tests/queries/0_stateless/01552_dict_fixedstring.sql diff --git a/tests/queries/0_stateless/01552_dict_fixedstring.reference b/tests/queries/0_stateless/01552_dict_fixedstring.reference new file mode 100644 index 00000000000..2f877f0c754 --- /dev/null +++ b/tests/queries/0_stateless/01552_dict_fixedstring.reference @@ -0,0 +1,2 @@ + +Hello\0World diff --git a/tests/queries/0_stateless/01552_dict_fixedstring.sql b/tests/queries/0_stateless/01552_dict_fixedstring.sql new file mode 100644 index 00000000000..7e0269f8e50 --- /dev/null +++ b/tests/queries/0_stateless/01552_dict_fixedstring.sql @@ -0,0 +1,20 @@ +DROP TABLE IF EXISTS src; + +CREATE TABLE src (k UInt64, s FixedString(11)) ENGINE = Memory; +INSERT INTO src VALUES (1, 'Hello\0World'); + +DROP DICTIONARY IF EXISTS dict; +CREATE DICTIONARY dict +( + k UInt64, + s String +) +PRIMARY KEY k +SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER default TABLE 'src')) +LAYOUT(FLAT) +LIFETIME(MIN 10 MAX 10); + +SELECT dictGet(currentDatabase() || '.dict', 's', number) FROM numbers(2); + +DROP TABLE src; +DROP DICTIONARY dict; From bdd453c54dcc78638c4bfe2e36af5c1ee577301c Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Tue, 3 Nov 2020 00:47:45 +0300 Subject: [PATCH 39/95] Add 01546_log_queries_min_query_duration_ms into arcadia_skip_list In attempt to fix "Yandex synchronization check (only for Yandex employees)" --- tests/queries/0_stateless/arcadia_skip_list.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/queries/0_stateless/arcadia_skip_list.txt b/tests/queries/0_stateless/arcadia_skip_list.txt index f5b81c08520..f6d899a5742 100644 --- a/tests/queries/0_stateless/arcadia_skip_list.txt +++ b/tests/queries/0_stateless/arcadia_skip_list.txt @@ -155,5 +155,6 @@ 01509_dictionary_preallocate 01526_max_untracked_memory 01530_drop_database_atomic_sync +01546_log_queries_min_query_duration_ms 01547_query_log_current_database 01548_query_log_query_execution_ms From 5d2c3d177ec28ba9cf22e4b5f10339f91ea96142 Mon Sep 17 00:00:00 2001 From: Yingchun Lai <405403881@qq.com> Date: Tue, 3 Nov 2020 15:53:44 +0800 Subject: [PATCH 40/95] Update query_log.md --- docs/zh/operations/system-tables/query_log.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/zh/operations/system-tables/query_log.md b/docs/zh/operations/system-tables/query_log.md index bf3aa063a83..6d8d7a39699 100644 --- a/docs/zh/operations/system-tables/query_log.md +++ b/docs/zh/operations/system-tables/query_log.md @@ -3,7 +3,7 @@ machine_translated: true machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3 --- -# 系统。query_log {#system_tables-query_log} +# system.query_log {#system_tables-query_log} 包含有关已执行查询的信息,例如,开始时间、处理持续时间、错误消息。 @@ -140,4 +140,4 @@ Settings.Values: ['0','random','1','10000000000'] **另请参阅** -- [系统。query_thread_log](../../operations/system-tables/query_thread_log.md#system_tables-query_thread_log) — This table contains information about each query execution thread. +- [system.query_thread_log](../../operations/system-tables/query_thread_log.md#system_tables-query_thread_log) — This table contains information about each query execution thread. From 72bde1c688f61ea77ca530e6422445507d2bbea6 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Tue, 3 Nov 2020 17:32:31 +0800 Subject: [PATCH 41/95] better change the config --- .../integration/test_reload_zookeeper/test.py | 35 +++---------------- 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/tests/integration/test_reload_zookeeper/test.py b/tests/integration/test_reload_zookeeper/test.py index 35958c95417..1a48535d3fd 100644 --- a/tests/integration/test_reload_zookeeper/test.py +++ b/tests/integration/test_reload_zookeeper/test.py @@ -28,28 +28,6 @@ def start_cluster(): yield cluster finally: - ## write back the configs - config = open(ZK_CONFIG_PATH, 'w') - config.write( -""" - - - - zoo1 - 2181 - - - zoo2 - 2181 - - - zoo3 - 2181 - - 2000 - - - """) config.close() cluster.shutdown() @@ -71,8 +49,7 @@ def test_reload_zookeeper(start_cluster): node.query("INSERT INTO test_table(date, id) select today(), number FROM numbers(1000)") ## remove zoo2, zoo3 from configs - config = open(ZK_CONFIG_PATH, 'w') - config.write( + new_config = """ @@ -84,8 +61,7 @@ def test_reload_zookeeper(start_cluster): """ - ) - config.close() + node.replace_config("/etc/clickhouse-server/conf.d/zookeeper.xml", new_config) ## config reloads, but can still work assert_eq_with_retry(node, "SELECT COUNT() FROM test_table", '1000', retry_count=120, sleep_time=0.5) @@ -101,8 +77,7 @@ def test_reload_zookeeper(start_cluster): node.query("SELECT COUNT() FROM test_table") ## set config to zoo2, server will be normal - config = open(ZK_CONFIG_PATH, 'w') - config.write( + new_config = """ @@ -114,7 +89,7 @@ def test_reload_zookeeper(start_cluster): """ - ) - config.close() + node.replace_config("/etc/clickhouse-server/conf.d/zookeeper.xml", new_config) + assert_eq_with_retry(node, "SELECT COUNT() FROM test_table", '1000', retry_count=120, sleep_time=0.5) From af5ecbef278ff2d86e0a75d1a7e9e6bcfe92983b Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Tue, 3 Nov 2020 17:57:24 +0800 Subject: [PATCH 42/95] set zookeeper config --- src/Interpreters/Context.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index 7f2ada8a426..be701ff171b 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -363,6 +363,7 @@ struct ContextShared /// Initialized on demand (on distributed storages initialization) since Settings should be initialized std::unique_ptr clusters; ConfigurationPtr clusters_config; /// Stores updated configs + ConfigurationPtr zookeeper_config; /// Stores zookeeperd configs mutable std::mutex clusters_mutex; /// Guards clusters and clusters_config #if USE_EMBEDDED_COMPILER @@ -1472,8 +1473,9 @@ zkutil::ZooKeeperPtr Context::getZooKeeper() const { std::lock_guard lock(shared->zookeeper_mutex); + const auto & config = shared->zookeeper_config ? *shared->zookeeper_config : getConfigRef(); if (!shared->zookeeper) - shared->zookeeper = std::make_shared(getConfigRef(), "zookeeper"); + shared->zookeeper = std::make_shared(config, "zookeeper"); else if (shared->zookeeper->expired()) shared->zookeeper = shared->zookeeper->startNewSession(); @@ -1507,6 +1509,8 @@ void Context::resetZooKeeper() const void Context::reloadZooKeeperIfChanged(const ConfigurationPtr & config) const { std::lock_guard lock(shared->zookeeper_mutex); + shared->zookeeper_config = config; + if (!shared->zookeeper || shared->zookeeper->configChanged(*config, "zookeeper")) { shared->zookeeper = std::make_shared(*config, "zookeeper"); From 9cfeb9fd324f26362e894d22083a1e40f80df329 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Tue, 3 Nov 2020 18:13:48 +0800 Subject: [PATCH 43/95] remove unused codes --- tests/integration/test_reload_zookeeper/test.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/integration/test_reload_zookeeper/test.py b/tests/integration/test_reload_zookeeper/test.py index 1a48535d3fd..ab0f3491ae9 100644 --- a/tests/integration/test_reload_zookeeper/test.py +++ b/tests/integration/test_reload_zookeeper/test.py @@ -10,9 +10,6 @@ from helpers.test_tools import assert_eq_with_retry cluster = ClickHouseCluster(__file__, zookeeper_config_path='configs/zookeeper.xml') node = cluster.add_instance('node', with_zookeeper=True) -SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) -ZK_CONFIG_PATH = os.path.join(SCRIPT_DIR, 'configs/zookeeper.xml') - @pytest.fixture(scope="module") def start_cluster(): @@ -28,7 +25,6 @@ def start_cluster(): yield cluster finally: - config.close() cluster.shutdown() def test_reload_zookeeper(start_cluster): From 4d8fb3842d48047be16e758d58b1e2b44c203384 Mon Sep 17 00:00:00 2001 From: alesapin Date: Tue, 3 Nov 2020 13:24:51 +0300 Subject: [PATCH 44/95] Fix strange test --- tests/queries/0_stateless/01093_cyclic_defaults_filimonov.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/queries/0_stateless/01093_cyclic_defaults_filimonov.sql b/tests/queries/0_stateless/01093_cyclic_defaults_filimonov.sql index 548cd794ba3..f5f88db9d66 100644 --- a/tests/queries/0_stateless/01093_cyclic_defaults_filimonov.sql +++ b/tests/queries/0_stateless/01093_cyclic_defaults_filimonov.sql @@ -1,7 +1,7 @@ CREATE TABLE test ( - `a1` UInt64 DEFAULT a + 1, - `a1` UInt64 DEFAULT a + 1, + `a0` UInt64 DEFAULT a1 + 1, + `a1` UInt64 DEFAULT a0 + 1, `a2` UInt64 DEFAULT a3 + a4, `a3` UInt64 DEFAULT a2 + 1, `a4` UInt64 ALIAS a3 + 1 From 888440fe8f2ea474b3ff6ba145fe56e42a80bd6d Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 3 Nov 2020 13:41:56 +0300 Subject: [PATCH 45/95] Skip test in Arcadia --- tests/queries/0_stateless/arcadia_skip_list.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/queries/0_stateless/arcadia_skip_list.txt b/tests/queries/0_stateless/arcadia_skip_list.txt index f5b81c08520..eb9c65885d9 100644 --- a/tests/queries/0_stateless/arcadia_skip_list.txt +++ b/tests/queries/0_stateless/arcadia_skip_list.txt @@ -157,3 +157,4 @@ 01530_drop_database_atomic_sync 01547_query_log_current_database 01548_query_log_query_execution_ms +01552_dict_fixedstring From d95bcc8890c54b09f73b5a2aa3e03e578b745fab Mon Sep 17 00:00:00 2001 From: nikitamikhaylov Date: Mon, 2 Nov 2020 21:55:44 +0300 Subject: [PATCH 46/95] done --- src/Core/Field.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Core/Field.h b/src/Core/Field.h index 46d7713e1e4..66e4f0ac8db 100644 --- a/src/Core/Field.h +++ b/src/Core/Field.h @@ -768,8 +768,7 @@ T & Field::get() // Disregard signedness when converting between int64 types. constexpr Field::Types::Which target = TypeToEnum>::value; if (target != which - && (!isInt64FieldType(target) || !isInt64FieldType(which)) - && target != Field::Types::Decimal64 /* DateTime64 fields */) + && (!isInt64FieldType(target) || !isInt64FieldType(which))) throw Exception(ErrorCodes::LOGICAL_ERROR, "Invalid Field get from type {} to type {}", Types::toString(which), Types::toString(target)); #endif From dea4bd483ec443c449dab260c5a345fa92fcf8b5 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Tue, 3 Nov 2020 19:40:45 +0800 Subject: [PATCH 47/95] remove unused codes2 --- tests/integration/test_reload_zookeeper/test.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/integration/test_reload_zookeeper/test.py b/tests/integration/test_reload_zookeeper/test.py index ab0f3491ae9..abc640c79dc 100644 --- a/tests/integration/test_reload_zookeeper/test.py +++ b/tests/integration/test_reload_zookeeper/test.py @@ -45,8 +45,7 @@ def test_reload_zookeeper(start_cluster): node.query("INSERT INTO test_table(date, id) select today(), number FROM numbers(1000)") ## remove zoo2, zoo3 from configs - new_config = -""" + new_config = """ @@ -73,8 +72,7 @@ def test_reload_zookeeper(start_cluster): node.query("SELECT COUNT() FROM test_table") ## set config to zoo2, server will be normal - new_config = -""" + new_config = """ From a8f325ba84836a01f1d4c3610ec9150a439f15d2 Mon Sep 17 00:00:00 2001 From: Pavel Kruglov Date: Tue, 3 Nov 2020 14:41:46 +0300 Subject: [PATCH 48/95] Remove redundant check --- src/Interpreters/executeQuery.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Interpreters/executeQuery.cpp b/src/Interpreters/executeQuery.cpp index a672b58633d..5a249c15799 100644 --- a/src/Interpreters/executeQuery.cpp +++ b/src/Interpreters/executeQuery.cpp @@ -461,9 +461,6 @@ static std::tuple executeQueryImpl( QueryPipeline & pipeline = res.pipeline; bool use_processors = pipeline.initialized(); - if (res.pipeline.initialized()) - use_processors = true; - if (const auto * insert_interpreter = typeid_cast(&*interpreter)) { /// Save insertion table (not table function). TODO: support remote() table function. From bf1ea39392a09e40d6d76a079bffff3ff003894e Mon Sep 17 00:00:00 2001 From: nikitamikhaylov Date: Tue, 3 Nov 2020 16:59:17 +0300 Subject: [PATCH 49/95] fix logs --- src/Interpreters/MetricLog.h | 2 +- src/Interpreters/QueryLog.h | 4 ++-- src/Interpreters/QueryThreadLog.h | 4 ++-- src/Interpreters/TextLog.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Interpreters/MetricLog.h b/src/Interpreters/MetricLog.h index f52d078bdc9..f03b682c60a 100644 --- a/src/Interpreters/MetricLog.h +++ b/src/Interpreters/MetricLog.h @@ -18,7 +18,7 @@ namespace DB struct MetricLogElement { time_t event_time{}; - UInt64 event_time_microseconds{}; + Decimal64 event_time_microseconds{}; UInt64 milliseconds{}; std::vector profile_events; diff --git a/src/Interpreters/QueryLog.h b/src/Interpreters/QueryLog.h index 9d42b787160..4b50dc3f57e 100644 --- a/src/Interpreters/QueryLog.h +++ b/src/Interpreters/QueryLog.h @@ -30,9 +30,9 @@ struct QueryLogElement /// Depending on the type of query and type of stage, not all the fields may be filled. time_t event_time{}; - UInt64 event_time_microseconds{}; + Decimal64 event_time_microseconds{}; time_t query_start_time{}; - UInt64 query_start_time_microseconds{}; + Decimal64 query_start_time_microseconds{}; UInt64 query_duration_ms{}; /// The data fetched from DB to execute the query diff --git a/src/Interpreters/QueryThreadLog.h b/src/Interpreters/QueryThreadLog.h index 5080bfe6919..7a4aa587057 100644 --- a/src/Interpreters/QueryThreadLog.h +++ b/src/Interpreters/QueryThreadLog.h @@ -16,11 +16,11 @@ namespace DB struct QueryThreadLogElement { time_t event_time{}; - UInt64 event_time_microseconds{}; + Decimal64 event_time_microseconds{}; /// When query was attached to current thread time_t query_start_time{}; /// same as above but adds microsecond precision - UInt64 query_start_time_microseconds{}; + Decimal64 query_start_time_microseconds{}; /// Real time spent by the thread to execute the query UInt64 query_duration_ms{}; diff --git a/src/Interpreters/TextLog.h b/src/Interpreters/TextLog.h index 814b3c73044..da678868be3 100644 --- a/src/Interpreters/TextLog.h +++ b/src/Interpreters/TextLog.h @@ -9,7 +9,7 @@ using Poco::Message; struct TextLogElement { time_t event_time{}; - UInt64 event_time_microseconds{}; + Decimal64 event_time_microseconds{}; UInt32 microseconds; String thread_name; From 7c2361af456630e0dbe6dda9c99278e80ab1ddb5 Mon Sep 17 00:00:00 2001 From: nikitamikhaylov Date: Tue, 3 Nov 2020 18:19:24 +0300 Subject: [PATCH 50/95] yet another logs --- src/Interpreters/AsynchronousMetricLog.h | 2 +- src/Interpreters/TraceLog.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Interpreters/AsynchronousMetricLog.h b/src/Interpreters/AsynchronousMetricLog.h index 0c02244246e..30bac3f5a99 100644 --- a/src/Interpreters/AsynchronousMetricLog.h +++ b/src/Interpreters/AsynchronousMetricLog.h @@ -22,7 +22,7 @@ struct AsynchronousMetricLogElement { UInt16 event_date; time_t event_time; - UInt64 event_time_microseconds; + Decimal64 event_time_microseconds; std::string metric_name; double value; diff --git a/src/Interpreters/TraceLog.h b/src/Interpreters/TraceLog.h index d694a6201f7..9ee43bf32cc 100644 --- a/src/Interpreters/TraceLog.h +++ b/src/Interpreters/TraceLog.h @@ -18,7 +18,7 @@ struct TraceLogElement static const TraceDataType::Values trace_values; time_t event_time{}; - UInt64 event_time_microseconds{}; + Decimal64 event_time_microseconds{}; UInt64 timestamp_ns{}; TraceType trace_type{}; UInt64 thread_id{}; From 993af08779180820cde39fc4a80d346d5fad7110 Mon Sep 17 00:00:00 2001 From: sevirov <72220289+sevirov@users.noreply.github.com> Date: Tue, 3 Nov 2020 18:36:25 +0300 Subject: [PATCH 51/95] DOCSUP-1829: Update the system.columns table description (#16576) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update order-by.md Задокументировал параметры OFFSET и FETCH. * Update prewhere.md Поправляю битые ссылки. * Update prewhere.md Вернул изменения назад. * Update order-by.md Пытаюсь исправить битые ссылки. * Update columns.md Добавил position и compression_codec. * Translation columns.md Сделал перевод на русский язык. * Delete changes order-by.md Удалил изменения в файле order-by. Co-authored-by: Dmitriy --- docs/en/operations/system-tables/columns.md | 30 +++++++++++---------- docs/ru/operations/system-tables/columns.md | 30 +++++++++++---------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/docs/en/operations/system-tables/columns.md b/docs/en/operations/system-tables/columns.md index 4d8077ddeac..92cbdd19ca8 100644 --- a/docs/en/operations/system-tables/columns.md +++ b/docs/en/operations/system-tables/columns.md @@ -6,19 +6,21 @@ You can use this table to get information similar to the [DESCRIBE TABLE](../../ The `system.columns` table contains the following columns (the column type is shown in brackets): -- `database` (String) — Database name. -- `table` (String) — Table name. -- `name` (String) — Column name. -- `type` (String) — Column type. -- `default_kind` (String) — Expression type (`DEFAULT`, `MATERIALIZED`, `ALIAS`) for the default value, or an empty string if it is not defined. -- `default_expression` (String) — Expression for the default value, or an empty string if it is not defined. -- `data_compressed_bytes` (UInt64) — The size of compressed data, in bytes. -- `data_uncompressed_bytes` (UInt64) — The size of decompressed data, in bytes. -- `marks_bytes` (UInt64) — The size of marks, in bytes. -- `comment` (String) — Comment on the column, or an empty string if it is not defined. -- `is_in_partition_key` (UInt8) — Flag that indicates whether the column is in the partition expression. -- `is_in_sorting_key` (UInt8) — Flag that indicates whether the column is in the sorting key expression. -- `is_in_primary_key` (UInt8) — Flag that indicates whether the column is in the primary key expression. -- `is_in_sampling_key` (UInt8) — Flag that indicates whether the column is in the sampling key expression. +- `database` ([String](../../sql-reference/data-types/string.md)) — Database name. +- `table` ([String](../../sql-reference/data-types/string.md)) — Table name. +- `name` ([String](../../sql-reference/data-types/string.md)) — Column name. +- `type` ([String](../../sql-reference/data-types/string.md)) — Column type. +- `position` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Ordinal position of a column in a table starting with 1. +- `default_kind` ([String](../../sql-reference/data-types/string.md)) — Expression type (`DEFAULT`, `MATERIALIZED`, `ALIAS`) for the default value, or an empty string if it is not defined. +- `default_expression` ([String](../../sql-reference/data-types/string.md)) — Expression for the default value, or an empty string if it is not defined. +- `data_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — The size of compressed data, in bytes. +- `data_uncompressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — The size of decompressed data, in bytes. +- `marks_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — The size of marks, in bytes. +- `comment` ([String](../../sql-reference/data-types/string.md)) — Comment on the column, or an empty string if it is not defined. +- `is_in_partition_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Flag that indicates whether the column is in the partition expression. +- `is_in_sorting_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Flag that indicates whether the column is in the sorting key expression. +- `is_in_primary_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Flag that indicates whether the column is in the primary key expression. +- `is_in_sampling_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Flag that indicates whether the column is in the sampling key expression. +- `compression_codec` ([String](../../sql-reference/data-types/string.md)) — Compression codec name. [Original article](https://clickhouse.tech/docs/en/operations/system_tables/columns) diff --git a/docs/ru/operations/system-tables/columns.md b/docs/ru/operations/system-tables/columns.md index b476d6907f8..8cb9408e7d8 100644 --- a/docs/ru/operations/system-tables/columns.md +++ b/docs/ru/operations/system-tables/columns.md @@ -6,19 +6,21 @@ Таблица `system.columns` содержит столбцы (тип столбца указан в скобках): -- `database` (String) — имя базы данных. -- `table` (String) — имя таблицы. -- `name` (String) — имя столбца. -- `type` (String) — тип столбца. -- `default_kind` (String) — тип выражения (`DEFAULT`, `MATERIALIZED`, `ALIAS`) значения по умолчанию, или пустая строка. -- `default_expression` (String) — выражение для значения по умолчанию или пустая строка. -- `data_compressed_bytes` (UInt64) — размер сжатых данных в байтах. -- `data_uncompressed_bytes` (UInt64) — размер распакованных данных в байтах. -- `marks_bytes` (UInt64) — размер засечек в байтах. -- `comment` (String) — комментарий к столбцу или пустая строка. -- `is_in_partition_key` (UInt8) — флаг, показывающий включение столбца в ключ партиционирования. -- `is_in_sorting_key` (UInt8) — флаг, показывающий включение столбца в ключ сортировки. -- `is_in_primary_key` (UInt8) — флаг, показывающий включение столбца в первичный ключ. -- `is_in_sampling_key` (UInt8) — флаг, показывающий включение столбца в ключ выборки. +- `database` ([String](../../sql-reference/data-types/string.md)) — имя базы данных. +- `table` ([String](../../sql-reference/data-types/string.md)) — имя таблицы. +- `name` ([String](../../sql-reference/data-types/string.md)) — имя столбца. +- `type` ([String](../../sql-reference/data-types/string.md)) — тип столбца. +- `position` ([UInt64](../../sql-reference/data-types/int-uint.md)) — порядковый номер столбца в таблице (нумерация начинается с 1). +- `default_kind` ([String](../../sql-reference/data-types/string.md)) — тип выражения (`DEFAULT`, `MATERIALIZED`, `ALIAS`) для значения по умолчанию или пустая строка. +- `default_expression` ([String](../../sql-reference/data-types/string.md)) — выражение для значения по умолчанию или пустая строка. +- `data_compressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — размер сжатых данных в байтах. +- `data_uncompressed_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — размер распакованных данных в байтах. +- `marks_bytes` ([UInt64](../../sql-reference/data-types/int-uint.md)) — размер засечек в байтах. +- `comment` ([String](../../sql-reference/data-types/string.md)) — комментарий к столбцу или пустая строка. +- `is_in_partition_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — флаг, показывающий включение столбца в ключ партиционирования. +- `is_in_sorting_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — флаг, показывающий включение столбца в ключ сортировки. +- `is_in_primary_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — флаг, показывающий включение столбца в первичный ключ. +- `is_in_sampling_key` ([UInt8](../../sql-reference/data-types/int-uint.md)) — флаг, показывающий включение столбца в ключ выборки. +- `compression_codec` ([String](../../sql-reference/data-types/string.md)) — имя кодека сжатия. [Оригинальная статья](https://clickhouse.tech/docs/ru/operations/system_tables/columns) From 2fae1c3c315e59a1de91096dd528e4bf577fd0f0 Mon Sep 17 00:00:00 2001 From: Evgenia Sudarikova <56156889+otrazhenia@users.noreply.github.com> Date: Tue, 3 Nov 2020 18:59:21 +0300 Subject: [PATCH 52/95] DOCSUP-3171: Document the formatRowNoNewline function (#16603) * add description in English * minor changes * changes in EN and added RU version --- .../functions/type-conversion-functions.md | 38 ++++++++++++++++++ .../functions/type-conversion-functions.md | 39 +++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/docs/en/sql-reference/functions/type-conversion-functions.md b/docs/en/sql-reference/functions/type-conversion-functions.md index ba8d379ccec..e4a47e2c620 100644 --- a/docs/en/sql-reference/functions/type-conversion-functions.md +++ b/docs/en/sql-reference/functions/type-conversion-functions.md @@ -780,4 +780,42 @@ Result: └──────────────────────────────────┘ ``` +## formatRowNoNewline {#formatrownonewline} + +Converts arbitrary expressions into a string via given format. The function trims the last `\n` if any. + +**Syntax** + +``` sql +formatRowNoNewline(format, x, y, ...) +``` + +**Parameters** + +- `format` — Text format. For example, [CSV](../../interfaces/formats.md#csv), [TSV](../../interfaces/formats.md#tabseparated). +- `x`,`y`, ... — Expressions. + +**Returned value** + +- A formatted string. + +**Example** + +Query: + +``` sql +SELECT formatRowNoNewline('CSV', number, 'good') +FROM numbers(3) +``` + +Result: + +``` text +┌─formatRowNoNewline('CSV', number, 'good')─┐ +│ 0,"good" │ +│ 1,"good" │ +│ 2,"good" │ +└───────────────────────────────────────────┘ +``` + [Original article](https://clickhouse.tech/docs/en/query_language/functions/type_conversion_functions/) diff --git a/docs/ru/sql-reference/functions/type-conversion-functions.md b/docs/ru/sql-reference/functions/type-conversion-functions.md index 773850b65ce..3733e570f10 100644 --- a/docs/ru/sql-reference/functions/type-conversion-functions.md +++ b/docs/ru/sql-reference/functions/type-conversion-functions.md @@ -772,4 +772,43 @@ FROM numbers(3) │ └──────────────────────────────────┘ ``` + +## formatRowNoNewline {#formatrownonewline} + +Преобразует произвольные выражения в строку заданного формата. При этом удаляет лишние переводы строк `\n`, если они появились. + +**Синтаксис** + +``` sql +formatRowNoNewline(format, x, y, ...) +``` + +**Параметры** + +- `format` — Текстовый формат. Например, [CSV](../../interfaces/formats.md#csv), [TSV](../../interfaces/formats.md#tabseparated). +- `x`,`y`, ... — Выражения. + +**Возвращаемое значение** + +- Отформатированная строка (в текстовых форматах без завершающего перевода строки). + +**Пример** + +Запрос: + +``` sql +SELECT formatRowNoNewline('CSV', number, 'good') +FROM numbers(3) +``` + +Ответ: + +``` text +┌─formatRowNoNewline('CSV', number, 'good')─┐ +│ 0,"good" │ +│ 1,"good" │ +│ 2,"good" │ +└───────────────────────────────────────────┘ +``` + [Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/type_conversion_functions/) From a9d4c0a4f97d9f73fab83d02d4a62909001e03fc Mon Sep 17 00:00:00 2001 From: nikitamikhaylov Date: Tue, 3 Nov 2020 19:59:45 +0300 Subject: [PATCH 53/95] open telementry log --- src/Interpreters/OpenTelemetrySpanLog.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Interpreters/OpenTelemetrySpanLog.h b/src/Interpreters/OpenTelemetrySpanLog.h index fb382ee3177..271d02804f4 100644 --- a/src/Interpreters/OpenTelemetrySpanLog.h +++ b/src/Interpreters/OpenTelemetrySpanLog.h @@ -11,8 +11,8 @@ struct OpenTelemetrySpan UInt64 span_id; UInt64 parent_span_id; std::string operation_name; - UInt64 start_time_us; - UInt64 finish_time_us; + Decimal64 start_time_us; + Decimal64 finish_time_us; UInt64 duration_ns; Array attribute_names; Array attribute_values; From e7f15dff557c2d267c1aa6d4ebfb3935e23536f9 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Tue, 3 Nov 2020 21:22:46 +0300 Subject: [PATCH 54/95] Do not pass StoragePtr to ReadInOrderOptimizer::getInputOrder() Looks like this is not required anymore, since #11745 --- src/Interpreters/InterpreterSelectQuery.cpp | 2 +- src/Storages/ReadInOrderOptimizer.cpp | 21 +++------------------ src/Storages/ReadInOrderOptimizer.h | 2 +- src/Storages/StorageBuffer.cpp | 2 +- src/Storages/StorageMaterializedView.cpp | 2 +- src/Storages/StorageMerge.cpp | 2 +- 6 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/Interpreters/InterpreterSelectQuery.cpp b/src/Interpreters/InterpreterSelectQuery.cpp index d9821be4e4e..b376fc36ee9 100644 --- a/src/Interpreters/InterpreterSelectQuery.cpp +++ b/src/Interpreters/InterpreterSelectQuery.cpp @@ -1453,7 +1453,7 @@ void InterpreterSelectQuery::executeFetchColumns( getSortDescriptionFromGroupBy(query), query_info.syntax_analyzer_result); - query_info.input_order_info = query_info.order_optimizer->getInputOrder(storage, metadata_snapshot); + query_info.input_order_info = query_info.order_optimizer->getInputOrder(metadata_snapshot); } StreamLocalLimits limits; diff --git a/src/Storages/ReadInOrderOptimizer.cpp b/src/Storages/ReadInOrderOptimizer.cpp index 37f07ad1876..2bff5aee9dc 100644 --- a/src/Storages/ReadInOrderOptimizer.cpp +++ b/src/Storages/ReadInOrderOptimizer.cpp @@ -30,26 +30,11 @@ ReadInOrderOptimizer::ReadInOrderOptimizer( forbidden_columns.insert(elem.first); } -InputOrderInfoPtr ReadInOrderOptimizer::getInputOrder(const StoragePtr & storage, const StorageMetadataPtr & metadata_snapshot) const +InputOrderInfoPtr ReadInOrderOptimizer::getInputOrder(const StorageMetadataPtr & metadata_snapshot) const { - Names sorting_key_columns; - if (dynamic_cast(storage.get())) - { - if (!metadata_snapshot->hasSortingKey()) - return {}; - sorting_key_columns = metadata_snapshot->getSortingKeyColumns(); - } - else if (dynamic_cast(storage.get())) - { - if (!metadata_snapshot->hasSortingKey()) - return {}; - sorting_key_columns = metadata_snapshot->getSortingKeyColumns(); - } - else /// Inapplicable storage type - { + Names sorting_key_columns = metadata_snapshot->getSortingKeyColumns(); + if (!metadata_snapshot->hasSortingKey()) return {}; - } - SortDescription order_key_prefix_descr; int read_direction = required_sort_description.at(0).direction; diff --git a/src/Storages/ReadInOrderOptimizer.h b/src/Storages/ReadInOrderOptimizer.h index 3a16a10f89b..7a268189222 100644 --- a/src/Storages/ReadInOrderOptimizer.h +++ b/src/Storages/ReadInOrderOptimizer.h @@ -20,7 +20,7 @@ public: const SortDescription & required_sort_description, const TreeRewriterResultPtr & syntax_result); - InputOrderInfoPtr getInputOrder(const StoragePtr & storage, const StorageMetadataPtr & metadata_snapshot) const; + InputOrderInfoPtr getInputOrder(const StorageMetadataPtr & metadata_snapshot) const; private: /// Actions for every element of order expression to analyze functions for monotonicity diff --git a/src/Storages/StorageBuffer.cpp b/src/Storages/StorageBuffer.cpp index cf1eaa1f46d..9a24623d789 100644 --- a/src/Storages/StorageBuffer.cpp +++ b/src/Storages/StorageBuffer.cpp @@ -179,7 +179,7 @@ Pipe StorageBuffer::read( if (dst_has_same_structure) { if (query_info.order_optimizer) - query_info.input_order_info = query_info.order_optimizer->getInputOrder(destination, destination_metadata_snapshot); + query_info.input_order_info = query_info.order_optimizer->getInputOrder(destination_metadata_snapshot); /// The destination table has the same structure of the requested columns and we can simply read blocks from there. pipe_from_dst = destination->read( diff --git a/src/Storages/StorageMaterializedView.cpp b/src/Storages/StorageMaterializedView.cpp index 8591bebe5cc..6287e2ad278 100644 --- a/src/Storages/StorageMaterializedView.cpp +++ b/src/Storages/StorageMaterializedView.cpp @@ -120,7 +120,7 @@ Pipe StorageMaterializedView::read( auto metadata_snapshot = storage->getInMemoryMetadataPtr(); if (query_info.order_optimizer) - query_info.input_order_info = query_info.order_optimizer->getInputOrder(storage, metadata_snapshot); + query_info.input_order_info = query_info.order_optimizer->getInputOrder(metadata_snapshot); Pipe pipe = storage->read(column_names, metadata_snapshot, query_info, context, processed_stage, max_block_size, num_streams); pipe.addTableLock(lock); diff --git a/src/Storages/StorageMerge.cpp b/src/Storages/StorageMerge.cpp index 1400689b990..12588654872 100644 --- a/src/Storages/StorageMerge.cpp +++ b/src/Storages/StorageMerge.cpp @@ -211,7 +211,7 @@ Pipe StorageMerge::read( { auto storage_ptr = std::get<0>(*it); auto storage_metadata_snapshot = storage_ptr->getInMemoryMetadataPtr(); - auto current_info = query_info.order_optimizer->getInputOrder(storage_ptr, storage_metadata_snapshot); + auto current_info = query_info.order_optimizer->getInputOrder(storage_metadata_snapshot); if (it == selected_tables.begin()) input_sorting_info = current_info; else if (!current_info || (input_sorting_info && *current_info != *input_sorting_info)) From aad09fc6f47c6fe182d9cc35f4a89f5f42ceea2d Mon Sep 17 00:00:00 2001 From: George Date: Tue, 3 Nov 2020 22:53:09 +0300 Subject: [PATCH 55/95] Added reinterpretAsUUID description --- docs/en/sql-reference/functions/type-conversion-functions.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/en/sql-reference/functions/type-conversion-functions.md b/docs/en/sql-reference/functions/type-conversion-functions.md index ba8d379ccec..bcd4d9c7016 100644 --- a/docs/en/sql-reference/functions/type-conversion-functions.md +++ b/docs/en/sql-reference/functions/type-conversion-functions.md @@ -323,6 +323,10 @@ This function accepts a number or date or date with time, and returns a string c This function accepts a number or date or date with time, and returns a FixedString containing bytes representing the corresponding value in host order (little endian). Null bytes are dropped from the end. For example, a UInt32 type value of 255 is a FixedString that is one byte long. +## reinterpretAsUUID {#reinterpretasuuid} + +This function accepts FixedString, and returns UUID. Takes 16 bytes string. If the string isn't long enough, the functions work as if the string is padded with the necessary number of null bytes to the rear. If the string longer than 16 bytes, the extra bytes in the rear are ignored. + ## CAST(x, T) {#type_conversion_function-cast} Converts ‘x’ to the ‘t’ data type. The syntax CAST(x AS t) is also supported. From 5fe679324efd8c657726b3de38fc6a36a3dbe2cc Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 3 Nov 2020 23:26:55 +0300 Subject: [PATCH 56/95] Improve performance of quantileMerge #16640 --- src/AggregateFunctions/ReservoirSampler.h | 30 +++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/AggregateFunctions/ReservoirSampler.h b/src/AggregateFunctions/ReservoirSampler.h index 2ff5ab863af..594ff689aa5 100644 --- a/src/AggregateFunctions/ReservoirSampler.h +++ b/src/AggregateFunctions/ReservoirSampler.h @@ -158,12 +158,25 @@ public: } else { - randomShuffle(samples); + /// Replace every element in our reservoir to the b's reservoir + /// with the probability of b.total_values / (a.total_values + b.total_values) + /// Do it more roughly than true random sampling to save performance. + total_values += b.total_values; - for (size_t i = 0; i < sample_count; ++i) + + /// Will replace every frequency'th element in a to element from b. + double frequency = static_cast(total_values) / b.total_values; + + /// When frequency is too low, replace just one random element with the corresponding probability. + if (frequency * 2 >= sample_count) { - UInt64 rnd = genRandom(total_values); - if (rnd < b.total_values) + UInt64 rnd = genRandom(frequency); + if (rnd < sample_count) + samples[rnd] = b.samples[rnd]; + } + else + { + for (double i = 0; i < sample_count; i += frequency) samples[i] = b.samples[i]; } } @@ -222,15 +235,6 @@ private: return (static_cast(rng()) * (static_cast(rng.max()) + 1ULL) + static_cast(rng())) % lim; } - void randomShuffle(Array & v) - { - for (size_t i = 1; i < v.size(); ++i) - { - size_t j = genRandom(i + 1); - std::swap(v[i], v[j]); - } - } - void sortIfNeeded() { if (sorted) From fdd7f31cf7ef566c351410176f4fcf35181bc7e7 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 3 Nov 2020 23:28:23 +0300 Subject: [PATCH 57/95] Add a test --- tests/performance/quantile_merge.xml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/performance/quantile_merge.xml diff --git a/tests/performance/quantile_merge.xml b/tests/performance/quantile_merge.xml new file mode 100644 index 00000000000..7f4d85a254c --- /dev/null +++ b/tests/performance/quantile_merge.xml @@ -0,0 +1,3 @@ + + SELECT quantileMerge(arrayJoin(arrayMap(x -> state, range(1000000)))) FROM (SELECT quantileState(rand()) AS state FROM numbers(10000)) + From 0b1c96db51e4b0a8f6f9aff7988434b1c7eb104d Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 3 Nov 2020 23:32:18 +0300 Subject: [PATCH 58/95] Provide row number when "Cannot read all data" during parsing input --- src/Processors/Formats/IRowInputFormat.cpp | 2 ++ src/Processors/Formats/IRowInputFormat.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Processors/Formats/IRowInputFormat.cpp b/src/Processors/Formats/IRowInputFormat.cpp index 12d4db1f4a8..79df9f6956c 100644 --- a/src/Processors/Formats/IRowInputFormat.cpp +++ b/src/Processors/Formats/IRowInputFormat.cpp @@ -14,6 +14,7 @@ namespace ErrorCodes extern const int CANNOT_PARSE_DATE; extern const int CANNOT_PARSE_DATETIME; extern const int CANNOT_READ_ARRAY_FROM_TEXT; + extern const int CANNOT_READ_ALL_DATA; extern const int CANNOT_PARSE_NUMBER; extern const int CANNOT_PARSE_UUID; extern const int TOO_LARGE_STRING_SIZE; @@ -32,6 +33,7 @@ bool isParseError(int code) || code == ErrorCodes::CANNOT_READ_ARRAY_FROM_TEXT || code == ErrorCodes::CANNOT_PARSE_NUMBER || code == ErrorCodes::CANNOT_PARSE_UUID + || code == ErrorCodes::CANNOT_READ_ALL_DATA || code == ErrorCodes::TOO_LARGE_STRING_SIZE || code == ErrorCodes::ARGUMENT_OUT_OF_BOUND /// For Decimals || code == ErrorCodes::INCORRECT_DATA; /// For some ReadHelpers diff --git a/src/Processors/Formats/IRowInputFormat.h b/src/Processors/Formats/IRowInputFormat.h index 1931fba2a0d..6571359bea5 100644 --- a/src/Processors/Formats/IRowInputFormat.h +++ b/src/Processors/Formats/IRowInputFormat.h @@ -37,7 +37,7 @@ struct RowInputFormatParams bool isParseError(int code); bool checkTimeLimit(const RowInputFormatParams & params, const Stopwatch & stopwatch); -///Row oriented input format: reads data row by row. +/// Row oriented input format: reads data row by row. class IRowInputFormat : public IInputFormat { public: From 213f290c09876e58940f65653dcb401861d65cfa Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 3 Nov 2020 23:35:03 +0300 Subject: [PATCH 59/95] Add a test --- .../01554_row_number_after_cannot_read_all_data.reference | 1 + .../01554_row_number_after_cannot_read_all_data.sh | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 tests/queries/0_stateless/01554_row_number_after_cannot_read_all_data.reference create mode 100755 tests/queries/0_stateless/01554_row_number_after_cannot_read_all_data.sh diff --git a/tests/queries/0_stateless/01554_row_number_after_cannot_read_all_data.reference b/tests/queries/0_stateless/01554_row_number_after_cannot_read_all_data.reference new file mode 100644 index 00000000000..00bd5c46d6d --- /dev/null +++ b/tests/queries/0_stateless/01554_row_number_after_cannot_read_all_data.reference @@ -0,0 +1 @@ +(at row 2) diff --git a/tests/queries/0_stateless/01554_row_number_after_cannot_read_all_data.sh b/tests/queries/0_stateless/01554_row_number_after_cannot_read_all_data.sh new file mode 100755 index 00000000000..a29b44d2f16 --- /dev/null +++ b/tests/queries/0_stateless/01554_row_number_after_cannot_read_all_data.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. "$CURDIR"/../shell_config.sh + +echo -n -e '\x01\x00\x00\x00\x05Hello\x80' | ${CLICKHOUSE_LOCAL} --structure 'x UInt32, s String' --query "SELECT * FROM table" --input-format RowBinary 2>&1 | grep -oF '(at row 2)' From f5ed9adad303d94d03529587aae21913d6c69ea3 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 3 Nov 2020 23:52:57 +0300 Subject: [PATCH 60/95] Remove old code --- src/AggregateFunctions/ReservoirSampler.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/AggregateFunctions/ReservoirSampler.h b/src/AggregateFunctions/ReservoirSampler.h index 2ff5ab863af..abf41ad6581 100644 --- a/src/AggregateFunctions/ReservoirSampler.h +++ b/src/AggregateFunctions/ReservoirSampler.h @@ -200,9 +200,6 @@ public: } private: - friend void qdigest_test(int normal_size, UInt64 value_limit, const std::vector & values, int queries_count, bool verbose); - friend void rs_perf_test(); - /// We allocate a little memory on the stack - to avoid allocations when there are many objects with a small number of elements. using Array = DB::PODArrayWithStackMemory; From 3ea2047d8f2aa93e4a4543751f19e0f4cd90afea Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Wed, 4 Nov 2020 01:46:52 +0300 Subject: [PATCH 61/95] Update index.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавил описание возможности использования строкового литерала. --- docs/en/sql-reference/operators/index.md | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/en/sql-reference/operators/index.md b/docs/en/sql-reference/operators/index.md index 262ae00dc95..274f7269bc8 100644 --- a/docs/en/sql-reference/operators/index.md +++ b/docs/en/sql-reference/operators/index.md @@ -151,21 +151,43 @@ Types of intervals: - `QUARTER` - `YEAR` +You can also use a string literal when setting the `INTERVAL` value. For example, `INTERVAL 1 HOUR` is identical to the `INTERVAL '1 hour'` or `INTERVAL '1' hour`. + !!! warning "Warning" Intervals with different types can’t be combined. You can’t use expressions like `INTERVAL 4 DAY 1 HOUR`. Specify intervals in units that are smaller or equal to the smallest unit of the interval, for example, `INTERVAL 25 HOUR`. You can use consecutive operations, like in the example below. -Example: +Examples: ``` sql -SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR +SELECT now() AS current_date_time, current_date_time + INTERVAL 4 DAY + INTERVAL 3 HOUR; ``` ``` text ┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ -│ 2019-10-23 11:16:28 │ 2019-10-27 14:16:28 │ +│ 2020-11-03 22:09:50 │ 2020-11-08 01:09:50 │ └─────────────────────┴────────────────────────────────────────────────────────┘ ``` +``` sql +SELECT now() AS current_date_time, current_date_time + INTERVAL '4 day' + INTERVAL '3 hour'; +``` + +``` text +┌───current_date_time─┬─plus(plus(now(), toIntervalDay(4)), toIntervalHour(3))─┐ +│ 2020-11-03 22:12:10 │ 2020-11-08 01:12:10 │ +└─────────────────────┴────────────────────────────────────────────────────────┘ +``` + +``` sql +SELECT now() AS current_date_time, current_date_time + INTERVAL '4' day + INTERVAL '3' hour; +``` + +``` text +┌───current_date_time─┬─plus(plus(now(), toIntervalDay('4')), toIntervalHour('3'))─┐ +│ 2020-11-03 22:33:19 │ 2020-11-08 01:33:19 │ +└─────────────────────┴────────────────────────────────────────────────────────────┘ +``` + **See Also** - [Interval](../../sql-reference/data-types/special-data-types/interval.md) data type From 6c37133f2c30bac50ad9ddc95d3c2db9c48f19d4 Mon Sep 17 00:00:00 2001 From: Denny Crane Date: Tue, 3 Nov 2020 20:05:06 -0400 Subject: [PATCH 62/95] Update uuid-functions.md Russian doc for toUUIDOrNull toUUIDOrZero. --- .../sql-reference/functions/uuid-functions.md | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/docs/ru/sql-reference/functions/uuid-functions.md b/docs/ru/sql-reference/functions/uuid-functions.md index 389ce751ce0..6082fcaa712 100644 --- a/docs/ru/sql-reference/functions/uuid-functions.md +++ b/docs/ru/sql-reference/functions/uuid-functions.md @@ -59,6 +59,54 @@ SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid └──────────────────────────────────────┘ ``` +## toUUIDOrNull (x) {#touuidornull-x} + +Принимает строку, и пытается преобразовать в тип UUID. При неудаче возвращает NULL. + +``` sql +toUUIDOrNull(String) +``` + +**Возвращаемое значение** + +Значение типа Nullable(UUID). + +**Пример использования** + +``` sql +SELECT toUUIDOrNull('61f0c404-5cb3-11e7-907b-a6006ad3dba0T') AS uuid +``` + +``` text +┌─uuid─┐ +│ ᴺᵁᴸᴸ │ +└──────┘ +``` + +## toUUIDOrZero (x) {#touuidorzero-x} + +Принимает строку, и пытается преобразовать в тип UUID. При неудаче возвращает нулевой UUID. + +``` sql +toUUIDOrZero(String) +``` + +**Возвращаемое значение** + +Значение типа UUID. + +**Пример использования** + +``` sql +SELECT toUUIDOrZero('61f0c404-5cb3-11e7-907b-a6006ad3dba0T') AS uuid +``` + +``` text +┌─────────────────────────────────uuid─┐ +│ 00000000-0000-0000-0000-000000000000 │ +└──────────────────────────────────────┘ +``` + ## UUIDStringToNum {#uuidstringtonum} Принимает строку, содержащую 36 символов в формате `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`, и возвращает в виде набора байт в [FixedString(16)](../../sql-reference/functions/uuid-functions.md). From 64bd63ca4999297e041fe853c6e4b6a2fa5bd5f0 Mon Sep 17 00:00:00 2001 From: Ivan <5627721+abyss7@users.noreply.github.com> Date: Wed, 4 Nov 2020 03:08:55 +0300 Subject: [PATCH 63/95] Try to parse DataType arguments as another nested type (#16262) * Try to parse DataType arguments as another nested one * Allow mixed lists of arguments of data types * Restore croaring back * Fix tests --- src/Parsers/ParserDataType.cpp | 31 +++++++++++++++++-- ...oom_filter_index_string_multi_granulas.sql | 3 ++ .../01532_tuple_with_name_type.reference | 5 +++ .../01532_tuple_with_name_type.sql | 21 +++++++++++++ 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 tests/queries/0_stateless/01532_tuple_with_name_type.reference create mode 100644 tests/queries/0_stateless/01532_tuple_with_name_type.sql diff --git a/src/Parsers/ParserDataType.cpp b/src/Parsers/ParserDataType.cpp index a0a4eb97efe..ee746329bff 100644 --- a/src/Parsers/ParserDataType.cpp +++ b/src/Parsers/ParserDataType.cpp @@ -1,13 +1,38 @@ #include -#include -#include + #include #include +#include +#include #include + namespace DB { +namespace +{ + +/// Wrapper to allow mixed lists of nested and normal types. +class ParserNestedTableOrExpression : public IParserBase +{ + private: + const char * getName() const override { return "data type or expression"; } + bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override + { + ParserNestedTable parser1; + + if (parser1.parse(pos, node, expected)) + return true; + + ParserExpression parser2; + + return parser2.parse(pos, node, expected); + } +}; + +} + bool ParserDataType::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) { ParserNestedTable nested; @@ -78,7 +103,7 @@ bool ParserDataType::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) ++pos; /// Parse optional parameters - ParserList args_parser(std::make_unique(), std::make_unique(TokenType::Comma)); + ParserList args_parser(std::make_unique(), std::make_unique(TokenType::Comma)); ASTPtr expr_list_args; if (!args_parser.parse(pos, expr_list_args, expected)) diff --git a/tests/queries/0_stateless/01307_bloom_filter_index_string_multi_granulas.sql b/tests/queries/0_stateless/01307_bloom_filter_index_string_multi_granulas.sql index 832f7140af2..e96c70bef7f 100644 --- a/tests/queries/0_stateless/01307_bloom_filter_index_string_multi_granulas.sql +++ b/tests/queries/0_stateless/01307_bloom_filter_index_string_multi_granulas.sql @@ -1,4 +1,5 @@ DROP TABLE IF EXISTS test_01307; + CREATE TABLE test_01307 (id UInt64, val String, INDEX ind val TYPE bloom_filter() GRANULARITY 1) ENGINE = MergeTree() ORDER BY id SETTINGS index_granularity = 2; INSERT INTO test_01307 (id, val) select number as id, toString(number) as val from numbers(4); SELECT count() FROM test_01307 WHERE identity(val) = '2'; @@ -6,3 +7,5 @@ SELECT count() FROM test_01307 WHERE val = '2'; OPTIMIZE TABLE test_01307 FINAL; SELECT count() FROM test_01307 WHERE identity(val) = '2'; SELECT count() FROM test_01307 WHERE val = '2'; + +DROP TABLE test_01307; diff --git a/tests/queries/0_stateless/01532_tuple_with_name_type.reference b/tests/queries/0_stateless/01532_tuple_with_name_type.reference new file mode 100644 index 00000000000..f9f6b5995ce --- /dev/null +++ b/tests/queries/0_stateless/01532_tuple_with_name_type.reference @@ -0,0 +1,5 @@ +a Tuple(key String, value String) +a Tuple(Tuple(key String, value String)) +a.key Array(String) +a.value Array(String) +a Tuple(UInt8, Tuple(key String, value String)) diff --git a/tests/queries/0_stateless/01532_tuple_with_name_type.sql b/tests/queries/0_stateless/01532_tuple_with_name_type.sql new file mode 100644 index 00000000000..fbc052d3cc0 --- /dev/null +++ b/tests/queries/0_stateless/01532_tuple_with_name_type.sql @@ -0,0 +1,21 @@ +DROP TABLE IF EXISTS test_01532_1; +DROP TABLE IF EXISTS test_01532_2; +DROP TABLE IF EXISTS test_01532_3; +DROP TABLE IF EXISTS test_01532_4; + +CREATE TABLE test_01532_1 (a Tuple(key String, value String)) ENGINE Memory(); +DESCRIBE TABLE test_01532_1; + +CREATE TABLE test_01532_2 (a Tuple(Tuple(key String, value String))) ENGINE Memory(); +DESCRIBE TABLE test_01532_2; + +CREATE TABLE test_01532_3 (a Array(Tuple(key String, value String))) ENGINE Memory(); +DESCRIBE TABLE test_01532_3; + +CREATE TABLE test_01532_4 (a Tuple(UInt8, Tuple(key String, value String))) ENGINE Memory(); +DESCRIBE TABLE test_01532_4; + +DROP TABLE test_01532_1; +DROP TABLE test_01532_2; +DROP TABLE test_01532_3; +DROP TABLE test_01532_4; From dea3641e5c88815a9d448bcb32b2861159a9e9d5 Mon Sep 17 00:00:00 2001 From: Denny Crane Date: Tue, 3 Nov 2020 20:47:42 -0400 Subject: [PATCH 64/95] Update external-dicts-dict-layout.md --- .../external-dictionaries/external-dicts-dict-layout.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/en/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md b/docs/en/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md index ae2de0ba6f8..a49ddf62eb9 100644 --- a/docs/en/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md +++ b/docs/en/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md @@ -59,7 +59,8 @@ LAYOUT(LAYOUT_TYPE(param value)) -- layout settings - [range_hashed](#range-hashed) - [complex_key_hashed](#complex-key-hashed) - [complex_key_cache](#complex-key-cache) -- [ssd_complex_key_cache](#ssd-cache) +- [ssd_cache](#ssd-cache) +- [ssd_complex_key_cache](#complex-key-ssd-cache) - [complex_key_direct](#complex-key-direct) - [ip_trie](#ip-trie) From 52f3ef01d4a21ea23acfbd012e4a1bcf4c694b69 Mon Sep 17 00:00:00 2001 From: Denny Crane Date: Tue, 3 Nov 2020 20:55:54 -0400 Subject: [PATCH 65/95] Update external-dicts-dict-layout.md --- .../external-dicts-dict-layout.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md index 979f1f2e5b9..70a99dd6841 100644 --- a/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md +++ b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md @@ -299,6 +299,40 @@ LAYOUT(CACHE(SIZE_IN_CELLS 1000000000)) Тип размещения предназначен для использования с составными [ключами](external-dicts-dict-structure.md). Аналогичен `cache`. +### ssd_cache {#ssd-cache} + +Похож на `cache`, но хранит данные на SSD и индекс в оперативной памяти. + +``` xml + + + + 4096 + + 16777216 + + 131072 + + 1048576 + + /var/lib/clickhouse/clickhouse_dictionaries/test_dict + + 1048576 + + +``` + +или + +``` sql +LAYOUT(CACHE(BLOCK_SIZE 4096 FILE_SIZE 16777216 READ_BUFFER_SIZE 1048576 + PATH /var/lib/clickhouse/clickhouse_dictionaries/test_dict MAX_STORED_KEYS 1048576)) +``` + +### complex_key_ssd_cache {#complex-key-ssd-cache} + +Тип размещения предназначен для использования с составными [ключами](../../../sql-reference/dictionaries/external-dictionaries/external-dicts-dict-structure.md). Похож на `ssd_cache`. + ### direct {#direct} Словарь не хранит данные локально и взаимодействует с источником непосредственно в момент запроса. From e945e256bbbe124918fea28831a0c3b81b575e3d Mon Sep 17 00:00:00 2001 From: Denny Crane Date: Tue, 3 Nov 2020 20:57:14 -0400 Subject: [PATCH 66/95] Update external-dicts-dict-layout.md --- .../external-dictionaries/external-dicts-dict-layout.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md index 70a99dd6841..e97b1e421a4 100644 --- a/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md +++ b/docs/ru/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-layout.md @@ -54,6 +54,8 @@ LAYOUT(LAYOUT_TYPE(param value)) -- layout settings - [hashed](#dicts-external_dicts_dict_layout-hashed) - [sparse_hashed](#dicts-external_dicts_dict_layout-sparse_hashed) - [cache](#cache) +- [ssd_cache](#ssd-cache) +- [ssd_complex_key_cache](#complex-key-ssd-cache) - [direct](#direct) - [range_hashed](#range-hashed) - [complex_key_hashed](#complex-key-hashed) From 26b1024feaa7a48a94c9129c5300fb5a505bd2c1 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Wed, 4 Nov 2020 07:12:29 +0300 Subject: [PATCH 67/95] Fix 01339_client_unrecognized_option after UNRECOGNIZED_ARGUMENTS value change --- tests/queries/0_stateless/01339_client_unrecognized_option.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/queries/0_stateless/01339_client_unrecognized_option.sh b/tests/queries/0_stateless/01339_client_unrecognized_option.sh index 09e3a2b291f..13c286cd032 100755 --- a/tests/queries/0_stateless/01339_client_unrecognized_option.sh +++ b/tests/queries/0_stateless/01339_client_unrecognized_option.sh @@ -3,13 +3,13 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) . "$CURDIR"/../shell_config.sh -$CLICKHOUSE_CLIENT xyzgarbage 2>&1 | grep -q "Code: 2003" && echo 'OK' || echo 'FAIL' +$CLICKHOUSE_CLIENT xyzgarbage 2>&1 | grep -q "Code: 552" && echo 'OK' || echo 'FAIL' $CLICKHOUSE_CLIENT -xyzgarbage 2>&1 | grep -q "Bad arguments" && echo 'OK' || echo 'FAIL' $CLICKHOUSE_CLIENT --xyzgarbage 2>&1 | grep -q "Bad arguments" && echo 'OK' || echo 'FAIL' -cat /etc/passwd | sed 's/:/\t/g' | $CLICKHOUSE_CLIENT --query="SELECT shell, count() AS c FROM passwd GROUP BY shell ORDER BY c DESC" --external --file=- --name=passwd --structure='login String, unused String, uid UInt16, gid UInt16, comment String, home String, shell String' xyzgarbage 2>&1 | grep -q "Code: 2003" && echo 'OK' || echo 'FAIL' +cat /etc/passwd | sed 's/:/\t/g' | $CLICKHOUSE_CLIENT --query="SELECT shell, count() AS c FROM passwd GROUP BY shell ORDER BY c DESC" --external --file=- --name=passwd --structure='login String, unused String, uid UInt16, gid UInt16, comment String, home String, shell String' xyzgarbage 2>&1 | grep -q "Code: 552" && echo 'OK' || echo 'FAIL' cat /etc/passwd | sed 's/:/\t/g' | $CLICKHOUSE_CLIENT --query="SELECT shell, count() AS c FROM passwd GROUP BY shell ORDER BY c DESC" --external -xyzgarbage --file=- --name=passwd --structure='login String, unused String, uid UInt16, gid UInt16, comment String, home String, shell String' 2>&1 | grep -q "Bad arguments" && echo 'OK' || echo 'FAIL' From 130263332a865771486ecc5b6fe43ad652d51513 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 4 Nov 2020 10:52:42 +0300 Subject: [PATCH 68/95] Added results from Huawei --- website/benchmark/hardware/index.html | 1 + .../results/huawei_taishan_2280_3.json | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 website/benchmark/hardware/results/huawei_taishan_2280_3.json diff --git a/website/benchmark/hardware/index.html b/website/benchmark/hardware/index.html index 68bc4b29653..73503179bc0 100644 --- a/website/benchmark/hardware/index.html +++ b/website/benchmark/hardware/index.html @@ -53,6 +53,7 @@ Results for Xeon 2176G are from Sergey Golod.
Results for Azure DS3v2 are from Boris Granveaud.
Results for AWS are from Wolf Kreuzerkrieg.
Results for Huawei Taishan are from Peng Gao in sina.com.
+Results for Huawei Taishan (2) are from Kurmaev Roman at Huawei.
Results for Selectel and AMD EPYC 7402P are from Andrey Dudin.
Results for ProLiant are from Denis Ustinov.
Results for AMD EPYC 7502P 128GiB are from Kostiantyn Velychkovskyi.
diff --git a/website/benchmark/hardware/results/huawei_taishan_2280_3.json b/website/benchmark/hardware/results/huawei_taishan_2280_3.json new file mode 100644 index 00000000000..c31b055dbee --- /dev/null +++ b/website/benchmark/hardware/results/huawei_taishan_2280_3.json @@ -0,0 +1,54 @@ +[ + { + "system": "Huawei TaiShan (2)", + "system_full": "Huawei TaiShan 2280 (AArch64) 2280 (2x64 cores, SSD)", + "time": "2020-11-03 00:00:00", + "kind": "server", + "result": + [ + [0.001, 0.003, 0.002], + [0.009, 0.024, 0.032], + [0.023, 0.051, 0.027], + [0.035, 0.063, 0.027], + [0.103, 0.145, 0.096], + [0.121, 0.191, 0.109], + [0.009, 0.026, 0.023], + [0.014, 0.025, 0.022], + [0.209, 0.157, 0.119], + [0.254, 0.182, 0.132], + [0.153, 0.101, 0.078], + [0.151, 0.099, 0.097], + [0.289, 0.238, 0.137], + [0.342, 0.255, 0.164], + [0.302, 0.216, 0.142], + [0.291, 0.202, 0.163], + [1.269, 0.483, 0.309], + [0.457, 0.313, 0.229], + [1.376, 0.942, 0.597], + [0.073, 0.055, 0.023], + [0.555, 0.321, 0.193], + [0.913, 0.308, 0.191], + [1.713, 0.668, 0.421], + [0.894, 0.837, 0.387], + [0.238, 0.091, 0.061], + [0.153, 0.081, 0.055], + [0.174, 0.091, 0.059], + [0.933, 0.361, 0.233], + [0.793, 0.366, 0.237], + [0.682, 0.551, 0.549], + [0.321, 0.213, 0.154], + [0.593, 0.293, 0.173], + [4.436, 1.481, 1.003], + [1.544, 0.997, 0.774], + [1.981, 1.006, 0.841], + [0.539, 0.339, 0.247], + [0.194, 0.186, 0.141], + [0.075, 0.072, 0.066], + [0.072, 0.087, 0.053], + [0.393, 0.398, 0.356], + [0.032, 0.042, 0.031], + [0.023, 0.023, 0.022], + [0.005, 0.006, 0.006] + ] + } +] From 96d66a480fe2f532248ee283ae378ee1ed757920 Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Wed, 4 Nov 2020 11:18:50 +0300 Subject: [PATCH 69/95] Update type-conversion-functions.md --- docs/en/sql-reference/functions/type-conversion-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/functions/type-conversion-functions.md b/docs/en/sql-reference/functions/type-conversion-functions.md index bcd4d9c7016..4e1b7ebef02 100644 --- a/docs/en/sql-reference/functions/type-conversion-functions.md +++ b/docs/en/sql-reference/functions/type-conversion-functions.md @@ -325,7 +325,7 @@ This function accepts a number or date or date with time, and returns a FixedStr ## reinterpretAsUUID {#reinterpretasuuid} -This function accepts FixedString, and returns UUID. Takes 16 bytes string. If the string isn't long enough, the functions work as if the string is padded with the necessary number of null bytes to the rear. If the string longer than 16 bytes, the extra bytes in the rear are ignored. +This function accepts FixedString, and returns UUID. Takes 16 bytes string. If the string isn't long enough, the functions work as if the string is padded with the necessary number of null bytes to the end. If the string longer than 16 bytes, the extra bytes in the end are ignored. ## CAST(x, T) {#type_conversion_function-cast} From 788418b447c5b4de28bad4de397d0de77c89f781 Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Wed, 4 Nov 2020 11:19:17 +0300 Subject: [PATCH 70/95] Update type-conversion-functions.md --- docs/en/sql-reference/functions/type-conversion-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/functions/type-conversion-functions.md b/docs/en/sql-reference/functions/type-conversion-functions.md index 4e1b7ebef02..5c8dc5fd272 100644 --- a/docs/en/sql-reference/functions/type-conversion-functions.md +++ b/docs/en/sql-reference/functions/type-conversion-functions.md @@ -325,7 +325,7 @@ This function accepts a number or date or date with time, and returns a FixedStr ## reinterpretAsUUID {#reinterpretasuuid} -This function accepts FixedString, and returns UUID. Takes 16 bytes string. If the string isn't long enough, the functions work as if the string is padded with the necessary number of null bytes to the end. If the string longer than 16 bytes, the extra bytes in the end are ignored. +This function accepts FixedString, and returns UUID. Takes 16 bytes string. If the string isn't long enough, the functions work as if the string is padded with the necessary number of null bytes to the end. If the string longer than 16 bytes, the extra bytes at the end are ignored. ## CAST(x, T) {#type_conversion_function-cast} From 0001fc244ddf3e083c5f77e94ce6a7c1bd6f281d Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Wed, 4 Nov 2020 11:24:40 +0300 Subject: [PATCH 71/95] Update settings.md --- .../server-configuration-parameters/settings.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/en/operations/server-configuration-parameters/settings.md b/docs/en/operations/server-configuration-parameters/settings.md index dbece2d0cee..31a8e896438 100644 --- a/docs/en/operations/server-configuration-parameters/settings.md +++ b/docs/en/operations/server-configuration-parameters/settings.md @@ -481,9 +481,13 @@ The maximum number of simultaneously processed requests. ## max_concurrent_queries_for_all_users {#max-concurrent-queries-for-all-users} -The maximum number of simultaneously processed requests for all users. +Throw exception if the value of this setting is less or equal than the current number of simultaneously processed queries. -Default value: `0`. +Example: `max_concurrent_queries_for_all_users` can be set to 99 for all users and database administrator can set it to 100 for itself to run queries for investigation even when the server is overloaded. + +Modifying the setting for one query or user does not affect other queries. + +Default value: `0` that means no limit. **Example** @@ -491,8 +495,6 @@ Default value: `0`. 99 ``` -`max_concurrent_queries_for_all_users` can be set to 99 for all users and database administrator can set it to 100 for itself to run queries for investigation even when the server is overloaded. - **See Also** - [max_concurrent_queries](#max-concurrent-queries) From 74ebe952d1c712dcaa7cc1cab474a009e27e4672 Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Wed, 4 Nov 2020 11:32:20 +0300 Subject: [PATCH 72/95] Update Context.cpp --- src/Interpreters/Context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index be701ff171b..20b976b71dc 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -363,7 +363,7 @@ struct ContextShared /// Initialized on demand (on distributed storages initialization) since Settings should be initialized std::unique_ptr clusters; ConfigurationPtr clusters_config; /// Stores updated configs - ConfigurationPtr zookeeper_config; /// Stores zookeeperd configs + ConfigurationPtr zookeeper_config; /// Stores zookeeper configs mutable std::mutex clusters_mutex; /// Guards clusters and clusters_config #if USE_EMBEDDED_COMPILER From c82d8dde3dad814db62b52d727e3732e62e2b2bf Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Wed, 4 Nov 2020 12:11:43 +0300 Subject: [PATCH 73/95] Fix inconsistent whitespace. --- src/Interpreters/ApplyWithSubqueryVisitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Interpreters/ApplyWithSubqueryVisitor.cpp b/src/Interpreters/ApplyWithSubqueryVisitor.cpp index d8ddbd2c2fa..c360a9683c3 100644 --- a/src/Interpreters/ApplyWithSubqueryVisitor.cpp +++ b/src/Interpreters/ApplyWithSubqueryVisitor.cpp @@ -18,7 +18,7 @@ void ApplyWithSubqueryVisitor::visit(ASTPtr & ast, const Data & data) { for (auto & child : with->children) { - visit(child, new_data ? *new_data: data); + visit(child, new_data ? *new_data : data); if (auto * ast_with_elem = child->as()) { if (!new_data) From cf61c29a03bb4ae7d29c0e7d4524be6f99695057 Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Wed, 4 Nov 2020 12:17:53 +0300 Subject: [PATCH 74/95] Update docs/en/sql-reference/table-functions/null.md Co-authored-by: BayoNet --- docs/en/sql-reference/table-functions/null.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/sql-reference/table-functions/null.md b/docs/en/sql-reference/table-functions/null.md index 988ba18d709..cc0fd8f9427 100644 --- a/docs/en/sql-reference/table-functions/null.md +++ b/docs/en/sql-reference/table-functions/null.md @@ -5,7 +5,7 @@ toc_title: null function # null {#null-function} -Accepts an inserted data of the specified structure and immediately drops it away. The function is used for convenience writing tests and demos. +Accepts an inserted data of the specified structure and immediately drops it away. The function is used for convenience writing tests and demonstrations. **Syntax** From 1f323e98d1bca559bbab974cb084b8bae7737552 Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Wed, 4 Nov 2020 12:20:06 +0300 Subject: [PATCH 75/95] Update null.md --- docs/en/sql-reference/table-functions/null.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/sql-reference/table-functions/null.md b/docs/en/sql-reference/table-functions/null.md index cc0fd8f9427..6edec61add7 100644 --- a/docs/en/sql-reference/table-functions/null.md +++ b/docs/en/sql-reference/table-functions/null.md @@ -36,4 +36,6 @@ INSERT INTO t SELECT * FROM numbers_mt(1000000000); DROP TABLE IF EXISTS t; ``` +See also: format **Null**. + [Original article](https://clickhouse.tech/docs/en/sql-reference/table-functions/null/) From 4dccc51332bb6361a7fe6d7df5a97ddb66f3bf9f Mon Sep 17 00:00:00 2001 From: hcz Date: Wed, 4 Nov 2020 18:21:59 +0800 Subject: [PATCH 76/95] Fix typo --- src/Core/Settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Settings.h b/src/Core/Settings.h index 29052f7ba84..4d4712dcba7 100644 --- a/src/Core/Settings.h +++ b/src/Core/Settings.h @@ -109,7 +109,7 @@ class IColumn; \ M(UInt64, parallel_distributed_insert_select, 0, "Process distributed INSERT SELECT query in the same cluster on local tables on every shard, if 1 SELECT is executed on each shard, if 2 SELECT and INSERT is executed on each shard", 0) \ M(UInt64, distributed_group_by_no_merge, 0, "If 1, Do not merge aggregation states from different servers for distributed query processing - in case it is for certain that there are different keys on different shards. If 2 - same as 1 but also apply ORDER BY and LIMIT stages", 0) \ - M(Bool, optimize_distributed_group_by_sharding_key, false, "Optimize GROUP BY sharding_key queries (by avodiing costly aggregation on the initiator server).", 0) \ + M(Bool, optimize_distributed_group_by_sharding_key, false, "Optimize GROUP BY sharding_key queries (by avoiding costly aggregation on the initiator server).", 0) \ M(Bool, optimize_skip_unused_shards, false, "Assumes that data is distributed by sharding_key. Optimization to skip unused shards if SELECT query filters by sharding_key.", 0) \ M(Bool, allow_nondeterministic_optimize_skip_unused_shards, false, "Allow non-deterministic functions (includes dictGet) in sharding_key for optimize_skip_unused_shards", 0) \ M(UInt64, force_optimize_skip_unused_shards, 0, "Throw an exception if unused shards cannot be skipped (1 - throw only if the table has the sharding key, 2 - always throw.", 0) \ From 85f81f9d9e64d7456f264f95a84371ca3d04d2da Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 4 Nov 2020 13:38:04 +0300 Subject: [PATCH 77/95] Minor modification: less templates --- .../AggregateFunctionOrFill.cpp | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/AggregateFunctions/AggregateFunctionOrFill.cpp b/src/AggregateFunctions/AggregateFunctionOrFill.cpp index af107e26ca9..959836c0e49 100644 --- a/src/AggregateFunctions/AggregateFunctionOrFill.cpp +++ b/src/AggregateFunctions/AggregateFunctionOrFill.cpp @@ -9,16 +9,23 @@ namespace DB namespace { -template +enum class Kind +{ + OrNull, + OrDefault +}; + class AggregateFunctionCombinatorOrFill final : public IAggregateFunctionCombinator { +private: + Kind kind; + public: + AggregateFunctionCombinatorOrFill(Kind kind_) : kind(kind_) {} + String getName() const override { - if constexpr (UseNull) - return "OrNull"; - else - return "OrDefault"; + return kind == Kind::OrNull ? "OrNull" : "OrDefault"; } AggregateFunctionPtr transformAggregateFunction( @@ -27,10 +34,10 @@ public: const DataTypes & arguments, const Array & params) const override { - return std::make_shared>( - nested_function, - arguments, - params); + if (kind == Kind::OrNull) + return std::make_shared>(nested_function, arguments, params); + else + return std::make_shared>(nested_function, arguments, params); } }; @@ -38,8 +45,8 @@ public: void registerAggregateFunctionCombinatorOrFill(AggregateFunctionCombinatorFactory & factory) { - factory.registerCombinator(std::make_shared>()); - factory.registerCombinator(std::make_shared>()); + factory.registerCombinator(std::make_shared(Kind::OrNull)); + factory.registerCombinator(std::make_shared(Kind::OrDefault)); } } From 155c11d29c793d311bb10f278d47ba71c1ef9eb6 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 4 Nov 2020 13:53:10 +0300 Subject: [PATCH 78/95] Optimize -OrNull and -OrDefault aggregate functions by providing specializations #16123 --- .../AggregateFunctionOrFill.h | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/AggregateFunctions/AggregateFunctionOrFill.h b/src/AggregateFunctions/AggregateFunctionOrFill.h index 333f07d5e33..58b2cebb9e4 100644 --- a/src/AggregateFunctions/AggregateFunctionOrFill.h +++ b/src/AggregateFunctions/AggregateFunctionOrFill.h @@ -78,7 +78,6 @@ public: void create(AggregateDataPtr place) const override { nested_function->create(place); - place[size_of_data] = 0; } @@ -94,10 +93,36 @@ public: Arena * arena) const override { nested_function->add(place, columns, row_num, arena); - place[size_of_data] = 1; } + void addBatch(size_t batch_size, AggregateDataPtr * places, size_t place_offset, const IColumn ** columns, Arena * arena) const override + { + nested_function->addBatch(batch_size, places, place_offset, columns, arena); + for (size_t i = 0; i < batch_size; ++i) + (places[i] + place_offset)[size_of_data] = 1; + } + + void addBatchSinglePlace(size_t batch_size, AggregateDataPtr place, const IColumn ** columns, Arena * arena) const override + { + nested_function->addBatchSinglePlace(batch_size, place, columns, arena); + place[size_of_data] = 1; + } + + void addBatchSinglePlaceNotNull( + size_t batch_size, AggregateDataPtr place, const IColumn ** columns, const UInt8 * null_map, Arena * arena) const override + { + nested_function->addBatchSinglePlaceNotNull(batch_size, place, columns, null_map, arena); + for (size_t i = 0; i < batch_size; ++i) + { + if (!null_map[i]) + { + place[size_of_data] = 1; + break; + } + } + } + void merge( AggregateDataPtr place, ConstAggregateDataPtr rhs, From 938ef62532776ecc8d6449a064d1d5d4d1446152 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 4 Nov 2020 14:00:43 +0300 Subject: [PATCH 79/95] Add a test --- tests/performance/or_null_default.xml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tests/performance/or_null_default.xml diff --git a/tests/performance/or_null_default.xml b/tests/performance/or_null_default.xml new file mode 100644 index 00000000000..009719f66a5 --- /dev/null +++ b/tests/performance/or_null_default.xml @@ -0,0 +1,5 @@ + + SELECT sumOrNull(number) FROM numbers(100000000) + SELECT sumOrDefault(toNullable(number)) FROM numbers(100000000) + SELECT sumOrNull(number) FROM numbers(10000000) GROUP BY number % 1024 + From c7618ea99e84d70362d9f400e81660191a9fe8fe Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 4 Nov 2020 14:02:12 +0300 Subject: [PATCH 80/95] Remove obsolete code from JOIN --- src/Interpreters/TableJoin.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Interpreters/TableJoin.cpp b/src/Interpreters/TableJoin.cpp index cd837cc15d6..5db914bc457 100644 --- a/src/Interpreters/TableJoin.cpp +++ b/src/Interpreters/TableJoin.cpp @@ -28,8 +28,6 @@ TableJoin::TableJoin(const Settings & settings, VolumePtr tmp_volume_) , temporary_files_codec(settings.temporary_files_codec) , tmp_volume(tmp_volume_) { - if (settings.partial_merge_join) - join_algorithm = JoinAlgorithm::PREFER_PARTIAL_MERGE; } void TableJoin::resetCollected() From c7facedf10d720989d22379ce19cc6d7d00ac4e9 Mon Sep 17 00:00:00 2001 From: filimonov <1549571+filimonov@users.noreply.github.com> Date: Wed, 4 Nov 2020 12:02:30 +0100 Subject: [PATCH 81/95] Update clickhouse-copier.md --- docs/en/operations/utilities/clickhouse-copier.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/en/operations/utilities/clickhouse-copier.md b/docs/en/operations/utilities/clickhouse-copier.md index d450f5753e4..ec5a619b86b 100644 --- a/docs/en/operations/utilities/clickhouse-copier.md +++ b/docs/en/operations/utilities/clickhouse-copier.md @@ -7,6 +7,9 @@ toc_title: clickhouse-copier Copies data from the tables in one cluster to tables in another (or the same) cluster. +!!! warning "Warning" + To get a consistent copy, the data in the source tables and partitions should not change during the entire process. + You can run multiple `clickhouse-copier` instances on different servers to perform the same job. ZooKeeper is used for syncing the processes. After starting, `clickhouse-copier`: From c848deed1e123040c1f605cf8eb162cdf7c17e20 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 4 Nov 2020 14:07:54 +0300 Subject: [PATCH 82/95] Fix test --- .../AggregateFunctionOrFill.h | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/AggregateFunctions/AggregateFunctionOrFill.h b/src/AggregateFunctions/AggregateFunctionOrFill.h index 58b2cebb9e4..456c0e22305 100644 --- a/src/AggregateFunctions/AggregateFunctionOrFill.h +++ b/src/AggregateFunctions/AggregateFunctionOrFill.h @@ -105,20 +105,26 @@ public: void addBatchSinglePlace(size_t batch_size, AggregateDataPtr place, const IColumn ** columns, Arena * arena) const override { - nested_function->addBatchSinglePlace(batch_size, place, columns, arena); - place[size_of_data] = 1; + if (batch_size) + { + nested_function->addBatchSinglePlace(batch_size, place, columns, arena); + place[size_of_data] = 1; + } } void addBatchSinglePlaceNotNull( size_t batch_size, AggregateDataPtr place, const IColumn ** columns, const UInt8 * null_map, Arena * arena) const override { - nested_function->addBatchSinglePlaceNotNull(batch_size, place, columns, null_map, arena); - for (size_t i = 0; i < batch_size; ++i) + if (batch_size) { - if (!null_map[i]) + nested_function->addBatchSinglePlaceNotNull(batch_size, place, columns, null_map, arena); + for (size_t i = 0; i < batch_size; ++i) { - place[size_of_data] = 1; - break; + if (!null_map[i]) + { + place[size_of_data] = 1; + break; + } } } } @@ -129,7 +135,6 @@ public: Arena * arena) const override { nested_function->merge(place, rhs, arena); - place[size_of_data] |= rhs[size_of_data]; } From 3993636d8db09c22d52cac76801db6a47e6e38b3 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 4 Nov 2020 14:09:20 +0300 Subject: [PATCH 83/95] Add a test --- .../0_stateless/01555_or_fill.reference | 2 ++ tests/queries/0_stateless/01555_or_fill.sql | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/queries/0_stateless/01555_or_fill.reference create mode 100644 tests/queries/0_stateless/01555_or_fill.sql diff --git a/tests/queries/0_stateless/01555_or_fill.reference b/tests/queries/0_stateless/01555_or_fill.reference new file mode 100644 index 00000000000..6a204045944 --- /dev/null +++ b/tests/queries/0_stateless/01555_or_fill.reference @@ -0,0 +1,2 @@ +0 \N 0 \N +0 \N 0 \N diff --git a/tests/queries/0_stateless/01555_or_fill.sql b/tests/queries/0_stateless/01555_or_fill.sql new file mode 100644 index 00000000000..a2da07d0a7c --- /dev/null +++ b/tests/queries/0_stateless/01555_or_fill.sql @@ -0,0 +1,22 @@ +SELECT + count(), + countOrNull(), + sum(x), + sumOrNull(x) +FROM +( + SELECT number AS x + FROM numbers(10) + WHERE number > 10 +); + +SELECT + count(), + countOrNull(), + sum(x), + sumOrNull(x) +FROM +( + SELECT 1 AS x + WHERE 0 +); From e0d962a3cfb6404432abda4f579820708e96db11 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 4 Nov 2020 14:22:02 +0300 Subject: [PATCH 84/95] Add a test for #8772 --- tests/performance/group_by_sundy_li.xml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/performance/group_by_sundy_li.xml diff --git a/tests/performance/group_by_sundy_li.xml b/tests/performance/group_by_sundy_li.xml new file mode 100644 index 00000000000..4c9e397520a --- /dev/null +++ b/tests/performance/group_by_sundy_li.xml @@ -0,0 +1,25 @@ + + +CREATE TABLE a +( + d Date, + os String +) +ENGINE = MergeTree +PARTITION BY d +ORDER BY d + + + insert into a select '2000-01-01', ['aa','bb','cc','dd'][number % 4 + 1] from numbers(100000000) + insert into a select '2000-01-02', ['aa','bb','cc','dd'][number % 4 + 1] from numbers(100000000) + insert into a select '2000-01-03', ['aa','bb','cc','dd'][number % 4 + 1] from numbers(100000000) + insert into a select '2000-01-04', ['aa','bb','cc','dd'][number % 4 + 1] from numbers(100000000) + + OPTIMIZE TABLE a FINAL + + select d, count() from a group by d + select os, count() from a group by os + select d, os, count() from a group by d, os + + drop table if exists a + From 7986dbdfc7a6b57e9924171b46ca9899beb2ad8c Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Wed, 4 Nov 2020 14:32:55 +0300 Subject: [PATCH 85/95] Update ontime.md --- docs/en/getting-started/example-datasets/ontime.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/getting-started/example-datasets/ontime.md b/docs/en/getting-started/example-datasets/ontime.md index c2c8d5d930e..6f2408af3b6 100644 --- a/docs/en/getting-started/example-datasets/ontime.md +++ b/docs/en/getting-started/example-datasets/ontime.md @@ -148,7 +148,7 @@ SETTINGS index_granularity = 8192; Loading data: ``` bash -$ for i in *.zip; do echo $i; unzip -cq $i '*.csv' | sed 's/\.00//g' | clickhouse-client --host=example-perftest01j --query="INSERT INTO ontime FORMAT CSVWithNames"; done +$ for i in *.zip; do echo $i; unzip -cq $i '*.csv' | sed 's/\.00//g' | clickhouse-client --input_format_with_names_use_header=0 --host=example-perftest01j --query="INSERT INTO ontime FORMAT CSVWithNames"; done ``` ## Download of Prepared Partitions {#download-of-prepared-partitions} From eedf4439bbefe4ebdaa4233f25ff702090039ee9 Mon Sep 17 00:00:00 2001 From: Denis Zhuravlev Date: Wed, 4 Nov 2020 10:16:49 -0400 Subject: [PATCH 86/95] more tests for CTE #16575 --- ...5_subqueries_in_with_statement_2.reference | 26 ++++++ .../01495_subqueries_in_with_statement_2.sql | 49 +++++++++++ ...5_subqueries_in_with_statement_3.reference | 8 ++ .../01495_subqueries_in_with_statement_3.sql | 82 +++++++++++++++++++ 4 files changed, 165 insertions(+) create mode 100644 tests/queries/0_stateless/01495_subqueries_in_with_statement_2.reference create mode 100644 tests/queries/0_stateless/01495_subqueries_in_with_statement_2.sql create mode 100644 tests/queries/0_stateless/01495_subqueries_in_with_statement_3.reference create mode 100644 tests/queries/0_stateless/01495_subqueries_in_with_statement_3.sql diff --git a/tests/queries/0_stateless/01495_subqueries_in_with_statement_2.reference b/tests/queries/0_stateless/01495_subqueries_in_with_statement_2.reference new file mode 100644 index 00000000000..d8eaf6f67b6 --- /dev/null +++ b/tests/queries/0_stateless/01495_subqueries_in_with_statement_2.reference @@ -0,0 +1,26 @@ +0 +1 +2 +3 +4 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 +1 +2 +3 +4 +1 +1 +3 +3 +1 +3 diff --git a/tests/queries/0_stateless/01495_subqueries_in_with_statement_2.sql b/tests/queries/0_stateless/01495_subqueries_in_with_statement_2.sql new file mode 100644 index 00000000000..7ec4eeaa778 --- /dev/null +++ b/tests/queries/0_stateless/01495_subqueries_in_with_statement_2.sql @@ -0,0 +1,49 @@ + +WITH +x AS (SELECT number AS a FROM numbers(10)), +y AS (SELECT number AS a FROM numbers(5)) +SELECT * FROM x WHERE a in (SELECT a FROM y) +ORDER BY a; + +WITH +x AS (SELECT number AS a FROM numbers(10)), +y AS (SELECT number AS a FROM numbers(5)) +SELECT * FROM x left JOIN y USING a +ORDER BY a; + +WITH +x AS (SELECT number AS a FROM numbers(10)), +y AS (SELECT number AS a FROM numbers(5)) +SELECT * FROM x JOIN y USING a +ORDER BY x.a; + +WITH +x AS (SELECT number AS a FROM numbers(10)), +y AS (SELECT number AS a FROM numbers(5)), +z AS (SELECT toUInt64(1) b) +SELECT * FROM x JOIN y USING a WHERE a in (SELECT * FROM z); + +WITH +x AS (SELECT number AS a FROM numbers(10)), +y AS (SELECT number AS a FROM numbers(5)), +z AS (SELECT * FROM x WHERE a % 2), +w AS (SELECT * FROM y WHERE a > 0) +SELECT * FROM x JOIN y USING a WHERE a in (SELECT * FROM z) +ORDER BY x.a; + +WITH +x AS (SELECT number AS a FROM numbers(10)), +y AS (SELECT number AS a FROM numbers(5)), +z AS (SELECT * FROM x WHERE a % 2), +w AS (SELECT * FROM y WHERE a > 0) +SELECT max(a) FROM x JOIN y USING a WHERE a in (SELECT * FROM z) +HAVING a > (SELECT min(a) FROM w); + +WITH +x AS (SELECT number AS a FROM numbers(10)), +y AS (SELECT number AS a FROM numbers(5)), +z AS (SELECT * FROM x WHERE a % 2), +w AS (SELECT * FROM y WHERE a > 0) +SELECT a FROM x JOIN y USING a WHERE a in (SELECT * FROM z) +HAVING a <= (SELECT max(a) FROM w) +ORDER BY x.a; diff --git a/tests/queries/0_stateless/01495_subqueries_in_with_statement_3.reference b/tests/queries/0_stateless/01495_subqueries_in_with_statement_3.reference new file mode 100644 index 00000000000..7cc310d9662 --- /dev/null +++ b/tests/queries/0_stateless/01495_subqueries_in_with_statement_3.reference @@ -0,0 +1,8 @@ +4999 +333 +3333 +2000 +97 1 33 +99 -3299 3399 +99 0 100 +99 -3299 3399 diff --git a/tests/queries/0_stateless/01495_subqueries_in_with_statement_3.sql b/tests/queries/0_stateless/01495_subqueries_in_with_statement_3.sql new file mode 100644 index 00000000000..36cba596d00 --- /dev/null +++ b/tests/queries/0_stateless/01495_subqueries_in_with_statement_3.sql @@ -0,0 +1,82 @@ +DROP TABLE IF EXISTS cte1; +DROP TABLE IF EXISTS cte2; + +CREATE TABLE cte1(a Int64) ENGINE=Memory; +CREATE TABLE cte2(a Int64) ENGINE=Memory; + +INSERT INTO cte1 SELECT * FROM numbers(10000); +INSERT INTO cte2 SELECT * FROM numbers(5000); + +WITH +x AS (SELECT * FROM cte1), +y AS (SELECT * FROM cte2), +z AS (SELECT * FROM x WHERE a % 2 = 1), +w AS (SELECT * FROM y WHERE a > 333) +SELECT max(a) +FROM x JOIN y USING (a) +WHERE a in (SELECT * FROM z) AND a <= (SELECT max(a) FROM w); + +WITH +x AS (SELECT * FROM cte1), +y AS (SELECT * FROM cte2), +z AS (SELECT * FROM x WHERE a % 3 = 1), +w AS (SELECT * FROM y WHERE a > 333 AND a < 1000) +SELECT count(a) +FROM x left JOIN y USING (a) +WHERE a in (SELECT * FROM z) AND a <= (SELECT max(a) FROM w); + +WITH +x AS (SELECT * FROM cte1), +y AS (SELECT * FROM cte2), +z AS (SELECT * FROM x WHERE a % 3 = 1), +w AS (SELECT * FROM y WHERE a > 333 AND a < 1000) +SELECT count(a) +FROM x left JOIN y USING (a) +WHERE a in (SELECT * FROM z); + +WITH +x AS (SELECT a-4000 a FROM cte1 WHERE cte1.a >700), +y AS (SELECT * FROM cte2), +z AS (SELECT * FROM x WHERE a % 3 = 1), +w AS (SELECT * FROM y WHERE a > 333 AND a < 1000) +SELECT count(*) +FROM x left JOIN y USING (a) +WHERE a in (SELECT * FROM z); + +WITH +x AS (SELECT a-4000 a FROM cte1 WHERE cte1.a >700), +y AS (SELECT * FROM cte2), +z AS (SELECT * FROM x WHERE a % 3 = 1), +w AS (SELECT * FROM y WHERE a > 333 AND a < 1000) +SELECT max(a), min(a), count(*) +FROM x +WHERE a in (SELECT * FROM z) AND a <100; + +WITH +x AS (SELECT a-4000 a FROM cte1 WHERE cte1.a >700), +y AS (SELECT * FROM cte2), +z AS (SELECT * FROM x WHERE a % 3 = 1), +w AS (SELECT * FROM y WHERE a > 333 AND a < 1000) +SELECT max(a), min(a), count(*) FROM x +WHERE a <100; + +WITH +x AS (SELECT a-4000 a FROM cte1 AS t WHERE cte1.a >700), +y AS (SELECT * FROM cte2), +z AS (SELECT * FROM x WHERE a % 3 = 1), +w AS (SELECT * FROM y WHERE a > 333 AND a < 1000) +SELECT max(a), min(a), count(*) +FROM y +WHERE a <100; + +WITH +x AS (SELECT a-4000 a FROM cte1 t WHERE t.a >700), +y AS (SELECT x.a a FROM x left JOIN cte1 USING (a)), +z AS (SELECT * FROM x WHERE a % 3 = 1), +w AS (SELECT * FROM y WHERE a > 333 AND a < 1000) +SELECT max(a), min(a), count(*) +FROM y +WHERE a <100; + +DROP TABLE cte1; +DROP TABLE cte2; From 5b9d48c71555c33b5383bebd866c2e9f4a0a11a5 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 4 Nov 2020 17:39:18 +0300 Subject: [PATCH 87/95] Remove garbage from docs --- docker/test/stress/README.md | 5 +- docker/test/stress/stress | 2 - docs/es/development/tests.md | 262 +--------------------------------- docs/fa/development/tests.md | 263 +---------------------------------- docs/fr/development/tests.md | 262 +--------------------------------- docs/ja/development/tests.md | 262 +--------------------------------- docs/tr/development/tests.md | 263 +---------------------------------- docs/zh/development/tests.md | 237 ------------------------------- 8 files changed, 7 insertions(+), 1549 deletions(-) mode change 100644 => 120000 docs/es/development/tests.md mode change 100644 => 120000 docs/fa/development/tests.md mode change 100644 => 120000 docs/fr/development/tests.md mode change 100644 => 120000 docs/ja/development/tests.md mode change 100644 => 120000 docs/tr/development/tests.md delete mode 100644 docs/zh/development/tests.md diff --git a/docker/test/stress/README.md b/docker/test/stress/README.md index c9b6da37b05..f747996fa2d 100644 --- a/docker/test/stress/README.md +++ b/docker/test/stress/README.md @@ -1,7 +1,6 @@ Allow to run simple ClickHouse stress test in Docker from debian packages. -Actually it runs single copy of clickhouse-performance-test and multiple copies -of clickhouse-test (functional tests). This allows to find problems like -segmentation fault which cause shutdown of server. +Actually it runs multiple copies of clickhouse-test (functional tests). +This allows to find problems like segmentation fault which cause shutdown of server. Usage: ``` diff --git a/docker/test/stress/stress b/docker/test/stress/stress index f29ebc55141..874dca751f3 100755 --- a/docker/test/stress/stress +++ b/docker/test/stress/stress @@ -68,8 +68,6 @@ if __name__ == "__main__": parser.add_argument("--test-cmd", default='/usr/bin/clickhouse-test') parser.add_argument("--skip-func-tests", default='') parser.add_argument("--client-cmd", default='clickhouse-client') - parser.add_argument("--perf-test-cmd", default='clickhouse-performance-test') - parser.add_argument("--perf-test-xml-path", default='/usr/share/clickhouse-test/performance/') parser.add_argument("--server-log-folder", default='/var/log/clickhouse-server') parser.add_argument("--output-folder") parser.add_argument("--global-time-limit", type=int, default=3600) diff --git a/docs/es/development/tests.md b/docs/es/development/tests.md deleted file mode 100644 index ae2b61b6ba7..00000000000 --- a/docs/es/development/tests.md +++ /dev/null @@ -1,261 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd -toc_priority: 69 -toc_title: "C\xF3mo ejecutar pruebas de ClickHouse" ---- - -# Pruebas de ClickHouse {#clickhouse-testing} - -## Pruebas funcionales {#functional-tests} - -Las pruebas funcionales son las más simples y cómodas de usar. La mayoría de las características de ClickHouse se pueden probar con pruebas funcionales y son obligatorias para cada cambio en el código de ClickHouse que se puede probar de esa manera. - -Cada prueba funcional envía una o varias consultas al servidor ClickHouse en ejecución y compara el resultado con la referencia. - -Las pruebas se encuentran en `queries` directorio. Hay dos subdirectorios: `stateless` y `stateful`. Las pruebas sin estado ejecutan consultas sin datos de prueba precargados: a menudo crean pequeños conjuntos de datos sintéticos sobre la marcha, dentro de la prueba misma. Las pruebas estatales requieren datos de prueba precargados de Yandex.Métrica y no está disponible para el público en general. Tendemos a usar sólo `stateless` pruebas y evitar la adición de nuevos `stateful` prueba. - -Cada prueba puede ser de dos tipos: `.sql` y `.sh`. `.sql` test es el script SQL simple que se canaliza a `clickhouse-client --multiquery --testmode`. `.sh` test es un script que se ejecuta por sí mismo. - -Para ejecutar todas las pruebas, use `clickhouse-test` herramienta. Mira `--help` para la lista de posibles opciones. Simplemente puede ejecutar todas las pruebas o ejecutar un subconjunto de pruebas filtradas por subcadena en el nombre de la prueba: `./clickhouse-test substring`. - -La forma más sencilla de invocar pruebas funcionales es copiar `clickhouse-client` a `/usr/bin/`, ejecutar `clickhouse-server` y luego ejecutar `./clickhouse-test` de su propio directorio. - -Para agregar una nueva prueba, cree un `.sql` o `.sh` archivo en `queries/0_stateless` directorio, compruébelo manualmente y luego genere `.reference` archivo de la siguiente manera: `clickhouse-client -n --testmode < 00000_test.sql > 00000_test.reference` o `./00000_test.sh > ./00000_test.reference`. - -Las pruebas deben usar (crear, soltar, etc.) solo tablas en `test` base de datos que se supone que se crea de antemano; también las pruebas pueden usar tablas temporales. - -Si desea utilizar consultas distribuidas en pruebas funcionales, puede aprovechar `remote` función de la tabla con `127.0.0.{1..2}` direcciones para que el servidor se consulte; o puede usar clústeres de prueba predefinidos en el archivo de configuración del servidor como `test_shard_localhost`. - -Algunas pruebas están marcadas con `zookeeper`, `shard` o `long` en sus nombres. -`zookeeper` es para pruebas que están usando ZooKeeper. `shard` es para pruebas que -requiere servidor para escuchar `127.0.0.*`; `distributed` o `global` tienen el mismo -significado. `long` es para pruebas que duran un poco más de un segundo. Usted puede -deshabilitar estos grupos de pruebas utilizando `--no-zookeeper`, `--no-shard` y -`--no-long` opciones, respectivamente. - -## Bugs Conocidos {#known-bugs} - -Si conocemos algunos errores que se pueden reproducir fácilmente mediante pruebas funcionales, colocamos pruebas funcionales preparadas en `tests/queries/bugs` directorio. Estas pruebas se moverán a `tests/queries/0_stateless` cuando se corrigen errores. - -## Pruebas de integración {#integration-tests} - -Las pruebas de integración permiten probar ClickHouse en la configuración agrupada y la interacción de ClickHouse con otros servidores como MySQL, Postgres, MongoDB. Son útiles para emular divisiones de red, caídas de paquetes, etc. Estas pruebas se ejecutan bajo Docker y crean múltiples contenedores con varios software. - -Ver `tests/integration/README.md` sobre cómo ejecutar estas pruebas. - -Tenga en cuenta que la integración de ClickHouse con controladores de terceros no se ha probado. Además, actualmente no tenemos pruebas de integración con nuestros controladores JDBC y ODBC. - -## Pruebas unitarias {#unit-tests} - -Las pruebas unitarias son útiles cuando desea probar no ClickHouse como un todo, sino una sola biblioteca o clase aislada. Puede habilitar o deshabilitar la compilación de pruebas con `ENABLE_TESTS` Opción CMake. Las pruebas unitarias (y otros programas de prueba) se encuentran en `tests` subdirectorios en todo el código. Para ejecutar pruebas unitarias, escriba `ninja test`. Algunas pruebas usan `gtest`, pero algunos son solo programas que devuelven un código de salida distinto de cero en caso de fallo de prueba. - -No es necesariamente tener pruebas unitarias si el código ya está cubierto por pruebas funcionales (y las pruebas funcionales suelen ser mucho más simples de usar). - -## Pruebas de rendimiento {#performance-tests} - -Las pruebas de rendimiento permiten medir y comparar el rendimiento de alguna parte aislada de ClickHouse en consultas sintéticas. Las pruebas se encuentran en `tests/performance`. Cada prueba está representada por `.xml` archivo con la descripción del caso de prueba. Las pruebas se ejecutan con `clickhouse performance-test` herramienta (que está incrustada en `clickhouse` binario). Ver `--help` para la invocación. - -Cada prueba ejecuta una o varias consultas (posiblemente con combinaciones de parámetros) en un bucle con algunas condiciones para detener (como “maximum execution speed is not changing in three seconds”) y medir algunas métricas sobre el rendimiento de las consultas (como “maximum execution speed”). Algunas pruebas pueden contener condiciones previas en el conjunto de datos de pruebas precargado. - -Si desea mejorar el rendimiento de ClickHouse en algún escenario, y si se pueden observar mejoras en consultas simples, se recomienda encarecidamente escribir una prueba de rendimiento. Siempre tiene sentido usar `perf top` u otras herramientas de perf durante sus pruebas. - -## Herramientas de prueba y secuencias de comandos {#test-tools-and-scripts} - -Algunos programas en `tests` directorio no son pruebas preparadas, pero son herramientas de prueba. Por ejemplo, para `Lexer` hay una herramienta `src/Parsers/tests/lexer` que solo hacen la tokenización de stdin y escriben el resultado coloreado en stdout. Puede usar este tipo de herramientas como ejemplos de código y para exploración y pruebas manuales. - -También puede colocar un par de archivos `.sh` y `.reference` junto con la herramienta para ejecutarlo en alguna entrada predefinida, entonces el resultado del script se puede comparar con `.reference` file. Este tipo de pruebas no están automatizadas. - -## Pruebas diversas {#miscellaneous-tests} - -Hay pruebas para diccionarios externos ubicados en `tests/external_dictionaries` y para modelos aprendidos a máquina en `tests/external_models`. Estas pruebas no se actualizan y deben transferirse a pruebas de integración. - -Hay una prueba separada para inserciones de quórum. Esta prueba ejecuta el clúster ClickHouse en servidores separados y emula varios casos de fallas: división de red, caída de paquetes (entre nodos ClickHouse, entre ClickHouse y ZooKeeper, entre el servidor ClickHouse y el cliente, etc.), `kill -9`, `kill -STOP` y `kill -CONT` , como [Jepsen](https://aphyr.com/tags/Jepsen). A continuación, la prueba comprueba que todas las inserciones reconocidas se escribieron y todas las inserciones rechazadas no. - -La prueba de quórum fue escrita por un equipo separado antes de que ClickHouse fuera de código abierto. Este equipo ya no trabaja con ClickHouse. La prueba fue escrita accidentalmente en Java. Por estas razones, la prueba de quórum debe reescribirse y trasladarse a pruebas de integración. - -## Pruebas manuales {#manual-testing} - -Cuando desarrolla una nueva característica, es razonable probarla también manualmente. Puede hacerlo con los siguientes pasos: - -Construir ClickHouse. Ejecute ClickHouse desde el terminal: cambie el directorio a `programs/clickhouse-server` y ejecutarlo con `./clickhouse-server`. Se utilizará la configuración (`config.xml`, `users.xml` y archivos dentro de `config.d` y `users.d` directorios) desde el directorio actual de forma predeterminada. Para conectarse al servidor ClickHouse, ejecute `programs/clickhouse-client/clickhouse-client`. - -Tenga en cuenta que todas las herramientas de clickhouse (servidor, cliente, etc.) son solo enlaces simbólicos a un único binario llamado `clickhouse`. Puede encontrar este binario en `programs/clickhouse`. Todas las herramientas también se pueden invocar como `clickhouse tool` en lugar de `clickhouse-tool`. - -Alternativamente, puede instalar el paquete ClickHouse: ya sea una versión estable del repositorio de Yandex o puede crear un paquete para usted con `./release` en la raíz de fuentes de ClickHouse. Luego inicie el servidor con `sudo service clickhouse-server start` (o detener para detener el servidor). Busque registros en `/etc/clickhouse-server/clickhouse-server.log`. - -Cuando ClickHouse ya está instalado en su sistema, puede crear un nuevo `clickhouse` binario y reemplazar el binario existente: - -``` bash -$ sudo service clickhouse-server stop -$ sudo cp ./clickhouse /usr/bin/ -$ sudo service clickhouse-server start -``` - -También puede detener el servidor de clickhouse del sistema y ejecutar el suyo propio con la misma configuración pero con el registro en la terminal: - -``` bash -$ sudo service clickhouse-server stop -$ sudo -u clickhouse /usr/bin/clickhouse server --config-file /etc/clickhouse-server/config.xml -``` - -Ejemplo con gdb: - -``` bash -$ sudo -u clickhouse gdb --args /usr/bin/clickhouse server --config-file /etc/clickhouse-server/config.xml -``` - -Si el servidor de clickhouse del sistema ya se está ejecutando y no desea detenerlo, puede cambiar los números de `config.xml` (o anularlos en un archivo en `config.d` directorio), proporcione la ruta de datos adecuada y ejecútela. - -`clickhouse` binary casi no tiene dependencias y funciona en una amplia gama de distribuciones de Linux. Para probar rápidamente y sucio sus cambios en un servidor, simplemente puede `scp` su fresco construido `clickhouse` binario a su servidor y luego ejecútelo como en los ejemplos anteriores. - -## Entorno de prueba {#testing-environment} - -Antes de publicar la versión como estable, la implementamos en el entorno de prueba. El entorno de prueba es un clúster que procesa 1/39 parte de [El Yandex.Métrica](https://metrica.yandex.com/) datos. Compartimos nuestro entorno de pruebas con Yandex.Equipo de Metrica. ClickHouse se actualiza sin tiempo de inactividad sobre los datos existentes. Nos fijamos en un primer momento que los datos se procesan con éxito sin retraso de tiempo real, la replicación continúan trabajando y no hay problemas visibles para Yandex.Equipo de Metrica. La primera comprobación se puede hacer de la siguiente manera: - -``` sql -SELECT hostName() AS h, any(version()), any(uptime()), max(UTCEventTime), count() FROM remote('example01-01-{1..3}t', merge, hits) WHERE EventDate >= today() - 2 GROUP BY h ORDER BY h; -``` - -En algunos casos también implementamos en el entorno de prueba de nuestros equipos de amigos en Yandex: Market, Cloud, etc. También tenemos algunos servidores de hardware que se utilizan con fines de desarrollo. - -## Pruebas de carga {#load-testing} - -Después de implementar en el entorno de prueba, ejecutamos pruebas de carga con consultas del clúster de producción. Esto se hace manualmente. - -Asegúrese de que ha habilitado `query_log` en su clúster de producción. - -Recopilar el registro de consultas para un día o más: - -``` bash -$ clickhouse-client --query="SELECT DISTINCT query FROM system.query_log WHERE event_date = today() AND query LIKE '%ym:%' AND query NOT LIKE '%system.query_log%' AND type = 2 AND is_initial_query" > queries.tsv -``` - -Este es un ejemplo complicado. `type = 2` filtrará las consultas que se ejecutan correctamente. `query LIKE '%ym:%'` es seleccionar consultas relevantes de Yandex.Métrica. `is_initial_query` es seleccionar solo las consultas iniciadas por el cliente, no por ClickHouse (como partes del procesamiento de consultas distribuidas). - -`scp` este registro en su clúster de prueba y ejecútelo de la siguiente manera: - -``` bash -$ clickhouse benchmark --concurrency 16 < queries.tsv -``` - -(probablemente también desee especificar un `--user`) - -Luego déjalo por una noche o un fin de semana e ir a tomar un descanso. - -Usted debe comprobar que `clickhouse-server` no se bloquea, la huella de memoria está limitada y el rendimiento no se degrada con el tiempo. - -Los tiempos de ejecución de consultas precisos no se registran y no se comparan debido a la alta variabilidad de las consultas y el entorno. - -## Pruebas de construcción {#build-tests} - -Las pruebas de compilación permiten verificar que la compilación no esté rota en varias configuraciones alternativas y en algunos sistemas extranjeros. Las pruebas se encuentran en `ci` directorio. Ejecutan compilación desde la fuente dentro de Docker, Vagrant y, a veces, con `qemu-user-static` dentro de Docker. Estas pruebas están en desarrollo y las ejecuciones de pruebas no están automatizadas. - -Motivación: - -Normalmente lanzamos y ejecutamos todas las pruebas en una sola variante de compilación ClickHouse. Pero hay variantes de construcción alternativas que no se prueban a fondo. Ejemplos: - -- construir en FreeBSD; -- construir en Debian con bibliotecas de paquetes del sistema; -- construir con enlaces compartidos de bibliotecas; -- construir en la plataforma AArch64; -- construir en la plataforma PowerPc. - -Por ejemplo, construir con paquetes del sistema es una mala práctica, porque no podemos garantizar qué versión exacta de paquetes tendrá un sistema. Pero esto es realmente necesario para los mantenedores de Debian. Por esta razón, al menos tenemos que admitir esta variante de construcción. Otro ejemplo: la vinculación compartida es una fuente común de problemas, pero es necesaria para algunos entusiastas. - -Aunque no podemos ejecutar todas las pruebas en todas las variantes de compilaciones, queremos verificar al menos que varias variantes de compilación no estén rotas. Para este propósito utilizamos pruebas de construcción. - -## Pruebas de Compatibilidad de protocolos {#testing-for-protocol-compatibility} - -Cuando ampliamos el protocolo de red ClickHouse, probamos manualmente que el antiguo clickhouse-client funciona con el nuevo clickhouse-server y el nuevo clickhouse-client funciona con el antiguo clickhouse-server (simplemente ejecutando binarios de los paquetes correspondientes). - -## Ayuda del compilador {#help-from-the-compiler} - -Código principal de ClickHouse (que se encuentra en `dbms` directorio) se construye con `-Wall -Wextra -Werror` y con algunas advertencias habilitadas adicionales. Aunque estas opciones no están habilitadas para bibliotecas de terceros. - -Clang tiene advertencias aún más útiles: puedes buscarlas con `-Weverything` y elige algo para la compilación predeterminada. - -Para las compilaciones de producción, se usa gcc (todavía genera un código ligeramente más eficiente que clang). Para el desarrollo, el clang suele ser más conveniente de usar. Puede construir en su propia máquina con el modo de depuración (para ahorrar batería de su computadora portátil), pero tenga en cuenta que el compilador puede generar más advertencias con `-O3` debido a un mejor flujo de control y análisis entre procedimientos. Al construir con clang con el modo de depuración, la versión de depuración de `libc++` se utiliza que permite detectar más errores en tiempo de ejecución. - -## Desinfectantes {#sanitizers} - -**Dirección desinfectante**. -Ejecutamos pruebas funcionales y de integración bajo ASan por compromiso. - -**Valgrind (Memcheck)**. -Realizamos pruebas funcionales bajo Valgrind durante la noche. Se tarda varias horas. Actualmente hay un falso positivo conocido en `re2` biblioteca, ver [este artículo](https://research.swtch.com/sparse). - -**Desinfectante de comportamiento indefinido.** -Ejecutamos pruebas funcionales y de integración bajo ASan por compromiso. - -**Desinfectante de hilo**. -Ejecutamos pruebas funcionales bajo TSan por compromiso. Todavía no ejecutamos pruebas de integración bajo TSan por compromiso. - -**Desinfectante de memoria**. -Actualmente todavía no usamos MSan. - -**Asignador de depuración.** -Versión de depuración de `jemalloc` se utiliza para la compilación de depuración. - -## Fuzzing {#fuzzing} - -ClickHouse fuzzing se implementa tanto usando [LibFuzzer](https://llvm.org/docs/LibFuzzer.html) y consultas SQL aleatorias. -Todas las pruebas de fuzz deben realizarse con desinfectantes (Dirección y Undefined). - -LibFuzzer se usa para pruebas de fuzz aisladas del código de la biblioteca. Fuzzers se implementan como parte del código de prueba y tienen “_fuzzer” nombre postfixes. -El ejemplo de Fuzzer se puede encontrar en `src/Parsers/tests/lexer_fuzzer.cpp`. Las configuraciones, diccionarios y corpus específicos de LibFuzzer se almacenan en `tests/fuzz`. -Le recomendamos que escriba pruebas fuzz para cada funcionalidad que maneje la entrada del usuario. - -Fuzzers no se construyen de forma predeterminada. Para construir fuzzers ambos `-DENABLE_FUZZING=1` y `-DENABLE_TESTS=1` se deben establecer opciones. -Recomendamos deshabilitar Jemalloc mientras se construyen fuzzers. Configuración utilizada para integrar -Google OSS-Fuzz se puede encontrar en `docker/fuzz`. - -También usamos una prueba de fuzz simple para generar consultas SQL aleatorias y verificar que el servidor no muera al ejecutarlas. -Lo puedes encontrar en `00746_sql_fuzzy.pl`. Esta prueba debe ejecutarse de forma continua (de la noche a la mañana y más). - -## Auditoría de seguridad {#security-audit} - -La gente de Yandex Security Team hace una visión general básica de las capacidades de ClickHouse desde el punto de vista de la seguridad. - -## Analizadores estáticos {#static-analyzers} - -Corremos `PVS-Studio` por compromiso. Hemos evaluado `clang-tidy`, `Coverity`, `cppcheck`, `PVS-Studio`, `tscancode`. Encontrará instrucciones de uso en `tests/instructions/` directorio. También puedes leer [el artículo en ruso](https://habr.com/company/yandex/blog/342018/). - -Si usted usa `CLion` como IDE, puede aprovechar algunos `clang-tidy` comprueba fuera de la caja. - -## Endurecer {#hardening} - -`FORTIFY_SOURCE` se utiliza de forma predeterminada. Es casi inútil, pero todavía tiene sentido en casos raros y no lo desactivamos. - -## Estilo de código {#code-style} - -Se describen las reglas de estilo de código [aqui](https://clickhouse.tech/docs/en/development/style/). - -Para comprobar si hay algunas violaciones de estilo comunes, puede usar `utils/check-style` script. - -Para forzar el estilo adecuado de su código, puede usar `clang-format`. File `.clang-format` se encuentra en la raíz de las fuentes. Se corresponde principalmente con nuestro estilo de código real. Pero no se recomienda aplicar `clang-format` a los archivos existentes porque empeora el formato. Usted puede utilizar `clang-format-diff` herramienta que puede encontrar en el repositorio de origen clang. - -Alternativamente, puede intentar `uncrustify` herramienta para reformatear su código. La configuración está en `uncrustify.cfg` en la raíz de las fuentes. Es menos probado que `clang-format`. - -`CLion` tiene su propio formateador de código que debe ajustarse para nuestro estilo de código. - -## Pruebas Metrica B2B {#metrica-b2b-tests} - -Cada lanzamiento de ClickHouse se prueba con los motores Yandex Metrica y AppMetrica. Las pruebas y las versiones estables de ClickHouse se implementan en máquinas virtuales y se ejecutan con una copia pequeña del motor Metrica que procesa una muestra fija de datos de entrada. A continuación, los resultados de dos instancias del motor Metrica se comparan juntos. - -Estas pruebas son automatizadas por un equipo separado. Debido a la gran cantidad de piezas móviles, las pruebas fallan la mayor parte del tiempo por razones completamente no relacionadas, que son muy difíciles de descubrir. Lo más probable es que estas pruebas tengan un valor negativo para nosotros. Sin embargo, se demostró que estas pruebas son útiles en aproximadamente una o dos veces de cada cientos. - -## Cobertura de prueba {#test-coverage} - -A partir de julio de 2018, no realizamos un seguimiento de la cobertura de las pruebas. - -## Automatización de pruebas {#test-automation} - -Realizamos pruebas con el CI interno de Yandex y el sistema de automatización de trabajos llamado “Sandbox”. - -Los trabajos de compilación y las pruebas se ejecutan en Sandbox por confirmación. Los paquetes resultantes y los resultados de las pruebas se publican en GitHub y se pueden descargar mediante enlaces directos. Los artefactos se almacenan eternamente. Cuando envías una solicitud de extracción en GitHub, la etiquetamos como “can be tested” y nuestro sistema CI construirá paquetes ClickHouse (liberación, depuración, con desinfectante de direcciones, etc.) para usted. - -No usamos Travis CI debido al límite de tiempo y potencia computacional. -No usamos Jenkins. Se usó antes y ahora estamos felices de no estar usando Jenkins. - -[Artículo Original](https://clickhouse.tech/docs/en/development/tests/) diff --git a/docs/es/development/tests.md b/docs/es/development/tests.md new file mode 120000 index 00000000000..c03d36c3916 --- /dev/null +++ b/docs/es/development/tests.md @@ -0,0 +1 @@ +../../en/development/tests.md \ No newline at end of file diff --git a/docs/fa/development/tests.md b/docs/fa/development/tests.md deleted file mode 100644 index abab3230e2f..00000000000 --- a/docs/fa/development/tests.md +++ /dev/null @@ -1,262 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd -toc_priority: 69 -toc_title: "\u0646\u062D\u0648\u0647 \u0627\u062C\u0631\u0627\u06CC \u062A\u0633\u062A\ - \ \u0647\u0627\u06CC \u06A9\u0644\u06CC\u06A9 \u062E\u0627\u0646\u0647" ---- - -# تست کلیک {#clickhouse-testing} - -## تست های کاربردی {#functional-tests} - -تست های کاربردی ساده ترین و راحت برای استفاده هستند. بسیاری از ClickHouse ویژگی ها را می توان مورد آزمایش با استفاده از آزمون های عملکردی و آنها را اجباری به استفاده از برای هر تغییر در ClickHouse کد است که می تواند آزمایش می شود که در راه است. - -هر تست عملکردی یک یا چند نمایش داده شد به سرور در حال اجرا تاتر می فرستد و نتیجه را با مرجع مقایسه می کند. - -تست ها در واقع `queries` فهرست راهنما. دو زیرشاخه وجود دارد: `stateless` و `stateful`. تست های بدون تابعیت بدون هیچ گونه داده های تست پیش بارگذاری شده نمایش داده می شوند-اغلب مجموعه داده های مصنوعی کوچک را در پرواز در داخل تست خود ایجاد می کنند. تست های نفرت انگیز نیاز به داده های تست از قبل نصب شده از یاندکس.متریکا و در دسترس عموم نیست. ما تمایل به استفاده از تنها `stateless` تست ها و جلوگیری از اضافه کردن جدید `stateful` تستها - -هر تست می تواند یکی از دو نوع باشد: `.sql` و `.sh`. `.sql` تست اسکریپت ساده مربع است که به لوله کشی است `clickhouse-client --multiquery --testmode`. `.sh` تست یک اسکریپت است که به خودی خود اجرا است. - -برای اجرای تمام تست ها استفاده کنید `clickhouse-test` ابزار. نگاه کن `--help` برای لیستی از گزینه های ممکن. شما به سادگی می توانید تمام تست ها را اجرا کنید یا زیر مجموعه ای از تست های فیلتر شده توسط زیر رشته را در نام تست اجرا کنید: `./clickhouse-test substring`. - -ساده ترین راه برای فراخوانی تست های کاربردی کپی است `clickhouse-client` به `/usr/bin/` فرار کن `clickhouse-server` و سپس اجرا کنید `./clickhouse-test` از دایرکتوری خود را. - -برای اضافه کردن تست جدید, ایجاد یک `.sql` یا `.sh` پرونده در `queries/0_stateless` فهرست راهنما را به صورت دستی بررسی کنید و سپس تولید کنید `.reference` پرونده به روش زیر: `clickhouse-client -n --testmode < 00000_test.sql > 00000_test.reference` یا `./00000_test.sh > ./00000_test.reference`. - -تست باید استفاده کنید (ساختن, قطره, و غیره) تنها جداول در `test` پایگاه داده است که فرض بر این است که از قبل ایجاد می شود; همچنین تست می توانید جداول موقت استفاده. - -اگر شما می خواهید به استفاده از نمایش داده شد توزیع شده در تست های کاربردی, شما می توانید اهرم `remote` تابع جدول با `127.0.0.{1..2}` یا شما می توانید خوشه تست از پیش تعریف شده در فایل پیکربندی سرور مانند استفاده کنید `test_shard_localhost`. - -برخی از تست ها با مشخص شده اند `zookeeper`, `shard` یا `long` در نام خود. -`zookeeper` برای تست هایی است که از باغ وحش استفاده می کنند. `shard` برای تست هایی است که -نیاز به سرور برای گوش دادن `127.0.0.*`; `distributed` یا `global` همان -معنی. `long` برای تست هایی است که کمی طولانی تر اجرا می شوند که یک ثانیه. شما می توانید -غیر فعال کردن این گروه از تست با استفاده از `--no-zookeeper`, `--no-shard` و -`--no-long` گزینه, به ترتیب. - -## اشکالات شناخته شده {#known-bugs} - -اگر ما می دانیم برخی از اشکالات است که می تواند به راحتی توسط تست های کاربردی تکثیر, ما تست های عملکردی تهیه شده در `tests/queries/bugs` فهرست راهنما. این تست خواهد شد به نقل مکان کرد `tests/queries/0_stateless` هنگامی که اشکالات ثابت هستند. - -## تست های ادغام {#integration-tests} - -ادغام آزمون اجازه می دهد برای تست ClickHouse در خوشه پیکربندی و ClickHouse تعامل با سرور های دیگر مانند MySQL, Postgres, MongoDB. مفید برای تقلید انشعابات شبکه قطره بسته و غیره هستند. این تست ها تحت کارگر بارانداز اجرا و ایجاد ظروف متعدد با نرم افزار های مختلف. - -ببینید `tests/integration/README.md` در مورد چگونگی اجرای این تست. - -توجه داشته باشید که ادغام کلیک با رانندگان شخص ثالث تست نشده است. همچنین ما در حال حاضر تست های یکپارچه سازی با رانندگان جی بی سی و بی سی ما ندارد. - -## تست های واحد {#unit-tests} - -تست واحد مفید هستند که شما می خواهید برای تست نیست خانه کلیک به عنوان یک کل, اما یک کتابخانه جدا شده و یا کلاس. شما می توانید ساخت تست ها را فعال یا غیر فعال کنید `ENABLE_TESTS` گزینه کیک. تست واحد (و دیگر برنامه های تست) در واقع `tests` زیرشاخه در سراسر کد. برای اجرای تست واحد, نوع `ninja test`. برخی از تست ها استفاده می کنند `gtest`, اما برخی فقط برنامه هایی که بازگشت کد خروج غیر صفر در شکست تست. - -این لزوما به تست واحد اگر کد در حال حاضر توسط تست های کاربردی تحت پوشش (و تست های کاربردی معمولا بسیار ساده تر برای استفاده). - -## تست های عملکرد {#performance-tests} - -تست های عملکرد اجازه می دهد برای اندازه گیری و مقایسه عملکرد برخی از بخش جدا شده از خانه رعیتی در نمایش داده شد مصنوعی. تست ها در واقع `tests/performance`. هر تست توسط نمایندگی `.xml` فایل با شرح مورد تست. تست ها با اجرا `clickhouse performance-test` ابزار (که در تعبیه شده است `clickhouse` دودویی). ببینید `--help` برای نیایش. - -هر تست یک یا چند نمایش داده شد (احتمالا با ترکیبی از پارامترهای) در یک حلقه با برخی از شرایط برای توقف (مانند “maximum execution speed is not changing in three seconds”) و اندازه گیری برخی از معیارهای مورد عملکرد پرس و جو (مانند “maximum execution speed”). برخی از تست ها می توانند پیش شرط ها را در مجموعه داده های تست پیش بارگذاری شده داشته باشند. - -اگر شما می خواهید برای بهبود عملکرد تاتر در برخی از سناریو, و اگر پیشرفت را می توان در نمایش داده شد ساده مشاهده, بسیار توصیه می شود برای نوشتن یک تست عملکرد. همیشه حس می کند به استفاده از `perf top` و یا دیگر ابزار دقیق در طول تست های خود را. - -## ابزار تست و اسکریپت {#test-tools-and-scripts} - -برخی از برنامه ها در `tests` دایرکتوری تست تهیه نشده, اما ابزار تست. مثلا, برای `Lexer` یک ابزار وجود دارد `src/Parsers/tests/lexer` این فقط تقلید از استدین را انجام می دهد و نتیجه رنگی را به انحراف می نویسد. شما می توانید از این نوع ابزار به عنوان نمونه کد و برای اکتشاف و تست دستی استفاده کنید. - -شما همچنین می توانید جفت فایل قرار دهید `.sh` و `.reference` همراه با ابزار برای اجرا در برخی از ورودی از پیش تعریف شده - سپس نتیجه اسکریپت را می توان به مقایسه `.reference` پرونده. این نوع تست ها خودکار نیستند. - -## تست های متفرقه {#miscellaneous-tests} - -تست برای لغت نامه های خارجی واقع در وجود دارد `tests/external_dictionaries` و برای مدل های ماشین یاد گرفته شده در `tests/external_models`. این تست ها به روز نمی شوند و باید به تست های ادغام منتقل شوند. - -تست جداگانه برای درج حد نصاب وجود دارد. این اجرای آزمون ClickHouse خوشه در سرورهای جداگانه و شبیه سازی شکست های مختلف در موارد: شبکه تقسیم بسته رها کردن (بین ClickHouse گره بین ClickHouse و باغ وحش بین ClickHouse سرور و کلاینت ، ), `kill -9`, `kill -STOP` و `kill -CONT` مثل [جپسن](https://aphyr.com/tags/Jepsen). سپس چک تست که همه درج اذعان نوشته شده بود و همه درج رد شد. - -تست حد نصاب توسط تیم جداگانه نوشته شده بود قبل از کلیک باز منابع بود. این تیم دیگر با کلیکهاوس کار. تست به طور تصادفی در جاوا نوشته شده بود. به این دلایل, تست حد نصاب باید بازنویسی شود و به تست ادغام نقل مکان کرد. - -## تست دستی {#manual-testing} - -هنگامی که شما توسعه یک ویژگی جدید معقول نیز دستی تست است. شما می توانید این کار را با مراحل زیر انجام دهید: - -ساخت خانه کلیک. اجرای کلیک از ترمینال: تغییر دایرکتوری به `programs/clickhouse-server` و با `./clickhouse-server`. این پیکربندی استفاده کنید (`config.xml`, `users.xml` و فایل ها در `config.d` و `users.d` دایرکتوری ها) از دایرکتوری جاری به طور پیش فرض. برای اتصال به سرور کلیک اجرا کنید `programs/clickhouse-client/clickhouse-client`. - -توجه داشته باشید که تمام clickhouse ابزار (سرور مشتری و غیره) فقط symlinks به یک باینری به نام `clickhouse`. شما می توانید این دودویی در `programs/clickhouse`. همه ابزار همچنین می توانید به عنوان استناد شود `clickhouse tool` به جای `clickhouse-tool`. - -متناوبا شما می توانید بسته بندی کلیک را نصب کنید: در هر صورت انتشار پایدار از مخزن یاندکس و یا شما می توانید بسته را برای خودتان با ساخت `./release` در منابع کلیک خانه ریشه. سپس سرور را با شروع `sudo service clickhouse-server start` (یا توقف برای متوقف کردن سرور). به دنبال سیاهههای مربوط در `/etc/clickhouse-server/clickhouse-server.log`. - -هنگامی که تاتر در حال حاضر بر روی سیستم شما نصب شده, شما می توانید جدید ساخت `clickhouse` دودویی و جایگزین باینری موجود: - -``` bash -$ sudo service clickhouse-server stop -$ sudo cp ./clickhouse /usr/bin/ -$ sudo service clickhouse-server start -``` - -همچنین شما می توانید سیستم کلیک سرور را متوقف و اجرا خود را با همان پیکربندی اما با ورود به ترمینال: - -``` bash -$ sudo service clickhouse-server stop -$ sudo -u clickhouse /usr/bin/clickhouse server --config-file /etc/clickhouse-server/config.xml -``` - -به عنوان مثال با دیابت بارداری: - -``` bash -$ sudo -u clickhouse gdb --args /usr/bin/clickhouse server --config-file /etc/clickhouse-server/config.xml -``` - -اگر سیستم کلیک-سرور در حال اجرا است و شما نمی خواهید برای متوقف کردن, شما می توانید شماره پورت در خود تغییر دهید `config.xml` (یا نادیده گرفتن در یک فایل در `config.d` فهرست راهنما) مسیر داده مناسب را فراهم کرده و اجرا کنید. - -`clickhouse` دودویی تقریبا هیچ وابستگی و کار در سراسر طیف گسترده ای از توزیع های لینوکس. برای تست سریع و کثیف تغییرات خود را بر روی یک سرور, شما به سادگی می توانید `scp` تازه ساخته شده است `clickhouse` باینری به سرور شما و سپس به عنوان مثال بالا اجرا شود. - -## محیط تست {#testing-environment} - -قبل از انتشار انتشار به عنوان پایدار ما را در محیط تست استقرار. محیط تست یک خوشه است که بخشی از 1/39 را پردازش می کند [یاندکسمتریکا](https://metrica.yandex.com/) داده ها. ما محیط تست خود را با یاندکس به اشتراک می گذاریم.تیم متریکا تاتر بدون خرابی در بالای داده های موجود به روز رسانی. ما در ابتدا نگاه کنید که داده ها با موفقیت و بدون عقب مانده از زمان واقعی پردازش, تکرار ادامه کار و هیچ مشکلی برای یاندکس قابل مشاهده وجود دارد.تیم متریکا اولین چک را می توان در راه زیر انجام داد: - -``` sql -SELECT hostName() AS h, any(version()), any(uptime()), max(UTCEventTime), count() FROM remote('example01-01-{1..3}t', merge, hits) WHERE EventDate >= today() - 2 GROUP BY h ORDER BY h; -``` - -در برخی موارد ما نیز به تست محیط زیست از تیم های دوست ما در یاندکس استقرار: بازار, ابر, و غیره. همچنین در حال حاضر برخی از سرورهای سخت افزاری است که برای اهداف توسعه استفاده می شود. - -## تست بار {#load-testing} - -پس از استقرار به محیط تست ما تست بار با نمایش داده شد از خوشه تولید را اجرا کنید. این کار به صورت دستی انجام می شود. - -اطمینان حاصل کنید که شما را فعال کرده اند `query_log` در خوشه تولید خود را. - -جمع کردن گزارش پرس و جو برای یک روز یا بیشتر: - -``` bash -$ clickhouse-client --query="SELECT DISTINCT query FROM system.query_log WHERE event_date = today() AND query LIKE '%ym:%' AND query NOT LIKE '%system.query_log%' AND type = 2 AND is_initial_query" > queries.tsv -``` - -این یک مثال راه پیچیده است. `type = 2` نمایش داده شد که با موفقیت اجرا فیلتر کنید. `query LIKE '%ym:%'` است برای انتخاب نمایش داده شد مربوطه از یاندکس.متریکا `is_initial_query` است را انتخاب کنید تنها نمایش داده شد که توسط مشتری شروع, نه با کلیک خود (به عنوان بخش هایی از پردازش پرس و جو توزیع). - -`scp` این ورود به خوشه تست خود را و اجرا به شرح زیر است: - -``` bash -$ clickhouse benchmark --concurrency 16 < queries.tsv -``` - -(احتمالا شما همچنین می خواهید برای مشخص کردن یک `--user`) - -پس یه شب یا هفته ولش کن و برو استراحت کن - -شما باید بررسی کنید که `clickhouse-server` سقوط نمی کند, رد پای حافظه محدود است و عملکرد در طول زمان تنزل نمی. - -زمان اجرای پرس و جو دقیق ثبت نشده است و با توجه به تنوع بالا از نمایش داده شد و محیط زیست در مقایسه نیست. - -## ساخت تست {#build-tests} - -تست های ساخت اجازه می دهد تا بررسی کنید که ساخت در تنظیمات مختلف جایگزین و در برخی از سیستم های خارجی شکسته نمی شود. تست ها در واقع `ci` فهرست راهنما. ساخت از منبع داخل کارگر بارانداز ولگرد و گاهی با اجرا می شوند `qemu-user-static` در داخل کارگر بارانداز. این تست ها در حال توسعه هستند و تست اجرا می شود خودکار نیست. - -انگیزه: - -به طور معمول ما انتشار و اجرای تمام تست بر روی یک نوع واحد از ساخت تاتر. اما انواع ساخت جایگزین است که به طور کامل تست شده وجود دارد. مثالها: - -- ساخت در بورس; -- ساخت در دبیان با کتابخانه ها از بسته های سیستم; -- ساخت با لینک مشترک از کتابخانه ها; -- ساخت پلت فرم AArch64; -- ساخت بر روی پلت فرم پاور. - -مثلا, ساخت با بسته های سیستم عمل بد است, چرا که ما نمی تواند تضمین کند که چه نسخه دقیق از بسته های یک سیستم باید. اما این واقعا توسط نگهداری دبیان مورد نیاز است. به همین دلیل ما حداقل باید برای حمایت از این نوع ساخت. مثال دیگر: ارتباط مشترک یک منبع مشترک از مشکل است, اما برای برخی از علاقه مندان مورد نیاز است. - -هر چند ما می توانیم تمام تست در همه نوع از ایجاد اجرا کنید, ما می خواهیم برای بررسی حداقل که انواع ساخت های مختلف شکسته نمی. برای این منظور ما از تست های ساخت استفاده می کنیم. - -## تست برای سازگاری پروتکل {#testing-for-protocol-compatibility} - -هنگامی که ما گسترش ClickHouse پروتکل شبکه ما تست دستی که clickhouse-مشتری با این نسخهها کار جدید clickhouse-سرور و جدید clickhouse-مشتری با این نسخهها کار با clickhouse-سرور (به سادگی با در حال اجرا فایل های باینری از مربوطه بسته). - -## کمک از کامپایلر {#help-from-the-compiler} - -کد اصلی کلیک (که در واقع `dbms` فهرست راهنما) با ساخته شده است `-Wall -Wextra -Werror` و با برخی از هشدارهای اضافی را فعال کنید. اگر چه این گزینه ها برای کتابخانه های شخص ثالث فعال نیست. - -کلانگ هشدارهای بیشتری دارد - شما می توانید با `-Weverything` و انتخاب چیزی به طور پیش فرض ساخت. - -برای تولید ساخت, شورای همکاری خلیج فارس استفاده می شود (هنوز تولید کد کمی موثر تر از صدای جرنگ جرنگ). برای توسعه, صدای جرنگ جرنگ است که معمولا راحت تر به استفاده از. شما می توانید بر روی دستگاه خود را با حالت اشکال زدایی ساخت (برای صرفه جویی در باتری لپ تاپ خود را), اما لطفا توجه داشته باشید که کامپایلر قادر به تولید هشدارهای بیشتر با است `-O3` با توجه به جریان کنترل بهتر و تجزیه و تحلیل بین روش. هنگام ساخت با صدای جرنگ جرنگ, `libc++` به جای استفاده `libstdc++` و هنگامی که ساختمان با حالت اشکال زدایی, نسخه اشکال زدایی از `libc++` استفاده شده است که اجازه می دهد تا برای گرفتن خطاهای بیشتر در زمان اجرا. - -## Sanitizers {#sanitizers} - -**نشانی ضد عفونی کننده**. -ما تست های کاربردی و یکپارچه سازی را تحت عنوان بر اساس هر متعهد اجرا می کنیم. - -**Valgrind (Memcheck)**. -ما یک شبه تست های کاربردی را تحت ارزیابی قرار می دهیم. چند ساعت طول می کشد. در حال حاضر یک مثبت کاذب شناخته شده در وجود دارد `re2` کتابخانه را ببینید [این مقاله](https://research.swtch.com/sparse). - -**تعریف نشده رفتار ضد عفونی کننده.** -ما تست های کاربردی و یکپارچه سازی را تحت عنوان بر اساس هر متعهد اجرا می کنیم. - -**ضدعفونی کننده موضوع**. -ما تست های کاربردی تحت تسان بر اساس هر مرتکب اجرا. ما هنوز تست های ادغام تحت تسان بر اساس هر متعهد اجرا کنید. - -**ضد عفونی کننده حافظه**. -در حال حاضر ما هنوز از خانم استفاده نمی کنیم. - -**اشکال زدایی تخصیص.** -نسخه اشکال زدایی از `jemalloc` برای ساخت اشکال زدایی استفاده می شود. - -## Fuzzing {#fuzzing} - -ریش ریش شدن کلیک هر دو با استفاده از اجرا شده است [هرزه](https://llvm.org/docs/LibFuzzer.html) و تصادفی گذاشتن نمایش داده شد. -تمام تست ریش شدن باید با ضدعفونی کننده انجام شود (نشانی و تعریف نشده). - -پازل برای تست ریش ریش شدن جدا شده از کد کتابخانه استفاده می شود. طبع به عنوان بخشی از کد تست اجرا و “_fuzzer” نام پسوند. -به عنوان مثال ریش ریش شدن را می توان در یافت `src/Parsers/tests/lexer_fuzzer.cpp`. تنظیمات-پازل خاص, لغت نامه ها و جسم در ذخیره می شود `tests/fuzz`. -ما شما را تشویق به نوشتن تست ریش ریش شدن برای هر قابلیت که دسته ورودی کاربر. - -طبع به طور پیش فرض ساخته شده است. برای ساخت ریش ریش ریش ریش شدن هر دو `-DENABLE_FUZZING=1` و `-DENABLE_TESTS=1` گزینه ها باید تنظیم شود. -ما توصیه می کنیم برای غیر فعال کردن Jemalloc در حالی که ساختمان fuzzers. پیکربندی مورد استفاده برای ادغام ریش ریش شدن تاتر به -گوگل اوس فوز را می توان در یافت `docker/fuzz`. - -ما همچنین از تست ریش ریش شدن ساده برای تولید پرس و جو تصادفی ساده استفاده می کنیم و بررسی می کنیم که سرور نمی میرد. -شما می توانید این را در `00746_sql_fuzzy.pl`. این تست باید به طور مداوم اجرا شود (یک شبه و طولانی تر). - -## ممیزی امنیتی {#security-audit} - -مردم از تیم امنیتی یاندکس انجام برخی از بررسی اجمالی اساسی از قابلیت های تاتر از نقطه نظر امنیت. - -## تجزیه و تحلیل استاتیک {#static-analyzers} - -فرار میکنیم `PVS-Studio` بر اساس هر مرتکب. ما ارزیابی کرده ایم `clang-tidy`, `Coverity`, `cppcheck`, `PVS-Studio`, `tscancode`. شما دستورالعمل برای استفاده در پیدا `tests/instructions/` فهرست راهنما. همچنین شما می توانید به عنوان خوانده شده [مقاله در روسیه](https://habr.com/company/yandex/blog/342018/). - -در صورت استفاده `CLion` به عنوان محیط برنامه نویسی, شما می توانید اهرم برخی از `clang-tidy` چک از جعبه. - -## سخت شدن {#hardening} - -`FORTIFY_SOURCE` به طور پیش فرض استفاده می شود. این تقریبا بی فایده است, اما هنوز هم حس می کند در موارد نادر و ما این کار را غیر فعال کنید. - -## سبک کد {#code-style} - -قوانین سبک کد شرح داده شده است [اینجا](https://clickhouse.tech/docs/en/development/style/). - -برای بررسی برخی از نقض سبک مشترک, شما می توانید استفاده کنید `utils/check-style` خط نوشتن. - -به زور سبک مناسب از کد خود را, شما می توانید استفاده کنید `clang-format`. پرونده `.clang-format` در منابع ریشه واقع شده است. این بیشتر با سبک کد واقعی ما مطابقت دارد. اما توصیه نمی شود که اعمال شود `clang-format` به فایل های موجود چون باعث می شود قالب بندی بدتر است. شما می توانید استفاده کنید `clang-format-diff` ابزاری است که شما می توانید در مخزن منبع صدای جرنگ جرنگ پیدا. - -متناوبا شما می توانید سعی کنید `uncrustify` ابزار مجدد کد خود را. پیکربندی در `uncrustify.cfg` در منابع ریشه. این کمتر از تست شده است `clang-format`. - -`CLion` فرمت کد خود را دارد که باید برای سبک کد ما تنظیم شود. - -## تست های متریکا ب2 {#metrica-b2b-tests} - -هر ClickHouse نسخه تست شده با Yandex Metrica و AppMetrica موتورهای. تست و نسخه های پایدار از تاتر در ماشین های مجازی مستقر و اجرا با یک کپی کوچک از موتور متریکا است که پردازش نمونه ثابت از داده های ورودی. سپس نتایج حاصل از دو نمونه از موتور متریکا با هم مقایسه می شوند. - -این تست ها توسط تیم جداگانه خودکار می شوند. با توجه به تعداد زیادی از قطعات متحرک, تست شکست بیشتر از زمان به دلایل کاملا نامربوط, که بسیار دشوار است برای کشف کردن. به احتمال زیاد این تست ها ارزش منفی برای ما دارند. با این وجود این تست در حدود یک یا دو بار از صدها مفید ثابت شد. - -## پوشش تست {#test-coverage} - -تا جولای 2018 ما پوشش تست را پیگیری نمی کنیم. - -## اتوماسیون تست {#test-automation} - -ما تست ها را با سیستم اتوماسیون داخلی یاندکس اجرا می کنیم “Sandbox”. - -ساخت شغل و تست ها در گودال ماسهبازی در هر مرتکب اساس اجرا شود. نتیجه بسته ها و نتایج تست در گیتهاب منتشر شده و می تواند توسط لینک مستقیم دانلود. مصنوعات ابد ذخیره می شود. هنگامی که شما یک درخواست کشش ارسال در گیتهاب, ما برچسب به عنوان “can be tested” و سیستم سی ما خواهد بسته های تاتر ساخت (رهایی, اشکال زدایی, با نشانی ضد عفونی کننده, و غیره) برای شما. - -ما از تراویس سی به دلیل محدودیت در زمان و قدرت محاسباتی استفاده نمی کنیم. -ما از جنکینز استفاده نمیکنیم. این قبل از استفاده شد و در حال حاضر ما خوشحال ما با استفاده از جنکینز نیست. - -[مقاله اصلی](https://clickhouse.tech/docs/en/development/tests/) diff --git a/docs/fa/development/tests.md b/docs/fa/development/tests.md new file mode 120000 index 00000000000..c03d36c3916 --- /dev/null +++ b/docs/fa/development/tests.md @@ -0,0 +1 @@ +../../en/development/tests.md \ No newline at end of file diff --git a/docs/fr/development/tests.md b/docs/fr/development/tests.md deleted file mode 100644 index 5fd5cd36e2d..00000000000 --- a/docs/fr/development/tests.md +++ /dev/null @@ -1,261 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd -toc_priority: 69 -toc_title: "Comment ex\xE9cuter des Tests ClickHouse" ---- - -# ClickHouse Test {#clickhouse-testing} - -## Les Tests Fonctionnels {#functional-tests} - -Les tests fonctionnels sont les plus simples et pratiques à utiliser. La plupart des fonctionnalités de ClickHouse peuvent être testées avec des tests fonctionnels et elles sont obligatoires à utiliser pour chaque changement de code de ClickHouse qui peut être testé de cette façon. - -Chaque test fonctionnel envoie une ou plusieurs requêtes au serveur clickhouse en cours d'exécution et compare le résultat avec la référence. - -Les Tests sont situés dans `queries` répertoire. Il y a deux sous-répertoires: `stateless` et `stateful`. Les tests sans état exécutent des requêtes sans données de test préchargées - ils créent souvent de petits ensembles de données synthétiques à la volée, dans le test lui-même. Les tests avec État nécessitent des données de test préchargées de Yandex.Metrica et non disponible pour le grand public. Nous avons tendance à utiliser uniquement `stateless` tests et éviter d'ajouter de nouveaux `stateful` test. - -Chaque test peut être de deux types: `.sql` et `.sh`. `.sql` test est le script SQL simple qui est canalisé vers `clickhouse-client --multiquery --testmode`. `.sh` test est un script qui est exécuté par lui-même. - -Pour exécuter tous les tests, utilisez `clickhouse-test` outil. Regarder `--help` pour la liste des options possibles. Vous pouvez simplement exécuter tous les tests ou exécuter un sous ensemble de tests filtrés par sous chaîne dans le nom du test: `./clickhouse-test substring`. - -Le moyen le plus simple d'invoquer des tests fonctionnels est de copier `clickhouse-client` de `/usr/bin/`, exécuter `clickhouse-server` et puis exécutez `./clickhouse-test` à partir de son propre répertoire. - -Pour ajouter un nouveau test, créez un `.sql` ou `.sh` fichier dans `queries/0_stateless` répertoire, vérifiez-le manuellement, puis générez `.reference` fichier de la façon suivante: `clickhouse-client -n --testmode < 00000_test.sql > 00000_test.reference` ou `./00000_test.sh > ./00000_test.reference`. - -Les Tests doivent utiliser (create, drop, etc) uniquement des tables dans `test` base de données supposée être créée au préalable; les tests peuvent également utiliser des tables temporaires. - -Si vous souhaitez utiliser des requêtes distribuées dans les tests fonctionnels, vous pouvez tirer parti de `remote` fonction de table avec `127.0.0.{1..2}` ou vous pouvez utiliser des clusters de test prédéfinis dans le fichier de configuration du serveur comme `test_shard_localhost`. - -Certains tests sont marqués avec `zookeeper`, `shard` ou `long` en leurs noms. -`zookeeper` est pour les tests qui utilisent ZooKeeper. `shard` est pour les tests -nécessite l'écoute du serveur `127.0.0.*`; `distributed` ou `global` avoir le même -sens. `long` est pour les tests qui s'exécutent légèrement plus longtemps qu'une seconde. Vous pouvez -désactivez ces groupes de tests en utilisant `--no-zookeeper`, `--no-shard` et -`--no-long` options, respectivement. - -## Bugs Connus {#known-bugs} - -Si nous connaissons des bugs qui peuvent être facilement reproduits par des tests fonctionnels, nous plaçons des tests fonctionnels préparés dans `tests/queries/bugs` répertoire. Ces tests seront déplacés à `tests/queries/0_stateless` quand les bugs sont corrigés. - -## Les Tests D'Intégration {#integration-tests} - -Les tests d'intégration permettent de tester ClickHouse en configuration cluster et clickhouse interaction avec D'autres serveurs comme MySQL, Postgres, MongoDB. Ils sont utiles pour émuler les splits réseau, les chutes de paquets, etc. Ces tests sont exécutés sous Docker et créent plusieurs conteneurs avec divers logiciels. - -Voir `tests/integration/README.md` sur la façon d'exécuter ces tests. - -Notez que l'intégration de ClickHouse avec des pilotes tiers n'est pas testée. De plus, nous n'avons actuellement pas de tests d'intégration avec nos pilotes JDBC et ODBC. - -## Les Tests Unitaires {#unit-tests} - -Les tests unitaires sont utiles lorsque vous voulez tester non pas le ClickHouse dans son ensemble, mais une seule bibliothèque ou classe isolée. Vous pouvez activer ou désactiver la génération de tests avec `ENABLE_TESTS` Option CMake. Les tests unitaires (et autres programmes de test) sont situés dans `tests` sous-répertoires à travers le code. Pour exécuter des tests unitaires, tapez `ninja test`. Certains tests utilisent `gtest`, mais certains ne sont que des programmes qui renvoient un code de sortie non nul en cas d'échec du test. - -Ce n'est pas nécessairement d'avoir des tests unitaires si le code est déjà couvert par des tests fonctionnels (et les tests fonctionnels sont généralement beaucoup plus simples à utiliser). - -## Tests De Performance {#performance-tests} - -Les tests de Performance permettent de mesurer et de comparer les performances d'une partie isolée de ClickHouse sur des requêtes synthétiques. Les Tests sont situés à `tests/performance`. Chaque test est représenté par `.xml` fichier avec description du cas de test. Les Tests sont exécutés avec `clickhouse performance-test` outil (qui est incorporé dans `clickhouse` binaire). Voir `--help` pour l'invocation. - -Chaque essai d'exécuter une ou plusieurs requêtes (éventuellement avec des combinaisons de paramètres) dans une boucle avec certaines conditions pour l'arrêt (comme “maximum execution speed is not changing in three seconds”) et mesurer certaines mesures sur les performances de la requête (comme “maximum execution speed”). Certains tests peuvent contenir des conditions préalables sur un ensemble de données de test préchargé. - -Si vous souhaitez améliorer les performances de ClickHouse dans certains scénarios, et si des améliorations peuvent être observées sur des requêtes simples, il est fortement recommandé d'écrire un test de performance. Il est toujours logique d'utiliser `perf top` ou d'autres outils perf pendant vos tests. - -## Outils et Scripts de Test {#test-tools-and-scripts} - -Certains programmes dans `tests` directory ne sont pas des tests préparés, mais sont des outils de test. Par exemple, pour `Lexer` il est un outil `src/Parsers/tests/lexer` Cela fait juste la tokenisation de stdin et écrit le résultat colorisé dans stdout. Vous pouvez utiliser ce genre d'outils comme exemples de code et pour l'exploration et les tests manuels. - -Vous pouvez également placer une paire de fichiers `.sh` et `.reference` avec l'outil pour l'exécuter sur une entrée prédéfinie - alors le résultat du script peut être comparé à `.reference` fichier. Ce genre de tests ne sont pas automatisés. - -## Divers Tests {#miscellaneous-tests} - -Il existe des tests pour les dictionnaires externes situés à `tests/external_dictionaries` et pour machine appris modèles dans `tests/external_models`. Ces tests ne sont pas mis à jour et doivent être transférés aux tests d'intégration. - -Il y a un test séparé pour les inserts de quorum. Ce test exécute le cluster ClickHouse sur des serveurs séparés et émule divers cas d'échec: scission réseau, chute de paquets (entre les nœuds ClickHouse, entre Clickhouse et ZooKeeper, entre le serveur ClickHouse et le client, etc.), `kill -9`, `kill -STOP` et `kill -CONT` , comme [Jepsen](https://aphyr.com/tags/Jepsen). Ensuite, le test vérifie que toutes les insertions reconnues ont été écrites et que toutes les insertions rejetées ne l'ont pas été. - -Le test de Quorum a été écrit par une équipe distincte avant que ClickHouse ne soit open-source. Cette équipe ne travaille plus avec ClickHouse. Test a été écrit accidentellement en Java. Pour ces raisons, quorum test doit être réécrit et déplacé vers tests d'intégration. - -## Les Tests Manuels {#manual-testing} - -Lorsque vous développez une nouvelle fonctionnalité, il est raisonnable de tester également manuellement. Vous pouvez le faire avec les étapes suivantes: - -Construire ClickHouse. Exécuter ClickHouse à partir du terminal: changer le répertoire à `programs/clickhouse-server` et de l'exécuter avec `./clickhouse-server`. Il utilisera la configuration (`config.xml`, `users.xml` et les fichiers à l'intérieur `config.d` et `users.d` répertoires) à partir du répertoire courant par défaut. Pour vous connecter au serveur ClickHouse, exécutez `programs/clickhouse-client/clickhouse-client`. - -Notez que tous les outils clickhouse (serveur, client, etc.) ne sont que des liens symboliques vers un seul binaire nommé `clickhouse`. Vous pouvez trouver ce binaire à `programs/clickhouse`. Tous les outils peuvent également être invoquée comme `clickhouse tool` plutôt `clickhouse-tool`. - -Alternativement, vous pouvez installer le paquet ClickHouse: soit une version stable du référentiel Yandex, soit vous pouvez créer un paquet pour vous-même avec `./release` dans les sources de ClickHouse racine. Puis démarrez le serveur avec `sudo service clickhouse-server start` (ou stop pour arrêter le serveur). Rechercher des journaux à `/etc/clickhouse-server/clickhouse-server.log`. - -Lorsque ClickHouse est déjà installé sur votre système, vous pouvez créer un nouveau `clickhouse` binaire et remplacer le binaire: - -``` bash -$ sudo service clickhouse-server stop -$ sudo cp ./clickhouse /usr/bin/ -$ sudo service clickhouse-server start -``` - -Vous pouvez également arrêter system clickhouse-server et exécuter le vôtre avec la même configuration mais en vous connectant au terminal: - -``` bash -$ sudo service clickhouse-server stop -$ sudo -u clickhouse /usr/bin/clickhouse server --config-file /etc/clickhouse-server/config.xml -``` - -Exemple avec gdb: - -``` bash -$ sudo -u clickhouse gdb --args /usr/bin/clickhouse server --config-file /etc/clickhouse-server/config.xml -``` - -Si le système clickhouse-server est déjà en cours d'exécution et que vous ne voulez pas l'arrêter, vous pouvez modifier les numéros de port dans votre `config.xml` (ou de les remplacer dans un fichier `config.d` répertoire), fournissez le chemin de données approprié, et exécutez-le. - -`clickhouse` binary n'a presque aucune dépendance et fonctionne sur un large éventail de distributions Linux. Rapide et sale de tester vos modifications sur un serveur, vous pouvez simplement `scp` votre douce construite `clickhouse` binaire à votre serveur et ensuite l'exécuter comme dans les exemples ci-dessus. - -## L'Environnement De Test {#testing-environment} - -Avant de publier la version stable, nous la déployons sur l'environnement de test. L'environnement de test est un cluster processus 1/39 partie de [Yandex.Metrica](https://metrica.yandex.com/) données. Nous partageons notre environnement de test avec Yandex.Metrica de l'équipe. ClickHouse est mis à niveau sans temps d'arrêt au-dessus des données existantes. Nous regardons d'abord que les données sont traitées avec succès sans retard par rapport au temps réel, la réplication continue à fonctionner et il n'y a pas de problèmes visibles pour Yandex.Metrica de l'équipe. Première vérification peut être effectuée de la façon suivante: - -``` sql -SELECT hostName() AS h, any(version()), any(uptime()), max(UTCEventTime), count() FROM remote('example01-01-{1..3}t', merge, hits) WHERE EventDate >= today() - 2 GROUP BY h ORDER BY h; -``` - -Dans certains cas, nous déployons également à l'environnement de test de nos équipes d'amis dans Yandex: marché, Cloud, etc. Nous avons également des serveurs matériels qui sont utilisés à des fins de développement. - -## Les Tests De Charge {#load-testing} - -Après le déploiement dans l'environnement de test, nous exécutons des tests de charge avec des requêtes du cluster de production. Ceci est fait manuellement. - -Assurez-vous que vous avez activé `query_log` sur votre cluster de production. - -Recueillir le journal des requêtes pour une journée ou plus: - -``` bash -$ clickhouse-client --query="SELECT DISTINCT query FROM system.query_log WHERE event_date = today() AND query LIKE '%ym:%' AND query NOT LIKE '%system.query_log%' AND type = 2 AND is_initial_query" > queries.tsv -``` - -C'est une façon compliquée exemple. `type = 2` filtrera les requêtes exécutées avec succès. `query LIKE '%ym:%'` est de sélectionner les requêtes de Yandex.Metrica. `is_initial_query` est de sélectionner uniquement les requêtes initiées par le client, pas par ClickHouse lui-même (en tant que partie du traitement de requête distribué). - -`scp` ce journal à votre cluster de test et l'exécuter comme suit: - -``` bash -$ clickhouse benchmark --concurrency 16 < queries.tsv -``` - -(probablement vous voulez aussi spécifier un `--user`) - -Ensuite, laissez-le pour une nuit ou un week-end et allez vous reposer. - -Tu devrais vérifier ça `clickhouse-server` ne plante pas, l'empreinte mémoire est limitée et les performances ne se dégradent pas au fil du temps. - -Les délais précis d'exécution des requêtes ne sont pas enregistrés et ne sont pas comparés en raison de la grande variabilité des requêtes et de l'environnement. - -## Essais De Construction {#build-tests} - -Les tests de construction permettent de vérifier que la construction n'est pas interrompue sur diverses configurations alternatives et sur certains systèmes étrangers. Les Tests sont situés à `ci` répertoire. Ils exécutent build from source à L'intérieur de Docker, Vagrant, et parfois avec `qemu-user-static` à l'intérieur de Docker. Ces tests sont en cours de développement et les essais ne sont pas automatisées. - -Motivation: - -Normalement, nous libérons et exécutons tous les tests sur une seule variante de construction ClickHouse. Mais il existe des variantes de construction alternatives qui ne sont pas complètement testées. Exemple: - -- construire sur FreeBSD; -- construire sur Debian avec les bibliothèques des paquets système; -- construire avec des liens partagés de bibliothèques; -- construire sur la plate-forme AArch64; -- construire sur la plate-forme PowerPc. - -Par exemple, construire avec des paquets système est une mauvaise pratique, car nous ne pouvons pas garantir quelle version exacte des paquets un système aura. Mais c'est vraiment nécessaire pour les responsables Debian. Pour cette raison, nous devons au moins soutenir cette variante de construction. Un autre exemple: la liaison partagée est une source commune de problèmes, mais elle est nécessaire pour certains amateurs. - -Bien que nous ne puissions pas exécuter tous les tests sur toutes les variantes de builds, nous voulons vérifier au moins que les différentes variantes de build ne sont pas cassées. Pour cela nous utilisons les essais de construction. - -## Test de compatibilité du protocole {#testing-for-protocol-compatibility} - -Lorsque nous étendons le protocole réseau ClickHouse, nous testons manuellement que l'ancien clickhouse-client fonctionne avec le nouveau clickhouse-server et que le nouveau clickhouse-client fonctionne avec l'ancien clickhouse-server (simplement en exécutant des binaires à partir des paquets correspondants). - -## L'aide du Compilateur {#help-from-the-compiler} - -Code ClickHouse principal (qui est situé dans `dbms` annuaire) est construit avec `-Wall -Wextra -Werror` et avec quelques avertissements supplémentaires activés. Bien que ces options ne soient pas activées pour les bibliothèques tierces. - -Clang a des avertissements encore plus utiles - vous pouvez les chercher avec `-Weverything` et choisissez quelque chose à construire par défaut. - -Pour les builds de production, gcc est utilisé (il génère toujours un code légèrement plus efficace que clang). Pour le développement, clang est généralement plus pratique à utiliser. Vous pouvez construire sur votre propre machine avec le mode débogage (pour économiser la batterie de votre ordinateur portable), mais veuillez noter que le compilateur est capable de générer plus d'Avertissements avec `-O3` grâce à une meilleure analyse du flux de contrôle et de l'inter-procédure. Lors de la construction avec clang avec le mode débogage, la version de débogage de `libc++` est utilisé qui permet d'attraper plus d'erreurs à l'exécution. - -## Désinfectant {#sanitizers} - -**Désinfectant d'adresse**. -Nous exécutons des tests fonctionnels et d'intégration sous ASan sur la base de per-commit. - -**Valgrind (Memcheck)**. -Nous effectuons des tests fonctionnels sous Valgrind pendant la nuit. Cela prend plusieurs heures. Actuellement il y a un faux positif connu dans `re2` bibliothèque, consultez [cet article](https://research.swtch.com/sparse). - -**Désinfectant de comportement indéfini.** -Nous exécutons des tests fonctionnels et d'intégration sous ASan sur la base de per-commit. - -**Désinfectant pour filetage**. -Nous exécutons des tests fonctionnels sous TSan sur la base de per-commit. Nous n'exécutons toujours pas de tests D'intégration sous TSan sur la base de la validation. - -**Mémoire de désinfectant**. -Actuellement, nous n'utilisons toujours pas MSan. - -**Débogueur allocateur.** -Version de débogage de `jemalloc` est utilisé pour la construction de débogage. - -## Fuzzing {#fuzzing} - -Clickhouse fuzzing est implémenté à la fois en utilisant [libFuzzer](https://llvm.org/docs/LibFuzzer.html) et des requêtes SQL aléatoires. -Tous les tests de fuzz doivent être effectués avec des désinfectants (adresse et indéfini). - -LibFuzzer est utilisé pour les tests de fuzz isolés du code de la bibliothèque. Les Fuzzers sont implémentés dans le cadre du code de test et ont “_fuzzer” nom postfixes. -Exemple Fuzzer peut être trouvé à `src/Parsers/tests/lexer_fuzzer.cpp`. Les configs, dictionnaires et corpus spécifiques à LibFuzzer sont stockés à `tests/fuzz`. -Nous vous encourageons à écrire des tests fuzz pour chaque fonctionnalité qui gère l'entrée de l'utilisateur. - -Fuzzers ne sont pas construits par défaut. Pour construire fuzzers à la fois `-DENABLE_FUZZING=1` et `-DENABLE_TESTS=1` options doivent être définies. -Nous vous recommandons de désactiver Jemalloc lors de la construction de fuzzers. Configuration utilisée pour intégrer clickhouse fuzzing à -Google OSS-Fuzz peut être trouvé à `docker/fuzz`. - -Nous utilisons également un simple test fuzz pour générer des requêtes SQL aléatoires et vérifier que le serveur ne meurt pas en les exécutant. -Vous pouvez le trouver dans `00746_sql_fuzzy.pl`. Ce test doit être exécuté en continu (pendant la nuit et plus longtemps). - -## Audit De Sécurité {#security-audit} - -Les gens de L'équipe de sécurité Yandex font un aperçu de base des capacités de ClickHouse du point de vue de la sécurité. - -## Analyseurs Statiques {#static-analyzers} - -Nous courons `PVS-Studio` par commettre base. Nous avons évalué `clang-tidy`, `Coverity`, `cppcheck`, `PVS-Studio`, `tscancode`. Vous trouverez des instructions pour l'utilisation dans `tests/instructions/` répertoire. Aussi, vous pouvez lire [l'article en russe](https://habr.com/company/yandex/blog/342018/). - -Si vous utilisez `CLion` en tant QU'IDE, vous pouvez tirer parti de certains `clang-tidy` contrôles de la boîte. - -## Durcir {#hardening} - -`FORTIFY_SOURCE` est utilisé par défaut. C'est presque inutile, mais cela a toujours du sens dans de rares cas et nous ne le désactivons pas. - -## Code De Style {#code-style} - -Les règles de style de Code sont décrites [ici](https://clickhouse.tech/docs/en/development/style/). - -Pour vérifier certaines violations de style courantes, vous pouvez utiliser `utils/check-style` script. - -Pour forcer le style approprié de votre code, vous pouvez utiliser `clang-format`. Fichier `.clang-format` est situé à la racine des sources. Il correspond principalement à notre style de code réel. Mais il n'est pas recommandé d'appliquer `clang-format` pour les fichiers existants, car il rend le formatage pire. Vous pouvez utiliser `clang-format-diff` outil que vous pouvez trouver dans clang référentiel source. - -Alternativement vous pouvez essayer `uncrustify` outil pour reformater votre code. La Configuration est en `uncrustify.cfg` dans la racine des sources. Il est moins testé que `clang-format`. - -`CLion` a son propre formateur de code qui doit être réglé pour notre style de code. - -## Tests Metrica B2B {#metrica-b2b-tests} - -Chaque version de ClickHouse est testée avec les moteurs Yandex Metrica et AppMetrica. Les versions de test et stables de ClickHouse sont déployées sur des machines virtuelles et exécutées avec une petite copie de metrica engine qui traite un échantillon fixe de données d'entrée. Ensuite, les résultats de deux instances de metrica engine sont comparés ensemble. - -Ces tests sont automatisés par une équipe distincte. En raison du nombre élevé de pièces en mouvement, les tests échouent la plupart du temps complètement raisons, qui sont très difficiles à comprendre. Très probablement, ces tests ont une valeur négative pour nous. Néanmoins, ces tests se sont révélés utiles dans environ une ou deux fois sur des centaines. - -## La Couverture De Test {#test-coverage} - -En juillet 2018, nous ne suivons pas la couverture des tests. - -## Automatisation Des Tests {#test-automation} - -Nous exécutons des tests avec Yandex CI interne et le système d'automatisation des tâches nommé “Sandbox”. - -Les travaux de construction et les tests sont exécutés dans Sandbox sur une base de validation. Les paquets résultants et les résultats des tests sont publiés dans GitHub et peuvent être téléchargés par des liens directs. Les artefacts sont stockés éternellement. Lorsque vous envoyez une demande de tirage sur GitHub, nous l'étiquetons comme “can be tested” et notre système CI construira des paquets ClickHouse (release, debug, avec un désinfectant d'adresse, etc.) pour vous. - -Nous n'utilisons pas Travis CI en raison de la limite de temps et de puissance de calcul. -On n'utilise pas Jenkins. Il a été utilisé avant et maintenant nous sommes heureux de ne pas utiliser Jenkins. - -[Article Original](https://clickhouse.tech/docs/en/development/tests/) diff --git a/docs/fr/development/tests.md b/docs/fr/development/tests.md new file mode 120000 index 00000000000..c03d36c3916 --- /dev/null +++ b/docs/fr/development/tests.md @@ -0,0 +1 @@ +../../en/development/tests.md \ No newline at end of file diff --git a/docs/ja/development/tests.md b/docs/ja/development/tests.md deleted file mode 100644 index e41032a6b76..00000000000 --- a/docs/ja/development/tests.md +++ /dev/null @@ -1,261 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd -toc_priority: 69 -toc_title: "ClickHouse\u30C6\u30B9\u30C8\u306E\u5B9F\u884C\u65B9\u6CD5" ---- - -# ClickHouseのテスト {#clickhouse-testing} - -## 機能テスト {#functional-tests} - -機能テストは、最も簡単で使いやすいです。 ClickHouseの機能のほとんどは機能テストでテストすることができ、そのようにテストできるClickHouseコードのすべての変更に使用することが必須です。 - -各機能テストは、実行中のClickHouseサーバーに一つまたは複数のクエリを送信し、結果を参照と比較します。 - -テストは `queries` ディレクトリ。 サブディレクトリは二つあります: `stateless` と `stateful`. ステートレステストは、プリロードされたテストデータなしでクエリを実行します。 状態での検査が必要とな予圧試験データからのYandex.Metricaおよび一般に利用できない。 私たちは使用する傾向があります `stateless` テストと新しい追加を避ける `stateful` テストだ - -それぞれの試験できるの種類: `.sql` と `.sh`. `.sql` testは、パイプ処理される単純なSQLスクリプトです `clickhouse-client --multiquery --testmode`. `.sh` testは、それ自体で実行されるスクリプトです。 - -すべてのテストを実行するには、 `clickhouse-test` ツール。 見て! `--help` 可能なオプションのリスト。 できるだけ実行すべての試験または実行のサブセットの試験フィルター部分文字列の試験名: `./clickhouse-test substring`. - -機能テストを呼び出す最も簡単な方法は、コピーすることです `clickhouse-client` に `/usr/bin/`,run `clickhouse-server` そして、実行 `./clickhouse-test` 独自のディレクトリから。 - -新しいテストを追加するには、 `.sql` または `.sh` ファイル `queries/0_stateless` ディレクトリでチェックを手動でその生成 `.reference` 次の方法でファイル: `clickhouse-client -n --testmode < 00000_test.sql > 00000_test.reference` または `./00000_test.sh > ./00000_test.reference`. - -テストでは、テーブルのみを使用(create、dropなど)する必要があります `test` また、テストでは一時テーブルを使用することもできます。 - -機能テストで分散クエリを使用する場合は、以下を利用できます `remote` テーブル関数 `127.0.0.{1..2}` または、サーバー設定ファイルで次のように定義済みのテストクラスタを使用できます `test_shard_localhost`. - -いくつかのテストには `zookeeper`, `shard` または `long` 彼らの名前で。 -`zookeeper` ZooKeeperを使用しているテスト用です。 `shard` そのテストのためです -サーバーにリッスンが必要 `127.0.0.*`; `distributed` または `global` 同じを持っている -意味だ `long` 少し長く実行されるテストのためのものです。 あなたはできる -disableこれらのグループの試験を使用 `--no-zookeeper`, `--no-shard` と -`--no-long` オプション、それぞれ。 - -## 既知のバグ {#known-bugs} - -機能テストで簡単に再現できるいくつかのバグがわかっている場合は、準備された機能テストを `tests/queries/bugs` ディレクトリ。 これらのテストは `tests/queries/0_stateless` バグが修正されたとき。 - -## 統合テスト {#integration-tests} - -統合テストでは、クラスター化された構成でClickHouseをテストし、Mysql、Postgres、MongoDBなどの他のサーバーとClickHouseの相互作用をテストできます。 これらをエミュレートするネットワーク分割、パケットの落下など。 これらの試験する方向に作用しDockerを複数の容器を様々なソフトウェアです。 - -見る `tests/integration/README.md` これらのテストを実行する方法について。 - -この統合ClickHouse第三者によるドライバーではない。 また、現在、JDBCおよびODBCドライバとの統合テストはありません。 - -## 単体テスト {#unit-tests} - -単体テストは、ClickHouse全体ではなく、単一の孤立したライブラリまたはクラスをテストする場合に便利です。 テストのビルドを有効または無効にするには `ENABLE_TESTS` CMakeオプション。 単体テスト(およびその他のテストプログラム)は `tests` コード全体のサブディレクトリ。 単体テストを実行するには、 `ninja test`. 一部のテストでは `gtest` しかし、いくつかは、テストの失敗でゼロ以外の終了コードを返すプログラムです。 - -コードがすでに機能テストでカバーされている場合は、必ずしも単体テストを持つとは限りません(機能テストは通常ははるかに簡単です)。 - -## 性能テスト {#performance-tests} - -パフォーマ テストは `tests/performance`. それぞれの試験に代表される `.xml` テストケースの説明を持つファイル。 テストは以下で実行されます `clickhouse performance-test` ツール(埋め込まれている `clickhouse` バイナリ)。 見る `--help` 呼び出し用。 - -それぞれの試験実行または複数のクエリ(このパラメータの組み合わせ)のループ条件のための停止など “maximum execution speed is not changing in three seconds” 測定一部の指標につクエリの性能など “maximum execution speed”). いくつかの試験を含むことができ前提条件に予圧試験データを得る。 - -いくつかのシナリオでClickHouseのパフォーマンスを向上させたい場合や、単純なクエリで改善が見られる場合は、パフォーマンステストを作成することを強 いう意味があるのに使用 `perf top` またはあなたのテストの間の他のperf用具。 - -## テストツールとスクリプ {#test-tools-and-scripts} - -一部のプログラム `tests` ディレク 例えば、 `Lexer` ツールがあります `src/Parsers/tests/lexer` それはstdinのトークン化を行い、色付けされた結果をstdoutに書き込みます。 これらの種類のツールは、コード例として、また探索と手動テストに使用できます。 - -でも一対のファイル `.sh` と `.reference` いくつかの事前定義された入力でそれを実行するためのツールと一緒に-その後、スクリプトの結果は `.reference` ファイル これらの種類のテストは自動化されていません。 - -## その他のテスト {#miscellaneous-tests} - -外部辞書のテストは次の場所にあります `tests/external_dictionaries` そして機械学んだモデルのために `tests/external_models`. これらのテストは更新されず、統合テストに転送する必要があります。 - -クォーラム挿入には別のテストがあります。 このテストでは、ネットワーク分割、パケットドロップ(ClickHouseノード間、ClickHouseとZooKeeper間、ClickHouseサーバーとクライアント間など)など、さまざまな障害ケースをエミュレートします。), `kill -9`, `kill -STOP` と `kill -CONT` 例えば [ジェプセン](https://aphyr.com/tags/Jepsen). その後、試験チェックすべての認識を挿入したすべて拒否された挿入しました。 - -定足数を緩和試験の筆に別々のチーム前ClickHouseしたオープン達した. このチームはClickHouseでは動作しなくなりました。 テストは誤ってJavaで書かれました。 これらのことから、決議の定足数テストを書き換え及び移転統合。 - -## 手動テスト {#manual-testing} - -新しい機能を開発するときは、手動でもテストするのが妥当です。 これを行うには、次の手順を実行します: - -ClickHouseを構築します。 ターミナルからClickHouseを実行します。 `programs/clickhouse-server` そして、それを実行します `./clickhouse-server`. それは構成を使用します (`config.xml`, `users.xml` そして内のファイル `config.d` と `users.d` ディレクトリ)から、現在のディレクトリがデフォルトです。 ClickHouseサーバーに接続するには、以下を実行します `programs/clickhouse-client/clickhouse-client`. - -これらのclickhouseツール(サーバ、クライアント、などだそうでsymlinks単一のバイナリ名 `clickhouse`. このバイナリは `programs/clickhouse`. すべてのツ `clickhouse tool` 代わりに `clickhouse-tool`. - -またインストールすることができClickHouseパッケージは安定したリリースからのYandexリポジトリあるいはすることで作ることができるパッケージで `./release` ClickHouseソースルートで. 次に、サーバーを起動します `sudo service clickhouse-server start` (または停止してサーバーを停止します)。 ログを探す `/etc/clickhouse-server/clickhouse-server.log`. - -時ClickHouseでに既にインストールされているシステムを構築できる新しい `clickhouse` 既存のバイナリを置き換えます: - -``` bash -$ sudo service clickhouse-server stop -$ sudo cp ./clickhouse /usr/bin/ -$ sudo service clickhouse-server start -``` - -また、システムclickhouse-serverを停止し、同じ構成ではなく端末にログインして独自のものを実行することもできます: - -``` bash -$ sudo service clickhouse-server stop -$ sudo -u clickhouse /usr/bin/clickhouse server --config-file /etc/clickhouse-server/config.xml -``` - -Gdbの例: - -``` bash -$ sudo -u clickhouse gdb --args /usr/bin/clickhouse server --config-file /etc/clickhouse-server/config.xml -``` - -システムclickhouse-serverがすでに実行されていて、それを停止したくない場合は、次のポート番号を変更できます `config.xml` (または、ファイル内でそれらを上書きする `config.d` ディレクトリ)、適切なデータパスを提供し、それを実行します。 - -`clickhouse` バイナリーはほとんどない依存関係の作品を広い範囲のLinuxディストリビューション. サーバー上で変更を迅速かつ汚いテストするには、次のことができます `scp` あなたの新鮮な構築 `clickhouse` あなたのサーバーにバイナリし、上記の例のように実行します。 - -## テスト環境 {#testing-environment} - -リリースを安定版として公開する前に、テスト環境に展開します。 テスト環境は1/39の部分を処理する集りです [Yandex.メトリカ](https://metrica.yandex.com/) データ テスト環境をYandexと共有しています。メトリカ-チーム ClickHouseは既存のデータの上にダウンタイムなしで改善される。 私たちは、データがリアルタイムから遅れることなく正常に処理され、複製が動作し続け、Yandexに見える問題はないことを最初に見ています。メトリカ-チーム 最初のチェックは、次の方法で行うことができます: - -``` sql -SELECT hostName() AS h, any(version()), any(uptime()), max(UTCEventTime), count() FROM remote('example01-01-{1..3}t', merge, hits) WHERE EventDate >= today() - 2 GROUP BY h ORDER BY h; -``` - -市場、クラウドなど:いくつかのケースでは、我々はまた、Yandexの中で私たちの友人チームのテスト環境に展開します また、開発目的で使用されるハードウェアサーバーもあります。 - -## 負荷テスト {#load-testing} - -後の展開を試験環境を実行負荷テストクエリから生産ます。 これは手動で行われます。 - -有効にしていることを確認します `query_log` 運用クラスター上。 - -一日以上のクエリログを収集する: - -``` bash -$ clickhouse-client --query="SELECT DISTINCT query FROM system.query_log WHERE event_date = today() AND query LIKE '%ym:%' AND query NOT LIKE '%system.query_log%' AND type = 2 AND is_initial_query" > queries.tsv -``` - -これは複雑な例です。 `type = 2` 正常に実行されたクエリをフィルタ処理します。 `query LIKE '%ym:%'` Yandexから関連するクエリを選択することです。メトリカ `is_initial_query` ClickHouse自体ではなく、クライアントによって開始されたクエリのみを選択することです(分散クエリ処理の一部として)。 - -`scp` このログをテストクラスタに記録し、次のように実行します: - -``` bash -$ clickhouse benchmark --concurrency 16 < queries.tsv -``` - -(おそらくあなたはまた、 `--user`) - -それから夜または週末のためにそれを残し、残りを取る行きなさい。 - -きることを確認 `clickhouse-server` なクラッシュメモリのフットプリントは有界性なつ品位を傷つける。 - -クエリと環境の変動が大きいため、正確なクエリ実行タイミングは記録されず、比較されません。 - -## ビルドテスト {#build-tests} - -構築を試験できることを確認の構築においても様々な代替構成されており、外国のシステム。 テストは `ci` ディレクトリ。 Docker、Vagrant、時には以下のようなソースからビルドを実行します `qemu-user-static` ドッカー内部。 これらのテストは開発中であり、テストの実行は自動化されません。 - -動機: - -通常、ClickHouse buildの単一のバリアントですべてのテストをリリースして実行します。 しかし、徹底的にテストされていない別のビルド変種があります。 例: - -- FreeBSD上でビルド; -- をDebianを対象として図書館システムのパッケージ; -- ライブラリの共有リンクでビルド; -- AArch64プラットフォ; -- PowerPcプラットフォーム上で構築。 - -たとえば、システムパッケージを使用したビルドは悪い習慣です。 しかし、これは本当にDebianメンテナに必要です。 このため、少なくともこのビルドの変種をサポートする必要があります。 別の例:共有リンクは一般的な問題の原因ですが、一部の愛好家にとって必要です。 - -ができませんので実行した全試験はすべての変異体を構築し、チェックしたい少なくとも上記に記載された各種の構築異な破となりました。 この目的のためにビルドテストを使用します。 - -## プロトコル互換性のテスト {#testing-for-protocol-compatibility} - -ClickHouse network protocolを拡張すると、古いclickhouse-clientが新しいclickhouse-serverで動作し、新しいclickhouse-clientが古いclickhouse-serverで動作することを手動でテストします(対応するパッケージからバイナリを - -## コンパイラからのヘルプ {#help-from-the-compiler} - -メインクリックハウスコード(にある `dbms` ディレクトリ)は `-Wall -Wextra -Werror` そして、いくつかの追加の有効な警告と。 これらのオプションは有効になっていないためにサードパーティーのライブラリ. - -Clangにはさらに便利な警告があります。 `-Weverything` デフォルトのビルドに何かを選ぶ。 - -本番ビルドでは、gccが使用されます(clangよりもやや効率的なコードが生成されます)。 開発のために、clangは通常、使用する方が便利です。 あなたは(あなたのラップトップのバッテリーを節約するために)デバッグモードで自分のマシン上で構築することができますが、コンパイラがでより `-O3` よりよい制御フローおよびinter-procedure分析が原因で。 Clangでビルドする場合, `libc++` の代わりに使用されます。 `libstdc++` そして、デバッグモードでビルドするとき、 `libc++` 使用可能にするにはより誤差があります。. - -## サニタイザー {#sanitizers} - -**アドレスsanitizer**. -私たちは、コミットごとにASanの下で機能テストと統合テストを実行します。 - -**ヴァルグリンド(曖昧さ回避)**. -私たちは一晩Valgrindの下で機能テストを実行します。 数時間かかります。 現在知られている偽陽性があります `re2` 図書館、参照 [この記事](https://research.swtch.com/sparse). - -**未定義の動作のサニタイザー。** -私たちは、コミットごとにASanの下で機能テストと統合テストを実行します。 - -**糸のsanitizer**. -私たちは、コミットごとにTSanの下で機能テストを実行します。 コミットごとにTSanの下で統合テストを実行することはまだありません。 - -**メモリサニタイザー**. -現在、我々はまだMSanを使用していません。 - -**デバッグアロケータ。** -デバッグバージョン `jemalloc` デバッグビルドに使用されます。 - -## ファジング {#fuzzing} - -ClickHouseファジングは、両方を使用して実装されます [libFuzzer](https://llvm.org/docs/LibFuzzer.html) とランダムSQLクエリ。 -すべてのファズテストは、サニタイザー(アドレスと未定義)で実行する必要があります。 - -LibFuzzerは、ライブラリコードの分離ファズテストに使用されます。 ファザーはテストコードの一部として実装され “_fuzzer” 名前の接尾辞。 -Fuzzerの例はで見つけることができます `src/Parsers/tests/lexer_fuzzer.cpp`. LibFuzzer固有の設定、辞書、およびコーパスは次の場所に格納されます `tests/fuzz`. -ご協力をお願いいたし書きファズ試験べての機能を取り扱うユーザー入力します。 - -ファザーはデフォルトではビルドされません。 両方のファザーを構築するには `-DENABLE_FUZZING=1` と `-DENABLE_TESTS=1` 選択は置かれるべきである。 -ファザーのビルド中にJemallocを無効にすることをお勧めします。 ClickHouseファジングを統合するために使用される設定 -Google OSS-Fuzzは次の場所にあります `docker/fuzz`. - -また簡単なファズ試験をランダムなSQLクエリーやことを確認するにはサーバーにな金型を実行します。 -それを見つけることができる `00746_sql_fuzzy.pl`. このテストは、継続的に実行する必要があります(一晩と長い)。 - -## セキュリティ監査 {#security-audit} - -人からのYandexセキュリティチームはいくつかの基本的な概要ClickHouse力からのセキュリティの観点から. - -## 静的アナライザ {#static-analyzers} - -私たちは走る `PVS-Studio` コミットごと。 私達は評価しました `clang-tidy`, `Coverity`, `cppcheck`, `PVS-Studio`, `tscancode`. 使用のための指示をで見つけます `tests/instructions/` ディレクトリ。 また読むことができます [ロシア語の記事](https://habr.com/company/yandex/blog/342018/). - -を使用する場合 `CLion` IDEとして、いくつかを活用できます `clang-tidy` 箱から出してチェックします。 - -## 硬化 {#hardening} - -`FORTIFY_SOURCE` デフォルトで使用されます。 それはほとんど役に立たないですが、まれに理にかなっており、それを無効にしません。 - -## コードスタイル {#code-style} - -コードのスタイルのルールを記述 [ここに](https://clickhouse.tech/docs/en/development/style/). - -チェックのための、共通したスタイル違反、利用できる `utils/check-style` スクリプト - -コードの適切なスタイルを強制するには、次のようにします `clang-format`. ファイル `.clang-format` ソースルートにあります。 実際のコードスタイルにほとんど対応しています。 しかし、適用することはお勧めしません `clang-format` 既存のファイルへの書式設定が悪化するためです。 以下を使用できます `clang-format-diff` clangソースリポジトリで見つけることができるツール。 - -あるいは、 `uncrustify` コードを再フォーマットするツール。 設定は次のとおりです `uncrustify.cfg` ソースルートで。 それはより少なくテストさ `clang-format`. - -`CLion` 独自のコードをフォーマッタしていると見ることができる調整のためのコードです。 - -## Metrica B2Bテスト {#metrica-b2b-tests} - -各ClickHouseリリースはYandex MetricaとAppMetricaエンジンでテストされます。 ClickHouseのテスト版と安定版はVmにデプロイされ、入力データの固定サンプルを処理するMetrica engineの小さなコピーで実行されます。 次に,Metricaエンジンの二つのインスタンスの結果を比較した。 - -これらの試験により自動化されており、別のチームです。 可動部分の高い数が原因で、テストは把握し非常ににくい完全に無関係な理由によって失敗ほとんどの時間です。 がこれらの試験は負の値です。 しかしこれらの試験することが明らかとなったが有用である一又は二倍の数百名 - -## テスト範囲 {#test-coverage} - -2018年現在、テストカバーは行っていない。 - -## テスト自動化 {#test-automation} - -Yandex内部CIとジョブ自動化システムという名前のテストを実行します “Sandbox”. - -ビルドジョブとテストは、コミットごとにSandboxで実行されます。 結果のパッケージとテスト結果はGitHubに公開され、直接リンクでダウンロードできます。 成果物は永遠に保存されます。 GitHubでプルリクエストを送信すると、次のようにタグ付けします “can be tested” そして私達のCIシステムはあなたのためのClickHouseのパッケージ(住所sanitizerの解放、デバッグ、等)を造ります。 - -時間と計算能力の限界のため、Travis CIは使用しません。 -ジェンキンスは使わない 以前は使用されていましたが、今はJenkinsを使用していません。 - -[元の記事](https://clickhouse.tech/docs/en/development/tests/) diff --git a/docs/ja/development/tests.md b/docs/ja/development/tests.md new file mode 120000 index 00000000000..c03d36c3916 --- /dev/null +++ b/docs/ja/development/tests.md @@ -0,0 +1 @@ +../../en/development/tests.md \ No newline at end of file diff --git a/docs/tr/development/tests.md b/docs/tr/development/tests.md deleted file mode 100644 index a0766e54ae7..00000000000 --- a/docs/tr/development/tests.md +++ /dev/null @@ -1,262 +0,0 @@ ---- -machine_translated: true -machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd -toc_priority: 69 -toc_title: "ClickHouse testleri nas\u0131l \xE7al\u0131\u015Ft\u0131r\u0131l\u0131\ - r" ---- - -# ClickHouse Testi {#clickhouse-testing} - -## Fonksiyonel Testler {#functional-tests} - -Fonksiyonel testler en basit ve kullanımı kolay olanlardır. ClickHouse özelliklerinin çoğu fonksiyonel testlerle test edilebilir ve bu şekilde test edilebilecek ClickHouse kodundaki her değişiklik için kullanılması zorunludur. - -Her işlevsel test, çalışan ClickHouse sunucusuna bir veya birden çok sorgu gönderir ve sonucu referansla karşılaştırır. - -Testler bulunur `queries` dizin. İki alt dizin var: `stateless` ve `stateful`. Durumsuz testler, önceden yüklenmiş test verileri olmadan sorguları çalıştırır - genellikle testin kendisinde anında küçük sentetik veri kümeleri oluştururlar. Durum bilgisi testleri, Yandex'ten önceden yüklenmiş test verileri gerektirir.Metrica ve halka açık değil. Biz sadece kullanmak eğilimindedir `stateless` testler ve yeni eklemekten kaçının `stateful` testler. - -Her test iki tipten biri olabilir: `.sql` ve `.sh`. `.sql` test için borulu basit SQL komut dosyasıdır `clickhouse-client --multiquery --testmode`. `.sh` test kendisi tarafından çalıştırılan bir komut dosyasıdır. - -Tüm testleri çalıştırmak için şunları kullanın `clickhouse-test` aracı. Bak `--help` Olası seçeneklerin listesi için. Sadece tüm testleri çalıştırmak veya test adı alt dize tarafından süzülmüş testlerin alt kümesini çalıştırabilirsiniz: `./clickhouse-test substring`. - -Fonksiyonel testleri çağırmanın en basit yolu kopyalamaktır `clickhouse-client` -e doğru `/usr/bin/`, çalıştırmak `clickhouse-server` ve sonra koş `./clickhouse-test` kendi dizininden. - -Yeni test eklemek için, bir `.sql` veya `.sh` dosya içinde `queries/0_stateless` dizin, elle kontrol edin ve sonra oluşturun `.reference` aşağıdaki şekilde dosya: `clickhouse-client -n --testmode < 00000_test.sql > 00000_test.reference` veya `./00000_test.sh > ./00000_test.reference`. - -Testler yalnızca tabloları (create, drop, vb.) kullanmalıdır `test` önceden oluşturulduğu varsayılır veritabanı; ayrıca testler geçici tablolar kullanabilirsiniz. - -İşlevsel testlerde dağıtılmış sorgular kullanmak istiyorsanız, kaldıraç `remote` tablo fonksiyonu ile `127.0.0.{1..2}` sunucunun kendisini sorgulaması için adresler; veya sunucu yapılandırma dosyasında önceden tanımlanmış test kümelerini kullanabilirsiniz `test_shard_localhost`. - -Bazı testler ile işaretlenir `zookeeper`, `shard` veya `long` kendi adlarına. -`zookeeper` ZooKeeper kullanan testler içindir. `shard` testler içindir -dinlemek için sunucu gerektirir `127.0.0.*`; `distributed` veya `global` aynı var -anlama. `long` bir saniye biraz daha uzun süren testler içindir. Yapabilirsin -kullanarak bu test gruplarını devre dışı bırakın `--no-zookeeper`, `--no-shard` ve -`--no-long` sırasıyla seçenekler. - -## Bilinen Hatalar {#known-bugs} - -Fonksiyonel testlerle kolayca çoğaltılabilen bazı hatalar biliyorsak, hazırlanmış fonksiyonel testleri `tests/queries/bugs` dizin. Bu testler taşınacaktır `tests/queries/0_stateless` hatalar düzeltildiğinde. - -## Entegrasyon Testleri {#integration-tests} - -Entegrasyon testleri, kümelenmiş konfigürasyonda Clickhouse'u ve MySQL, Postgres, MongoDB gibi diğer sunucularla ClickHouse etkileşimini test etmeyi sağlar. Ağ bölmelerini, paket damlalarını vb. taklit etmek için kullanışlıdırlar. Bu testler Docker altında çalıştırılır ve çeşitli yazılımlarla birden fazla konteyner oluşturur. - -Görmek `tests/integration/README.md` bu testlerin nasıl çalıştırılacağı hakkında. - -Clickhouse'un üçüncü taraf sürücülerle entegrasyonunun sınanmadığını unutmayın. Ayrıca şu anda JDBC ve ODBC sürücülerimizle entegrasyon testlerimiz yok. - -## Ünite Testleri {#unit-tests} - -Birim testleri, Clickhouse'u bir bütün olarak değil, tek bir yalıtılmış kitaplık veya sınıfı test etmek istediğinizde kullanışlıdır. Etkinleştirebilir veya devre dışı bırakma ile testlerin yapı `ENABLE_TESTS` Cmake seçeneği. Birim testleri (ve diğer test programları) bulunur `tests` kodun alt dizinleri. Birim testlerini çalıştırmak için şunları yazın `ninja test`. Bazı testler kullanın `gtest`, ancak bazıları test başarısızlığında sıfır olmayan çıkış kodunu döndüren programlardır. - -Kodun zaten işlevsel testler tarafından kapsanması durumunda birim testlerine sahip olmak zorunlu değildir (ve işlevsel testler genellikle kullanımı çok daha basittir). - -## Performans Testleri {#performance-tests} - -Performans testleri ölçmek ve sentetik sorguları ClickHouse bazı izole kısmının performansını karşılaştırmak için izin verir. Testler bulunur `tests/performance`. Her test ile temsil edilir `.xml` test durumunun açıklaması ile dosya. Testler ile çalıştırılır `clickhouse performance-test` Aracı (Bu gömülü `clickhouse` ikilik). Görmek `--help` çağırma için. - -Her test, durdurma için bazı koşullarla (örneğin, bir döngüde bir veya birden fazla sorgu (muhtemelen parametre kombinasyonlarıyla) çalıştırır “maximum execution speed is not changing in three seconds”) ve sorgu performansı ile ilgili bazı metrikleri ölçün (örneğin “maximum execution speed”). Bazı testler önceden yüklenmiş test veri kümesinde Önkoşullar içerebilir. - -Bazı senaryoda Clickhouse'un performansını artırmak istiyorsanız ve basit sorgularda iyileştirmeler gözlemlenebiliyorsa, bir performans testi yazmanız önerilir. Her zaman kullanmak mantıklı `perf top` testleriniz sırasında veya diğer perf araçları. - -## Test araçları ve komut dosyaları {#test-tools-and-scripts} - -Bazı programlar `tests` dizin testleri hazırlanmış değil, ancak test araçlarıdır. Örneğin, için `Lexer` bir araç var `src/Parsers/tests/lexer` bu sadece stdin'in tokenizasyonunu yapar ve renklendirilmiş sonucu stdout'a yazar. Bu tür araçları kod örnekleri olarak ve keşif ve manuel test için kullanabilirsiniz. - -Ayrıca Çift Dosya yerleştirebilirsiniz `.sh` ve `.reference` aracı ile birlikte bazı önceden tanımlanmış giriş üzerinde çalıştırmak için-daha sonra komut sonucu karşılaştırılabilir `.reference` Dosya. Bu tür testler otomatik değildir. - -## Çeşitli Testler {#miscellaneous-tests} - -Bulunan dış sözlükler için testler vardır `tests/external_dictionaries` ve makine öğrenilen modeller için `tests/external_models`. Bu testler güncelleştirilmez ve tümleştirme testlerine aktarılmalıdır. - -Çekirdek ekler için ayrı bir test var. Bu test, ayrı sunucularda ClickHouse kümesini çalıştırır ve çeşitli arıza durumlarını taklit eder: ağ bölünmesi, paket bırakma (ClickHouse düğümleri arasında, ClickHouse ve ZooKeeper arasında, ClickHouse sunucusu ve istemci arasında, vb.), `kill -9`, `kill -STOP` ve `kill -CONT` , istemek [Jepsen](https://aphyr.com/tags/Jepsen). Daha sonra test, kabul edilen tüm eklerin yazıldığını ve reddedilen tüm eklerin olmadığını kontrol eder. - -Clickhouse açık kaynaklı önce çekirdek testi ayrı ekip tarafından yazılmıştır. Bu takım artık ClickHouse ile çalışmıyor. Test yanlışlıkla Java ile yazılmıştır. Bu nedenlerden dolayı, çekirdek testi yeniden yazılmalı ve entegrasyon testlerine taşınmalıdır. - -## Manuel Test {#manual-testing} - -Yeni bir özellik geliştirdiğinizde, el ile de test etmek mantıklıdır. Bunu aşağıdaki adımlarla yapabilirsiniz: - -ClickHouse Oluşturun. Terminalden Clickhouse'u çalıştırın: dizini değiştir `programs/clickhouse-server` ve ile çalıştırın `./clickhouse-server`. Bu yapılandırma kullanacak (`config.xml`, `users.xml` ve içindeki dosyalar `config.d` ve `users.d` dizinler) geçerli dizinden varsayılan olarak. ClickHouse sunucusuna bağlanmak için, çalıştırın `programs/clickhouse-client/clickhouse-client`. - -Tüm clickhouse araçlarının (sunucu, istemci, vb.) sadece tek bir ikili için symlinks olduğunu unutmayın `clickhouse`. Bu ikili bulabilirsiniz `programs/clickhouse`. Tüm araçlar olarak da çağrılabilir `clickhouse tool` yerine `clickhouse-tool`. - -Alternatif olarak ClickHouse paketini yükleyebilirsiniz: Yandex deposundan kararlı sürüm veya kendiniz için paket oluşturabilirsiniz `./release` ClickHouse kaynakları kökünde. Ardından sunucuyu şu şekilde başlatın `sudo service clickhouse-server start` (veya sunucuyu durdurmak için durdurun). Günlükleri arayın `/etc/clickhouse-server/clickhouse-server.log`. - -ClickHouse sisteminizde zaten yüklü olduğunda, yeni bir `clickhouse` ikili ve mevcut ikili değiştirin: - -``` bash -$ sudo service clickhouse-server stop -$ sudo cp ./clickhouse /usr/bin/ -$ sudo service clickhouse-server start -``` - -Ayrıca sistem clickhouse-server durdurmak ve aynı yapılandırma ile ancak terminale günlüğü ile kendi çalıştırabilirsiniz: - -``` bash -$ sudo service clickhouse-server stop -$ sudo -u clickhouse /usr/bin/clickhouse server --config-file /etc/clickhouse-server/config.xml -``` - -Gdb ile örnek: - -``` bash -$ sudo -u clickhouse gdb --args /usr/bin/clickhouse server --config-file /etc/clickhouse-server/config.xml -``` - -Sistem clickhouse-sunucu zaten çalışıyorsa ve bunu durdurmak istemiyorsanız, sizin port numaralarını değiştirebilirsiniz `config.xml` (veya bunları bir dosyada geçersiz kılma `config.d` dizin), uygun veri yolu sağlayın ve çalıştırın. - -`clickhouse` ikili neredeyse hiçbir bağımlılıkları vardır ve Linux dağıtımları geniş genelinde çalışır. Hızlı ve kirli bir sunucuda değişikliklerinizi test etmek için, sadece yapabilirsiniz `scp` taze inşa `clickhouse` sunucunuza ikili ve daha sonra yukarıdaki örneklerde olduğu gibi çalıştırın. - -## Test Ortamı {#testing-environment} - -Kararlı olarak yayınlamadan önce test ortamında dağıtın. Test ortamı, 1/39 bölümünü işleyen bir kümedir [Üye.Metrica](https://metrica.yandex.com/) veriler. Test ortamımızı Yandex ile paylaşıyoruz.Metrica takımı. ClickHouse mevcut verilerin üstünde kesinti olmadan yükseltilir. İlk önce verilerin gerçek zamanlı olarak gecikmeden başarıyla işlendiğine bakıyoruz, çoğaltma çalışmaya devam ediyor ve Yandex tarafından görülebilen herhangi bir sorun yok.Metrica takımı. İlk kontrol aşağıdaki şekilde yapılabilir: - -``` sql -SELECT hostName() AS h, any(version()), any(uptime()), max(UTCEventTime), count() FROM remote('example01-01-{1..3}t', merge, hits) WHERE EventDate >= today() - 2 GROUP BY h ORDER BY h; -``` - -Bazı durumlarda yandex'teki arkadaş ekiplerimizin test ortamına da dağıtım yapıyoruz: Pazar, Bulut, vb. Ayrıca geliştirme amacıyla kullanılan bazı donanım sunucularımız var. - -## Yük Testi {#load-testing} - -Test ortamına dağıtıldıktan sonra, üretim kümesinden gelen sorgularla yük testini çalıştırıyoruz. Bu elle yapılır. - -Etkinleştirdiğinizden emin olun `query_log` üretim kümenizde. - -Bir gün veya daha fazla sorgu günlüğü toplayın: - -``` bash -$ clickhouse-client --query="SELECT DISTINCT query FROM system.query_log WHERE event_date = today() AND query LIKE '%ym:%' AND query NOT LIKE '%system.query_log%' AND type = 2 AND is_initial_query" > queries.tsv -``` - -Bu şekilde karmaşık bir örnektir. `type = 2` başarıyla yürütülen sorguları süzer. `query LIKE '%ym:%'` yandex'ten ilgili sorguları seçmektir.Metrica. `is_initial_query` yalnızca istemci tarafından başlatılan sorguları seçmektir, Clickhouse'un kendisi tarafından değil (dağıtılmış sorgu işlemenin parçaları olarak). - -`scp` bu test kümenize günlük ve aşağıdaki gibi çalıştırın: - -``` bash -$ clickhouse benchmark --concurrency 16 < queries.tsv -``` - -(muhtemelen de belirtmek istiyorum `--user`) - -Sonra bir gece ya da hafta sonu için bırakın ve dinlenin. - -Kontrol etmelisiniz `clickhouse-server` çökmez, bellek ayak izi sınırlıdır ve performans zamanla aşağılayıcı değildir. - -Kesin sorgu yürütme zamanlamaları kaydedilmez ve sorguların ve ortamın yüksek değişkenliği nedeniyle karşılaştırılmaz. - -## Yapı Testleri {#build-tests} - -Yapı testleri, yapının çeşitli alternatif konfigürasyonlarda ve bazı yabancı sistemlerde bozulmadığını kontrol etmeyi sağlar. Testler bulunur `ci` dizin. Docker, Vagrant ve bazen de `qemu-user-static` Docker'ın içinde. Bu testler geliştirme aşamasındadır ve test çalıştırmaları otomatik değildir. - -Motivasyon: - -Normalde tüm testleri ClickHouse yapısının tek bir varyantında serbest bırakırız ve çalıştırırız. Ancak, iyice test edilmeyen alternatif yapı varyantları vardır. Örnekler: - -- FreeBSD üzerine inşa; -- sistem paketlerinden kütüphaneler ile Debian üzerine inşa; -- kütüphanelerin paylaşılan bağlantısı ile oluşturun; -- AArch64 platformunda oluşturun; -- PowerPc platformunda oluşturun. - -Örneğin, sistem paketleri ile oluştur kötü bir uygulamadır, çünkü bir sistemin hangi paketlerin tam sürümüne sahip olacağını garanti edemeyiz. Ancak bu gerçekten Debian bakıcılarına ihtiyaç duyuyor. Bu nedenle en azından bu yapı varyantını desteklemeliyiz. Başka bir örnek: paylaşılan bağlantı ortak bir sorun kaynağıdır, ancak bazı Meraklılar için gereklidir. - -Tüm yapı varyantlarında tüm testleri çalıştıramasak da, en azından çeşitli yapı varyantlarının bozulmadığını kontrol etmek istiyoruz. Bu amaçla yapı testlerini kullanıyoruz. - -## Protokol uyumluluğu testi {#testing-for-protocol-compatibility} - -ClickHouse ağ protokolünü genişlettiğimizde, eski clickhouse istemcisinin yeni clickhouse sunucusu ile çalıştığını ve yeni clickhouse istemcisinin eski clickhouse sunucusu ile çalıştığını (sadece ilgili paketlerden ikili dosyaları çalıştırarak) manuel olarak test ediyoruz. - -## Derleyiciden yardım {#help-from-the-compiler} - -Ana ClickHouse kodu (bu `dbms` dizin) ile inşa edilmiştir `-Wall -Wextra -Werror` ve bazı ek etkin uyarılar ile. Bu seçenekler üçüncü taraf kitaplıkları için etkin olmasa da. - -Clang daha yararlı uyarılar vardır-Sen ile onları arayabilirsiniz `-Weverything` ve varsayılan oluşturmak için bir şey seçin. - -Üretim yapıları için gcc kullanılır (hala clang'dan biraz daha verimli kod üretir). Geliştirme için, clang genellikle kullanımı daha uygundur. Hata ayıklama modu ile kendi makinenizde inşa edebilirsiniz (dizüstü bilgisayarınızın pilinden tasarruf etmek için), ancak derleyicinin daha fazla uyarı üretebileceğini lütfen unutmayın `-O3` daha iyi kontrol akışı ve prosedürler arası analiz nedeniyle. Clang ile inşa ederken ayıklama modu ile oluştururken, hata ayıklama sürümü `libc++` çalışma zamanında daha fazla hata yakalamak için izin verir kullanılır. - -## Dezenfektanlar {#sanitizers} - -**Adres dezenfektanı**. -Biz başına taahhüt bazında ASan altında fonksiyonel ve entegrasyon testleri çalıştırın. - -**Valgrind (Memcheck)**. -Bir gecede valgrind altında fonksiyonel testler yapıyoruz. Birden fazla saat sürer. Şu anda bilinen bir yanlış pozitif var `re2` kütüphane, bkz [bu makale](https://research.swtch.com/sparse). - -**Tanımsız davranış dezenfektanı.** -Biz başına taahhüt bazında ASan altında fonksiyonel ve entegrasyon testleri çalıştırın. - -**İplik dezenfektanı**. -Biz başına taahhüt bazında tsan altında fonksiyonel testler çalıştırın. Tsan altında hala taahhüt bazında entegrasyon testleri yapmıyoruz. - -**Bellek temizleyici**. -Şu anda hala MSan kullanmıyoruz. - -**Hata ayıklama ayırıcısı.** -Hata ayıklama sürümü `jemalloc` hata ayıklama oluşturmak için kullanılır. - -## Fuzzing {#fuzzing} - -ClickHouse fuzzing hem kullanılarak uygulanmaktadır [libFuzzer](https://llvm.org/docs/LibFuzzer.html) ve rastgele SQL sorguları. -Tüm fuzz testleri sanitizers (Adres ve tanımsız) ile yapılmalıdır. - -LibFuzzer kütüphane kodu izole fuzz testi için kullanılır. Fuzzers test kodunun bir parçası olarak uygulanır ve “_fuzzer” adı postfixes. -Fuzzer örneği bulunabilir `src/Parsers/tests/lexer_fuzzer.cpp`. LibFuzzer özgü yapılandırmalar, sözlükler ve corpus saklanır `tests/fuzz`. -Kullanıcı girişini işleyen her işlevsellik için fuzz testleri yazmanızı öneririz. - -Fuzzers varsayılan olarak oluşturulmaz. Hem fuzzers inşa etmek `-DENABLE_FUZZING=1` ve `-DENABLE_TESTS=1` seçenekler ayarlanmalıdır. -Fuzzers oluştururken Jemalloc'u devre dışı bırakmanızı öneririz. ClickHouse fuzzing'i entegre etmek için kullanılan yapılandırma -Google OSS-Fuzz bulunabilir `docker/fuzz`. - -Ayrıca rastgele SQL sorguları oluşturmak ve sunucunun bunları çalıştırarak ölmediğini kontrol etmek için basit fuzz testi kullanıyoruz. -İçinde bulabilirsiniz `00746_sql_fuzzy.pl`. Bu test sürekli olarak (gece ve daha uzun) çalıştırılmalıdır. - -## Güvenlik Denetimi {#security-audit} - -Yandex Güvenlik ekibinden insanlar güvenlik açısından ClickHouse yetenekleri bazı temel bakış yapmak. - -## Statik Analizörler {#static-analyzers} - -Koş weuyoruz `PVS-Studio` taahhüt bazında. Değerlendir havedik `clang-tidy`, `Coverity`, `cppcheck`, `PVS-Studio`, `tscancode`. Sen kullanım talimatları bulacaksınız `tests/instructions/` dizin. Ayrıca okuyabilirsiniz [Rusça makale](https://habr.com/company/yandex/blog/342018/). - -Kullanıyorsanız `CLion` bir IDE olarak, bazı kaldıraç `clang-tidy` kutudan kontrol eder. - -## Sertleşme {#hardening} - -`FORTIFY_SOURCE` varsayılan olarak kullanılır. Neredeyse işe yaramaz, ancak nadir durumlarda hala mantıklı ve bunu devre dışı bırakmıyoruz. - -## Kod Stili {#code-style} - -Kod stili kuralları açıklanmıştır [burada](https://clickhouse.tech/docs/en/development/style/). - -Bazı ortak stil ihlallerini kontrol etmek için şunları kullanabilirsiniz `utils/check-style` komut. - -Kodunuzun uygun stilini zorlamak için şunları kullanabilirsiniz `clang-format`. Dosya `.clang-format` kaynak rootlarında yer almaktadır. Çoğunlukla gerçek kod stilimizle karşılık gelir. Ancak uygulanması tavsiye edilmez `clang-format` varolan dosyalara biçimlendirmeyi daha da kötüleştirdiği için. Kullanabilirsiniz `clang-format-diff` eğer clang kaynak deposunda bulabilirsiniz aracı. - -Alternatif olarak deneyebilirsiniz `uncrustify` kodunuzu yeniden biçimlendirmek için bir araç. Yapılandırma içinde `uncrustify.cfg` kaynaklarda kök. Daha az test edilmiştir `clang-format`. - -`CLion` kod stilimiz için ayarlanması gereken kendi kod biçimlendiricisine sahiptir. - -## Metrica B2B testleri {#metrica-b2b-tests} - -Her ClickHouse sürümü Yandex Metrica ve AppMetrica motorları ile test edilir. Clickhouse'un Test ve kararlı sürümleri Vm'lerde dağıtılır ve Giriş verilerinin sabit örneğini işleyen Metrica motorunun küçük bir kopyasıyla çalışır. Daha sonra Metrica motorunun iki örneğinin sonuçları birlikte karşılaştırılır. - -Bu testler ayrı ekip tarafından otomatikleştirilir. Yüksek sayıda hareketli parça nedeniyle, testler çoğu zaman tamamen ilgisiz nedenlerle başarısız olur, bu da anlaşılması çok zordur. Büyük olasılıkla bu testlerin bizim için negatif değeri var. Bununla birlikte, bu testlerin yüzlerce kişiden yaklaşık bir veya iki kez yararlı olduğu kanıtlanmıştır. - -## Test Kapsamı {#test-coverage} - -Temmuz 2018 itibariyle test kapsamını takip etmiyoruz. - -## Test Otomasyonu {#test-automation} - -Yandex dahili CI ve iş otomasyon sistemi ile testler yapıyoruz “Sandbox”. - -Yapı işleri ve testler, taahhüt bazında sanal alanda çalıştırılır. Ortaya çıkan paketler ve test sonuçları Github'da yayınlanır ve doğrudan bağlantılar tarafından indirilebilir. Eserler sonsuza dek saklanır. Eğer GitHub bir çekme isteği gönderdiğinizde, biz olarak etiketlemek “can be tested” ve bizim CI sistemi sizin için ClickHouse paketleri (yayın, hata ayıklama, Adres dezenfektanı ile, vb) inşa edecek. - -Travis CI, zaman ve hesaplama gücü sınırı nedeniyle kullanmıyoruz. -Jenkins'i kullanmayız. Daha önce kullanıldı ve şimdi Jenkins kullanmadığımız için mutluyuz. - -[Orijinal makale](https://clickhouse.tech/docs/en/development/tests/) diff --git a/docs/tr/development/tests.md b/docs/tr/development/tests.md new file mode 120000 index 00000000000..c03d36c3916 --- /dev/null +++ b/docs/tr/development/tests.md @@ -0,0 +1 @@ +../../en/development/tests.md \ No newline at end of file diff --git a/docs/zh/development/tests.md b/docs/zh/development/tests.md deleted file mode 100644 index d2690a86887..00000000000 --- a/docs/zh/development/tests.md +++ /dev/null @@ -1,237 +0,0 @@ -# ClickHouse 测试 {#clickhouse-ce-shi} - -## 功能性测试 {#gong-neng-xing-ce-shi} - -功能性测试是最简便使用的。绝大部分 ClickHouse 的功能可以通过功能性测试来测试,任何代码的更改都必须通过该测试。 - -每个功能测试会向正在运行的 ClickHouse服务器发送一个或多个查询,并将结果与预期结果进行比较。 - -测试用例在 `tests/queries` 目录中。这里有两个子目录:`stateless` 和 `stateful`目录。无状态的测试无需预加载测试数据集 - 通常是在测试运行期间动态创建小量的数据集。有状态测试需要来自 Yandex.Metrica 的预加载测试数据,而不向一般公众提供。我们倾向于仅使用«无状态»测试并避免添加新的«有状态»测试。 - -每个测试用例可以是两种类型之一:`.sql` 和 `.sh`。`.sql` 测试文件是用于管理`clickhouse-client --multiquery --testmode`的简单SQL脚本。`.sh` 测试文件是一个可以自己运行的脚本。 - -要运行所有测试,请使用 `tests/clickhouse-test` 工具,用 `--help` 可以获取所有的选项列表。您可以简单地运行所有测试或运行测试名称中的子字符串过滤的测试子集:`./clickhouse-test substring`。 - -调用功能测试最简单的方法是将 `clickhouse-client` 复制到`/usr/bin/`,运行`clickhouse-server`,然后从自己的目录运行`./ clickhouse-test`。 - -要添加新测试,请在 `tests/queries/0_stateless` 目录内添加新的 `.sql` 或 `.sh` 文件,手动检查,然后按以下方式生成 `.reference` 文件: `clickhouse-client -n --testmode < 00000_test.sql > 00000_test.reference` 或 `./00000_test.sh > ./00000_test.reference`。 - -测试应该只使用(创建,删除等)`test` 数据库中的表,这些表假定是事先创建的; 测试也可以使用临时表。 - -如果要在功能测试中使用分布式查询,可以利用 `remote` 表函数和 `127.0.0.{1..2}` 地址为服务器查询自身; 或者您可以在服务器配置文件中使用预定义的测试集群,例如`test_shard_localhost`。 - -有些测试在名称中标有 `zookeeper`,`shard` 或 `long`。`zookeeper` 用于使用ZooKeeper的测试; `shard` 用于需要服务器监听`127.0.0.*`的测试。`long` 适用于运行时间稍长一秒的测试。 - -## 已知的bug {#yi-zhi-de-bug} - -如果我们知道一些可以通过功能测试轻松复制的错误,我们将准备好的功能测试放在 `tests/queries/bugs` 目录中。当修复错误时,这些测试将被移动到 `tests/queries/0_stateless` 目录中。 - -## 集成测试 {#ji-cheng-ce-shi} - -集成测试允许在集群配置中测试 ClickHouse,并与其他服务器(如MySQL,Postgres,MongoDB)进行 ClickHouse 交互。它们可用于模拟网络拆分,数据包丢弃等。这些测试在Docker下运行,并使用各种软件创建多个容器。 - -参考 `tests/integration/README.md` 文档关于如何使用集成测试。 - -请注意,ClickHouse 与第三方驱动程序的集成未经过测试。此外,我们目前还没有与 JDBC 和ODBC 驱动程序进行集成测试。 - -## 单元测试 {#dan-yuan-ce-shi} - -当您想要测试整个 ClickHouse,而不是单个独立的库或类时,单元测试非常有用。您可以使用`ENABLE_TESTS` CMake 选项启用或禁用测试构建。单元测试(和其他测试程序)位于代码中的`tests` 子目录中。要运行单元测试,请键入 `ninja test`。有些测试使用 `gtest`,但有些只是在测试失败时返回非零状态码。 - -如果代码已经被功能测试覆盖(并且功能测试通常使用起来要简单得多),则不一定要进行单元测试。 - -## 性能测试 {#xing-neng-ce-shi} - -性能测试允许测量和比较综合查询中 ClickHouse 的某些独立部分的性能。测试位于`tests/performance` 目录中。每个测试都由 `.xml` 文件表示,并附有测试用例的描述。使用 `clickhouse performance-test` 工具(嵌入在 `clickhouse` 二进制文件中)运行测试。请参阅 `--help` 以进行调用。 - -每个测试在循环中运行一个或多个查询(可能带有参数组合),并具有一些停止条件(如«最大执行速度不会在三秒内更改»)并测量一些有关查询性能的指标(如«最大执行速度»))。某些测试可以包含预加载的测试数据集的前提条件。 - -如果要在某些情况下提高 ClickHouse 的性能,并且如果可以在简单查询上观察到改进,则强烈建议编写性能测试。在测试过程中使用 `perf top` 或其他 perf 工具总是有意义的。 - -性能测试不是基于每个提交运行的。不收集性能测试结果,我们手动比较它们。 - -## 测试工具和脚本 {#ce-shi-gong-ju-he-jiao-ben} - -`tests`目录中的一些程序不是准备测试,而是测试工具。例如,对于`Lexer`,有一个工具`src/Parsers/tests/lexer` 标准输出。您可以使用这些工具作为代码示例以及探索和手动测试。 - -您还可以将一对文件 `.sh` 和 `.reference` 与工具放在一些预定义的输入上运行它 - 然后可以将脚本结果与 `.reference` 文件进行比较。这些测试不是自动化的。 - -## 杂项测试 {#za-xiang-ce-shi} - -有一些外部字典的测试位于 `tests/external_dictionaries`,机器学习模型在`tests/external_models`目录。这些测试未更新,必须转移到集成测试。 - -对于分布式数据的插入,有单独的测试。此测试在单独的服务器上运行 ClickHouse 集群并模拟各种故障情况:网络拆分,数据包丢弃(ClickHouse 节点之间,ClickHouse 和 ZooKeeper之间,ClickHouse 服务器和客户端之间等),进行 `kill -9`,`kill -STOP` 和`kill -CONT` 等操作,类似[Jepsen](https://aphyr.com/tags/Jepsen)。然后,测试检查是否已写入所有已确认的插入,并且所有已拒绝的插入都未写入。 - -在 ClickHouse 开源之前,分布式测试是由单独的团队编写的,但该团队不再使用 ClickHouse,测试是在 Java 中意外编写的。由于这些原因,必须重写分布式测试并将其移至集成测试。 - -## 手动测试 {#shou-dong-ce-shi} - -当您开发了新的功能,做手动测试也是合理的。可以按照以下步骤来进行: - -编译 ClickHouse。在命令行中运行 ClickHouse:进入 `programs/clickhouse-server` 目录并运行 `./clickhouse-server`。它会默认使用当前目录的配置文件 (`config.xml`, `users.xml` 以及在 `config.d` 和 `users.d` 目录的文件)。可以使用 `programs/clickhouse-client/clickhouse-client` 来连接数据库。 - -或者,您可以安装 ClickHouse 软件包:从 Yandex 存储库中获得稳定版本,或者您可以在ClickHouse源根目录中使用 `./release` 构建自己的软件包。然后使用 `sudo service clickhouse-server start` 启动服务器(或停止服务器)。在 `/etc/clickhouse-server/clickhouse-server.log` 中查找日志。 - -当您的系统上已经安装了 ClickHouse 时,您可以构建一个新的 `clickhouse` 二进制文件并替换现有的二进制文件: - - sudo service clickhouse-server stop - sudo cp ./clickhouse /usr/bin/ - sudo service clickhouse-server start - -您也可以停止 clickhouse-server 并使用相同的配置运行您自己的服务器,日志打印到终端: - - sudo service clickhouse-server stop - sudo -u clickhouse /usr/bin/clickhouse server --config-file /etc/clickhouse-server/config.xml - -使用 gdb 的一个示例: - - sudo -u clickhouse gdb --args /usr/bin/clickhouse server --config-file /etc/clickhouse-server/config.xml - -如果 clickhouse-server 已经运行并且您不想停止它,您可以更改 `config.xml` 中的端口号(或在 `config.d` 目录中的文件中覆盖它们),配置适当的数据路径,然后运行它。 - -`clickhouse` 二进制文件几乎没有依赖关系,适用于各种 Linux 发行版。要快速地测试服务器上的更改,您可以简单地将新建的 `clickhouse` 二进制文件 `scp` 到其他服务器,然后按照上面的示例运行它。 - -## 测试环境 {#ce-shi-huan-jing} - -在将版本发布为稳定之前,我们将其部署在测试环境中测试环境是一个处理\[Yandex.Metrica\](https://metrica.yandex.com/)总数据的1/39部分大小的集群。我们与 Yandex.Metrica 团队公用我们的测试环境。ClickHouse 在现有数据的基础上无需停机即可升级。我们首先看到数据处理成功而不会实时滞后,复制继续工作,并且 Yandex.Metrica 团队无法看到问题。首先的检查可以通过以下方式完成: - - SELECT hostName() AS h, any(version()), any(uptime()), max(UTCEventTime), count() FROM remote('example01-01-{1..3}t', merge, hits) WHERE EventDate >= today() - 2 GROUP BY h ORDER BY h; - -在某些情况下,我们还部署到 Yandex 的合作团队的测试环境:市场,云等。此外,我们还有一些用于开发目的的硬件服务器。 - -## 负载测试 {#fu-zai-ce-shi} - -部署到测试环境后,我们使用生产群集中的查询运行负载测试。这是手动完成的。 - -确保在生产集群中开启了 `query_log` 选项。 - -收集一天或更多的查询日志: - - clickhouse-client --query="SELECT DISTINCT query FROM system.query_log WHERE event_date = today() AND query LIKE '%ym:%' AND query NOT LIKE '%system.query_log%' AND type = 2 AND is_initial_query" > queries.tsv - -这是一个复杂的例子。`type = 2` 将过滤成功执行的查询。`query LIKE'%ym:%'` 用于从 Yandex.Metrica 中选择相关查询。`is_initial_query` 是仅选择由客户端发起的查询,而不是由 ClickHouse 本身(作为分布式查询处理的一部分)。 - -`scp` 这份日志到测试机器,并运行以下操作: - - clickhouse benchmark --concurrency 16 < queries.tsv - -(可能你需要指定运行的用户 `--user`) - -然后离开它一晚或周末休息一下。 - -你要检查下 `clickhouse-server` 是否崩溃,内存占用是否合理,性能也不会随着时间的推移而降低。 - -由于查询和环境的高度可变性,不会记录精确的查询执行时序并且不进行比较。 - -## 编译测试 {#bian-yi-ce-shi} - -构建测试允许检查构建在各种替代配置和某些外部系统上是否被破坏。测试位于`ci`目录。它们从 Docker,Vagrant 中的源代码运行构建,有时在 Docker 中运行 `qemu-user-static`。这些测试正在开发中,测试运行不是自动化的。 - -动机: - -通常我们会在 ClickHouse 构建的单个版本上发布并运行所有测试。但是有一些未经过彻底测试的替代构建版本。例子: - -- 在 FreeBSD 中的构建; -- 在 Debian 中使用系统包中的库进行构建; -- 使用库的共享链接构建; -- 在 AArch64 平台进行构建。 - -例如,使用系统包构建是不好的做法,因为我们无法保证系统具有的确切版本的软件包。但 Debian 维护者确实需要这样做。出于这个原因,我们至少必须支持这种构建。另一个例子:共享链接是一个常见的麻烦来源,但是对于一些爱好者来说需要它。 - -虽然我们无法对所有构建版本运行所有测试,但我们想要检查至少不会破坏各种构建变体。为此,我们使用构建测试。 - -## 测试协议兼容性 {#ce-shi-xie-yi-jian-rong-xing} - -当我们扩展 ClickHouse 网络协议时,我们手动测试旧的 clickhouse-client 与新的 clickhouse-server 和新的clickhouse-client 一起使用旧的 clickhouse-server (只需从相应的包中运行二进制文件) - -## 来自编译器的提示 {#lai-zi-bian-yi-qi-de-ti-shi} - -ClickHouse 主要的代码 (位于`dbms`目录中) 使用 `-Wall -Wextra -Werror` 构建,并带有一些其他已启用的警告。 虽然没有为第三方库启用这些选项。 - -Clang 有更多有用的警告 - 您可以使用 `-Weverything` 查找它们并选择默认构建的东西。 - -对于生产构建,使用 gcc(它仍然生成比 clang 稍高效的代码)。对于开发来说,clang 通常更方便使用。您可以使用调试模式在自己的机器上构建(以节省笔记本电脑的电量),但请注意,由于更好的控制流程和过程分析,编译器使用 `-O3` 会生成更多警告。 当使用 clang 构建时,使用 `libc++` 而不是 `libstdc++`,并且在使用调试模式构建时,使用调试版本的 `libc++`,它允许在运行时捕获更多错误。 - -## Sanitizers {#sanitizers} - -### Address sanitizer -我们使用Asan对每个提交进行功能和集成测试。 - -### Valgrind (Memcheck) -我们在夜间使用Valgrind进行功能测试。这需要几个小时。目前在 `re2` 库中有一个已知的误报,请参阅[文章](https://research.swtch.com/sparse)。 - -### Undefined behaviour sanitizer -我们使用Asan对每个提交进行功能和集成测试。 - -### Thread sanitizer -我们使用TSan对每个提交进行功能测试。目前不使用TSan对每个提交进行集成测试。 - -### Memory sanitizer -目前我们不使用 MSan。 - -### Debug allocator -您可以使用 `DEBUG_TCMALLOC` CMake 选项启用 `tcmalloc` 的调试版本。我们在每次提交的基础上使用调试分配器运行测试。 - -更多请参阅 `tests/instructions/sanitizers.txt`。 - -## 模糊测试 {#mo-hu-ce-shi} - -ClickHouse模糊测试可以通过[libFuzzer](https://llvm.org/docs/LibFuzzer.html)和随机SQL查询实现。 -所有的模糊测试都应使用sanitizers(Address及Undefined)。 - -LibFuzzer用于对库代码进行独立的模糊测试。模糊器作为测试代码的一部分实现,并具有“_fuzzer”名称后缀。 -模糊测试示例在`src/Parsers/tests/lexer_fuzzer.cpp`。LibFuzzer配置、字典及语料库存放在`tests/fuzz`。 -我们鼓励您为每个处理用户输入的功能编写模糊测试。 - -默认情况下不构建模糊器。可通过设置`-DENABLE_FUZZING=1`和`-DENABLE_TESTS=1`来构建模糊器。 我们建议在构建模糊器时关闭Jemalloc。 -用于将ClickHouse模糊测试集成到的Google OSS-Fuzz的配置文件位于`docker/fuzz`。 - -此外,我们使用简单的模糊测试来生成随机SQL查询并检查服务器是否正常。你可以在`00746_sql_fuzzy.pl` 找到它。测试应连续进行(过夜和更长时间)。 - -## 安全审计 {#an-quan-shen-ji} - -Yandex Cloud 部门的人员从安全角度对 ClickHouse 功能进行了一些基本概述。 - -## 静态分析 {#jing-tai-fen-xi} - -我们偶尔使用静态分析。我们已经评估过 `clang-tidy`, `Coverity`, `cppcheck`, `PVS-Studio`, `tscancode`。您将在 `tests/instructions/` 目录中找到使用说明。你也可以阅读[俄文文章](https://habr.com/company/yandex/blog/342018/). - -如果您使用 `CLion` 作为 IDE,您可以开箱即用一些 `clang-tidy` 检查。 - -## 其他强化 {#qi-ta-qiang-hua} - -默认情况下使用 `FORTIFY_SOURCE`。它几乎没用,但在极少数情况下仍然有意义,我们不会禁用它。 - -## 代码风格 {#dai-ma-feng-ge} - -代码风格在[这里](https://clickhouse.tech/docs/en/development/style/) 有说明。 - -要检查一些常见的样式冲突,您可以使用 `utils/check-style` 脚本。 - -为了强制你的代码的正确风格,你可以使用 `clang-format` 文件。`.clang-format` 位于源代码根目录, 它主要与我们的实际代码风格对应。但不建议将 `clang-format` 应用于现有文件,因为它会使格式变得更糟。您可以使用 `clang-format-diff` 工具,您可以在 clang 源代码库中找到 - -或者,您可以尝试`uncrustify` 工具来格式化您的代码。配置文件在源代码的根目录中的`uncrustify.cfg`。它比 `clang-format` 经过更少的测试。 - -`CLion` 有自己的代码格式化程序,必须调整为我们的代码风格。 - -## Metrica B2B 测试 {#metrica-b2b-ce-shi} - -每个 ClickHouse 版本都经过 Yandex Metrica 和 AppMetrica 引擎的测试。测试和稳定版本的 ClickHouse 部署在虚拟机上,并使用处理输入数据固定样本的度量引擎的小副本运行。将度量引擎的两个实例的结果一起进行比较 - -这些测试是由单独的团队自动完成的。由于移动部件的数量很多,大部分时间的测试都是完全无关的,很难弄清楚。很可能这些测试对我们来说是负值。然而,这些测试被证明是有用的大约一个或两个倍的数百。 - -## 测试覆盖率 {#ce-shi-fu-gai-lu} - -截至2018年7月,我们不会跟踪测试复盖率。 - -## 自动化测试 {#zi-dong-hua-ce-shi} - -我们使用 Yandex 内部 CI 和名为«沙箱»的作业自动化系统运行测试。我们还继续使用 Jenkins(可在Yandex内部使用)。 - -构建作业和测试在沙箱中按每次提交的基础上运行。结果包和测试结果发布在 GitHub 上,可以通过直接链接下载,结果会被永久存储。当您在 GitHub 上发送拉取请求时,我们将其标记为«可以测试»,我们的 CI 系统将为您构建 ClickHouse 包(发布,调试,地址消除等)。 - -由于时间和计算能力的限制,我们不使用 Travis CI。 - -在 Jenkins,我们运行字典测试,指标B2B测试。我们使用 Jenkins 来准备和发布版本。Jenkins是一种传统的技术,所有的工作将被转移到沙箱中。 - -[来源文章](https://clickhouse.tech/docs/zh/development/tests/) From 4c6819c26fa8c608e9f4d004a408bcaf680467d1 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 4 Nov 2020 17:41:16 +0300 Subject: [PATCH 88/95] Fix misleading info --- docs/en/development/tests.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/development/tests.md b/docs/en/development/tests.md index e6141f7ab02..5b096bcc5fa 100644 --- a/docs/en/development/tests.md +++ b/docs/en/development/tests.md @@ -74,9 +74,9 @@ It’s not necessarily to have unit tests if the code is already covered by func ## Performance Tests {#performance-tests} -Performance tests allow to measure and compare performance of some isolated part of ClickHouse on synthetic queries. Tests are located at `tests/performance`. Each test is represented by `.xml` file with description of test case. Tests are run with `clickhouse performance-test` tool (that is embedded in `clickhouse` binary). See `--help` for invocation. +Performance tests allow to measure and compare performance of some isolated part of ClickHouse on synthetic queries. Tests are located at `tests/performance`. Each test is represented by `.xml` file with description of test case. Tests are run with `docker/tests/performance-comparison` tool . See the readme file for invocation. -Each test run one or multiple queries (possibly with combinations of parameters) in a loop with some conditions for stop (like “maximum execution speed is not changing in three seconds”) and measure some metrics about query performance (like “maximum execution speed”). Some tests can contain preconditions on preloaded test dataset. +Each test run one or multiple queries (possibly with combinations of parameters) in a loop. Some tests can contain preconditions on preloaded test dataset. If you want to improve performance of ClickHouse in some scenario, and if improvements can be observed on simple queries, it is highly recommended to write a performance test. It always makes sense to use `perf top` or other perf tools during your tests. From d966bb939efc0c7d65e56ce816b5ca5546b4a1e1 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 4 Nov 2020 17:51:41 +0300 Subject: [PATCH 89/95] Fix inconsistent code around H3 --- src/Functions/CMakeLists.txt | 18 ------------------ src/Functions/geoToH3.cpp | 8 ++++++++ src/Functions/h3EdgeAngle.cpp | 8 ++++++++ src/Functions/h3EdgeLengthM.cpp | 8 ++++++++ src/Functions/h3GetBaseCell.cpp | 8 ++++++++ src/Functions/h3GetResolution.cpp | 8 ++++++++ src/Functions/h3HexAreaM2.cpp | 8 ++++++++ src/Functions/h3IndexesAreNeighbors.cpp | 8 ++++++++ src/Functions/h3IsValid.cpp | 8 ++++++++ src/Functions/h3ToChildren.cpp | 8 ++++++++ src/Functions/h3ToParent.cpp | 8 ++++++++ src/Functions/h3ToString.cpp | 8 ++++++++ src/Functions/h3kRing.cpp | 8 ++++++++ src/Functions/stringToH3.cpp | 8 ++++++++ 14 files changed, 104 insertions(+), 18 deletions(-) diff --git a/src/Functions/CMakeLists.txt b/src/Functions/CMakeLists.txt index bdf89c983f1..126e4c7c57d 100644 --- a/src/Functions/CMakeLists.txt +++ b/src/Functions/CMakeLists.txt @@ -6,24 +6,6 @@ add_headers_and_sources(clickhouse_functions .) list(REMOVE_ITEM clickhouse_functions_sources IFunctionImpl.cpp FunctionFactory.cpp FunctionHelpers.cpp) list(REMOVE_ITEM clickhouse_functions_headers IFunctionImpl.h FunctionFactory.h FunctionHelpers.h) -if (NOT USE_H3) - list (REMOVE_ITEM clickhouse_functions_sources - geoToH3.cpp - h3EdgeAngle.cpp - h3EdgeLengthM.cpp - h3GetBaseCell.cpp - h3GetResolution.cpp - h3HexAreaM2.cpp - h3IndexesAreNeighbors.cpp - h3IsValid.cpp - h3kRing.cpp - h3ToChildren.cpp - h3ToParent.cpp - h3ToString.cpp - stringToH3.cpp - ) -endif () - add_library(clickhouse_functions ${clickhouse_functions_sources}) target_link_libraries(clickhouse_functions diff --git a/src/Functions/geoToH3.cpp b/src/Functions/geoToH3.cpp index 882425c4a77..257c73daa4c 100644 --- a/src/Functions/geoToH3.cpp +++ b/src/Functions/geoToH3.cpp @@ -1,3 +1,9 @@ +#if !defined(ARCADIA_BUILD) +# include "config_functions.h" +#endif + +#if USE_H3 + #include #include #include @@ -94,3 +100,5 @@ void registerFunctionGeoToH3(FunctionFactory & factory) } } + +#endif diff --git a/src/Functions/h3EdgeAngle.cpp b/src/Functions/h3EdgeAngle.cpp index 88995427e6d..7b0b1cdc3a7 100644 --- a/src/Functions/h3EdgeAngle.cpp +++ b/src/Functions/h3EdgeAngle.cpp @@ -1,3 +1,9 @@ +#if !defined(ARCADIA_BUILD) +# include "config_functions.h" +#endif + +#if USE_H3 + #include #include #include @@ -77,3 +83,5 @@ void registerFunctionH3EdgeAngle(FunctionFactory & factory) } } + +#endif diff --git a/src/Functions/h3EdgeLengthM.cpp b/src/Functions/h3EdgeLengthM.cpp index 6626deffd6b..d22074ceee0 100644 --- a/src/Functions/h3EdgeLengthM.cpp +++ b/src/Functions/h3EdgeLengthM.cpp @@ -1,3 +1,9 @@ +#if !defined(ARCADIA_BUILD) +# include "config_functions.h" +#endif + +#if USE_H3 + #include #include #include @@ -81,3 +87,5 @@ void registerFunctionH3EdgeLengthM(FunctionFactory & factory) } } + +#endif diff --git a/src/Functions/h3GetBaseCell.cpp b/src/Functions/h3GetBaseCell.cpp index 80cbf96fe9b..f9bc8bcea20 100644 --- a/src/Functions/h3GetBaseCell.cpp +++ b/src/Functions/h3GetBaseCell.cpp @@ -1,3 +1,9 @@ +#if !defined(ARCADIA_BUILD) +# include "config_functions.h" +#endif + +#if USE_H3 + #include #include #include @@ -70,3 +76,5 @@ void registerFunctionH3GetBaseCell(FunctionFactory & factory) } } + +#endif diff --git a/src/Functions/h3GetResolution.cpp b/src/Functions/h3GetResolution.cpp index 1b7d108dbd1..c73d7ed4f4c 100644 --- a/src/Functions/h3GetResolution.cpp +++ b/src/Functions/h3GetResolution.cpp @@ -1,3 +1,9 @@ +#if !defined(ARCADIA_BUILD) +# include "config_functions.h" +#endif + +#if USE_H3 + #include #include #include @@ -70,3 +76,5 @@ void registerFunctionH3GetResolution(FunctionFactory & factory) } } + +#endif diff --git a/src/Functions/h3HexAreaM2.cpp b/src/Functions/h3HexAreaM2.cpp index 8de17cc1f11..f1e74591785 100644 --- a/src/Functions/h3HexAreaM2.cpp +++ b/src/Functions/h3HexAreaM2.cpp @@ -1,3 +1,9 @@ +#if !defined(ARCADIA_BUILD) +# include "config_functions.h" +#endif + +#if USE_H3 + #include #include #include @@ -76,3 +82,5 @@ void registerFunctionH3HexAreaM2(FunctionFactory & factory) } } + +#endif diff --git a/src/Functions/h3IndexesAreNeighbors.cpp b/src/Functions/h3IndexesAreNeighbors.cpp index d2ba36347a3..bddaffd96bc 100644 --- a/src/Functions/h3IndexesAreNeighbors.cpp +++ b/src/Functions/h3IndexesAreNeighbors.cpp @@ -1,3 +1,9 @@ +#if !defined(ARCADIA_BUILD) +# include "config_functions.h" +#endif + +#if USE_H3 + #include #include #include @@ -78,3 +84,5 @@ void registerFunctionH3IndexesAreNeighbors(FunctionFactory & factory) } } + +#endif diff --git a/src/Functions/h3IsValid.cpp b/src/Functions/h3IsValid.cpp index 9455bec19ee..bd99f57af3e 100644 --- a/src/Functions/h3IsValid.cpp +++ b/src/Functions/h3IsValid.cpp @@ -1,3 +1,9 @@ +#if !defined(ARCADIA_BUILD) +# include "config_functions.h" +#endif + +#if USE_H3 + #include #include #include @@ -70,3 +76,5 @@ void registerFunctionH3IsValid(FunctionFactory & factory) } } + +#endif diff --git a/src/Functions/h3ToChildren.cpp b/src/Functions/h3ToChildren.cpp index d1438c70676..8c0d4d23e96 100644 --- a/src/Functions/h3ToChildren.cpp +++ b/src/Functions/h3ToChildren.cpp @@ -1,3 +1,9 @@ +#if !defined(ARCADIA_BUILD) +# include "config_functions.h" +#endif + +#if USE_H3 + #include #include #include @@ -111,3 +117,5 @@ void registerFunctionH3ToChildren(FunctionFactory & factory) } } + +#endif diff --git a/src/Functions/h3ToParent.cpp b/src/Functions/h3ToParent.cpp index 1f3cafe690f..cbdbbedfcd6 100644 --- a/src/Functions/h3ToParent.cpp +++ b/src/Functions/h3ToParent.cpp @@ -1,3 +1,9 @@ +#if !defined(ARCADIA_BUILD) +# include "config_functions.h" +#endif + +#if USE_H3 + #include #include #include @@ -85,3 +91,5 @@ void registerFunctionH3ToParent(FunctionFactory & factory) } } + +#endif diff --git a/src/Functions/h3ToString.cpp b/src/Functions/h3ToString.cpp index 5f1a93648ad..01d1b02809a 100644 --- a/src/Functions/h3ToString.cpp +++ b/src/Functions/h3ToString.cpp @@ -1,3 +1,9 @@ +#if !defined(ARCADIA_BUILD) +# include "config_functions.h" +#endif + +#if USE_H3 + #include #include #include @@ -86,3 +92,5 @@ void registerFunctionH3ToString(FunctionFactory & factory) } } + +#endif diff --git a/src/Functions/h3kRing.cpp b/src/Functions/h3kRing.cpp index 10fea799dd2..883c20d6324 100644 --- a/src/Functions/h3kRing.cpp +++ b/src/Functions/h3kRing.cpp @@ -1,3 +1,9 @@ +#if !defined(ARCADIA_BUILD) +# include "config_functions.h" +#endif + +#if USE_H3 + #include #include #include @@ -108,3 +114,5 @@ void registerFunctionH3KRing(FunctionFactory & factory) } } + +#endif diff --git a/src/Functions/stringToH3.cpp b/src/Functions/stringToH3.cpp index 10cb3120c3f..65e7fa20314 100644 --- a/src/Functions/stringToH3.cpp +++ b/src/Functions/stringToH3.cpp @@ -1,3 +1,9 @@ +#if !defined(ARCADIA_BUILD) +# include "config_functions.h" +#endif + +#if USE_H3 + #include #include #include @@ -101,3 +107,5 @@ void registerFunctionStringToH3(FunctionFactory & factory) } } + +#endif From ffeee2b471b299daa7713522ff349222fdcfaa79 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 4 Nov 2020 18:03:32 +0300 Subject: [PATCH 90/95] Remove T-Tests --- .../AggregateFunctionStudentTTest.cpp | 52 ---- .../AggregateFunctionStudentTTest.h | 262 ----------------- .../AggregateFunctionWelchTTest.cpp | 49 ---- .../AggregateFunctionWelchTTest.h | 274 ------------------ .../registerAggregateFunctions.cpp | 50 +++- .../registerAggregateFunctions.h | 47 --- src/AggregateFunctions/ya.make | 2 - .../0_stateless/01322_student_ttest.sql | 19 -- .../0_stateless/01322_ttest_scipy.python | 108 ------- .../queries/0_stateless/01322_ttest_scipy.sh | 8 - .../queries/0_stateless/01322_welch_ttest.sql | 37 --- 11 files changed, 48 insertions(+), 860 deletions(-) delete mode 100644 src/AggregateFunctions/AggregateFunctionStudentTTest.cpp delete mode 100644 src/AggregateFunctions/AggregateFunctionStudentTTest.h delete mode 100644 src/AggregateFunctions/AggregateFunctionWelchTTest.cpp delete mode 100644 src/AggregateFunctions/AggregateFunctionWelchTTest.h delete mode 100644 tests/queries/0_stateless/01322_student_ttest.sql delete mode 100644 tests/queries/0_stateless/01322_ttest_scipy.python delete mode 100755 tests/queries/0_stateless/01322_ttest_scipy.sh delete mode 100644 tests/queries/0_stateless/01322_welch_ttest.sql diff --git a/src/AggregateFunctions/AggregateFunctionStudentTTest.cpp b/src/AggregateFunctions/AggregateFunctionStudentTTest.cpp deleted file mode 100644 index 58fc9e5b5b9..00000000000 --- a/src/AggregateFunctions/AggregateFunctionStudentTTest.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include -#include "registerAggregateFunctions.h" - -#include -#include - - -// the return type is boolean (we use UInt8 as we do not have boolean in clickhouse) - -namespace ErrorCodes -{ -extern const int NOT_IMPLEMENTED; -} - -namespace DB -{ - -namespace -{ - -AggregateFunctionPtr createAggregateFunctionStudentTTest(const std::string & name, const DataTypes & argument_types, const Array & parameters) -{ - assertBinary(name, argument_types); - assertNoParameters(name, parameters); - - AggregateFunctionPtr res; - - if (isDecimal(argument_types[0]) || isDecimal(argument_types[1])) - { - throw Exception("Aggregate function " + name + " only supports numerical types", ErrorCodes::NOT_IMPLEMENTED); - } - else - { - res.reset(createWithTwoNumericTypes(*argument_types[0], *argument_types[1], argument_types)); - } - - if (!res) - { - throw Exception("Aggregate function " + name + " only supports numerical types", ErrorCodes::NOT_IMPLEMENTED); - } - - return res; -} -} - -void registerAggregateFunctionStudentTTest(AggregateFunctionFactory & factory) -{ - factory.registerFunction("studentTTest", createAggregateFunctionStudentTTest); -} -} diff --git a/src/AggregateFunctions/AggregateFunctionStudentTTest.h b/src/AggregateFunctions/AggregateFunctionStudentTTest.h deleted file mode 100644 index 0aef8f3ee2a..00000000000 --- a/src/AggregateFunctions/AggregateFunctionStudentTTest.h +++ /dev/null @@ -1,262 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace ErrorCodes -{ - extern const int BAD_ARGUMENTS; -} - -#if defined(OS_DARWIN) -extern "C" -{ - double lgammal_r(double x, int * signgamp); -} -#endif - - -namespace DB -{ - -template -struct AggregateFunctionStudentTTestData final -{ - size_t size_x = 0; - size_t size_y = 0; - X sum_x = static_cast(0); - Y sum_y = static_cast(0); - X square_sum_x = static_cast(0); - Y square_sum_y = static_cast(0); - Float64 mean_x = static_cast(0); - Float64 mean_y = static_cast(0); - - void add(X x, Y y) - { - sum_x += x; - sum_y += y; - size_x++; - size_y++; - mean_x = static_cast(sum_x) / size_x; - mean_y = static_cast(sum_y) / size_y; - square_sum_x += x * x; - square_sum_y += y * y; - } - - void merge(const AggregateFunctionStudentTTestData &other) - { - sum_x += other.sum_x; - sum_y += other.sum_y; - size_x += other.size_x; - size_y += other.size_y; - mean_x = static_cast(sum_x) / size_x; - mean_y = static_cast(sum_y) / size_y; - square_sum_x += other.square_sum_x; - square_sum_y += other.square_sum_y; - } - - void serialize(WriteBuffer &buf) const - { - writeBinary(mean_x, buf); - writeBinary(mean_y, buf); - writeBinary(sum_x, buf); - writeBinary(sum_y, buf); - writeBinary(square_sum_x, buf); - writeBinary(square_sum_y, buf); - writeBinary(size_x, buf); - writeBinary(size_y, buf); - } - - void deserialize(ReadBuffer &buf) - { - readBinary(mean_x, buf); - readBinary(mean_y, buf); - readBinary(sum_x, buf); - readBinary(sum_y, buf); - readBinary(square_sum_x, buf); - readBinary(square_sum_y, buf); - readBinary(size_x, buf); - readBinary(size_y, buf); - } - - size_t getSizeY() const - { - return size_y; - } - - size_t getSizeX() const - { - return size_x; - } - - Float64 getSSquared() const - { - /// The original formulae looks like - /// \frac{\sum_{i = 1}^{n_x}{(x_i - \bar{x}) ^ 2} + \sum_{i = 1}^{n_y}{(y_i - \bar{y}) ^ 2}}{n_x + n_y - 2} - /// But we made some mathematical transformations not to store original sequences. - /// Also we dropped sqrt, because later it will be squared later. - const Float64 all_x = square_sum_x + size_x * std::pow(mean_x, 2) - 2 * mean_x * sum_x; - const Float64 all_y = square_sum_y + size_y * std::pow(mean_y, 2) - 2 * mean_y * sum_y; - return static_cast(all_x + all_y) / (size_x + size_y - 2); - } - - - Float64 getTStatisticSquared() const - { - return std::pow(mean_x - mean_y, 2) / getStandartErrorSquared(); - } - - Float64 getTStatistic() const - { - return (mean_x - mean_y) / std::sqrt(getStandartErrorSquared()); - } - - Float64 getStandartErrorSquared() const - { - if (size_x == 0 || size_y == 0) - throw Exception("Division by zero encountered in Aggregate function StudentTTest", ErrorCodes::BAD_ARGUMENTS); - - return getSSquared() * (1.0 / static_cast(size_x) + 1.0 / static_cast(size_y)); - } - - Float64 getDegreesOfFreedom() const - { - return static_cast(size_x + size_y - 2); - } - - static Float64 integrateSimpson(Float64 a, Float64 b, std::function func) - { - const size_t iterations = std::max(1e6, 1e4 * std::abs(std::round(b))); - const long double h = (b - a) / iterations; - Float64 sum_odds = 0.0; - for (size_t i = 1; i < iterations; i += 2) - sum_odds += func(a + i * h); - Float64 sum_evens = 0.0; - for (size_t i = 2; i < iterations; i += 2) - sum_evens += func(a + i * h); - return (func(a) + func(b) + 2 * sum_evens + 4 * sum_odds) * h / 3; - } - - Float64 getPValue() const - { - const Float64 v = getDegreesOfFreedom(); - const Float64 t = getTStatisticSquared(); - auto f = [&v] (double x) { return std::pow(x, v/2 - 1) / std::sqrt(1 - x); }; - Float64 numenator = integrateSimpson(0, v / (t + v), f); - int unused; - Float64 denominator = std::exp(lgammal_r(v / 2, &unused) + lgammal_r(0.5, &unused) - lgammal_r(v / 2 + 0.5, &unused)); - return numenator / denominator; - } - - std::pair getResult() const - { - return std::make_pair(getTStatistic(), getPValue()); - } -}; - -/// Returns tuple of (t-statistic, p-value) -/// https://cpb-us-w2.wpmucdn.com/voices.uchicago.edu/dist/9/1193/files/2016/01/05b-TandP.pdf -template -class AggregateFunctionStudentTTest : - public IAggregateFunctionDataHelper,AggregateFunctionStudentTTest> -{ - -public: - AggregateFunctionStudentTTest(const DataTypes & arguments) - : IAggregateFunctionDataHelper, AggregateFunctionStudentTTest> ({arguments}, {}) - {} - - String getName() const override - { - return "studentTTest"; - } - - DataTypePtr getReturnType() const override - { - DataTypes types - { - std::make_shared>(), - std::make_shared>(), - }; - - Strings names - { - "t-statistic", - "p-value" - }; - - return std::make_shared( - std::move(types), - std::move(names) - ); - } - - void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override - { - auto col_x = assert_cast *>(columns[0]); - auto col_y = assert_cast *>(columns[1]); - - X x = col_x->getData()[row_num]; - Y y = col_y->getData()[row_num]; - - this->data(place).add(x, y); - } - - void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena *) const override - { - this->data(place).merge(this->data(rhs)); - } - - void serialize(ConstAggregateDataPtr place, WriteBuffer & buf) const override - { - this->data(place).serialize(buf); - } - - void deserialize(AggregateDataPtr place, ReadBuffer & buf, Arena *) const override - { - this->data(place).deserialize(buf); - } - - void insertResultInto(AggregateDataPtr place, IColumn & to, Arena * /*arena*/) const override - { - size_t size_x = this->data(place).getSizeX(); - size_t size_y = this->data(place).getSizeY(); - - if (size_x < 2 || size_y < 2) - { - throw Exception("Aggregate function " + getName() + " requires samples to be of size > 1", ErrorCodes::BAD_ARGUMENTS); - } - - Float64 t_statistic = 0.0; - Float64 p_value = 0.0; - std::tie(t_statistic, p_value) = this->data(place).getResult(); - - /// Because p-value is a probability. - p_value = std::min(1.0, std::max(0.0, p_value)); - - auto & column_tuple = assert_cast(to); - auto & column_stat = assert_cast &>(column_tuple.getColumn(0)); - auto & column_value = assert_cast &>(column_tuple.getColumn(1)); - - column_stat.getData().push_back(t_statistic); - column_value.getData().push_back(p_value); - } - -}; - -}; diff --git a/src/AggregateFunctions/AggregateFunctionWelchTTest.cpp b/src/AggregateFunctions/AggregateFunctionWelchTTest.cpp deleted file mode 100644 index 0dcb125305d..00000000000 --- a/src/AggregateFunctions/AggregateFunctionWelchTTest.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include -#include -#include "registerAggregateFunctions.h" - -#include -#include - -namespace ErrorCodes -{ -extern const int NOT_IMPLEMENTED; -} - -namespace DB -{ - -namespace -{ - -AggregateFunctionPtr createAggregateFunctionWelchTTest(const std::string & name, const DataTypes & argument_types, const Array & parameters) -{ - assertBinary(name, argument_types); - assertNoParameters(name, parameters); - - AggregateFunctionPtr res; - - if (isDecimal(argument_types[0]) || isDecimal(argument_types[1])) - { - throw Exception("Aggregate function " + name + " only supports numerical types", ErrorCodes::NOT_IMPLEMENTED); - } - else - { - res.reset(createWithTwoNumericTypes(*argument_types[0], *argument_types[1], argument_types)); - } - - if (!res) - { - throw Exception("Aggregate function " + name + " only supports numerical types", ErrorCodes::NOT_IMPLEMENTED); - } - - return res; -} -} - -void registerAggregateFunctionWelchTTest(AggregateFunctionFactory & factory) -{ - factory.registerFunction("welchTTest", createAggregateFunctionWelchTTest); -} -} diff --git a/src/AggregateFunctions/AggregateFunctionWelchTTest.h b/src/AggregateFunctions/AggregateFunctionWelchTTest.h deleted file mode 100644 index b598f25162e..00000000000 --- a/src/AggregateFunctions/AggregateFunctionWelchTTest.h +++ /dev/null @@ -1,274 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -namespace ErrorCodes -{ - extern const int BAD_ARGUMENTS; -} - -#if defined(OS_DARWIN) -extern "C" -{ - double lgammal_r(double x, int * signgamp); -} -#endif - - -namespace DB -{ - -template -struct AggregateFunctionWelchTTestData final -{ - size_t size_x = 0; - size_t size_y = 0; - X sum_x = static_cast(0); - Y sum_y = static_cast(0); - X square_sum_x = static_cast(0); - Y square_sum_y = static_cast(0); - Float64 mean_x = static_cast(0); - Float64 mean_y = static_cast(0); - - void add(X x, Y y) - { - sum_x += x; - sum_y += y; - size_x++; - size_y++; - mean_x = static_cast(sum_x) / size_x; - mean_y = static_cast(sum_y) / size_y; - square_sum_x += x * x; - square_sum_y += y * y; - } - - void merge(const AggregateFunctionWelchTTestData &other) - { - sum_x += other.sum_x; - sum_y += other.sum_y; - size_x += other.size_x; - size_y += other.size_y; - mean_x = static_cast(sum_x) / size_x; - mean_y = static_cast(sum_y) / size_y; - square_sum_x += other.square_sum_x; - square_sum_y += other.square_sum_y; - } - - void serialize(WriteBuffer &buf) const - { - writeBinary(mean_x, buf); - writeBinary(mean_y, buf); - writeBinary(sum_x, buf); - writeBinary(sum_y, buf); - writeBinary(square_sum_x, buf); - writeBinary(square_sum_y, buf); - writeBinary(size_x, buf); - writeBinary(size_y, buf); - } - - void deserialize(ReadBuffer &buf) - { - readBinary(mean_x, buf); - readBinary(mean_y, buf); - readBinary(sum_x, buf); - readBinary(sum_y, buf); - readBinary(square_sum_x, buf); - readBinary(square_sum_y, buf); - readBinary(size_x, buf); - readBinary(size_y, buf); - } - - size_t getSizeY() const - { - return size_y; - } - - size_t getSizeX() const - { - return size_x; - } - - Float64 getSxSquared() const - { - /// The original formulae looks like \frac{1}{size_x - 1} \sum_{i = 1}^{size_x}{(x_i - \bar{x}) ^ 2} - /// But we made some mathematical transformations not to store original sequences. - /// Also we dropped sqrt, because later it will be squared later. - return static_cast(square_sum_x + size_x * std::pow(mean_x, 2) - 2 * mean_x * sum_x) / (size_x - 1); - } - - Float64 getSySquared() const - { - /// The original formulae looks like \frac{1}{size_y - 1} \sum_{i = 1}^{size_y}{(y_i - \bar{y}) ^ 2} - /// But we made some mathematical transformations not to store original sequences. - /// Also we dropped sqrt, because later it will be squared later. - return static_cast(square_sum_y + size_y * std::pow(mean_y, 2) - 2 * mean_y * sum_y) / (size_y - 1); - } - - Float64 getTStatisticSquared() const - { - if (size_x == 0 || size_y == 0) - { - throw Exception("Division by zero encountered in Aggregate function WelchTTest", ErrorCodes::BAD_ARGUMENTS); - } - - return std::pow(mean_x - mean_y, 2) / (getSxSquared() / size_x + getSySquared() / size_y); - } - - Float64 getTStatistic() const - { - if (size_x == 0 || size_y == 0) - { - throw Exception("Division by zero encountered in Aggregate function WelchTTest", ErrorCodes::BAD_ARGUMENTS); - } - - return (mean_x - mean_y) / std::sqrt(getSxSquared() / size_x + getSySquared() / size_y); - } - - Float64 getDegreesOfFreedom() const - { - auto sx = getSxSquared(); - auto sy = getSySquared(); - Float64 numerator = std::pow(sx / size_x + sy / size_y, 2); - Float64 denominator_first = std::pow(sx, 2) / (std::pow(size_x, 2) * (size_x - 1)); - Float64 denominator_second = std::pow(sy, 2) / (std::pow(size_y, 2) * (size_y - 1)); - return numerator / (denominator_first + denominator_second); - } - - static Float64 integrateSimpson(Float64 a, Float64 b, std::function func) - { - size_t iterations = std::max(1e6, 1e4 * std::abs(std::round(b))); - double h = (b - a) / iterations; - Float64 sum_odds = 0.0; - for (size_t i = 1; i < iterations; i += 2) - sum_odds += func(a + i * h); - Float64 sum_evens = 0.0; - for (size_t i = 2; i < iterations; i += 2) - sum_evens += func(a + i * h); - return (func(a) + func(b) + 2 * sum_evens + 4 * sum_odds) * h / 3; - } - - Float64 getPValue() const - { - const Float64 v = getDegreesOfFreedom(); - const Float64 t = getTStatisticSquared(); - auto f = [&v] (double x) { return std::pow(x, v / 2 - 1) / std::sqrt(1 - x); }; - Float64 numenator = integrateSimpson(0, v / (t + v), f); - int unused; - Float64 denominator = std::exp(lgammal_r(v / 2, &unused) + lgammal_r(0.5, &unused) - lgammal_r(v / 2 + 0.5, &unused)); - return numenator / denominator; - } - - std::pair getResult() const - { - return std::make_pair(getTStatistic(), getPValue()); - } -}; - -/// Returns tuple of (t-statistic, p-value) -/// https://cpb-us-w2.wpmucdn.com/voices.uchicago.edu/dist/9/1193/files/2016/01/05b-TandP.pdf -template -class AggregateFunctionWelchTTest : - public IAggregateFunctionDataHelper,AggregateFunctionWelchTTest> -{ - -public: - AggregateFunctionWelchTTest(const DataTypes & arguments) - : IAggregateFunctionDataHelper, AggregateFunctionWelchTTest> ({arguments}, {}) - {} - - String getName() const override - { - return "welchTTest"; - } - - DataTypePtr getReturnType() const override - { - DataTypes types - { - std::make_shared>(), - std::make_shared>(), - }; - - Strings names - { - "t-statistic", - "p-value" - }; - - return std::make_shared( - std::move(types), - std::move(names) - ); - } - - void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override - { - auto col_x = assert_cast *>(columns[0]); - auto col_y = assert_cast *>(columns[1]); - - X x = col_x->getData()[row_num]; - Y y = col_y->getData()[row_num]; - - this->data(place).add(x, y); - } - - void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena *) const override - { - this->data(place).merge(this->data(rhs)); - } - - void serialize(ConstAggregateDataPtr place, WriteBuffer & buf) const override - { - this->data(place).serialize(buf); - } - - void deserialize(AggregateDataPtr place, ReadBuffer & buf, Arena *) const override - { - this->data(place).deserialize(buf); - } - - void insertResultInto(AggregateDataPtr place, IColumn & to, Arena * /*arena*/) const override - { - size_t size_x = this->data(place).getSizeX(); - size_t size_y = this->data(place).getSizeY(); - - if (size_x < 2 || size_y < 2) - { - throw Exception("Aggregate function " + getName() + " requires samples to be of size > 1", ErrorCodes::BAD_ARGUMENTS); - } - - Float64 t_statistic = 0.0; - Float64 p_value = 0.0; - std::tie(t_statistic, p_value) = this->data(place).getResult(); - - /// Because p-value is a probability. - p_value = std::min(1.0, std::max(0.0, p_value)); - - auto & column_tuple = assert_cast(to); - auto & column_stat = assert_cast &>(column_tuple.getColumn(0)); - auto & column_value = assert_cast &>(column_tuple.getColumn(1)); - - column_stat.getData().push_back(t_statistic); - column_value.getData().push_back(p_value); - } - -}; - -}; diff --git a/src/AggregateFunctions/registerAggregateFunctions.cpp b/src/AggregateFunctions/registerAggregateFunctions.cpp index 9fd02ba9d6c..90109a98433 100644 --- a/src/AggregateFunctions/registerAggregateFunctions.cpp +++ b/src/AggregateFunctions/registerAggregateFunctions.cpp @@ -7,6 +7,54 @@ namespace DB { +class AggregateFunctionFactory; +void registerAggregateFunctionAvg(AggregateFunctionFactory &); +void registerAggregateFunctionAvgWeighted(AggregateFunctionFactory &); +void registerAggregateFunctionCount(AggregateFunctionFactory &); +void registerAggregateFunctionGroupArray(AggregateFunctionFactory &); +void registerAggregateFunctionGroupUniqArray(AggregateFunctionFactory &); +void registerAggregateFunctionGroupArrayInsertAt(AggregateFunctionFactory &); +void registerAggregateFunctionsQuantile(AggregateFunctionFactory &); +void registerAggregateFunctionsSequenceMatch(AggregateFunctionFactory &); +void registerAggregateFunctionWindowFunnel(AggregateFunctionFactory &); +void registerAggregateFunctionRate(AggregateFunctionFactory &); +void registerAggregateFunctionsMinMaxAny(AggregateFunctionFactory &); +void registerAggregateFunctionsStatisticsStable(AggregateFunctionFactory &); +void registerAggregateFunctionsStatisticsSimple(AggregateFunctionFactory &); +void registerAggregateFunctionSum(AggregateFunctionFactory &); +void registerAggregateFunctionSumMap(AggregateFunctionFactory &); +void registerAggregateFunctionsUniq(AggregateFunctionFactory &); +void registerAggregateFunctionUniqCombined(AggregateFunctionFactory &); +void registerAggregateFunctionUniqUpTo(AggregateFunctionFactory &); +void registerAggregateFunctionTopK(AggregateFunctionFactory &); +void registerAggregateFunctionsBitwise(AggregateFunctionFactory &); +void registerAggregateFunctionsBitmap(AggregateFunctionFactory &); +void registerAggregateFunctionsMaxIntersections(AggregateFunctionFactory &); +void registerAggregateFunctionHistogram(AggregateFunctionFactory &); +void registerAggregateFunctionRetention(AggregateFunctionFactory &); +void registerAggregateFunctionTimeSeriesGroupSum(AggregateFunctionFactory &); +void registerAggregateFunctionMLMethod(AggregateFunctionFactory &); +void registerAggregateFunctionEntropy(AggregateFunctionFactory &); +void registerAggregateFunctionSimpleLinearRegression(AggregateFunctionFactory &); +void registerAggregateFunctionMoving(AggregateFunctionFactory &); +void registerAggregateFunctionCategoricalIV(AggregateFunctionFactory &); +void registerAggregateFunctionAggThrow(AggregateFunctionFactory &); +void registerAggregateFunctionWelchTTest(AggregateFunctionFactory &); +void registerAggregateFunctionStudentTTest(AggregateFunctionFactory &); +void registerAggregateFunctionRankCorrelation(AggregateFunctionFactory &); + +class AggregateFunctionCombinatorFactory; +void registerAggregateFunctionCombinatorIf(AggregateFunctionCombinatorFactory &); +void registerAggregateFunctionCombinatorArray(AggregateFunctionCombinatorFactory &); +void registerAggregateFunctionCombinatorForEach(AggregateFunctionCombinatorFactory &); +void registerAggregateFunctionCombinatorState(AggregateFunctionCombinatorFactory &); +void registerAggregateFunctionCombinatorMerge(AggregateFunctionCombinatorFactory &); +void registerAggregateFunctionCombinatorNull(AggregateFunctionCombinatorFactory &); +void registerAggregateFunctionCombinatorOrFill(AggregateFunctionCombinatorFactory &); +void registerAggregateFunctionCombinatorResample(AggregateFunctionCombinatorFactory &); +void registerAggregateFunctionCombinatorDistinct(AggregateFunctionCombinatorFactory &); + + void registerAggregateFunctions() { { @@ -45,8 +93,6 @@ void registerAggregateFunctions() registerAggregateFunctionMoving(factory); registerAggregateFunctionCategoricalIV(factory); registerAggregateFunctionAggThrow(factory); - registerAggregateFunctionWelchTTest(factory); - registerAggregateFunctionStudentTTest(factory); registerAggregateFunctionRankCorrelation(factory); } diff --git a/src/AggregateFunctions/registerAggregateFunctions.h b/src/AggregateFunctions/registerAggregateFunctions.h index abbba56ed32..2a2e0bb7d3f 100644 --- a/src/AggregateFunctions/registerAggregateFunctions.h +++ b/src/AggregateFunctions/registerAggregateFunctions.h @@ -3,53 +3,6 @@ namespace DB { -class AggregateFunctionFactory; -void registerAggregateFunctionAvg(AggregateFunctionFactory &); -void registerAggregateFunctionAvgWeighted(AggregateFunctionFactory &); -void registerAggregateFunctionCount(AggregateFunctionFactory &); -void registerAggregateFunctionGroupArray(AggregateFunctionFactory &); -void registerAggregateFunctionGroupUniqArray(AggregateFunctionFactory &); -void registerAggregateFunctionGroupArrayInsertAt(AggregateFunctionFactory &); -void registerAggregateFunctionsQuantile(AggregateFunctionFactory &); -void registerAggregateFunctionsSequenceMatch(AggregateFunctionFactory &); -void registerAggregateFunctionWindowFunnel(AggregateFunctionFactory &); -void registerAggregateFunctionRate(AggregateFunctionFactory &); -void registerAggregateFunctionsMinMaxAny(AggregateFunctionFactory &); -void registerAggregateFunctionsStatisticsStable(AggregateFunctionFactory &); -void registerAggregateFunctionsStatisticsSimple(AggregateFunctionFactory &); -void registerAggregateFunctionSum(AggregateFunctionFactory &); -void registerAggregateFunctionSumMap(AggregateFunctionFactory &); -void registerAggregateFunctionsUniq(AggregateFunctionFactory &); -void registerAggregateFunctionUniqCombined(AggregateFunctionFactory &); -void registerAggregateFunctionUniqUpTo(AggregateFunctionFactory &); -void registerAggregateFunctionTopK(AggregateFunctionFactory &); -void registerAggregateFunctionsBitwise(AggregateFunctionFactory &); -void registerAggregateFunctionsBitmap(AggregateFunctionFactory &); -void registerAggregateFunctionsMaxIntersections(AggregateFunctionFactory &); -void registerAggregateFunctionHistogram(AggregateFunctionFactory &); -void registerAggregateFunctionRetention(AggregateFunctionFactory &); -void registerAggregateFunctionTimeSeriesGroupSum(AggregateFunctionFactory &); -void registerAggregateFunctionMLMethod(AggregateFunctionFactory &); -void registerAggregateFunctionEntropy(AggregateFunctionFactory &); -void registerAggregateFunctionSimpleLinearRegression(AggregateFunctionFactory &); -void registerAggregateFunctionMoving(AggregateFunctionFactory &); -void registerAggregateFunctionCategoricalIV(AggregateFunctionFactory &); -void registerAggregateFunctionAggThrow(AggregateFunctionFactory &); -void registerAggregateFunctionWelchTTest(AggregateFunctionFactory &); -void registerAggregateFunctionStudentTTest(AggregateFunctionFactory &); -void registerAggregateFunctionRankCorrelation(AggregateFunctionFactory &); - -class AggregateFunctionCombinatorFactory; -void registerAggregateFunctionCombinatorIf(AggregateFunctionCombinatorFactory &); -void registerAggregateFunctionCombinatorArray(AggregateFunctionCombinatorFactory &); -void registerAggregateFunctionCombinatorForEach(AggregateFunctionCombinatorFactory &); -void registerAggregateFunctionCombinatorState(AggregateFunctionCombinatorFactory &); -void registerAggregateFunctionCombinatorMerge(AggregateFunctionCombinatorFactory &); -void registerAggregateFunctionCombinatorNull(AggregateFunctionCombinatorFactory &); -void registerAggregateFunctionCombinatorOrFill(AggregateFunctionCombinatorFactory &); -void registerAggregateFunctionCombinatorResample(AggregateFunctionCombinatorFactory &); -void registerAggregateFunctionCombinatorDistinct(AggregateFunctionCombinatorFactory &); - void registerAggregateFunctions(); } diff --git a/src/AggregateFunctions/ya.make b/src/AggregateFunctions/ya.make index 8d27cf986d0..80b8de0eea7 100644 --- a/src/AggregateFunctions/ya.make +++ b/src/AggregateFunctions/ya.make @@ -41,7 +41,6 @@ SRCS( AggregateFunctionState.cpp AggregateFunctionStatistics.cpp AggregateFunctionStatisticsSimple.cpp - AggregateFunctionStudentTTest.cpp AggregateFunctionSum.cpp AggregateFunctionSumMap.cpp AggregateFunctionTimeSeriesGroupSum.cpp @@ -49,7 +48,6 @@ SRCS( AggregateFunctionUniqCombined.cpp AggregateFunctionUniq.cpp AggregateFunctionUniqUpTo.cpp - AggregateFunctionWelchTTest.cpp AggregateFunctionWindowFunnel.cpp parseAggregateFunctionParameters.cpp registerAggregateFunctions.cpp diff --git a/tests/queries/0_stateless/01322_student_ttest.sql b/tests/queries/0_stateless/01322_student_ttest.sql deleted file mode 100644 index b8b86384bc4..00000000000 --- a/tests/queries/0_stateless/01322_student_ttest.sql +++ /dev/null @@ -1,19 +0,0 @@ -DROP TABLE IF EXISTS student_ttest; - -/*Check t-stat and p-value and compare it with scipy.stat implementation - First: a=1, sigma (not sigma^2)=5, size=500 - Second: a=1, sigma = 5, size = 500 */ -CREATE TABLE student_ttest (left Float64, right Float64) ENGINE = Memory; -INSERT INTO student_ttest VALUES (0.88854,-2.90702), (-5.76966,3.61651), (6.76618,4.27458), (3.55546,4.82133), (-9.76948,9.59483), (4.92323,1.00424), (-0.36352,2.04147), (0.97018,-3.58214), (4.61656,6.59543), (-6.78292,-1.00532), (4.02008,-3.59794), (12.41838,-2.82434), (5.14417,-3.13194), (3.86836,9.90977), (-1.26199,0.523), (12.44106,4.62779), (3.28349,-2.56872), (1.77261,2.25807), (-8.94748,1.04044), (-1.01449,-2.35744), (-1.26377,10.81531), (6.79682,-9.68469), (6.32333,3.80885), (-8.21214,12.70435), (-1.68565,-6.01112), (9.7557,1.89065), (3.66694,5.08892), (1.39967,3.45254), (-5.52035,11.58151), (-10.95601,0.85035), (0.93877,8.38397), (1.45933,1.17169), (-5.40551,4.74621), (-0.83857,-1.66614), (8.50794,4.2414), (-6.68686,1.68765), (5.03099,1.85223), (1.56251,9.10111), (4.17381,-2.38085), (-2.92644,-14.79595), (5.11068,-3.8938), (2.09617,-3.41864), (11.7787,-3.15282), (6.50336,-0.56684), (0.62098,12.87997), (-7.97121,6.89115), (3.81902,12.921), (0.33151,-7.94908), (10.68584,2.45687), (0.56007,2.14957), (-7.38621,7.55081), (5.05882,-3.71534), (2.34616,-2.41064), (11.3806,-0.80734), (5.95276,-4.75651), (-3.01429,2.05241), (5.98169,-5.44523), (0.96985,-2.75054), (-1.15932,-13.00131), (2.11547,-2.74451), (2.49668,-1.39004), (-12.49569,-3.02854), (-4.94667,7.65112), (-3.64215,1.1245), (-8.35595,6.74117), (3.211,-0.75777), (2.33805,8.93451), (2.38608,-8.85559), (-3.2862,-0.36405), (-0.80454,4.02742), (-0.53483,6.88718), (10.66445,-1.05124), (-0.37619,3.04085), (0.48246,3.32368), (7.41919,1.147), (0.42414,3.41554), (-2.32335,-3.47851), (-0.70223,-0.47684), (-5.9332,-0.55605), (-1.20561,-0.17006), (3.39865,2.26218), (9.61739,12.45494), (-0.78651,-1.84097), (-4.00256,1.64934), (-7.99646,-7.07496), (8.72923,-9.99462), (0.71859,6.09954), (-1.62726,-1.05319), (5.11234,3.04757), (-0.95625,0.93899), (-3.75573,-4.63243), (1.03141,-7.43322), (-3.33588,-7.298), (1.51804,-6.59016), (-3.30935,-6.11649), (-1.97507,0.56682), (4.06456,2.00661), (3.27195,-2.79814), (-7.81761,2.84482), (-3.81785,3.65348), (-4.18311,-4.22807), (-11.33313,-4.54336), (-0.25221,-3.63343), (7.2514,2.96878), (5.30301,6.11661), (2.46762,-1.70919), (4.22716,-4.71133), (0.33916,6.09652), (9.7638,-6.83454), (-7.58684,0.18006), (-4.09888,1.51676), (4.26617,-5.31646), (-0.56744,-3.21215), (4.65125,-5.07599), (-1.30301,-2.36591), (4.53771,3.55724), (9.96929,4.8904), (3.72939,-3.22586), (-2.29818,-1.74928), (3.09417,5.73458), (0.82251,1.41188), (5.29975,2.86255), (2.8685,2.90179), (-5.73321,-2.19949), (-1.85651,1.72727), (-1.07984,1.76939), (9.78342,-0.12848), (-13.49652,-0.52), (3.68791,3.48333), (1.9998,7.8262), (1.11674,0.09099), (9.43869,7.77017), (4.07029,9.49484), (5.32715,1.42825), (7.16504,1.99624), (6.66096,4.00419), (-5.7111,1.07925), (-0.38575,-0.09987), (4.49165,-5.48733), (-3.36489,-1.83517), (7.71814,2.38059), (-1.58966,1.42075), (-1.61063,-1.11968), (-0.91602,-6.46035), (0.73459,7.66576), (-3.24463,4.6307), (6.3947,5.55989), (-2.77845,3.16684), (4.45899,5.07671), (-8.84186,-10.20566), (2.62276,-4.73386), (1.774,1.28353), (4.3692,6.75679), (0.05942,12.09895), (-1.44042,7.0049), (-2.53594,7.16156), (-2.24752,-0.64311), (4.98874,-0.66747), (4.05434,3.99996), (-2.56483,9.07298), (-6.79286,-4.60971), (-2.06165,0.70744), (-0.26056,2.56774), (1.89567,9.32424), (-3.15145,3.95087), (-7.31321,7.11372), (0.28936,-0.89284), (-0.63111,8.6155), (0.22611,-0.14141), (-9.3377,-4.86319), (-5.76638,-6.95801), (3.87306,4.44883), (6.7011,4.6156), (9.03915,-2.3579), (-1.21835,-5.1186), (0.82892,8.12819), (2.80656,2.78392), (-1.34746,-4.30221), (-1.99912,-1.47506), (0.6036,6.8598), (-3.46117,0.47636), (5.23732,0.95383), (-1.86702,7.79779), (-5.86115,-2.61767), (6.48523,-10.5087), (-7.40158,-2.74299), (-1.38913,3.87369), (4.94613,-1.07093), (-2.07818,4.98864), (2.39808,-7.50772), (4.89238,6.41316), (4.39481,1.39061), (5.20425,-3.1747), (13.62598,-2.13621), (-2.86293,-0.02203), (-3.62396,0.89025), (-4.28695,-5.87746), (4.66425,3.60026), (2.20871,-0.23178), (1.60382,-2.1897), (-9.87024,-5.85101), (-7.37302,-1.6053), (-4.17814,3.6184), (2.5148,-8.53795), (3.21708,-0.35987), (-11.48089,2.15301), (1.19821,-6.60692), (-0.07436,9.54341), (-1.10652,1.11511), (4.03395,2.94025), (-4.35883,12.05657), (2.04013,3.75156), (0.52264,7.95597), (8.14004,-0.99449), (-8.86949,0.90597), (-0.35807,-7.90627), (-10.71113,3.50863), (-2.13755,-1.47493), (0.50715,4.11671), (6.30826,10.06325), (2.37527,-1.06059), (0.20872,-1.37737), (-5.85729,-0.42542), (-4.97217,-3.90267), (-9.78434,9.35037), (-1.53277,-7.91219), (0.14827,-4.69945), (-1.053,3.63776), (1.74558,3.46492), (11.17194,2.84518), (9.35487,-3.04301), (-9.17209,8.82764), (10.41814,7.80134), (7.41206,7.87755), (3.71775,7.01035), (-2.04674,2.43271), (6.18037,11.36418), (5.6383,-6.92659), (-0.90058,5.95541), (-1.27073,3.59436), (-2.3473,5.18429), (-8.44271,4.20225), (2.75551,0.5029), (-1.15521,4.03074), (4.08722,5.23152), (-1.70399,10.65409), (7.24114,-0.69845), (-8.43976,11.70096), (-1.53052,5.80692), (-0.00526,-8.1819), (-4.04813,4.31485), (-2.84299,5.7227), (-5.201,5.67398), (7.75774,-1.75826), (-2.85791,7.54164), (-3.86071,-1.79026), (-1.80029,-1.7395), (-5.26015,5.65042), (-3.158,0.38765), (7.71014,-4.64719), (-4.84866,-10.22048), (-8.38785,-2.05447), (7.67021,-2.43441), (4.96521,-5.38551), (-0.40919,5.47764), (-3.25711,8.26637), (3.07685,-3.6421), (2.89376,-11.66269), (-10.47331,3.972), (-3.48942,5.46642), (1.13906,-3.72304), (-8.57454,5.75251), (-3.38963,5.12841), (-2.3195,0.59067), (-1.60694,5.21138), (-5.57406,-4.58702), (-0.93075,-8.737), (-11.76579,-2.12737), (10.68283,0.22888), (8.74324,-1.46448), (7.66409,2.40311), (4.76715,-5.21814), (0.44539,13.94749), (-1.35941,-2.77448), (4.18849,-3.7867), (-6.17097,3.4954), (0.27977,3.12586), (-1.45006,-7.01485), (-4.81694,-3.20727), (-3.0297,6.31415), (0.02145,2.37521), (2.46883,8.13787), (9.60317,2.15956), (-9.93898,-0.40842), (1.05549,-7.27283), (5.55366,4.27575), (-3.80722,-2.89126), (-4.18851,6.84344), (1.00351,7.0869), (3.11385,-5.18837), (-5.17623,2.67648), (-3.18396,-6.57021), (-6.65302,0.60429), (-0.50832,-1.04921), (-4.04375,7.12873), (4.52707,1.68973), (6.63124,-2.58404), (-3.72082,-3.83114), (5.79825,-7.26546), (-2.0158,-5.07153), (-2.78369,-0.80395), (-1.91821,2.09455), (6.31714,4.33374), (-1.80869,8.54335), (8.55586,0.80566), (2.40826,-8.38085), (-8.46361,7.54812), (5.04452,8.78007), (-0.84665,1.5857), (2.30903,8.43855), (-3.71837,-1.90846), (-0.69419,-1.2434), (3.6733,7.16172), (-1.96098,-3.44129), (2.36747,-6.37542), (-12.03622,-4.99486), (4.38481,4.99033), (2.93955,-1.83734), (2.16804,-2.83289), (-0.08218,-4.13997), (-3.97934,1.40163), (-7.43985,8.57867), (0.91666,-1.87639), (7.23432,3.41667), (-6.13303,6.31762), (-10.23217,1.58473), (-6.21681,1.63625), (-0.80934,-6.93618), (0.17914,3.58046), (2.13338,-6.8097), (6.97656,4.69978), (6.90455,-1.72912), (6.25943,5.29491), (-6.04019,-1.63062), (-7.30909,5.83818), (1.4589,17.0769), (12.00208,4.54301), (2.22457,-1.33801), (-2.45912,5.64339), (-6.92213,1.26913), (4.05547,-1.01553), (0.04709,4.8316), (-7.70952,3.08635), (-1.47883,-2.27738), (1.3701,-1.13761), (-4.92928,10.08698), (-2.75872,5.33827), (-0.09178,2.84345), (2.62642,-1.51132), (-1.14623,13.46078), (2.76609,8.58965), (4.94404,-2.36683), (-7.01764,-1.8217), (-10.91568,1.96981), (-2.49738,2.31718), (0.73576,3.66493), (2.25436,1.93104), (-1.72956,5.20332), (2.41054,3.20519), (5.72149,3.34631), (-6.41371,7.0087), (3.38217,-7.96126), (1.24133,-0.62182), (10.03634,-4.65227), (-2.37303,10.6572), (-1.35543,4.50891), (-1.4387,9.74298), (-4.0976,3.85707), (-0.82501,6.41144), (-1.93498,1.48649), (5.59955,2.28076), (5.46656,2.75342), (2.43568,-5.40401), (-0.23926,7.11389), (-4.9945,5.74368), (-4.96655,6.78345), (-0.59258,3.83773), (2.02497,0.70959), (0.67583,0.57434), (3.16522,1.5888), (-1.9673,3.94889), (-6.75319,5.8234), (-6.69723,7.78366), (0.81148,9.08354), (4.44531,-7.99182), (-4.43522,-2.77033), (-5.28602,-10.29342), (-3.58829,1.76251), (-7.97395,2.09266), (-2.84891,4.20614), (-3.95112,-3.63064), (3.54945,-2.17794), (12.12376,-2.66225), (-3.12347,-2.74707), (3.65209,-1.93431), (9.34031,1.38629), (-0.26348,4.12816), (-5.23968,-1.58902), (2.22336,-5.08864), (-10.70405,-2.30491), (-4.41319,2.64605), (-5.94912,1.16158), (1.8147,2.63534), (7.69287,1.4956), (9.46125,-4.60768), (4.72497,0.60771), (-0.57565,3.29549), (-1.12303,-1.42592), (2.90272,0.8883), (-4.4584,-1.10612), (4.28819,-2.57296), (11.64512,5.88085), (-1.80395,7.40745), (2.51605,13.48116), (-3.18439,5.53539), (-0.70213,-1.46014), (-7.68383,3.73304), (-8.32268,3.5435), (-8.71115,-3.89151), (9.96933,4.16265), (0.95675,2.32663), (3.35114,5.31735), (-2.66008,6.33485), (7.75456,2.1339), (0.73568,0.82708), (0.3483,-2.95155), (-1.09203,-6.76019), (-7.76963,-4.20179), (5.81902,8.78354), (-3.41424,1.41863), (-0.39209,7.65689), (4.67608,-6.52601), (0.68753,-4.4426), (5.17179,-4.49483), (4.98983,-3.91479), (-0.12659,-2.84562), (3.25267,2.58974), (1.50184,2.24424), (2.94507,-4.65846), (-0.42333,8.4062), (-3.66227,8.20262), (8.90812,-8.63752), (4.74411,4.97966), (2.22018,-0.35563), (-2.07976,-4.72116), (4.8711,-2.95997), (0.5023,2.73959), (6.31569,-0.23956), (-4.36903,10.13915), (3.82146,11.83775), (-6.99477,-2.50332), (3.61225,-0.58181), (14.69335,-7.62836), (0.58368,2.26478), (4.65341,-3.50179), (-3.14272,-2.08023), (2.67048,4.07256), (4.64963,-1.40826), (-2.70828,-2.33644), (1.42923,3.00197), (5.84498,4.23668), (-4.76568,-2.24647), (0.19907,1.0445), (1.67486,-0.31901), (5.32145,8.62657), (-8.03477,3.92817), (3.46776,0.08462), (4.66374,10.15884), (-5.37394,0.4113), (5.39045,4.45847), (-1.44756,5.82941), (-1.64419,6.59202), (3.39699,-3.73441), (-2.94659,-5.86969), (-2.38437,-4.56543), (-0.23958,-1.32636), (6.88389,-0.17884), (-2.7172,-3.56181), (-1.53419,-0.66932), (7.38841,6.87538), (-5.44178,0.73527), (-0.89287,-0.24177), (2.93546,-0.8657), (-0.26901,-0.22977), (-4.70044,1.02095), (2.25846,6.16311), (-9.28813,-5.68027), (6.04268,-3.7619), (4.41693,4.22959), (1.75714,-1.5249); -SELECT '-2.610898982580138', '0.00916587538237954'; -SELECT roundBankers(studentTTest(left, right).1, 16) as t_stat, roundBankers(studentTTest(left, right).2, 16) as p_value from student_ttest; -DROP TABLE IF EXISTS student_ttest; - -/*Check t-stat and p-value and compare it with scipy.stat implementation - First: a=1, sigma (not sigma^2)=5, size=500 - Second: a=1, sigma = 5, size = 500 */ -CREATE TABLE student_ttest (left Float64, right Float64) ENGINE = Memory; -INSERT INTO student_ttest VALUES (4.52546,8.69444), (3.73628,3.81414), (-0.39478,12.38442), (5.15633,8.9738), (0.50539,9.19594), (-5.34036,7.21009), (0.19336,4.97743), (8.35729,4.94756), (6.95818,19.80911), (-2.93812,13.75358), (8.30807,16.56373), (-3.3517,9.72882), (4.16279,4.64509), (-3.17231,17.76854), (1.93545,4.80693), (11.06606,8.79505), (-4.22678,10.88868), (-1.99975,6.21932), (-4.51178,15.11614), (-4.50711,13.24703), (1.89786,14.76476), (-6.19638,-0.6117), (-3.70188,17.48993), (5.01334,12.11847), (1.79036,4.87439), (2.14435,18.56479), (3.0282,1.23712), (2.35528,5.41596), (-12.18535,4.54994), (5.59709,11.37668), (-12.92336,9.5982), (-0.04281,6.59822), (-0.16923,1.16703), (0.88924,8.88418), (-4.68414,10.95047), (8.01099,5.52787), (2.61686,-1.11647), (-2.76895,14.49946), (3.32165,3.27585), (-0.85135,-0.42025), (1.21368,6.37906), (4.38673,2.5242), (6.20964,8.1405), (-1.23172,6.46732), (4.65516,9.89332), (-1.87143,10.4374), (0.86429,-1.06465), (2.51184,6.84902), (-1.88822,10.96576), (-1.61802,7.83319), (1.93653,14.39823), (-3.66631,7.02594), (-1.05294,13.46629), (-10.74718,10.39531), (16.49295,11.27348), (-7.65494,9.32187), (-3.39303,12.32667), (-4.89418,8.98905), (3.2521,9.54757), (0.05831,5.98325), (-3.00409,3.47248), (5.76702,9.26966), (2.67674,5.77816), (10.52623,6.32966), (-0.54501,9.49313), (-4.89835,6.21337), (3.52457,10.00242), (-0.0451,6.25167), (-6.61226,15.64671), (9.02391,2.78968), (5.52571,6.55442), (4.54352,3.68819), (-3.8394,9.55934), (-7.75295,4.166), (5.91167,12.32471), (1.38897,7.10969), (6.24166,16.31723), (5.58536,12.99482), (4.7591,10.11585), (-2.58336,10.29455), (-1.91263,18.27524), (3.31575,12.84435), (5.3507,13.11954), (-15.22081,12.84147), (-0.84775,15.55658), (-4.538,11.45329), (6.71177,7.50912), (0.52882,8.56226), (2.0242,8.63104), (5.69146,15.68026), (4.63328,21.6361), (0.22984,6.23925), (-2.84052,8.65714), (7.91867,9.9423), (1.11001,12.28213), (-0.11251,3.11279), (-0.20905,13.58128), (0.03287,16.51407), (-1.59397,16.60476), (-5.39405,12.02022), (-7.1233,12.11035), (4.51517,9.47832), (-0.70967,6.40742), (5.67299,8.87252), (-0.33835,15.14265), (-1.83047,2.23572), (-0.62877,11.57144), (-7.23148,18.87737), (0.1802,12.1833), (11.73325,11.17519), (2.17603,16.80422), (-0.11683,6.81423), (-1.29102,12.12546), (-0.23201,8.06153), (-6.8643,10.97228), (-6.85153,7.30596), (-4.77163,15.44026), (6.11721,8.00993), (5.96406,12.60196), (3.59135,13.96832), (-0.60095,14.03207), (3.11163,4.53758), (-0.18831,8.08297), (0.67657,4.90451), (-3.16117,8.14253), (0.26957,19.88605), (2.18653,13.85254), (-5.94611,23.01839), (-4.39352,6.02084), (-3.71525,9.60319), (5.11103,1.90511), (1.33998,10.35237), (1.01629,16.27082), (-3.36917,12.52379), (-3.99661,11.37435), (8.19336,13.61823), (2.89168,15.77622), (-11.10373,15.17254), (11.68005,6.711), (3.08282,4.74205), (-6.81506,10.09812), (-2.34587,6.61722), (-2.68725,10.34164), (0.3577,8.96602), (-3.05682,12.32157), (9.08062,11.75711), (-0.77913,13.49499), (10.35215,8.57713), (6.82565,11.50313), (-1.24674,1.13097), (5.18822,7.83205), (-3.70743,5.77957), (1.40319,15.5519), (5.89432,10.82676), (1.43152,11.51218), (6.70638,9.29779), (9.76613,9.77021), (4.27604,9.94114), (-2.63141,15.54513), (-7.8133,19.10736), (-0.06668,15.04205), (1.05391,9.03114), (4.41797,24.0104), (0.09337,9.94205), (6.16075,2.5925), (7.49413,8.82726), (-3.52872,10.0209), (-2.17126,8.1635), (-3.87605,4.24074), (3.26607,7.67291), (-3.28045,5.21642), (2.1429,11.2808), (1.53386,6.88172), (0.21169,5.98743), (-0.63674,17.97249), (5.84893,6.46323), (-0.63498,15.37416), (8.29526,2.89957), (-1.08358,17.13044), (-2.306,11.06355), (2.86991,3.09625), (-0.76074,-2.33019), (5.49191,7.42675), (1.82883,15.06792), (-3.70497,8.81116), (-0.53232,19.17446), (-11.49722,18.77181), (3.44877,14.06443), (-1.8596,12.81241), (-10.34851,2.72299), (1.13093,18.67739), (-10.93389,11.63275), (-3.39703,2.23891), (0.19749,13.01195), (-3.68389,7.43402), (-4.67863,8.14599), (10.78916,16.65328), (0.37675,1.362), (3.98094,3.87957), (-3.64775,11.16134), (-4.8443,6.25357), (1.102,4.21945), (8.72112,12.50047), (-1.47361,6.45486), (6.24183,18.99924), (6.83569,18.09508), (-3.11684,13.59528), (4.91306,3.39681), (-0.03628,13.33157), (5.1282,5.8945), (-2.38558,5.61212), (2.33351,8.41149), (-0.97191,13.78608), (-0.05588,6.08609), (-4.70019,12.76962), (-5.12371,3.26206), (0.65606,0.25528), (-0.11574,11.9083), (4.4238,4.35071), (6.93399,11.19855), (3.68712,13.87404), (-0.01187,6.87986), (1.8332,8.32566), (5.81322,22.51334), (-4.04709,2.5226), (-8.26397,16.84498), (-2.11273,6.26108), (5.28396,13.84824), (0.73054,6.03262), (6.43559,14.12668), (4.35565,16.01939), (-1.05545,8.19237), (5.00087,18.01595), (-2.72239,9.45609), (7.32313,6.90459), (2.11548,12.83115), (-3.40953,10.603), (6.97051,13.70439), (-0.45567,6.1633), (1.31699,4.1151), (-1.49871,8.20499), (7.14772,11.67903), (0.79277,7.30851), (6.9698,6.50941), (2.08733,7.3949), (-3.55962,12.80075), (0.75601,5.62043), (1.21,18.2542), (-2.17877,17.9393), (1.83206,16.4569), (5.72463,8.78811), (7.42257,4.85949), (0.97829,-3.36394), (7.54238,5.38683), (9.91081,12.26083), (-4.61743,10.27907), (-4.40799,11.5144), (9.99854,11.57335), (8.53725,1.94203), (3.2905,7.78228), (0.38634,11.79385), (-2.53374,10.18415), (4.94758,14.67613), (4.79624,4.70301), (5.57664,12.72151), (-6.44871,-3.35508), (3.34431,17.63775), (0.14209,2.53883), (10.88431,14.01483), (0.31846,12.4387), (-0.54703,11.15408), (-4.67791,7.74882), (-5.68011,13.60956), (-4.93362,7.81991), (1.2271,10.90969), (5.27512,8.19828), (-3.84611,-1.18523), (6.81706,0.5916), (10.33033,0.35805), (5.13979,12.98364), (3.66534,11.38628), (-2.07219,13.94644), (10.65442,2.03781), (-3.31751,10.74447), (-1.82011,12.35656), (-0.39886,7.08701), (1.77052,2.69871), (1.29049,19.66653), (7.92344,7.88636), (-2.92595,10.36916), (-2.67107,1.632), (5.64708,11.86081), (0.34639,13.47602), (-3.04356,6.60204), (3.98828,7.01303), (-1.36695,20.19992), (-8.48462,18.88249), (-4.04669,11.34367), (9.84561,12.97305), (-6.1537,9.5776), (0.82433,17.91364), (1.92449,18.3247), (2.51288,9.9211), (0.40965,7.14257), (2.89183,6.59133), (3.84347,12.35274), (0.66829,10.57523), (-3.45094,12.12859), (1.3544,9.47177), (-9.85456,0.60659), (5.25689,4.72996), (-5.26018,4.51121), (-6.16912,13.28893), (-1.77163,8.09014), (3.96687,8.02511), (0.70893,13.85406), (-5.45342,1.75412), (-3.89706,6.00641), (3.11868,6.35554), (4.41714,7.11293), (7.64841,8.30442), (0.00489,12.63024), (3.2263,12.38966), (-5.33042,7.6801), (2.52189,11.33744), (-7.40308,4.67713), (0.67891,7.62276), (2.49343,2.14478), (5.43133,15.32988), (-0.67541,1.52299), (-0.60299,17.00017), (-6.32903,8.29701), (-3.44336,10.92961), (-0.23963,6.78449), (6.94686,7.02698), (6.59442,11.51719), (-4.18532,9.97926), (-1.8228,7.44251), (-0.29443,7.58541), (2.99821,4.76058), (2.51942,12.88959), (-3.49176,9.974), (-0.57979,17.03689), (8.69471,11.14554), (-1.19427,11.7392), (-3.17119,11.50029), (-2.99566,19.41759), (-3.34493,9.65127), (-2.33826,9.87673), (-5.04164,14.13485), (-0.48214,9.78034), (7.45097,1.57826), (3.04787,3.72091), (2.92632,9.4054), (1.39694,23.22816), (4.38686,-0.12571), (3.25753,6.97343), (7.14218,10.09049), (-4.04341,11.78393), (-9.19352,3.01909), (2.78473,16.09448), (0.33331,6.25485), (9.89238,7.13164), (6.00566,7.75879), (-1.7511,9.56834), (4.77815,6.14824), (5.07457,13.53454), (2.56132,8.26364), (2.38317,8.7095), (-1.63486,10.61607), (-1.46871,10.64418), (-5.8681,23.9106), (-2.96227,11.38978), (-1.90638,11.4383), (-13.3052,18.41498), (-2.14705,3.70959), (-9.62069,19.95918), (2.29313,9.53847), (0.22162,14.04957), (-1.83956,13.70151), (4.1853,5.45046), (6.05965,10.95061), (-0.23737,9.55156), (6.07452,17.92345), (4.34629,6.23976), (4.02922,8.71029), (3.62622,13.58736), (-3.95825,8.78527), (-1.63412,11.14213), (-1.25727,12.23717), (5.06323,16.44557), (-0.66176,0.47144), (2.36606,9.7198), (-5.77792,13.50981), (4.535,14.27806), (1.02031,13.50793), (4.49345,7.47381), (-4.99791,11.07844), (2.46716,9.89844), (3.65471,21.48548), (11.2283,6.92085), (6.69743,4.44074), (-5.60375,19.98074), (0.28683,7.92826), (-0.85737,16.6313), (4.26726,17.17618), (-3.4322,13.80807), (-2.07039,5.37083), (-2.26798,9.73962), (-0.99818,10.66273), (0.41335,8.90639), (5.18124,12.24596), (-5.01858,16.89203), (2.05561,12.69184), (-0.12117,15.59077), (0.99471,6.94287), (6.89979,-0.1801), (-4.18527,3.25318), (-6.35104,8.08804), (3.89734,13.78384), (-1.979,0.46434), (3.15404,7.78224), (3.52672,9.10987), (2.48372,-0.89391), (-6.13089,14.3696), (2.2968,3.01763), (-2.74324,8.03559), (-0.12876,7.24609), (-1.51135,11.86271), (-3.92434,6.28196), (-1.71254,8.9725), (-1.25878,14.46114), (2.03021,9.50216), (4.31726,16.30413), (-3.02908,1.02795), (9.7093,1.88717), (-3.36284,9.80106), (6.70938,4.53487), (0.42762,16.34543), (5.04726,7.71098), (2.78386,2.74639), (6.83022,6.51875), (-3.02109,10.42308), (-0.65382,13.57901), (-15.58675,0.52784), (5.89746,4.4708), (-4.11598,6.39619), (-1.37208,14.57666), (10.08082,2.71602), (5.35686,12.53905), (1.93331,11.4292), (10.47444,12.44641), (-2.36872,14.50894), (6.50752,17.64374), (2.54603,11.03218), (-0.4332,9.82789), (5.26572,10.11104), (2.09016,2.16137), (1.15513,10.24054), (14.95941,12.86909), (-3.85505,15.22845), (-2.36239,5.05411), (1.64338,10.84836), (-4.25074,11.15717), (7.29744,0.91782), (-1.18964,13.29961), (5.60612,15.11314), (-3.77011,11.54004), (6.67642,-0.94238), (-0.06862,19.32581), (5.60514,10.20744), (3.7341,6.54857), (9.59001,8.69108), (3.30093,8.2296), (-2.75658,8.4474), (4.71994,6.81178), (0.74699,5.99415), (2.91095,13.99336), (-7.36829,8.7469), (-5.29487,8.62349), (3.31079,1.84212), (1.06974,4.4762), (-1.18424,9.25421), (-7.415,10.44229), (3.40595,12.21649), (-7.63085,10.45968), (1.13336,15.34722), (-0.0096,5.50868), (0.8928,10.93609), (-0.5943,2.78631), (7.48306,11.86145), (10.11943,18.67385), (5.60459,10.64051), (4.00189,12.75565), (2.35823,6.63666), (0.33475,12.19343), (3.47072,9.08636), (-6.68867,11.67256), (3.31031,20.31392), (2.17159,11.66443); -SELECT '-28.740781574102936', '7.667329672103986e-133'; -SELECT roundBankers(studentTTest(left, right).1, 16) as t_stat, roundBankers(studentTTest(left, right).2, 16) as p_value from student_ttest; -DROP TABLE IF EXISTS student_ttest; diff --git a/tests/queries/0_stateless/01322_ttest_scipy.python b/tests/queries/0_stateless/01322_ttest_scipy.python deleted file mode 100644 index 66659e2ab71..00000000000 --- a/tests/queries/0_stateless/01322_ttest_scipy.python +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env python3 -import os -import io -import sys -import requests -import time -import pandas as pd -import numpy as np -from scipy import stats - -CLICKHOUSE_HOST = os.environ.get('CLICKHOUSE_HOST', '127.0.0.1') -CLICKHOUSE_PORT_HTTP = os.environ.get('CLICKHOUSE_PORT_HTTP', '8123') -CLICKHOUSE_SERVER_URL_STR = 'http://' + ':'.join(str(s) for s in [CLICKHOUSE_HOST, CLICKHOUSE_PORT_HTTP]) + "/" - -class ClickHouseClient: - def __init__(self, host = CLICKHOUSE_SERVER_URL_STR): - self.host = host - - def query(self, query, connection_timeout = 1500): - NUMBER_OF_TRIES = 30 - DELAY = 10 - - for i in range(NUMBER_OF_TRIES): - r = requests.post( - self.host, - params = {'timeout_before_checking_execution_speed': 120, 'max_execution_time': 6000}, - timeout = connection_timeout, - data = query) - if r.status_code == 200: - return r.text - else: - print('ATTENTION: try #%d failed' % i) - if i != (NUMBER_OF_TRIES-1): - print(query) - print(r.text) - time.sleep(DELAY*(i+1)) - else: - raise ValueError(r.text) - - def query_return_df(self, query, connection_timeout = 1500): - data = self.query(query, connection_timeout) - df = pd.read_csv(io.StringIO(data), sep = '\t') - return df - - def query_with_data(self, query, content): - content = content.encode('utf-8') - r = requests.post(self.host, data=content) - result = r.text - if r.status_code == 200: - return result - else: - raise ValueError(r.text) - -def test_and_check(name, a, b, t_stat, p_value): - client = ClickHouseClient() - client.query("DROP TABLE IF EXISTS ttest;") - client.query("CREATE TABLE ttest (left Float64, right Float64) ENGINE = Memory;"); - client.query("INSERT INTO ttest VALUES {};".format(", ".join(['({},{})'.format(i, j) for i,j in zip(a, b)]))) - - real = client.query_return_df( - "SELECT roundBankers({}(left, right).1, 16) as t_stat, ".format(name) + - "roundBankers({}(left, right).2, 16) as p_value ".format(name) + - "FROM ttest FORMAT TabSeparatedWithNames;") - real_t_stat = real['t_stat'][0] - real_p_value = real['p_value'][0] - assert(abs(real_t_stat - np.float64(t_stat) < 1e-2)), "clickhouse_t_stat {}, scipy_t_stat {}".format(real_t_stat, t_stat) - assert(abs(real_p_value - np.float64(p_value)) < 1e-2), "clickhouse_p_value {}, scipy_p_value {}".format(real_p_value, p_value) - client.query("DROP TABLE IF EXISTS ttest;") - - -def test_student(): - rvs1 = np.round(stats.norm.rvs(loc=1, scale=5,size=500), 5) - rvs2 = np.round(stats.norm.rvs(loc=10, scale=5,size=500), 5) - s, p = stats.ttest_ind(rvs1, rvs2, equal_var = True) - test_and_check("studentTTest", rvs1, rvs2, s, p) - - rvs1 = np.round(stats.norm.rvs(loc=0, scale=5,size=500), 5) - rvs2 = np.round(stats.norm.rvs(loc=0, scale=5,size=500), 5) - s, p = stats.ttest_ind(rvs1, rvs2, equal_var = True) - test_and_check("studentTTest", rvs1, rvs2, s, p) - - - rvs1 = np.round(stats.norm.rvs(loc=0, scale=10,size=65536), 5) - rvs2 = np.round(stats.norm.rvs(loc=5, scale=1,size=65536), 5) - s, p = stats.ttest_ind(rvs1, rvs2, equal_var = True) - test_and_check("studentTTest", rvs1, rvs2, s, p) - -def test_welch(): - rvs1 = np.round(stats.norm.rvs(loc=1, scale=15,size=500), 5) - rvs2 = np.round(stats.norm.rvs(loc=10, scale=5,size=500), 5) - s, p = stats.ttest_ind(rvs1, rvs2, equal_var = True) - test_and_check("studentTTest", rvs1, rvs2, s, p) - - rvs1 = np.round(stats.norm.rvs(loc=0, scale=7,size=500), 5) - rvs2 = np.round(stats.norm.rvs(loc=0, scale=3,size=500), 5) - s, p = stats.ttest_ind(rvs1, rvs2, equal_var = True) - test_and_check("studentTTest", rvs1, rvs2, s, p) - - - rvs1 = np.round(stats.norm.rvs(loc=0, scale=10,size=65536), 5) - rvs2 = np.round(stats.norm.rvs(loc=5, scale=1,size=65536), 5) - s, p = stats.ttest_ind(rvs1, rvs2, equal_var = True) - test_and_check("studentTTest", rvs1, rvs2, s, p) - -if __name__ == "__main__": - test_student() - test_welch() - print("Ok.") \ No newline at end of file diff --git a/tests/queries/0_stateless/01322_ttest_scipy.sh b/tests/queries/0_stateless/01322_ttest_scipy.sh deleted file mode 100755 index 31c1acf3e60..00000000000 --- a/tests/queries/0_stateless/01322_ttest_scipy.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -. "$CURDIR"/../shell_config.sh - -# We should have correct env vars from shell_config.sh to run this test - -python3 "$CURDIR"/01322_ttest_scipy.python diff --git a/tests/queries/0_stateless/01322_welch_ttest.sql b/tests/queries/0_stateless/01322_welch_ttest.sql deleted file mode 100644 index cce65c28bd8..00000000000 --- a/tests/queries/0_stateless/01322_welch_ttest.sql +++ /dev/null @@ -1,37 +0,0 @@ -/*Check only p-value first*/ -DROP TABLE IF EXISTS welch_ttest; -CREATE TABLE welch_ttest (left Float64, right Float64) ENGINE = Memory; -INSERT INTO welch_ttest VALUES (27.5,27.1), (21.0,22.0), (19.0,20.8), (23.6,23.4), (17.0,23.4), (17.9,23.5), (16.9,25.8), (20.1,22.0), (21.9,24.8), (22.6,20.2), (23.1,21.9), (19.6,22.1), (19.0,22.9), (21.7,20.5), (21.4,24.4); -SELECT '0.021378001462867'; -SELECT roundBankers(welchTTest(left, right).2, 16) from welch_ttest; -DROP TABLE IF EXISTS welch_ttest; - -CREATE TABLE welch_ttest (left Float64, right Float64) ENGINE = Memory; -INSERT INTO welch_ttest VALUES (30.02,29.89), (29.99,29.93), (30.11,29.72), (29.97,29.98), (30.01,30.02), (29.99,29.98); -SELECT '0.090773324285671'; -SELECT roundBankers(welchTTest(left, right).2, 16) from welch_ttest; -DROP TABLE IF EXISTS welch_ttest; - -CREATE TABLE welch_ttest (left Float64, right Float64) ENGINE = Memory; -INSERT INTO welch_ttest VALUES (0.010268,0.159258), (0.000167,0.136278), (0.000167,0.122389); -SELECT '0.00339907162713746'; -SELECT roundBankers(welchTTest(left, right).2, 16) from welch_ttest; -DROP TABLE IF EXISTS welch_ttest; - -/*Check t-stat and p-value and compare it with scipy.stat implementation - First: a=10, sigma (not sigma^2)=5, size=500 - Second: a=10, sigma = 10, size = 500 */ -CREATE TABLE welch_ttest (left Float64, right Float64) ENGINE = Memory; -INSERT INTO welch_ttest VALUES (14.72789,-8.65656), (9.61661,22.98234), (13.57615,23.80821), (3.98392,13.33939), (11.98889,-4.05537), (10.99422,23.5155), (5.44792,-6.45272), (20.29346,17.7903), (7.05926,11.463), (9.22732,5.28021), (12.06847,8.39157), (13.52612,6.02464), (8.24597,14.43732), (9.35245,15.76584), (10.12297,1.54391), (15.80624,1.24897), (13.68613,27.1507), (10.72729,7.71091), (5.62078,15.71846), (6.12229,32.97808), (6.03801,-1.79334), (8.95585,-9.23439), (24.04613,11.27838), (9.04757,0.72703), (2.68263,18.51557), (15.43935,9.16619), (2.89423,17.29624), (4.01423,-1.30208), (4.30568,-3.48018), (11.99948,10.12082), (8.40574,-8.01318), (10.86642,-14.22264), (9.4266,16.58174), (-8.12752,-0.55975), (7.91634,5.61449), (7.3967,1.44626), (2.26431,7.89158), (14.20118,1.13369), (6.68233,-0.82609), (15.46221,12.23365), (7.88467,12.45443), (11.20011,14.46915), (8.92027,13.72627), (10.27926,18.41459), (5.14395,29.66702), (5.62178,1.51619), (12.84383,10.40078), (9.98009,3.33266), (-0.69789,6.12036), (11.41386,11.86553), (7.76863,6.59422), (7.21743,22.0948), (1.81176,1.79623), (9.43762,14.29513), (19.22117,19.69162), (2.97128,-7.98033), (14.32851,5.48433), (7.54959,-2.28474), (3.81545,9.91876), (10.1281,10.64097), (2.48596,0.22523), (10.0461,17.01773), (3.59714,22.37388), (9.73522,14.04215), (18.8077,23.1244), (3.15148,18.96958), (12.26062,8.42663), (5.66707,3.7165), (6.58623,14.29366), (17.30902,23.50886), (9.91391,26.33722), (5.36946,26.72396), (15.73637,13.26287), (16.96281,12.97607), (11.54063,17.41838), (18.37358,8.63875), (11.38255,17.08943), (10.53256,23.15356), (8.08833,-4.4965), (16.27556,7.58895), (2.42969,26.04074), (9.56127,6.84245), (7.32998,20.56287), (9.19511,3.84735), (9.66903,-2.76304), (4.15029,13.1615), (8.83511,8.21954), (14.60617,-3.49943), (14.06143,22.12419), (5.39556,7.08323), (10.11871,16.12937), (10.56619,-0.32672), (14.4462,16.5942), (10.42106,7.68977), (7.75551,11.39484), (11.00418,-5.11987), (4.47226,20.87404), (16.35461,8.01007), (18.55174,3.26497), (11.82044,5.61253), (7.39454,20.69182), (11.27767,0.0296), (6.83827,21.904), (7.76858,22.46572), (15.97614,3.63685), (14.53781,-5.10846), (12.99546,14.86389), (16.91151,5.47188), (9.65012,18.44095), (14.25487,16.71368), (14.03618,6.36704), (2.57382,8.82663), (2.50779,14.6727), (14.24787,7.98383), (13.34666,2.65568), (7.31102,21.45827), (10.22981,11.77948), (17.4435,4.71979), (21.2074,3.17951), (6.64191,13.90226), (18.7086,15.50578), (14.78686,10.8026), (9.85287,16.91369), (4.48263,9.90552), (14.17469,13.87322), (14.4342,4.12366), (19.2481,-3.78985), (3.47165,1.7599), (8.28712,3.43715), (8.81657,-3.45246), (0.92319,23.64571), (20.41106,-4.96877), (6.76127,3.93514), (22.00242,1.49914), (8.66129,12.71519), (10.9929,5.11521), (17.95494,4.79872), (17.20996,20.89391), (12.18888,5.363), (12.14257,8.02765), (15.81243,14.30804), (4.43362,11.49002), (1.17567,14.25281), (15.60881,7.6573), (9.34833,15.49686), (6.33513,3.29327), (-0.83095,2.27236), (12.43268,12.58104), (6.63207,19.19128), (11.96877,15.25901), (14.81029,6.5221), (21.84876,10.10965), (3.75896,12.75249), (6.91307,16.50977), (13.73015,-8.6697), (8.63753,8.28553), (15.71679,1.44315), (1.74565,4.65869), (9.16895,0.98149), (5.70685,0.16623), (5.00117,17.66332), (13.06888,4.35346), (7.51204,6.52742), (15.34885,-1.06631), (5.20264,-5.28454), (8.59043,14.25583), (6.45619,8.74058), (14.61979,1.89553), (11.7075,-0.92959), (14.04901,10.30289), (4.20525,-6.3744), (15.1733,-8.1706), (3.12934,10.95369), (8.08049,4.94384), (15.41273,28.40568), (16.90751,3.7004), (5.86893,2.52363), (7.1086,4.07997), (4.418,7.8849), (12.0614,17.95409), (7.07887,16.67021), (3.61585,11.34377), (11.73001,-0.07446), (10.80449,22.00223), (8.40311,3.31778), (9.91276,18.50719), (16.4164,-3.58655), (5.25034,6.5394), (15.20283,12.40459), (10.42909,16.59866), (9.53888,7.54176), (14.68939,-1.51044), (6.60007,12.69758), (18.31058,2.9842), (7.01885,2.49187), (18.71631,2.04113), (10.50002,-2.46544), (10.7517,15.18368), (4.23224,-0.04058), (2.28924,-0.4127), (8.56059,10.5526), (8.25095,12.03982), (9.15673,12.10923), (13.28409,11.54954), (8.4513,-1.18613), (2.83911,11.30984), (2.79676,23.54105), (9.11055,10.67321), (7.18529,24.09196), (-4.1258,7.5008), (5.28306,12.52233), (6.82757,4.30673), (10.89035,9.35793), (5.24822,4.44472), (11.935,-7.00679), (6.45675,8.56241), (10.18088,23.73891), (4.9932,15.62708), (18.09939,16.09205), (8.11738,12.52074), (5.37883,14.58927), (10.50339,-4.80187), (16.64093,8.47964), (14.77263,7.75477), (13.71385,12.6893), (6.98746,7.14147), (10.74635,12.12654), (5.49432,12.32334), (13.46078,7.98909), (10.67565,3.26652), (9.0291,20.53684), (11.51417,32.3369), (13.07118,19.74911), (9.5049,-4.62897), (8.50611,8.26483), (6.47606,20.88451), (13.06526,-2.12982), (19.08658,25.61459), (9.49741,5.32091), (10.60865,-4.1196), (2.28996,7.57937), (8.12846,21.15847), (5.62241,6.46355), (4.07712,7.74846), (17.98526,19.62636), (9.466,28.34629), (11.38904,26.73919), (5.91826,20.40427), (1.52059,3.03378), (18.79161,10.2537), (18.20669,7.47745), (-1.67829,10.79184), (18.01586,3.91962), (16.31577,19.97973), (7.88281,18.87711), (8.46179,12.56157), (10.31113,11.46033), (14.88377,3.78661), (1.31835,-9.45748), (2.53176,12.06033), (9.48625,-0.74615), (3.97936,13.2815), (11.52319,24.78052), (13.24178,5.83337), (7.58739,17.4111), (10.00959,19.70331), (9.73361,11.78446), (8.35716,-1.366), (1.65491,1.37458), (11.11521,16.31483), (6.08355,32.63464), (10.04582,-3.79736), (11.58237,19.17984), (16.40249,-0.27705), (1.9691,-3.69456), (13.22776,28.38058), (2.67059,-1.36876), (9.83651,-25.63301), (2.12539,3.58644), (9.27114,-6.85667), (9.0699,13.42225), (2.78179,12.04671), (12.49311,28.99468), (12.97662,7.87662), (15.06359,2.61119), (16.91565,-3.56022), (5.92011,1.50022), (5.81304,14.55836), (8.46425,9.35831), (9.48705,16.9366), (4.68191,29.23126), (5.70028,15.31386), (-0.78798,13.46112), (10.03442,7.39667), (15.45433,11.15599), (9.43845,9.80499), (3.05825,22.64923), (6.92126,8.67693), (14.05905,18.67335), (19.71579,-3.19127), (15.0131,22.94716), (4.50386,17.86834), (1.31061,16.98267), (10.81197,15.91653), (14.32942,11.79718), (9.26469,18.50208), (7.27679,8.90755), (22.69295,10.44843), (12.03763,4.67433), (7.34876,6.82287), (16.60689,10.82228), (7.48786,-4.18631), (15.78602,20.3872), (17.21048,11.84735), (13.93482,21.25376), (9.69911,10.55032), (12.24315,12.19023), (10.58131,0.63369), (19.57006,7.92381), (9.8856,17.90933), (11.70302,15.30781), (7.89864,10.01877), (12.24831,0.88744), (16.93707,22.20967), (9.65467,-4.23117), (4.221,21.50819), (15.45229,11.27421), (12.83088,-16.23179), (7.58313,33.43085), (12.895,5.15093), (10.02471,1.34505), (13.36059,6.027), (5.07864,-10.43035), (9.72017,27.45998), (11.05809,19.24886), (15.28528,-4.44761), (13.99834,5.453), (19.26989,12.73758), (9.41846,11.2897), (11.65425,31.032), (8.49638,7.39168), (6.38592,11.95245), (-4.69837,26.279), (12.22061,-1.0255), (9.41331,10.36675), (13.2075,11.58439), (12.97005,27.8405), (11.44352,13.1707), (9.79805,31.39133), (6.93116,27.08301), (10.07691,-2.14368), (22.05892,4.08476), (7.80353,21.5573), (-2.17276,16.69822), (0.61509,7.69955), (8.35842,8.32793), (17.77108,6.49235), (14.70841,-7.3284), (1.27992,10.58264), (15.62699,-6.17006), (9.32914,34.55782), (15.41866,10.93221), (10.82009,44.24299), (3.29902,14.6224), (9.21998,-7.42798), (7.93845,15.52351), (10.33344,11.33982), (12.06399,10.46716), (5.5308,13.0986), (8.38727,-4.25988), (18.11104,9.55316), (8.86565,0.75489), (19.41825,25.99212), (9.52376,-0.81401), (3.94552,3.49551), (9.37587,22.99402), (15.44954,10.99628), (15.90527,23.70223), (13.18927,2.71482), (7.01646,22.82309), (9.06005,31.25686), (9.06431,4.86318), (5.76006,-1.06476), (9.18705,15.10298), (-3.48446,-0.61015), (15.89817,17.81246), (12.94719,-1.55788), (23.69426,18.09709), (17.47755,9.11271), (15.61528,9.94682), (0.54832,-7.33194), (14.32916,-4.67293), (9.55305,21.81717), (13.79891,7.16318), (0.82544,13.25649), (13.34875,13.88776), (9.07614,4.95793), (5.19621,17.65303), (2.1451,14.47382), (9.87726,13.19373), (8.45439,31.86093), (-1.41842,5.73161), (7.93598,10.96492), (11.23151,6.97951), (17.84458,1.75136), (7.02237,10.96144), (10.7842,15.08137), (4.42832,9.95311), (4.45044,7.07729), (1.50938,3.08148), (21.21651,22.37954), (6.2097,8.51951), (6.84354,2.88746), (18.53804,26.73509), (12.01072,-2.88939), (4.8345,-2.82367), (20.41587,-0.35783), (14.48353,14.22076), (8.71116,11.50295), (12.42818,7.10171), (14.89244,8.28488), (8.03033,0.54178), (5.25917,13.8022), (2.30092,15.62157), (10.22504,10.79173), (15.37573,28.18946), (7.13666,30.43524), (4.45018,2.54914), (10.18405,9.89421), (3.91025,13.08631), (14.52304,4.68761), (13.14771,5.61516), (11.99219,22.88072), (9.21345,7.4735), (8.85106,11.27382), (12.91887,2.39559), (15.62308,-3.31889), (11.88034,9.61957), (15.12097,23.01381), (11.58168,-1.23467), (16.83051,9.07691), (5.25405,15.78056), (2.19976,12.28421), (4.56716,9.44888), (16.46053,13.16928), (5.61995,4.33357), (8.67704,2.21737), (5.62789,33.17833), (9.84815,13.25407), (13.05834,-2.47961), (11.74205,6.41401), (3.88393,18.8439), (16.15321,-4.63375), (4.83925,-8.2909), (13.00334,12.18221), (4.4028,-2.95356), (4.35794,19.61659), (4.47478,12.45056), (2.38713,-4.17198), (4.25235,21.9641), (10.87509,11.96416), (9.82411,12.74573), (13.61518,10.47873), (10.25507,12.73295), (4.0335,11.31373), (10.69881,9.9827), (5.70321,5.87138), (6.96244,4.24372), (9.35874,-23.72256), (6.28076,28.41337), (8.29015,4.88103), (6.88653,3.61902), (7.70687,8.93586), (8.2001,16.40759), (6.73415,27.84494), (3.82052,5.6001), (3.94469,14.51379), (15.82384,13.5576), (2.54004,12.92213), (10.74876,3.90686), (12.60517,17.07104), (17.7024,15.84268), (4.6722,17.38777), (13.67341,16.54766), (6.4565,5.94487), (12.95699,17.02804), (4.56912,7.66386), (5.58464,10.43088), (4.0638,6.16059), (13.05559,20.46178), (5.38269,20.02888), (0.16354,20.95949), (7.23962,6.50808), (7.38577,7.22366), (8.50951,8.06659), (13.72574,16.08241), (17.80421,13.83514), (3.01135,-0.33454), (8.02608,12.98848), (14.23847,12.99024); -SELECT '-0.5028215369186904', '0.6152361677168877'; -SELECT roundBankers(welchTTest(left, right).1, 16) as t_stat, roundBankers(welchTTest(left, right).2, 16) as p_value from welch_ttest; -DROP TABLE IF EXISTS welch_ttest; - -/*Check t-stat and p-value and compare it with scipy.stat implementation - First: a=10, sigma (not sigma^2)=5, size=500 - Second: a=1, sigma = 12, size = 500 */ -CREATE TABLE welch_ttest (left Float64, right Float64) ENGINE = Memory; -INSERT INTO welch_ttest VALUES (4.82025,-2.69857), (6.13896,15.80943), (15.20277,7.31555), (14.15351,3.96517), (7.21338,4.77809), (8.55506,9.6472), (13.80816,-26.41717), (11.28411,-10.85635), (7.4612,-1.4376), (7.43759,-0.96308), (12.9832,2.84315), (-5.74783,5.79467), (12.47114,-3.06091), (15.14223,-14.62902), (3.40603,22.08022), (9.27323,-2.11982), (7.88547,-4.84824), (8.56456,-10.50447), (4.59731,2.4891), (7.91213,9.90324), (7.33894,-22.66866), (21.74811,-0.97103), (11.92111,-16.57608), (0.18828,-3.78749), (10.47314,25.84511), (20.37396,5.30797), (11.04991,-18.19466), (13.30083,11.72708), (14.28065,0.2891), (2.86942,-9.83474), (24.96072,6.69942), (14.20164,18.09604), (18.28769,18.52651), (10.50949,1.38201), (9.22273,7.64615), (11.77608,17.66598), (8.56872,-2.44141), (13.74535,-9.01598), (11.65209,27.69142), (12.51894,4.06946), (17.76256,-15.0077), (13.52122,-10.49648), (8.70796,-4.88322), (6.04749,-25.09805), (16.33064,-4.64024), (8.35636,20.94434), (14.03496,24.12126), (11.05834,-14.10962), (14.49261,10.6512), (2.59383,14.50687), (8.01022,-19.88081), (4.05458,-11.55271), (13.26384,13.16921), (14.62058,16.63864), (10.52489,-24.08114), (8.46357,-9.09949), (6.4147,-10.54702), (9.70071,0.20813), (12.47581,8.19066), (4.38333,-2.70523), (17.54172,-0.23954), (10.12109,7.19398), (7.73186,-7.1618), (14.0279,-7.44322), (11.6621,-17.92031), (17.47045,-1.58146), (15.50223,9.18338), (15.46034,3.25838), (13.39964,-14.30234), (14.98025,1.84695), (15.87912,31.13794), (17.67374,-0.85067), (9.64073,19.02787), (12.84904,-3.09594), (7.70278,13.45584), (13.03156,-5.48104), (9.04512,-22.74928), (15.97014,-8.03697), (8.96389,17.31143), (11.48009,-16.65231), (9.71153,-18.58713), (13.00084,-16.52641), (12.39803,14.95261), (13.08188,12.56762), (5.82244,15.00188), (10.81871,1.85858), (8.2539,2.1926), (7.52114,-2.4095), (9.11488,21.56873), (8.37482,3.35509), (14.48652,-4.98672), (11.42152,35.08603), (16.03111,-10.01602), (13.14057,-3.85153), (-2.26351,-6.81974), (15.50394,19.56525), (14.88603,-9.35488), (13.37257,0.24268), (11.84026,-3.51488), (7.66558,-0.37066), (6.24584,24.20888), (3.6312,-11.73537), (2.7018,0.01282), (5.63656,0.03963), (5.82643,-9.65589), (10.06745,-0.37429), (-0.5831,5.61255), (14.84202,0.49984), (9.5524,-10.15066), (19.71713,-14.54314), (14.23109,16.56889), (8.69105,-7.73873), (5.33742,-3.76422), (7.30372,1.40722), (7.93342,2.28818), (15.20884,-13.12643), (7.53839,5.17082), (13.45311,4.79089), (11.04473,-17.42643), (10.76673,8.72548), (15.44145,-3.70285), (14.06596,16.77893), (9.14873,13.382), (12.88372,19.98418), (8.74994,0.00483), (10.53263,-4.75951), (16.16694,2.35391), (8.37197,21.65809), (3.43739,-9.2714), (4.72799,-18.38253), (9.08802,7.23097), (11.2531,14.97927), (5.16115,-4.02197), (10.20895,-29.8189), (18.70884,-12.8554), (15.88924,-7.60124), (3.38758,-14.90158), (6.46449,-3.31486), (10.21088,31.38144), (14.08458,-8.61288), (15.74508,15.31895), (19.31896,-10.19488), (13.19641,13.796), (11.95409,-0.32912), (10.70718,-0.0684), (1.05245,-30.06834), (10.04772,24.93912), (17.01369,-3.26506), (10.2286,-8.29751), (19.58323,-5.39189), (7.02892,-25.08603), (4.16866,-1.45318), (8.94326,16.72724), (4.99854,-3.38467), (8.88352,-26.00478), (18.65422,7.28369), (17.32328,16.96226), (9.33492,16.5858), (14.94788,10.46583), (8.05863,3.84345), (14.6737,-2.99382), (10.93801,1.42078), (0.54036,-11.0123), (-0.34242,2.09909), (5.89076,1.21064), (3.15189,15.36079), (1.94421,-21.61349), (6.38698,22.7726), (10.50654,10.50512), (8.95362,-6.95825), (6.23711,9.20036), (11.75359,15.66902), (12.42155,3.28098), (-1.55472,-9.05692), (4.6688,0.32882), (10.48087,-1.64934), (11.74615,-4.81406), (9.26822,-5.06006), (7.55517,19.97493), (12.76005,2.88646), (16.47102,-0.34552), (11.31297,7.55186), (14.37437,-22.96115), (2.38799,31.29166), (6.44577,6.18798), (5.07471,-2.52715), (11.55123,-11.58799), (7.76795,14.13596), (10.60116,13.45069), (14.40885,12.15179), (11.58158,3.44491), (8.81648,-8.78006), (12.92299,18.32087), (11.26939,11.91757), (17.95014,-2.00179), (2.95002,10.88411), (17.41959,9.09327), (11.12455,6.62484), (8.78541,8.87178), (14.36413,11.52254), (12.98554,-14.15988), (12.58505,-17.19515), (15.49789,14.03089), (11.70999,-2.4095), (0.65596,-16.83575), (11.08202,2.71469), (14.75752,4.84351), (6.84385,-1.17651), (9.27245,-3.37529), (13.78243,-19.92137), (17.4863,4.48952), (4.01777,-12.4906), (11.82861,-5.65277), (13.86551,8.50819), (6.16591,-19.61261), (8.71589,12.54156), (16.77195,11.06784), (17.23243,-12.59285), (-2.12941,3.43683), (5.66629,-3.00325), (12.45153,12.49082), (1.63971,7.20955), (13.84031,17.6547), (4.6144,15.8619), (5.26169,24.3048), (9.27769,-8.05434), (9.14288,-6.06901), (9.71953,-15.69515), (9.38446,-11.13917), (1.64788,-3.90757), (11.72922,-2.57038), (13.68926,5.14065), (9.42952,17.8497), (12.05574,-8.64665), (9.09148,-18.68331), (5.32273,5.8567), (20.25258,-20.93884), (10.14599,4.40583), (10.82156,14.35985), (5.75736,4.18134), (7.13567,4.3635), (9.29746,9.35428), (5.1618,2.8908), (10.076,16.01017), (21.65669,-1.48499), (13.35486,-9.97949), (6.79957,1.03055), (8.76243,-2.79697), (14.59294,6.85977), (16.90609,4.73213), (10.50337,2.7815), (-0.07923,-2.46866), (13.51648,18.39425), (12.0676,-0.80378), (0.86482,-0.22982), (9.03563,-16.11608), (5.38751,3.0862), (17.16866,3.20779), (2.78702,10.50146), (11.15548,-0.21305), (12.30843,11.21012), (8.04897,-0.99825), (9.95814,18.39633), (11.29308,-3.39003), (14.13032,-0.64411), (21.05877,-1.39932), (3.57386,15.45319), (7.96631,-0.66044), (3.30484,-15.2223), (18.61856,-34.39907), (16.35184,-3.57836), (7.65236,16.82828), (18.02895,1.66624), (9.79458,15.43475), (16.7274,8.17776), (8.84453,5.50486), (13.05709,10.43082), (10.91447,-6.63332), (8.40171,2.28008), (16.95211,16.37203), (11.82194,5.16313), (19.87978,-8.85281), (12.88455,13.26692), (-0.00947,-7.46842), (12.28109,8.43091), (6.96462,-13.18172), (13.75282,-0.72401), (14.39141,22.3881), (11.07193,10.65448), (12.88039,2.81289), (11.38253,10.92405), (21.02707,-8.95358), (7.51955,19.80653), (6.31984,-12.86527), (15.6543,5.38826), (14.80315,-6.83501), (8.38024,-15.7647), (21.7516,-27.67412), (14.31336,8.6499), (15.04703,-4.89542), (5.73787,16.76167), (13.16911,12.84284), (12.40695,-17.27324), (9.88968,-4.18726), (8.46703,-14.62366), (8.70637,-5.49863), (8.03551,-16.22846), (5.9757,10.60329), (12.22951,6.46781), (3.14736,1.70458), (10.51266,10.77448), (18.593,0.8463), (10.82213,13.0482), (7.14216,-4.36264), (6.81154,3.22647), (-0.6486,2.38828), (20.56136,6.7946), (11.35367,-0.25254), (11.38205,1.2497), (17.14,1.6544), (14.91215,4.1019), (15.50207,11.27839), (5.93162,-5.04127), (3.74869,18.11674), (14.11532,0.51231), (7.38954,-0.51029), (5.45764,13.52556), (18.33733,16.10171), (9.91923,5.68197), (2.38991,-2.85904), (14.16756,-8.89167), (2.39791,6.24489), (6.92586,10.85319), (5.32474,-0.39816), (2.28812,3.87079), (5.71718,-3.1867), (5.84197,1.55322), (2.76206,16.86779), (19.05928,-14.60321), (11.51788,-1.81952), (6.56648,-3.11624), (3.35735,1.24193), (7.55948,10.18179), (19.99908,4.69796), (13.00634,0.69032), (18.36886,11.7723), (11.14675,7.62896), (16.72931,9.89741), (12.50106,9.11484), (6.00605,-3.84676), (23.06653,-0.4777), (5.39694,0.95958), (9.53167,-7.95056), (12.76944,-10.97474), (7.20604,-6.54861), (13.25391,34.74933), (13.7341,27.39463), (10.85292,4.18299), (-7.75835,6.02476), (10.29728,-1.99397), (13.70099,1.26478), (10.17959,23.37106), (9.98399,10.49682), (12.69389,-11.04354), (-0.28848,-12.22284), (-2.18319,-9.87635), (13.36378,28.90511), (10.09232,6.77613), (5.49489,0.55352), (5.46156,0.37031), (0.94225,7.1418), (12.79205,3.24897), (10.09593,-1.60918), (6.06218,3.1675), (0.89463,-17.97072), (11.88986,-5.61743), (10.79733,14.1422), (1.51371,14.87695), (2.20967,-4.65961), (15.45732,-0.99174), (16.5262,-2.96623), (5.99724,-9.02263), (8.3613,-17.2088), (15.68183,2.78608), (15.32117,6.74239), (14.15674,4.8524), (6.64553,7.46731), (4.20777,1.04894), (-0.10521,-12.8023), (-0.88169,-17.18188), (1.85913,-5.08801), (9.73673,22.13942), (0.30926,-0.36384), (6.17559,17.80564), (11.76602,7.67504), (5.68385,1.59779), (14.57088,4.10942), (12.81509,0.61074), (9.85682,-14.40767), (12.06376,10.59906), (6.08874,16.57017), (11.63921,-15.17526), (14.86722,-6.98549), (10.41035,-0.64548), (2.93794,3.23756), (12.21841,14.65504), (0.23804,4.583), (3.14845,12.72378), (7.29748,5.26547), (3.06134,0.81781), (13.77684,9.38273), (16.21992,10.37636), (5.33511,10.70325), (9.68959,-0.83043), (9.44169,-7.53149), (18.08012,-9.09147), (4.04224,-19.51381), (8.77918,-28.44508), (10.18324,6.44392), (9.38914,11.10201), (11.76995,-2.86184), (14.19963,8.30673), (6.88817,8.8797), (16.56123,10.68053), (15.39885,15.62919), (5.21241,8.00579), (4.44408,6.4651), (17.87587,-4.50029), (12.53337,18.04514), (13.60916,11.12996), (6.60104,-5.14007), (7.35453,9.43857), (18.61572,3.13476), (6.10437,4.9772), (13.08682,-17.45782), (12.15404,0.05552), (4.90789,-1.90283), (2.13353,2.67908), (12.49593,-2.62243), (11.93056,-3.22767), (13.29408,-8.70222), (5.70038,-23.11605), (8.40271,21.6757), (5.19456,12.70076), (-5.51028,4.4322), (14.0329,11.69344), (10.38365,9.18052), (6.56812,-2.2549), (4.21129,-2.15615), (9.7157,20.29765), (9.88553,-0.29536), (13.45346,15.50109), (4.97752,8.79187), (12.77595,5.11533), (8.56465,-20.44436), (4.27703,-3.00909), (18.12502,-4.48291), (12.45735,21.84462), (12.42912,1.94225), (12.08125,-2.81908), (10.85779,17.19418), (4.36013,-9.33528), (11.85062,-0.17346), (8.47776,0.03958), (9.60822,-35.17786), (11.3069,8.36887), (14.25525,-9.02292), (1.55168,-10.98804), (14.57782,0.29335), (7.84786,4.29634), (9.87774,3.87718), (14.75575,-9.08532), (3.68774,7.13922), (9.37667,-7.62463), (20.28676,-10.5666), (12.10027,4.68165), (8.01819,-3.30172), (18.78158,13.04852), (20.85402,13.45616), (18.98069,2.41043), (16.1429,-0.36501), (9.24047,-15.67383), (14.12487,17.92217), (10.18841,8.42106), (-3.04478,3.22063), (5.7552,-7.31753), (9.30376,21.99596), (11.42837,-36.8273), (6.02364,-20.46391), (8.86984,5.74179), (10.91177,-15.83178), (10.04418,14.90454), (18.10774,-8.84645), (7.49384,3.72036), (9.11556,4.6877), (9.7051,16.35418), (5.23268,3.15441), (9.04647,2.39907), (8.81547,-17.58664), (2.65098,-13.18269); -SELECT '14.971190998235835', '5.898143508382202e-44'; -SELECT roundBankers(welchTTest(left, right).1, 16) as t_stat, roundBankers(welchTTest(left, right).2, 16) as p_value from welch_ttest; -DROP TABLE IF EXISTS welch_ttest; From ca0037d18b73956301b6bebec4ef364921944e2a Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Wed, 4 Nov 2020 18:07:18 +0300 Subject: [PATCH 91/95] Update group_by_sundy_li.xml --- tests/performance/group_by_sundy_li.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/performance/group_by_sundy_li.xml b/tests/performance/group_by_sundy_li.xml index 4c9e397520a..3fcc4acf88d 100644 --- a/tests/performance/group_by_sundy_li.xml +++ b/tests/performance/group_by_sundy_li.xml @@ -1,4 +1,4 @@ - + CREATE TABLE a ( From 97b4534eb3a4ca9f8aad99dc25c4e73f7f66cb2a Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Wed, 4 Nov 2020 19:57:00 +0300 Subject: [PATCH 92/95] Update AggregateFunctionOrFill.cpp --- src/AggregateFunctions/AggregateFunctionOrFill.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AggregateFunctions/AggregateFunctionOrFill.cpp b/src/AggregateFunctions/AggregateFunctionOrFill.cpp index 959836c0e49..ee9fce710e6 100644 --- a/src/AggregateFunctions/AggregateFunctionOrFill.cpp +++ b/src/AggregateFunctions/AggregateFunctionOrFill.cpp @@ -21,7 +21,7 @@ private: Kind kind; public: - AggregateFunctionCombinatorOrFill(Kind kind_) : kind(kind_) {} + explicit AggregateFunctionCombinatorOrFill(Kind kind_) : kind(kind_) {} String getName() const override { From fa72fed4ad10cf6a71ef940fde3db4add709d041 Mon Sep 17 00:00:00 2001 From: damozhaeva <68770561+damozhaeva@users.noreply.github.com> Date: Wed, 4 Nov 2020 22:17:02 +0300 Subject: [PATCH 93/95] DOCSUP-3173 Edit and translate to Russian (#16462) * Edit and translate to Russian. * v2 27.10 * other-functions * Update docs/ru/sql-reference/functions/other-functions.md Co-authored-by: BayoNet * Update docs/ru/sql-reference/functions/other-functions.md Co-authored-by: BayoNet Co-authored-by: Daria Mozhaeva Co-authored-by: BayoNet --- .../reference/quantileexact.md | 13 +- .../aggregate-functions/reference/index.md | 138 +++++------ .../reference/quantileexact.md | 222 +++++++++++++----- .../functions/other-functions.md | 42 ++++ 4 files changed, 285 insertions(+), 130 deletions(-) diff --git a/docs/en/sql-reference/aggregate-functions/reference/quantileexact.md b/docs/en/sql-reference/aggregate-functions/reference/quantileexact.md index 40b25c14988..a39f724f368 100644 --- a/docs/en/sql-reference/aggregate-functions/reference/quantileexact.md +++ b/docs/en/sql-reference/aggregate-functions/reference/quantileexact.md @@ -53,13 +53,13 @@ Result: Similar to `quantileExact`, this computes the exact [quantile](https://en.wikipedia.org/wiki/Quantile) of a numeric data sequence. -To get exact value, all the passed values are combined into an array, which is then fully sorted. The sorting [algorithm's](https://en.cppreference.com/w/cpp/algorithm/sort) complexity is `O(N·log(N))`, where `N = std::distance(first, last)` comparisons. +To get the exact value, all the passed values are combined into an array, which is then fully sorted. The sorting [algorithm's](https://en.cppreference.com/w/cpp/algorithm/sort) complexity is `O(N·log(N))`, where `N = std::distance(first, last)` comparisons. -Depending on the level, i.e if the level is 0.5 then the exact lower median value is returned if there are even number of elements and the middle value is returned if there are odd number of elements. Median is calculated similar to the [median_low](https://docs.python.org/3/library/statistics.html#statistics.median_low) implementation which is used in python. +The return value depends on the quantile level and the number of elements in the selection, i.e. if the level is 0.5, then the function returns the lower median value for an even number of elements and the middle median value for an odd number of elements. Median is calculated similarly to the [median_low](https://docs.python.org/3/library/statistics.html#statistics.median_low) implementation which is used in python. -For all other levels, the element at the the index corresponding to the value of `level * size_of_array` is returned. For example: +For all other levels, the element at the index corresponding to the value of `level * size_of_array` is returned. For example: -```$sql +``` sql SELECT quantileExactLow(0.1)(number) FROM numbers(10) ┌─quantileExactLow(0.1)(number)─┐ @@ -111,9 +111,10 @@ Result: Similar to `quantileExact`, this computes the exact [quantile](https://en.wikipedia.org/wiki/Quantile) of a numeric data sequence. -To get exact value, all the passed values are combined into an array, which is then fully sorted. The sorting [algorithm's](https://en.cppreference.com/w/cpp/algorithm/sort) complexity is `O(N·log(N))`, where `N = std::distance(first, last)` comparisons. +All the passed values are combined into an array, which is then fully sorted, +to get the exact value. The sorting [algorithm's](https://en.cppreference.com/w/cpp/algorithm/sort) complexity is `O(N·log(N))`, where `N = std::distance(first, last)` comparisons. -Depending on the level, i.e if the level is 0.5 then the exact higher median value is returned if there are even number of elements and the middle value is returned if there are odd number of elements. Median is calculated similar to the [median_high](https://docs.python.org/3/library/statistics.html#statistics.median_high) implementation which is used in python. For all other levels, the element at the the index corresponding to the value of `level * size_of_array` is returned. +The return value depends on the quantile level and the number of elements in the selection, i.e. if the level is 0.5, then the function returns the higher median value for an even number of elements and the middle median value for an odd number of elements. Median is calculated similarly to the [median_high](https://docs.python.org/3/library/statistics.html#statistics.median_high) implementation which is used in python. For all other levels, the element at the index corresponding to the value of `level * size_of_array` is returned. This implementation behaves exactly similar to the current `quantileExact` implementation. diff --git a/docs/ru/sql-reference/aggregate-functions/reference/index.md b/docs/ru/sql-reference/aggregate-functions/reference/index.md index e621e68e8f2..4cbe0a0fba4 100644 --- a/docs/ru/sql-reference/aggregate-functions/reference/index.md +++ b/docs/ru/sql-reference/aggregate-functions/reference/index.md @@ -1,68 +1,70 @@ ---- -toc_folder_title: "\u0421\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a" -toc_priority: 36 -toc_hidden: true ---- - -# Перечень агрегатных функций {#aggregate-functions-list} - -Стандартные агрегатные функции: - -- [count](../../../sql-reference/aggregate-functions/reference/count.md) -- [min](../../../sql-reference/aggregate-functions/reference/min.md) -- [max](../../../sql-reference/aggregate-functions/reference/max.md) -- [sum](../../../sql-reference/aggregate-functions/reference/sum.md) -- [avg](../../../sql-reference/aggregate-functions/reference/avg.md) -- [any](../../../sql-reference/aggregate-functions/reference/any.md) -- [stddevPop](../../../sql-reference/aggregate-functions/reference/stddevpop.md) -- [stddevSamp](../../../sql-reference/aggregate-functions/reference/stddevsamp.md) -- [varPop](../../../sql-reference/aggregate-functions/reference/varpop.md) -- [varSamp](../../../sql-reference/aggregate-functions/reference/varsamp.md) -- [covarPop](../../../sql-reference/aggregate-functions/reference/covarpop.md) -- [covarSamp](../../../sql-reference/aggregate-functions/reference/covarsamp.md) - -Агрегатные функции, специфичные для ClickHouse: - -- [anyHeavy](../../../sql-reference/aggregate-functions/reference/anyheavy.md) -- [anyLast](../../../sql-reference/aggregate-functions/reference/anylast.md) -- [argMin](../../../sql-reference/aggregate-functions/reference/argmin.md) -- [argMax](../../../sql-reference/aggregate-functions/reference/argmax.md) -- [avgWeighted](../../../sql-reference/aggregate-functions/reference/avgweighted.md) -- [topK](../../../sql-reference/aggregate-functions/reference/topk.md) -- [topKWeighted](../../../sql-reference/aggregate-functions/reference/topkweighted.md) -- [groupArray](../../../sql-reference/aggregate-functions/reference/grouparray.md) -- [groupUniqArray](../../../sql-reference/aggregate-functions/reference/groupuniqarray.md) -- [groupArrayInsertAt](../../../sql-reference/aggregate-functions/reference/grouparrayinsertat.md) -- [groupArrayMovingAvg](../../../sql-reference/aggregate-functions/reference/grouparraymovingavg.md) -- [groupArrayMovingSum](../../../sql-reference/aggregate-functions/reference/grouparraymovingsum.md) -- [groupBitAnd](../../../sql-reference/aggregate-functions/reference/groupbitand.md) -- [groupBitOr](../../../sql-reference/aggregate-functions/reference/groupbitor.md) -- [groupBitXor](../../../sql-reference/aggregate-functions/reference/groupbitxor.md) -- [groupBitmap](../../../sql-reference/aggregate-functions/reference/groupbitmap.md) -- [sumWithOverflow](../../../sql-reference/aggregate-functions/reference/sumwithoverflow.md) -- [sumMap](../../../sql-reference/aggregate-functions/reference/summap.md) -- [skewSamp](../../../sql-reference/aggregate-functions/reference/skewsamp.md) -- [skewPop](../../../sql-reference/aggregate-functions/reference/skewpop.md) -- [kurtSamp](../../../sql-reference/aggregate-functions/reference/kurtsamp.md) -- [kurtPop](../../../sql-reference/aggregate-functions/reference/kurtpop.md) -- [timeSeriesGroupSum](../../../sql-reference/aggregate-functions/reference/timeseriesgroupsum.md) -- [timeSeriesGroupRateSum](../../../sql-reference/aggregate-functions/reference/timeseriesgroupratesum.md) -- [uniq](../../../sql-reference/aggregate-functions/reference/uniq.md) -- [uniqExact](../../../sql-reference/aggregate-functions/reference/uniqexact.md) -- [uniqCombined](../../../sql-reference/aggregate-functions/reference/uniqcombined.md) -- [uniqCombined64](../../../sql-reference/aggregate-functions/reference/uniqcombined64.md) -- [uniqHLL12](../../../sql-reference/aggregate-functions/reference/uniqhll12.md) -- [quantile](../../../sql-reference/aggregate-functions/reference/quantile.md) -- [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md) -- [quantileExact](../../../sql-reference/aggregate-functions/reference/quantileexact.md) -- [quantileExactWeighted](../../../sql-reference/aggregate-functions/reference/quantileexactweighted.md) -- [quantileTiming](../../../sql-reference/aggregate-functions/reference/quantiletiming.md) -- [quantileTimingWeighted](../../../sql-reference/aggregate-functions/reference/quantiletimingweighted.md) -- [quantileDeterministic](../../../sql-reference/aggregate-functions/reference/quantiledeterministic.md) -- [quantileTDigest](../../../sql-reference/aggregate-functions/reference/quantiletdigest.md) -- [quantileTDigestWeighted](../../../sql-reference/aggregate-functions/reference/quantiletdigestweighted.md) -- [simpleLinearRegression](../../../sql-reference/aggregate-functions/reference/simplelinearregression.md) -- [stochasticLinearRegression](../../../sql-reference/aggregate-functions/reference/stochasticlinearregression.md) -- [stochasticLogisticRegression](../../../sql-reference/aggregate-functions/reference/stochasticlogisticregression.md) - -[Оригинальная статья](https://clickhouse.tech/docs/ru/sql-reference/aggregate-functions/reference) +--- +toc_folder_title: "\u0421\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a" +toc_priority: 36 +toc_hidden: true +--- + +# Перечень агрегатных функций {#aggregate-functions-list} + +Стандартные агрегатные функции: + +- [count](../../../sql-reference/aggregate-functions/reference/count.md) +- [min](../../../sql-reference/aggregate-functions/reference/min.md) +- [max](../../../sql-reference/aggregate-functions/reference/max.md) +- [sum](../../../sql-reference/aggregate-functions/reference/sum.md) +- [avg](../../../sql-reference/aggregate-functions/reference/avg.md) +- [any](../../../sql-reference/aggregate-functions/reference/any.md) +- [stddevPop](../../../sql-reference/aggregate-functions/reference/stddevpop.md) +- [stddevSamp](../../../sql-reference/aggregate-functions/reference/stddevsamp.md) +- [varPop](../../../sql-reference/aggregate-functions/reference/varpop.md) +- [varSamp](../../../sql-reference/aggregate-functions/reference/varsamp.md) +- [covarPop](../../../sql-reference/aggregate-functions/reference/covarpop.md) +- [covarSamp](../../../sql-reference/aggregate-functions/reference/covarsamp.md) + +Агрегатные функции, специфичные для ClickHouse: + +- [anyHeavy](../../../sql-reference/aggregate-functions/reference/anyheavy.md) +- [anyLast](../../../sql-reference/aggregate-functions/reference/anylast.md) +- [argMin](../../../sql-reference/aggregate-functions/reference/argmin.md) +- [argMax](../../../sql-reference/aggregate-functions/reference/argmax.md) +- [avgWeighted](../../../sql-reference/aggregate-functions/reference/avgweighted.md) +- [topK](../../../sql-reference/aggregate-functions/reference/topk.md) +- [topKWeighted](../../../sql-reference/aggregate-functions/reference/topkweighted.md) +- [groupArray](../../../sql-reference/aggregate-functions/reference/grouparray.md) +- [groupUniqArray](../../../sql-reference/aggregate-functions/reference/groupuniqarray.md) +- [groupArrayInsertAt](../../../sql-reference/aggregate-functions/reference/grouparrayinsertat.md) +- [groupArrayMovingAvg](../../../sql-reference/aggregate-functions/reference/grouparraymovingavg.md) +- [groupArrayMovingSum](../../../sql-reference/aggregate-functions/reference/grouparraymovingsum.md) +- [groupBitAnd](../../../sql-reference/aggregate-functions/reference/groupbitand.md) +- [groupBitOr](../../../sql-reference/aggregate-functions/reference/groupbitor.md) +- [groupBitXor](../../../sql-reference/aggregate-functions/reference/groupbitxor.md) +- [groupBitmap](../../../sql-reference/aggregate-functions/reference/groupbitmap.md) +- [sumWithOverflow](../../../sql-reference/aggregate-functions/reference/sumwithoverflow.md) +- [sumMap](../../../sql-reference/aggregate-functions/reference/summap.md) +- [skewSamp](../../../sql-reference/aggregate-functions/reference/skewsamp.md) +- [skewPop](../../../sql-reference/aggregate-functions/reference/skewpop.md) +- [kurtSamp](../../../sql-reference/aggregate-functions/reference/kurtsamp.md) +- [kurtPop](../../../sql-reference/aggregate-functions/reference/kurtpop.md) +- [timeSeriesGroupSum](../../../sql-reference/aggregate-functions/reference/timeseriesgroupsum.md) +- [timeSeriesGroupRateSum](../../../sql-reference/aggregate-functions/reference/timeseriesgroupratesum.md) +- [uniq](../../../sql-reference/aggregate-functions/reference/uniq.md) +- [uniqExact](../../../sql-reference/aggregate-functions/reference/uniqexact.md) +- [uniqCombined](../../../sql-reference/aggregate-functions/reference/uniqcombined.md) +- [uniqCombined64](../../../sql-reference/aggregate-functions/reference/uniqcombined64.md) +- [uniqHLL12](../../../sql-reference/aggregate-functions/reference/uniqhll12.md) +- [quantile](../../../sql-reference/aggregate-functions/reference/quantile.md) +- [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md) +- [quantileExact](../../../sql-reference/aggregate-functions/reference/quantileexact.md) +- [quantileExactLow](../../../sql-reference/aggregate-functions/reference/quantileexact.md#quantileexactlow) +- [quantileExactHigh](../../../sql-reference/aggregate-functions/reference/quantileexact.md#quantileexacthigh) +- [quantileExactWeighted](../../../sql-reference/aggregate-functions/reference/quantileexactweighted.md) +- [quantileTiming](../../../sql-reference/aggregate-functions/reference/quantiletiming.md) +- [quantileTimingWeighted](../../../sql-reference/aggregate-functions/reference/quantiletimingweighted.md) +- [quantileDeterministic](../../../sql-reference/aggregate-functions/reference/quantiledeterministic.md) +- [quantileTDigest](../../../sql-reference/aggregate-functions/reference/quantiletdigest.md) +- [quantileTDigestWeighted](../../../sql-reference/aggregate-functions/reference/quantiletdigestweighted.md) +- [simpleLinearRegression](../../../sql-reference/aggregate-functions/reference/simplelinearregression.md) +- [stochasticLinearRegression](../../../sql-reference/aggregate-functions/reference/stochasticlinearregression.md) +- [stochasticLogisticRegression](../../../sql-reference/aggregate-functions/reference/stochasticlogisticregression.md) + +[Оригинальная статья](https://clickhouse.tech/docs/ru/sql-reference/aggregate-functions/reference) diff --git a/docs/ru/sql-reference/aggregate-functions/reference/quantileexact.md b/docs/ru/sql-reference/aggregate-functions/reference/quantileexact.md index 49415d96af9..4ee815a94fb 100644 --- a/docs/ru/sql-reference/aggregate-functions/reference/quantileexact.md +++ b/docs/ru/sql-reference/aggregate-functions/reference/quantileexact.md @@ -1,56 +1,166 @@ ---- -toc_priority: 202 ---- - -# quantileExact {#quantileexact} - -Точно вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности. - -Чтобы получить точный результат, все переданные значения собираются в массив, который затем частично сортируется. Таким образом, функция потребляет объем памяти `O(n)`, где `n` — количество переданных значений. Для небольшого числа значений эта функция эффективна. - -Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. - -**Синтаксис** - -``` sql -quantileExact(level)(expr) -``` - -Алиас: `medianExact`. - -**Параметры** - -- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). -- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../../sql-reference/data-types/index.md#data_types) или типов [Date](../../../sql-reference/data-types/date.md), [DateTime](../../../sql-reference/data-types/datetime.md). - -**Возвращаемое значение** - -- Квантиль заданного уровня. - -Тип: - -- [Float64](../../../sql-reference/data-types/float.md) для входных данных числового типа. -- [Date](../../../sql-reference/data-types/date.md), если входные значения имеют тип `Date`. -- [DateTime](../../../sql-reference/data-types/datetime.md), если входные значения имеют тип `DateTime`. -**Пример** - -Запрос: - -``` sql -SELECT quantileExact(number) FROM numbers(10) -``` - -Результат: - -``` text -┌─quantileExact(number)─┐ -│ 5 │ -└───────────────────────┘ -``` - -**Смотрите также** - -- [median](../../../sql-reference/aggregate-functions/reference/median.md#median) -- [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) - -[Оригинальная статья](https://clickhouse.tech/docs/en/sql-reference/aggregate-functions/reference/quantileexact/) +--- +toc_priority: 202 +--- + +# quantileExact {#quantileexact} + +Точно вычисляет [квантиль](https://ru.wikipedia.org/wiki/Квантиль) числовой последовательности. + +Чтобы получить точный результат, все переданные значения собираются в массив, который затем частично сортируется. Таким образом, функция потребляет объем памяти `O(n)`, где `n` — количество переданных значений. Для небольшого числа значений эта функция эффективна. + +Внутренние состояния функций `quantile*` не объединяются, если они используются в одном запросе. Если вам необходимо вычислить квантили нескольких уровней, используйте функцию [quantiles](#quantiles), это повысит эффективность запроса. + +**Синтаксис** + +``` sql +quantileExact(level)(expr) +``` + +Алиас: `medianExact`. + +**Параметры** + +- `level` — Уровень квантили. Опционально. Константное значение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://ru.wikipedia.org/wiki/Медиана_(статистика)). +- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../../sql-reference/data-types/index.md#data_types) или типов [Date](../../../sql-reference/data-types/date.md), [DateTime](../../../sql-reference/data-types/datetime.md). + +**Возвращаемое значение** + +- Квантиль заданного уровня. + +Тип: + +- [Float64](../../../sql-reference/data-types/float.md) для входных данных числового типа. +- [Date](../../../sql-reference/data-types/date.md), если входные значения имеют тип `Date`. +- [DateTime](../../../sql-reference/data-types/datetime.md), если входные значения имеют тип `DateTime`. + +**Пример** + +Запрос: + +``` sql +SELECT quantileExact(number) FROM numbers(10) +``` + +Результат: + +``` text +┌─quantileExact(number)─┐ +│ 5 │ +└───────────────────────┘ +``` + +# quantileExactLow {#quantileexactlow} + +Как и `quantileExact`, эта функция вычисляет точный [квантиль](https://en.wikipedia.org/wiki/Quantile) числовой последовательности данных. + +Чтобы получить точное значение, все переданные значения объединяются в массив, который затем полностью сортируется. Сложность [алгоритма сортировки](https://en.cppreference.com/w/cpp/algorithm/sort) равна `O(N·log(N))`, где `N = std::distance(first, last)`. + +Возвращаемое значение зависит от уровня квантили и количества элементов в выборке, то есть если уровень 0,5, то функция возвращает нижнюю медиану при чётном количестве элементов и медиану при нечётном. Медиана вычисляется аналогично реализации [median_low](https://docs.python.org/3/library/statistics.html#statistics.median_low), которая используется в python. + +Для всех остальных уровней возвращается элемент с индексом, соответствующим значению `level * size_of_array`. Например: + +``` sql +SELECT quantileExactLow(0.1)(number) FROM numbers(10) + +┌─quantileExactLow(0.1)(number)─┐ +│ 1 │ +└───────────────────────────────┘ +``` + +При использовании в запросе нескольких функций `quantile*` с разными уровнями, внутренние состояния не объединяются (то есть запрос работает менее эффективно). В этом случае используйте функцию [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles). + +**Синтаксис** + +``` sql +quantileExact(level)(expr) +``` + +Алиас: `medianExactLow`. + +**Параметры** + +- `level` — Уровень квантили. Опциональный параметр. Константное занчение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://en.wikipedia.org/wiki/Median). +- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../../sql-reference/data-types/index.md#data_types), [Date](../../../sql-reference/data-types/date.md) или [DateTime](../../../sql-reference/data-types/datetime.md). + +**Возвращаемое значение** + +- Квантиль заданного уровня. + +Тип: + +- [Float64](../../../sql-reference/data-types/float.md) для входных данных числового типа. +- [Date](../../../sql-reference/data-types/date.md) если входные значения имеют тип `Date`. +- [DateTime](../../../sql-reference/data-types/datetime.md) если входные значения имеют тип `DateTime`. + +**Пример** + +Запрос: + +``` sql +SELECT quantileExactLow(number) FROM numbers(10) +``` + +Результат: + +``` text +┌─quantileExactLow(number)─┐ +│ 4 │ +└──────────────────────────┘ +``` +# quantileExactHigh {#quantileexacthigh} + +Как и `quantileExact`, эта функция вычисляет точный [квантиль](https://en.wikipedia.org/wiki/Quantile) числовой последовательности данных. + +Все переданные значения объединяются в массив, который затем сортируется, чтобы получить точное значение. Сложность [алгоритма сортировки](https://en.cppreference.com/w/cpp/algorithm/sort) равна `O(N·log(N))`, где `N = std::distance(first, last)`. + +Возвращаемое значение зависит от уровня квантили и количества элементов в выборке, то есть если уровень 0,5, то функция возвращает верхнюю медиану при чётном количестве элементов и медиану при нечётном. Медиана вычисляется аналогично реализации [median_high](https://docs.python.org/3/library/statistics.html#statistics.median_high), которая используется в python. Для всех остальных уровней возвращается элемент с индексом, соответствующим значению `level * size_of_array`. + +Эта реализация ведет себя точно так же, как `quantileExact`. + +При использовании в запросе нескольких функций `quantile*` с разными уровнями, внутренние состояния не объединяются (то есть запрос работает менее эффективно). В этом случае используйте функцию [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles). + +**Синтаксис** + +``` sql +quantileExactHigh(level)(expr) +``` + +Алиас: `medianExactHigh`. + +**Параметры** + +- `level` — Уровень квантили. Опциональный параметр. Константное занчение с плавающей запятой от 0 до 1. Мы рекомендуем использовать значение `level` из диапазона `[0.01, 0.99]`. Значение по умолчанию: 0.5. При `level=0.5` функция вычисляет [медиану](https://en.wikipedia.org/wiki/Median). +- `expr` — Выражение над значениями столбца, которое возвращает данные [числовых типов](../../../sql-reference/data-types/index.md#data_types), [Date](../../../sql-reference/data-types/date.md) или [DateTime](../../../sql-reference/data-types/datetime.md). + +**Возвращаемое значение** + +- Квантиль заданного уровня. + +Тип: + +- [Float64](../../../sql-reference/data-types/float.md) для входных данных числового типа. +- [Date](../../../sql-reference/data-types/date.md) если входные значения имеют тип `Date`. +- [DateTime](../../../sql-reference/data-types/datetime.md) если входные значения имеют тип `DateTime`. + +**Пример** + +Запрос: + +``` sql +SELECT quantileExactHigh(number) FROM numbers(10) +``` + +Результат: + +``` text +┌─quantileExactHigh(number)─┐ +│ 5 │ +└───────────────────────────┘ +``` + +**Смотрите также** + +- [median](../../../sql-reference/aggregate-functions/reference/median.md#median) +- [quantiles](../../../sql-reference/aggregate-functions/reference/quantiles.md#quantiles) + +[Оригинальная статья](https://clickhouse.tech/docs/en/sql-reference/aggregate-functions/reference/quantileexact/) diff --git a/docs/ru/sql-reference/functions/other-functions.md b/docs/ru/sql-reference/functions/other-functions.md index 9367f3be00c..91bf0f5b3a0 100644 --- a/docs/ru/sql-reference/functions/other-functions.md +++ b/docs/ru/sql-reference/functions/other-functions.md @@ -927,6 +927,48 @@ SELECT defaultValueOfArgumentType( CAST(1 AS Nullable(Int8) ) ) └───────────────────────────────────────────────────────┘ ``` +## defaultValueOfTypeName {#defaultvalueoftypename} + +Выводит значение по умолчанию для указанного типа данных. + +Не включает значения по умолчанию для настраиваемых столбцов, установленных пользователем. + +``` sql +defaultValueOfTypeName(type) +``` + +**Параметры:** + +- `type` — тип данных. + +**Возвращаемое значение** + +- `0` для чисел; +- Пустая строка для строк; +- `ᴺᵁᴸᴸ` для [Nullable](../../sql-reference/data-types/nullable.md). + +**Пример** + +``` sql +SELECT defaultValueOfTypeName('Int8') +``` + +``` text +┌─defaultValueOfTypeName('Int8')─┐ +│ 0 │ +└────────────────────────────────┘ +``` + +``` sql +SELECT defaultValueOfTypeName('Nullable(Int8)') +``` + +``` text +┌─defaultValueOfTypeName('Nullable(Int8)')─┐ +│ ᴺᵁᴸᴸ │ +└──────────────────────────────────────────┘ +``` + ## replicate {#other-functions-replicate} Создает массив, заполненный одним значением. From fa929b03122c8724f7cd28a78d8d338f14b6ab90 Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Wed, 4 Nov 2020 23:45:06 +0300 Subject: [PATCH 94/95] Replace duplicate development config files with symlinks. (#16486) * Fix test "max_memory_usage_for_user" * Update test * Update annoying boilerplate * Support symlinks in tarballs * Fix Fuzzer * Remove "secondary" user * Remove "secondary" user --- docker/packager/binary/build.sh | 2 +- docker/test/fuzzer/run-fuzzer.sh | 10 ++++----- programs/server/config.d/macros.xml | 6 +---- programs/server/config.d/metric_log.xml | 9 +------- programs/server/config.d/part_log.xml | 8 +------ .../server/config.d/query_masking_rules.xml | 20 +---------------- programs/server/config.d/text_log.xml | 8 +------ programs/server/config.d/zookeeper.xml | 6 +---- programs/server/users.d/access_management.xml | 8 +------ programs/server/users.d/log_queries.xml | 9 +------- programs/server/users.d/readonly.xml | 22 +------------------ 11 files changed, 15 insertions(+), 93 deletions(-) mode change 100644 => 120000 programs/server/config.d/macros.xml mode change 100644 => 120000 programs/server/config.d/metric_log.xml mode change 100644 => 120000 programs/server/config.d/part_log.xml mode change 100644 => 120000 programs/server/config.d/query_masking_rules.xml mode change 100644 => 120000 programs/server/config.d/text_log.xml mode change 100644 => 120000 programs/server/config.d/zookeeper.xml mode change 100644 => 120000 programs/server/users.d/access_management.xml mode change 100644 => 120000 programs/server/users.d/log_queries.xml mode change 100644 => 120000 programs/server/users.d/readonly.xml diff --git a/docker/packager/binary/build.sh b/docker/packager/binary/build.sh index 8acbe271b1f..4ba2f5f87c7 100755 --- a/docker/packager/binary/build.sh +++ b/docker/packager/binary/build.sh @@ -63,7 +63,7 @@ then mkdir -p /output/config cp ../programs/server/config.xml /output/config cp ../programs/server/users.xml /output/config - cp -r ../programs/server/config.d /output/config + cp -r --dereference ../programs/server/config.d /output/config tar -czvf "$COMBINED_OUTPUT.tgz" /output rm -r /output/* mv "$COMBINED_OUTPUT.tgz" /output diff --git a/docker/test/fuzzer/run-fuzzer.sh b/docker/test/fuzzer/run-fuzzer.sh index 41559a9b1f5..26db6455fd5 100755 --- a/docker/test/fuzzer/run-fuzzer.sh +++ b/docker/test/fuzzer/run-fuzzer.sh @@ -45,11 +45,11 @@ function configure { rm -rf db ||: mkdir db ||: - cp -av "$repo_dir"/programs/server/config* db - cp -av "$repo_dir"/programs/server/user* db + cp -av --dereference "$repo_dir"/programs/server/config* db + cp -av --dereference "$repo_dir"/programs/server/user* db # TODO figure out which ones are needed - cp -av "$repo_dir"/tests/config/config.d/listen.xml db/config.d - cp -av "$script_dir"/query-fuzzer-tweaks-users.xml db/users.d + cp -av --dereference "$repo_dir"/tests/config/config.d/listen.xml db/config.d + cp -av --dereference "$script_dir"/query-fuzzer-tweaks-users.xml db/users.d } function watchdog @@ -89,7 +89,7 @@ function fuzz > >(tail -10000 > fuzzer.log) \ 2>&1 \ || fuzzer_exit_code=$? - + echo "Fuzzer exit code is $fuzzer_exit_code" ./clickhouse-client --query "select elapsed, query from system.processes" ||: diff --git a/programs/server/config.d/macros.xml b/programs/server/config.d/macros.xml deleted file mode 100644 index 1f86f5f9efd..00000000000 --- a/programs/server/config.d/macros.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Hello, world! - - diff --git a/programs/server/config.d/macros.xml b/programs/server/config.d/macros.xml new file mode 120000 index 00000000000..f28bafb97fa --- /dev/null +++ b/programs/server/config.d/macros.xml @@ -0,0 +1 @@ +../../../tests/config/config.d/macros.xml \ No newline at end of file diff --git a/programs/server/config.d/metric_log.xml b/programs/server/config.d/metric_log.xml deleted file mode 100644 index 0ca9f162416..00000000000 --- a/programs/server/config.d/metric_log.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - system - metric_log
- 7500 - 1000 -
-
diff --git a/programs/server/config.d/metric_log.xml b/programs/server/config.d/metric_log.xml new file mode 120000 index 00000000000..7f033c60a64 --- /dev/null +++ b/programs/server/config.d/metric_log.xml @@ -0,0 +1 @@ +../../../tests/config/config.d/metric_log.xml \ No newline at end of file diff --git a/programs/server/config.d/part_log.xml b/programs/server/config.d/part_log.xml deleted file mode 100644 index 35add3c6cc1..00000000000 --- a/programs/server/config.d/part_log.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - system - part_log
- 7500 -
-
diff --git a/programs/server/config.d/part_log.xml b/programs/server/config.d/part_log.xml new file mode 120000 index 00000000000..d97ea7f226d --- /dev/null +++ b/programs/server/config.d/part_log.xml @@ -0,0 +1 @@ +../../../tests/config/config.d/part_log.xml \ No newline at end of file diff --git a/programs/server/config.d/query_masking_rules.xml b/programs/server/config.d/query_masking_rules.xml deleted file mode 100644 index f919523472c..00000000000 --- a/programs/server/config.d/query_masking_rules.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - profanity - (?i:shit) - substance - - - - TOPSECRET.TOPSECRET - [hidden] - - - diff --git a/programs/server/config.d/query_masking_rules.xml b/programs/server/config.d/query_masking_rules.xml new file mode 120000 index 00000000000..2e2a234a67b --- /dev/null +++ b/programs/server/config.d/query_masking_rules.xml @@ -0,0 +1 @@ +../../../tests/config/config.d/query_masking_rules.xml \ No newline at end of file diff --git a/programs/server/config.d/text_log.xml b/programs/server/config.d/text_log.xml deleted file mode 100644 index 3699a23578c..00000000000 --- a/programs/server/config.d/text_log.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - system - text_log
- 7500 -
-
diff --git a/programs/server/config.d/text_log.xml b/programs/server/config.d/text_log.xml new file mode 120000 index 00000000000..49203862fa6 --- /dev/null +++ b/programs/server/config.d/text_log.xml @@ -0,0 +1 @@ +../../../tests/config/config.d/text_log.xml \ No newline at end of file diff --git a/programs/server/config.d/zookeeper.xml b/programs/server/config.d/zookeeper.xml deleted file mode 100644 index 68c85788c98..00000000000 --- a/programs/server/config.d/zookeeper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - testkeeper - - diff --git a/programs/server/config.d/zookeeper.xml b/programs/server/config.d/zookeeper.xml new file mode 120000 index 00000000000..921e0011378 --- /dev/null +++ b/programs/server/config.d/zookeeper.xml @@ -0,0 +1 @@ +../../../tests/config/config.d/zookeeper.xml \ No newline at end of file diff --git a/programs/server/users.d/access_management.xml b/programs/server/users.d/access_management.xml deleted file mode 100644 index 7e799cb7b10..00000000000 --- a/programs/server/users.d/access_management.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - 1 - - - diff --git a/programs/server/users.d/access_management.xml b/programs/server/users.d/access_management.xml new file mode 120000 index 00000000000..b7331126e09 --- /dev/null +++ b/programs/server/users.d/access_management.xml @@ -0,0 +1 @@ +../../../tests/config/users.d/access_management.xml \ No newline at end of file diff --git a/programs/server/users.d/log_queries.xml b/programs/server/users.d/log_queries.xml deleted file mode 100644 index 796a115d8a6..00000000000 --- a/programs/server/users.d/log_queries.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - 1 - - - diff --git a/programs/server/users.d/log_queries.xml b/programs/server/users.d/log_queries.xml new file mode 120000 index 00000000000..c7c0c99e000 --- /dev/null +++ b/programs/server/users.d/log_queries.xml @@ -0,0 +1 @@ +../../../tests/config/users.d/log_queries.xml \ No newline at end of file diff --git a/programs/server/users.d/readonly.xml b/programs/server/users.d/readonly.xml deleted file mode 100644 index 64fbaf77464..00000000000 --- a/programs/server/users.d/readonly.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - 1 - - - - - - - - ::1 - 127.0.0.1 - - readonly - default - - - diff --git a/programs/server/users.d/readonly.xml b/programs/server/users.d/readonly.xml new file mode 120000 index 00000000000..9029a2ce480 --- /dev/null +++ b/programs/server/users.d/readonly.xml @@ -0,0 +1 @@ +../../../tests/config/users.d/readonly.xml \ No newline at end of file From 6757fb69960a5d75513da685c319c87acfdf1126 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 5 Nov 2020 01:17:19 +0300 Subject: [PATCH 95/95] Add development roadmap for web UI --- programs/server/play.html | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/programs/server/play.html b/programs/server/play.html index de918191cdf..22eea0002ca 100644 --- a/programs/server/play.html +++ b/programs/server/play.html @@ -3,7 +3,7 @@ ClickHouse Query - + +