apache / apache/datafusion

Misleading query results due to likely internal parsing differences

Aperta
#12,655 4 commenti 0 reazioni 1 assegnatario Rivendicata da @doupache Vedi su GitHub
bug
Lingua principale
Rust
Stelle
9.3k
Fork
2.4k
Merge medio
3g 11h
PR unite (30g)
360

Descrizione

### Describe the bug

I ran across a query where `select * from foo where col < 1.3` returns values rendered as `1.3`. My guess is that this is either a subtle parsing difference or possibly the result of a differently ordered type cast. If you change the column type from `float` to `double` the issue no longer occurs.

Also, just to preempt anyone jumping to floating point values are approximations, I'm fully aware. I know that this issue is likely caused either by the miniscule difference between `f32::from_str` and `f64::from_str` or `f32 as f64` vs `f64 as f32` or some combination thereof. However, given that this is all one parser, it feels like a bug that we've parsed two different values for the same string.

### To Reproduce

```
DataFusion CLI v42.0.0
> create table test(col float);
0 row(s) fetched.
Elapsed 0.008 seconds.

> insert into test values (1.1), (1.2), (1.3), (1.4), (1.5);
+-------+
| count |
+-------+
| 5 |
+-------+
1 row(s) fetched.
Elapsed 0.007 seconds.

> select * from test where col > 1.3;
+-----+
| col |
+-----+
| 1.4 |
| 1.5 |
+-----+
2 row(s) fetched.
Elapsed 0.004 seconds.

> select * from test where col < 1.3
;
+-----+
| col |
+-----+
| 1.1 |
| 1.2 |
| 1.3 |
+-----+
3 row(s) fetched.
Elapsed 0.002 seconds.
```

### Expected behavior

I would expect that `1.3 == 1.3`.

### Additional context

_No response_

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.