Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
106afda
feat: map_concat
nagisa-kunhah Nov 26, 2025
eaddffe
fix: optimize code
nagisa-kunhah Nov 29, 2025
6473a03
fix: nullable
nagisa-kunhah Dec 4, 2025
930ef85
feat: FunctionMapConcatTest
nagisa-kunhah Dec 4, 2025
7b0bf75
fix: ColumnNullable
nagisa-kunhah Dec 7, 2025
f0970be
feat: function_map_concat_test
nagisa-kunhah Dec 7, 2025
cef3520
fix: function_map_concat_test
nagisa-kunhah Dec 7, 2025
e5c3bd8
remove: FunctionMapConcatTest.TestComplexTypes
nagisa-kunhah Dec 7, 2025
7869361
fix: get_key_value_type
nagisa-kunhah Dec 7, 2025
aea2e7f
fix: TestComplexTypes of array
nagisa-kunhah Dec 7, 2025
71a6cb7
fix: check_function_all_arg_comb
nagisa-kunhah Dec 8, 2025
d42447c
feat: Test with double, float and decimalv2
nagisa-kunhah Dec 10, 2025
fc221f6
feat: Test single map
nagisa-kunhah Dec 12, 2025
053760a
feat: extend map_concat to handle struct-typed values
nagisa-kunhah Dec 12, 2025
3c585c6
fix: compile error
nagisa-kunhah Dec 12, 2025
174cab1
feat: test_map_concat
nagisa-kunhah Dec 13, 2025
65de5e5
fix: handle null values in arguments to prevent crash
nagisa-kunhah Dec 13, 2025
d428f86
fix: test_map_concat.out
nagisa-kunhah Dec 14, 2025
41c7f69
test: expand test coverage for mapconcat function
nagisa-kunhah Dec 14, 2025
4332c22
fix: style issue
nagisa-kunhah Dec 16, 2025
94bd981
fix: stype issue
nagisa-kunhah Dec 16, 2025
7bfec0f
fix: style issue
nagisa-kunhah Dec 17, 2025
958eac9
fix: style issue
nagisa-kunhah Dec 17, 2025
fb58202
fix: crash when “select map_concat();”
nagisa-kunhah Dec 17, 2025
109c9af
fix: optimize test
nagisa-kunhah Dec 17, 2025
41ed41f
fix: license issue
nagisa-kunhah Dec 18, 2025
b28ec86
fix: int -> size_t
nagisa-kunhah Dec 18, 2025
207cade
fix: remove info log
nagisa-kunhah Dec 19, 2025
4d7e3e2
fix: remove chinese comment
nagisa-kunhah Dec 19, 2025
57a3d28
Merge branch 'master' into feat_map_concat
nagisa-kunhah Dec 22, 2025
e3a0e06
feat: assert_cast
nagisa-kunhah Dec 26, 2025
c85ec74
add: test about map_concat(map3,map1)
nagisa-kunhah Dec 27, 2025
92ebc69
fix: assert_cast
nagisa-kunhah Jan 8, 2026
7528446
fix: format
nagisa-kunhah Jan 8, 2026
3663724
fix: process map_concat() by be
nagisa-kunhah Jan 10, 2026
105c5a6
fix: style
nagisa-kunhah Jan 10, 2026
be768a6
fix: comment
nagisa-kunhah Jan 16, 2026
88045c4
refactor
nagisa-kunhah Jan 16, 2026
5c33069
fix: comment
nagisa-kunhah Jan 17, 2026
c35513d
fix: comment
nagisa-kunhah Jan 17, 2026
42829ff
Merge branch 'master' into feat_map_concat
nagisa-kunhah Jan 18, 2026
49bfdd6
fix: ut
nagisa-kunhah Jan 18, 2026
9dd20de
Merge branch 'master' into feat_map_concat
nagisa-kunhah Jan 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions be/src/vec/data_types/data_type_date_or_datetime_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,11 @@ template <typename DataType>
constexpr bool IsDataTypeDateTimeV2 = false;
template <>
inline constexpr bool IsDataTypeDateTimeV2<DataTypeDateTimeV2> = true;

template <typename DataType>
constexpr bool IsDataTypeMap = false;
template <>
inline constexpr bool IsDataTypeMap<DataTypeMap> = true;

