This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push: new 9737652231 [Bug](decimalv3) fix decimalv3 keyrange set wrong number #22818 9737652231 is described below commit 9737652231002fa6ea8ba7a7ec5a3138c4091309 Author: Pxl <pxl...@qq.com> AuthorDate: Thu Aug 10 18:15:40 2023 +0800 [Bug](decimalv3) fix decimalv3 keyrange set wrong number #22818 --- be/src/exec/olap_common.h | 4 +-- be/src/runtime/primitive_type.h | 16 ++++++++++ be/src/vec/core/types.h | 9 ++++++ be/src/vec/exec/jni_connector.h | 2 +- be/src/vec/exec/scan/vscan_node.cpp | 6 ++-- .../test_decimalv3_key/test_decimalv3_key.out | 4 +++ .../test_decimalv3_key/test_decimalv3_key.groovy | 37 ++++++++++++++++++++++ 7 files changed, 72 insertions(+), 6 deletions(-) diff --git a/be/src/exec/olap_common.h b/be/src/exec/olap_common.h index 7a58645b74..5bd06d8d54 100644 --- a/be/src/exec/olap_common.h +++ b/be/src/exec/olap_common.h @@ -79,7 +79,7 @@ std::string cast_to_string(T value, int scale) { template <PrimitiveType primitive_type> class ColumnValueRange { public: - using CppType = typename PrimitiveTypeTraits<primitive_type>::CppType; + using CppType = typename VecPrimitiveTypeTraits<primitive_type>::CppType; using IteratorType = typename std::set<CppType>::iterator; ColumnValueRange(); @@ -1094,7 +1094,7 @@ bool ColumnValueRange<primitive_type>::has_intersection(ColumnValueRange<primiti template <PrimitiveType primitive_type> Status OlapScanKeys::extend_scan_key(ColumnValueRange<primitive_type>& range, int32_t max_scan_key_num, bool* exact_value, bool* eos) { - using CppType = typename PrimitiveTypeTraits<primitive_type>::CppType; + using CppType = typename VecPrimitiveTypeTraits<primitive_type>::CppType; using ConstIterator = typename std::set<CppType>::const_iterator; // 1. clear ScanKey if some column range is empty diff --git a/be/src/runtime/primitive_type.h b/be/src/runtime/primitive_type.h index 2caad79546..980e4af954 100644 --- a/be/src/runtime/primitive_type.h +++ b/be/src/runtime/primitive_type.h @@ -288,4 +288,20 @@ struct VecPrimitiveTypeTraits<TYPE_DATETIME> { using ColumnType = vectorized::ColumnVector<vectorized::DateTime>; }; +template <> +struct VecPrimitiveTypeTraits<TYPE_DECIMAL32> { + using CppType = vectorized::Decimal32; + using ColumnType = vectorized::ColumnDecimal<vectorized::Decimal32>; +}; +template <> +struct VecPrimitiveTypeTraits<TYPE_DECIMAL64> { + using CppType = vectorized::Decimal64; + using ColumnType = vectorized::ColumnDecimal<vectorized::Decimal64>; +}; +template <> +struct VecPrimitiveTypeTraits<TYPE_DECIMAL128I> { + using CppType = vectorized::Decimal128I; + using ColumnType = vectorized::ColumnDecimal<vectorized::Decimal128I>; +}; + } // namespace doris diff --git a/be/src/vec/core/types.h b/be/src/vec/core/types.h index eb21a17117..4bec3619d8 100644 --- a/be/src/vec/core/types.h +++ b/be/src/vec/core/types.h @@ -350,6 +350,15 @@ struct Decimal { operator T() const { return value; } + const Decimal<T>& operator++() { + value++; + return *this; + } + const Decimal<T>& operator--() { + value--; + return *this; + } + const Decimal<T>& operator+=(const T& x) { value += x; return *this; diff --git a/be/src/vec/exec/jni_connector.h b/be/src/vec/exec/jni_connector.h index 1cadc37a1b..f7779736c2 100644 --- a/be/src/vec/exec/jni_connector.h +++ b/be/src/vec/exec/jni_connector.h @@ -353,7 +353,7 @@ private: template <PrimitiveType primitive_type> void _parse_value_range(const ColumnValueRange<primitive_type>& col_val_range, const std::string& column_name) { - using CppType = typename PrimitiveTypeTraits<primitive_type>::CppType; + using CppType = typename VecPrimitiveTypeTraits<primitive_type>::CppType; if (col_val_range.is_fixed_value_range()) { ScanPredicate<CppType> in_predicate(column_name); diff --git a/be/src/vec/exec/scan/vscan_node.cpp b/be/src/vec/exec/scan/vscan_node.cpp index 66bfe6386d..d9d191b6ab 100644 --- a/be/src/vec/exec/scan/vscan_node.cpp +++ b/be/src/vec/exec/scan/vscan_node.cpp @@ -1136,7 +1136,7 @@ Status VScanNode::_normalize_match_predicate(VExpr* expr, VExprContext* expr_ctx if (temp_pdt != PushDownType::UNACCEPTABLE) { DCHECK(slot_ref_child >= 0); if (value.data != nullptr) { - using CppType = typename PrimitiveTypeTraits<T>::CppType; + using CppType = typename VecPrimitiveTypeTraits<T>::CppType; if constexpr (T == TYPE_CHAR || T == TYPE_VARCHAR || T == TYPE_STRING || T == TYPE_HLL) { auto val = StringRef(value.data, value.size); @@ -1198,10 +1198,10 @@ Status VScanNode::_change_value_range(ColumnValueRange<PrimitiveType>& temp_rang (PrimitiveType == TYPE_BOOLEAN) || (PrimitiveType == TYPE_DATEV2)) { if constexpr (IsFixed) { func(temp_range, - reinterpret_cast<typename PrimitiveTypeTraits<PrimitiveType>::CppType*>(value)); + reinterpret_cast<typename VecPrimitiveTypeTraits<PrimitiveType>::CppType*>(value)); } else { func(temp_range, to_olap_filter_type(fn_name, slot_ref_child), - reinterpret_cast<typename PrimitiveTypeTraits<PrimitiveType>::CppType*>(value)); + reinterpret_cast<typename VecPrimitiveTypeTraits<PrimitiveType>::CppType*>(value)); } } else { static_assert(always_false_v<PrimitiveType>); diff --git a/regression-test/data/datatype_p0/decimalv3/test_decimalv3_key/test_decimalv3_key.out b/regression-test/data/datatype_p0/decimalv3/test_decimalv3_key/test_decimalv3_key.out new file mode 100644 index 0000000000..2ef8304a2a --- /dev/null +++ b/regression-test/data/datatype_p0/decimalv3/test_decimalv3_key/test_decimalv3_key.out @@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !test -- +1 + diff --git a/regression-test/suites/datatype_p0/decimalv3/test_decimalv3_key/test_decimalv3_key.groovy b/regression-test/suites/datatype_p0/decimalv3/test_decimalv3_key/test_decimalv3_key.groovy new file mode 100644 index 0000000000..1a332190c4 --- /dev/null +++ b/regression-test/suites/datatype_p0/decimalv3/test_decimalv3_key/test_decimalv3_key.groovy @@ -0,0 +1,37 @@ +// 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("test_decimalv3_key") { + + sql "drop table if exists d_table" + + sql """ + create table d_table ( + k1 decimal null, + k2 decimal not null + ) + duplicate key (k1) + distributed BY hash(k1) buckets 3 + properties("replication_num" = "1"); + """ + + sql """ + insert into d_table values(999999999,999999999); + """ + + qt_test "select count(*) from d_table;" +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org