You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by pa...@apache.org on 2023/07/18 04:53:17 UTC

[doris] branch master updated: [Bug](decimalv3) fix failed on test_dup_tab_decimalv3 due to wrong precision (#21890)

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

panxiaolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 19492b06c1 [Bug](decimalv3) fix failed on test_dup_tab_decimalv3 due to wrong precision (#21890)
19492b06c1 is described below

commit 19492b06c10fb18b5a31455f2cfd325daa7034bd
Author: Pxl <px...@qq.com>
AuthorDate: Tue Jul 18 12:53:09 2023 +0800

    [Bug](decimalv3) fix failed on test_dup_tab_decimalv3 due to wrong precision (#21890)
    
     fix failed on test_dup_tab_decimalv3 due to wrong precision
---
 be/src/vec/exec/scan/vscan_node.cpp                | 38 ++++++++++++++++------
 .../rules/SimplifyComparisonPredicate.java         | 12 +++----
 .../decimalv3/test_dup_tab_decimalv3.out           | 10 ++++++
 .../decimalv3/test_dup_tab_decimalv3.groovy        |  3 ++
 4 files changed, 45 insertions(+), 18 deletions(-)

diff --git a/be/src/vec/exec/scan/vscan_node.cpp b/be/src/vec/exec/scan/vscan_node.cpp
index 7384225971..4c0dd28b4e 100644
--- a/be/src/vec/exec/scan/vscan_node.cpp
+++ b/be/src/vec/exec/scan/vscan_node.cpp
@@ -65,9 +65,12 @@
 
 namespace doris::vectorized {
 
-#define RETURN_IF_PUSH_DOWN(stmt)            \
+#define RETURN_IF_PUSH_DOWN(stmt, status)    \
     if (pdt == PushDownType::UNACCEPTABLE) { \
-        stmt;                                \
+        status = stmt;                       \
+        if (!status.ok()) {                  \
+            return;                          \
+        }                                    \
     } else {                                 \
         return;                              \
     }
@@ -472,6 +475,7 @@ Status VScanNode::_normalize_predicate(const VExprSPtr& conjunct_expr_root, VExp
             }
             if (_is_predicate_acting_on_slot(cur_expr, in_predicate_checker, &slot, &range) ||
                 _is_predicate_acting_on_slot(cur_expr, eq_predicate_checker, &slot, &range)) {
+                Status status = Status::OK();
                 std::visit(
                         [&](auto& value_range) {
                             Defer mark_runtime_filter_flag {[&]() {
@@ -479,27 +483,36 @@ Status VScanNode::_normalize_predicate(const VExprSPtr& conjunct_expr_root, VExp
                                         _is_runtime_filter_predicate);
                             }};
                             RETURN_IF_PUSH_DOWN(_normalize_in_and_eq_predicate(
-                                    cur_expr, context, slot, value_range, &pdt));
+                                                        cur_expr, context, slot, value_range, &pdt),
+                                                status);
                             RETURN_IF_PUSH_DOWN(_normalize_not_in_and_not_eq_predicate(
-                                    cur_expr, context, slot, value_range, &pdt));
+                                                        cur_expr, context, slot, value_range, &pdt),
+                                                status);
                             RETURN_IF_PUSH_DOWN(_normalize_is_null_predicate(
-                                    cur_expr, context, slot, value_range, &pdt));
+                                                        cur_expr, context, slot, value_range, &pdt),
+                                                status);
                             RETURN_IF_PUSH_DOWN(_normalize_noneq_binary_predicate(
-                                    cur_expr, context, slot, value_range, &pdt));
+                                                        cur_expr, context, slot, value_range, &pdt),
+                                                status);
                             RETURN_IF_PUSH_DOWN(_normalize_match_predicate(cur_expr, context, slot,
-                                                                           value_range, &pdt));
+                                                                           value_range, &pdt),
+                                                status);
                             if (_is_key_column(slot->col_name())) {
                                 RETURN_IF_PUSH_DOWN(
-                                        _normalize_bitmap_filter(cur_expr, context, slot, &pdt));
+                                        _normalize_bitmap_filter(cur_expr, context, slot, &pdt),
+                                        status);
                                 RETURN_IF_PUSH_DOWN(
-                                        _normalize_bloom_filter(cur_expr, context, slot, &pdt));
+                                        _normalize_bloom_filter(cur_expr, context, slot, &pdt),
+                                        status);
                                 if (_state->enable_function_pushdown()) {
                                     RETURN_IF_PUSH_DOWN(_normalize_function_filters(
-                                            cur_expr, context, slot, &pdt));
+                                                                cur_expr, context, slot, &pdt),
+                                                        status);
                                 }
                             }
                         },
                         *range);
