Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

bug: ReferenceVisitor::GetReferencedFieldIds dereferences null on a bound COUNT(*)

已關閉 適合新手
#978 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

@LuciferYang 已經在處理了。

開始於 2026年10月1日。

  • #981 來自 @LuciferYang —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
82/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
cpp
領域
backend

研究方向

從 src/iceberg/expression/binder.cc 開始,特別查看 ReferenceVisitor::Aggregate,並將 BoundAggregate::reference() 處理 COUNT(*) 的方式與 src/iceberg/expression/aggregate.cc 中的聚合建構進行比較。檢查 aggregate_test.cc 中現有的聚合覆蓋;當對已繫結的 COUNT(*) 呼叫 GetReferencedFieldIds 不再當機且不貢獻任何欄位 id 時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

Summary

ReferenceVisitor::GetReferencedFieldIds (exported via ICEBERG_EXPORT) crashes with a SIGSEGV when the expression tree contains a bound COUNT(*). ReferenceVisitor::Aggregate runs referenced_field_ids_.insert(aggregate->reference()->field_id()), but a COUNT(*) aggregate has a null term, so reference() returns nullptr and ->field_id() dereferences it.

Root Cause

CountStarAggregate is constructed with a null term (src/iceberg/expression/aggregate.cc), and BoundAggregate::reference() returns term() ? term()->reference() : nullptr, so it is nullptr for COUNT(*). src/iceberg/expression/binder.cc dereferences it with no guard. Visit() routes any bound aggregate to Aggregate(), so binding Expressions::CountStar() and calling GetReferencedFieldIds segfaults. COUNT(col) / MAX / MIN have non-null terms and are unaffected.

Impact

No in-tree scan path passes aggregates to GetReferencedFieldIds today (table_scan.cc and manifest_group.cc pass row filters), so the crash lands on a library consumer that does aggregate pushdown through the exported API. COUNT(*) is the most common aggregate, and binding it is a supported, tested workflow (aggregate_test.cc). Java's ReferenceVisitor base throws UnsupportedOperationException on aggregates, a catchable error; the C++ port instead crashes the process.

Proposed Fix

Insert the field id only when reference() is non-null. COUNT(*) then contributes no field ids, which is the correct result for field projection (counting rows reads no columns).

主要語言
C++
星號
228
分支
136
平均合併
5 天 19 小時
30 天內合併 PR
53

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

apache/iceberg-cpp 的其他 Issue

查看 apache/iceberg-cpp 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。