Skip to content

abs returns incorrect value in some cases #666

Closed

Description

@andygrove

Describe the bug

SQL

SELECT c28, abs(c28) AS x FROM test1 ORDER BY c28;

Spark Plan

AdaptiveSparkPlan isFinalPlan=true
+- == Final Plan ==
   *(2) Sort [c28#228L ASC NULLS FIRST], true, 0
   +- AQEShuffleRead coalesced
      +- ShuffleQueryStage 0
         +- Exchange rangepartitioning(c28#228L ASC NULLS FIRST, 200), ENSURE_REQUIREMENTS, [plan_id=24514]
            +- *(1) Project [c28#228L, abs(c28#228L) AS x#25310L]
               +- *(1) ColumnarToRow
                  +- FileScan parquet [c28#228L] Batched: true, DataFilters: [], Format: Parquet, Location: InMemoryFileIndex(1 paths)[file:/home/andy/git/apache/datafusion-comet/fuzz-testing/test1.parquet], PartitionFilters: [], PushedFilters: [], ReadSchema: struct<c28:bigint>
+- == Initial Plan ==
   Sort [c28#228L ASC NULLS FIRST], true, 0
   +- Exchange rangepartitioning(c28#228L ASC NULLS FIRST, 200), ENSURE_REQUIREMENTS, [plan_id=24500]
      +- Project [c28#228L, abs(c28#228L) AS x#25310L]
         +- FileScan parquet [c28#228L] Batched: true, DataFilters: [], Format: Parquet, Location: InMemoryFileIndex(1 paths)[file:/home/andy/git/apache/datafusion-comet/fuzz-testing/test1.parquet], PartitionFilters: [], PushedFilters: [], ReadSchema: struct<c28:bigint>

Comet Plan

AdaptiveSparkPlan isFinalPlan=true
+- == Final Plan ==
   *(2) Sort [c28#228L ASC NULLS FIRST], true, 0
   +- AQEShuffleRead coalesced
      +- ShuffleQueryStage 0
         +- Exchange rangepartitioning(c28#228L ASC NULLS FIRST, 200), ENSURE_REQUIREMENTS, [plan_id=24579]
            +- *(1) ColumnarToRow
               +- CometProject [c28#228L, x#25316L], [c28#228L, abs(c28#228L) AS x#25316L]
                  +- CometScan parquet [c28#228L] Batched: true, DataFilters: [], Format: CometParquet, Location: InMemoryFileIndex(1 paths)[file:/home/andy/git/apache/datafusion-comet/fuzz-testing/test1.parquet], PartitionFilters: [], PushedFilters: [], ReadSchema: struct<c28:bigint>
+- == Initial Plan ==
   Sort [c28#228L ASC NULLS FIRST], true, 0
   +- Exchange rangepartitioning(c28#228L ASC NULLS FIRST, 200), ENSURE_REQUIREMENTS, [plan_id=24559]
      +- CometProject [c28#228L, x#25316L], [c28#228L, abs(c28#228L) AS x#25316L]
         +- CometScan parquet [c28#228L] Batched: true, DataFilters: [], Format: CometParquet, Location: InMemoryFileIndex(1 paths)[file:/home/andy/git/apache/datafusion-comet/fuzz-testing/test1.parquet], PartitionFilters: [], PushedFilters: [], ReadSchema: struct<c28:bigint>

First difference at row 11:
Spark: -8779944534083813778,8779944534083813778
Comet: -8779944534083813778,-8779944534083813778

Steps to reproduce

No response

Expected behavior

No response

Additional context

No response

Activity

  1. added this to the 0.1.0 milestone on Jul 15, 2024
  2. andygrove commented on Jul 15, 2024

    @andygrove
    MemberAuthor

    This is likely a duplicate of #642

  3. vaibhawvipul commented on Jul 20, 2024

    @vaibhawvipul
    Contributor

    working on it.

  4. vaibhawvipul commented on Jul 24, 2024

    @vaibhawvipul
    Contributor

    I am able to reproduce the issue.

  5. modified the milestones: 0.1.0, 0.2.0 on Jul 24, 2024
  6. removed this from the 0.2.0 milestone on Aug 16, 2024
  7. kazuyukitanimura commented on Sep 24, 2024

    @kazuyukitanimura
    Contributor

    Native abs is disabled for now

  8. andygrove commented on Jun 16, 2025

    @andygrove
    MemberAuthor

    Closing this bug because we disabled the feature. Filed #1890 to re-implement.

  9. coderfender commented on Sep 20, 2025

    @coderfender
    Contributor

    👀

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions