fix sample by tuple()

add tests

fix

fix

fix
This commit is contained in:
feng lv 2021-10-12 04:13:02 +00:00
parent 84e16f9c8e
commit b5d69d599e
3 changed files with 11 additions and 0 deletions

View File

@ -132,10 +132,14 @@ namespace ErrorCodes
extern const int ALTER_OF_COLUMN_IS_FORBIDDEN; extern const int ALTER_OF_COLUMN_IS_FORBIDDEN;
extern const int SUPPORT_IS_DISABLED; extern const int SUPPORT_IS_DISABLED;
extern const int TOO_MANY_SIMULTANEOUS_QUERIES; extern const int TOO_MANY_SIMULTANEOUS_QUERIES;
extern const int INCORRECT_QUERY;
} }
static void checkSampleExpression(const StorageInMemoryMetadata & metadata, bool allow_sampling_expression_not_in_primary_key, bool check_sample_column_is_correct) static void checkSampleExpression(const StorageInMemoryMetadata & metadata, bool allow_sampling_expression_not_in_primary_key, bool check_sample_column_is_correct)
{ {
if (metadata.sampling_key.column_names.empty())
throw Exception("There are no columns in sampling expression", ErrorCodes::INCORRECT_QUERY);
const auto & pk_sample_block = metadata.getPrimaryKey().sample_block; const auto & pk_sample_block = metadata.getPrimaryKey().sample_block;
if (!pk_sample_block.has(metadata.sampling_key.column_names[0]) && !allow_sampling_expression_not_in_primary_key) if (!pk_sample_block.has(metadata.sampling_key.column_names[0]) && !allow_sampling_expression_not_in_primary_key)
throw Exception("Sampling expression must be present in the primary key", ErrorCodes::BAD_ARGUMENTS); throw Exception("Sampling expression must be present in the primary key", ErrorCodes::BAD_ARGUMENTS);

View File

@ -0,0 +1,7 @@
DROP TABLE IF EXISTS t;
CREATE TABLE t (n UInt8) ENGINE=MergeTree ORDER BY n SAMPLE BY tuple(); -- { serverError 80 }
CREATE TABLE t (n UInt8) ENGINE=MergeTree ORDER BY tuple();
ALTER TABLE t MODIFY SAMPLE BY tuple(); -- { serverError 80 }