Flink: a column's `initial-default` is ignored on read, rows written before the column was added read NULL (FlinkSchemaUtil.convert(Schema, ResolvedSchema) drops the defaults of the projected schema)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
調査の方向性
Start with FlinkSchemaUtil.convert(Schema, ResolvedSchema) and its TableSchema overload, then trace how IcebergTableSource passes the projected schema into the source builders and reader. Check how field IDs and docs are copied from the base schema and how defaults reach RowDataFileScanTaskReader. Done means Flink reads the initial default for older rows and the column filter returns those rows across both source paths and the listed file formats.
索引モデルが issue の本文から書いたものです。
説明
Apache Iceberg version
1.12.0 (latest release)
Query engine
Flink
Please describe the bug 🐞
A format-version 3 table gets a new optional column with an initial default (UpdateSchema.addColumn(name, type, Literal)). A Flink scan reads NULL for that column in every row of the older data files. The default should be returned. The Iceberg generic reader (IcebergGenerics) and Spark return it. Both the FLIP-27 source and the legacy source are affected, as are Parquet, ORC and Avro data files. A filter on the column (WHERE d = 7) returns no rows.
Flink 2.3.0, iceberg-flink-runtime-2.3 1.12.0, batch mode, hadoop catalog:
CREATE CATALOG ice WITH ('type'='iceberg', 'catalog-type'='hadoop', 'warehouse'='file:///tmp/ice');
CREATE DATABASE ice.db;
CREATE TABLE ice.db.t (id BIGINT, v STRING) WITH ('format-version'='3');
INSERT INTO ice.db.t VALUES (1, 'a'), (2, 'b');
// Flink DDL cannot set a default; Java API (HadoopCatalog over the same warehouse)
table.updateSchema().addColumn("d", Types.IntegerType.get(), Literal.of(7)).commit();
// table.schema(): 3: d: optional int (default 7)
// IcebergGenerics.read(table).build(): Record(1, a, 7), Record(2, b, 7)
SELECT * FROM ice.db.t;
-- expected: (1, 'a', 7), (2, 'b', 7)
-- actual: (1, 'a', NULL), (2, 'b', NULL)
SELECT * FROM ice.db.t WHERE d = 7;
-- expected: both rows; actual: none
SET 'table.exec.iceberg.use-flip27-source' = 'false';
SELECT * FROM ice.db.t; -- the same NULLs
The spec says the initial-default must be used to populate the field's value for every record written before the field was added. So this is a silent wrong result. Spark (iceberg-spark-runtime-4.2 1.13.0-SNAPSHOT) reads 7 from the same table.
Cause:
IcebergTableSourcehands the planner's projectedResolvedSchematoIcebergSource.Builder.project(ResolvedSchema)/FlinkSource.Builder.project(TableSchema). These convert it back withFlinkSchemaUtil.convert(icebergSchema, projectedFlinkSchema).convert(Schema baseSchema, ResolvedSchema flinkSchema)builds a fresh struct from the Flink types. It then copies field ids (TypeUtil.reassignIds) and docs (TypeUtil.reassignDoc) from the table schema, but notinitialDefault()/writeDefault().- The projected schema that reaches
RowDataFileScanTaskReader(and the Parquet / ORC / Avro read builders) therefore has no defaults. A column missing from a data file is read as NULL. - The Flink Parquet reader can read defaults (#11839, #12072), but it never gets the default through the source.
convert(Schema, ResolvedSchema)is unchanged on main (checked 2026-11-26).
A possible fix: carry initialDefault / writeDefault over from the base schema in FlinkSchemaUtil.convert(Schema, ResolvedSchema) / convert(Schema, TableSchema) (as is done for the docs), or project the table schema by field id (TypeUtil.select) instead of converting the Flink schema back.
Side note: with ORC data files, the generic and Spark readers fail with UnsupportedOperationException: ORC cannot read default value for field d, but Flink silently returns NULL.
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
- 主要言語
- Java
- スター
- 9.5k
- フォーク
- 3.7k
- 平均マージ
- 2日 2時間
- マージ済み PR(30日)
- 170
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/iceberg のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Spark: Test INSERT targets with computed IDENTIFIER expressions対応中かも @shivadarshan-devadiga が 15 日前に担当しました。 オープンimprovement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
[Core] TestAvroPartitionStatsHandler fails on Windows due to unclosed partition statistics scan対応中かも @Ankitkj1999 が 17 日前に担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
Core: TableMetadata.Builder allows adding encryption keys to v1/v2 tables対応中かも @yusufyildiz34 が 37 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/iceberg#18632 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Kafka: Filter empty strings and whitespace in IcebergSinkConfig stringToList対応中かも @mohamed-elbrik が 42 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug vault
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
bancolombia/secrets-manager#150 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 92/100
HexaHexes/neoforge-mod-template#124 ·
メンテナーはふだん 1 日以内に返信
-
awaiting triage java new feature P2
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
source-survicate: pagination reads pagination and stops after one page; substreams drop survey_idオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
OpenLiberty/open-liberty#36410 ·
メンテナーはふだん 1 日以内に返信