+                RETURN_IF_ERROR(status);
             }
 
             if (pdt == PushDownType::UNACCEPTABLE &&
@@ -772,6 +785,11 @@ Status VScanNode::_normalize_in_and_eq_predicate(VExpr* expr, VExprContext* expr
                         temp_range, reinterpret_cast<void*>(&val),
                         ColumnValueRange<T>::add_fixed_value_range, fn_name));
             } else {
+                if (sizeof(typename PrimitiveTypeTraits<T>::CppType) != value.size) {
+                    return Status::InternalError(
+                            "PrimitiveType {} meet invalid input value size {}, expect size {}", T,
+                            value.size, sizeof(typename PrimitiveTypeTraits<T>::CppType));
+                }
                 RETURN_IF_ERROR(_change_value_range<true>(
                         temp_range, reinterpret_cast<void*>(const_cast<char*>(value.data)),
                         ColumnValueRange<T>::add_fixed_value_range, fn_name));
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicate.java
index 2c9976c2cb..cdc4d80a8a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicate.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicate.java
@@ -46,8 +46,6 @@ import org.apache.doris.nereids.types.DateV2Type;
 import org.apache.doris.nereids.types.DecimalV3Type;
 import org.apache.doris.nereids.types.coercion.DateLikeType;
 
-import java.math.BigDecimal;
-
 /**
  * simplify comparison
  * such as: cast(c1 as DateV2) >= DateV2Literal --> c1 >= DateLiteral
@@ -214,9 +212,8 @@ public class SimplifyComparisonPredicate extends AbstractExpressionRewriteRule {
                 int toScale = ((DecimalV3Type) left.getDataType()).getScale();
                 if (comparisonPredicate instanceof EqualTo) {
                     try {
-                        BigDecimal newValue = literal.getValue().setScale(toScale);
-                        return comparisonPredicate.withChildren(left,
-                                new DecimalV3Literal(newValue));
+                        return comparisonPredicate.withChildren(left, new DecimalV3Literal(
+                                (DecimalV3Type) left.getDataType(), literal.getValue().setScale(toScale)));
                     } catch (ArithmeticException e) {
                         if (left.nullable()) {
                             // TODO: the ideal way is to return an If expr like:
@@ -232,9 +229,8 @@ public class SimplifyComparisonPredicate extends AbstractExpressionRewriteRule {
                     }
                 } else if (comparisonPredicate instanceof NullSafeEqual) {
                     try {
-                        BigDecimal newValue = literal.getValue().setScale(toScale);
-                        return comparisonPredicate.withChildren(left,
-                                new DecimalV3Literal(newValue));
+                        return comparisonPredicate.withChildren(left, new DecimalV3Literal(
+                                (DecimalV3Type) left.getDataType(), literal.getValue().setScale(toScale)));
                     } catch (ArithmeticException e) {
                         return BooleanLiteral.of(false);
                     }
diff --git a/regression-test/data/datatype_p0/decimalv3/test_dup_tab_decimalv3.out b/regression-test/data/datatype_p0/decimalv3/test_dup_tab_decimalv3.out
index 119ce2a68c..703f532892 100644
--- a/regression-test/data/datatype_p0/decimalv3/test_dup_tab_decimalv3.out
+++ b/regression-test/data/datatype_p0/decimalv3/test_dup_tab_decimalv3.out
@@ -211,3 +211,13 @@
 2.10000	1.20000	1.30000	1.40000	1.50000	1.60000
 2.10000	1.20000	1.30000	1.40000	1.50000	1.60000
 
+-- !select_in_pred_decimal64_key2 --
+1.10000	1.20000	1.30000	1.40000	1.50000	1.60000
+1.10000	1.20000	1.30000	1.40000	1.50000	1.60000
+1.10000	1.20000	1.30000	1.40000	1.50000	1.60000
+1.10000	1.20000	1.30000	1.40000	1.50000	1.60000
+1.10000	1.20000	1.30000	1.40000	1.50000	1.60000
+2.10000	1.20000	1.30000	1.40000	1.50000	1.60000
+2.10000	1.20000	1.30000	1.40000	1.50000	1.60000
+2.10000	1.20000	1.30000	1.40000	1.50000	1.60000
+
diff --git a/regression-test/suites/datatype_p0/decimalv3/test_dup_tab_decimalv3.groovy b/regression-test/suites/datatype_p0/decimalv3/test_dup_tab_decimalv3.groovy
index 62100b8b79..aab144bff6 100644
--- a/regression-test/suites/datatype_p0/decimalv3/test_dup_tab_decimalv3.groovy
+++ b/regression-test/suites/datatype_p0/decimalv3/test_dup_tab_decimalv3.groovy
@@ -86,5 +86,8 @@ suite("test_dup_tab_decimalv3") {
     qt_select_in_pred_decimal128_key2 "select * from ${table1} where decimal128_key in(1.30000000000) order by decimal32_key"
     qt_select_in_pred_decimal128_key3 "select * from ${table1} where decimal128_key in(1.3, 1.4) order by decimal32_key"
 
+    sql "set enable_nereids_planner=true;"
+    qt_select_in_pred_decimal64_key2 "select * from ${table1} where decimal64_key in(1.20000000000) order by decimal32_key"
+
     sql "drop table if exists ${table1}"
 }


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