INSERT fails after a column is added to the table, until the provider is rebuilt
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- rust
调研方向
Start with insert_into in crates/datafusion/src/table_provider/catalog_table_provider.rs, where the cached Arrow schema is used to plan the input, then read IcebergWriteExec in crates/datafusion/src/write/exec.rs, where the Parquet writer takes the table's current schema. Reproduce by adding a column to the table outside the session and running an INSERT. Done means either the missing columns are filled with NULL, or the INSERT fails with a clear schema-changed error, and a test covers the case. The fix choice is a design decision, so confirm it with maintainers first.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
IcebergCatalogTableProvider caches the table's Arrow schema when it is built (catalog_table_provider.rs#L81-L84). IcebergCatalogProvider builds one provider per table when it is constructed and keeps it (schema.rs#L64-L94). insert_into plans its input against the cached schema, but IcebergWriteExec builds the Parquet writer from the table's current schema (write/exec.rs#L244-L250).
Once a column has been added to the table, by another engine or another session, the input batches lack that column and the Parquet writer fails on it:
Execution error: DataInvalid => Field id 3 not found in struct array
Every INSERT through that provider fails this way, with or without a column list, including after other sessions have written with the new schema. Scans through the same provider keep working and return only the cached columns. Writing works again only once the provider is rebuilt, which for IcebergCatalogProvider means registering the catalog again.
To Reproduce
Tested with an unpartitioned table in a MemoryCatalog:
- Create
ns.t(id INT NOT NULL, name STRING NOT NULL), register anIcebergCatalogProviderascin a session, and runINSERT INTO c.ns.t VALUES (1, 'a'). - Outside that session, add an optional column, for example with
Transaction::update_schema().add_column(AddColumn::optional("email", Type::Primitive(PrimitiveType::String)))orALTER TABLE t ADD COLUMN email STRINGfrom Spark. - In the same session, run
INSERT INTO c.ns.t VALUES (2, 'b')orINSERT INTO c.ns.t (id, name) VALUES (2, 'b'). Both fail with the error above.
In a session that registers the catalog after step 2, INSERT INTO c.ns.t (id, name) VALUES (2, 'b') succeeds and email reads back as NULL.
Expected behavior
The INSERT succeeds and writes NULL for email, as it does through a provider built after the change. At the least, it should fail with an error saying that the table's schema changed after the provider was built.
Additional context
- This is a concrete case of #24 §2: the provider plans with its cached schema but writes with the table's current metadata. It persists because of #24 §1:
IcebergCatalogProvidernever rebuilds its providers. - #48 adds a constructor so that Ballista can rebuild a provider on the scheduler with the schema the client planned against. Ballista runs DML through that rebuilt provider, so it fails the same way.
- Possible fixes:
- have
IcebergWriteExecfill the columns the input lacks with NULL, or with their write default - have
insert_intocompare the cached schema with the table's current schema and return a clear error
- have
- 主要语言
- Rust
- 星标
- 33
- 派生
- 34
- 平均合并
- 4 天 14 小时
- 30 天内合并 PR
- 10
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/datafusion-iceberg 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
apache/datafusion-iceberg#100 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
apache/datafusion-iceberg#101 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
apache/datafusion-iceberg#85 · 1 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
apache/datafusion-iceberg#84 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
apache/datafusion-iceberg#75 ·
维护者通常 1 天内回复
查看 apache/datafusion-iceberg 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
-
area:frontend kind:bug priority:p3 ready
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
bug priority: medium ui
难度 2/5 1-3 小时 新手友好度 82/100
storytold/vectorcraft#6333 · 1 条评论 ·
维护者通常 1 天内回复
-
bug lexer
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
yara-x fails to build with rsa 0.10.0: unresolved import rsa::Pkcs1v15Sign可能已有人在做 @CfirTsabari 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 87/100
VirusTotal/yara-x#865 ·
维护者通常 1 天内回复