Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

CLI: --output=json list-refs emits one object per retention property instead of per ref

未关闭 适合新手
#4,098 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@tomron 已经在做这个了。

开始于 2026年10月13日。

  • #4101 来自 @tomron —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
87/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
cli

调研方向

阅读 pyiceberg/cli/output.py,并检查 JsonOutput.describe_refs() 和 ConsoleOutput.describe_refs()。为一个和多个引用的情况添加回归测试,然后运行相关的输出测试。每个引用都生成一个包含其所有保留属性的 JSON 对象,即表示完成。

由索引模型根据 Issue 内容生成。

描述

kind:bug
Apache Iceberg version

None

Please describe the bug 🐞
Apache Iceberg version

main (development)

Please describe the bug

JsonOutput.describe_refs() emits one JSON object for each retention property rather than one object per snapshot reference.

As a result, pyiceberg --output=json list-refs <table> can return three objects for a table containing only one snapshot reference.

Reproduction
from pyiceberg.cli.output import JsonOutput
from pyiceberg.table.refs import SnapshotRefType

JsonOutput().describe_refs([
    (
        "main",
        SnapshotRefType.BRANCH,
        {
            "min_snapshots_to_keep": "1",
            "max_snapshot_age_ms": "432000000",
            "max_ref_age_ms": "forever",
        },
    )
])
Actual output
[
  {"name": "main", "type": "branch", "min_snapshots_to_keep": "1"},
  {"name": "main", "type": "branch", "max_snapshot_age_ms": "432000000"},
  {"name": "main", "type": "branch", "max_ref_age_ms": "forever"}
]
Expected output
[
  {
    "name": "main",
    "type": "branch",
    "min_snapshots_to_keep": "1",
    "max_snapshot_age_ms": "432000000",
    "max_ref_age_ms": "forever"
  }
]
Root cause

In pyiceberg/cli/output.py, JsonOutput.describe_refs() uses a nested list comprehension:

[
    {"name": name, "type": type, detail_key: detail_val}
    for name, type, detail in refs
    for detail_key, detail_val in detail.items()
]

The inner loop creates a separate object for every entry in detail.

This is inconsistent with ConsoleOutput.describe_refs(), which renders one row per reference.

Suggested fix

Construct one dictionary per reference and merge the retention properties into it. Add a regression test ensuring that one input reference produces one complete JSON object, ideally also covering multiple references.

I reproduced the incorrect output by executing the current list-comprehension logic in isolation. I have not yet run the full CLI against a catalog.

Willingness to contribute

I'd be happy to submit a focused fix with regression tests if the proposed JSON structure is correct.

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
主要语言
Python
星标
1.2k
派生
618
平均合并
1 天 3 小时
30 天内合并 PR
45

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/iceberg-python 的其他 Issue

查看 apache/iceberg-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。