2010YOUY01 opened a new issue, #11742: URL: https://github.com/apache/datafusion/issues/11742
### Describe the bug Here is Q1 `select nvl(v1, 0.5) from tt;` then let `Q1` union a empty set, two queries should have the same result, but it's returning a different result. Looks like it's an incorrect casting (cast double to int), since double has higher precision, it should cast in the opposite direction Reproducer in datafusion-cli ``` DataFusion CLI v40.0.0 > create table tt(v1 int); 0 row(s) fetched. Elapsed 0.072 seconds. > insert into tt values (1),(null); +-------+ | count | +-------+ | 2 | +-------+ 1 row(s) fetched. Elapsed 0.051 seconds. > select nvl(v1, 0.5) from tt; +-------------------------+ | nvl(tt.v1,Float64(0.5)) | +-------------------------+ | 1.0 | | 0.5 | +-------------------------+ 2 row(s) fetched. Elapsed 0.015 seconds. > select nvl(v1, 0.5) from tt union all select null where false; +-------------------------+ | nvl(tt.v1,Float64(0.5)) | +-------------------------+ | 1 | | 0 | +-------------------------+ 2 row(s) fetched. Elapsed 0.007 seconds. // Example: two number have different type, cast to the type with higher precision/range > select 1 + 0.5; +-------------------------+ | Int64(1) + Float64(0.5) | +-------------------------+ | 1.5 | +-------------------------+ 1 row(s) fetched. Elapsed 0.008 seconds. ``` ### 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