github-actions[bot] commented on code in PR #68579:
URL: https://github.com/apache/doris/pull/68579#discussion_r4246211841
##########
be/src/exprs/function/function_regexp.cpp:
##########
@@ -531,30 +525,87 @@ class FunctionRegexpReplace : public IFunction {
auto result_null_map =
regexp_result_null_map<check_null>(std::move(null_map),
input_rows_count);
+ bool col_const[3];
+ for (int i = 0; i < 3; ++i) {
+ col_const[i] =
is_column_const(*args_block.get_by_position(args[i]).column);
+ }
ColumnPtr argument_columns[3];
- const bool parameters_const =
prepare_regexp_argument_columns(
- args_block, args, {1, 2}, argument_columns);
-
+ const auto& [source_column, source_const] =
+
unpack_if_const(args_block.get_by_position(args[0]).column);
+ argument_columns[0] = source_column;
+ default_preprocess_parameter_columns(argument_columns,
col_const, {1, 2},
+ args_block, args);
+ const bool parameters_const = col_const[1] && col_const[2];
+
+ // FE checks that the options are a constant, so the first
row holds their
+ // value even when BE evaluates the constant to a full
column. Each row that
+ // compiles the pattern, e.g. of an empty constant
pattern, needs the options
+ // in both branches below.
StringRef options_value;
+ if (args.size() == 4) {
+ options_value =
+
args_block.get_by_position(args[3]).column->get_data_at(0);
+ }
+
if (parameters_const) {
+ if constexpr (std::is_same_v<FourParamTypes,
ParamTypes>) {
Review Comment:
[P2] Cache deferred regex patterns with variable replacements
With `enable_fold_constant_by_be=false`, `regexp_replace(s, 'a+', r, if(1 +
crc32('') > 0, 'none', 'ignore_invalid_escape'))` over a table leaves the
options unevaluated in `open()` while `r` is a full column. `parameters_const`
excludes lazy compilation because it also requires a constant replacement, so
`_execute_inner_loop` constructs and destroys the same RE2 for every row and
block; equivalent literal options compile once. Move lazy initialization before
this branch, retaining the query-constant pattern guard, and cover variable
replacements in both replacement variants. This concerns repeated compilation
of one constant pattern, distinct from the earlier varying-pattern cache issue.
--
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]