Skip to content

truncate partitioning underflows, leads to wrong results #9767

Closed as not planned

Description

@JFinis

Apache Iceberg version

1.4.3 (latest release)

Query engine

Spark, but probably all of them.

Please describe the bug 🐞

The truncate partition transform can underflow for all numeric types (decimal, int, long), leading to it no longer being order preservering. I.e., a very small value gets assigned to a very large bucket, leading to partition pruning incorrectly pruning this bucket and therefore queries to return wrong results.

Also, due to the underflow, the bucket is not even a correct bucket, as it is not a remainder of the truncate width.

For example, integer value -2147483648 with truncate width 10000 gets put into bucket 2147477296.

Spark SQL repro:

CREATE TABLE iceberg.sample (x integer) PARTITIONED BY(truncate(x,10000))
TBLPROPERTIES(`format-version`=2);

INSERT INTO iceberg.sample VALUES(-2147483648);

-- Returns empty result, since the value is put into bucket 2147477296
SELECT * FROM iceberg.sample WHERE x < 0

I guess truncate partitioning should check for underflow and in this case put the value into the lowest possible bucket. The transform needs to be clarified in the specification as well.

Activity

  1. added
    bug
    on Feb 20, 2024
  2. github-actions commented on Oct 21, 2024

    @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.

  3. github-actions commented on Nov 5, 2024

    @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