Skip to content

Divide by zero produces Infinity instead of NULL #665

@andygrove

Description

@andygrove

Describe the bug

SQL

SELECT c38, c91, c38 / c91 FROM test0 ORDER BY c38, c91;

Spark Plan

AdaptiveSparkPlan isFinalPlan=true
+- == Final Plan ==
   *(2) Sort [c38#38 ASC NULLS FIRST, c91#91 ASC NULLS FIRST], true, 0
   +- AQEShuffleRead coalesced
      +- ShuffleQueryStage 0
         +- Exchange rangepartitioning(c38#38 ASC NULLS FIRST, c91#91 ASC NULLS FIRST, 200), ENSURE_REQUIREMENTS, [plan_id=42538]
            +- *(1) Project [c38#38, c91#91, (cast(c38#38 as double) / cast(c91#91 as double)) AS (c38 / c91)#45670]
               +- *(1) ColumnarToRow
                  +- FileScan parquet [c38#38,c91#91] Batched: true, DataFilters: [], Format: Parquet, Location: InMemoryFileIndex(1 paths)[file:/home/andy/git/apache/datafusion-comet/fuzz-testing/test0.parquet], PartitionFilters: [], PushedFilters: [], ReadSchema: struct<c38:float,c91:float>
+- == Initial Plan ==
   Sort [c38#38 ASC NULLS FIRST, c91#91 ASC NULLS FIRST], true, 0
   +- Exchange rangepartitioning(c38#38 ASC NULLS FIRST, c91#91 ASC NULLS FIRST, 200), ENSURE_REQUIREMENTS, [plan_id=42524]
      +- Project [c38#38, c91#91, (cast(c38#38 as double) / cast(c91#91 as double)) AS (c38 / c91)#45670]
         +- FileScan parquet [c38#38,c91#91] Batched: true, DataFilters: [], Format: Parquet, Location: InMemoryFileIndex(1 paths)[file:/home/andy/git/apache/datafusion-comet/fuzz-testing/test0.parquet], PartitionFilters: [], PushedFilters: [], ReadSchema: struct<c38:float,c91:float>

Comet Plan

AdaptiveSparkPlan isFinalPlan=true
+- == Final Plan ==
   *(2) Sort [c38#38 ASC NULLS FIRST, c91#91 ASC NULLS FIRST], true, 0
   +- AQEShuffleRead coalesced
      +- ShuffleQueryStage 0
         +- Exchange rangepartitioning(c38#38 ASC NULLS FIRST, c91#91 ASC NULLS FIRST, 200), ENSURE_REQUIREMENTS, [plan_id=42603]
            +- *(1) ColumnarToRow
               +- CometProject [c38#38, c91#91, (c38 / c91)#45678], [c38#38, c91#91, (cast(c38#38 as double) / cast(c91#91 as double)) AS (c38 / c91)#45678]
                  +- CometScan parquet [c38#38,c91#91] Batched: true, DataFilters: [], Format: CometParquet, Location: InMemoryFileIndex(1 paths)[file:/home/andy/git/apache/datafusion-comet/fuzz-testing/test0.parquet], PartitionFilters: [], PushedFilters: [], ReadSchema: struct<c38:float,c91:float>
+- == Initial Plan ==
   Sort [c38#38 ASC NULLS FIRST, c91#91 ASC NULLS FIRST], true, 0
   +- Exchange rangepartitioning(c38#38 ASC NULLS FIRST, c91#91 ASC NULLS FIRST, 200), ENSURE_REQUIREMENTS, [plan_id=42583]
      +- CometProject [c38#38, c91#91, (c38 / c91)#45678], [c38#38, c91#91, (cast(c38#38 as double) / cast(c91#91 as double)) AS (c38 / c91)#45678]
         +- CometScan parquet [c38#38,c91#91] Batched: true, DataFilters: [], Format: CometParquet, Location: InMemoryFileIndex(1 paths)[file:/home/andy/git/apache/datafusion-comet/fuzz-testing/test0.parquet], PartitionFilters: [], PushedFilters: [], ReadSchema: struct<c38:float,c91:float>

First difference at row 15:
Spark: -3.4028235E38,-0.0,NULL
Comet: -3.4028235E38,-0.0,Infinity

Steps to reproduce

No response

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions