You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@doris.apache.org by GitBox <gi...@apache.org> on 2018/11/26 05:36:24 UTC

[GitHub] imay closed pull request #344: Fix wrong query result when column value is Null

imay closed pull request #344: Fix wrong query result when column value is Null
URL: https://github.com/apache/incubator-doris/pull/344
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/be/src/exec/olap_common.h b/be/src/exec/olap_common.h
index 3fc3d475..a0d0bb35 100644
--- a/be/src/exec/olap_common.h
+++ b/be/src/exec/olap_common.h
@@ -94,6 +94,10 @@ class ColumnValueRange {
         return _low_value == _type_min;
     }
 
+    bool is_high_value_maximum() const {
+        return _high_value == _type_max;
+    }
+
     bool is_begin_include() const {
         return _low_op == FILTER_LARGER_OR_EQUAL;
     }
@@ -662,6 +666,10 @@ Status OlapScanKeys::extend_scan_key(ColumnValueRange<T>& range) {
         return Status::OK;
     }
 
+    //if a column doesn't have any predicate, we will try converting the range to fixed values
+    //for this case, we need to add null value to fixed values
+    bool has_converted = false;
+
     if (range.is_fixed_value_range()) {
         if ((_begin_scan_keys.empty() && range.get_fixed_value_size() > config::doris_max_scan_key_num)
                 || range.get_fixed_value_size() * _begin_scan_keys.size() > config::doris_max_scan_key_num) {
@@ -675,11 +683,19 @@ Status OlapScanKeys::extend_scan_key(ColumnValueRange<T>& range) {
         if (range.is_fixed_value_convertible() && _is_convertible) {
             if (_begin_scan_keys.empty()) {
                 if (range.get_convertible_fixed_value_size() < config::doris_max_scan_key_num) {
+                    if (range.is_low_value_mininum() && range.is_high_value_maximum()) {
+                        has_converted = true;
+                    }
+
                     range.convert_to_fixed_value();
                 }
             } else {
                 if (range.get_convertible_fixed_value_size() * _begin_scan_keys.size()
                         < config::doris_max_scan_key_num) {
+                    if (range.is_low_value_mininum() && range.is_high_value_maximum()) {
+                        has_converted = true;
+                    }
+
                     range.convert_to_fixed_value();
                 }
             }
@@ -699,6 +715,13 @@ Status OlapScanKeys::extend_scan_key(ColumnValueRange<T>& range) {
                 _end_scan_keys.emplace_back();
                 _end_scan_keys.back().add_value(cast_to_string(*iter));
             }
+
+            if (has_converted) {
+                 _begin_scan_keys.emplace_back();
+                 _begin_scan_keys.back().add_null();
+                 _end_scan_keys.emplace_back();
+                 _end_scan_keys.back().add_null();
+            }
         } // 3.1.2 produces the Cartesian product of ScanKey and fixed_value
         else {
             const set<T>& fixed_value_set = range.get_fixed_value_set();
@@ -723,6 +746,13 @@ Status OlapScanKeys::extend_scan_key(ColumnValueRange<T>& range) {
                         _end_scan_keys.back().add_value(cast_to_string(*iter));
                     }
                 }
+
+                if (has_converted) {
+                    _begin_scan_keys.push_back(start_base_key_range);
+                    _begin_scan_keys.back().add_null();
+                    _end_scan_keys.push_back(end_base_key_range);
+                    _end_scan_keys.back().add_null();
+                }
             }
         }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@doris.apache.org
For additional commands, e-mail: dev-help@doris.apache.org