You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/07/08 00:24:25 UTC

[doris] branch dev-1.0.1 updated: [hotfix](dev-1.0.1) Fix bug of VInPredicate on date type (#10687)

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

yiguolei pushed a commit to branch dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/dev-1.0.1 by this push:
     new dd27acc22a [hotfix](dev-1.0.1) Fix bug of VInPredicate on date type (#10687)
dd27acc22a is described below

commit dd27acc22a7a61b175961dceb1d83db9b9143730
Author: Xin Liao <li...@126.com>
AuthorDate: Fri Jul 8 08:24:18 2022 +0800

    [hotfix](dev-1.0.1) Fix bug of VInPredicate on date type (#10687)
---
 be/src/exprs/create_predicate_function.h | 25 +++++++++++++++++++------
 be/src/runtime/primitive_type.h          | 16 ++++++++++++++++
 be/src/vec/functions/in.cpp              |  8 ++++----
 3 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/be/src/exprs/create_predicate_function.h b/be/src/exprs/create_predicate_function.h
index 27aef88c92..bd7c8bc6e0 100644
--- a/be/src/exprs/create_predicate_function.h
+++ b/be/src/exprs/create_predicate_function.h
@@ -33,15 +33,23 @@ public:
     };
 };
 
+template <bool is_vec>
 class HybridSetTraits {
 public:
     using BasePtr = HybridSetBase*;
     template <PrimitiveType type>
     static BasePtr get_function([[maybe_unused]] MemTracker* tracker) {
-        using CppType = typename PrimitiveTypeTraits<type>::CppType;
-        using Set = std::conditional_t<std::is_same_v<CppType, StringValue>, StringValueSet,
-                                       HybridSet<CppType>>;
-        return new (std::nothrow) Set();
+        if constexpr (is_vec) {
+            using CppType = typename VecPrimitiveTypeTraits<type>::CppType;
+            using Set = std::conditional_t<std::is_same_v<CppType, StringValue>, StringValueSet,
+                                           HybridSet<CppType>>;
+            return new (std::nothrow) Set();
+        } else {
+            using CppType = typename PrimitiveTypeTraits<type>::CppType;
+            using Set = std::conditional_t<std::is_same_v<CppType, StringValue>, StringValueSet,
+                                           HybridSet<CppType>>;
+            return new (std::nothrow) Set();
+        }
     };
 };
 
@@ -114,11 +122,16 @@ inline auto create_minmax_filter(PrimitiveType type) {
 }
 
 inline auto create_set(PrimitiveType type) {
-    return create_predicate_function<HybridSetTraits>(type);
+    return create_predicate_function<HybridSetTraits<false>>(type);
+}
+
+// used for VInPredicate
+inline auto vec_create_set(PrimitiveType type) {
+    return create_predicate_function<HybridSetTraits<true>>(type);
 }
 
 inline auto create_bloom_filter(MemTracker* tracker, PrimitiveType type) {
     return create_predicate_function<BloomFilterTraits>(type, tracker);
 }
 
-} // namespace doris
\ No newline at end of file
+} // namespace doris
diff --git a/be/src/runtime/primitive_type.h b/be/src/runtime/primitive_type.h
index 03d13b2069..7b4789b0b4 100644
--- a/be/src/runtime/primitive_type.h
+++ b/be/src/runtime/primitive_type.h
@@ -372,6 +372,22 @@ struct PredicatePrimitiveTypeTraits<TYPE_DATETIME> {
     using PredicateFieldType = uint64_t;
 };
 
+// used for VInPredicate. VInPredicate should use vectorized data type
+template <PrimitiveType type>
+struct VecPrimitiveTypeTraits {
+    using CppType = typename PrimitiveTypeTraits<type>::CppType;
+};
+
+template <>
+struct VecPrimitiveTypeTraits<TYPE_DATE> {
+    using CppType = vectorized::VecDateTimeValue;
+};
+
+template <>
+struct VecPrimitiveTypeTraits<TYPE_DATETIME> {
+    using CppType = vectorized::VecDateTimeValue;
+};
+
 } // namespace doris
 
 #endif
diff --git a/be/src/vec/functions/in.cpp b/be/src/vec/functions/in.cpp
index 65232c442e..216165b826 100644
--- a/be/src/vec/functions/in.cpp
+++ b/be/src/vec/functions/in.cpp
@@ -67,8 +67,8 @@ public:
         }
         auto* state = new InState();
         context->set_function_state(scope, state);
-        state->hybrid_set.reset(create_set(convert_type_to_primitive(
-                context->get_arg_type(0)->type)));
+        state->hybrid_set.reset(
+                vec_create_set(convert_type_to_primitive(context->get_arg_type(0)->type)));
 
         DCHECK(context->get_num_args() > 1);
         for (int i = 1; i < context->get_num_args(); ++i) {
@@ -135,8 +135,8 @@ public:
                     continue;
                 }
 
-                std::unique_ptr<HybridSetBase> hybrid_set(create_set(convert_type_to_primitive(
-                context->get_arg_type(0)->type)));
+                std::unique_ptr<HybridSetBase> hybrid_set(
+                        vec_create_set(convert_type_to_primitive(context->get_arg_type(0)->type)));
                 bool null_in_set = false;
 
                 for (const auto& set_column : set_columns) {


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