Skip to content

Datafusion FP comparator works incorrectly with -0.0 +0.0 #22826

@comphead

Description

@comphead

Describe the bug

Originally reported by apache/datafusion-comet#4481

PSQL

select +0.0 a union select 0.0 a union select -0.0 a;

  a  
-----
 0.0
(1 row)

select count(distinct a) from (select +0.0 a union select 0.0 a union select -0.0 a);

 count 
-------
     1
(1 row)

select distinct a from (select +0.0 a union select 0.0 a union select -0.0 a);

  a  
-----
 0.0
(1 row)
DataFusion CLI v53.1.0
> select +0.0 a union select 0.0 a union select -0.0 a;
+------+
| a    |
+------+
| 0.0  |
| -0.0 |
+------+
2 row(s) fetched. 
Elapsed 0.019 seconds.

> select count(distinct a) from (select +0.0 a union select 0.0 a union select -0.0 a);

+-------------------+
| count(DISTINCT a) |
+-------------------+
| 2                 |
+-------------------+
1 row(s) fetched. 
Elapsed 0.013 seconds.

> select distinct a from (select +0.0 a union select 0.0 a union select -0.0 a);

+------+
| a    |
+------+
| -0.0 |
| 0.0  |
+------+
2 row(s) fetched. 
Elapsed 0.011 seconds.


To Reproduce

No response

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions