Skip to content

[iceberg] Incorrect results when reading decimal fields #1983

@andygrove

Description

@andygrove

Describe the bug

During fuzz testing, I am seeing errors reading decimals (or maybe when sorting decimals).

SQL

SELECT c7, cast(c7 as SMALLINT), try_cast(c7 as SMALLINT) FROM local.db.test0 ORDER BY c7;

Note that c7 is defined as Decimal128(10, 2).

Spark Plan

AdaptiveSparkPlan isFinalPlan=true
+- == Final Plan ==
   *(2) Sort [c7#6669 ASC NULLS FIRST], true, 0
   +- AQEShuffleRead coalesced
      +- ShuffleQueryStage 0
         +- Exchange rangepartitioning(c7#6669 ASC NULLS FIRST, 200), ENSURE_REQUIREMENTS, [plan_id=8959]
            +- *(1) Project [c7#6669, cast(c7#6669 as smallint) AS c7#6675, try_cast(c7#6669 as smallint) AS c7#6676]
               +- *(1) ColumnarToRow
                  +- BatchScan local.db.test0[c7#6669] local.db.test0 (branch=null) [filters=, groupedBy=] RuntimeFilters: []
+- == Initial Plan ==
   Sort [c7#6669 ASC NULLS FIRST], true, 0
   +- Exchange rangepartitioning(c7#6669 ASC NULLS FIRST, 200), ENSURE_REQUIREMENTS, [plan_id=8946]
      +- Project [c7#6669, cast(c7#6669 as smallint) AS c7#6675, try_cast(c7#6669 as smallint) AS c7#6676]
         +- BatchScan local.db.test0[c7#6669] local.db.test0 (branch=null) [filters=, groupedBy=] RuntimeFilters: []

Comet Plan

AdaptiveSparkPlan isFinalPlan=true
+- == Final Plan ==
   *(1) CometColumnarToRow
   +- CometSort [c7#6697, c7#6703, c7#6704], [c7#6697 ASC NULLS FIRST]
      +- AQEShuffleRead coalesced
         +- ShuffleQueryStage 0
            +- CometColumnarExchange rangepartitioning(c7#6697 ASC NULLS FIRST, 200), ENSURE_REQUIREMENTS, CometColumnarShuffle, [plan_id=9021]
               +- CometProject [c7#6697, c7#6703, c7#6704], [c7#6697, cast(c7#6697 as smallint) AS c7#6703, try_cast(c7#6697 as smallint) AS c7#6704]
                  +- CometBatchScan local.db.test0[c7#6697] local.db.test0 (branch=null) [filters=, groupedBy=] RuntimeFilters: []
+- == Initial Plan ==
   CometSort [c7#6697, c7#6703, c7#6704], [c7#6697 ASC NULLS FIRST]
   +- CometColumnarExchange rangepartitioning(c7#6697 ASC NULLS FIRST, 200), ENSURE_REQUIREMENTS, CometColumnarShuffle, [plan_id=9008]
      +- CometProject [c7#6697, c7#6703, c7#6704], [c7#6697, cast(c7#6697 as smallint) AS c7#6703, try_cast(c7#6697 as smallint) AS c7#6704]
         +- CometBatchScan local.db.test0[c7#6697] local.db.test0 (branch=null) [filters=, groupedBy=] RuntimeFilters: []

First difference at row 1:
Spark: 0.01,0,0
Comet: 0.00,0,0

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

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions