Yibo-Dong opened a new issue, #19139:
URL: https://github.com/apache/iceberg/issues/19139

   ### 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
   
   ```sql
   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
   - [x] I cannot contribute a fix for this bug at this time


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to