mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-06 07:32:27 +00:00
Better check
This commit is contained in:
parent
5606e248a7
commit
1ffaf1d793
@ -599,22 +599,30 @@ bool KeyCondition::canConstantBeWrappedByMonotonicFunctions(
|
||||
Field & out_value,
|
||||
DataTypePtr & out_type)
|
||||
{
|
||||
auto adjusted_node = node->clone();
|
||||
KeyDescription::moduloToModuloLegacyRecursive(adjusted_node);
|
||||
const auto & sample_block = key_expr->getSampleBlock();
|
||||
|
||||
String adjusted_expr_name = adjusted_node->getColumnName();
|
||||
// Constant expr should use alias names if any
|
||||
String passed_expr_name = node->getColumnName();
|
||||
String expr_name;
|
||||
|
||||
const auto & sample_block = key_expr->getSampleBlock();
|
||||
/// sample_block from key_expr cannot contain modulo and moduloLegacy at the same time.
|
||||
/// For partition key it is always moduloLegacy.
|
||||
if (sample_block.has(passed_expr_name))
|
||||
{
|
||||
expr_name = passed_expr_name;
|
||||
else if (sample_block.has(adjusted_expr_name))
|
||||
expr_name = adjusted_expr_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto adjusted_ast = node->clone();
|
||||
KeyDescription::moduloToModuloLegacyRecursive(adjusted_ast);
|
||||
String adjusted_expr_name = adjusted_ast->getColumnName();
|
||||
|
||||
if (!sample_block.has(adjusted_expr_name))
|
||||
return false;
|
||||
|
||||
expr_name = adjusted_expr_name;
|
||||
}
|
||||
|
||||
/// TODO Nullable index is not yet landed.
|
||||
if (out_value.isNull())
|
||||
return false;
|
||||
@ -677,22 +685,30 @@ bool KeyCondition::canConstantBeWrappedByMonotonicFunctions(
|
||||
bool KeyCondition::canConstantBeWrappedByFunctions(
|
||||
const ASTPtr & ast, size_t & out_key_column_num, DataTypePtr & out_key_column_type, Field & out_value, DataTypePtr & out_type)
|
||||
{
|
||||
auto adjusted_ast = ast->clone();
|
||||
KeyDescription::moduloToModuloLegacyRecursive(adjusted_ast);
|
||||
const auto & sample_block = key_expr->getSampleBlock();
|
||||
|
||||
String adjusted_expr_name = adjusted_ast->getColumnName();
|
||||
// Constant expr should use alias names if any
|
||||
String passed_expr_name = ast->getColumnName();
|
||||
String expr_name;
|
||||
|
||||
const auto & sample_block = key_expr->getSampleBlock();
|
||||
/// sample_block from key_expr cannot contain modulo and moduloLegacy at the same time.
|
||||
/// For partition key it is always moduloLegacy.
|
||||
if (sample_block.has(passed_expr_name))
|
||||
{
|
||||
expr_name = passed_expr_name;
|
||||
else if (sample_block.has(adjusted_expr_name))
|
||||
expr_name = adjusted_expr_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto adjusted_ast = ast->clone();
|
||||
KeyDescription::moduloToModuloLegacyRecursive(adjusted_ast);
|
||||
String adjusted_expr_name = adjusted_ast->getColumnName();
|
||||
|
||||
if (!sample_block.has(adjusted_expr_name))
|
||||
return false;
|
||||
|
||||
expr_name = adjusted_expr_name;
|
||||
}
|
||||
|
||||
/// TODO Nullable index is not yet landed.
|
||||
if (out_value.isNull())
|
||||
return false;
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
static Block executePartitionByExpression(const StorageMetadataPtr & metadata_snapshot, Block & block, ContextPtr context);
|
||||
|
||||
/// Make a modified partition key with substitution from modulo to moduloLegacy. Used in paritionPruner.
|
||||
static KeyDescription adjustPartitionKey(const StorageMetadataPtr & partition_key, ContextPtr context);
|
||||
static KeyDescription adjustPartitionKey(const StorageMetadataPtr & metadata_snapshot, ContextPtr context);
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user