Skip to content

atan2 precision loss with integer arguments #22514

@neilconway

Description

@neilconway

Describe the bug

When atan2 is invoked with integer arguments, the input is coerced to Float32 (not Float64 as the comments in the implementation suggest). This results in losing precision unnecessarily and produces inconsistent results with DuckDB and Postgres.

To Reproduce

> select  atan2(1, 1000000);
+--------------------------------+
| atan2(Int64(1),Int64(1000000)) |
+--------------------------------+
| 0.000001                       |
+--------------------------------+
1 row(s) fetched.
Elapsed 0.084 seconds.

> select  atan2(1.0, 1000000.0);
+------------------------------------+
| atan2(Float64(1),Float64(1000000)) |
+------------------------------------+
| 9.999999999996666e-7               |
+------------------------------------+
1 row(s) fetched.
Elapsed 0.006 seconds.

Expected behavior

DuckDB and Postgres both return 9.999999999996666e-7, matching the DataFusion behavior for Float64 input.

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