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 cdaaec6b418 [Chore](hash-map) remove ck hash set and reduce ck hash 
map usage (#43600)
cdaaec6b418 is described below

commit cdaaec6b4188fc98c9cd7f7bd212d6d7d21e4dbc
Author: Pxl <[email protected]>
AuthorDate: Tue Nov 12 16:17:57 2024 +0800

    [Chore](hash-map) remove ck hash set and reduce ck hash map usage (#43600)
    
    ### What problem does this PR solve?
    remove ck hash set and reduce ck hash map usage
---
 be/src/pipeline/common/join_utils.h                |   1 +
 be/src/vec/columns/subcolumn_tree.h                |   1 -
 be/src/vec/common/columns_hashing.h                |   1 -
 be/src/vec/common/hash_table/hash_map.h            |  19 ----
 be/src/vec/common/hash_table/hash_set.h            | 104 ---------------------
 .../vec/common/hash_table/hash_table_allocator.h   |   3 -
 be/src/vec/common/hash_table/join_hash_table.h     |   4 +-
 be/src/vec/exec/format/json/new_json_reader.cpp    |  11 +--
 be/src/vec/exec/format/json/new_json_reader.h      |   5 +-
 .../array/function_array_enumerate_uniq.cpp        |   2 -
 .../functions/array/function_array_intersect.cpp   |   1 -
 be/src/vec/functions/array/function_array_map.h    |  51 ++++------
 be/src/vec/functions/function_cast.h               |   1 +
 .../test_generated_column_nereids.out              |   4 +-
 .../array_functions/test_array_functions.out       |  42 ++++-----
 .../test_array_functions_by_literal.out            |  26 +++---
 .../test_generated_column_nereids.groovy           |   4 +-
 .../array_functions/test_array_functions.groovy    |  26 +++---
 .../test_array_functions_by_literal.groovy         |   6 +-
 19 files changed, 84 insertions(+), 228 deletions(-)

diff --git a/be/src/pipeline/common/join_utils.h 
b/be/src/pipeline/common/join_utils.h
index e214d1a5293..a25e65e0a46 100644
--- a/be/src/pipeline/common/join_utils.h
+++ b/be/src/pipeline/common/join_utils.h
@@ -21,6 +21,7 @@
 #include <vector>
 
 #include "vec/common/hash_table/hash_map_util.h"
+#include "vec/common/hash_table/join_hash_table.h"
 
 namespace doris {
 using JoinOpVariants =
diff --git a/be/src/vec/columns/subcolumn_tree.h 
b/be/src/vec/columns/subcolumn_tree.h
index 81e835b58c4..8b53d1912f3 100644
--- a/be/src/vec/columns/subcolumn_tree.h
+++ b/be/src/vec/columns/subcolumn_tree.h
@@ -25,7 +25,6 @@
 #include "runtime/thread_context.h"
 #include "vec/columns/column.h"
 #include "vec/common/arena.h"
-#include "vec/common/hash_table/hash_map.h"
 #include "vec/common/string_ref.h"
 #include "vec/data_types/data_type.h"
 #include "vec/json/path_in_data.h"
diff --git a/be/src/vec/common/columns_hashing.h 
b/be/src/vec/common/columns_hashing.h
index 6a59c5964e4..00c86686d2b 100644
--- a/be/src/vec/common/columns_hashing.h
+++ b/be/src/vec/common/columns_hashing.h
@@ -29,7 +29,6 @@
 #include "vec/common/arena.h"
 #include "vec/common/assert_cast.h"
 #include "vec/common/columns_hashing_impl.h"
-#include "vec/common/hash_table/hash_table.h"
 #include "vec/common/hash_table/ph_hash_map.h"
 #include "vec/common/string_ref.h"
 #include "vec/common/unaligned.h"
diff --git a/be/src/vec/common/hash_table/hash_map.h 
b/be/src/vec/common/hash_table/hash_map.h
index 8cb02d6a80d..72f0584b640 100644
--- a/be/src/vec/common/hash_table/hash_map.h
+++ b/be/src/vec/common/hash_table/hash_map.h
@@ -20,14 +20,9 @@
 
 #pragma once
 
-#include <gen_cpp/PlanNodes_types.h>
-
-#include "common/compiler_util.h"
-#include "vec/columns/column_filter_helper.h"
 #include "vec/common/hash_table/hash.h"
 #include "vec/common/hash_table/hash_table.h"
 #include "vec/common/hash_table/hash_table_allocator.h"
-#include "vec/common/hash_table/join_hash_table.h"
 
 namespace doris {
 /** NOTE HashMap could only be used for memmoveable (position independent) 
types.
@@ -194,18 +189,4 @@ public:
     bool has_null_key_data() const { return false; }
 };
 
-template <typename Key, typename Mapped, typename Hash = DefaultHash<Key>,
-          typename Grower = HashTableGrower<>, typename Allocator = 
HashTableAllocator>
-using HashMap = HashMapTable<Key, HashMapCell<Key, Mapped, Hash>, Hash, 
Grower, Allocator>;
-
-template <typename Key, typename Hash = DefaultHash<Key>>
-using JoinHashMap = JoinHashTable<Key, Hash>;
-
-template <typename Key, typename Mapped, typename Hash, size_t 
initial_size_degree>
-using HashMapWithStackMemory = HashMapTable<
-        Key, HashMapCellWithSavedHash<Key, Mapped, Hash>, Hash,
-        HashTableGrower<initial_size_degree>,
-        HashTableAllocatorWithStackMemory<(1ULL << initial_size_degree) *
-                                          sizeof(HashMapCellWithSavedHash<Key, 
Mapped, Hash>)>>;
-
 } // namespace doris
diff --git a/be/src/vec/common/hash_table/hash_set.h 
b/be/src/vec/common/hash_table/hash_set.h
deleted file mode 100644
index 337a41afb23..00000000000
--- a/be/src/vec/common/hash_table/hash_set.h
+++ /dev/null
@@ -1,104 +0,0 @@
-// 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.
-// This file is copied from
-// 
https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/HashTable/HashSet.h
-// and modified by Doris
-
-#pragma once
-
-#include "vec/common/hash_table/hash.h"
-#include "vec/common/hash_table/hash_table.h"
-#include "vec/common/hash_table/hash_table_allocator.h"
-
-/** NOTE HashSet could only be used for memmoveable (position independent) 
types.
-  * Example: std::string is not position independent in libstdc++ with C++11 
ABI or in libc++.
-  * Also, key must be of type, that zero bytes is compared equals to zero key.
-  */
-
-template <typename Key, typename TCell, typename Hash = DefaultHash<Key>,
-          typename Grower = HashTableGrower<>, typename Allocator = 
HashTableAllocator>
-class HashSetTable : public HashTable<Key, TCell, Hash, Grower, Allocator> {
-public:
-    using Self = HashSetTable;
-    using Cell = TCell;
-
-    using Base = HashTable<Key, TCell, Hash, Grower, Allocator>;
-    using typename Base::LookupResult;
-
-    void merge(const Self& rhs) {
-        if (!this->get_has_zero() && rhs.get_has_zero()) {
-            this->set_get_has_zero();
-            ++this->m_size;
-        }
-
-        for (size_t i = 0; i < rhs.grower.buf_size(); ++i)
-            if (!rhs.buf[i].is_zero(*this)) 
this->insert(Cell::get_key(rhs.buf[i].get_value()));
-    }
-};
-
-template <typename Key, typename Hash, typename TState = HashTableNoState>
-struct HashSetCellWithSavedHash : public HashTableCell<Key, Hash, TState> {
-    using Base = HashTableCell<Key, Hash, TState>;
-
-    size_t saved_hash;
-
-    HashSetCellWithSavedHash() : Base() {}
-    HashSetCellWithSavedHash(const Key& key_, const typename Base::State& 
state)
-            : Base(key_, state) {}
-
-    bool key_equals(const Key& key_) const { return this->key == key_; }
-    bool key_equals(const Key& key_, size_t hash_) const {
-        return saved_hash == hash_ && this->key == key_;
-    }
-    bool key_equals(const Key& key_, size_t hash_, const typename 
Base::State&) const {
-        return key_equals(key_, hash_);
-    }
-
-    void set_hash(size_t hash_value) { saved_hash = hash_value; }
-    size_t get_hash(const Hash& /*hash_function*/) const { return saved_hash; }
-};
-
-template <typename Key, typename Hash, typename State>
-ALWAYS_INLINE inline auto lookup_result_get_key(HashSetCellWithSavedHash<Key, 
Hash, State>* cell) {
-    return &cell->key;
-}
-
-template <typename Key, typename Hash, typename State>
-ALWAYS_INLINE inline void* 
lookup_result_get_mapped(HashSetCellWithSavedHash<Key, Hash, State>*) {
-    return nullptr;
-}
-
-template <typename Key, typename Hash = DefaultHash<Key>, typename Grower = 
HashTableGrower<>,
-          typename Allocator = HashTableAllocator>
-using HashSet = HashSetTable<Key, HashTableCell<Key, Hash>, Hash, Grower, 
Allocator>;
-
-template <typename Key, typename Hash = DefaultHash<Key>, typename Grower = 
HashTableGrower<>,
-          typename Allocator = HashTableAllocator>
-using HashSetWithSavedHash =
-        HashSetTable<Key, HashSetCellWithSavedHash<Key, Hash>, Hash, Grower, 
Allocator>;
-
-template <typename Key, typename Hash, size_t initial_size_degree>
-using HashSetWithStackMemory =
-        HashSet<Key, Hash, HashTableGrower<initial_size_degree>,
-                HashTableAllocatorWithStackMemory<(1ULL << 
initial_size_degree) *
-                                                  sizeof(HashTableCell<Key, 
Hash>)>>;
-
-template <typename Key, typename Hash, size_t initial_size_degree>
-using HashSetWithSavedHashWithStackMemory = HashSetWithSavedHash<
-        Key, Hash, HashTableGrower<initial_size_degree>,
-        HashTableAllocatorWithStackMemory<(1ULL << initial_size_degree) *
-                                          sizeof(HashSetCellWithSavedHash<Key, 
Hash>)>>;
\ No newline at end of file
diff --git a/be/src/vec/common/hash_table/hash_table_allocator.h 
b/be/src/vec/common/hash_table/hash_table_allocator.h
index 2159bf474a0..87111dfe946 100644
--- a/be/src/vec/common/hash_table/hash_table_allocator.h
+++ b/be/src/vec/common/hash_table/hash_table_allocator.h
@@ -29,6 +29,3 @@
   * interrupt the resize loop. Set the allocator parameter accordingly.
   */
 using HashTableAllocator = Allocator<true /* clear_memory */, true /* 
mmap_populate */>;
-
-template <size_t N = 64>
-using HashTableAllocatorWithStackMemory = 
AllocatorWithStackMemory<HashTableAllocator, N>;
diff --git a/be/src/vec/common/hash_table/join_hash_table.h 
b/be/src/vec/common/hash_table/join_hash_table.h
index 25ca8844cd2..59463f0e3f4 100644
--- a/be/src/vec/common/hash_table/join_hash_table.h
+++ b/be/src/vec/common/hash_table/join_hash_table.h
@@ -23,7 +23,6 @@
 
 #include "vec/columns/column_filter_helper.h"
 #include "vec/common/hash_table/hash.h"
-#include "vec/common/hash_table/hash_table.h"
 #include "vec/common/hash_table/hash_table_allocator.h"
 
 namespace doris {
@@ -464,4 +463,7 @@ private:
     bool _has_null_key = false;
     bool _empty_build_side = true;
 };
+
+template <typename Key, typename Hash = DefaultHash<Key>>
+using JoinHashMap = JoinHashTable<Key, Hash>;
 } // namespace doris
\ No newline at end of file
diff --git a/be/src/vec/exec/format/json/new_json_reader.cpp 
b/be/src/vec/exec/format/json/new_json_reader.cpp
index 7dfc3c528cd..d726de3d998 100644
--- a/be/src/vec/exec/format/json/new_json_reader.cpp
+++ b/be/src/vec/exec/format/json/new_json_reader.cpp
@@ -1361,16 +1361,15 @@ Status 
NewJsonReader::_simdjson_handle_nested_complex_json(
 size_t NewJsonReader::_column_index(const StringRef& name, size_t key_index) {
     /// Optimization by caching the order of fields (which is almost always 
the same)
     /// and a quick check to match the next expected field, instead of 
searching the hash table.
-    if (_prev_positions.size() > key_index && _prev_positions[key_index] &&
-        name == _prev_positions[key_index]->get_first()) {
-        return _prev_positions[key_index]->get_second();
+    if (_prev_positions.size() > key_index && name == 
_prev_positions[key_index]->first) {
+        return _prev_positions[key_index]->second;
     }
-    auto* it = _slot_desc_index.find(name);
-    if (it) {
+    auto it = _slot_desc_index.find(name);
+    if (it != _slot_desc_index.end()) {
         if (key_index < _prev_positions.size()) {
             _prev_positions[key_index] = it;
         }
-        return it->get_second();
+        return it->second;
     }
     return size_t(-1);
 }
diff --git a/be/src/vec/exec/format/json/new_json_reader.h 
b/be/src/vec/exec/format/json/new_json_reader.h
index 1dc5b90da6f..985bf999676 100644
--- a/be/src/vec/exec/format/json/new_json_reader.h
+++ b/be/src/vec/exec/format/json/new_json_reader.h
@@ -39,7 +39,6 @@
 #include "io/file_factory.h"
 #include "io/fs/file_reader_writer_fwd.h"
 #include "util/runtime_profile.h"
-#include "vec/common/hash_table/hash_map.h"
 #include "vec/common/string_ref.h"
 #include "vec/core/types.h"
 #include "vec/exec/format/generic_reader.h"
@@ -267,10 +266,10 @@ private:
     // ======SIMD JSON======
     // name mapping
     /// Hash table match `field name -> position in the block`. NOTE You can 
use perfect hash map.
-    using NameMap = HashMap<StringRef, size_t, StringRefHash>;
+    using NameMap = phmap::flat_hash_map<StringRef, size_t, StringRefHash>;
     NameMap _slot_desc_index;
     /// Cached search results for previous row (keyed as index in JSON object) 
- used as a hint.
-    std::vector<NameMap::LookupResult> _prev_positions;
+    std::vector<NameMap::iterator> _prev_positions;
     /// Set of columns which already met in row. Exception is thrown if there 
are more than one column with the same name.
     std::vector<UInt8> _seen_columns;
     // simdjson
diff --git a/be/src/vec/functions/array/function_array_enumerate_uniq.cpp 
b/be/src/vec/functions/array/function_array_enumerate_uniq.cpp
index a10124354be..21d6ab40007 100644
--- a/be/src/vec/functions/array/function_array_enumerate_uniq.cpp
+++ b/be/src/vec/functions/array/function_array_enumerate_uniq.cpp
@@ -38,9 +38,7 @@
 #include "vec/common/assert_cast.h"
 #include "vec/common/columns_hashing.h"
 #include "vec/common/hash_table/hash.h"
-#include "vec/common/hash_table/hash_map.h"
 #include "vec/common/hash_table/hash_map_context.h"
-#include "vec/common/hash_table/hash_table.h"
 #include "vec/common/hash_table/hash_table_allocator.h"
 #include "vec/common/pod_array_fwd.h"
 #include "vec/common/string_ref.h"
diff --git a/be/src/vec/functions/array/function_array_intersect.cpp 
b/be/src/vec/functions/array/function_array_intersect.cpp
index cc27e1a6657..e68ddf30542 100644
--- a/be/src/vec/functions/array/function_array_intersect.cpp
+++ b/be/src/vec/functions/array/function_array_intersect.cpp
@@ -17,7 +17,6 @@
 
 #include "vec/columns/column_const.h"
 #include "vec/common/assert_cast.h"
-#include "vec/common/hash_table/hash_map.h"
 #include "vec/functions/array/function_array_binary.h"
 #include "vec/functions/array/function_array_map.h"
 #include "vec/functions/array/function_array_nary.h"
diff --git a/be/src/vec/functions/array/function_array_map.h 
b/be/src/vec/functions/array/function_array_map.h
index 74b0a19f0f0..bcb71a4a79f 100644
--- a/be/src/vec/functions/array/function_array_map.h
+++ b/be/src/vec/functions/array/function_array_map.h
@@ -21,28 +21,10 @@
 
 #include "vec/columns/column_array.h"
 #include "vec/columns/column_string.h"
-#include "vec/common/hash_table/hash_map.h"
 #include "vec/data_types/data_type_array.h"
 #include "vec/functions/array/function_array_utils.h"
 #include "vec/functions/function_helpers.h"
 
-#define FILL_MAP_DATA_INTO_DEFAULT_COLUMN()                                \
-    ++dst_off;                                                             \
-    auto& dst_data = static_cast<ColumnType&>(*dst.nested_col).get_data(); \
-    dst_data.push_back(entry.get_first());                                 \
-    if (dst.nested_nullmap_data) {                                         \
-        dst.nested_nullmap_data->push_back(0);                             \
-    }
-
-#define FILL_MAP_DATA_INTO_STRING_COLUMN()                       \
-    auto& dst_col = static_cast<ColumnString&>(*dst.nested_col); \
-    StringRef key = entry.get_first();                           \
-    ++dst_off;                                                   \
-    dst_col.insert_data(key.data, key.size);                     \
-    if (dst.nested_nullmap_data) {                               \
-        dst.nested_nullmap_data->push_back(0);                   \
-    }
-
 namespace doris::vectorized {
 
 enum class MapOperation { INTERSECT, UNION };
@@ -70,8 +52,7 @@ template <MapOperation operation, typename ColumnType>
 struct OpenMapImpl {
     using Element = typename ColumnType::value_type;
     using ElementNativeType = typename NativeType<Element>::Type;
-    using Map =
-            HashMapWithStackMemory<ElementNativeType, size_t, 
DefaultHash<ElementNativeType>, 6>;
+    using Map = phmap::flat_hash_map<ElementNativeType, size_t>;
     using Action = typename MapActionImpl<Map, ColumnType, operation>::Action;
 
     Action action;
@@ -100,13 +81,14 @@ struct OpenMapImpl {
             }
             // make map result to dst
             for (const auto& entry : map) {
-                if constexpr (operation == MapOperation::INTERSECT) {
-                    if (entry.get_mapped() == params.size()) {
-                        FILL_MAP_DATA_INTO_DEFAULT_COLUMN()
+                if ((operation == MapOperation::INTERSECT && entry.second == 
params.size()) ||
+                    operation == MapOperation::UNION) {
+                    ++dst_off;
+                    auto& dst_data = 
static_cast<ColumnType&>(*dst.nested_col).get_data();
+                    dst_data.push_back(entry.first);
+                    if (dst.nested_nullmap_data) {
+                        dst.nested_nullmap_data->push_back(0);
                     }
-                } else if constexpr (operation == MapOperation::UNION) {
-                    // union in map all key
-                    FILL_MAP_DATA_INTO_DEFAULT_COLUMN()
                 }
             }
             dst.offsets_ptr->push_back(dst_off);
@@ -116,7 +98,7 @@ struct OpenMapImpl {
 
 template <MapOperation operation>
 struct OpenMapImpl<operation, ColumnString> {
-    using Map = HashMapWithStackMemory<StringRef, size_t, StringRefHash, 6>;
+    using Map = phmap::flat_hash_map<StringRef, size_t, StringRefHash>;
     using Action = typename MapActionImpl<Map, ColumnString, 
operation>::Action;
 
     Action action;
@@ -145,12 +127,15 @@ struct OpenMapImpl<operation, ColumnString> {
             }
             // make map result to dst
             for (const auto& entry : map) {
-                if constexpr (operation == MapOperation::INTERSECT) {
-                    if (entry.get_mapped() == params.size()) {
-                        FILL_MAP_DATA_INTO_STRING_COLUMN()
+                if ((operation == MapOperation::INTERSECT && entry.second == 
params.size()) ||
+                    operation == MapOperation::UNION) {
+                    auto& dst_col = 
static_cast<ColumnString&>(*dst.nested_col);
+                    StringRef key = entry.first;
+                    ++dst_off;
+                    dst_col.insert_data(key.data, key.size);
+                    if (dst.nested_nullmap_data) {
+                        dst.nested_nullmap_data->push_back(0);
                     }
-                } else if constexpr (operation == MapOperation::UNION) {
-                    FILL_MAP_DATA_INTO_STRING_COLUMN()
                 }
             }
             dst.offsets_ptr->push_back(dst_off);
@@ -166,7 +151,7 @@ public:
         // if any nested type of array arguments is nullable then return array 
with
         // nullable nested type.
         for (const auto& arg : arguments) {
-            const DataTypeArray* array_type = 
check_and_get_data_type<DataTypeArray>(arg.get());
+            const auto* array_type = 
check_and_get_data_type<DataTypeArray>(arg.get());
             if (array_type->get_nested_type()->is_nullable()) {
                 res = arg;
                 break;
diff --git a/be/src/vec/functions/function_cast.h 
b/be/src/vec/functions/function_cast.h
index c2195fd7e69..19503f7b648 100644
--- a/be/src/vec/functions/function_cast.h
+++ b/be/src/vec/functions/function_cast.h
@@ -93,6 +93,7 @@
 #include "vec/functions/function.h"
 #include "vec/functions/function_convert_tz.h"
 #include "vec/functions/function_helpers.h"
+#include "vec/io/io_helper.h"
 #include "vec/io/reader_buffer.h"
 #include "vec/runtime/time_value.h"
 #include "vec/runtime/vdatetime_value.h"
diff --git 
a/regression-test/data/ddl_p0/test_create_table_generated_column/test_generated_column_nereids.out
 
b/regression-test/data/ddl_p0/test_create_table_generated_column/test_generated_column_nereids.out
index 85541d34cf1..b7757222ab4 100644
--- 
a/regression-test/data/ddl_p0/test_create_table_generated_column/test_generated_column_nereids.out
+++ 
b/regression-test/data/ddl_p0/test_create_table_generated_column/test_generated_column_nereids.out
@@ -108,7 +108,7 @@
 1
 
 -- !gencol_array_function_select --
-1      [1, 2]  [3, 2]  [3, 2, 1]
+1      [1, 2]  [2, 3]  [1, 2, 3]
 
 -- !gencol_array_function_element_at_create --
 0
@@ -117,7 +117,7 @@
 1
 
 -- !gencol_array_function_element_at_select --
-1      [1, 2]  [3, 2]  1
+1      [1, 2]  [2, 3]  1
 
 -- !create_table_like --
 0
diff --git 
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out
 
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out
index 8e3d004b148..bfc7dcafbc0 100644
--- 
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out
+++ 
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out
@@ -209,19 +209,19 @@
 9      \N
 
 -- !select --
-1      [3, 2, 1]
+1      [1, 2, 3]
 2      [4, 5]
 3      \N
-4      [3, 2, 1, 4, 5]
+4      [1, 2, 3, 4, 5]
 5      \N
 6      \N
 7      \N
-8      [null, 3, 2, 1, 4]
-9      [3, 2, 1]
+8      [null, 1, 2, 3, 4]
+9      [1, 2, 3]
 
 -- !select --
-1      ["2023-02-07", "2023-02-06", "2023-02-05"]
-2      ["2023-01-06", "2023-01-07", "2023-01-05"]
+1      ["2023-02-05", "2023-02-06", "2023-02-07"]
+2      ["2023-01-05", "2023-01-06", "2023-01-07"]
 3      \N
 4      \N
 5      \N
@@ -231,8 +231,8 @@
 9      \N
 
 -- !select --
-1      ["2022-10-16 10:30:00.999", "2022-10-15 10:30:00.999", "2022-08-31 
12:00:00.999"]
-2      ["2022-11-15 10:30:00.999", "2022-11-16 10:30:00.999", "2022-01-31 
12:00:00.999"]
+1      ["2022-08-31 12:00:00.999", "2022-10-15 10:30:00.999", "2022-10-16 
10:30:00.999"]
+2      ["2022-01-31 12:00:00.999", "2022-11-15 10:30:00.999", "2022-11-16 
10:30:00.999"]
 3      \N
 4      \N
 5      \N
@@ -243,7 +243,7 @@
 
 -- !select --
 1      [111.111, 222.222, 333.333]
-2      [444.444, 555.556, 333.333]
+2      [333.333, 444.444, 555.556]
 3      \N
 4      \N
 5      \N
@@ -253,15 +253,15 @@
 9      \N
 
 -- !select --
-1      [3, 2, 222, 1]
+1      [1, 2, 3, 222]
 2      \N
 3      \N
-4      [null, 3, 23, 2, 1, 4, 5]
+4      [null, 1, 2, 3, 4, 5, 23]
 5      \N
 6      \N
 7      \N
-8      [null, 8, 10, 3, 9, 2, 1, 4]
-9      [null, 3, 2, 1, 12]
+8      [null, 1, 2, 3, 4, 8, 9, 10]
+9      [null, 1, 2, 3, 12]
 
 -- !select --
 1      [3]
@@ -271,7 +271,7 @@
 5      \N
 6      \N
 7      \N
-8      [4, null]
+8      [null, 4]
 9      [3]
 
 -- !select --
@@ -308,15 +308,15 @@
 9      \N
 
 -- !select --
-1      [2, 1]
+1      [1, 2]
 2      []
 3      \N
 4      []
 5      \N
 6      \N
 7      \N
-8      [3, 2, 1]
-9      [2, 1]
+8      [1, 2, 3]
+9      [1, 2]
 
 -- !select --
 1      ["2023-02-06"]
@@ -1656,12 +1656,12 @@
 [1, 2, 3]      1,2,3
 
 -- !select_union --
-10005  [10005, null, null]     [null, 3, 10005, 2, 1]
-10006  [60002, 60002, 60003, null, 60005]      [null, 3, 60002, 60005, 60003, 
2, 1]
+10005  [10005, null, null]     [null, 10005, 1, 2, 3]
+10006  [60002, 60002, 60003, null, 60005]      [null, 60003, 1, 60005, 2, 
60002, 3]
 
 -- !select_union_left_const --
-10005  [10005, null, null]     [null, 3, 10005, 2, 1]
-10006  [60002, 60002, 60003, null, 60005]      [null, 3, 60002, 60005, 60003, 
2, 1]
+10005  [10005, null, null]     [null, 10005, 1, 2, 3]
+10006  [60002, 60002, 60003, null, 60005]      [null, 60003, 1, 2, 60005, 3, 
60002]
 
 -- !select_except --
 10005  [10005, null, null]     [10005, null]
diff --git 
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
 
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
index 221d38b267a..58f3774584d 100644
--- 
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
+++ 
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions_by_literal.out
@@ -465,22 +465,22 @@ false
 true
 
 -- !sql --
-[3, 2, 1, 4]
+[4, 1, 2, 3]
 
 -- !sql --
 [1]
 
 -- !sql --
-[3, 2]
+[2, 3]
 
 -- !sql --
-[null, 3, 2, 1, 4]
+[null, 4, 1, 2, 3]
 
 -- !sql --
 [1]
 
 -- !sql --
-[3, 2]
+[2, 3]
 
 -- !sql --
 [0, 1]
@@ -501,7 +501,7 @@ true
 []
 
 -- !sql --
-[3, 2, 1]
+[2, 1, 3]
 
 -- !sql --
 []
@@ -510,7 +510,7 @@ true
 []
 
 -- !sql --
-[null, 3, 2, 1]
+[null, 2, 1, 3]
 
 -- !sql --
 [null]
@@ -519,7 +519,7 @@ true
 []
 
 -- !sql --
-[100000000, 1]
+[1, 100000000]
 
 -- !sql --
 [1]
@@ -537,7 +537,7 @@ true
 ["2023-02-04 23:07:34.999"]
 
 -- !sql --
-["2023-02-07", "2023-02-06", "2023-02-05"]
+["2023-02-06", "2023-02-05", "2023-02-07"]
 
 -- !sql --
 ["2023-02-06"]
@@ -546,7 +546,7 @@ true
 ["2023-02-05"]
 
 -- !sql --
-[111.111, 222.222, 333.333]
+[333.333, 222.222, 111.111]
 
 -- !sql --
 [111.111]
@@ -603,16 +603,16 @@ true
 []
 
 -- !sql_union_1 --
-[null, 3, 2, 1]
+[null, 2, 1, 3]
 
 -- !sql_union_2 --
-[null, 3, 2, 1]
+[null, 2, 1, 3]
 
 -- !sql_union_3 --
-[null, 3, 2, 1]
+[null, 2, 1, 3]
 
 -- !sql_union_4 --
-[null, 3, 2, 1]
+[null, 2, 1, 3]
 
 -- !sql --
 [2, 3, 4, 5, 6]
diff --git 
a/regression-test/suites/ddl_p0/test_create_table_generated_column/test_generated_column_nereids.groovy
 
b/regression-test/suites/ddl_p0/test_create_table_generated_column/test_generated_column_nereids.groovy
index c2c451b59ff..36fbf9d80aa 100644
--- 
a/regression-test/suites/ddl_p0/test_create_table_generated_column/test_generated_column_nereids.groovy
+++ 
b/regression-test/suites/ddl_p0/test_create_table_generated_column/test_generated_column_nereids.groovy
@@ -90,7 +90,7 @@ suite("test_generated_column") {
     ;
     """
     qt_gencol_array_function_insert "insert into test_gen_col_array_func 
values(1,[1,2],[3,2],default);"
-    qt_gencol_array_function_select "select * from test_gen_col_array_func"
+    qt_gencol_array_function_select "select 
pk,array_sort(a),array_sort(b),array_sort(c) from test_gen_col_array_func order 
by 1"
 
     sql "drop table if exists test_gen_col_element_at_func"
     qt_gencol_array_function_element_at_create """
@@ -100,7 +100,7 @@ suite("test_generated_column") {
     ;
     """
     qt_gencol_array_function_element_at_insert "insert into 
test_gen_col_element_at_func values(1,[1,2],[3,2],default);"
-    qt_gencol_array_function_element_at_select "select * from 
test_gen_col_element_at_func"
+    qt_gencol_array_function_element_at_select "select 
pk,array_sort(a),array_sort(b),c from test_gen_col_element_at_func order by 1"
 
     sql "drop table if exists gencol_like_t;"
     qt_create_table_like "create table gencol_like_t like test_gen_col_common;"
diff --git 
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
 
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
index 96bca3eb4ff..5a684faaccd 100644
--- 
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
+++ 
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
@@ -72,20 +72,20 @@ suite("test_array_functions") {
     qt_select_array_reverse_sort1 "SELECT k1, array_reverse_sort(k2), 
array_reverse_sort(k3), array_reverse_sort(k4) FROM ${tableName} ORDER BY k1"
     qt_select_array_reverse_sort2 "SELECT k1, array_reverse_sort(k8), 
array_reverse_sort(k10) FROM ${tableName} ORDER BY k1"
     qt_select_array_reverse_sort3 "SELECT k1, array_reverse_sort(k12) FROM 
${tableName} ORDER BY k1"
-    qt_select "SELECT k1, array_union(k2, k4) FROM ${tableName} ORDER BY k1"
-    qt_select "SELECT k1, array_union(k8, k9) FROM ${tableName} ORDER BY k1"
-    qt_select "SELECT k1, array_union(k10, k11) FROM ${tableName} ORDER BY k1"
-    qt_select "SELECT k1, array_union(k12, k13) FROM ${tableName} ORDER BY k1"
+    qt_select "SELECT k1, array_sort(array_union(k2, k4)) FROM ${tableName} 
ORDER BY k1"
+    qt_select "SELECT k1, array_sort(array_union(k8, k9)) FROM ${tableName} 
ORDER BY k1"
+    qt_select "SELECT k1, array_sort(array_union(k10, k11)) FROM ${tableName} 
ORDER BY k1"
+    qt_select "SELECT k1, array_sort(array_union(k12, k13)) FROM ${tableName} 
ORDER BY k1"
     // multi-params array_union
-    qt_select "SELECT k1, array_union(k2, k4, k14) FROM ${tableName} ORDER BY 
k1"
-    qt_select "SELECT k1, array_except(k2, k4) FROM ${tableName} ORDER BY k1"
-    qt_select "SELECT k1, array_except(k8, k9) FROM ${tableName} ORDER BY k1"
-    qt_select "SELECT k1, array_except(k10, k11) FROM ${tableName} ORDER BY k1"
-    qt_select "SELECT k1, array_except(k12, k13) FROM ${tableName} ORDER BY k1"
-    qt_select "SELECT k1, array_intersect(k2, k4) FROM ${tableName} ORDER BY 
k1"
-    qt_select "SELECT k1, array_intersect(k8, k9) FROM ${tableName} ORDER BY 
k1"
-    qt_select "SELECT k1, array_intersect(k10, k11) FROM ${tableName} ORDER BY 
k1"
-    qt_select "SELECT k1, array_intersect(k12, k13) FROM ${tableName} ORDER BY 
k1"
+    qt_select "SELECT k1, array_sort(array_union(k2, k4, k14)) FROM 
${tableName} ORDER BY k1"
+    qt_select "SELECT k1, array_sort(array_except(k2, k4)) FROM ${tableName} 
ORDER BY k1"
+    qt_select "SELECT k1, array_sort(array_except(k8, k9)) FROM ${tableName} 
ORDER BY k1"
+    qt_select "SELECT k1, array_sort(array_except(k10, k11)) FROM ${tableName} 
ORDER BY k1"
+    qt_select "SELECT k1, array_sort(array_except(k12, k13)) FROM ${tableName} 
ORDER BY k1"
+    qt_select "SELECT k1, array_sort(array_intersect(k2, k4)) FROM 
${tableName} ORDER BY k1"
+    qt_select "SELECT k1, array_sort(array_intersect(k8, k9)) FROM 
${tableName} ORDER BY k1"
+    qt_select "SELECT k1, array_sort(array_intersect(k10, k11)) FROM 
${tableName} ORDER BY k1"
+    qt_select "SELECT k1, array_sort(array_intersect(k12, k13)) FROM 
${tableName} ORDER BY k1"
     qt_select "SELECT k1, array_slice(k2, 2) FROM ${tableName} ORDER BY k1"
     qt_select "SELECT k1, array_slice(k2, 1, 2) FROM ${tableName} ORDER BY k1"
     qt_select "SELECT k1, array_slice(k8, 1, 2) FROM ${tableName} ORDER BY k1"
diff --git 
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
 
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
index 344c1935f44..cd4baf28252 100644
--- 
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
+++ 
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions_by_literal.groovy
@@ -30,9 +30,9 @@ suite("test_array_functions_by_literal") {
     qt_sql_6 """select array_sum(array(1.0,2.0,null, null,2.0));"""
     qt_sql_7 """select array_product(array(1.0,2.0,null, null,2.0));"""
     qt_sql_8 """select array_distinct(array(1.0,2.0,null, null,2.0));"""
-    qt_sql_9 """select array_intersect(array(1.0,2.0,null, null,2.0), 
array(1.0,2.0,null, null,2.0));"""
-    qt_sql_10 """select array_except(array(1.0,2.0,null, null,2.0), 
array(1.0,2.0,null, null,2.0));"""
-    qt_sql_11 """select array_union(array(1.0,2.0,null, null,2.0), 
array(1.0,2.0,null, null,2.0));"""
+    qt_sql_9 """select array_sort(array_intersect(array(1.0,2.0,null, 
null,2.0), array(1.0,2.0,null, null,2.0)));"""
+    qt_sql_10 """select array_sort(array_except(array(1.0,2.0,null, null,2.0), 
array(1.0,2.0,null, null,2.0)));"""
+    qt_sql_11 """select array_sort(array_union(array(1.0,2.0,null, null,2.0), 
array(1.0,2.0,null, null,2.0)));"""
     qt_sql_14 """select array_popfront(array(1.0,2.0,null, null,2.0));"""
     qt_sql_15 """select array_popback(array(1.0,2.0,null, null,2.0));"""
     qt_sql_16 """select array_concat(array(1.0,2.0,null, null,2.0), 
array(1.0,2.0,null, null,2.0));"""


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to