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 #11030
Describe the bug
Query
select 'foo' ~ null;should be valid, sincenullcan be treated as a missing string regex, so the final result should beNULLCurrent datafusion-cli:
Expected behavior if the same query is executed in DuckDB:
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.Expected:
To Reproduce
No response
Expected behavior
No response
Additional context
Found by SQLancer #11030