Skip to content

[Bug]: Iceberg years(date) partition pruning silently returns an empty result #27200

Closed

Description

@Ariznawlll

Description

MatrixOne incorrectly prunes every file for a supported Iceberg table partitioned by years(date). A four-row table is readable without a date predicate, but a range selecting the two 2020 rows returns an empty result instead of the Spark result.

Environment

  • Branch: main
  • Commit: 1f9e501594509fb5d2e0284833faf8c3426e2285
  • Test date: 2026-08-17
  • Deployment: local 1 CN + 1 TN + 1 LogService, DISK-V2
  • External services: native MinIO RELEASE.2025-09-06T17-38-46Z + Nessie 0.108.4
  • Oracle: Spark 3.5.1, Iceberg 1.6.1, JDK 21.0.12
  • Iceberg table: format v2, Parquet, PARTITIONED BY (years(obs_date))

Steps to reproduce

Create the table through Spark against the same Nessie catalog and MinIO warehouse:

CREATE TABLE tiera.public_negative.year_partition_tiny (
  id BIGINT, obs_date DATE, value BIGINT
) USING iceberg
PARTITIONED BY (years(obs_date))
TBLPROPERTIES ('format-version'='2');

INSERT INTO tiera.public_negative.year_partition_tiny VALUES
  (1, DATE '2019-06-01', 10),
  (2, DATE '2020-02-01', 20),
  (3, DATE '2020-12-31', 30),
  (4, DATE '2021-01-01', 40);

Create the normal MatrixOne Iceberg catalog/access mapping and map the table with the supported columns:

CREATE EXTERNAL TABLE iceberg_native_verify.year_partition_tiny (
  id BIGINT, obs_date DATE, value BIGINT
) ENGINE = ICEBERG WITH (
  'catalog'='native_t3',
  'namespace'='public_negative',
  'table'='year_partition_tiny',
  'ref'='main',
  'read_mode'='append_only',
  'write_mode'='read_only'
);

Run the control and the filtered query:

SELECT COUNT(*), SUM(value)
FROM iceberg_native_verify.year_partition_tiny;

SELECT COUNT(*), SUM(value)
FROM iceberg_native_verify.year_partition_tiny
WHERE obs_date >= DATE '2020-01-01'
  AND obs_date < DATE '2021-01-01';

Actual behavior

The unfiltered control is correct, but the valid 2020 range is silently empty:

control: 4, 100
filtered: 0, NULL

The same filtered query returned 0, NULL in 3/3 fresh executions. No SQL error is returned.

Expected behavior

Spark returns the two 2020 rows:

filtered: 2, 50

MatrixOne must return the same result and must not prune the 2020 partition.

Stability and controls

  • Minimal reproducer: 3/3 wrong results with four rows.
  • Spark oracle: 2019 => 1/10, 2020 => 2/50, 2021 => 1/40.
  • MatrixOne full-scan control: 3/3 returned 4/100.
  • Unrelated Iceberg identity-partition control: 3/3 returned the expected 10 rows.
  • Service health: SELECT 1 continued to succeed; no panic, OOM, or restart observed.
  • This is not a big-data-only issue.

Evidence

MatrixOne EXPLAIN keeps the date predicate as a residual filter but execution returns no rows:

External Scan on iceberg_native_verify.year_partition_tiny
  Iceberg: namespace=public_negative, table=year_partition_tiny, ref=main,
           read_mode=append_only, residual_filter=true

The same behavior was also observed on the fixed NOAA 2019/2020 table: Spark returned 359629 / 29072705 for February 2020 TMAX, while MatrixOne returned 0 / NULL 3/3.

Code analysis

The Iceberg specification stores the result of the year transform as years from 1970, not the calendar year. The stable four-row failure is consistent with an incorrect transform-domain comparison during MatrixOne partition pruning. This is a hypothesis; the exact faulty conversion has not yet been confirmed.

Regression coverage

After the fix, add a deterministic Nessie + MinIO external Iceberg scenario containing years 2019/2020/2021. Assert unfiltered, equality, closed/open range, IN, pre-epoch, NULL, and no-match predicates against Spark, repeat 3 times, and preserve an EXPLAIN pruning assertion. No big-data dataset is needed.

Related

Activity

  1. added
    kind/bug
    need-regression-or-chaos
    on Aug 16, 2026
  2. added theissue type on Aug 16, 2026
  3. added this to the MO-202608 milestone on Aug 16, 2026
  4. added
    ai-easy
    on Aug 17, 2026
  5. Ariznawlll commented on Aug 17, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:`main`
    • commit:`414fb8e0f854a4ab31519394542f93535e2c492f`
    • 部署方式:MatrixOne 本地隔离服务 + Nessie/MinIO/Iceberg Spark oracle;普通 SQL 路径重复 3 次
    • 测试日期:2026-08-17

    原问题验证

    建立按 `years(obs_date)` 分区的 Iceberg 表,使用 Spark oracle 计算 2019、2020、2021、epoch 前日期和 NULL 分组,再映射到 MatrixOne 外部表执行原始 pruning 场景。当前 main 每轮完整扫描为 `6/155`,2020 范围为 `2/50`,与 oracle 一致;没有匹配的范围返回 `0/NULL`。

    Happy Path 覆盖

    1. 全表、单日等值、2020 半开区间、2019/2021 IN,3/3 与 Spark oracle 的分组计数和 SUM 一致。
    2. epoch 前日期、NULL 分区、无匹配范围边界,3/3 返回 `1/5`、`1/50`、`0/NULL`。
    3. `YEAR(obs_date)=2020` 和 OR 组合条件结果分别为 `2/50`、`2/60`,与逐行计算一致。
    4. identity partition 控制的全表 `4/100`、2020 范围 `2/50` 正确;EXPLAIN 保留外部扫描及残余日期过滤。

    Unhappy Path 覆盖

    不适用:该 issue 是合法日期分区 pruning 的错误结果,不要求拒绝输入;未注入 Nessie/MinIO/Spark 故障,也未将外部服务故障误报为产品修复证据。

    白盒验证

    不适用:问题由外部表服务级 SQL 完整触发,已用独立 Spark oracle 做结果交叉校验;本机 Go cgo 头文件不完整,未把未执行的 Go UT 作为通过依据。

    回归测试

    • 该场景不加入默认 MOTR SQL:MOTR 当前没有自包含 Nessie + MinIO + Spark 夹具;已在 PR #113 的 BLACKBOX_COVERAGE.md 明确路由到专用 Iceberg E2E。
    • 不需要 big-data、soak 或 chaos:本次错误是日期字面量归一化,不依赖内存/溢出阈值;外部服务恢复属于另行的 Iceberg recovery workflow。

    测试证据

    • 服务级 SQL 3/3:完整扫描、等值、范围、IN、OR、函数、NULL、epoch 前日期和 no-match 共 8 类断言均通过;Spark oracle 分组为 2019=`1/10`、2020=`2/50`、2021=`1/40`、epoch 前=`1/5`、NULL=`1/50`。
    • MatrixOne 修复提交:f2146c82。

    测试结论

    测试通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bugneed-regression-or-chaos

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions