crepererum opened a new issue, #13164:
URL: https://github.com/apache/datafusion/issues/13164
### Describe the bug
`nullif(float_arg, mask)` results in a Utf8 output but should preserve the
float type.
### To Reproduce
Use the following sqllogictest (I've adapted the `nullif.slt` file, that's
why there are some more columns in that table):
```text
statement ok
CREATE TABLE test(
int_field INT,
bool_field BOOLEAN,
text_field TEXT,
more_ints INT,
float_field FLOAT
) as VALUES
(1, true, 'abc', 2, 1.1),
(2, false, 'def', 2, 2.2),
(3, NULL, 'ghij', 3, 3.3),
(NULL, NULL, NULL, 4, NULL),
(4, false, 'zxc', 5, 4.4),
(NULL, true, NULL, 6, NULL)
;
query R rowsort
SELECT NULLIF(float_field, bool_field) FROM test;
----
1.1
2.2
3.3
4.4
NULL
NULL
```
This will fail with:
```text
External error: query columns mismatch:
[SQL] SELECT NULLIF(float_field, bool_field) FROM test;
[Expected] [R]
[Actual ] [T]
```
which means the output type was coerced to `Utf8`.
You can further test this by adding some floating point operation:
```
query R rowsort
SELECT NULLIF(float_field, bool_field) + 1.0 FROM test;
----
2.1
3.2
4.3
5.4
NULL
NULL
```
which fails with:
```text
External error: query failed: DataFusion error: Error during planning:
Cannot coerce arithmetic expression Utf8 + Float64 to valid types
[SQL] SELECT NULLIF(float_field, bool_field) + 1.0 FROM test;
```
### Expected behavior
Both test should pass.
### Additional context
Tested with 444a673682a4823b98695568ecdab1087b5b6a60.
--
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]