mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +00:00
Move partition key initialization into registerMergeTree
This commit is contained in:
parent
ad443d9d0c
commit
3c47faa9da
@ -138,7 +138,9 @@ public:
|
||||
public:
|
||||
|
||||
StorageInMemoryMetadata getInMemoryMetadata() const { return *metadata.get(); }
|
||||
|
||||
StorageMetadataPtr getInMemoryMetadataPtr() const { return metadata.get(); }
|
||||
|
||||
void setInMemoryMetadata(const StorageInMemoryMetadata & metadata_)
|
||||
{
|
||||
metadata.set(std::make_unique<StorageInMemoryMetadata>(metadata_));
|
||||
|
@ -118,7 +118,7 @@ const char * DELETE_ON_DESTROY_MARKER_PATH = "delete-on-destroy.txt";
|
||||
MergeTreeData::MergeTreeData(
|
||||
const StorageID & table_id_,
|
||||
const String & relative_data_path_,
|
||||
StorageInMemoryMetadata metadata_,
|
||||
const StorageInMemoryMetadata & metadata_,
|
||||
Context & context_,
|
||||
const String & date_column_name,
|
||||
const MergingParams & merging_params_,
|
||||
@ -143,15 +143,11 @@ MergeTreeData::MergeTreeData(
|
||||
throw Exception("MergeTree storages require data path", ErrorCodes::INCORRECT_FILE_NAME);
|
||||
|
||||
MergeTreeDataFormatVersion min_format_version(0);
|
||||
/// TODO(alesap) Move to register methods
|
||||
if (!date_column_name.empty())
|
||||
{
|
||||
try
|
||||
{
|
||||
auto partition_by_ast = makeASTFunction("toYYYYMM", std::make_shared<ASTIdentifier>(date_column_name));
|
||||
metadata_.partition_key = KeyDescription::getKeyFromAST(partition_by_ast, metadata_.columns, global_context);
|
||||
initPartitionKey(metadata_.partition_key);
|
||||
|
||||
if (minmax_idx_date_column_pos == -1)
|
||||
throw Exception("Could not find Date column", ErrorCodes::BAD_TYPE_OF_FIELD);
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ public:
|
||||
/// attach - whether the existing table is attached or the new table is created.
|
||||
MergeTreeData(const StorageID & table_id_,
|
||||
const String & relative_data_path_,
|
||||
StorageInMemoryMetadata metadata_,
|
||||
const StorageInMemoryMetadata & metadata_,
|
||||
Context & context_,
|
||||
const String & date_column_name,
|
||||
const MergingParams & merging_params_,
|
||||
|
@ -570,6 +570,12 @@ static StoragePtr create(const StorageFactory::Arguments & args)
|
||||
throw Exception(
|
||||
"Date column name must be an unquoted string" + getMergeTreeVerboseHelp(is_extended_storage_def),
|
||||
ErrorCodes::BAD_ARGUMENTS);
|
||||
|
||||
auto partition_by_ast = makeASTFunction("toYYYYMM", std::make_shared<ASTIdentifier>(date_column_name));
|
||||
|
||||
metadata.partition_key = KeyDescription::getKeyFromAST(partition_by_ast, metadata.columns, args.context);
|
||||
|
||||
|
||||
++arg_num;
|
||||
|
||||
/// If there is an expression for sampling
|
||||
|
@ -14,9 +14,6 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
/// Structure represent table metadata stored in memory.
|
||||
/// Only one storage engine support all fields -- MergeTree.
|
||||
/// Complete table AST can be recreated from this struct.
|
||||
struct StorageInMemoryMetadata
|
||||
{
|
||||
/// Columns of table with their names, types,
|
||||
|
Loading…
Reference in New Issue
Block a user