This is an automated email from the ASF dual-hosted git repository.

lihaopeng pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new e01c070f90 [Bug](exec) push down no group by agg min cause error 
result (#20336)
e01c070f90 is described below

commit e01c070f9068e010bce49325651b1791f836f997
Author: HappenLee <happen...@hotmail.com>
AuthorDate: Thu Jun 1 20:46:39 2023 +0800

    [Bug](exec) push down no group by agg min cause error result (#20336)
---
 be/src/olap/rowset/segment_v2/column_reader.cpp    | 18 ++++++++-
 be/src/olap/rowset/segment_v2/column_reader.h      |  3 ++
 .../aggregate/aggregate_not_group_null.out         |  4 ++
 .../aggregate/aggregate_not_group_null.groovy      | 44 ++++++++++++++++++++++
 4 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/be/src/olap/rowset/segment_v2/column_reader.cpp 
b/be/src/olap/rowset/segment_v2/column_reader.cpp
index ecef8cb4dd..b2c2b70974 100644
--- a/be/src/olap/rowset/segment_v2/column_reader.cpp
+++ b/be/src/olap/rowset/segment_v2/column_reader.cpp
@@ -181,7 +181,8 @@ Status ColumnReader::next_batch_of_zone_map(size_t* n, 
vectorized::MutableColumn
     FieldType type = _type_info->type();
     std::unique_ptr<WrapperField> min_value(WrapperField::create_by_type(type, 
_meta.length()));
     std::unique_ptr<WrapperField> max_value(WrapperField::create_by_type(type, 
_meta.length()));
-    _parse_zone_map(_zone_map_index_meta->segment_zone_map(), min_value.get(), 
max_value.get());
+    _parse_zone_map_skip_null(_zone_map_index_meta->segment_zone_map(), 
min_value.get(),
+                              max_value.get());
 
     dst->reserve(*n);
     bool is_string = is_olap_string_type(type);
@@ -246,6 +247,21 @@ void ColumnReader::_parse_zone_map(const ZoneMapPB& 
zone_map, WrapperField* min_
     }
 }
 
+void ColumnReader::_parse_zone_map_skip_null(const ZoneMapPB& zone_map,
+                                             WrapperField* min_value_container,
+                                             WrapperField* 
max_value_container) const {
+    // min value and max value are valid if has_not_null is true
+    if (zone_map.has_not_null()) {
+        min_value_container->from_string(zone_map.min());
+        max_value_container->from_string(zone_map.max());
+    }
+
+    if (!zone_map.has_not_null()) {
+        min_value_container->set_null();
+        max_value_container->set_null();
+    }
+}
+
 bool ColumnReader::_zone_map_match_condition(const ZoneMapPB& zone_map,
                                              WrapperField* min_value_container,
                                              WrapperField* max_value_container,
diff --git a/be/src/olap/rowset/segment_v2/column_reader.h 
b/be/src/olap/rowset/segment_v2/column_reader.h
index 81be872f3d..f59eef221a 100644
--- a/be/src/olap/rowset/segment_v2/column_reader.h
+++ b/be/src/olap/rowset/segment_v2/column_reader.h
@@ -186,6 +186,9 @@ private:
     void _parse_zone_map(const ZoneMapPB& zone_map, WrapperField* 
min_value_container,
                          WrapperField* max_value_container) const;
 
+    void _parse_zone_map_skip_null(const ZoneMapPB& zone_map, WrapperField* 
min_value_container,
+                                   WrapperField* max_value_container) const;
+
     Status _get_filtered_pages(const AndBlockColumnPredicate* col_predicates,
                                std::vector<const ColumnPredicate*>* 
delete_predicates,
                                std::vector<uint32_t>* page_indexes);
diff --git 
a/regression-test/data/query_p0/aggregate/aggregate_not_group_null.out 
b/regression-test/data/query_p0/aggregate/aggregate_not_group_null.out
new file mode 100644
index 0000000000..095c7b2035
--- /dev/null
+++ b/regression-test/data/query_p0/aggregate/aggregate_not_group_null.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+1
+
diff --git 
a/regression-test/suites/query_p0/aggregate/aggregate_not_group_null.groovy 
b/regression-test/suites/query_p0/aggregate/aggregate_not_group_null.groovy
new file mode 100644
index 0000000000..7be16a0f0a
--- /dev/null
+++ b/regression-test/suites/query_p0/aggregate/aggregate_not_group_null.groovy
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+suite("aggregate_no_group_null") {
+    sql "DROP TABLE IF EXISTS t1_int;"
+    sql """
+       CREATE TABLE `t1_int` (
+       `num` int(11) NULL,
+       `dgs_jkrq` bigint(20) NULL
+    ) ENGINE=OLAP
+    DUPLICATE KEY(`num`)
+    COMMENT 'OLAP'
+    DISTRIBUTED BY HASH(`num`) BUCKETS 1
+    PROPERTIES (
+    "replication_allocation" = "tag.location.default: 1",
+    "storage_format" = "V2",
+    "light_schema_change" = "true",
+    "disable_auto_compaction" = "false",
+    "enable_single_replica_compaction" = "false"
+    );
+    """
+    sql """insert into t1_int values(1,1),(1,2),(1,3),(1,4),(1,null);"""
+    qt_sql """
+       select min(dgs_jkrq) from t1_int;
+    """
+
+    sql "DROP TABLE t1_int"
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to