diff --git a/dbms/include/DB/Storages/StorageMergeTree.h b/dbms/include/DB/Storages/StorageMergeTree.h index 7f4f4839c73..06c7761ca03 100644 --- a/dbms/include/DB/Storages/StorageMergeTree.h +++ b/dbms/include/DB/Storages/StorageMergeTree.h @@ -94,7 +94,7 @@ private: String date_column_name; size_t index_granularity; - Expression primary_expr; + SharedPtr primary_expr; SortDescription sort_descr; Increment increment; diff --git a/dbms/src/Storages/StorageFactory.cpp b/dbms/src/Storages/StorageFactory.cpp index 9ab6f639fac..cb2c9b3e9fa 100644 --- a/dbms/src/Storages/StorageFactory.cpp +++ b/dbms/src/Storages/StorageFactory.cpp @@ -127,7 +127,7 @@ StoragePtr StorageFactory::get( UInt64 index_granularity = boost::get(dynamic_cast(*args[2]).value); ASTFunction & primary_expr_func = dynamic_cast(*args[1]); - if (primary_expr_func.name != "makeTuple") + if (primary_expr_func.name != "tuple") throw Exception("Primary expression for storage MergeTree must be in parentheses.", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); diff --git a/dbms/src/Storages/StorageMergeTree.cpp b/dbms/src/Storages/StorageMergeTree.cpp index 69d7e80744c..4c48bb2a298 100644 --- a/dbms/src/Storages/StorageMergeTree.cpp +++ b/dbms/src/Storages/StorageMergeTree.cpp @@ -119,7 +119,7 @@ private: Poco::File(part_tmp_path).createDirectories(); /// Если для сортировки надо вычислить некоторые столбцы - делаем это. - storage.primary_expr.execute(block); + storage.primary_expr->execute(block); /// Сортируем. sortBlock(block, storage.sort_descr); @@ -189,7 +189,6 @@ StorageMergeTree::StorageMergeTree( : path(path_), name(name_), full_path(path + escapeForFileName(name) + '/'), columns(columns_), context(context_), primary_expr_ast(primary_expr_ast_->clone()), date_column_name(date_column_name_), index_granularity(index_granularity_), - primary_expr(primary_expr_ast, context), increment(full_path + "increment.txt") { /// создаём директорию, если её нет @@ -201,9 +200,12 @@ StorageMergeTree::StorageMergeTree( it != primary_expr_ast->children.end(); ++it) { - String name = (*it)->children.front()->getColumnName(); + String name = (*it)->getColumnName(); sort_descr.push_back(SortColumnDescription(name, 1)); } + + context.columns = *columns; + primary_expr = new Expression(primary_expr_ast, context); }