mrhhsg commented on code in PR #68579:
URL: https://github.com/apache/doris/pull/68579#discussion_r4218814825
##########
be/src/exprs/function/array/function_array_apply.cpp:
##########
@@ -88,11 +90,11 @@ class FunctionArrayApply : public IFunction {
DataTypePtr src_column_type = block.get_by_position(arguments[0]).type;
auto nested_type = assert_cast<const
DataTypeArray&>(*src_column_type).get_nested_type();
+ // op and val are constants checked in FE, so the first row holds
their values. A constant
+ // expression such as an IF one is not a ColumnConst.
const std::string& condition =
block.get_by_position(arguments[1]).column->get_data_at(0).to_string();
-
- const ColumnConst& rhs_value_column =
- static_cast<const
ColumnConst&>(*block.get_by_position(arguments[2]).column.get());
+ const IColumn& rhs_value_column =
*block.get_by_position(arguments[2]).column;
Review Comment:
Fixed in 8963623f870: array_apply evaluates a constant source array once and
returns a ColumnConst result. The BE unit test checks the result shape, and a
mixed-column SQL regression passes.
##########
be/src/exprs/function/function_regexp.cpp:
##########
@@ -361,29 +361,19 @@ class FunctionRegexpReplace : public IFunction {
if (context->is_col_constant(1)) {
DCHECK(!context->get_function_state(scope));
const auto pattern_col =
context->get_constant_col(1)->column_ptr;
- const auto& pattern = pattern_col->get_data_at(0);
- if (pattern.size == 0) {
- return Status::OK();
- }
-
- std::string error_str;
- std::unique_ptr<re2::RE2> scoped_re;
StringRef options_value;
if constexpr (std::is_same_v<FourParamTypes, ParamTypes>) {
DCHECK_EQ(context->get_num_args(), 4);
- DCHECK(context->is_col_constant(3));
+ // The options are a constant, but a constant expression
such as an arithmetic
+ // one is not evaluated in open. Then the regex is
compiled in execute.
+ if (!context->is_col_constant(3)) {
+ return Status::OK();
+ }
const auto options_col =
context->get_constant_col(3)->column_ptr;
options_value = options_col->get_data_at(0);
}
-
- bool st = StringFunctions::compile_regex(pattern, &error_str,
StringRef(),
- options_value,
scoped_re);
- if (!st) {
- context->set_error(error_str.c_str());
- return Status::InvalidArgument(error_str);
- }
- std::shared_ptr<re2::RE2> re(scoped_re.release());
- context->set_function_state(scope, re);
+ return compile_constant_pattern(context,
pattern_col->get_data_at(0),
Review Comment:
Fixed in 8963623f870: regexp replacement skips eager pattern compilation
when constant options are NULL. BE unit tests cover both variants; the multirow
VALUES regression produces NULL.
##########
be/src/exprs/function/function_regexp.cpp:
##########
@@ -411,14 +401,25 @@ class FunctionRegexpReplace : public IFunction {
default_preprocess_parameter_columns(argument_columns, col_const, {1,
2}, block, arguments);
+ if constexpr (std::is_same_v<FourParamTypes, ParamTypes>) {
+ // The regex of a constant pattern was not compiled in open
because the options were
+ // not evaluated there. Compile it once with the options of the
first row.
+ if (col_const[1] && !context->is_col_constant(3) &&
input_rows_count > 0 &&
Review Comment:
Fixed in 8963623f870: both regexp replacement variants keep a constant
source compact and index row 0 in mixed-column execution. BE unit tests and SQL
regression cover this path.
--
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]