Skip to content

[Bug]: Iceberg writer ignores write.parquet.compression-codec and writes uncompressed, plain-encoded Parquet (~14x larger files) #32466

Closed

Description

@iamlinjunhong

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

Reproduced on 2f6fcc772175d0c0e80ad97aac6d44360c513347; the code below is unchanged on 0c8bd5e5f3be4ce5582201513161181ddca37d6d (main, 2026-11-10).

Other Environment Information

  • Single-node MatrixOne (launch.toml), [cn.frontend.iceberg] enable/enable-write/enable-delete/enable-dml = true
  • Iceberg REST catalog: Nessie (ghcr.io/projectnessie/nessie), warehouse on MinIO (RELEASE.2023-11-01T18-37-25Z)
  • Linux x86_64, 64 vCPU, NVMe
  • Reader used for inspection: pyarrow 19.0.1 / pyiceberg 0.9.1

Actual Behavior

Every Parquet data file that MatrixOne writes to an Iceberg table (INSERT INTO <iceberg external table> ...) is written without compression and without dictionary encoding, regardless of the table property write.parquet.compression-codec.

Footer of a data file written by MO (table created with "write.parquet.compression-codec": "zstd"), 38,688 rows, 10 row groups:

created_by github.com/parquet-go/parquet-go version 0.25.1
  column                 codec         encodings
  mongo_id               UNCOMPRESSED  PLAIN,RLE
  source_stream          UNCOMPRESSED  PLAIN,RLE
  mnemonic               UNCOMPRESSED  PLAIN,RLE
  value_num              UNCOMPRESSED  PLAIN,RLE
  capture_ts_ms          UNCOMPRESSED  PLAIN,RLE
  ... (all 18 columns: UNCOMPRESSED, PLAIN)

Impact, measured on the same 773,936 rows (20 data files written by MO, 18 columns: low-cardinality strings, BIGINT timestamps, DOUBLE values), re-encoded with pyarrow:

writer bytes/row vs MO
MO (current) 207.1 1.0x
pyarrow, uncompressed, no dictionary 206.3 1.0x
pyarrow, uncompressed, dictionary 45.7 4.5x smaller
pyarrow, snappy + dictionary 19.7 10.5x smaller
pyarrow, zstd + dictionary 14.2 14.5x smaller

For a table of 22.4M rows this is 4.71 GB on object storage instead of roughly 0.32 GB. For an IoT/telemetry Bronze layer at ~12 billion points per month, it is the difference between ~2.5 TB and ~0.17 TB per month of object storage, plus proportionally more S3 GET bytes and scan I/O for every reader (MO itself, Spark, Trino, pyiceberg).

Correctness is not affected: pyiceberg reads the same 22,383,184 rows and the same SUM(value_num) as MO.

Expected Behavior

  1. Honour the Iceberg table property write.parquet.compression-codec (and ideally write.parquet.compression-level). When the property is absent, use the Iceberg default, which is zstd since Iceberg 1.4.
  2. Allow dictionary encoding for string (and other low-cardinality) columns, e.g. let parquet-go pick dictionary encoding with a plain fallback, as other Iceberg writers do.

Steps to Reproduce

We observed this with INSERT INTO <iceberg table> SELECT ... FROM <MO native table> and with INSERT ... SELECT from a MongoDB external table; the files are uncompressed in both cases. The SQL below is a minimal equivalent:

-- 1. Create the Iceberg table through the REST catalog (MO maps existing tables only), e.g.
--    POST /iceberg/v1/main%7Cwarehouse/namespaces/demo/tables
--    { "name": "t", "stage-create": false,
--      "schema": {"type":"struct","schema-id":0,"fields":[
--         {"id":1,"name":"id","required":false,"type":"long"},
--         {"id":2,"name":"tag","required":false,"type":"string"},
--         {"id":3,"name":"v","required":false,"type":"double"}]},
--      "partition-spec": {"spec-id":0,"fields":[]},
--      "properties": {"format-version":"2","write.parquet.compression-codec":"zstd"} }

-- 2. Map and write from MO
CREATE ICEBERG CATALOG c WITH ('type'='rest','uri'='http://127.0.0.1:19120/iceberg',
  'warehouse'='s3://mo-iceberg/warehouse','auth_mode'='none');
CREATE DATABASE d; USE d;
CREATE EXTERNAL TABLE t (id BIGINT, tag VARCHAR(64), v DOUBLE) ENGINE = ICEBERG
  WITH ('catalog'='c','namespace'='demo','table'='t','ref'='main',
        'read_mode'='append_only','write_mode'='append_only');
INSERT INTO t SELECT result, CONCAT('tag_', result % 10), result * 1.5
  FROM generate_series(1, 1000000) g;
# 3. Inspect any data file of the new snapshot
import pyarrow.parquet as pq
md = pq.ParquetFile("<data file>").metadata
rg = md.row_group(0)
print([(rg.column(i).path_in_schema, rg.column(i).compression, rg.column(i).encodings)
       for i in range(rg.num_columns)])
# -> every column: 'UNCOMPRESSED', ('PLAIN', 'RLE')

Additional information

