Removed strange code from MergeTreeIndexSet

This commit is contained in:
Alexey Milovidov 2020-02-25 15:12:16 +03:00
parent 749c41a545
commit 4e935c684a
3 changed files with 11 additions and 7 deletions

View File

@ -21,7 +21,7 @@ namespace DB
static inline ResultType NO_SANITIZE_UNDEFINED apply(A a)
{
if constexpr (!is_integral_v<A>)
throw DB::Exception("It's a bug! Only integer types are supported by __bitWrapperFunc.", ErrorCodes::BAD_CAST);
throw DB::Exception("It's a bug! Only integer types are supported by __bitWrapperFunc.", ErrorCodes::LOGICAL_ERROR);
return a == 0 ? static_cast<ResultType>(0b10) : static_cast<ResultType >(0b1);
}

View File

@ -18,7 +18,7 @@ namespace ErrorCodes
}
/// 0b11 -- can be true and false at the same time
const Field UNKNOWN_FIELD(3u);
static const Field UNKNOWN_FIELD(3u);
MergeTreeIndexGranuleSet::MergeTreeIndexGranuleSet(const MergeTreeIndexSet & index_)
@ -236,8 +236,6 @@ MergeTreeIndexConditionSet::MergeTreeIndexConditionSet(
expression_ast = select.where()->clone();
else if (select.prewhere())
expression_ast = select.prewhere()->clone();
else
expression_ast = std::make_shared<ASTLiteral>(UNKNOWN_FIELD);
useless = checkASTUseless(expression_ast);
/// Do not proceed if index is useless for this query.
@ -260,6 +258,9 @@ bool MergeTreeIndexConditionSet::alwaysUnknownOrTrue() const
bool MergeTreeIndexConditionSet::mayBeTrueOnGranule(MergeTreeIndexGranulePtr idx_granule) const
{
if (useless)
return true;
auto granule = std::dynamic_pointer_cast<MergeTreeIndexGranuleSet>(idx_granule);
if (!granule)
throw Exception(
@ -405,8 +406,11 @@ bool MergeTreeIndexConditionSet::operatorFromAST(ASTPtr & node) const
return true;
}
bool MergeTreeIndexConditionSet::checkASTUseless(const ASTPtr &node, bool atomic) const
bool MergeTreeIndexConditionSet::checkASTUseless(const ASTPtr & node, bool atomic) const
{
if (!node)
return true;
if (const auto * func = node->as<ASTFunction>())
{
if (key_columns.count(func->getColumnName()))
@ -422,7 +426,7 @@ bool MergeTreeIndexConditionSet::checkASTUseless(const ASTPtr &node, bool atomic
return checkASTUseless(args[0], atomic);
else
return std::any_of(args.begin(), args.end(),
[this](const auto & arg) { return checkASTUseless(arg, true); });
[this](const auto & arg) { return checkASTUseless(arg, true); });
}
else if (const auto * literal = node->as<ASTLiteral>())
return !atomic && literal->value.get<bool>();

View File

@ -80,7 +80,7 @@ private:
bool atomFromAST(ASTPtr & node) const;
bool operatorFromAST(ASTPtr & node) const;
bool checkASTUseless(const ASTPtr &node, bool atomic = false) const;
bool checkASTUseless(const ASTPtr & node, bool atomic = false) const;
const MergeTreeIndexSet & index;