Skip to content

SQL "order by" query returns wrong order for +0.0 and -0.0 #3825

Open

Description

@kazuyukitanimura

Describe the bug

Spark returns +0.0 first
Comet returns -0.0 first

Steps to reproduce

  test("negative zero order by") {
    withTable("t1") {
      Seq(0.0f, -0.0f).toDF("a").write.saveAsTable("t1")
      val df = sql("SELECT * FROM t1 ORDER BY a")
      checkSparkAnswerAndOperator(df)
    }
  }

Expected behavior

No response

Additional context

No response

Activity

  1. andygrove commented on Mar 28, 2026

    @andygrove
    Member

    This is documented in the compatibility guide already, and there is a config that can be enabled to fallback to Spark for this case.

    https://datafusion.apache.org/comet/user-guide/latest/compatibility.html#floating-point-number-comparison

  2. kazuyukitanimura commented on Mar 30, 2026

    @kazuyukitanimura
    ContributorAuthor

    The main issue is that many tests sort results and fails due to this incompatibility issue, so we have to treat the tests differently.

    May not be a problem for end users, but for development purpose, we should fix this.

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 workingdf compatibilityAny issue related to DF & Spark compatibility

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions