From 60aabafdfaf96cfb348b90688e86b0b418e06c1d Mon Sep 17 00:00:00 2001 From: Sergey Skvortsov Date: Sat, 18 Jun 2022 01:38:50 +0300 Subject: [PATCH] fix: Do not segfault on empty first_bucket & totals --- src/Interpreters/GraceHashJoin.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Interpreters/GraceHashJoin.cpp b/src/Interpreters/GraceHashJoin.cpp index 0544d57fc3e..a096ebf6a19 100644 --- a/src/Interpreters/GraceHashJoin.cpp +++ b/src/Interpreters/GraceHashJoin.cpp @@ -369,8 +369,9 @@ size_t GraceHashJoin::getTotalByteCount() const bool GraceHashJoin::alwaysReturnsEmptySet() const { auto snapshot = buckets.get(); - bool all_buckets_are_empty = std::all_of(snapshot->begin(), snapshot->end(), [](const auto & bucket) { return bucket->empty(); }); - return isInnerOrRight(table_join->kind()) && first_bucket->alwaysReturnsEmptySet() && all_buckets_are_empty; + bool file_buckets_are_empty = std::all_of(snapshot->begin(), snapshot->end(), [](const auto & bucket) { return bucket->empty(); }); + bool first_bucket_is_empty = first_bucket && first_bucket->alwaysReturnsEmptySet(); + return isInnerOrRight(table_join->kind()) && first_bucket_is_empty && file_buckets_are_empty; } std::shared_ptr GraceHashJoin::getNonJoinedBlocks(const Block &, const Block &, UInt64) const