Skip to content

Make cast from float/double to decimal compatible with Spark #1371

Closed

Description

@andygrove

What is the problem the feature request solves?

Spark has specific rounding rules when casting from float/double to decimal that we do not have in Comet.

See #1354 for a repro.

Describe the potential solution

No response

Additional context

No response

Activity

  1. modified the milestones: 0.7.0, 0.6.0 on Feb 6, 2025
  2. modified the milestones: 0.6.0, 0.7.0, 0.8.0 on Feb 28, 2025
  3. modified the milestones: 0.8.0, 0.9.0 on Apr 17, 2025
  4. removed this from the 0.9.0 milestone on Jun 5, 2025
  5. andygrove commented on May 6, 2026

    @andygrove
    MemberAuthor

    @coderfender is this issue still valid?

  6. coderfender commented on May 7, 2026

    @coderfender
    Contributor

    Yeah , this still seems like an issue . We have a commented test commented out as well

  7. coderfender commented on May 7, 2026

    @coderfender
    Contributor

    @parthchandra I can take stab at it unless you want to ?

  8. parthchandra commented on May 7, 2026

    @parthchandra
    Contributor

    @coderfender go ahead.
    Also, from my notes -
    The incompatibility comes from rounding differences between Comet and Spark. Comet uses the binary representation of the numbers and sometimes these numbers are not represented exactly in IEEE 754. (e.g. 1.005 is actually 1.00499999999999989). Spark represents these as string. With rounding Comet ends up with 1.00, Spark ends up with 1.01.
    This happens for a very small set of numbers. For deterministic data however, it is a correctness issue.
    String representation comes at the cost of performance.
    So now the tradeoff is - faster, but sometimes not exact OR slower but always exact.
    I would like to have both, and default to the faster version, but others might have different opinions.

  9. added a commit that references this issue on Aug 1, 2026
    671a8dd
  10. added a commit that references this issue on Aug 26, 2026
    b5649c2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions