github-actions[bot] commented on code in PR #28030:
URL: https://github.com/apache/doris/pull/28030#discussion_r1415595228
##########
be/src/vec/functions/function_string.h:
##########
@@ -1747,50 +1747,66 @@ class FunctionSplitByString : public IFunction {
}
Status execute_impl(FunctionContext* /*context*/, Block& block, const
ColumnNumbers& arguments,
- size_t result, size_t /*input_rows_count*/) const
override {
+ size_t result, size_t input_rows_count) const override
{
DCHECK_EQ(arguments.size(), 2);
const auto& [src_column, left_const] =
unpack_if_const(block.get_by_position(arguments[0]).column);
const auto& [right_column, right_const] =
unpack_if_const(block.get_by_position(arguments[1]).column);
+ DataTypePtr right_column_type =
block.get_by_position(arguments[1]).type;
DataTypePtr src_column_type = block.get_by_position(arguments[0]).type;
auto dest_column_ptr =
ColumnArray::create(make_nullable(src_column_type)->create_column(),
ColumnArray::ColumnOffsets::create());
IColumn* dest_nested_column = &dest_column_ptr->get_data();
auto& dest_offsets = dest_column_ptr->get_offsets();
DCHECK(dest_nested_column != nullptr);
- dest_nested_column->reserve(0);
- dest_offsets.reserve(0);
+ dest_nested_column->reserve(input_rows_count);
+ dest_offsets.reserve(input_rows_count);
NullMapType* dest_nested_null_map = nullptr;
ColumnNullable* dest_nullable_col =
reinterpret_cast<ColumnNullable*>(dest_nested_column);
dest_nested_column = dest_nullable_col->get_nested_column_ptr();
dest_nested_null_map =
&dest_nullable_col->get_null_map_column().get_data();
- if (auto col_left =
check_and_get_column<ColumnString>(src_column.get())) {
- if (auto col_right =
check_and_get_column<ColumnString>(right_column.get())) {
- if (right_const) {
- _execute_constant(*col_left, col_right->get_data_at(0),
*dest_nested_column,
- dest_offsets, dest_nested_null_map);
- } else {
- _execute_vector(*col_left, *col_right,
*dest_nested_column, dest_offsets,
- dest_nested_null_map);
- }
+ auto col_left = check_and_get_column<ColumnString>(src_column.get());
+ if (!col_left) {
+ return Status::InternalError("Left operator of function {} can not
be {}", get_name(),
+ src_column_type->get_name());
+ }
- block.replace_by_position(result, std::move(dest_column_ptr));
- return Status::OK();
- }
+ auto col_right =
check_and_get_column<ColumnString>(right_column.get());
+ if (!col_right) {
+ return Status::InternalError("Right operator of function {} can
not be {}", get_name(),
+ right_column_type->get_name());
}
- return Status::RuntimeError("unimplements function {}", get_name());
+
+ // split_by_string(ColumnString, "xxx")
+ if (right_const) {
+ _execute_constant_delimiter(*col_left, col_right->get_data_at(0),
*dest_nested_column,
+ dest_offsets, dest_nested_null_map);
+ } else if (left_const) {
+ // split_by_string("xxx", ColumnString)
+ _execute_constant_src_string(col_left->get_data_at(0), *col_right,
*dest_nested_column,
+ dest_offsets, dest_nested_null_map);
+ } else {
+ // split_by_string(ColumnString, ColumnString)
+ _execute_vector(*col_left, *col_right, *dest_nested_column,
dest_offsets,
+ dest_nested_null_map);
+ }
+
+ block.replace_by_position(result, std::move(dest_column_ptr));
+
+ return Status::OK();
}
private:
- void _execute_constant(const ColumnString& src_column_string, const
StringRef& delimiter_ref,
- IColumn& dest_nested_column,
ColumnArray::Offsets64& dest_offsets,
- NullMapType* dest_nested_null_map) const {
+ void _execute_constant_delimiter(const ColumnString& src_column_string,
Review Comment:
warning: method '_execute_constant_delimiter' can be made static
[readability-convert-member-functions-to-static]
```suggestion
static void _execute_constant_delimiter(const ColumnString&
src_column_string,
```
be/src/vec/functions/function_string.h:1808:
```diff
- NullMapType* dest_nested_null_map)
const {
+ NullMapType* dest_nested_null_map) {
```
##########
be/src/vec/functions/function_string.h:
##########
@@ -1911,6 +1927,60 @@
}
}
+ void _execute_constant_src_string(const StringRef& str_ref, const
ColumnString& delimiter_col,
+ IColumn& dest_nested_column,
+ ColumnArray::Offsets64& dest_offsets,
+ NullMapType* dest_nested_null_map) const
{
+ ColumnString& dest_column_string =
reinterpret_cast<ColumnString&>(dest_nested_column);
Review Comment:
warning: use auto when initializing with a cast to avoid duplicating the
type name [modernize-use-auto]
```suggestion
auto& dest_column_string =
reinterpret_cast<ColumnString&>(dest_nested_column);
```
--
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]