mrhhsg commented on code in PR #68359:
URL: https://github.com/apache/doris/pull/68359#discussion_r4236710558
##########
be/src/exprs/function/function_regexp.cpp:
##########
@@ -74,6 +76,60 @@ static bool advance_re2_search_position(const char* data,
size_t size,
return true;
}
+// The regexp functions below handle NULL rows themselves
(use_default_implementation_for_nulls()
+// returns false). The framework's default path runs a function over the
nested column of a
+// Nullable argument, and the bytes stored under a NULL slot are whatever the
producer left there;
+// compiling them as a pattern could fail and abort a query whose result for
that row is simply
+// NULL.
+//
+// Strips Nullable from every argument into `nested_block` (a ColumnConst
wrapper stays, so the
+// const/full handling of the functions applies unchanged) and ORs the
argument null maps into
+// `null_map`, which the functions skip while executing and hand back as the
result null map.
+// Returns false when an argument is a NULL constant: the whole result is NULL.
+bool unnest_regexp_arguments(const Block& block, const ColumnNumbers&
arguments,
+ Block& nested_block, ColumnNumbers&
nested_arguments,
+ NullMap& null_map) {
+ for (const auto argument : arguments) {
+ const auto& column = block.get_by_position(argument);
+ NullableColumnInfo info;
+ if (column.type->is_nullable()) {
+ info = column.get_nullable_column_info();
+ if (info.only_null) {
+ return false;
+ }
+ if (info.has_null) {
+ // A ColumnConst holding NULL is only_null, so this is a full
column.
+ DCHECK(!info.is_const);
+ VectorizedUtils::update_null_map(null_map,
+
column.get_nullable_null_map_column()->get_data());
+ }
+ }
+ nested_arguments.push_back(nested_block.columns());
+ nested_block.insert(column.unnest_nullable(info, false));
+ }
+ return true;
+}
+
+// Shared execute() prologue of the regexp functions: a NULL constant argument
makes the result
+// a NULL constant, otherwise `execute` runs over the Nullable-stripped
arguments and returns the
+// result column already wrapped with `null_map`.
+template <typename Execute>
+Status execute_regexp_with_nulls(Block& block, const ColumnNumbers& arguments,
uint32_t result,
+ size_t input_rows_count, Execute&& execute) {
+ auto& result_column = block.get_by_position(result);
+ auto null_map = ColumnUInt8::create(input_rows_count, 0);
Review Comment:
Thanks, done in 506f5df266a.
- `execute_regexp_with_nulls()` now picks the path once per block with
`have_null_column(block, arguments)`. For non-nullable inputs the original
block/arguments are passed straight through with `std::false_type` and no input
NULL map or nested block; for nullable inputs the existing unnesting, NULL-map
merging, all-NULL short-circuit and NULL-row skipping run with `std::true_type`.
- count, extract, extract_or_null, extract_all(_array) and replace(_one) all
go through this dispatch and wrap their input NULL checks in `if constexpr
(CheckNull)`. `regexp_count`'s separate fast path is folded into it.
- Input NULL checking stays separate from output nullability:
`regexp_result_null_map<CheckNull>()` still provides the result NULL map when
there is no input NULL map, so `regexp_extract_or_null` returns NULL on no
match for non-nullable input, and a nullable count result keeps its wrapper.
- Tests: the hidden-invalid-payload and count fast-path tests are kept (the
NULL rows now sit between valid rows). The new
`FunctionLikeTest.regexp_non_nullable_arguments` covers non-nullable
extract/extract_all/replace with column patterns and with all-constant
parameters, including the or_null no-match NULL. The regression case adds a NOT
NULL table with column and constant patterns.
--
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]