diff --git a/src/Functions/ITupleFunction.h b/src/Functions/ITupleFunction.h index d0cebd00d8f..836e5d273fc 100644 --- a/src/Functions/ITupleFunction.h +++ b/src/Functions/ITupleFunction.h @@ -7,8 +7,6 @@ namespace DB namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; - extern const int ILLEGAL_COLUMN; - extern const int ARGUMENT_OUT_OF_BOUND; } class ITupleFunction : public IFunction diff --git a/src/Functions/vectorFunctions.cpp b/src/Functions/vectorFunctions.cpp index d479057c770..d3b5742c4e6 100644 --- a/src/Functions/vectorFunctions.cpp +++ b/src/Functions/vectorFunctions.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -11,6 +12,8 @@ namespace DB namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; + extern const int ILLEGAL_COLUMN; + extern const int ARGUMENT_OUT_OF_BOUND; } struct PlusName { static constexpr auto name = "plus"; }; @@ -1022,6 +1025,11 @@ public: ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override { + if (getReturnTypeImpl(arguments)->isNullable()) { + return DataTypeNullable(std::make_shared()) + .createColumnConstWithDefaultValue(input_rows_count); + } + FunctionDotProduct dot(context); ColumnWithTypeAndName dot_result{dot.executeImpl(arguments, DataTypePtr(), input_rows_count), dot.getReturnTypeImpl(arguments), {}}; diff --git a/tests/queries/0_stateless/02011_tuple_vector_functions.reference b/tests/queries/0_stateless/02011_tuple_vector_functions.reference index 379464d51aa..74e9c1b8a3c 100644 --- a/tests/queries/0_stateless/02011_tuple_vector_functions.reference +++ b/tests/queries/0_stateless/02011_tuple_vector_functions.reference @@ -70,3 +70,4 @@ (0.5,0.5) (0.7071067811865475,0.7071067811865475) (1,1) (0.5,0.5) 3.6060655943063797 4.3208683194033215 +\N diff --git a/tests/queries/0_stateless/02011_tuple_vector_functions.sql b/tests/queries/0_stateless/02011_tuple_vector_functions.sql index 2eb1c767bfa..419ca753500 100644 --- a/tests/queries/0_stateless/02011_tuple_vector_functions.sql +++ b/tests/queries/0_stateless/02011_tuple_vector_functions.sql @@ -100,4 +100,4 @@ SELECT LpNorm((1, 2, 3), inf); -- { serverError 69 } SELECT LpNorm((1, 2, 3), -1.); -- { serverError 69 } SELECT LpNorm((1, 2, 3), -1); -- { serverError 44 } SELECT LpNorm((1, 2, 3), 0.); -- { serverError 69 } ---SELECT cosineDistance(materialize((NULL, -2147483648)), (1048577, 1048575)); +SELECT cosineDistance(materialize((NULL, -2147483648)), (1048577, 1048575));