未验证 提交 0c38226a 编写于 作者: A alexey-milovidov 提交者: GitHub

Merge pull request #5366 from abyss7/storage-merge-sample

Check that underlying tables support sampling for StorageMerge
......@@ -41,6 +41,7 @@ namespace ErrorCodes
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
extern const int NO_SUCH_COLUMN_IN_TABLE;
extern const int BLOCKS_HAVE_DIFFERENT_STRUCTURE;
extern const int SAMPLING_NOT_SUPPORTED;
}
......@@ -218,6 +219,7 @@ BlockInputStreams StorageMerge::read(
query_info.query, has_table_virtual_column, true, context.getCurrentQueryId());
if (selected_tables.empty())
/// FIXME: do we support sampling in this case?
return createSourceStreams(
query_info, processed_stage, max_block_size, header, {}, {}, real_column_names, modified_context, 0, has_table_virtual_column);
......@@ -234,6 +236,10 @@ BlockInputStreams StorageMerge::read(
StoragePtr storage = it->first;
TableStructureReadLockHolder struct_lock = it->second;
/// If sampling requested, then check that table supports it.
if (query_info.query->as<ASTSelectQuery>()->sample_size() && !storage->supportsSampling())
throw Exception("Illegal SAMPLE: table doesn't support sampling", ErrorCodes::SAMPLING_NOT_SUPPORTED);
BlockInputStreams source_streams;
if (current_streams)
......
494
331
576
709
903
378
498
102
861
97
494
331
576
709
903
378
498
102
861
97
DROP TABLE IF EXISTS test.numbers1;
DROP TABLE IF EXISTS test.numbers2;
CREATE TABLE test.numbers1 ENGINE = Memory AS SELECT number FROM numbers(1000);
CREATE TABLE test.numbers2 ENGINE = Memory AS SELECT number FROM numbers(1000);
SELECT * FROM merge(test, '^numbers\\d+$') SAMPLE 0.1; -- { serverError 141 }
DROP TABLE test.numbers1;
DROP TABLE test.numbers2;
CREATE TABLE test.numbers1 ENGINE = MergeTree ORDER BY intHash32(number) SAMPLE BY intHash32(number) AS SELECT number FROM numbers(1000);
CREATE TABLE test.numbers2 ENGINE = MergeTree ORDER BY intHash32(number) SAMPLE BY intHash32(number) AS SELECT number FROM numbers(1000);
SELECT * FROM merge(test, '^numbers\\d+$') SAMPLE 0.01;
DROP TABLE test.numbers1;
DROP TABLE test.numbers2;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册