#include "common/compile_check_end.h"
} // namespace doris::vectorized
76 changes: 75 additions & 1 deletion be/src/vec/functions/function_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <algorithm>
#include <boost/iterator/iterator_facade.hpp>
#include <cstddef>
#include <memory>
#include <ostream>
#include <string>
Expand All @@ -36,6 +37,7 @@
#include "vec/columns/column_const.h"
#include "vec/columns/column_map.h"
#include "vec/columns/column_nullable.h"
#include "vec/columns/column_variant.h"
#include "vec/columns/column_vector.h"
#include "vec/common/assert_cast.h"
#include "vec/common/typeid_cast.h"
Expand Down Expand Up @@ -88,7 +90,6 @@ class FunctionMap : public IFunction {
uint32_t result, size_t input_rows_count) const override {
DCHECK(arguments.size() % 2 == 0)
<< "function: " << get_name() << ", arguments should not be even number";

size_t num_element = arguments.size();

auto result_col = block.get_by_position(result).type->create_column();
Expand Down Expand Up @@ -792,6 +793,78 @@ class FunctionDeduplicateMap : public IFunction {
private:
};

class FunctionMapConcat : public IFunction {
public:
static constexpr auto name = "map_concat";
static FunctionPtr create() { return std::make_shared<FunctionMapConcat>(); }
String get_name() const override { return name; }
bool is_variadic() const override { return true; }
size_t get_number_of_arguments() const override { return 0; }
DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
if (arguments.empty()) {
return std::make_shared<DataTypeMap>(
make_nullable(std::make_shared<DataTypeNothing>()),
make_nullable(std::make_shared<DataTypeNothing>()));
}
DCHECK(arguments.size() > 0)
<< "function: " << get_name() << ", arguments should not be empty";
return arguments[0];
}
Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
const uint32_t result, size_t input_rows_count) const override {
auto result_col = block.get_by_position(result).type->create_column();
ColumnMap* result_map_column = nullptr;
ColumnNullable* result_nullable_column = nullptr;
if (result_col->is_nullable()) {
result_nullable_column = assert_cast<ColumnNullable*>(result_col.get());
result_map_column =
assert_cast<ColumnMap*>(result_nullable_column->get_nested_column_ptr().get());
} else {
result_map_column = assert_cast<ColumnMap*>(result_col.get());
}
auto& result_col_map_keys_data = result_map_column->get_keys();
auto& result_col_map_vals_data = result_map_column->get_values();
ColumnArray::Offsets64& column_offsets = result_map_column->get_offsets();
column_offsets.resize(input_rows_count);

if (result_nullable_column) {
auto& null_map_data = result_nullable_column->get_null_map_data();
null_map_data.resize_fill(input_rows_count, 0);
}

size_t off = 0;
for (size_t row = 0; row < input_rows_count; row++) {
for (size_t col : arguments) {
const ColumnMap* map_column = nullptr;
auto src_column =
block.get_by_position(col).column->convert_to_full_column_if_const();
if (src_column->is_nullable()) {
auto nullable_column = assert_cast<const ColumnNullable*>(src_column.get());
map_column = assert_cast<const ColumnMap*>(
nullable_column->get_nested_column_ptr().get());
} else {
map_column = assert_cast<const ColumnMap*>(src_column.get());
}
if (!map_column) {
return Status::RuntimeError("unsupported types for function {}({})", get_name(),
block.get_by_position(col).type->get_name());
}
const auto& src_column_offsets = map_column->get_offsets();
const size_t length = src_column_offsets[row] - src_column_offsets[row - 1];
off += length;
for (size_t i = src_column_offsets[row - 1]; i < src_column_offsets[row]; i++) {
result_col_map_keys_data.insert_from(map_column->get_keys(), i);
result_col_map_vals_data.insert_from(map_column->get_values(), i);
}
}
column_offsets[row] = off;
}
RETURN_IF_ERROR(result_map_column->deduplicate_keys());
block.replace_by_position(result, std::move(result_col));
return Status::OK();
}
};

void register_function_map(SimpleFunctionFactory& factory) {
factory.register_function<FunctionMap>();
factory.register_function<FunctionMapContains<true>>();
Expand All @@ -801,6 +874,7 @@ void register_function_map(SimpleFunctionFactory& factory) {
factory.register_function<FunctionMapEntries>();
factory.register_function<FunctionStrToMap>();
factory.register_function<FunctionMapContainsEntry>();
factory.register_function<FunctionMapConcat>();
factory.register_function<FunctionDeduplicateMap>();
}

Expand Down
Loading