mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-18 08:44:07 +00:00
* test(recordbatch): compare float zero predicates with DataFusion `SimpleFilterEvaluator` filters SST rows exactly, so it has to agree with the SQL predicate that DataFusion evaluates above the scan. DataFusion compares -0.0 and +0.0 as equal. Evaluate comparisons against both zeros, NaN and NULL in Float64 and Float32 columns, and check the selected rows against DataFusion's filter. On main this fails: `v = Float64(0)` selects only the +0.0 row, while DataFusion selects both zeros. Signed-off-by: dayan02dev <pawarudayan92@gmail.com> * fix(recordbatch): compare -0.0 and +0.0 as equal in simple filters DataFusion 55 normalizes -0.0 to +0.0 before Arrow's comparison kernels, so SQL compares the two zeros as equal. SimpleFilterEvaluator called the kernels directly, and for floats they compare bit patterns: -0.0 != +0.0 and -0.0 < +0.0. Mito applies the evaluator to SST rows as an exact filter, so after a flush `v = 0.0`, `v >= 0` and `v IN (0.0)` dropped the rows holding -0.0, and `v = -0.0` dropped the rows holding +0.0. Rows still in a memtable matched. Normalize the literal when the predicate is built and the input before it is evaluated, with the helpers DataFusion uses for the same purpose. Signed-off-by: dayan02dev <pawarudayan92@gmail.com> * test(sqlness): cover flushed float rows holding -0.0 Flush rows holding -0.0, 0.0 and 1.0, then filter with `= 0.0`, `>= 0`, `= -0.0` and `IN (0.0)`. Both zeros have to match every one of them, as they do while the rows are still in the memtable. Signed-off-by: dayan02dev <pawarudayan92@gmail.com> --------- Signed-off-by: dayan02dev <pawarudayan92@gmail.com> Co-authored-by: dennis zhuang <killme2008@gmail.com>
42 lines
1.1 KiB
SQL
42 lines
1.1 KiB
SQL
CREATE TABLE IF NOT EXISTS prune_field (
|
|
ts TIMESTAMP TIME INDEX,
|
|
`tag` UInt16,
|
|
a UInt8,
|
|
b UInt8,
|
|
PRIMARY KEY (`tag`)) ENGINE = mito WITH('merge_mode'='last_non_null');
|
|
|
|
insert into prune_field(ts, `tag`, a, b) values(0, 1, 1, null);
|
|
|
|
admin flush_table('prune_field');
|
|
|
|
insert into prune_field(ts, `tag`, a, b) values(0, 1, null, 1);
|
|
|
|
admin flush_table('prune_field');
|
|
|
|
select * from prune_field where a = 1;
|
|
|
|
select * from prune_field where b = 1;
|
|
|
|
select * from prune_field;
|
|
|
|
select * from prune_field where a = 1 and b = 1;
|
|
|
|
drop table prune_field;
|
|
|
|
-- -0.0 equals 0.0, so flushed rows holding either zero must keep matching.
|
|
CREATE TABLE prune_float_zero (ts TIMESTAMP TIME INDEX, v DOUBLE);
|
|
|
|
insert into prune_float_zero values (1, -0.0), (2, 0.0), (3, 1.0);
|
|
|
|
admin flush_table('prune_float_zero');
|
|
|
|
select ts from prune_float_zero where v = 0.0 order by ts;
|
|
|
|
select ts from prune_float_zero where v >= 0 order by ts;
|
|
|
|
select ts from prune_float_zero where v = -0.0 order by ts;
|
|
|
|
select ts from prune_float_zero where v in (0.0) order by ts;
|
|
|
|
drop table prune_float_zero;
|