bug: ReferenceVisitor::GetReferencedFieldIds dereferences null on a bound COUNT(*)
維護者通常 2 天內回覆
評估
研究方向
從 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,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
apache/iceberg-cpp 的其他 Issue
-
bug: TableMetadataBuilder::RemoveSchemas leaves removed ids in the schema index可能已有人在做 @LuciferYang 於 5 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
apache/iceberg-cpp#1011 ·
維護者通常 2 天內回覆
-
難度 5/5 一週以上 新手友好度 12/100
apache/iceberg-cpp#1027 ·
維護者通常 2 天內回覆
-
bug: gzip table metadata is neither written nor detected as gzip可能已有人在做 @LuciferYang 於 5 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 66/100
apache/iceberg-cpp#1013 ·
維護者通常 2 天內回覆
-
難度 4/5 3-5 天 新手友好度 35/100
apache/iceberg-cpp#1000 · 2 則留言 · 1 個 reaction ·
維護者通常 2 天內回覆
-
難度 5/5 一週以上 新手友好度 8/100
apache/iceberg-cpp#988 · 2 則留言 ·
維護者通常 2 天內回覆
查看 apache/iceberg-cpp 的全部 Issue
相似的 Issue
-
bug tooling
難度 2/5 1-3 小時 新手友好度 76/100
-
bug
難度 2/5 1-3 小時 新手友好度 69/100
維護者通常 1 天內回覆
-
bug GPU
難度 2/5 1-3 小時 新手友好度 69/100
AMReX-Astro/Microphysics#2115 ·
維護者通常 1 天內回覆
-
Bug: negative DECIMAL with fewer digits than its scale prints as "0.-5"可能已有人在做 @adsharma 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
LadybugDB/ladybug#1311 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