Root cause in pkg/iceberg/write/parquet_writer.go:

  • The writer is created with only parquet.MaxRowsPerRowGroup(...); no parquet.Compression(...) option is passed, so parquet-go writes every page uncompressed:
    writer: parquet.NewGenericWriter[any](
    cw,
    parquet.NewSchema("iceberg", group),
    parquet.MaxRowsPerRowGroup(parquetWriteMaxRowsPerRowGroup),
    ),
  • String columns are forced to plain encoding, which disables dictionary encoding:
    func icebergStringNode() parquet.Node {
    return parquet.Encoded(parquet.String(), &parquet.Plain)
    }
  • Nothing under pkg/iceberg reads write.parquet.compression-codec.

A related, smaller point: parquetWriteMaxRowsPerRowGroup = 8192 produces many small row groups (10 row groups in a 38,688-row file). Larger row groups (by bytes, e.g. Iceberg's write.parquet.row-group-size-bytes, default 128 MB) would improve compression and reduce footer and statistics overhead for readers.

Activity

  1. added
    severity/s0
    on Nov 10, 2026
  2. XuPeng-SH commented on Nov 11, 2026

    @XuPeng-SH
    Contributor

    转 QA 验证:#32548 已于 2026-11-11 17:03:36 UTC 合入 main,merge SHA 01da59989792c498524489796eb1b74ad2ef2ca6,PR head 799682549d5a6bcff08b8d4c16b020dbec9ad3e6。本 issue 的 codec 未传递及字符串固定 PLAIN 编码问题进入转测,尚不代表验收通过。

    修复将表的 write.parquet.compression-codec 传到 append/replacement writer,缺省使用 ZSTD,字符串使用 dictionary,并限制每 row group 字符串输入、复用有限 ZSTD encoder。compression-level、可配置 row-group byte limit 和 dictionary 自动 plain fallback 不在本次实现内,不能据此承诺所有数据分布均获得同样收益。

    证据来自作者记录,本轮仅核对远端合并、issue 正文及完整评论,未运行本地测试:701f9a8 上相关包、focused race、静态检查及六种 codec/旧格式文件测试通过;Linux 实际 SQL append 10/10,默认/显式 ZSTD 与 UNCOMPRESSED footer/PyIceberg 对照、含 NULL 的 8194 行旧新混合 snapshot、SNAPPY INSERT OVERWRITE 已验证。7413b03 做了较小的公开路径复核,并非全套重跑;PR记录 ffebfe3 Ubuntu UT/SCA/CI Required 通过,这些不等同于本轮对最终合并 SHA 的实测。

    建议 QA 在合并构建检查表属性到实际已提交 footer 的 codec/encoding、默认与显式设置、append/OVERWRITE、新旧文件混合读取、NULL/长字符串/多分区,比较行数和值,并评估真实数据压缩收益及资源使用。作者的小型低基数样本缩小96.1%,宽随机字符串 CPU约2.85倍、累计分配约2.68倍,不能作为生产吞吐或峰值内存保证;1MiB字符串输入阈值允许单行超限,也不限制总SQL内存。

    保留验证边界:UPDATE虽写入SNAPPY并由MO读回,但PyIceberg0.12.0会在加载operation=update快照元数据时报错,未用完整干净旧服务建立基线,本次不能宣称解决该独立兼容限制。旧二进制读取新文件、端到端备份恢复及与更新main合并后的全套验证仍未完成。此前Ubuntu超时根因未定,后续成功不能归因为预分配修复。

  3. Ariznawlll commented on Nov 13, 2026

    @Ariznawlll
    Collaborator

    结论

    测试通过。#32466 的 Iceberg 写入压缩配置和字符串字典编码问题在本次测试范围内未再复现;宽表带过滤读取仍有独立失败,见下文。

    关键证据

    • 官方 main@3ac43c9f56eeaa7cdf6e5f45987792d9878fae8f;隔离 MO、Nessie REST catalog 和 MinIO 环境,服务 git_version() 与源码 SHA 一致。
    • 已合入的 big-data 回归 #1933 在本轮 CI 完整通过:默认压缩、显式 ZSTD、UNCOMPRESSED 对照各写入并核对 800,004 行和聚合结果;检查实际 Parquet footer,三组 codec 分别为 ZSTD、ZSTD、UNCOMPRESSED,字符串字典编码各覆盖 800,004 行。文件大小分别为 2,202,630、2,198,669、16,553,760 字节。
    • 18 列宽表复测分别写入 773,936 行 ZSTD 和 UNCOMPRESSED 数据;实际 footer 和 PyArrow 独立读取通过,6 个字符串列均观察到字典编码。该测试使用合成数据,不代表原生产数据的压缩比或吞吐。
    • 回归已合入 nightly 仓库 main,配置为每天 18:00 UTC 运行;本次为手动运行,首次定时执行结果尚未观察到。

    待解决点

    • 宽表的 MO 带过滤读取在两种 codec、两种查询下各失败 3/3,报 invalid Parquet footer;相同文件的 PyArrow 读取及 MO 非过滤对照通过。现象与已开放的 [Bug]: Predicate-pruned reads on multi-row-group Iceberg files fail with invalid magic footer #30459 相符,但本次未对根因做插桩,不能断言两者根因完全相同。失败日志。
    • 未复现原 18 列生产数据及其工作负载,未验证压缩级别、字节级 row-group 配置和生产资源开销;这些不属于本次压缩 codec/字典编码的通过结论。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triageseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions