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

airborne 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 b42a06c135b [improve](array-funcs)support arrays_overlap with 
invertedIndex (#41161)
b42a06c135b is described below

commit b42a06c135b20677f1785ea7f16b85a1eb729de3
Author: amory <wangqian...@selectdb.com>
AuthorDate: Wed Sep 25 10:06:01 2024 +0800

    [improve](array-funcs)support arrays_overlap with invertedIndex (#41161)
    
    support arrays_overlap with invertedIndex
    
    ## Proposed changes
    
    Issue Number: close #xxx
    
    <!--Describe your changes.-->
---
 .../vec/functions/array/function_arrays_overlap.h  |  82 +++++
 .../test_array_contains_with_inverted_index.out    | 359 +++++++++++++++++++++
 .../test_array_contains_with_inverted_index.groovy |  39 ++-
 3 files changed, 471 insertions(+), 9 deletions(-)

diff --git a/be/src/vec/functions/array/function_arrays_overlap.h 
b/be/src/vec/functions/array/function_arrays_overlap.h
index 74872b6cd55..c06af8b05bd 100644
--- a/be/src/vec/functions/array/function_arrays_overlap.h
+++ b/be/src/vec/functions/array/function_arrays_overlap.h
@@ -45,6 +45,7 @@
 #include "vec/data_types/data_type_number.h"
 #include "vec/functions/array/function_array_utils.h"
 #include "vec/functions/function.h"
+#include "vec/functions/function_helpers.h"
 
 namespace doris {
 class FunctionContext;
@@ -128,6 +129,87 @@ public:
         return make_nullable(std::make_shared<DataTypeUInt8>());
     }
 
+    /**
+     * eval inverted index. we can filter array rows with inverted index iter
+     * array_overlap(array, []) -> array_overlap(array, const value)
+     */
+    Status evaluate_inverted_index(
+            const ColumnsWithTypeAndName& arguments,
+            const std::vector<vectorized::IndexFieldNameAndTypePair>& 
data_type_with_names,
+            std::vector<segment_v2::InvertedIndexIterator*> iterators, 
uint32_t num_rows,
+            segment_v2::InvertedIndexResultBitmap& bitmap_result) const 
override {
+        DCHECK(arguments.size() == 1);
+        DCHECK(data_type_with_names.size() == 1);
+        DCHECK(iterators.size() == 1);
+        auto* iter = iterators[0];
+        if (iter == nullptr) {
+            return Status::OK();
+        }
+        auto data_type_with_name = data_type_with_names[0];
+        if (iter->get_inverted_index_reader_type() ==
+            segment_v2::InvertedIndexReaderType::FULLTEXT) {
+            return Status::Error<ErrorCode::INVERTED_INDEX_EVALUATE_SKIPPED>(
+                    "Inverted index evaluate skipped, FULLTEXT reader can not 
support "
+                    "array_overlap");
+        }
+        // in arrays_overlap param is array Field and const Field
+        ColumnPtr arg_column = arguments[0].column;
+        DataTypePtr arg_type = arguments[0].type;
+        if ((is_column_nullable(*arg_column) && 
!is_column_const(*remove_nullable(arg_column))) ||
+            !is_column_const(*arg_column)) {
+            // if not we should skip inverted index and evaluate in expression
+            return Status::Error<ErrorCode::INVERTED_INDEX_EVALUATE_SKIPPED>(
+                    "Inverted index evaluate skipped, array_overlap only 
support const value");
+        }
+
+        Field param_value;
+        arguments[0].column->get(0, param_value);
+        DCHECK(is_array(remove_nullable(arguments[0].type)));
+        auto nested_param_type =
+                
check_and_get_data_type<DataTypeArray>(remove_nullable(arguments[0].type).get())
+                        ->get_nested_type()
+                        ->get_type_as_type_descriptor()
+                        .type;
+        // The current implementation for the inverted index of arrays cannot 
handle cases where the array contains null values,
+        // meaning an item in the array is null.
+        if (param_value.is_null()) {
+            return Status::OK();
+        }
+        std::shared_ptr<roaring::Roaring> roaring = 
std::make_shared<roaring::Roaring>();
+        std::shared_ptr<roaring::Roaring> null_bitmap = 
std::make_shared<roaring::Roaring>();
+        if (iter->has_null()) {
+            segment_v2::InvertedIndexQueryCacheHandle null_bitmap_cache_handle;
+            RETURN_IF_ERROR(iter->read_null_bitmap(&null_bitmap_cache_handle));
+            null_bitmap = null_bitmap_cache_handle.get_bitmap();
+        }
+        std::unique_ptr<InvertedIndexQueryParamFactory> query_param = nullptr;
+        const Array& query_val = param_value.get<Array>();
+        for (size_t i = 0; i < query_val.size(); ++i) {
+            Field nested_query_val = query_val[i];
+            std::shared_ptr<roaring::Roaring> single_res = 
std::make_shared<roaring::Roaring>();
+            RETURN_IF_ERROR(InvertedIndexQueryParamFactory::create_query_value(
+                    nested_param_type, &nested_query_val, query_param));
+            Status st = iter->read_from_inverted_index(
+                    data_type_with_name.first, query_param->get_value(),
+                    segment_v2::InvertedIndexQueryType::EQUAL_QUERY, num_rows, 
single_res);
+            if (st.code() == ErrorCode::INVERTED_INDEX_NO_TERMS) {
+                // if analyzed param with no term, we do not filter any rows
+                // return all rows with OK status
+                roaring->addRange(0, num_rows);
+                break;
+            } else if (st != Status::OK()) {
+                return st;
+            }
+            *roaring |= *single_res;
+        }
+
+        segment_v2::InvertedIndexResultBitmap result(roaring, null_bitmap);
+        bitmap_result = result;
+        bitmap_result.mask_out_null();
+
+        return Status::OK();
+    }
+
     Status execute_impl(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
                         size_t result, size_t input_rows_count) const override 
{
         auto left_column =
diff --git 
a/regression-test/data/inverted_index_p0/test_array_contains_with_inverted_index.out
 
b/regression-test/data/inverted_index_p0/test_array_contains_with_inverted_index.out
index 76a72d8c595..c1c4ee1dc04 100644
--- 
a/regression-test/data/inverted_index_p0/test_array_contains_with_inverted_index.out
+++ 
b/regression-test/data/inverted_index_p0/test_array_contains_with_inverted_index.out
@@ -80,3 +80,362 @@
 2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
 2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
 
+-- !sql --
+
+-- !sql --
+
+-- !sql --
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a3        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a4        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+
+-- !sql --
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a3        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a4        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+
+-- !sql --
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+
+-- !sql --
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a3        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a4        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+
+-- !sql --
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a3        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a4        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+
+-- !sql --
+
+-- !sql --
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a3        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a4        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+
+-- !sql --
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a3        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a4        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+
+-- !sql --
+
+-- !sql --
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a3        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a4        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+
+-- !sql --
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a3        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a4        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
+-- !sql --
+
+-- !sql --
+
+-- !sql --
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a3        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a4        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+
+-- !sql --
+
+-- !sql --
+
+-- !sql --
+
+-- !sql --
+2017-01-01     021603e7dcfe65d44af0efd0e5aee154        ["n"]
+2017-01-01     48a33ec3453a28bce84b8f96fe161956        ["m"]
+2017-01-01     6afef581285b6608bf80d5a4e46cf839        ["a", "b", "c"]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a3        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a4        \N
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a5        []
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a6        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a7        [null, null, null]
+2017-01-01     8fcb57ae675f0af4d613d9e6c0e8a2a8        []
+2017-01-01     9fcb57ae675f0af4d613d9e6c0e8a2a2        ["o"]
+2017-01-01     d93d942d985a8fb7547c72dada8d332d        ["d", "e", "f", "g", 
"h", "i", "j", "k", "l"]
+
+-- !sql --
+2019-01-01     0974e7a82e30d1af83205e474fadd0a2        ["w"]
+2019-01-01     26823b3995ee38bd145ddd910b2f6300        ["x"]
+2019-01-01     a648a447b8f71522f11632eba4b4adde        ["p", "q", "r", "s", 
"t"]
+2019-01-01     a9fb5c985c90bf05f3bee5ca3ae95260        ["u", "v"]
+2019-01-01     ee27ee1da291e46403c408e220bed6e1        ["y"]
+
diff --git 
a/regression-test/suites/inverted_index_p0/test_array_contains_with_inverted_index.groovy
 
b/regression-test/suites/inverted_index_p0/test_array_contains_with_inverted_index.groovy
index 3c182d9963d..19bf8cc481f 100644
--- 
a/regression-test/suites/inverted_index_p0/test_array_contains_with_inverted_index.groovy
+++ 
b/regression-test/suites/inverted_index_p0/test_array_contains_with_inverted_index.groovy
@@ -66,14 +66,35 @@ suite("test_array_contains_with_inverted_index"){
     sql """ set enable_common_expr_pushdown = true """
 
     qt_sql """ select count() from ${indexTblName}"""
-    order_qt_sql """ select * from tai where array_contains(inventors, 's') 
order by id; """
+    def param_contains = ["\'s\'", "\'\'", null]
+    for (i = 0 ; i < param_contains.size(); ++i) {
+        def p = param_contains[i]
+        log.info("param: ${p}")
+        order_qt_sql """ select * from tai where array_contains(inventors, 
${p}) order by id; """
+        order_qt_sql """ select * from tai where array_contains(inventors, 
${p}) and apply_date = '2017-01-01' order by id; """
+        order_qt_sql """ select * from tai where array_contains(inventors, 
${p}) and apply_date = '2019-01-01' order by id; """
+        order_qt_sql """ select * from tai where array_contains(inventors, 
${p}) or apply_date = '2017-01-01' order by id; """
+        order_qt_sql """ select * from tai where !array_contains(inventors, 
${p}) order by id; """
+        order_qt_sql """ select * from tai where !array_contains(inventors, 
${p}) and apply_date = '2017-01-01' order by id; """
+        order_qt_sql """ select * from tai where !array_contains(inventors, 
${p}) and apply_date = '2019-01-01' order by id; """
+        order_qt_sql """ select * from tai where !array_contains(inventors, 
${p}) or apply_date = '2017-01-01' order by id; """
+        order_qt_sql """ select * from tai where (array_contains(inventors, 
${p}) and apply_date = '2017-01-01') or apply_date = '2019-01-01' order by id; 
"""
+    }
 
-    order_qt_sql """ select * from tai where array_contains(inventors, 's') 
and apply_date = '2017-01-01' order by id; """
-    order_qt_sql """ select * from tai where array_contains(inventors, 's') 
and apply_date = '2019-01-01' order by id; """
-    order_qt_sql """ select * from tai where array_contains(inventors, 's') or 
apply_date = '2017-01-01' order by id; """
-    order_qt_sql """ select * from tai where !array_contains(inventors, 's') 
order by id; """
-    order_qt_sql """ select * from tai where !array_contains(inventors, 's') 
and apply_date = '2017-01-01' order by id; """
-    order_qt_sql """ select * from tai where !array_contains(inventors, 's') 
and apply_date = '2019-01-01' order by id; """
-    order_qt_sql """ select * from tai where !array_contains(inventors, 's') 
or apply_date = '2017-01-01' order by id; """
-    order_qt_sql """ select * from tai where (array_contains(inventors, 's') 
and apply_date = '2017-01-01') or apply_date = '2019-01-01' order by id; """
+    // test arrays_overlap with inverted index
+    // now if we use inverted index we will not eval exprs
+    def param = [["\'s\'", "\'t\'"], [], null] // null for arrays_overlap will 
return null which in predicate will lead to return empty set
+    for (i = 0 ; i < param.size(); ++i) {
+        def p = param[i]
+        log.info("param: ${p}")
+        order_qt_sql """ select * from tai where arrays_overlap(inventors, 
${p}) order by id; """
+        order_qt_sql """ select * from tai where arrays_overlap(inventors, 
${p}) and apply_date = '2017-01-01' order by id; """
+        order_qt_sql """ select * from tai where arrays_overlap(inventors, 
${p}) and apply_date = '2019-01-01' order by id; """
+        order_qt_sql """ select * from tai where arrays_overlap(inventors, 
${p}) or apply_date = '2017-01-01' order by id; """
+        order_qt_sql """ select * from tai where !arrays_overlap(inventors, 
${p}) order by id; """
+        order_qt_sql """ select * from tai where !arrays_overlap(inventors, 
${p}) and apply_date = '2017-01-01' order by id; """
+        order_qt_sql """ select * from tai where !arrays_overlap(inventors, 
${p}) and apply_date = '2019-01-01' order by id; """
+        order_qt_sql """ select * from tai where !arrays_overlap(inventors, 
${p}) or apply_date = '2017-01-01' order by id; """
+        order_qt_sql """ select * from tai where (arrays_overlap(inventors, 
${p}) and apply_date = '2017-01-01') or apply_date = '2019-01-01' order by id; 
"""
+    }
 }


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

Reply via email to