Time-travel read of a dropped identity-partition source colunm fails
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 18/100
Research direction
The failures come from the Spark read path: ConstantColumnVector.getUTF8String (ConstantColumnVector.java:117) for the ClassCastException, and Spark3Util.SpecTransformToSparkTransform.identity (Spark3Util.java:314) reached through SparkPartitioningAwareScan.outputPartitioning for the NullPointerException. Reproduce with the SQL in the issue, then check how a dropped identity partition field is handled when the tag's schema still contains the column. Done means both VERSION AS OF queries return 1 a 10. Linked PR #19149 is already open against this, so coordinate with it before starting.
Written by the indexing model from the issue text.
Description
Apache Iceberg version
main (development)
Query engine
Spark
Please describe the bug 🐞
After DROP PARTITION FIELD p and DROP COLUMN p, reading an older tag that still has p fails when p is projected: ClassCastException (String to UTF8String) in the task, or a NullPointerException during planning with preserve-data-grouping=true. The tag is readable before the drop, or when p is not projected. Reproduced on main (2e12b22, 2026-11-25) and 1.12.0, Spark 3.5.5.
Reproduction
CREATE TABLE local.t (id INT, p STRING, v INT) USING iceberg PARTITIONED BY (p);
INSERT INTO local.t VALUES (1, 'a', 10);
ALTER TABLE local.t CREATE TAG hist;
ALTER TABLE local.t DROP PARTITION FIELD p;
SELECT id, p, v FROM local.t VERSION AS OF 'hist'; -- control: 1 a 10
ALTER TABLE local.t DROP COLUMN p;
SELECT id, v FROM local.t VERSION AS OF 'hist'; -- control: 1 10
SELECT id, p, v FROM local.t VERSION AS OF 'hist'; -- (1) ClassCastException
SET `spark.sql.iceberg.planning.preserve-data-grouping`=true;
SELECT id, p, v FROM local.t VERSION AS OF 'hist'; -- (2) NullPointerException
Expected: (1) and (2) return 1 a 10; the tag's schema still contains p.
Actual: both controls return the expected rows. (1) fails in the task:
java.lang.ClassCastException: class java.lang.String cannot be cast to class org.apache.spark.unsafe.types.UTF8String
at org.apache.iceberg.spark.data.vectorized.ConstantColumnVector.getUTF8String(ConstantColumnVector.java:117)
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.processNext(Unknown Source)
...
(2) fails during planning:
org.apache.spark.SparkException: [INTERNAL_ERROR] The Spark SQL phase optimization failed with an internal error. ...
Caused by: java.lang.NullPointerException: Cannot invoke "String.length()" because "s" is null
at org.apache.spark.sql.connector.expressions.Expressions.identity(Expressions.java:105)
at org.apache.iceberg.spark.Spark3Util$SpecTransformToSparkTransform.identity(Spark3Util.java:314)
at org.apache.iceberg.transforms.PartitionSpecVisitor.visit(PartitionSpecVisitor.java:117)
at org.apache.iceberg.spark.Spark3Util.toTransforms(Spark3Util.java:284)
at org.apache.iceberg.spark.source.SparkPartitioningAwareScan.groupingKeyTransforms(SparkPartitioningAwareScan.java:151)
at org.apache.iceberg.spark.source.SparkPartitioningAwareScan.outputPartitioning(SparkPartitioningAwareScan.java:117)
...
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
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 3.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 170
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/iceberg
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Spark: Test INSERT targets with computed IDENTIFIER expressionsPossibly taken @shivadarshan-devadiga claimed this 15 days ago. Openimprovement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
[Core] TestAvroPartitionStatsHandler fails on Windows due to unclosed partition statistics scanPossibly taken @Ankitkj1999 claimed this 17 days ago. Open
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Core: TableMetadata.Builder allows adding encryption keys to v1/v2 tablesPossibly taken @yusufyildiz34 claimed this 37 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/iceberg#18632 · 1 comment ·
Maintainers usually reply within 1 day
-
Kafka: Filter empty strings and whitespace in IcebergSinkConfig stringToListPossibly taken @mohamed-elbrik claimed this 42 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
Similar issues
-
bug vault
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
bancolombia/secrets-manager#150 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 92/100
HexaHexes/neoforge-mod-template#124 ·
Maintainers usually reply within 1 day
-
awaiting triage java new feature P2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
source-survicate: pagination reads pagination and stops after one page; substreams drop survey_idOpen
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
OpenLiberty/open-liberty#36410 ·
Maintainers usually reply within 1 day