This commit is contained in:
Andrey Mironov 2014-11-11 19:29:21 +03:00
parent 8a2de38dc7
commit 65629ef560

View File

@ -45,23 +45,27 @@ MergeTreeData::MergeTreeData(
log_name(log_name_), log(&Logger::get(log_name + " (Data)"))
{
/// Проверяем, что столбец с датой существует и имеет тип Date.
{
auto it = columns->begin();
for (; it != columns->end(); ++it)
const auto check_date_exists = [this] (const NamesAndTypesList & columns) {
for (const auto & column : columns)
{
if (it->name == date_column_name)
if (column.name == date_column_name)
{
if (!typeid_cast<const DataTypeDate *>(&*it->type))
if (!typeid_cast<const DataTypeDate *>(column.type.get()))
throw Exception("Date column (" + date_column_name + ") for storage of MergeTree family must have type Date."
" Provided column of type " + it->type->getName() + "."
" You may have separate column with type " + it->type->getName() + ".", ErrorCodes::BAD_TYPE_OF_FIELD);
break;
" Provided column of type " + column.type->getName() + "."
" You may have separate column with type " + column.type->getName() + ".", ErrorCodes::BAD_TYPE_OF_FIELD);
return true;
}
}
if (it == columns->end())
throw Exception("Date column (" + date_column_name + ") does not exist in table declaration.", ErrorCodes::NO_SUCH_COLUMN_IN_TABLE);
}
return false;
};
if (!check_date_exists(*columns) && !check_date_exists(materialized_columns))
throw Exception{
"Date column (" + date_column_name + ") does not exist in table declaration.",
ErrorCodes::NO_SUCH_COLUMN_IN_TABLE
};
/// создаём директорию, если её нет
Poco::File(full_path).createDirectories();
@ -75,9 +79,9 @@ MergeTreeData::MergeTreeData(
sort_descr.push_back(SortColumnDescription(name, 1));
}
primary_expr = ExpressionAnalyzer(primary_expr_ast, context, *columns).getActions(false);
primary_expr = ExpressionAnalyzer(primary_expr_ast, context, getColumnsList()).getActions(false);
ExpressionActionsPtr projected_expr = ExpressionAnalyzer(primary_expr_ast, context, *columns).getActions(true);
ExpressionActionsPtr projected_expr = ExpressionAnalyzer(primary_expr_ast, context, getColumnsList()).getActions(true);
primary_key_sample = projected_expr->getSampleBlock();
}