-
Notifications
You must be signed in to change notification settings - Fork 1.5k
UNION ALL not correctly projects the floating numbers #10688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
When
|
Thats weird.
So first values transforms into |
take |
I think it is because the first |
Agreed. I also found it.
If we cast |
I wanted to share something I found. I tried to observe the plan transformation step by step:
I found that |
After some testing, I found it could be an arrow-cast issue. When trying to cast a float32 to float64, the precision is missing.
I found it happens in datafusion/datafusion/common/src/scalar/mod.rs Line 2506 in 3d00760
let expr2 = ScalarValue::Float64(Some(128.2))
.cast_to(&DataType::Float32)
.unwrap()
.cast_to(&DataType::Float64)
.unwrap();
println!("expr2: {:?}", expr2);
------------------------------------
expr2: Float64(128.1999969482422) It happens in (Float16, Float32) => cast_numeric_arrays::<Float16Type, Float32Type>(array, cast_options), I think it maybe not a DataFusion issue but a arrow-cast issue. |
good catch, we can check that Even simple conversion gives weird result
Opposite conversion is ok though
For me looks like a conversion issue, especially strange its happening when we convert into larger precision. |
Indeed, it's a conversion issue. I tried to dig into the root cause and found that arrow-cast uses the crate num to handle casting problems. I tried to use it directly:
I have no idea how to fix it in DataFusion. Maybe we need to go back to the crate |
Well, that might be some representation issue.
|
Filed rust-lang/rust#125777 |
So this looks like a representation hm... feature, it can be hard to explain for users but it is float output semantics |
there is some issue with UNION ALL and type derivation
I expect those numbers to be the same. And that what duck db does
Originally posted by @comphead in #10634 (review)
The text was updated successfully, but these errors were encountered: