[Flink] Filter pushdown of DOUBLE <= DECIMAL literal throws ValidationException: Invalid value for conversion to type double (java.math.BigDecimal)
维护者通常 1 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 18/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- java
调研方向
The failure comes from FlinkFilters converting a DECIMAL literal to BigDecimal, which then fails in UnboundPredicate.bindLiteralOperation during ManifestGroup projection inside FlinkSplitPlanner.planIcebergSourceSplits. Start by reading the literal conversion in FlinkFilters and the bind path in UnboundPredicate. Done means a DOUBLE column compared with an uncast decimal literal plans and filters without ValidationException, but a pull request (#19098) is already open against this issue, so check it before starting.
由索引模型根据 Issue 内容生成。
描述
Apache Iceberg version
1.11.0
Query engine
Flink
Please describe the bug 🐞
In Flink SQL batch mode, querying a non-empty Iceberg table with a comparison between a DOUBLE column and an uncast SQL decimal literal (for example WHERE score <= 14.3) crashes during split planning (even on EXPLAIN PLAN FOR) with:
org.apache.iceberg.exceptions.ValidationException: Invalid value for conversion to type double: 14.3 (java.math.BigDecimal)
Flink pushes filter=[<=(score, 14.3:DECIMAL(3, 1))] into IcebergTableSource. FlinkFilters converts the DECIMAL(3, 1) literal to java.math.BigDecimal and builds an Iceberg UnboundPredicate against the DOUBLE column score. When FlinkSplitPlanner.planIcebergSourceSplits evaluates manifests via ManifestGroup, UnboundPredicate.bindLiteralOperation fails to convert BigDecimal to Types.DoubleType and throws ValidationException.
In contrast:
- Explicitly casting the literal (
WHERE score <= CAST(14.3 AS DOUBLE)) passes planning and filter binding cleanly. - The exact same predicate
WHERE score <= 14.3on a pure FlinkVALUESsource (and on Apache Spark 3.5.5 + Iceberg 1.11.0, Trino 470, and DuckDB 2.0.0 against the same Iceberg table) succeeds without error. - Note that the table must have at least one committed data file so that
ManifestGroupbinds and evaluates the pushed filter.
Minimal Reproducer
Run in Flink 2.1.0 SQL Gateway / SQL Client with iceberg-flink-runtime-2.1-1.11.0.jar:
SET 'execution.runtime-mode' = 'batch';
SET 'table.dml-sync' = 'true';
CREATE CATALOG ic_r25 WITH (
'type' = 'iceberg',
'catalog-type' = 'hadoop',
'warehouse' = 'file:///tmp/ic_r25_wh'
);
CREATE TABLE ic_r25.`default`.t_double (
id INT,
score DOUBLE
);
INSERT INTO ic_r25.`default`.t_double
VALUES
(1, CAST(10.5 AS DOUBLE)),
(2, CAST(20.0 AS DOUBLE));
-- Fails during planning with ValidationException:
EXPLAIN PLAN FOR
SELECT id,
score
FROM ic_r25.`default`.t_double
WHERE score <= 14.3;
-- Also fails during execution with the same ValidationException:
SELECT id,
score
FROM ic_r25.`default`.t_double
WHERE score <= 14.3;
-- Control: explicit CAST to DOUBLE passes planning & filter binding cleanly:
EXPLAIN PLAN FOR
SELECT id,
score
FROM ic_r25.`default`.t_double
WHERE score <= CAST(14.3 AS DOUBLE);
Stacktrace (Flink 2.1.0 + iceberg-flink-runtime-2.1-1.11.0.jar)
Caused by: org.apache.iceberg.exceptions.ValidationException: Invalid value for conversion to type double: 14.3 (java.math.BigDecimal)
at org.apache.iceberg.expressions.UnboundPredicate.bindLiteralOperation(UnboundPredicate.java:184)
at org.apache.iceberg.expressions.UnboundPredicate.bind(UnboundPredicate.java:123)
at org.apache.iceberg.expressions.Projections$BaseProjectionEvaluator.predicate(Projections.java:181)
at org.apache.iceberg.expressions.Projections$BaseProjectionEvaluator.predicate(Projections.java:135)
at org.apache.iceberg.expressions.ExpressionVisitors.visit(ExpressionVisitors.java:347)
at org.apache.iceberg.expressions.Projections$BaseProjectionEvaluator.project(Projections.java:151)
at org.apache.iceberg.ManifestGroup.lambda$entries$9(ManifestGroup.java:289)
...
at org.apache.iceberg.flink.source.FlinkSplitPlanner.planIcebergSourceSplits(FlinkSplitPlanner.java:77)
at org.apache.iceberg.flink.source.IcebergSource.planSplitsForBatch(IcebergSource.java:159)
at org.apache.iceberg.flink.source.IcebergSource.lambda$inferParallelism$0(IcebergSource.java:248)
at org.apache.iceberg.flink.source.SourceUtil.inferParallelism(SourceUtil.java:65)
at org.apache.iceberg.flink.source.IcebergSource.inferParallelism(IcebergSource.java:244)
at org.apache.iceberg.flink.source.IcebergSource$Builder.buildStream(IcebergSource.java:652)
at org.apache.iceberg.flink.source.IcebergTableSource.createFLIP27Stream(IcebergTableSource.java:148)
Expected Behavior
FlinkFilters should either:
- Avoid pushing down predicates whose literal Java/Flink type (
BigDecimal/DECIMAL) is not accepted by Iceberg'sUnboundPredicate.bindfor the target column type (DOUBLE/FLOAT), letting Flink'sCalcoperator evaluate the filter safely; or - Convert the
BigDecimalliteral to a valid bound forDOUBLE/FLOATbefore constructing the IcebergExpression.
Environment
- Iceberg Runtime:
iceberg-flink-runtime-2.1-1.11.0.jar(also reproduced oniceberg-flink-runtime-1.19-1.8.1.jarwith REST catalog) - Flink Version:
2.1.0(flink:2.1.0-scala_2.12-java17, also reproduced on1.19.1) - Runtime Mode:
batch
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.4k
- 派生
- 3.7k
- 平均合并
- 2 天 16 小时
- 30 天内合并 PR
- 160
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/iceberg 的其他 Issue
-
Spark: Test INSERT targets with computed IDENTIFIER expressions可能已有人在做 @shivadarshan-devadiga 于 7 天前认领。 未关闭improvement
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
[Core] TestAvroPartitionStatsHandler fails on Windows due to unclosed partition statistics scan可能已有人在做 @Ankitkj1999 于 9 天前认领。 未关闭
难度 1/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
Flink: JdbcLockFactory concurrent lock-table creation can fail with "table already exists" and restart the job可能已有人在做 @adiranjan25 于 16 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
apache/iceberg#18797 · 1 条评论 ·
维护者通常 1 天内回复
-
Core: TableMetadata.Builder allows adding encryption keys to v1/v2 tables可能已有人在做 @yusufyildiz34 于 29 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
apache/iceberg#18632 · 1 条评论 ·
维护者通常 1 天内回复
-
Kafka: Filter empty strings and whitespace in IcebergSinkConfig stringToList可能已有人在做 @mohamed-elbrik 于 34 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 80/100
speakeasy-api/speakeasy#2159 ·
维护者通常 1 天内回复
-
area: cli
难度 2/5 1-3 小时 新手友好度 70/100
vitruv-tools/NeoJoin#415 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
jenkinsci/user-guide-ai-chatbot-plugin#132 ·
维护者通常 6 天内回复
-
account assessment course feature lecture
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
bug db/dameng user-priority/P2
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复