diff --git a/be/src/vec/data_types/data_type_date.h b/be/src/vec/data_types/data_type_date.h index 0df23022e2b6d2..077ce33c58f025 100644 --- a/be/src/vec/data_types/data_type_date.h +++ b/be/src/vec/data_types/data_type_date.h @@ -55,7 +55,7 @@ class DataTypeDate final : public DataTypeNumberBase { doris::FieldType get_storage_field_type() const override { return doris::FieldType::OLAP_FIELD_TYPE_DATE; } - const char* get_family_name() const override { return "DateTime"; } + const char* get_family_name() const override { return "Date"; } std::string do_get_name() const override { return "Date"; } bool equals(const IDataType& rhs) const override; diff --git a/be/src/vec/functions/array/function_array_apply.cpp b/be/src/vec/functions/array/function_array_apply.cpp index 75425389dd975c..d01285e8f162ab 100644 --- a/be/src/vec/functions/array/function_array_apply.cpp +++ b/be/src/vec/functions/array/function_array_apply.cpp @@ -64,6 +64,8 @@ class FunctionArrayApply : public IFunction { size_t get_number_of_arguments() const override { return 3; } ColumnNumbers get_arguments_that_are_always_constant() const override { return {1, 2}; } + bool dont_append_return_type_name_when_register_function() override { return true; } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { DCHECK(is_array(arguments[0])) << "first argument for function: " << name << " should be DataTypeArray" diff --git a/be/src/vec/functions/array/function_array_binary.h b/be/src/vec/functions/array/function_array_binary.h index 3a134e7392a40c..dc060987d6389d 100644 --- a/be/src/vec/functions/array/function_array_binary.h +++ b/be/src/vec/functions/array/function_array_binary.h @@ -36,6 +36,8 @@ class FunctionArrayBinary : public IFunction { bool is_variadic() const override { return false; } size_t get_number_of_arguments() const override { return 2; } + bool dont_append_return_type_name_when_register_function() override { return true; } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { DCHECK(is_array(arguments[0])) << arguments[0]->get_name(); DCHECK(is_array(arguments[1])) << arguments[1]->get_name(); diff --git a/be/src/vec/functions/array/function_array_compact.h b/be/src/vec/functions/array/function_array_compact.h index ef4ae5a76ad892..aea8d4657977d9 100644 --- a/be/src/vec/functions/array/function_array_compact.h +++ b/be/src/vec/functions/array/function_array_compact.h @@ -56,6 +56,8 @@ class FunctionArrayCompact : public IFunction { bool is_variadic() const override { return false; } + bool dont_append_return_type_name_when_register_function() override { return true; } + size_t get_number_of_arguments() const override { return 1; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { diff --git a/be/src/vec/functions/array/function_array_concat.cpp b/be/src/vec/functions/array/function_array_concat.cpp index 18d0b7b48c14dc..f1f4061a418fc0 100644 --- a/be/src/vec/functions/array/function_array_concat.cpp +++ b/be/src/vec/functions/array/function_array_concat.cpp @@ -54,6 +54,7 @@ class FunctionArrayConcat : public IFunction { String get_name() const override { return name; } bool is_variadic() const override { return true; } + bool dont_append_return_type_name_when_register_function() override { return true; } size_t get_number_of_arguments() const override { return 1; } diff --git a/be/src/vec/functions/array/function_array_constructor.cpp b/be/src/vec/functions/array/function_array_constructor.cpp index 50c53697d2600d..49918979992e92 100644 --- a/be/src/vec/functions/array/function_array_constructor.cpp +++ b/be/src/vec/functions/array/function_array_constructor.cpp @@ -62,6 +62,8 @@ class FunctionArrayConstructor : public IFunction { size_t get_number_of_arguments() const override { return 0; } + bool dont_append_return_type_name_when_register_function() override { return true; } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { // we accept with empty argument, like array(), which will be treated as array(UInt8) if (arguments.empty()) { diff --git a/be/src/vec/functions/array/function_array_contains_all.cpp b/be/src/vec/functions/array/function_array_contains_all.cpp index c65ec57e3d6572..b920d34d951177 100644 --- a/be/src/vec/functions/array/function_array_contains_all.cpp +++ b/be/src/vec/functions/array/function_array_contains_all.cpp @@ -21,7 +21,9 @@ #include #include "common/status.h" +#include "vec/aggregate_functions/aggregate_function.h" #include "vec/common/assert_cast.h" +#include "vec/core/columns_with_type_and_name.h" #include "vec/data_types/data_type_array.h" #include "vec/data_types/data_type_number.h" #include "vec/functions/array/function_array_utils.h" @@ -42,18 +44,22 @@ class FunctionArrayContainsAll : public IFunction { size_t get_number_of_arguments() const override { return 2; } - DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - auto left_data_type = remove_nullable(arguments[0]); - auto right_data_type = remove_nullable(arguments[1]); - DCHECK(is_array(left_data_type)) << arguments[0]->get_name(); - DCHECK(is_array(right_data_type)) << arguments[1]->get_name(); + DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + auto left_data_type = remove_nullable(arguments[0].type); + auto right_data_type = remove_nullable(arguments[1].type); + DCHECK(is_array(left_data_type)) << arguments[0].type->get_name(); + DCHECK(is_array(right_data_type)) << arguments[1].type->get_name(); auto left_nested_type = remove_nullable( assert_cast(*left_data_type).get_nested_type()); auto right_nested_type = remove_nullable( assert_cast(*right_data_type).get_nested_type()); DCHECK(left_nested_type->equals(*right_nested_type)) - << "data type " << arguments[0]->get_name() << " not equal with " - << arguments[1]->get_name(); + << "data type " << arguments[0].type->get_name() << " not equal with " + << arguments[1].type->get_name(); + return std::make_shared(); + } + + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { return std::make_shared(); } diff --git a/be/src/vec/functions/array/function_array_cum_sum.cpp b/be/src/vec/functions/array/function_array_cum_sum.cpp index 2f93a2a83b1a89..5a41453a8213d4 100644 --- a/be/src/vec/functions/array/function_array_cum_sum.cpp +++ b/be/src/vec/functions/array/function_array_cum_sum.cpp @@ -52,6 +52,8 @@ class FunctionArrayCumSum : public IFunction { bool is_variadic() const override { return false; } + bool dont_append_return_type_name_when_register_function() override { return true; } + size_t get_number_of_arguments() const override { return 1; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { diff --git a/be/src/vec/functions/array/function_array_difference.h b/be/src/vec/functions/array/function_array_difference.h index 283ac206ce69b7..d5802a19990886 100644 --- a/be/src/vec/functions/array/function_array_difference.h +++ b/be/src/vec/functions/array/function_array_difference.h @@ -64,6 +64,8 @@ class FunctionArrayDifference : public IFunction { bool is_variadic() const override { return false; } + bool dont_append_return_type_name_when_register_function() override { return true; } + size_t get_number_of_arguments() const override { return 1; } bool use_default_implementation_for_nulls() const override { return true; } diff --git a/be/src/vec/functions/array/function_array_distinct.h b/be/src/vec/functions/array/function_array_distinct.h index 4b7e3e6f035d48..568833bf076bef 100644 --- a/be/src/vec/functions/array/function_array_distinct.h +++ b/be/src/vec/functions/array/function_array_distinct.h @@ -65,6 +65,8 @@ class FunctionArrayDistinct : public IFunction { bool is_variadic() const override { return false; } + bool dont_append_return_type_name_when_register_function() override { return true; } + size_t get_number_of_arguments() const override { return 1; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { diff --git a/be/src/vec/functions/array/function_array_element.h b/be/src/vec/functions/array/function_array_element.h index e4b57348c883ae..9687571740962b 100644 --- a/be/src/vec/functions/array/function_array_element.h +++ b/be/src/vec/functions/array/function_array_element.h @@ -73,6 +73,8 @@ class FunctionArrayElement : public IFunction { bool is_variadic() const override { return false; } + bool dont_append_return_type_name_when_register_function() override { return true; } + bool use_default_implementation_for_nulls() const override { return false; } size_t get_number_of_arguments() const override { return 2; } diff --git a/be/src/vec/functions/array/function_array_enumerate.cpp b/be/src/vec/functions/array/function_array_enumerate.cpp index 0e8bca3e5cd3b1..122faa2cf429e6 100644 --- a/be/src/vec/functions/array/function_array_enumerate.cpp +++ b/be/src/vec/functions/array/function_array_enumerate.cpp @@ -57,6 +57,8 @@ class FunctionArrayEnumerate : public IFunction { static FunctionPtr create() { return std::make_shared(); } String get_name() const override { return name; } size_t get_number_of_arguments() const override { return 1; } + + bool dont_append_return_type_name_when_register_function() override { return true; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { const DataTypeArray* array_type = check_and_get_data_type(remove_nullable(arguments[0]).get()); 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 21d6ab40007b6e..488e3f99a0fae4 100644 --- a/be/src/vec/functions/array/function_array_enumerate_uniq.cpp +++ b/be/src/vec/functions/array/function_array_enumerate_uniq.cpp @@ -74,6 +74,7 @@ class FunctionArrayEnumerateUniq : public IFunction { String get_name() const override { return name; } bool is_variadic() const override { return true; } size_t get_number_of_arguments() const override { return 1; } + bool dont_append_return_type_name_when_register_function() override { return true; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { if (arguments.empty()) { diff --git a/be/src/vec/functions/array/function_array_exists.cpp b/be/src/vec/functions/array/function_array_exists.cpp index 8621ecd35c0280..cf46c9e40abb38 100644 --- a/be/src/vec/functions/array/function_array_exists.cpp +++ b/be/src/vec/functions/array/function_array_exists.cpp @@ -56,6 +56,8 @@ class FunctionArrayExists : public IFunction { size_t get_number_of_arguments() const override { return 1; } + bool dont_append_return_type_name_when_register_function() override { return true; } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { DCHECK(is_array(arguments[0])) << "first argument for function: " << name << " should be DataTypeArray" diff --git a/be/src/vec/functions/array/function_array_filter.cpp b/be/src/vec/functions/array/function_array_filter.cpp index 1a9cc5105b0f58..a334801b5a5ee2 100644 --- a/be/src/vec/functions/array/function_array_filter.cpp +++ b/be/src/vec/functions/array/function_array_filter.cpp @@ -52,6 +52,7 @@ class FunctionArrayFilter : public IFunction { String get_name() const override { return name; } bool is_variadic() const override { return false; } + bool dont_append_return_type_name_when_register_function() override { return true; } size_t get_number_of_arguments() const override { return 2; } diff --git a/be/src/vec/functions/array/function_array_index.h b/be/src/vec/functions/array/function_array_index.h index e602d67a73b01c..a3e388bce04887 100644 --- a/be/src/vec/functions/array/function_array_index.h +++ b/be/src/vec/functions/array/function_array_index.h @@ -40,6 +40,7 @@ #include "vec/core/block.h" #include "vec/core/column_numbers.h" #include "vec/core/column_with_type_and_name.h" +#include "vec/core/columns_with_type_and_name.h" #include "vec/core/types.h" #include "vec/data_types/data_type.h" #include "vec/data_types/data_type_array.h" @@ -182,14 +183,18 @@ class FunctionArrayIndex : public IFunction { return Status::OK(); } - DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - if (arguments[0]->is_nullable()) { + DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + if (arguments[0].type->is_nullable()) { return make_nullable(std::make_shared>()); } else { return std::make_shared>(); } } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + return std::make_shared>(); + } + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, uint32_t result, size_t input_rows_count) const override { DBUG_EXECUTE_IF("array_func.array_contains", { diff --git a/be/src/vec/functions/array/function_array_join.h b/be/src/vec/functions/array/function_array_join.h index 957b2288fb746a..4944325970eca2 100644 --- a/be/src/vec/functions/array/function_array_join.h +++ b/be/src/vec/functions/array/function_array_join.h @@ -16,8 +16,12 @@ // under the License. #pragma once +#include + #include "vec/columns/column_array.h" #include "vec/columns/column_const.h" +#include "vec/core/columns_with_type_and_name.h" +#include "vec/data_types/data_type.h" #include "vec/data_types/data_type_array.h" #include "vec/data_types/data_type_number.h" #include "vec/data_types/data_type_string.h" @@ -55,6 +59,10 @@ struct ArrayJoinImpl { return std::make_shared(); } + static DataTypePtr get_return_type_impl(const DataTypes& arguments) { + return std::make_shared(); + } + static Status execute(Block& block, const ColumnNumbers& arguments, uint32_t result, const DataTypeArray* data_type_array, const ColumnArray& array) { ColumnPtr src_column = diff --git a/be/src/vec/functions/array/function_array_mapped.h b/be/src/vec/functions/array/function_array_mapped.h index 5c84baf9dfadb8..0697e1dffad62d 100644 --- a/be/src/vec/functions/array/function_array_mapped.h +++ b/be/src/vec/functions/array/function_array_mapped.h @@ -46,6 +46,8 @@ class FunctionArrayMapped : public IFunction { static constexpr auto name = Name::name; static FunctionPtr create() { return std::make_shared(); } + bool dont_append_return_type_name_when_register_function() override { return true; } + String get_name() const override { return name; } Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, uint32_t result, size_t input_rows_count) const override { diff --git a/be/src/vec/functions/array/function_array_nary.h b/be/src/vec/functions/array/function_array_nary.h index e9b2009f68484c..181206ae44031d 100644 --- a/be/src/vec/functions/array/function_array_nary.h +++ b/be/src/vec/functions/array/function_array_nary.h @@ -37,6 +37,8 @@ class FunctionArrayNary : public IFunction { bool is_variadic() const override { return true; } size_t get_number_of_arguments() const override { return 0; } + bool dont_append_return_type_name_when_register_function() override { return true; } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { DCHECK(arguments.size() >= 2) << "function: " << get_name() << ", arguments should large equals than 2"; diff --git a/be/src/vec/functions/array/function_array_pop.cpp b/be/src/vec/functions/array/function_array_pop.cpp index 2182699e0205b5..336096e8c125da 100644 --- a/be/src/vec/functions/array/function_array_pop.cpp +++ b/be/src/vec/functions/array/function_array_pop.cpp @@ -54,6 +54,7 @@ class FunctionArrayPop : public IFunction { bool is_variadic() const override { return false; } size_t get_number_of_arguments() const override { return 1; } + bool dont_append_return_type_name_when_register_function() override { return true; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { DCHECK(is_array(arguments[0])) diff --git a/be/src/vec/functions/array/function_array_pushback.cpp b/be/src/vec/functions/array/function_array_pushback.cpp index d1152ca9739b98..7d08d4f198af55 100644 --- a/be/src/vec/functions/array/function_array_pushback.cpp +++ b/be/src/vec/functions/array/function_array_pushback.cpp @@ -51,6 +51,7 @@ class FunctionArrayPushback : public IFunction { String get_name() const override { return name; } bool is_variadic() const override { return false; } + bool dont_append_return_type_name_when_register_function() override { return true; } size_t get_number_of_arguments() const override { return 2; } diff --git a/be/src/vec/functions/array/function_array_pushfront.cpp b/be/src/vec/functions/array/function_array_pushfront.cpp index c592999b108a35..ace7d27278b945 100644 --- a/be/src/vec/functions/array/function_array_pushfront.cpp +++ b/be/src/vec/functions/array/function_array_pushfront.cpp @@ -54,6 +54,7 @@ class FunctionArrayPushfront : public IFunction { bool is_variadic() const override { return false; } size_t get_number_of_arguments() const override { return 2; } + bool dont_append_return_type_name_when_register_function() override { return true; } bool use_default_implementation_for_nulls() const override { return false; } diff --git a/be/src/vec/functions/array/function_array_remove.h b/be/src/vec/functions/array/function_array_remove.h index 197b032b0f8a4b..c8f4c98b00bf10 100644 --- a/be/src/vec/functions/array/function_array_remove.h +++ b/be/src/vec/functions/array/function_array_remove.h @@ -63,6 +63,8 @@ class FunctionArrayRemove : public IFunction { bool is_variadic() const override { return false; } + bool dont_append_return_type_name_when_register_function() override { return true; } + size_t get_number_of_arguments() const override { return 2; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { diff --git a/be/src/vec/functions/array/function_array_shuffle.cpp b/be/src/vec/functions/array/function_array_shuffle.cpp index b9e3206ba0baa1..e37c60a8098cd2 100644 --- a/be/src/vec/functions/array/function_array_shuffle.cpp +++ b/be/src/vec/functions/array/function_array_shuffle.cpp @@ -57,6 +57,8 @@ class FunctionArrayShuffle : public IFunction { bool is_variadic() const override { return true; } + bool dont_append_return_type_name_when_register_function() override { return true; } + size_t get_number_of_arguments() const override { return 1; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { diff --git a/be/src/vec/functions/array/function_array_slice.h b/be/src/vec/functions/array/function_array_slice.h index 2acd1d3fbe1fd4..c1b5fc03c89750 100644 --- a/be/src/vec/functions/array/function_array_slice.h +++ b/be/src/vec/functions/array/function_array_slice.h @@ -51,6 +51,8 @@ class FunctionArraySlice : public IFunction { bool is_variadic() const override { return true; } + bool dont_append_return_type_name_when_register_function() override { return true; } + size_t get_number_of_arguments() const override { return 0; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { diff --git a/be/src/vec/functions/array/function_array_sort.h b/be/src/vec/functions/array/function_array_sort.h index 7b66336836ea12..c7cdc0e95947c9 100644 --- a/be/src/vec/functions/array/function_array_sort.h +++ b/be/src/vec/functions/array/function_array_sort.h @@ -53,6 +53,8 @@ class FunctionArraySort : public IFunction { bool is_variadic() const override { return false; } + bool dont_append_return_type_name_when_register_function() override { return true; } + size_t get_number_of_arguments() const override { return 1; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { diff --git a/be/src/vec/functions/array/function_array_sortby.cpp b/be/src/vec/functions/array/function_array_sortby.cpp index 899bb40fba1423..69ef7fdf66050c 100644 --- a/be/src/vec/functions/array/function_array_sortby.cpp +++ b/be/src/vec/functions/array/function_array_sortby.cpp @@ -58,6 +58,8 @@ class FunctionArraySortBy : public IFunction { bool use_default_implementation_for_nulls() const override { return false; } + bool dont_append_return_type_name_when_register_function() override { return true; } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { DCHECK(is_array(remove_nullable(arguments[0]))) << "first argument for function: " << name << " should be DataTypeArray" diff --git a/be/src/vec/functions/array/function_array_split.cpp b/be/src/vec/functions/array/function_array_split.cpp index 5e58a9f189a657..3459a7ce77baeb 100644 --- a/be/src/vec/functions/array/function_array_split.cpp +++ b/be/src/vec/functions/array/function_array_split.cpp @@ -55,6 +55,7 @@ class FunctionArraySplit : public IFunction { String get_name() const override { return name; } size_t get_number_of_arguments() const override { return 2; } + bool dont_append_return_type_name_when_register_function() override { return true; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { return std::make_shared(make_nullable(arguments[0])); diff --git a/be/src/vec/functions/array/function_array_with_constant.cpp b/be/src/vec/functions/array/function_array_with_constant.cpp index 7b9f3b43271f05..412580287fb58d 100644 --- a/be/src/vec/functions/array/function_array_with_constant.cpp +++ b/be/src/vec/functions/array/function_array_with_constant.cpp @@ -66,6 +66,7 @@ class FunctionArrayWithConstant : public IFunction { bool is_variadic() const override { return false; } size_t get_number_of_arguments() const override { return 2; } + bool dont_append_return_type_name_when_register_function() override { return true; } // need handle null cases bool use_default_implementation_for_nulls() const override { return false; } diff --git a/be/src/vec/functions/array/function_array_zip.cpp b/be/src/vec/functions/array/function_array_zip.cpp index 217a8039421a1c..108ca8a637d23f 100644 --- a/be/src/vec/functions/array/function_array_zip.cpp +++ b/be/src/vec/functions/array/function_array_zip.cpp @@ -60,6 +60,7 @@ class FunctionArrayZip : public IFunction { public: static constexpr auto name = "array_zip"; static FunctionPtr create() { return std::make_shared(); } + bool dont_append_return_type_name_when_register_function() override { return true; } /// Get function name. String get_name() const override { return name; } diff --git a/be/src/vec/functions/array/function_arrays_overlap.h b/be/src/vec/functions/array/function_arrays_overlap.h index dd993100885e3a..c549741c27668d 100644 --- a/be/src/vec/functions/array/function_arrays_overlap.h +++ b/be/src/vec/functions/array/function_arrays_overlap.h @@ -37,6 +37,7 @@ #include "vec/core/block.h" #include "vec/core/column_numbers.h" #include "vec/core/column_with_type_and_name.h" +#include "vec/core/columns_with_type_and_name.h" #include "vec/core/types.h" #include "vec/data_types/data_type.h" #include "vec/data_types/data_type_array.h" @@ -113,21 +114,25 @@ class FunctionArraysOverlap : public IFunction { size_t get_number_of_arguments() const override { return 2; } - DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - auto left_data_type = remove_nullable(arguments[0]); - auto right_data_type = remove_nullable(arguments[1]); - DCHECK(is_array(left_data_type)) << arguments[0]->get_name(); - DCHECK(is_array(right_data_type)) << arguments[1]->get_name(); + DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + auto left_data_type = remove_nullable(arguments[0].type); + auto right_data_type = remove_nullable(arguments[1].type); + DCHECK(is_array(left_data_type)) << arguments[0].type->get_name(); + DCHECK(is_array(right_data_type)) << arguments[1].type->get_name(); auto left_nested_type = remove_nullable( assert_cast(*left_data_type).get_nested_type()); auto right_nested_type = remove_nullable( assert_cast(*right_data_type).get_nested_type()); DCHECK(left_nested_type->equals(*right_nested_type)) - << "data type " << arguments[0]->get_name() << " not equal with " - << arguments[1]->get_name(); + << "data type " << arguments[0].type->get_name() << " not equal with " + << arguments[1].type->get_name(); return make_nullable(std::make_shared()); } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + return std::make_shared(); + } + /** * eval inverted index. we can filter array rows with inverted index iter * array_overlap(array, []) -> array_overlap(array, const value) diff --git a/be/src/vec/functions/function.cpp b/be/src/vec/functions/function.cpp index 851e430d2f0407..c5b43f05ced6f9 100644 --- a/be/src/vec/functions/function.cpp +++ b/be/src/vec/functions/function.cpp @@ -294,42 +294,9 @@ DataTypePtr FunctionBuilderImpl::get_return_type(const ColumnsWithTypeAndName& a return get_return_type_without_low_cardinality(arguments); } -bool FunctionBuilderImpl::is_date_or_datetime_or_decimal( - const DataTypePtr& return_type, const DataTypePtr& func_return_type) const { - return (is_date_or_datetime(return_type->is_nullable() - ? ((DataTypeNullable*)return_type.get())->get_nested_type() - : return_type) && - is_date_or_datetime( - func_return_type->is_nullable() - ? ((DataTypeNullable*)func_return_type.get())->get_nested_type() - : func_return_type)) || - (is_date_v2_or_datetime_v2( - return_type->is_nullable() - ? ((DataTypeNullable*)return_type.get())->get_nested_type() - : return_type) && - is_date_v2_or_datetime_v2( - func_return_type->is_nullable() - ? ((DataTypeNullable*)func_return_type.get())->get_nested_type() - : func_return_type)) || - // For some date functions such as str_to_date(string, string), return_type will - // be datetimev2 if users enable datev2 but get_return_type(arguments) will still - // return datetime. We need keep backward compatibility here. - (is_date_v2_or_datetime_v2( - return_type->is_nullable() - ? ((DataTypeNullable*)return_type.get())->get_nested_type() - : return_type) && - is_date_or_datetime( - func_return_type->is_nullable() - ? ((DataTypeNullable*)func_return_type.get())->get_nested_type() - : func_return_type)) || - (is_date_or_datetime(return_type->is_nullable() - ? ((DataTypeNullable*)return_type.get())->get_nested_type() - : return_type) && - is_date_v2_or_datetime_v2( - func_return_type->is_nullable() - ? ((DataTypeNullable*)func_return_type.get())->get_nested_type() - : func_return_type)) || - (is_decimal(return_type->is_nullable() +bool FunctionBuilderImpl::is_type_decimal(const DataTypePtr& return_type, + const DataTypePtr& func_return_type) const { + return (is_decimal(return_type->is_nullable() ? ((DataTypeNullable*)return_type.get())->get_nested_type() : return_type) && is_decimal(func_return_type->is_nullable() @@ -337,8 +304,8 @@ bool FunctionBuilderImpl::is_date_or_datetime_or_decimal( : func_return_type)); } -bool FunctionBuilderImpl::is_array_nested_type_date_or_datetime_or_decimal( - const DataTypePtr& return_type, const DataTypePtr& func_return_type) const { +bool FunctionBuilderImpl::is_array_nested_type_decimal(const DataTypePtr& return_type, + const DataTypePtr& func_return_type) const { auto return_type_ptr = return_type->is_nullable() ? ((DataTypeNullable*)return_type.get())->get_nested_type() : return_type; @@ -360,7 +327,7 @@ bool FunctionBuilderImpl::is_array_nested_type_date_or_datetime_or_decimal( ((DataTypeNullable*)(nested_nullable_return_type_ptr.get()))->get_nested_type(); auto nested_func_return_type_ptr = ((DataTypeNullable*)(nested_nullable_func_return_type.get()))->get_nested_type(); - return is_date_or_datetime_or_decimal(nested_return_type_ptr, nested_func_return_type_ptr); + return is_type_decimal(nested_return_type_ptr, nested_func_return_type_ptr); } return false; } diff --git a/be/src/vec/functions/function.h b/be/src/vec/functions/function.h index 92282c483948e6..fd021e492d49f6 100644 --- a/be/src/vec/functions/function.h +++ b/be/src/vec/functions/function.h @@ -272,8 +272,8 @@ class FunctionBuilderImpl : public IFunctionBuilder { // Nullable when `use_default_implementation_for_nulls` is true. (return_type->is_nullable() && func_return_type->is_nullable() && is_nothing(((DataTypeNullable*)func_return_type.get())->get_nested_type())) || - is_date_or_datetime_or_decimal(return_type, func_return_type) || - is_array_nested_type_date_or_datetime_or_decimal(return_type, func_return_type))) { + is_type_decimal(return_type, func_return_type) || + is_array_nested_type_decimal(return_type, func_return_type))) { LOG_WARNING( "function return type check failed, function_name={}, " "expect_return_type={}, real_return_type={}, input_arguments={}", @@ -299,6 +299,10 @@ class FunctionBuilderImpl : public IFunctionBuilder { ColumnNumbers get_arguments_that_are_always_constant() const override { return {}; } + // if a function's get_variadic_argument_types() not override and get_return_type_impl() + // result is not compile time be sure, the function should override return true + virtual bool dont_append_return_type_name_when_register_function() { return false; } + protected: // Get the result type by argument type. If the function does not apply to these arguments, throw an exception. // the get_return_type_impl and its overrides should only return the nested type if `use_default_implementation_for_nulls` is true. @@ -342,13 +346,14 @@ class FunctionBuilderImpl : public IFunctionBuilder { virtual DataTypes get_variadic_argument_types_impl() const { return {}; } private: + friend class SimpleFunctionFactory; + DataTypePtr get_return_type_without_low_cardinality( const ColumnsWithTypeAndName& arguments) const; - bool is_date_or_datetime_or_decimal(const DataTypePtr& return_type, - const DataTypePtr& func_return_type) const; - bool is_array_nested_type_date_or_datetime_or_decimal( - const DataTypePtr& return_type, const DataTypePtr& func_return_type) const; + bool is_type_decimal(const DataTypePtr& return_type, const DataTypePtr& func_return_type) const; + bool is_array_nested_type_decimal(const DataTypePtr& return_type, + const DataTypePtr& func_return_type) const; }; /// Previous function interface. @@ -532,6 +537,9 @@ class DefaultFunctionBuilder : public FunctionBuilderImpl { String get_name() const override { return function->get_name(); } bool is_variadic() const override { return function->is_variadic(); } + bool dont_append_return_type_name_when_register_function() override { + return function->dont_append_return_type_name_when_register_function(); + } size_t get_number_of_arguments() const override { return function->get_number_of_arguments(); } ColumnNumbers get_arguments_that_are_always_constant() const override { diff --git a/be/src/vec/functions/function_binary_arithmetic.h b/be/src/vec/functions/function_binary_arithmetic.h index 4c0b8e7a0890dc..1a5f43e98869e9 100644 --- a/be/src/vec/functions/function_binary_arithmetic.h +++ b/be/src/vec/functions/function_binary_arithmetic.h @@ -974,6 +974,8 @@ class FunctionBinaryArithmetic : public IFunction { size_t get_number_of_arguments() const override { return 2; } + bool dont_append_return_type_name_when_register_function() override { return true; } + DataTypes get_variadic_argument_types_impl() const override { if constexpr (OpTraits::has_variadic_argument) { return OpTraits::Op::get_variadic_argument_types(); diff --git a/be/src/vec/functions/function_case.h b/be/src/vec/functions/function_case.h index af44ea0d9b1ace..9e73f171668557 100644 --- a/be/src/vec/functions/function_case.h +++ b/be/src/vec/functions/function_case.h @@ -127,6 +127,7 @@ class FunctionCase : public IFunction { static constexpr auto name = FunctionCaseName::name; static FunctionPtr create() { return std::make_shared(); } String get_name() const override { return name; } + bool dont_append_return_type_name_when_register_function() override { return true; } size_t get_number_of_arguments() const override { return 0; } bool is_variadic() const override { return true; } diff --git a/be/src/vec/functions/function_cast.h b/be/src/vec/functions/function_cast.h index 3ad456d60d201f..dc9a2daf146250 100644 --- a/be/src/vec/functions/function_cast.h +++ b/be/src/vec/functions/function_cast.h @@ -1140,7 +1140,7 @@ class FunctionConvert : public IFunction { // This function should not be called for get DateType Ptr // using the FunctionCast::get_return_type_impl - DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + DataTypePtr get_return_type_impl(const DataTypes& types) const override { return std::make_shared(); } @@ -1465,7 +1465,7 @@ class FunctionConvertFromString : public IFunction { // This function should not be called for get DateType Ptr // using the FunctionCast::get_return_type_impl - DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + DataTypePtr get_return_type_impl(const DataTypes& types) const override { DataTypePtr res; if constexpr (IsDataTypeDecimal) { auto error_type = std::make_shared(); @@ -1511,7 +1511,7 @@ class FunctionConvertToTimeType : public IFunction { // This function should not be called for get DateType Ptr // using the FunctionCast::get_return_type_impl - DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { return std::make_shared(); } @@ -2362,6 +2362,8 @@ class FunctionBuilderCast : public FunctionBuilderImpl { ColumnNumbers get_arguments_that_are_always_constant() const override { return {1}; } + bool dont_append_return_type_name_when_register_function() override { return true; } + protected: FunctionBasePtr build_impl(const ColumnsWithTypeAndName& arguments, const DataTypePtr& return_type) const override { @@ -2381,16 +2383,7 @@ class FunctionBuilderCast : public FunctionBuilderImpl { // 2. from_type is string, to_type is not string need_to_be_nullable |= (arguments[0].type->get_type_id() == TypeIndex::String) && (type->get_type_id() != TypeIndex::String); - // 3. from_type is not DateTime/Date, to_type is DateTime/Date - need_to_be_nullable |= (arguments[0].type->get_type_id() != TypeIndex::Date && - arguments[0].type->get_type_id() != TypeIndex::DateTime) && - (type->get_type_id() == TypeIndex::Date || - type->get_type_id() == TypeIndex::DateTime); - // 4. from_type is not DateTimeV2/DateV2, to_type is DateTimeV2/DateV2 - need_to_be_nullable |= (arguments[0].type->get_type_id() != TypeIndex::DateV2 && - arguments[0].type->get_type_id() != TypeIndex::DateTimeV2) && - (type->get_type_id() == TypeIndex::DateV2 || - type->get_type_id() == TypeIndex::DateTimeV2); + if (need_to_be_nullable && !type->is_nullable()) { return make_nullable(type); } diff --git a/be/src/vec/functions/function_coalesce.cpp b/be/src/vec/functions/function_coalesce.cpp index 6e5db15d160c06..4051aeeb08b11e 100644 --- a/be/src/vec/functions/function_coalesce.cpp +++ b/be/src/vec/functions/function_coalesce.cpp @@ -62,6 +62,8 @@ class FunctionCoalesce : public IFunction { String get_name() const override { return name; } + bool dont_append_return_type_name_when_register_function() override { return true; } + bool use_default_implementation_for_nulls() const override { return false; } bool is_variadic() const override { return true; } diff --git a/be/src/vec/functions/function_date_or_datetime_computation.cpp b/be/src/vec/functions/function_date_or_datetime_computation.cpp index f6bf806ad46c1d..e1154b8448346b 100644 --- a/be/src/vec/functions/function_date_or_datetime_computation.cpp +++ b/be/src/vec/functions/function_date_or_datetime_computation.cpp @@ -21,24 +21,53 @@ namespace doris::vectorized { -using FunctionAddSeconds = FunctionDateOrDateTimeComputation>; -using FunctionAddMinutes = FunctionDateOrDateTimeComputation>; -using FunctionAddHours = FunctionDateOrDateTimeComputation>; -using FunctionAddDays = FunctionDateOrDateTimeComputation>; -using FunctionAddWeeks = FunctionDateOrDateTimeComputation>; -using FunctionAddMonths = FunctionDateOrDateTimeComputation>; -using FunctionAddQuarters = FunctionDateOrDateTimeComputation>; -using FunctionAddYears = FunctionDateOrDateTimeComputation>; - -using FunctionSubSeconds = FunctionDateOrDateTimeComputation>; -using FunctionSubMinutes = FunctionDateOrDateTimeComputation>; -using FunctionSubHours = FunctionDateOrDateTimeComputation>; -using FunctionSubDays = FunctionDateOrDateTimeComputation>; -using FunctionSubWeeks = FunctionDateOrDateTimeComputation>; -using FunctionSubMonths = FunctionDateOrDateTimeComputation>; -using FunctionSubQuarters = +using FunctionDatetimeAddSeconds = + FunctionDateOrDateTimeComputation>; +using FunctionDatetimeAddMinutes = + FunctionDateOrDateTimeComputation>; +using FunctionDatetimeAddHours = FunctionDateOrDateTimeComputation>; +using FunctionDatetimeAddDays = FunctionDateOrDateTimeComputation>; +using FunctionDatetimeAddWeeks = FunctionDateOrDateTimeComputation>; +using FunctionDatetimeAddMonths = + FunctionDateOrDateTimeComputation>; +using FunctionDatetimeAddQuarters = + FunctionDateOrDateTimeComputation>; +using FunctionDatetimeAddYears = FunctionDateOrDateTimeComputation>; + +using FunctionAddSeconds = FunctionDateOrDateTimeComputation>; +using FunctionAddMinutes = FunctionDateOrDateTimeComputation>; +using FunctionAddHours = FunctionDateOrDateTimeComputation>; +using FunctionAddDays = FunctionDateOrDateTimeComputation>; +using FunctionAddWeeks = FunctionDateOrDateTimeComputation>; +using FunctionAddMonths = FunctionDateOrDateTimeComputation>; +using FunctionAddQuarters = FunctionDateOrDateTimeComputation>; +using FunctionAddYears = FunctionDateOrDateTimeComputation>; + +using FunctionDatetimeSubSeconds = + FunctionDateOrDateTimeComputation>; +using FunctionDatetimeSubMinutes = + FunctionDateOrDateTimeComputation>; +using FunctionDatetimeSubHours = + FunctionDateOrDateTimeComputation>; +using FunctionDatetimeSubDays = + FunctionDateOrDateTimeComputation>; +using FunctionDatetimeSubWeeks = + FunctionDateOrDateTimeComputation>; +using FunctionDatetimeSubMonths = + FunctionDateOrDateTimeComputation>; +using FunctionDatetimeSubQuarters = FunctionDateOrDateTimeComputation>; -using FunctionSubYears = FunctionDateOrDateTimeComputation>; +using FunctionDatetimeSubYears = + FunctionDateOrDateTimeComputation>; + +using FunctionSubSeconds = FunctionDateOrDateTimeComputation>; +using FunctionSubMinutes = FunctionDateOrDateTimeComputation>; +using FunctionSubHours = FunctionDateOrDateTimeComputation>; +using FunctionSubDays = FunctionDateOrDateTimeComputation>; +using FunctionSubWeeks = FunctionDateOrDateTimeComputation>; +using FunctionSubMonths = FunctionDateOrDateTimeComputation>; +using FunctionSubQuarters = FunctionDateOrDateTimeComputation>; +using FunctionSubYears = FunctionDateOrDateTimeComputation>; using FunctionDateDiff = FunctionDateOrDateTimeComputation>; @@ -94,6 +123,15 @@ using FunctionMilliSecToDateTime = TimestampToDateTime; using FunctionSecToDateTime = TimestampToDateTime; void register_function_date_time_computation(SimpleFunctionFactory& factory) { + factory.register_function(); + factory.register_function(); + factory.register_function(); + factory.register_function(); + factory.register_function(); + factory.register_function(); + factory.register_function(); + factory.register_function(); + factory.register_function(); factory.register_function(); factory.register_function(); @@ -103,6 +141,15 @@ void register_function_date_time_computation(SimpleFunctionFactory& factory) { factory.register_function(); factory.register_function(); + factory.register_function(); + factory.register_function(); + factory.register_function(); + factory.register_function(); + factory.register_function(); + factory.register_function(); + factory.register_function(); + factory.register_function(); + factory.register_function(); factory.register_function(); factory.register_function(); diff --git a/be/src/vec/functions/function_date_or_datetime_computation.h b/be/src/vec/functions/function_date_or_datetime_computation.h index 330ea75cba96c8..cd296f2bc08f95 100644 --- a/be/src/vec/functions/function_date_or_datetime_computation.h +++ b/be/src/vec/functions/function_date_or_datetime_computation.h @@ -89,7 +89,15 @@ extern ResultType date_time_add(const Arg& t, Int64 delta, bool& is_null) { template \ struct CLASS { \ using ReturnType = std::conditional_t< \ - date_cast::IsV1(), DataTypeDateTime, \ + date_cast::IsV1(), \ + std::conditional_t< \ + std::is_same_v, \ + std::conditional_t, \ + DataTypeDateTime>, \ std::conditional_t< \ std::is_same_v, \ std::conditional_t>; \ static constexpr auto name = #NAME; \ static constexpr auto is_nullable = true; \ + static bool dont_append_return_type_name_when_register_function() { \ + return false; \ + } \ static inline ReturnNativeType execute(const InputNativeType& t, Int64 delta, \ bool& is_null) { \ if constexpr (std::is_same_v || \ @@ -162,6 +173,7 @@ struct AddQuartersImpl { Int64, std::conditional_t, UInt32, UInt64>>; static constexpr auto name = "quarters_add"; static constexpr auto is_nullable = true; + static bool dont_append_return_type_name_when_register_function() { return false; } static inline ReturnNativeType execute(const InputNativeType& t, Int64 delta, bool& is_null) { if constexpr (std::is_same_v || std::is_same_v) { @@ -184,6 +196,9 @@ template struct SubtractIntervalImpl { using ReturnType = typename Transform::ReturnType; using InputNativeType = typename Transform::InputNativeType; + static bool dont_append_return_type_name_when_register_function() { + return Transform::dont_append_return_type_name_when_register_function(); + } static constexpr auto is_nullable = true; static inline Int64 execute(const InputNativeType& t, Int64 delta, bool& is_null) { return Transform::execute(t, -delta, is_null); @@ -262,6 +277,9 @@ struct SubtractYearsImpl : SubtractIntervalImpl, DateType std::conditional_t, \ DateV2Value, VecDateTimeValue>>; \ using ReturnType = RETURN_TYPE; \ + static bool dont_append_return_type_name_when_register_function() { \ + return false; \ + } \ static constexpr auto name = #FN_NAME; \ static constexpr auto is_nullable = false; \ static inline ReturnType::FieldType execute(const ArgType1& t0, const ArgType2& t1, \ @@ -288,6 +306,7 @@ struct TimeDiffImpl { date_cast::IsV2() || date_cast::IsV2(); using ReturnType = DataTypeTimeV2; + static bool dont_append_return_type_name_when_register_function() { return false; } static constexpr auto name = "timediff"; static constexpr int64_t limit_value = 3020399000000; // 838:59:59 convert to microsecond @@ -339,6 +358,9 @@ TIME_DIFF_FUNCTION_IMPL(MicroSecondsDiffImpl, microseconds_diff, MICROSECOND); std::conditional_t, \ DateV2Value, VecDateTimeValue>>; \ using ReturnType = RETURN_TYPE; \ + static bool dont_append_return_type_name_when_register_function() { \ + return false; \ + } \ static constexpr auto name = #NAME; \ static constexpr auto is_nullable = false; \ static inline ReturnType::FieldType execute(const ArgType& t0, const Int32 mode, \ @@ -704,6 +726,10 @@ class FunctionDateOrDateTimeComputation : public IFunction { String get_name() const override { return name; } + bool dont_append_return_type_name_when_register_function() override { + return Transform::dont_append_return_type_name_when_register_function(); + } + bool is_variadic() const override { return true; } size_t get_number_of_arguments() const override { return 0; } @@ -746,6 +772,10 @@ class FunctionDateOrDateTimeComputation : public IFunction { RETURN_REAL_TYPE_FOR_DATEV2_FUNCTION(typename Transform::ReturnType); } + DataTypePtr get_return_type_impl(const DataTypes& types) const override { + return std::make_shared(); + } + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, uint32_t result, size_t input_rows_count) const override { const auto& first_arg_type = block.get_by_position(arguments[0]).type; @@ -815,6 +845,10 @@ class FunctionCurrentDateOrDateTime : public IFunction { return std::make_shared(); } + DataTypePtr get_return_type_impl(const DataTypes& types) const override { + return std::make_shared(); + } + bool is_variadic() const override { return true; } DataTypes get_variadic_argument_types_impl() const override { @@ -835,6 +869,7 @@ struct CurrentDateTimeImpl { static constexpr auto name = FunctionName::name; using ReturnType = std::conditional_t; + static bool dont_append_return_type_name_when_register_function() { return false; } static DataTypes get_variadic_argument_types() { if constexpr (WithPrecision) { return {std::make_shared()}; @@ -1067,6 +1102,10 @@ struct TimestampToDateTime : IFunction { return make_nullable(std::make_shared()); } + DataTypePtr get_return_type_impl(const DataTypes& types) const override { + return std::make_shared(); + } + static FunctionPtr create() { return std::make_shared>(); } Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, @@ -1159,10 +1198,7 @@ class CurrentDateFunctionBuilder : public FunctionBuilderImpl { protected: DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - return make_nullable(std::make_shared()); - } - DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { - return make_nullable(std::make_shared()); + return std::make_shared(); } bool use_default_implementation_for_nulls() const override { return false; } diff --git a/be/src/vec/functions/function_date_or_datetime_to_something.h b/be/src/vec/functions/function_date_or_datetime_to_something.h index 2bc96cc7e937d7..6424fca9eb1d0e 100644 --- a/be/src/vec/functions/function_date_or_datetime_to_something.h +++ b/be/src/vec/functions/function_date_or_datetime_to_something.h @@ -20,6 +20,7 @@ #pragma once +#include "vec/aggregate_functions/aggregate_function.h" #include "vec/data_types/data_type_date.h" #include "vec/functions/date_time_transforms.h" #include "vec/functions/function.h" @@ -90,6 +91,10 @@ class FunctionDateOrDateTimeToSomething : public IFunction { RETURN_REAL_TYPE_FOR_DATEV2_FUNCTION(ToDataType); } + DataTypePtr get_return_type_impl(const DataTypes& types) const override { + return std::make_shared(); + } + ColumnNumbers get_arguments_that_are_always_constant() const override { return {1}; } bool use_default_implementation_for_nulls() const override { return false; } diff --git a/be/src/vec/functions/function_date_or_datetime_to_string.h b/be/src/vec/functions/function_date_or_datetime_to_string.h index 14e8335388b2dc..4e30db19dc80fb 100644 --- a/be/src/vec/functions/function_date_or_datetime_to_string.h +++ b/be/src/vec/functions/function_date_or_datetime_to_string.h @@ -70,6 +70,10 @@ class FunctionDateOrDateTimeToString : public IFunction { RETURN_REAL_TYPE_FOR_DATEV2_FUNCTION(DataTypeString); } + DataTypePtr get_return_type_impl(const DataTypes& types) const override { + return std::make_shared(); + } + bool is_variadic() const override { return true; } DataTypes get_variadic_argument_types_impl() const override { diff --git a/be/src/vec/functions/function_datetime_string_to_string.h b/be/src/vec/functions/function_datetime_string_to_string.h index 5dfa32e0c9fac3..bd69b85b2762a6 100644 --- a/be/src/vec/functions/function_datetime_string_to_string.h +++ b/be/src/vec/functions/function_datetime_string_to_string.h @@ -126,6 +126,10 @@ class FunctionDateTimeStringToString : public IFunction { return make_nullable(std::make_shared()); } + DataTypePtr get_return_type_impl(const DataTypes& types) const override { + return std::make_shared(); + } + bool use_default_implementation_for_nulls() const override { return false; } ColumnNumbers get_arguments_that_are_always_constant() const override { return {1}; } diff --git a/be/src/vec/functions/function_fake.cpp b/be/src/vec/functions/function_fake.cpp index 646da600b50c13..1b28cd90f88183 100644 --- a/be/src/vec/functions/function_fake.cpp +++ b/be/src/vec/functions/function_fake.cpp @@ -42,6 +42,7 @@ namespace doris::vectorized { template struct FunctionFakeBaseImpl { + static bool dont_append_return_type_name_when_register_function() { return false; } static DataTypePtr get_return_type_impl(const DataTypes& arguments) { if constexpr (AlwaysNullable) { return make_nullable(std::make_shared()); @@ -62,6 +63,7 @@ struct FunctionFakeBaseImpl { }; struct FunctionExplode { + static bool dont_append_return_type_name_when_register_function() { return true; } static DataTypePtr get_return_type_impl(const DataTypes& arguments) { DCHECK(is_array(arguments[0])) << arguments[0]->get_name() << " not supported"; return make_nullable( @@ -73,6 +75,7 @@ struct FunctionExplode { // explode map: make map k,v as struct field struct FunctionExplodeMap { + static bool dont_append_return_type_name_when_register_function() { return true; } static DataTypePtr get_return_type_impl(const DataTypes& arguments) { DCHECK(is_map(arguments[0])) << arguments[0]->get_name() << " not supported"; DataTypes fieldTypes(2); @@ -86,6 +89,7 @@ struct FunctionExplodeMap { template struct FunctionPoseExplode { + static bool dont_append_return_type_name_when_register_function() { return true; } static DataTypePtr get_return_type_impl(const DataTypes& arguments) { DCHECK(is_array(arguments[0])) << arguments[0]->get_name() << " not supported"; DataTypes fieldTypes(2); @@ -105,6 +109,7 @@ struct FunctionPoseExplode { // explode json-object: expands json-object to struct with a pair of key and value in column string struct FunctionExplodeJsonObject { + static bool dont_append_return_type_name_when_register_function() { return true; } static DataTypePtr get_return_type_impl(const DataTypes& arguments) { DCHECK(WhichDataType(arguments[0]).is_json()) << " explode json object " << arguments[0]->get_name() << " not supported"; @@ -118,6 +123,7 @@ struct FunctionExplodeJsonObject { }; struct FunctionEsquery { + static bool dont_append_return_type_name_when_register_function() { return false; } static DataTypePtr get_return_type_impl(const DataTypes& arguments) { return FunctionFakeBaseImpl::get_return_type_impl(arguments); } diff --git a/be/src/vec/functions/function_fake.h b/be/src/vec/functions/function_fake.h index dabb5eb039afb7..0c9e3aef4acac4 100644 --- a/be/src/vec/functions/function_fake.h +++ b/be/src/vec/functions/function_fake.h @@ -38,6 +38,7 @@ class Block; namespace doris::vectorized { struct UDTFImpl { + static bool dont_append_return_type_name_when_register_function() { return false; } static DataTypePtr get_return_type_impl(const DataTypes& arguments) { return std::make_shared(); //just fake return uint8 } @@ -51,6 +52,10 @@ struct UDTFImpl { template class FunctionFake : public IFunction { public: + bool dont_append_return_type_name_when_register_function() override { + return Impl::dont_append_return_type_name_when_register_function(); + } + static constexpr auto name = "fake"; static FunctionPtr create() { return std::make_shared(); } @@ -70,10 +75,7 @@ class FunctionFake : public IFunction { } bool use_default_implementation_for_nulls() const override { - if constexpr (std::is_same_v) { - return false; - } - return true; + return !static_cast(std::is_same_v); } bool use_default_implementation_for_constants() const override { return false; } diff --git a/be/src/vec/functions/function_grouping.h b/be/src/vec/functions/function_grouping.h index 0917b4d1db89ec..67abc6d7219d85 100644 --- a/be/src/vec/functions/function_grouping.h +++ b/be/src/vec/functions/function_grouping.h @@ -52,6 +52,10 @@ class FunctionGroupingBase : public IFunction { return std::make_shared(); } + DataTypePtr get_return_type_impl(const DataTypes& types) const override { + return std::make_shared(); + } + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, uint32_t result, size_t input_rows_count) const override { const ColumnWithTypeAndName& src_column = block.get_by_position(arguments[0]); diff --git a/be/src/vec/functions/function_ifnull.h b/be/src/vec/functions/function_ifnull.h index 9cd1ef5b36e0ca..ae38d5a0ac35de 100644 --- a/be/src/vec/functions/function_ifnull.h +++ b/be/src/vec/functions/function_ifnull.h @@ -55,6 +55,8 @@ class FunctionIfNull : public IFunction { String get_name() const override { return name; } + bool dont_append_return_type_name_when_register_function() override { return true; } + size_t get_number_of_arguments() const override { return 2; } // be compatible with fe code diff --git a/be/src/vec/functions/function_json.cpp b/be/src/vec/functions/function_json.cpp index c53b31d7ec69f6..f6a3b3f3464b17 100644 --- a/be/src/vec/functions/function_json.cpp +++ b/be/src/vec/functions/function_json.cpp @@ -41,6 +41,7 @@ #include "common/compiler_util.h" // IWYU pragma: keep #include "common/status.h" #include "exprs/json_functions.h" +#include "vec/core/columns_with_type_and_name.h" #include "vec/io/io_helper.h" #ifdef __AVX2__ #include "util/jsonb_parser_simd.h" @@ -1396,11 +1397,11 @@ class FunctionJsonModifyImpl : public IFunction { bool use_default_implementation_for_nulls() const override { return false; } - DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { bool is_nullable = false; // arguments: (json_str, path, val[, path, val...], type_flag) for (auto col = 0; col < arguments.size() - 1; col += 1) { - if (arguments[col]->is_nullable()) { + if (arguments[col].type->is_nullable()) { is_nullable = true; break; } @@ -1409,6 +1410,10 @@ class FunctionJsonModifyImpl : public IFunction { : std::make_shared(); } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + return std::make_shared(); + } + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, uint32_t result, size_t input_rows_count) const override { auto result_column = ColumnString::create(); diff --git a/be/src/vec/functions/function_jsonb.cpp b/be/src/vec/functions/function_jsonb.cpp index 463508169aadc6..701302bee8e760 100644 --- a/be/src/vec/functions/function_jsonb.cpp +++ b/be/src/vec/functions/function_jsonb.cpp @@ -33,6 +33,7 @@ #include "udf/udf.h" #include "util/jsonb_document.h" #include "util/jsonb_error.h" +#include "vec/core/columns_with_type_and_name.h" #ifdef __AVX2__ #include "util/jsonb_parser_simd.h" #else @@ -136,7 +137,7 @@ class FunctionJsonbParseBase : public IFunction { } } - DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { bool is_nullable = true; switch (nullable_mode) { case NullalbeMode::NULLABLE: @@ -146,7 +147,7 @@ class FunctionJsonbParseBase : public IFunction { is_nullable = false; break; case NullalbeMode::FOLLOW_INPUT: - is_nullable = arguments[0]->is_nullable(); + is_nullable = arguments[0].type->is_nullable(); break; } @@ -154,6 +155,10 @@ class FunctionJsonbParseBase : public IFunction { : std::make_shared(); } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + return std::make_shared(); + } + bool use_default_implementation_for_nulls() const override { return false; } Status open(FunctionContext* context, FunctionContext::FunctionStateScope scope) override { diff --git a/be/src/vec/functions/function_map.cpp b/be/src/vec/functions/function_map.cpp index 5b4e4202b20de8..2252cde721a225 100644 --- a/be/src/vec/functions/function_map.cpp +++ b/be/src/vec/functions/function_map.cpp @@ -68,6 +68,8 @@ class FunctionMap : public IFunction { bool is_variadic() const override { return true; } + bool dont_append_return_type_name_when_register_function() override { return true; } + bool use_default_implementation_for_nulls() const override { return false; } size_t get_number_of_arguments() const override { return 0; } @@ -140,6 +142,8 @@ class FunctionMapContains : public IFunction { bool is_variadic() const override { return false; } + bool dont_append_return_type_name_when_register_function() override { return true; } + size_t get_number_of_arguments() const override { return 2; } bool use_default_implementation_for_nulls() const override { @@ -243,6 +247,8 @@ class FunctionMapEntries : public IFunction { bool is_variadic() const override { return false; } + bool dont_append_return_type_name_when_register_function() override { return true; } + size_t get_number_of_arguments() const override { return 1; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { diff --git a/be/src/vec/functions/function_multi_same_args.h b/be/src/vec/functions/function_multi_same_args.h index f22bae640aeda4..a93d72cd0a130e 100644 --- a/be/src/vec/functions/function_multi_same_args.h +++ b/be/src/vec/functions/function_multi_same_args.h @@ -36,6 +36,8 @@ class FunctionMultiSameArgs : public IFunction { bool use_default_implementation_for_nulls() const override { return true; } + bool dont_append_return_type_name_when_register_function() override { return true; } + bool is_variadic() const override { return true; } size_t get_number_of_arguments() const override { return 0; } diff --git a/be/src/vec/functions/function_nullables.cpp b/be/src/vec/functions/function_nullables.cpp index 91bce24f48fc8b..64f590f153886b 100644 --- a/be/src/vec/functions/function_nullables.cpp +++ b/be/src/vec/functions/function_nullables.cpp @@ -40,6 +40,8 @@ class FunctionNullable : public IFunction { static FunctionPtr create() { return std::make_shared(); } + bool dont_append_return_type_name_when_register_function() override { return true; } + String get_name() const override { return name; } size_t get_number_of_arguments() const override { return 1; } @@ -73,6 +75,8 @@ class FunctionNonNullable : public IFunction { String get_name() const override { return name; } + bool dont_append_return_type_name_when_register_function() override { return true; } + size_t get_number_of_arguments() const override { return 1; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { diff --git a/be/src/vec/functions/function_reverse.h b/be/src/vec/functions/function_reverse.h index ee0005a305d8ce..67963764a6f837 100644 --- a/be/src/vec/functions/function_reverse.h +++ b/be/src/vec/functions/function_reverse.h @@ -29,6 +29,8 @@ class FunctionReverseCommon : public IFunction { String get_name() const override { return name; } + bool dont_append_return_type_name_when_register_function() override { return true; } + size_t get_number_of_arguments() const override { return 1; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { diff --git a/be/src/vec/functions/function_size.cpp b/be/src/vec/functions/function_size.cpp index 68c873c8ea6c4b..1feee37d2d9a2d 100644 --- a/be/src/vec/functions/function_size.cpp +++ b/be/src/vec/functions/function_size.cpp @@ -15,9 +15,13 @@ // specific language governing permissions and limitations // under the License. +#include + #include "simple_function_factory.h" +#include "vec/aggregate_functions/aggregate_function.h" #include "vec/columns/column_array.h" #include "vec/columns/column_map.h" +#include "vec/core/columns_with_type_and_name.h" #include "vec/data_types/data_type_array.h" #include "vec/data_types/data_type_number.h" #include "vec/functions/array/function_array_utils.h" @@ -35,8 +39,8 @@ class FunctionSize : public IFunction { 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 { - DataTypePtr datatype = arguments[0]; + DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + DataTypePtr datatype = arguments[0].type; if (datatype->is_nullable()) { datatype = assert_cast(datatype.get())->get_nested_type(); } @@ -45,6 +49,10 @@ class FunctionSize : public IFunction { return std::make_shared(); } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + return std::make_shared(); + } + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, uint32_t result, size_t input_rows_count) const override { const auto& [left_column, left_const] = diff --git a/be/src/vec/functions/function_string.h b/be/src/vec/functions/function_string.h index 6e4a18fdd3100e..ea97c1f68b8682 100644 --- a/be/src/vec/functions/function_string.h +++ b/be/src/vec/functions/function_string.h @@ -17,6 +17,7 @@ #pragma once +#include #include #include @@ -63,6 +64,7 @@ #include "vec/core/block.h" #include "vec/core/column_numbers.h" #include "vec/core/column_with_type_and_name.h" +#include "vec/core/columns_with_type_and_name.h" #include "vec/core/types.h" #include "vec/data_types/data_type.h" #include "vec/utils/template_helpers.hpp" @@ -1322,14 +1324,19 @@ class FunctionStringConcatWs : public IFunction { size_t get_number_of_arguments() const override { return 0; } bool is_variadic() const override { return true; } - DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - const IDataType* first_type = arguments[0].get(); + DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + const IDataType* first_type = arguments[0].type.get(); if (first_type->is_nullable()) { return make_nullable(std::make_shared()); } else { return std::make_shared(); } } + + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + return std::make_shared(); + } + bool use_default_implementation_for_nulls() const override { return false; } Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, @@ -2105,14 +2112,19 @@ class FunctionSplitByString : public IFunction { size_t get_number_of_arguments() const override { return 2; } - DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - DCHECK(is_string(arguments[0])) + DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + DCHECK(arguments.size() == 2) << "function " << name << " should have 2 arguments"; + DCHECK(is_string(arguments[0].type)) << "first argument for function: " << name << " should be string" - << " and arguments[0] is " << arguments[0]->get_name(); - DCHECK(is_string(arguments[1])) + << " and arguments[0] is " << arguments[0].type->get_name(); + DCHECK(is_string(arguments[1].type)) << "second argument for function: " << name << " should be string" - << " and arguments[1] is " << arguments[1]->get_name(); - return std::make_shared(make_nullable(arguments[0])); + << " and arguments[1] is " << arguments[1].type->get_name(); + return std::make_shared(make_nullable(arguments[0].type)); + } + + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + return std::make_shared(std::make_shared()); } Status execute_impl(FunctionContext* /*context*/, Block& block, const ColumnNumbers& arguments, @@ -2382,13 +2394,18 @@ class FunctionCountSubString : public IFunction { size_t get_number_of_arguments() const override { return 2; } - DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - DCHECK(is_string(arguments[0])) + DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + DCHECK(arguments.size() == 2) << "function " << name << " should have 2 arguments"; + DCHECK(is_string(arguments[0].type)) << "first argument for function: " << name << " should be string" - << " and arguments[0] is " << arguments[0]->get_name(); - DCHECK(is_string(arguments[1])) + << " and arguments[0] is " << arguments[0].type->get_name(); + DCHECK(is_string(arguments[1].type)) << "second argument for function: " << name << " should be string" - << " and arguments[1] is " << arguments[1]->get_name(); + << " and arguments[1] is " << arguments[1].type->get_name(); + return std::make_shared(); + } + + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { return std::make_shared(); } diff --git a/be/src/vec/functions/function_string_to_string.h b/be/src/vec/functions/function_string_to_string.h index ea8c654faa1d31..acfed4d676eb93 100644 --- a/be/src/vec/functions/function_string_to_string.h +++ b/be/src/vec/functions/function_string_to_string.h @@ -20,8 +20,12 @@ #pragma once +#include + +#include "vec/aggregate_functions/aggregate_function.h" #include "vec/columns/column_string.h" #include "vec/columns/column_vector.h" +#include "vec/core/columns_with_type_and_name.h" #include "vec/data_types/data_type_number.h" #include "vec/data_types/data_type_string.h" #include "vec/functions/function.h" @@ -42,14 +46,18 @@ class FunctionStringToString : public IFunction { size_t get_number_of_arguments() const override { return 1; } - DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - if (!is_string_or_fixed_string(arguments[0])) { + DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + if (!is_string_or_fixed_string(arguments[0].type)) { throw doris::Exception(ErrorCode::INVALID_ARGUMENT, "Illegal type {} of argument of function {}", - arguments[0]->get_name(), get_name()); + arguments[0].type->get_name(), get_name()); } - return arguments[0]; + return arguments[0].type; + } + + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + return std::make_shared(); } DataTypes get_variadic_argument_types_impl() const override { diff --git a/be/src/vec/functions/function_struct.cpp b/be/src/vec/functions/function_struct.cpp index 49348f56f9036b..17b7da92c733ba 100644 --- a/be/src/vec/functions/function_struct.cpp +++ b/be/src/vec/functions/function_struct.cpp @@ -59,6 +59,8 @@ class FunctionStruct : public IFunction { bool is_variadic() const override { return true; } + bool dont_append_return_type_name_when_register_function() override { return true; } + bool use_default_implementation_for_nulls() const override { return false; } size_t get_number_of_arguments() const override { return 0; } diff --git a/be/src/vec/functions/function_struct_element.cpp b/be/src/vec/functions/function_struct_element.cpp index f547588dece646..e84b570768b005 100644 --- a/be/src/vec/functions/function_struct_element.cpp +++ b/be/src/vec/functions/function_struct_element.cpp @@ -51,6 +51,8 @@ class FunctionStructElement : public IFunction { size_t get_number_of_arguments() const override { return 2; } + bool dont_append_return_type_name_when_register_function() override { return true; } + ColumnNumbers get_arguments_that_are_always_constant() const override { return {1}; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { diff --git a/be/src/vec/functions/function_time_value_to_field.cpp b/be/src/vec/functions/function_time_value_to_field.cpp index 8c8ec3cf9ab219..ce2431ab9cbc27 100644 --- a/be/src/vec/functions/function_time_value_to_field.cpp +++ b/be/src/vec/functions/function_time_value_to_field.cpp @@ -47,6 +47,10 @@ class FunctionTimeValueToField : public IFunction { return std::make_shared(); } + DataTypePtr get_return_type_impl(const DataTypes& types) const override { + return std::make_shared(); + } + bool use_default_implementation_for_nulls() const override { return true; } Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, diff --git a/be/src/vec/functions/function_timestamp.cpp b/be/src/vec/functions/function_timestamp.cpp index cc812b8968124f..07586f7b91df29 100644 --- a/be/src/vec/functions/function_timestamp.cpp +++ b/be/src/vec/functions/function_timestamp.cpp @@ -249,7 +249,7 @@ struct MakeDateImpl { static DataTypes get_variadic_argument_types() { return {}; } static DataTypePtr get_return_type_impl(const DataTypes& arguments) { - return make_nullable(std::make_shared()); + return make_nullable(std::make_shared()); } static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments, @@ -498,7 +498,7 @@ class FromDays : public IFunction { size_t get_number_of_arguments() const override { return 1; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - return make_nullable(std::make_shared()); + return make_nullable(std::make_shared()); } Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, @@ -572,6 +572,10 @@ struct UnixTimeStampImpl { return std::make_shared(); } + static DataTypePtr get_return_type_impl(const DataTypes& arguments) { + return std::make_shared(); + } + static Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, uint32_t result, size_t input_rows_count) { @@ -607,6 +611,25 @@ struct UnixTimeStampDateImpl { } } + static DataTypePtr get_return_type_impl(const DataTypes& arguments) { + if constexpr (std::is_same_v) { + if (arguments[0]->is_nullable()) { + UInt32 scale = static_cast(arguments[0].get()) + ->get_nested_type() + ->get_scale(); + return make_nullable( + std::make_shared>(10 + scale, scale)); + } + UInt32 scale = arguments[0]->get_scale(); + return std::make_shared>(10 + scale, scale); + } else { + if (arguments[0]->is_nullable()) { + return make_nullable(std::make_shared()); + } + return std::make_shared(); + } + } + static Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, uint32_t result, size_t input_rows_count) { @@ -687,6 +710,10 @@ struct UnixTimeStampStrImpl { return {std::make_shared(), std::make_shared()}; } + static DataTypePtr get_return_type_impl(const DataTypes& arguments) { + return make_nullable(std::make_shared>(16, 6)); + } + static DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) { return make_nullable(std::make_shared>(16, 6)); } @@ -758,6 +785,10 @@ class FunctionUnixTimestamp : public IFunction { return Impl::get_return_type_impl(arguments); } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + return Impl::get_return_type_impl(arguments); + } + DataTypes get_variadic_argument_types_impl() const override { return Impl::get_variadic_argument_types(); } @@ -799,6 +830,10 @@ class DateTimeToTimestamp : public IFunction { return std::make_shared(); } + DataTypePtr get_return_type_impl(const DataTypes& types) const override { + return std::make_shared(); + } + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, uint32_t result, size_t input_rows_count) const override { const auto& arg_col = block.get_by_position(arguments[0]).column; @@ -855,6 +890,10 @@ class FunctionDateOrDateTimeToDate : public IFunction { } } + DataTypePtr get_return_type_impl(const DataTypes& types) const override { + return std::make_shared(); + } + DataTypes get_variadic_argument_types_impl() const override { return {std::make_shared()}; } diff --git a/be/src/vec/functions/function_tokenize.h b/be/src/vec/functions/function_tokenize.h index 4a7cb0dad26214..c034a70d702748 100644 --- a/be/src/vec/functions/function_tokenize.h +++ b/be/src/vec/functions/function_tokenize.h @@ -56,14 +56,18 @@ class FunctionTokenize : public IFunction { size_t get_number_of_arguments() const override { return 2; } - DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - DCHECK(is_string(arguments[0])) + DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + DCHECK(is_string(arguments[0].type)) << "first argument for function: " << name << " should be string" - << " and arguments[0] is " << arguments[0]->get_name(); - DCHECK(is_string(arguments[1])) + << " and arguments[0] is " << arguments[0].type->get_name(); + DCHECK(is_string(arguments[1].type)) << "second argument for function: " << name << " should be string" - << " and arguments[1] is " << arguments[1]->get_name(); - return std::make_shared(make_nullable(arguments[0])); + << " and arguments[1] is " << arguments[1].type->get_name(); + return std::make_shared(make_nullable(arguments[0].type)); + } + + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + return std::make_shared(std::make_shared()); } void _do_tokenize(const ColumnString& src_column_string, InvertedIndexCtx& inverted_index_ctx, IColumn& dest_nested_column, ColumnArray::Offsets64& dest_offsets, diff --git a/be/src/vec/functions/function_unary_arithmetic.h b/be/src/vec/functions/function_unary_arithmetic.h index 54d03f602593e1..d5064227018696 100644 --- a/be/src/vec/functions/function_unary_arithmetic.h +++ b/be/src/vec/functions/function_unary_arithmetic.h @@ -81,6 +81,8 @@ class FunctionUnaryArithmetic : public IFunction { size_t get_number_of_arguments() const override { return 1; } + bool dont_append_return_type_name_when_register_function() override { return true; } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { DataTypePtr result; bool valid = cast_type(arguments[0].get(), [&](const auto& type) { diff --git a/be/src/vec/functions/function_utility.cpp b/be/src/vec/functions/function_utility.cpp index 40dd11677758de..af2b7e114faac7 100644 --- a/be/src/vec/functions/function_utility.cpp +++ b/be/src/vec/functions/function_utility.cpp @@ -61,13 +61,17 @@ class FunctionSleep : public IFunction { size_t get_number_of_arguments() const override { return 1; } - DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - if (arguments[0]->is_nullable()) { + DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + if (arguments[0].type->is_nullable()) { return make_nullable(std::make_shared()); } return std::make_shared(); } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + return std::make_shared(); + } + bool use_default_implementation_for_nulls() const override { return false; } // Sleep function should not be executed during open stage, this will makes fragment prepare @@ -132,6 +136,10 @@ class FunctionVersion : public IFunction { return std::make_shared(); } + DataTypePtr get_return_type_impl(const DataTypes& types) const override { + return std::make_shared(); + } + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, uint32_t result, size_t input_rows_count) const override { auto res_column = ColumnString::create(); diff --git a/be/src/vec/functions/function_variadic_arguments.h b/be/src/vec/functions/function_variadic_arguments.h index 530b204e8067a1..68e924dd852124 100644 --- a/be/src/vec/functions/function_variadic_arguments.h +++ b/be/src/vec/functions/function_variadic_arguments.h @@ -54,6 +54,10 @@ class FunctionVariadicArgumentsBase : public IFunction { return res; } + DataTypePtr get_return_type_impl(const DataTypes& types) const override { + return std::make_shared(); + } + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, uint32_t result, size_t input_rows_count) const override { ToDataType to_type; diff --git a/be/src/vec/functions/function_variant_element.cpp b/be/src/vec/functions/function_variant_element.cpp index e04ff54dbe9d7c..ecc3ae95140487 100644 --- a/be/src/vec/functions/function_variant_element.cpp +++ b/be/src/vec/functions/function_variant_element.cpp @@ -37,6 +37,7 @@ #include "vec/common/assert_cast.h" #include "vec/common/string_ref.h" #include "vec/core/block.h" +#include "vec/core/columns_with_type_and_name.h" #include "vec/data_types/data_type.h" #include "vec/data_types/data_type_nothing.h" #include "vec/data_types/data_type_nullable.h" @@ -67,16 +68,21 @@ class FunctionVariantElement : public IFunction { return {std::make_shared(), std::make_shared()}; } - DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - DCHECK((WhichDataType(remove_nullable(arguments[0]))).is_variant_type()) + DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { + DCHECK((WhichDataType(remove_nullable(arguments[0].type))).is_variant_type()) << "First argument for function: " << name - << " should be DataTypeObject but it has type " << arguments[0]->get_name() << "."; - DCHECK(is_string(arguments[1])) + << " should be DataTypeObject but it has type " << arguments[0].type->get_name() + << "."; + DCHECK(is_string(arguments[1].type)) << "Second argument for function: " << name << " should be String but it has type " - << arguments[1]->get_name() << "."; + << arguments[1].type->get_name() << "."; return make_nullable(std::make_shared()); } + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + return std::make_shared(); + } + // wrap variant column with nullable // 1. if variant is null root(empty or nothing as root), then nullable map is all null // 2. if variant is scalar variant, then use the root's nullable map diff --git a/be/src/vec/functions/functions_logical.cpp b/be/src/vec/functions/functions_logical.cpp index 0f474851f032ee..b3affc8315b664 100644 --- a/be/src/vec/functions/functions_logical.cpp +++ b/be/src/vec/functions/functions_logical.cpp @@ -170,13 +170,6 @@ void null_execute_impl(ColumnRawPtrs arguments, ColumnWithTypeAndName& result_in template DataTypePtr FunctionAnyArityLogical::get_return_type_impl( const DataTypes& arguments) const { - if (arguments.size() < 2) { - throw doris::Exception( - ErrorCode::INVALID_ARGUMENT, - "Number of arguments for function \"{}\" should be at least 2: passed {}", - get_name(), arguments.size()); - } - bool has_nullable_arguments = false; for (size_t i = 0; i < arguments.size(); ++i) { const auto& arg_type = arguments[i]; @@ -240,7 +233,7 @@ struct UnaryOperationImpl { template