manuzhang commented on code in PR #952:
URL: https://github.com/apache/iceberg-cpp/pull/952#discussion_r4095137999


##########
src/iceberg/manifest/manifest_group.cc:
##########
@@ -131,6 +131,148 @@ ManifestGroup::~ManifestGroup() = default;
 ManifestGroup::ManifestGroup(ManifestGroup&&) noexcept = default;
 ManifestGroup& ManifestGroup::operator=(ManifestGroup&&) noexcept = default;
 
+class ManifestGroup::PlanningContext {
+ public:
+  // `group` is borrowed; its planning configuration must remain unchanged for 
the
+  // lifetime of this context.
+  static Result<PlanningContext> Make(const ManifestGroup& group,
+                                      std::vector<std::string> columns) {
+    std::unique_ptr<Evaluator> file_evaluator;
+    if (!group.file_filter_ || group.file_filter_->op() == 
Expression::Operation::kTrue) {
+      return PlanningContext(group, std::move(file_evaluator), 
std::move(columns));
+    }
+
+    auto data_file_schema = DataFileFilterSchema();
+    ICEBERG_ASSIGN_OR_RAISE(
+        file_evaluator,
+        Evaluator::Make(*data_file_schema, group.file_filter_, 
group.case_sensitive_));
+    if (std::ranges::contains(columns, Schema::kAllColumns)) {
+      return PlanningContext(group, std::move(file_evaluator), 
std::move(columns));
+    }
+
+    ICEBERG_ASSIGN_OR_RAISE(
+        auto bound_file_filter,
+        Binder::Bind(*data_file_schema, group.file_filter_, 
group.case_sensitive_));
+    ICEBERG_ASSIGN_OR_RAISE(auto referenced_field_ids,
+                            
ReferenceVisitor::GetReferencedFieldIds(bound_file_filter));
+
+    std::unordered_set<std::string> selected_columns(columns.cbegin(), 
columns.cend());
+    for (const auto field_id : referenced_field_ids) {

Review Comment:
   nit: I'm a bit uncomfortable with the follow two `continue`s in one loop.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to