diff --git a/be/src/agent/be_exec_version_manager.h b/be/src/agent/be_exec_version_manager.h index d3b120eda21583..746542088be0c3 100644 --- a/be/src/agent/be_exec_version_manager.h +++ b/be/src/agent/be_exec_version_manager.h @@ -78,6 +78,7 @@ class BeExecVersionManager { * 5: start from doris 3.0.0 * a. change the impl of percentile (need fix) * b. clear old version of version 3->4 + * c. change FunctionIsIPAddressInRange from AlwaysNotNullable to DependOnArguments */ constexpr inline int BeExecVersionManager::max_be_exec_version = 5; constexpr inline int BeExecVersionManager::min_be_exec_version = 0; diff --git a/be/src/vec/columns/column.h b/be/src/vec/columns/column.h index 36b75d549347aa..fd8d1688c332cc 100644 --- a/be/src/vec/columns/column.h +++ b/be/src/vec/columns/column.h @@ -22,10 +22,9 @@ #include #include -#include #include -#include +#include #include #include #include @@ -692,6 +691,7 @@ struct IsMutableColumns<> { static const bool value = true; }; +// prefer assert_cast than check_and_get template const Type* check_and_get_column(const IColumn& column) { return typeid_cast(&column); diff --git a/be/src/vec/functions/function_ip.cpp b/be/src/vec/functions/function_ip.cpp index 5e288bf9ec791b..dbb715ee7f6083 100644 --- a/be/src/vec/functions/function_ip.cpp +++ b/be/src/vec/functions/function_ip.cpp @@ -17,6 +17,8 @@ #include "vec/functions/function_ip.h" +#include "vec/functions/simple_function_factory.h" + namespace doris::vectorized { void register_function_ip(SimpleFunctionFactory& factory) { diff --git a/be/src/vec/functions/function_ip.h b/be/src/vec/functions/function_ip.h index a78f6cd1df13bf..69c7a20e8967da 100644 --- a/be/src/vec/functions/function_ip.h +++ b/be/src/vec/functions/function_ip.h @@ -23,7 +23,6 @@ #include #include -#include #include "vec/columns/column.h" #include "vec/columns/column_nullable.h" @@ -34,7 +33,6 @@ #include "vec/common/format_ip.h" #include "vec/common/ipv6_to_binary.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_ipv4.h" @@ -45,7 +43,6 @@ #include "vec/data_types/data_type_struct.h" #include "vec/functions/function.h" #include "vec/functions/function_helpers.h" -#include "vec/functions/simple_function_factory.h" #include "vec/runtime/ip_address_cidr.h" namespace doris::vectorized { @@ -57,7 +54,7 @@ class FunctionIPv4NumToString : public IFunction { using ColumnType = ColumnVector; const ColumnPtr& column = argument.column; - if (const ColumnType* col = typeid_cast(column.get())) { + if (const auto* col = typeid_cast(column.get())) { const typename ColumnType::Container& vec_in = col->get_data(); auto col_res = ColumnString::create(); @@ -87,9 +84,10 @@ class FunctionIPv4NumToString : public IFunction { block.replace_by_position( result, ColumnNullable::create(std::move(col_res), std::move(null_map))); return Status::OK(); - } else + } else { return Status::RuntimeError("Illegal column {} of argument of function {}", argument.column->get_name(), get_name()); + } } public: @@ -111,17 +109,21 @@ class FunctionIPv4NumToString : public IFunction { switch (argument.type->get_type_id()) { case TypeIndex::Int8: return execute_type(block, argument, result); + break; case TypeIndex::Int16: return execute_type(block, argument, result); + break; case TypeIndex::Int32: return execute_type(block, argument, result); + break; case TypeIndex::Int64: return execute_type(block, argument, result); + break; default: break; } - return Status::RuntimeError( + return Status::InternalError( "Illegal column {} of argument of function {}, expected Int8 or Int16 or Int32 or " "Int64", argument.name, get_name()); @@ -137,13 +139,7 @@ static inline bool try_parse_ipv4(const char* pos, Int64& result_value) { template ColumnPtr convert_to_ipv4(ColumnPtr column, const PaddedPODArray* null_map = nullptr) { - const ColumnString* column_string = check_and_get_column(column.get()); - - if (!column_string) { - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal column {} of argument of function {}, expected String", - column->get_name()); - } + const auto* column_string = assert_cast(column.get()); size_t column_size = column_string->size(); @@ -223,11 +219,6 @@ class FunctionIPv4StringToNum : 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(remove_nullable(arguments[0]))) { - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal type {} of argument of function {}", arguments[0]->get_name(), - get_name()); - } auto result_type = std::make_shared(); if constexpr (exception_mode == IPConvertExceptionMode::Null) { @@ -270,7 +261,7 @@ void process_ipv6_column(const ColumnPtr& column, size_t input_rows_count, auto* begin = reinterpret_cast(vec_res.data()); auto* pos = begin; - const auto* col = check_and_get_column(column.get()); + const auto* col = assert_cast(column.get()); for (size_t i = 0; i < input_rows_count; ++i) { bool is_empty = false; @@ -279,7 +270,7 @@ void process_ipv6_column(const ColumnPtr& column, size_t input_rows_count, const auto& vec_in = col->get_data(); memcpy(ipv6_address_data, reinterpret_cast(&vec_in[i]), IPV6_BINARY_LENGTH); - } else { + } else { // ColumnString const auto str_ref = col->get_data_at(i); const char* value = str_ref.data; size_t value_size = str_ref.size; @@ -321,26 +312,12 @@ class FunctionIPv6NumToString : public IFunction { size_t get_number_of_arguments() const override { return 1; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - const auto* arg_string = check_and_get_data_type(arguments[0].get()); - const auto* arg_ipv6 = check_and_get_data_type(arguments[0].get()); - if (!arg_ipv6 && !(arg_string)) - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal type {} of argument of function {}, expected IPv6 or String", - arguments[0]->get_name(), get_name()); - return make_nullable(std::make_shared()); } Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, size_t result, size_t input_rows_count) const override { const ColumnPtr& column = block.get_by_position(arguments[0]).column; - const auto* col_ipv6 = check_and_get_column(column.get()); - const auto* col_string = check_and_get_column(column.get()); - - if (!col_ipv6 && !col_string) - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal column {} of argument of function {}, expected IPv6 or String", - column->get_name(), get_name()); auto col_res = ColumnString::create(); ColumnString::Chars& vec_res = col_res->get_chars(); @@ -352,10 +329,10 @@ class FunctionIPv6NumToString : public IFunction { unsigned char ipv6_address_data[IPV6_BINARY_LENGTH]; - if (col_ipv6) { + if (check_and_get_column(column.get())) { process_ipv6_column(column, input_rows_count, vec_res, offsets_res, null_map, ipv6_address_data); - } else { + } else { //ColumnString process_ipv6_column(column, input_rows_count, vec_res, offsets_res, null_map, ipv6_address_data); } @@ -371,13 +348,6 @@ template ColumnPtr convert_to_ipv6(const StringColumnType& string_column, const PaddedPODArray* null_map = nullptr) { - if constexpr (!std::is_same_v && - !std::is_same_v) { - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal return column type {}. Expected IPv6 or String", - TypeName::get()); - } - const size_t column_size = string_column.size(); ColumnUInt8::MutablePtr col_null_map_to; @@ -519,14 +489,9 @@ ColumnPtr convert_to_ipv6(const StringColumnType& string_column, template ColumnPtr convert_to_ipv6(ColumnPtr column, const PaddedPODArray* null_map = nullptr) { - if (const auto* column_input_string = check_and_get_column(column.get())) { - auto result = - detail::convert_to_ipv6(*column_input_string, null_map); - return result; - } else { - throw Exception(ErrorCode::INVALID_ARGUMENT, "Illegal column type {}. Expected String", - column->get_name()); - } + const auto* column_input_string = assert_cast(column.get()); + auto result = detail::convert_to_ipv6(*column_input_string, null_map); + return result; } template @@ -549,12 +514,6 @@ class FunctionIPv6StringToNum : public IFunction { bool use_default_implementation_for_nulls() const override { return false; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - if (!is_string(remove_nullable(arguments[0]))) { - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal type {} of argument of function {}", arguments[0]->get_name(), - get_name()); - } - auto result_type = std::make_shared(); if constexpr (exception_mode == IPConvertExceptionMode::Null) { @@ -602,12 +561,6 @@ class FunctionIsIPString : public IFunction { size_t get_number_of_arguments() const override { return 1; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - const auto& addr_type = arguments[0]; - if (!is_string(remove_nullable(addr_type))) { - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal type {} of first argument of function {}, expected String", - addr_type->get_name(), get_name()); - } return std::make_shared(); } @@ -649,18 +602,52 @@ class FunctionIsIPAddressInRange : public IFunction { size_t get_number_of_arguments() const override { return 2; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - if (arguments.size() != 2) { - throw Exception( - ErrorCode::INVALID_ARGUMENT, - "Number of arguments for function {} doesn't match: passed {}, should be 2", - get_name(), arguments.size()); - } - const auto& addr_type = arguments[0]; - const auto& cidr_type = arguments[1]; - if (!is_string(remove_nullable(addr_type)) || !is_string(remove_nullable(cidr_type))) { - throw Exception(ErrorCode::INVALID_ARGUMENT, - "The arguments of function {} must be String", get_name()); + return std::make_shared(); + } + + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, + size_t result, size_t input_rows_count) const override { + const auto& addr_column_with_type_and_name = block.get_by_position(arguments[0]); + const auto& cidr_column_with_type_and_name = block.get_by_position(arguments[1]); + WhichDataType addr_type(addr_column_with_type_and_name.type); + WhichDataType cidr_type(cidr_column_with_type_and_name.type); + const auto& [addr_column, addr_const] = + unpack_if_const(addr_column_with_type_and_name.column); + const auto& [cidr_column, cidr_const] = + unpack_if_const(cidr_column_with_type_and_name.column); + const auto* str_addr_column = assert_cast(addr_column.get()); + const auto* str_cidr_column = assert_cast(cidr_column.get()); + + auto col_res = ColumnUInt8::create(input_rows_count, 0); + auto& col_res_data = col_res->get_data(); + + for (size_t i = 0; i < input_rows_count; ++i) { + auto addr_idx = index_check_const(i, addr_const); + auto cidr_idx = index_check_const(i, cidr_const); + + const auto addr = + IPAddressVariant(str_addr_column->get_data_at(addr_idx).to_string_view()); + const auto cidr = + parse_ip_with_cidr(str_cidr_column->get_data_at(cidr_idx).to_string_view()); + col_res_data[i] = is_address_in_range(addr, cidr) ? 1 : 0; } + + block.replace_by_position(result, std::move(col_res)); + return Status::OK(); + } +}; + +// old version throw exception when meet null value +class FunctionIsIPAddressInRangeOld : public IFunction { +public: + static constexpr auto name = "is_ip_address_in_range"; + static FunctionPtr create() { return std::make_shared(); } + + String get_name() const override { return name; } + + size_t get_number_of_arguments() const override { return 2; } + + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { return std::make_shared(); } @@ -684,33 +671,21 @@ class FunctionIsIPAddressInRange : public IFunction { if (addr_type.is_nullable()) { const auto* addr_column_nullable = assert_cast(addr_column.get()); - str_addr_column = - check_and_get_column(addr_column_nullable->get_nested_column()); + str_addr_column = assert_cast( + addr_column_nullable->get_nested_column_ptr().get()); null_map_addr = &addr_column_nullable->get_null_map_data(); } else { - str_addr_column = check_and_get_column(addr_column.get()); + str_addr_column = assert_cast(addr_column.get()); } if (cidr_type.is_nullable()) { const auto* cidr_column_nullable = assert_cast(cidr_column.get()); - str_cidr_column = - check_and_get_column(cidr_column_nullable->get_nested_column()); + str_cidr_column = assert_cast( + cidr_column_nullable->get_nested_column_ptr().get()); null_map_cidr = &cidr_column_nullable->get_null_map_data(); } else { - str_cidr_column = check_and_get_column(cidr_column.get()); - } - - if (!str_addr_column) { - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal column {} of argument of function {}, expected String", - addr_column->get_name(), get_name()); - } - - if (!str_cidr_column) { - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal column {} of argument of function {}, expected String", - cidr_column->get_name(), get_name()); + str_cidr_column = assert_cast(cidr_column.get()); } auto col_res = ColumnUInt8::create(input_rows_count, 0); @@ -719,12 +694,12 @@ class FunctionIsIPAddressInRange : public IFunction { for (size_t i = 0; i < input_rows_count; ++i) { auto addr_idx = index_check_const(i, addr_const); auto cidr_idx = index_check_const(i, cidr_const); - if (null_map_addr && (*null_map_addr)[addr_idx]) { + if (null_map_addr && (*null_map_addr)[addr_idx]) [[unlikely]] { throw Exception(ErrorCode::INVALID_ARGUMENT, "The arguments of function {} must be String, not NULL", get_name()); } - if (null_map_cidr && (*null_map_cidr)[cidr_idx]) { + if (null_map_cidr && (*null_map_cidr)[cidr_idx]) [[unlikely]] { throw Exception(ErrorCode::INVALID_ARGUMENT, "The arguments of function {} must be String, not NULL", get_name()); @@ -751,22 +726,7 @@ class FunctionIPv4CIDRToRange : public IFunction { size_t get_number_of_arguments() const override { return 2; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - WhichDataType first_arg_type = arguments[0]; - if (!(first_arg_type.is_ipv4())) { - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal type {} of first argument of function {}, expected IPv4", - arguments[0]->get_name(), get_name()); - } - - WhichDataType second_arg_type = arguments[1]; - if (!(second_arg_type.is_int16())) { - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal type {} of second argument of function {}, expected Int16", - arguments[1]->get_name(), get_name()); - } - DataTypePtr element = std::make_shared(); - return std::make_shared(DataTypes {element, element}, Strings {"min", "max"}); } @@ -779,9 +739,9 @@ class FunctionIPv4CIDRToRange : public IFunction { const auto& [ip_column_ptr, ip_col_const] = unpack_if_const(ip_column.column); const auto& [cidr_column_ptr, cidr_col_const] = unpack_if_const(cidr_column.column); - const auto* col_ip_column = check_and_get_column>(ip_column_ptr.get()); + const auto* col_ip_column = assert_cast*>(ip_column_ptr.get()); const auto* col_cidr_column = - check_and_get_column>(cidr_column_ptr.get()); + assert_cast*>(cidr_column_ptr.get()); const typename ColumnVector::Container& vec_ip_input = col_ip_column->get_data(); const ColumnInt16::Container& vec_cidr_input = col_cidr_column->get_data(); @@ -863,19 +823,6 @@ class FunctionIPv6CIDRToRange : public IFunction { size_t get_number_of_arguments() const override { return 2; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - const auto& ipv6_type = arguments[0]; - if (!is_string(remove_nullable(ipv6_type)) && !is_ipv6(remove_nullable(ipv6_type))) { - throw Exception( - ErrorCode::INVALID_ARGUMENT, - "Illegal type {} of first argument of function {}, expected String or IPv6", - ipv6_type->get_name(), get_name()); - } - const auto& cidr_type = arguments[1]; - if (!is_int16(remove_nullable(cidr_type))) { - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal type {} of second argument of function {}, expected Int16", - cidr_type->get_name(), get_name()); - } DataTypePtr element = std::make_shared(); return std::make_shared(DataTypes {element, element}, Strings {"min", "max"}); @@ -896,11 +843,11 @@ class FunctionIPv6CIDRToRange : public IFunction { ColumnPtr col_res = nullptr; if (addr_type.is_ipv6()) { - const auto* ipv6_addr_column = check_and_get_column(addr_column.get()); + const auto* ipv6_addr_column = assert_cast(addr_column.get()); col_res = execute_impl(*ipv6_addr_column, *cidr_col, input_rows_count, add_col_const, col_const); } else if (addr_type.is_string()) { - const auto* str_addr_column = check_and_get_column(addr_column.get()); + const auto* str_addr_column = assert_cast(addr_column.get()); col_res = execute_impl(*str_addr_column, *cidr_col, input_rows_count, add_col_const, col_const); } else { @@ -1018,12 +965,8 @@ class FunctionIsIPv4Compat : public IFunction { Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, size_t result, size_t input_rows_count) const override { const ColumnPtr& column = block.get_by_position(arguments[0]).column; - const auto* col_in = check_and_get_column(column.get()); + const auto* col_in = assert_cast(column.get()); - if (!col_in) - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal column {} of argument of function {}, expected String", - column->get_name(), get_name()); size_t col_size = col_in->size(); auto col_res = ColumnUInt8::create(col_size, 0); auto& col_res_data = col_res->get_data(); @@ -1063,12 +1006,8 @@ class FunctionIsIPv4Mapped : public IFunction { Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, size_t result, size_t input_rows_count) const override { const ColumnPtr& column = block.get_by_position(arguments[0]).column; - const auto* col_in = check_and_get_column(column.get()); + const auto* col_in = assert_cast(column.get()); - if (!col_in) - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal column {} of argument of function {}, expected String", - column->get_name(), get_name()); size_t col_size = col_in->size(); auto col_res = ColumnUInt8::create(col_size, 0); auto& col_res_data = col_res->get_data(); @@ -1121,12 +1060,6 @@ class FunctionToIP : 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(remove_nullable(arguments[0]))) { - throw Exception(ErrorCode::INVALID_ARGUMENT, - "Illegal type {} of argument of function {}, expected String", - arguments[0]->get_name(), get_name()); - } - DataTypePtr result_type; if constexpr (std::is_same_v) { @@ -1155,11 +1088,11 @@ class FunctionToIP : public IFunction { if (addr_type.is_nullable()) { const auto* addr_column_nullable = assert_cast(addr_column.get()); - str_addr_column = - check_and_get_column(addr_column_nullable->get_nested_column()); + str_addr_column = assert_cast( + addr_column_nullable->get_nested_column_ptr().get()); addr_null_map = &addr_column_nullable->get_null_map_data(); } else { - str_addr_column = check_and_get_column(addr_column.get()); + str_addr_column = assert_cast(addr_column.get()); } auto col_res = ColumnVector::create(input_rows_count, 0); diff --git a/be/test/vec/function/function_ip_test.cpp b/be/test/vec/function/function_ip_test.cpp index 70cd82655b454a..6a16798b9bda20 100644 --- a/be/test/vec/function/function_ip_test.cpp +++ b/be/test/vec/function/function_ip_test.cpp @@ -56,7 +56,7 @@ TEST(FunctionIpTest, FunctionIsIPAddressInRangeTest) { { // vector vs vector InputTypeSet input_types = {TypeIndex::String, TypeIndex::String}; - static_cast(check_function(func_name, input_types, data_set)); + static_cast(check_function(func_name, input_types, data_set)); } { @@ -64,8 +64,8 @@ TEST(FunctionIpTest, FunctionIsIPAddressInRangeTest) { InputTypeSet input_types = {TypeIndex::String, Consted {TypeIndex::String}}; for (const auto& line : data_set) { DataSet const_cidr_dataset = {line}; - static_cast(check_function(func_name, input_types, - const_cidr_dataset)); + static_cast(check_function(func_name, input_types, + const_cidr_dataset)); } } @@ -74,8 +74,8 @@ TEST(FunctionIpTest, FunctionIsIPAddressInRangeTest) { InputTypeSet input_types = {Consted {TypeIndex::String}, TypeIndex::String}; for (const auto& line : data_set) { DataSet const_addr_dataset = {line}; - static_cast(check_function(func_name, input_types, - const_addr_dataset)); + static_cast(check_function(func_name, input_types, + const_addr_dataset)); } } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ipv6NumToString.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ipv6NumToString.java index ef5ac558ade4fb..056601f369bf4f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ipv6NumToString.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ipv6NumToString.java @@ -41,8 +41,7 @@ public class Ipv6NumToString extends ScalarFunction public static final List SIGNATURES = ImmutableList.of( FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT), FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE), - FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(IPv6Type.INSTANCE), - FunctionSignature.ret(StringType.INSTANCE).args(IPv6Type.INSTANCE)); + FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(IPv6Type.INSTANCE)); public Ipv6NumToString(Expression arg0) { super("ipv6_num_to_string", arg0); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/IsIpAddressInRange.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/IsIpAddressInRange.java index d15af4235b73bc..85fe4dcab78333 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/IsIpAddressInRange.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/IsIpAddressInRange.java @@ -19,8 +19,8 @@ import org.apache.doris.catalog.FunctionSignature; import org.apache.doris.nereids.trees.expressions.Expression; -import org.apache.doris.nereids.trees.expressions.functions.AlwaysNotNullable; import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; +import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable; import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.BooleanType; @@ -36,7 +36,7 @@ * scalar function `is_ip_address_in_range` */ public class IsIpAddressInRange extends ScalarFunction - implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNotNullable { + implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { public static final List SIGNATURES = ImmutableList.of( FunctionSignature.ret(BooleanType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT), diff --git a/gensrc/script/doris_builtins_functions.py b/gensrc/script/doris_builtins_functions.py index b7912d08904775..1b49b1be031740 100644 --- a/gensrc/script/doris_builtins_functions.py +++ b/gensrc/script/doris_builtins_functions.py @@ -2042,7 +2042,6 @@ [['ipv6_num_to_string','inet6_ntoa'], 'VARCHAR', ['VARCHAR'], 'ALWAYS_NULLABLE'], [['ipv6_num_to_string','inet6_ntoa'], 'STRING', ['STRING'], 'ALWAYS_NULLABLE'], [['ipv6_num_to_string','inet6_ntoa'], 'VARCHAR', ['IPV6'], 'ALWAYS_NULLABLE'], - [['ipv6_num_to_string','inet6_ntoa'], 'STRING', ['IPV6'], 'ALWAYS_NULLABLE'], [['ipv6_string_to_num'], 'VARCHAR', ['VARCHAR'], 'ALWAYS_NOT_NULLABLE'], [['ipv6_string_to_num'], 'STRING', ['STRING'], 'ALWAYS_NOT_NULLABLE'], [['ipv6_string_to_num_or_default'], 'VARCHAR', ['VARCHAR'], 'ALWAYS_NOT_NULLABLE'], @@ -2057,12 +2056,12 @@ [['is_ipv4_string'], 'BOOLEAN', ['STRING'], ''], [['is_ipv6_string'], 'BOOLEAN', ['VARCHAR'], ''], [['is_ipv6_string'], 'BOOLEAN', ['STRING'], ''], - [['is_ip_address_in_range'], 'BOOLEAN', ['VARCHAR', 'VARCHAR'], 'ALWAYS_NOT_NULLABLE'], - [['is_ip_address_in_range'], 'BOOLEAN', ['STRING', 'STRING'], 'ALWAYS_NOT_NULLABLE'], - [['ipv4_cidr_to_range'], 'STRUCT', ['IPV4', 'SMALLINT'], ''], - [['ipv6_cidr_to_range'], 'STRUCT', ['IPV6', 'SMALLINT'], ''], - [['ipv6_cidr_to_range'], 'STRUCT', ['VARCHAR', 'SMALLINT'], ''], - [['ipv6_cidr_to_range'], 'STRUCT', ['STRING', 'SMALLINT'], ''], + [['is_ip_address_in_range'], 'BOOLEAN', ['VARCHAR', 'VARCHAR'], 'DEPEND_ON_ARGUMENT'], + [['is_ip_address_in_range'], 'BOOLEAN', ['STRING', 'STRING'], 'DEPEND_ON_ARGUMENT'], + [['ipv4_cidr_to_range'], 'STRUCT', ['IPV4', 'SMALLINT'], 'DEPEND_ON_ARGUMENT'], + [['ipv6_cidr_to_range'], 'STRUCT', ['IPV6', 'SMALLINT'], 'DEPEND_ON_ARGUMENT'], + [['ipv6_cidr_to_range'], 'STRUCT', ['VARCHAR', 'SMALLINT'], 'DEPEND_ON_ARGUMENT'], + [['ipv6_cidr_to_range'], 'STRUCT', ['STRING', 'SMALLINT'], 'DEPEND_ON_ARGUMENT'], [['to_ipv4'], 'IPV4', ['VARCHAR'], 'ALWAYS_NOT_NULLABLE'], [['to_ipv4'], 'IPV4', ['STRING'], 'ALWAYS_NOT_NULLABLE'], [['to_ipv4_or_default'], 'IPV4', ['VARCHAR'], 'ALWAYS_NOT_NULLABLE'], diff --git a/regression-test/data/query_p0/sql_functions/ip_functions/test_is_ip_address_in_range_function.out b/regression-test/data/query_p0/sql_functions/ip_functions/test_is_ip_address_in_range_function.out index 391ee192b58591..285b861b742c5b 100644 --- a/regression-test/data/query_p0/sql_functions/ip_functions/test_is_ip_address_in_range_function.out +++ b/regression-test/data/query_p0/sql_functions/ip_functions/test_is_ip_address_in_range_function.out @@ -1,3 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this -- !sql -- 1 true 2 false @@ -80,4 +81,14 @@ 23 false 24 false 25 false -26 false \ No newline at end of file +26 false + +-- !sql -- +\N + +-- !sql -- +\N + +-- !sql -- +\N + diff --git a/regression-test/suites/query_p0/sql_functions/ip_functions/test_is_ip_address_in_range_function.groovy b/regression-test/suites/query_p0/sql_functions/ip_functions/test_is_ip_address_in_range_function.groovy index e7b496a1408a0a..812bfffeb2f3e0 100644 --- a/regression-test/suites/query_p0/sql_functions/ip_functions/test_is_ip_address_in_range_function.groovy +++ b/regression-test/suites/query_p0/sql_functions/ip_functions/test_is_ip_address_in_range_function.groovy @@ -73,22 +73,9 @@ suite("test_is_ip_address_in_range_function") { // scalar vs vector qt_sql "select id, is_ip_address_in_range('192.168.100.0', cidr) from test_is_ip_address_in_range_function order by id" - test { - sql "SELECT is_ip_address_in_range('::ffff:192.168.0.1', NULL)" - // check exception message contains - exception "The arguments of function is_ip_address_in_range must be String, not NULL" - } + qt_sql "SELECT is_ip_address_in_range('::ffff:192.168.0.1', NULL)" - test { - sql "SELECT is_ip_address_in_range(NULL, '::ffff:192.168.0.4/128')" - // check exception message contains - exception "The arguments of function is_ip_address_in_range must be String, not NULL" - } + qt_sql "SELECT is_ip_address_in_range(NULL, '::ffff:192.168.0.4/128')" - test { - sql "SELECT is_ip_address_in_range(NULL, NULL)" - // check exception message contains - exception "The arguments of function is_ip_address_in_range must be String, not NULL" - } - sql """ DROP TABLE IF EXISTS test_is_ip_address_in_range_function """ + qt_sql "SELECT is_ip_address_in_range(NULL, NULL)" } \ No newline at end of file