mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Fixed error [#CLICKHOUSE-2]
This commit is contained in:
parent
e3e7c8c256
commit
02c67e2b13
@ -2194,7 +2194,7 @@ MergeTreeData::DataPartsVector MergeTreeData::Transaction::commit()
|
||||
return total_covered_parts;
|
||||
}
|
||||
|
||||
bool MergeTreeData::isPrimaryKeyColumn(const ASTPtr &node) const
|
||||
bool MergeTreeData::isPrimaryKeyColumnPossiblyWrappedInFunctions(const ASTPtr & node) const
|
||||
{
|
||||
String column_name = node->getColumnName();
|
||||
|
||||
@ -2202,6 +2202,10 @@ bool MergeTreeData::isPrimaryKeyColumn(const ASTPtr &node) const
|
||||
if (column_name == column.column_name)
|
||||
return true;
|
||||
|
||||
if (const ASTFunction * func = typeid_cast<const ASTFunction *>(node.get()))
|
||||
if (func->arguments->children.size() == 1)
|
||||
return isPrimaryKeyColumnPossiblyWrappedInFunctions(func->arguments->children.front());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2213,16 +2217,16 @@ bool MergeTreeData::mayBenefitFromIndexForIn(const ASTPtr & left_in_operand) con
|
||||
if (left_in_operand_tuple && left_in_operand_tuple->name == "tuple")
|
||||
{
|
||||
for (const auto & item : left_in_operand_tuple->arguments->children)
|
||||
if (!isPrimaryKeyColumn(item))
|
||||
if (!isPrimaryKeyColumnPossiblyWrappedInFunctions(item))
|
||||
/// The tuple itself may be part of the primary key, so check that as a last resort.
|
||||
return isPrimaryKeyColumn(left_in_operand);
|
||||
return isPrimaryKeyColumnPossiblyWrappedInFunctions(left_in_operand);
|
||||
|
||||
/// tuple() is invalid but can still be found here since this method may be called before the arguments are validated.
|
||||
return !left_in_operand_tuple->arguments->children.empty();
|
||||
}
|
||||
else
|
||||
{
|
||||
return isPrimaryKeyColumn(left_in_operand);
|
||||
return isPrimaryKeyColumnPossiblyWrappedInFunctions(left_in_operand);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -675,8 +675,8 @@ private:
|
||||
DataPartPtr & out_covering_part,
|
||||
std::lock_guard<std::mutex> & data_parts_lock) const;
|
||||
|
||||
/// Checks whether the column is in the primary key.
|
||||
bool isPrimaryKeyColumn(const ASTPtr &node) const;
|
||||
/// Checks whether the column is in the primary key, possibly wrapped in a chain of functions with single argument.
|
||||
bool isPrimaryKeyColumnPossiblyWrappedInFunctions(const ASTPtr &node) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user