mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
[StorageMerge] check that underlying tables support sampling
This commit is contained in:
parent
a08fee57b7
commit
28bddf9a4a
@ -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)
|
||||
|
@ -0,0 +1,20 @@
|
||||
494
|
||||
331
|
||||
576
|
||||
709
|
||||
903
|
||||
378
|
||||
498
|
||||
102
|
||||
861
|
||||
97
|
||||
494
|
||||
331
|
||||
576
|
||||
709
|
||||
903
|
||||
378
|
||||
498
|
||||
102
|
||||
861
|
||||
97
|
@ -0,0 +1,18 @@
|
||||
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;
|
Loading…
Reference in New Issue
Block a user