2010YOUY01 opened a new issue, #11623: URL: https://github.com/apache/datafusion/issues/11623
### Describe the bug Query `select 'foo' ~ null;` should be valid, since `null` can be treated as a missing string regex, so the final result should be `NULL` Current datafusion-cli: ``` DataFusion CLI v40.0.0 > select 'foo' ~ null; Error during planning: Cannot infer common argument type for regex operation Utf8 ~ Null ``` Expected behavior if the same query is executed in DuckDB: ``` D select 'foo' ~ null; ┌────────────────────────────────┐ │ regexp_full_match('foo', NULL) │ │ boolean │ ├────────────────────────────────┤ │ │ └────────────────────────────────┘ ``` There is another query also handles null incorrectly, `right('foo', null)` is a column of nulls, of it's operated on `~`, a internal error will be triggered. ``` > create table t1(v1 string); 0 row(s) fetched. Elapsed 0.148 seconds. > insert into t1 values ('foo'); +-------+ | count | +-------+ | 1 | +-------+ 1 row(s) fetched. Elapsed 0.071 seconds. > select v1 ~ right('foo', null) from t1; Internal error: compute_utf8_flag_op_scalar failed to cast literal value NULL for operation 'regexp_is_match'. 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: ``` D create table t1(v1 string); D insert into t1 values ('foo'); D D select v1 ~ right('foo', null) from t1; ┌───────────────────────────────────────────┐ │ regexp_full_match(v1, right('foo', NULL)) │ │ boolean │ ├───────────────────────────────────────────┤ │ │ └───────────────────────────────────────────┘ ``` ### To Reproduce _No response_ ### Expected behavior _No response_ ### Additional context Found by SQLancer https://github.com/apache/datafusion/issues/11030 -- 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: github-unsubscr...@datafusion.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org