You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let pattern = fetch_string_arg!(&args[1], "pattern", T, _regexp_replace_early_abort);
fetch_string_arg not passing the correct length to the _regexp_replace_early_abort function - when this specific arg is a scalar, its "array len" is just 1, and the abort function creates a 1-len array as the result.
To Reproduce
Normal case - values are valid scalars or array nulls:
> select regexp_replace(col, 'a', 'c') from (values ('a'), ('b')) as tbl(col);
+---------------------------------------------+
| regexp_replace(tbl.col,Utf8("a"),Utf8("c")) |
+---------------------------------------------+
| c |
| b |
+---------------------------------------------+
2 row(s) fetched.
Elapsed 0.001 seconds.
> select regexp_replace(col, ncol, 'c') from (values ('a', NULL), ('b', NULL)) as tbl(col, ncol);
+--------------------------------------------+
| regexp_replace(tbl.col,tbl.ncol,Utf8("c")) |
+--------------------------------------------+
| |
| |
+--------------------------------------------+
Failing case - pattern or replacement is a scalar NULL:
> select regexp_replace(col, NULL, 'c') from (values ('a'), ('b')) as tbl(col);
Internal error: UDF returned a different number of rows than expected. Expected: 2, Got: 1.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker
> select regexp_replace(col, 'a', NULL) from (values ('a'), ('b')) as tbl(col);
Internal error: UDF returned a different number of rows than expected. Expected: 2, Got: 1.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker
Expected behavior
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
regexp_replace fails to produce correct number of rows if either
pattern
orreplacement
arg is a scalar NULL.I think this is due to
datafusion/datafusion/functions/src/regex/regexpreplace.rs
Line 316 in 7a23ea9
fetch_string_arg
not passing the correct length to the_regexp_replace_early_abort
function - when this specific arg is a scalar, its "array len" is just 1, and the abort function creates a 1-len array as the result.To Reproduce
Normal case - values are valid scalars or array nulls:
Failing case - pattern or replacement is a scalar NULL:
Expected behavior
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: