merge-on-read UPDATE fails after dropping a partition field and its source column

Aperta
#19,117 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@kccrcodes ci sta già lavorando.

Dal 25/11/2026.

  • #19132 di @kccrcodes — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java, spark

Direzione di ricerca

The failure comes from StructProjection.create, called by buildPartitionProjections in SparkPositionDeltaWrite.java (BaseDeltaWriter), which looks up partition field 1000 in a schema where the source column is gone. Start by reading StructProjection.java around line 175 and the partition-projection setup in SparkPositionDeltaWrite.java near line 471, then reproduce with the SQL in the issue. Done means the merge-on-read UPDATE succeeds and returns (1, 110) and (2, 20), with a regression test for dropped partition source columns.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Apache Iceberg version

main (development)

Query engine

Spark

Please describe the bug 🐞

After a partition field is dropped and then its source column is dropped, a merge-on-read UPDATE on the table fails while constructing the position-delta writer. The same UPDATE succeeds with copy-on-write, and it also succeeds in merge-on-read mode if the source column is kept.

Reproduction
-- merge-on-read: fails
CREATE TABLE local.candidate (id INT, p STRING, v INT)
USING iceberg
PARTITIONED BY (p)
TBLPROPERTIES ('format-version'='2');
INSERT INTO local.candidate VALUES (1, 'a', 10), (2, 'b', 20);
ALTER TABLE local.candidate DROP PARTITION FIELD p;
ALTER TABLE local.candidate DROP COLUMN p;
ALTER TABLE local.candidate SET TBLPROPERTIES ('write.update.mode'='merge-on-read');
UPDATE local.candidate SET v = v + 100 WHERE id = 1;
SELECT id, v FROM local.candidate ORDER BY id;

-- control, copy-on-write: succeeds
CREATE TABLE local.control (id INT, p STRING, v INT)
USING iceberg
PARTITIONED BY (p)
TBLPROPERTIES ('format-version'='2');
INSERT INTO local.control VALUES (1, 'a', 10), (2, 'b', 20);
ALTER TABLE local.control DROP PARTITION FIELD p;
ALTER TABLE local.control DROP COLUMN p;
UPDATE local.control SET v = v + 100 WHERE id = 1;
SELECT id, v FROM local.control ORDER BY id;
Expected

Both UPDATE statements succeed and both tables contain (1, 110) and (2, 20).

Actual

The copy-on-write control returns (1, 110), (2, 20). The merge-on-read UPDATE fails and the table is left at (1, 10), (2, 20):

java.lang.IllegalArgumentException: Cannot find field 1000: p: optional unknown in struct<>
	at org.apache.iceberg.util.StructProjection.<init>(StructProjection.java:175)
	at org.apache.iceberg.util.StructProjection.<init>(StructProjection.java:103)
	at org.apache.iceberg.util.StructProjection.create(StructProjection.java:72)
	at org.apache.iceberg.spark.source.SparkPositionDeltaWrite$BaseDeltaWriter.buildPartitionProjections(SparkPositionDeltaWrite.java:471)
	at org.apache.iceberg.spark.source.SparkPositionDeltaWrite$DeleteAndDataDeltaWriter.<init>(SparkPositionDeltaWrite.java:674)
	at org.apache.iceberg.spark.source.SparkPositionDeltaWrite$UnpartitionedDeltaWriter.<init>(SparkPositionDeltaWrite.java:738)
	at org.apache.iceberg.spark.source.SparkPositionDeltaWrite$PositionDeltaWriteFactory.createWriter(SparkPositionDeltaWrite.java:445)
	...
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
Lingua principale
Java
Stelle
9.5k
Fork
3.7k
Merge medio
2g 2h
PR unite (30g)
170

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/iceberg

Tutte le issue di apache/iceberg

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.