Skip to content

Round error when casting float to decimal #4071

@andygrove

Description

@andygrove

Describe the bug

Spark

scala> spark.sql("select cast(0.06+0.01 as decimal(18,2))").show
+------------------------------------+
|CAST((0.06 + 0.01) AS DECIMAL(18,2))|
+------------------------------------+
|                                0.07|
+------------------------------------+

DataFusion

❯ select cast(0.06+0.01 as decimal(18,2));
+-------------------------------+
| Float64(0.06) + Float64(0.01) |
+-------------------------------+
| 0.06                          |
+-------------------------------+

To Reproduce
See above

Expected behavior

Additional context
Discovered as part of #4024

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions