github-actions[bot] commented on code in PR #16404:
URL: https://github.com/apache/doris/pull/16404#discussion_r1095609958
##########
be/src/vec/functions/function_helpers.cpp:
##########
@@ -20,83 +20,88 @@
#include "vec/functions/function_helpers.h"
-#include "common/consts.h"
#include "vec/columns/column_nullable.h"
#include "vec/data_types/data_type_nullable.h"
#include "vec/functions/function.h"
namespace doris::vectorized {
-std::tuple<Block, ColumnNumbers> create_block_with_nested_columns(const Block&
block,
- const
ColumnNumbers& args,
- const bool
need_check_same) {
+Block create_block_with_nested_columns_only_args(const Block& block, const
ColumnNumbers& args) {
+ std::set<size_t> args_set(args.begin(), args.end());
Block res;
- ColumnNumbers res_args(args.size());
-
- // only build temp block by args column, if args[i] == args[j]
- // just keep one
- for (size_t i = 0; i < args.size(); ++i) {
- bool is_in_res = false;
- size_t pre_loc = 0;
-
- if (need_check_same) {
- for (int j = 0; j < i; ++j) {
- if (args[j] == args[i]) {
- is_in_res = true;
- pre_loc = res_args[j];
- break;
- }
- }
- }
- if (!is_in_res) {
- const auto& col = block.get_by_position(args[i]);
- if (col.type->is_nullable()) {
- const DataTypePtr& nested_type =
- static_cast<const
DataTypeNullable&>(*col.type).get_nested_type();
-
- if (!col.column) {
- res.insert({nullptr, nested_type, col.name});
- } else if (auto* nullable =
check_and_get_column<ColumnNullable>(*col.column)) {
- const auto& nested_col = nullable->get_nested_column_ptr();
- res.insert({nested_col, nested_type, col.name});
- } else if (auto* const_column =
check_and_get_column<ColumnConst>(*col.column)) {
- const auto& nested_col =
-
check_and_get_column<ColumnNullable>(const_column->get_data_column())
- ->get_nested_column_ptr();
- res.insert({ColumnConst::create(nested_col,
col.column->size()), nested_type,
- col.name});
- } else {
- LOG(FATAL) << "Illegal column for DataTypeNullable";
- }
+ for (auto i : args_set) {
+ const auto& col = block.get_by_position(i);
+
+ if (col.type->is_nullable()) {
+ const DataTypePtr& nested_type =
+ static_cast<const
DataTypeNullable&>(*col.type).get_nested_type();
+
+ if (!col.column) {
+ res.insert({nullptr, nested_type, col.name});
+ } else if (auto* nullable =
check_and_get_column<ColumnNullable>(*col.column)) {
+ const auto& nested_col = nullable->get_nested_column_ptr();
+ res.insert({nested_col, nested_type, col.name});
+ } else if (auto* const_column =
check_and_get_column<ColumnConst>(*col.column)) {
+ const auto& nested_col =
+
check_and_get_column<ColumnNullable>(const_column->get_data_column())
+ ->get_nested_column_ptr();
+ res.insert({ColumnConst::create(nested_col,
col.column->size()), nested_type,
+ col.name});
} else {
- res.insert(col);
+ LOG(FATAL) << "Illegal column for DataTypeNullable";
}
-
- res_args[i] = res.columns() - 1;
} else {
- res_args[i] = pre_loc;
+ res.insert(col);
}
}
- // TODO: only support match function, rethink the logic
- for (const auto& ctn : block) {
- if (ctn.name.size() > BeConsts::BLOCK_TEMP_COLUMN_PREFIX.size() &&
- starts_with(ctn.name, BeConsts::BLOCK_TEMP_COLUMN_PREFIX)) {
- res.insert(ctn);
- }
+ return res;
+}
+
+static Block create_block_with_nested_columns_impl(const Block& block,
+ const
std::unordered_set<size_t>& args) {
+ Block res;
+ size_t columns = block.columns();
+
+ for (size_t i = 0; i < columns; ++i) {
+ const auto& col = block.get_by_position(i);
+
+ if (args.count(i) && col.type->is_nullable()) {
+ const DataTypePtr& nested_type =
+ static_cast<const
DataTypeNullable&>(*col.type).get_nested_type();
+
+ if (!col.column) {
+ res.insert({nullptr, nested_type, col.name});
+ } else if (auto* nullable =
check_and_get_column<ColumnNullable>(*col.column)) {
+ const auto& nested_col = nullable->get_nested_column_ptr();
+ res.insert({nested_col, nested_type, col.name});
+ } else if (auto* const_column =
check_and_get_column<ColumnConst>(*col.column)) {
+ const auto& nested_col =
+
check_and_get_column<ColumnNullable>(const_column->get_data_column())
+ ->get_nested_column_ptr();
+ res.insert({ColumnConst::create(nested_col,
col.column->size()), nested_type,
+ col.name});
+ } else {
+ LOG(FATAL) << "Illegal column for DataTypeNullable";
+ }
+ } else
+ res.insert(col);
Review Comment:
warning: statement should be inside braces
[readability-braces-around-statements]
```suggestion
} else {
res.insert(col);
}
```
--
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]