Skip to content

Iceberg Truncate Transform Wrong Result due to Integer Overflow #13105

Closed as not planned

Description

@aykut-bozkurt

Apache Iceberg version

1.9.0 (latest release)

Query engine

Spark

Please describe the bug 🐞

I get wrong results when I apply truncate transform on bigint type via pyspark sql api. It seems like an overflow issue with truncate transform. (can repro without iceberg as well)

Steps to repro:

> spark.sql("""CREATE TABLE prod.db.sample (a bigint) using iceberg partitioned by (truncate(10,a));""")
DataFrame[]

> spark.sql("""insert into prod.db.sample values(-9223372036854775808);""")
DataFrame[]

# wrong result due to overflow
> spark.sql(f"select * from prod.db.sample where a < 0").collect()
[]

# partition value overflow
> spark.sql("select partition.* from prod.db.sample.files").collect()
[Row(a_trunc=9223372036854775806)]

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time

Activity

  1. added
    bug
    on May 20, 2025
  2. nandorKollar commented on May 21, 2025

    @nandorKollar
    Contributor

    I think this would possibly require a spec change. I'm afraid that both over and underflows are possible, overflows might be addressed if spec would use v - (v % W) for positive values instead of v - (((v % W) + W) % W).

  3. github-actions commented on Nov 18, 2025

    @github-actions

    This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.

  4. github-actions commented on Dec 2, 2025

    @github-actions

    This issue has been closed because it has not received any activity in the last 14 days since being marked as 'stale'

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

    bugstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions