mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
clickhouse: fixed [#6201].
This commit is contained in:
parent
3f2da2d2e3
commit
81883201ec
@ -110,7 +110,7 @@ public:
|
|||||||
Context & context_,
|
Context & context_,
|
||||||
ASTPtr & primary_expr_ast_,
|
ASTPtr & primary_expr_ast_,
|
||||||
const String & date_column_name_,
|
const String & date_column_name_,
|
||||||
const String & sampling_column_name_, /// "", если семплирование не поддерживается.
|
const ASTPtr & sampling_expression_, /// NULL, если семплирование не поддерживается.
|
||||||
size_t index_granularity_,
|
size_t index_granularity_,
|
||||||
const String & sign_column_ = "",
|
const String & sign_column_ = "",
|
||||||
const StorageMergeTreeSettings & settings_ = StorageMergeTreeSettings());
|
const StorageMergeTreeSettings & settings_ = StorageMergeTreeSettings());
|
||||||
@ -119,7 +119,7 @@ public:
|
|||||||
|
|
||||||
std::string getName() const { return "MergeTree"; }
|
std::string getName() const { return "MergeTree"; }
|
||||||
std::string getTableName() const { return name; }
|
std::string getTableName() const { return name; }
|
||||||
bool supportsSampling() const { return sampling_column_name != ""; }
|
bool supportsSampling() const { return !!sampling_expression; }
|
||||||
|
|
||||||
const NamesAndTypesList & getColumnsList() const { return *columns; }
|
const NamesAndTypesList & getColumnsList() const { return *columns; }
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ private:
|
|||||||
Context context;
|
Context context;
|
||||||
ASTPtr primary_expr_ast;
|
ASTPtr primary_expr_ast;
|
||||||
String date_column_name;
|
String date_column_name;
|
||||||
String sampling_column_name; /// "", если семплирование не поддерживается.
|
ASTPtr sampling_expression;
|
||||||
size_t index_granularity;
|
size_t index_granularity;
|
||||||
|
|
||||||
size_t min_marks_for_seek;
|
size_t min_marks_for_seek;
|
||||||
|
@ -181,7 +181,7 @@ StoragePtr StorageFactory::get(
|
|||||||
size_t arg_offset = args.size() - 3;
|
size_t arg_offset = args.size() - 3;
|
||||||
|
|
||||||
String date_column_name = dynamic_cast<ASTIdentifier &>(*args[0]).name;
|
String date_column_name = dynamic_cast<ASTIdentifier &>(*args[0]).name;
|
||||||
String sampling_column_name = arg_offset == 0 ? "" : args[1]->getColumnName();
|
ASTPtr sampling_expression = arg_offset == 0 ? NULL : args[1];
|
||||||
UInt64 index_granularity = boost::get<UInt64>(dynamic_cast<ASTLiteral &>(*args[arg_offset + 2]).value);
|
UInt64 index_granularity = boost::get<UInt64>(dynamic_cast<ASTLiteral &>(*args[arg_offset + 2]).value);
|
||||||
ASTFunction & primary_expr_func = dynamic_cast<ASTFunction &>(*args[arg_offset + 1]);
|
ASTFunction & primary_expr_func = dynamic_cast<ASTFunction &>(*args[arg_offset + 1]);
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ StoragePtr StorageFactory::get(
|
|||||||
|
|
||||||
ASTPtr primary_expr = primary_expr_func.children.at(0);
|
ASTPtr primary_expr = primary_expr_func.children.at(0);
|
||||||
|
|
||||||
return new StorageMergeTree(data_path, table_name, columns, context, primary_expr, date_column_name, sampling_column_name, index_granularity);
|
return new StorageMergeTree(data_path, table_name, columns, context, primary_expr, date_column_name, sampling_expression, index_granularity);
|
||||||
}
|
}
|
||||||
else if (name == "CollapsingMergeTree")
|
else if (name == "CollapsingMergeTree")
|
||||||
{
|
{
|
||||||
@ -220,7 +220,7 @@ StoragePtr StorageFactory::get(
|
|||||||
size_t arg_offset = args.size() - 4;
|
size_t arg_offset = args.size() - 4;
|
||||||
|
|
||||||
String date_column_name = dynamic_cast<ASTIdentifier &>(*args[0]).name;
|
String date_column_name = dynamic_cast<ASTIdentifier &>(*args[0]).name;
|
||||||
String sampling_column_name = arg_offset == 0 ? "" : args[1]->getColumnName();
|
ASTPtr sampling_expression = arg_offset == 0 ? NULL : args[1];
|
||||||
UInt64 index_granularity = boost::get<UInt64>(dynamic_cast<ASTLiteral &>(*args[arg_offset + 2]).value);
|
UInt64 index_granularity = boost::get<UInt64>(dynamic_cast<ASTLiteral &>(*args[arg_offset + 2]).value);
|
||||||
String sign_column_name = dynamic_cast<ASTIdentifier &>(*args[arg_offset + 3]).name;
|
String sign_column_name = dynamic_cast<ASTIdentifier &>(*args[arg_offset + 3]).name;
|
||||||
ASTFunction & primary_expr_func = dynamic_cast<ASTFunction &>(*args[arg_offset + 1]);
|
ASTFunction & primary_expr_func = dynamic_cast<ASTFunction &>(*args[arg_offset + 1]);
|
||||||
@ -231,7 +231,7 @@ StoragePtr StorageFactory::get(
|
|||||||
|
|
||||||
ASTPtr primary_expr = primary_expr_func.children.at(0);
|
ASTPtr primary_expr = primary_expr_func.children.at(0);
|
||||||
|
|
||||||
return new StorageMergeTree(data_path, table_name, columns, context, primary_expr, date_column_name, sampling_column_name, index_granularity, sign_column_name);
|
return new StorageMergeTree(data_path, table_name, columns, context, primary_expr, date_column_name, sampling_expression, index_granularity, sign_column_name);
|
||||||
}
|
}
|
||||||
else if (name == "SystemNumbers")
|
else if (name == "SystemNumbers")
|
||||||
{
|
{
|
||||||
|
@ -763,13 +763,13 @@ StorageMergeTree::StorageMergeTree(
|
|||||||
const String & path_, const String & name_, NamesAndTypesListPtr columns_,
|
const String & path_, const String & name_, NamesAndTypesListPtr columns_,
|
||||||
Context & context_,
|
Context & context_,
|
||||||
ASTPtr & primary_expr_ast_,
|
ASTPtr & primary_expr_ast_,
|
||||||
const String & date_column_name_, const String & sampling_column_name_,
|
const String & date_column_name_, const ASTPtr & sampling_expression_,
|
||||||
size_t index_granularity_,
|
size_t index_granularity_,
|
||||||
const String & sign_column_,
|
const String & sign_column_,
|
||||||
const StorageMergeTreeSettings & settings_)
|
const StorageMergeTreeSettings & settings_)
|
||||||
: path(path_), name(name_), full_path(path + escapeForFileName(name) + '/'), columns(columns_),
|
: path(path_), name(name_), full_path(path + escapeForFileName(name) + '/'), columns(columns_),
|
||||||
context(context_), primary_expr_ast(primary_expr_ast_->clone()),
|
context(context_), primary_expr_ast(primary_expr_ast_->clone()),
|
||||||
date_column_name(date_column_name_), sampling_column_name(sampling_column_name_),
|
date_column_name(date_column_name_), sampling_expression(sampling_expression_),
|
||||||
index_granularity(index_granularity_),
|
index_granularity(index_granularity_),
|
||||||
sign_column(sign_column_),
|
sign_column(sign_column_),
|
||||||
settings(settings_),
|
settings(settings_),
|
||||||
@ -841,7 +841,7 @@ BlockInputStreams StorageMergeTree::read(
|
|||||||
{
|
{
|
||||||
sample_by_value = true;
|
sample_by_value = true;
|
||||||
sample_column_value_limit = static_cast<UInt64>(size * std::numeric_limits<UInt32>::max());
|
sample_column_value_limit = static_cast<UInt64>(size * std::numeric_limits<UInt32>::max());
|
||||||
if (!key_condition.addCondition(sampling_column_name,
|
if (!key_condition.addCondition(sampling_expression->getColumnName(),
|
||||||
Range::RightBounded(sample_column_value_limit, true)))
|
Range::RightBounded(sample_column_value_limit, true)))
|
||||||
throw Exception("Invalid sampling column in storage parameters", ErrorCodes::ILLEGAL_COLUMN);
|
throw Exception("Invalid sampling column in storage parameters", ErrorCodes::ILLEGAL_COLUMN);
|
||||||
}
|
}
|
||||||
@ -911,7 +911,7 @@ BlockInputStreams StorageMergeTree::read(
|
|||||||
/// Добавим фильтрацию: sampling_column_name <= sample_column_value_limit
|
/// Добавим фильтрацию: sampling_column_name <= sample_column_value_limit
|
||||||
|
|
||||||
ASTPtr filter_function_args = new ASTExpressionList;
|
ASTPtr filter_function_args = new ASTExpressionList;
|
||||||
filter_function_args->children.push_back(new ASTIdentifier(StringRange(), sampling_column_name));
|
filter_function_args->children.push_back(sampling_expression);
|
||||||
filter_function_args->children.push_back(new ASTLiteral(StringRange(), sample_column_value_limit));
|
filter_function_args->children.push_back(new ASTLiteral(StringRange(), sample_column_value_limit));
|
||||||
|
|
||||||
Poco::SharedPtr<ASTFunction> filter_function = new ASTFunction;
|
Poco::SharedPtr<ASTFunction> filter_function = new ASTFunction;
|
||||||
|
Loading…
Reference in New Issue
Block a user