superdiaodiao commented on code in PR #55631:
URL: https://github.com/apache/doris/pull/55631#discussion_r2321054639
##########
be/src/vec/functions/array/function_array_distance.h:
##########
@@ -109,55 +122,86 @@ class FunctionArrayDistance : public IFunction {
get_name(), col1->size(), col2->size()));
}
- ColumnArrayExecutionData arr1;
- ColumnArrayExecutionData arr2;
- if (!extract_column_array_info(*col1, arr1) ||
!extract_column_array_info(*col2, arr2)) {
- return Status::RuntimeError(fmt::format("unsupported types for
function {}({}, {})",
- get_name(),
arg1.type->get_name(),
- arg2.type->get_name()));
+ const ColumnArray* arr1 = nullptr;
+ const ColumnArray* arr2 = nullptr;
+
+ if (col1->is_nullable()) {
+ if (col1->has_null()) {
+ throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+ "Arguments for function {} cannot be
null", get_name());
+ }
Review Comment:
A minor advice:
```suggestion
throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
"The first argument for function {}
cannot be null", get_name());
}
```
So that we can distinguish it from line 141~142 to help user locate the
exception quicker.
##########
be/src/vec/functions/array/function_array_distance.h:
##########
@@ -109,55 +122,86 @@ class FunctionArrayDistance : public IFunction {
get_name(), col1->size(), col2->size()));
}
- ColumnArrayExecutionData arr1;
- ColumnArrayExecutionData arr2;
- if (!extract_column_array_info(*col1, arr1) ||
!extract_column_array_info(*col2, arr2)) {
- return Status::RuntimeError(fmt::format("unsupported types for
function {}({}, {})",
- get_name(),
arg1.type->get_name(),
- arg2.type->get_name()));
+ const ColumnArray* arr1 = nullptr;
+ const ColumnArray* arr2 = nullptr;
+
+ if (col1->is_nullable()) {
+ if (col1->has_null()) {
+ throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+ "Arguments for function {} cannot be
null", get_name());
+ }
+ auto nullable1 = assert_cast<const ColumnNullable*>(col1.get());
+ arr1 = assert_cast<const
ColumnArray*>(nullable1->get_nested_column_ptr().get());
+ } else {
+ arr1 = assert_cast<const ColumnArray*>(col1.get());
+ }
+
+ if (col2->is_nullable()) {
+ if (col2->has_null()) {
+ throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+ "Arguments for function {} cannot be
null", get_name());
+ }
+ auto nullable2 = assert_cast<const ColumnNullable*>(col2.get());
+ arr2 = assert_cast<const
ColumnArray*>(nullable2->get_nested_column_ptr().get());
+ } else {
+ arr2 = assert_cast<const ColumnArray*>(col2.get());
+ }
+
+ const ColumnFloat32* float1 = nullptr;
+ const ColumnFloat32* float2 = nullptr;
+ if (arr1->get_data_ptr()->is_nullable()) {
+ if (arr1->get_data_ptr()->has_null()) {
+ throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+ "Arguments for function {} cannot have
null", get_name());
Review Comment:
ditto
##########
be/src/vec/functions/array/function_array_distance.h:
##########
@@ -109,55 +122,86 @@ class FunctionArrayDistance : public IFunction {
get_name(), col1->size(), col2->size()));
}
- ColumnArrayExecutionData arr1;
- ColumnArrayExecutionData arr2;
- if (!extract_column_array_info(*col1, arr1) ||
!extract_column_array_info(*col2, arr2)) {
- return Status::RuntimeError(fmt::format("unsupported types for
function {}({}, {})",
- get_name(),
arg1.type->get_name(),
- arg2.type->get_name()));
+ const ColumnArray* arr1 = nullptr;
+ const ColumnArray* arr2 = nullptr;
+
+ if (col1->is_nullable()) {
+ if (col1->has_null()) {
+ throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+ "Arguments for function {} cannot be
null", get_name());
+ }
+ auto nullable1 = assert_cast<const ColumnNullable*>(col1.get());
+ arr1 = assert_cast<const
ColumnArray*>(nullable1->get_nested_column_ptr().get());
+ } else {
+ arr1 = assert_cast<const ColumnArray*>(col1.get());
+ }
+
+ if (col2->is_nullable()) {
+ if (col2->has_null()) {
+ throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+ "Arguments for function {} cannot be
null", get_name());
+ }
+ auto nullable2 = assert_cast<const ColumnNullable*>(col2.get());
+ arr2 = assert_cast<const
ColumnArray*>(nullable2->get_nested_column_ptr().get());
+ } else {
+ arr2 = assert_cast<const ColumnArray*>(col2.get());
+ }
+
+ const ColumnFloat32* float1 = nullptr;
+ const ColumnFloat32* float2 = nullptr;
+ if (arr1->get_data_ptr()->is_nullable()) {
+ if (arr1->get_data_ptr()->has_null()) {
+ throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+ "Arguments for function {} cannot have
null", get_name());
+ }
+ auto nullable1 = assert_cast<const
ColumnNullable*>(arr1->get_data_ptr().get());
+ float1 = assert_cast<const
ColumnFloat32*>(nullable1->get_nested_column_ptr().get());
+ } else {
+ float1 = assert_cast<const
ColumnFloat32*>(arr1->get_data_ptr().get());
+ }
+
+ if (arr2->get_data_ptr()->is_nullable()) {
+ if (arr2->get_data_ptr()->has_null()) {
+ throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+ "Arguments for function {} cannot have
null", get_name());
Review Comment:
ditto
##########
be/src/vec/functions/array/function_array_distance.h:
##########
@@ -109,55 +122,86 @@ class FunctionArrayDistance : public IFunction {
get_name(), col1->size(), col2->size()));
}
- ColumnArrayExecutionData arr1;
- ColumnArrayExecutionData arr2;
- if (!extract_column_array_info(*col1, arr1) ||
!extract_column_array_info(*col2, arr2)) {
- return Status::RuntimeError(fmt::format("unsupported types for
function {}({}, {})",
- get_name(),
arg1.type->get_name(),
- arg2.type->get_name()));
+ const ColumnArray* arr1 = nullptr;
+ const ColumnArray* arr2 = nullptr;
+
+ if (col1->is_nullable()) {
+ if (col1->has_null()) {
+ throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+ "Arguments for function {} cannot be
null", get_name());
+ }
+ auto nullable1 = assert_cast<const ColumnNullable*>(col1.get());
+ arr1 = assert_cast<const
ColumnArray*>(nullable1->get_nested_column_ptr().get());
+ } else {
+ arr1 = assert_cast<const ColumnArray*>(col1.get());
+ }
+
+ if (col2->is_nullable()) {
+ if (col2->has_null()) {
+ throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+ "Arguments for function {} cannot be
null", get_name());
Review Comment:
```suggestion
"The second arguments for function {}
cannot be null", get_name());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]