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,21 +599,29 @@ bool KeyCondition::canConstantBeWrappedByMonotonicFunctions(
|
|||||||
Field & out_value,
|
Field & out_value,
|
||||||
DataTypePtr & out_type)
|
DataTypePtr & out_type)
|
||||||
{
|
{
|
||||||
auto adjusted_node = node->clone();
|
const auto & sample_block = key_expr->getSampleBlock();
|
||||||
KeyDescription::moduloToModuloLegacyRecursive(adjusted_node);
|
|
||||||
|
|
||||||
String adjusted_expr_name = adjusted_node->getColumnName();
|
|
||||||
// Constant expr should use alias names if any
|
// Constant expr should use alias names if any
|
||||||
String passed_expr_name = node->getColumnName();
|
String passed_expr_name = node->getColumnName();
|
||||||
String expr_name;
|
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))
|
if (sample_block.has(passed_expr_name))
|
||||||
|
{
|
||||||
expr_name = passed_expr_name;
|
expr_name = passed_expr_name;
|
||||||
else if (sample_block.has(adjusted_expr_name))
|
}
|
||||||
expr_name = adjusted_expr_name;
|
|
||||||
else
|
else
|
||||||
return false;
|
{
|
||||||
|
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.
|
/// TODO Nullable index is not yet landed.
|
||||||
if (out_value.isNull())
|
if (out_value.isNull())
|
||||||
@ -677,21 +685,29 @@ bool KeyCondition::canConstantBeWrappedByMonotonicFunctions(
|
|||||||
bool KeyCondition::canConstantBeWrappedByFunctions(
|
bool KeyCondition::canConstantBeWrappedByFunctions(
|
||||||
const ASTPtr & ast, size_t & out_key_column_num, DataTypePtr & out_key_column_type, Field & out_value, DataTypePtr & out_type)
|
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();
|
const auto & sample_block = key_expr->getSampleBlock();
|
||||||
KeyDescription::moduloToModuloLegacyRecursive(adjusted_ast);
|
|
||||||
|
|
||||||
String adjusted_expr_name = adjusted_ast->getColumnName();
|
|
||||||
// Constant expr should use alias names if any
|
// Constant expr should use alias names if any
|
||||||
String passed_expr_name = ast->getColumnName();
|
String passed_expr_name = ast->getColumnName();
|
||||||
String expr_name;
|
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))
|
if (sample_block.has(passed_expr_name))
|
||||||
|
{
|
||||||
expr_name = passed_expr_name;
|
expr_name = passed_expr_name;
|
||||||
else if (sample_block.has(adjusted_expr_name))
|
}
|
||||||
expr_name = adjusted_expr_name;
|
|
||||||
else
|
else
|
||||||
return false;
|
{
|
||||||
|
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.
|
/// TODO Nullable index is not yet landed.
|
||||||
if (out_value.isNull())
|
if (out_value.isNull())
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
static Block executePartitionByExpression(const StorageMetadataPtr & metadata_snapshot, Block & block, ContextPtr context);
|
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.
|
/// 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