github-actions[bot] commented on code in PR #42353:
URL: https://github.com/apache/doris/pull/42353#discussion_r1813074124
##########
be/src/vec/functions/function_coalesce.cpp:
##########
@@ -68,25 +70,26 @@ class FunctionCoalesce : public IFunction {
size_t get_number_of_arguments() const override { return 0; }
DataTypePtr get_return_type_impl(const DataTypes& arguments) const
override {
- DataTypePtr res;
for (const auto& arg : arguments) {
if (!arg->is_nullable()) {
- res = arg;
+ result_type = arg;
break;
}
}
- res = res ? res : arguments[0];
-
- const ColumnsWithTypeAndName is_not_null_col {{nullptr,
make_nullable(res), ""}};
- func_is_not_null = SimpleFunctionFactory::instance().get_function(
- "is_not_null_pred", is_not_null_col,
std::make_shared<DataTypeUInt8>());
-
- return res;
+ result_type = result_type ? result_type : arguments[0];
+ return result_type;
}
Status execute_impl(FunctionContext* context, Block& block, const
ColumnNumbers& arguments,
Review Comment:
warning: function 'execute_impl' has cognitive complexity of 55 (threshold
50) [readability-function-cognitive-complexity]
```cpp
Status execute_impl(FunctionContext* context, Block& block, const
ColumnNumbers& arguments,
^
```
<details>
<summary>Additional context</summary>
**be/src/vec/functions/function_coalesce.cpp:85:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (!func_is_not_null) [[unlikely]] {
^
```
**be/src/vec/functions/function_coalesce.cpp:97:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
for (size_t i = 0; i < arguments.size(); ++i) {
^
```
**be/src/vec/functions/function_coalesce.cpp:100:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (!arg_type->is_nullable()) {
^
```
**be/src/vec/functions/function_coalesce.cpp:101:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (i == 0) {
^
```
**be/src/vec/functions/function_coalesce.cpp:106:** +1, nesting level
increased to 3
```cpp
} else {
^
```
**be/src/vec/functions/function_coalesce.cpp:122:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (!result_type->is_nullable()) {
^
```
**be/src/vec/functions/function_coalesce.cpp:124:** +1, nesting level
increased to 1
```cpp
} else {
^
```
**be/src/vec/functions/function_coalesce.cpp:131:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (is_string_result) {
^
```
**be/src/vec/functions/function_coalesce.cpp:133:** +1, nesting level
increased to 1
```cpp
} else {
^
```
**be/src/vec/functions/function_coalesce.cpp:143:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
for (size_t i = 0; i < argument_size; ++i) {
^
```
**be/src/vec/functions/function_coalesce.cpp:148:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (auto* nullable = check_and_get_column<const
ColumnNullable>(*argument_columns[i])) {
^
```
**be/src/vec/functions/function_coalesce.cpp:157:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
for (size_t i = 0; i < argument_size && remaining_rows; ++i) {
^
```
**be/src/vec/functions/function_coalesce.cpp:157:** +1
```cpp
for (size_t i = 0; i < argument_size && remaining_rows; ++i) {
^
```
**be/src/vec/functions/function_coalesce.cpp:160:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
RETURN_IF_ERROR(
^
```
**be/src/common/status.h:619:** expanded from macro 'RETURN_IF_ERROR'
```cpp
do { \
^
```
**be/src/vec/functions/function_coalesce.cpp:160:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
RETURN_IF_ERROR(
^
```
**be/src/common/status.h:621:** expanded from macro 'RETURN_IF_ERROR'
```cpp
if (UNLIKELY(!_status_.ok())) { \
^
```
**be/src/vec/functions/function_coalesce.cpp:172:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
for (size_t j = 0; j < input_rows_count; ++j) {
^
```
**be/src/vec/functions/function_coalesce.cpp:178:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (remaining_rows == 0) {
^
```
**be/src/vec/functions/function_coalesce.cpp:182:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
for (size_t row = 0; row < input_rows_count; ++row) {
^
```
**be/src/vec/functions/function_coalesce.cpp:186:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (is_same_column_count == input_rows_count) {
^
```
**be/src/vec/functions/function_coalesce.cpp:187:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
if (result_type->is_nullable()) {
^
```
**be/src/vec/functions/function_coalesce.cpp:190:** +1, nesting level
increased to 4
```cpp
} else {
^
```
**be/src/vec/functions/function_coalesce.cpp:197:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
if (!is_string_result) {
^
```
**be/src/vec/functions/function_coalesce.cpp:201:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
RETURN_IF_ERROR(filled_result_column(result_type,
result_column,
^
```
**be/src/common/status.h:619:** expanded from macro 'RETURN_IF_ERROR'
```cpp
do { \
^
```
**be/src/vec/functions/function_coalesce.cpp:201:** +4, including nesting
penalty of 3, nesting level increased to 4
```cpp
RETURN_IF_ERROR(filled_result_column(result_type,
result_column,
^
```
**be/src/common/status.h:621:** expanded from macro 'RETURN_IF_ERROR'
```cpp
if (UNLIKELY(!_status_.ok())) { \
^
```
**be/src/vec/functions/function_coalesce.cpp:207:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (is_string_result) {
^
```
**be/src/vec/functions/function_coalesce.cpp:209:** +2, including nesting
penalty of 1, nesting level increased to 2
```cpp
for (size_t row = 0; row < input_rows_count; ++row) {
^
```
**be/src/vec/functions/function_coalesce.cpp:210:** +3, including nesting
penalty of 2, nesting level increased to 3
```cpp
if (null_map_data[row]) { //should be null
^
```
**be/src/vec/functions/function_coalesce.cpp:212:** +1, nesting level
increased to 3
```cpp
} else {
^
```
**be/src/vec/functions/function_coalesce.cpp:218:** +1, including nesting
penalty of 0, nesting level increased to 1
```cpp
if (result_type->is_nullable()) {
^
```
**be/src/vec/functions/function_coalesce.cpp:221:** +1, nesting level
increased to 1
```cpp
} else {
^
```
</details>
--
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]