mrhhsg opened a new pull request, #68359:
URL: https://github.com/apache/doris/pull/68359
### What problem does this PR solve?
Issue Number: None
Problem Summary:
`regexp_extract`, `regexp_extract_or_null`, `regexp_extract_all`,
`regexp_extract_all_array`, `regexp_replace` and `regexp_replace_one` handled
an invalid regex pattern differently depending on where the pattern came
from.
A constant pattern is compiled in `open()` and the query fails with
`INVALID_ARGUMENT`. A pattern read from a column is compiled per row in the
execute path, and the same compile failure was swallowed: the row was turned
into NULL and only a warning was recorded.
```sql
CREATE TABLE t (id INT, s STRING, p STRING, repl STRING) ...;
INSERT INTO t VALUES (1, 'abc', '[', 'x');
SELECT regexp_extract('abc', '[', 0); -- INVALID_ARGUMENT
SELECT regexp_extract(s, p, 0) FROM t; -- NULL
SELECT regexp_replace('abc', '[', 'x'); -- INVALID_ARGUMENT
SELECT regexp_replace(s, p, repl) FROM t; -- NULL
```
So the same malformed pattern was either rejected or silently produced NULL
depending on the physical shape of the argument, which hides data problems
behind an unrelated NULL. `regexp_count` and `regexp` already raised the
error
on the column path.
This PR makes the column path of the extract/replace families throw the same
`Status::InvalidArgument` that the constant path returns from `open()`, so an
invalid pattern always fails the query. The null-map plumbing that only
existed
to mark those rows is removed, together with the now-unused `push_null`
handlers of `regexp_extract_all`.
### Release note
`regexp_extract`, `regexp_extract_or_null`, `regexp_extract_all`,
`regexp_extract_all_array`, `regexp_replace` and `regexp_replace_one` now
fail
the query with `INVALID_ARGUMENT` when a regex pattern read from a column
does
not compile, matching the behavior for constant patterns. Previously such
rows
returned NULL.
### Check List (For Author)
- Test:
- Unit Test: `FunctionLikeTest.regexp_invalid_column_pattern_fails`
covers
every family with a mixed valid/invalid pattern column; the existing
`FunctionLikeTest.*` and `function_string_test.function_regexp*` still
pass.
- Regression test: new `test_regexp_invalid_pattern` compares the
constant
and column paths for all families; `test_string_function_regexp`,
`test_regexp_chinese`, `test_split_by_regexp`, `nereids_syntax_p0`
`test_regexp_replace`/`function`, `nereids_function_p0` `R` and
`fold_constant_nullable` pass locally.
- Behavior changed: Yes. An invalid pattern read from a column now fails the
query instead of yielding NULL for that row.
- Does this need documentation: No
https://claude.ai/code/session_01CvzmDA8snJbHHhErBB58sB
--
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]