From 8cdc9fffe9017df20eb2bdd9c429d80cc4ee335b Mon Sep 17 00:00:00 2001 From: wangt1xiuyi <13547954130@163.com> Date: Sat, 9 Sep 2023 12:54:03 +0000 Subject: [PATCH] fix calc hybrid hist core caused by div 0 in pquery --- src/share/stat/ob_hybrid_hist_estimator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/share/stat/ob_hybrid_hist_estimator.cpp b/src/share/stat/ob_hybrid_hist_estimator.cpp index 440d3e085e..019f6a9f72 100644 --- a/src/share/stat/ob_hybrid_hist_estimator.cpp +++ b/src/share/stat/ob_hybrid_hist_estimator.cpp @@ -598,7 +598,7 @@ int ObHybridHistograms::build_hybrid_hist(ObIArray &bucket_pairs, dynamic_size = true; // first bucket always contain only one values. following code will handle first value is // popular value or not. - if (bucket_pairs.at(0).is_pop_) { + if (bucket_pairs.at(0).is_pop_ || bucket_num == pop_count + 1) { bucket_size = (total_count - pop_freq) / (bucket_num - pop_count); } else { bucket_size = (total_count - pop_freq - bucket_pairs.at(0).ep_count_) @@ -678,7 +678,7 @@ int ObHybridHistograms::build_hybrid_hist(ObAggregateProcessor::HybridHistExtraR // first bucket always contain only one values. following code will handle first value is // popular value or not. BucketDesc *desc = reinterpret_cast(row->get_extra_payload()); - if (desc->is_pop_) { + if (desc->is_pop_ || bucket_num == pop_count + 1) { bucket_size = (total_count - pop_freq) / (bucket_num - pop_count); } else { bucket_size = (total_count - pop_freq - desc->ep_count_) / (bucket_num - pop_count - 1);