nagisa-kunhah commented on code in PR #59130:
URL: https://github.com/apache/doris/pull/59130#discussion_r2648928886
##########
be/src/vec/functions/function_map.cpp:
##########
@@ -792,6 +793,74 @@ 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 {
+ DCHECK(arguments.size() > 0)
+ << "function: " << get_name() << ", arguments should not be
empty";
+ return arguments[0];
Review Comment:
Thank you for the review!
Yes, the return type is consistent with the FE logic. The BE receives
pre-processed types from FE, and all argument types are already unified at this
point.
For example, when running the SQL:
`select map_concat(map(1,2), map('3','4'));`
I verified this with GDB debugging at `function_map.cpp:806`. The results
show that FE has already performed type casting:
```
// arguments[0]: map(1,2) key type
(gdb) p
*(((DataTypeNullable*)((DataTypeMap*)arguments[0].get())->key_type.get())->nested_data_type.get())
$14 = (DataTypeString) { ... static PType = TYPE_STRING, _primitive_type =
TYPE_STRING }
// arguments[0]: map(1,2) value type
(gdb) p
*(((DataTypeNullable*)((DataTypeMap*)arguments[0].get())->value_type.get())->nested_data_type.get())
$15 = (DataTypeString) { ... static PType = TYPE_STRING, _primitive_type =
TYPE_STRING }
// arguments[1]: map('3','4') key type
(gdb) p
*(((DataTypeNullable*)((DataTypeMap*)arguments[1].get())->key_type.get())->nested_data_type.get())
$16 = (DataTypeString) { ... static PType = TYPE_STRING, _primitive_type =
TYPE_STRING }
// arguments[1]: map('3','4') value type
(gdb) p
*(((DataTypeNullable*)((DataTypeMap*)arguments[1].get())->value_type.get())->nested_data_type.get())
$17 = (DataTypeString) { ... static PType = TYPE_STRING, _primitive_type =
TYPE_STRING }
```
As you can see, both `map(1,2)` and `map('3','4')` have been converted to
`Map<String, String>` by FE before reaching BE. Therefore, returning
arguments[0] is safe and matches FE's type inference logic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]