mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Add settings for check query backward compatibility
This commit is contained in:
parent
30464ccef7
commit
f786c45ac4
@ -331,7 +331,8 @@ struct Settings : public SettingsCollection<Settings>
|
||||
M(SettingBool, allow_hyperscan, true, "Allow functions that use Hyperscan library. Disable to avoid potentially long compilation times and excessive resource usage.") \
|
||||
M(SettingBool, allow_simdjson, true, "Allow using simdjson library in 'JSON*' functions if AVX2 instructions are available. If disabled rapidjson will be used.") \
|
||||
\
|
||||
M(SettingUInt64, max_partitions_per_insert_block, 100, "Limit maximum number of partitions in single INSERTed block. Zero means unlimited. Throw exception if the block contains too many partitions. This setting is a safety threshold, because using large number of partitions is a common misconception.")
|
||||
M(SettingUInt64, max_partitions_per_insert_block, 100, "Limit maximum number of partitions in single INSERTed block. Zero means unlimited. Throw exception if the block contains too many partitions. This setting is a safety threshold, because using large number of partitions is a common misconception.") \
|
||||
M(SettingBool, check_query_single_value_result, true, "Return check query result as single 1/0 value")
|
||||
|
||||
DECLARE_SETTINGS_COLLECTION(LIST_OF_SETTINGS)
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <DataTypes/DataTypeString.h>
|
||||
#include <Columns/ColumnsNumber.h>
|
||||
#include <Common/typeid_cast.h>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -42,22 +43,33 @@ BlockIO InterpreterCheckQuery::execute()
|
||||
StoragePtr table = context.getTable(database_name, table_name);
|
||||
auto check_results = table->checkData(query_ptr, context);
|
||||
|
||||
auto block_structure = getBlockStructure();
|
||||
auto path_column = block_structure[0].type->createColumn();
|
||||
auto is_passed_column = block_structure[1].type->createColumn();
|
||||
auto message_column = block_structure[2].type->createColumn();
|
||||
|
||||
for (const auto & check_result : check_results)
|
||||
Block block;
|
||||
if (context.getSettingsRef().check_query_single_value_result)
|
||||
{
|
||||
path_column->insert(check_result.fs_path);
|
||||
is_passed_column->insert(static_cast<UInt8>(check_result.success));
|
||||
message_column->insert(check_result.failure_message);
|
||||
bool result = std::all_of(check_results.begin(), check_results.end(), [](const CheckResult & res ) { return res.success; });
|
||||
auto column = ColumnUInt8::create();
|
||||
column->insertValue(UInt64(result));
|
||||
block = Block{{std::move(column), std::make_shared<DataTypeUInt8>(), "result"}};
|
||||
}
|
||||
else
|
||||
{
|
||||
auto block_structure = getBlockStructure();
|
||||
auto path_column = block_structure[0].type->createColumn();
|
||||
auto is_passed_column = block_structure[1].type->createColumn();
|
||||
auto message_column = block_structure[2].type->createColumn();
|
||||
|
||||
Block block({
|
||||
{std::move(path_column), block_structure[0].type, block_structure[0].name},
|
||||
{std::move(is_passed_column), block_structure[1].type, block_structure[1].name},
|
||||
{std::move(message_column), block_structure[2].type, block_structure[2].name}});
|
||||
for (const auto & check_result : check_results)
|
||||
{
|
||||
path_column->insert(check_result.fs_path);
|
||||
is_passed_column->insert(static_cast<UInt8>(check_result.success));
|
||||
message_column->insert(check_result.failure_message);
|
||||
}
|
||||
|
||||
block = Block({
|
||||
{std::move(path_column), block_structure[0].type, block_structure[0].name},
|
||||
{std::move(is_passed_column), block_structure[1].type, block_structure[1].name},
|
||||
{std::move(message_column), block_structure[2].type, block_structure[2].name}});
|
||||
}
|
||||
|
||||
BlockIO res;
|
||||
res.in = std::make_shared<OneBlockInputStream>(block);
|
||||
|
@ -21,7 +21,6 @@ private:
|
||||
ASTPtr query_ptr;
|
||||
|
||||
const Context & context;
|
||||
Block result;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,2 @@
|
||||
N.bin 1
|
||||
S.bin 1
|
||||
N.bin 1
|
||||
S.bin 1
|
||||
__marks.mrk 1
|
||||
1
|
||||
1
|
||||
|
@ -1,3 +1,5 @@
|
||||
SET check_query_single_value_result = 1;
|
||||
|
||||
DROP TABLE IF EXISTS check_query_tiny_log;
|
||||
|
||||
CREATE TABLE check_query_tiny_log (N UInt32, S String) Engine = TinyLog;
|
||||
|
@ -1,3 +1,4 @@
|
||||
SET check_query_single_value_result = 0;
|
||||
DROP TABLE IF EXISTS mt_table;
|
||||
|
||||
CREATE TABLE mt_table (d Date, key UInt64, data String) ENGINE = MergeTree() PARTITION BY toYYYYMM(d) ORDER BY key;
|
||||
|
@ -1,17 +1,10 @@
|
||||
1
|
||||
1
|
||||
1
|
||||
8873898 12457120258355519194
|
||||
8873898 12457120258355519194
|
||||
8873898 12457120258355519194
|
||||
8873898 12457120258355519194
|
||||
AdvEngineID.bin 1
|
||||
CounterID.bin 1
|
||||
RegionID.bin 1
|
||||
SearchPhrase.bin 1
|
||||
UserID.bin 1
|
||||
__marks.mrk 1
|
||||
AdvEngineID.bin 1
|
||||
CounterID.bin 1
|
||||
RegionID.bin 1
|
||||
SearchPhrase.bin 1
|
||||
UserID.bin 1
|
||||
data.bin 1
|
||||
index.mrk 1
|
||||
1
|
||||
1
|
||||
1
|
||||
|
@ -1,3 +1,5 @@
|
||||
SET check_query_single_value_result = 1;
|
||||
|
||||
DROP TABLE IF EXISTS test.hits_log;
|
||||
DROP TABLE IF EXISTS test.hits_tinylog;
|
||||
DROP TABLE IF EXISTS test.hits_stripelog;
|
||||
|
Loading…
Reference in New Issue
Block a user