correct fallback for PREFER_PARTIAL_MERGE: HashJoin -> MergeJoin instead of HashJoin -> JoinSwitcher

This commit is contained in:
chertus 2020-02-20 14:26:00 +03:00
parent 3d7959d2e8
commit 56fa3cc1eb
2 changed files with 5 additions and 3 deletions

View File

@ -90,7 +90,7 @@ public:
const SizeLimits & sizeLimits() const { return size_limits; }
VolumePtr getTemporaryVolume() { return tmp_volume; }
bool allowMergeJoin() const;
bool preferMergeJoin() const { return allowMergeJoin() && join_algorithm == JoinAlgorithm::PREFER_PARTIAL_MERGE; }
bool preferMergeJoin() const { return join_algorithm == JoinAlgorithm::PREFER_PARTIAL_MERGE; }
bool forceMergeJoin() const { return join_algorithm == JoinAlgorithm::PARTIAL_MERGE; }
bool forceHashJoin() const { return join_algorithm == JoinAlgorithm::HASH; }

View File

@ -542,9 +542,11 @@ static ExpressionActionsPtr createJoinedBlockActions(const Context & context, co
static std::shared_ptr<IJoin> makeJoin(std::shared_ptr<AnalyzedJoin> analyzed_join, const Block & sample_block)
{
if (analyzed_join->forceHashJoin())
bool allow_merge_join = analyzed_join->allowMergeJoin();
if (analyzed_join->forceHashJoin() || (analyzed_join->preferMergeJoin() && !allow_merge_join))
return std::make_shared<Join>(analyzed_join, sample_block);
else if (analyzed_join->forceMergeJoin() || analyzed_join->preferMergeJoin())
else if (analyzed_join->forceMergeJoin() || (analyzed_join->preferMergeJoin() && allow_merge_join))
return std::make_shared<MergeJoin>(analyzed_join, sample_block);
return std::make_shared<JoinSwitcher>(analyzed_join, sample_block);
}