mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Added backward compatibility for tables created with wrong sampling key; fixed tiny error [#CLICKHOUSE-2].
This commit is contained in:
parent
dadb32d042
commit
6aff58c747
@ -117,7 +117,8 @@ MergeTreeData::MergeTreeData(
|
||||
|
||||
initPrimaryKey();
|
||||
|
||||
if (sampling_expression && (!primary_expr_ast || !primary_key_sample.has(sampling_expression->getColumnName())))
|
||||
if (sampling_expression && (!primary_expr_ast || !primary_key_sample.has(sampling_expression->getColumnName()))
|
||||
&& !attach && !settings.compatibility_allow_sampling_expression_not_in_primary_key) /// This is for backward compatibility.
|
||||
throw Exception("Sampling expression must be present in the primary key", ErrorCodes::BAD_ARGUMENTS);
|
||||
|
||||
MergeTreeDataFormatVersion min_format_version(0);
|
||||
@ -125,7 +126,7 @@ MergeTreeData::MergeTreeData(
|
||||
{
|
||||
try
|
||||
{
|
||||
String partition_expr_str = "toYYYYMM(" + date_column_name + ")";
|
||||
String partition_expr_str = "toYYYYMM(" + backQuoteIfNeed(date_column_name) + ")";
|
||||
ParserNotEmptyExpressionList parser(/* allow_alias_without_as_keyword = */ false);
|
||||
partition_expr_ast = parseQuery(
|
||||
parser, partition_expr_str.data(), partition_expr_str.data() + partition_expr_str.length(), "partition expression");
|
||||
|
@ -122,7 +122,15 @@ struct MergeTreeSettings
|
||||
M(SettingUInt64, vertical_merge_algorithm_min_rows_to_activate, 16 * DEFAULT_MERGE_BLOCK_SIZE) \
|
||||
\
|
||||
/** Minimal amount of non-PK columns to activate Vertical merge algorithm */ \
|
||||
M(SettingUInt64, vertical_merge_algorithm_min_columns_to_activate, 11)
|
||||
M(SettingUInt64, vertical_merge_algorithm_min_columns_to_activate, 11) \
|
||||
\
|
||||
/** Compatibility settings */ \
|
||||
\
|
||||
/** Allow to create a table with sampling expression not in primary key. \
|
||||
* This is needed only to temporarily allow to run the server with wrong tables \
|
||||
* for backward compatibility. \
|
||||
*/ \
|
||||
M(SettingBool, compatibility_allow_sampling_expression_not_in_primary_key, false) \
|
||||
|
||||
/// Settings that should not change after the creation of a table.
|
||||
#define APPLY_FOR_IMMUTABLE_MERGE_TREE_SETTINGS(M) \
|
||||
|
Loading…
Reference in New Issue
Block a user