zhjwpku commented on code in PR #491:
URL: https://github.com/apache/iceberg-cpp/pull/491#discussion_r2678526481


##########
src/iceberg/expression/binder.cc:
##########
@@ -113,4 +115,54 @@ Result<bool> IsBoundVisitor::Aggregate(
   return false;
 }
 
+Result<std::unordered_set<int32_t>> ReferenceVisitor::GetReferencedFieldIds(
+    const std::shared_ptr<Expression>& expr) {
+  ICEBERG_PRECHECK(expr != nullptr, "Expression cannot be null");
+  ReferenceVisitor visitor;
+  return Visit<FieldIdsSetRef, ReferenceVisitor>(expr, visitor);
+}
+
+Result<FieldIdsSetRef> ReferenceVisitor::AlwaysTrue() { return 
referenced_field_ids_; }
+
+Result<FieldIdsSetRef> ReferenceVisitor::AlwaysFalse() { return 
referenced_field_ids_; }
+
+Result<FieldIdsSetRef> ReferenceVisitor::Not(
+    [[maybe_unused]] const FieldIdsSetRef& child_result) {
+  return referenced_field_ids_;
+}
+
+Result<FieldIdsSetRef> ReferenceVisitor::And(
+    [[maybe_unused]] const FieldIdsSetRef& left_result,
+    [[maybe_unused]] const FieldIdsSetRef& right_result) {
+  return referenced_field_ids_;
+}
+
+Result<FieldIdsSetRef> ReferenceVisitor::Or(
+    [[maybe_unused]] const FieldIdsSetRef& left_result,
+    [[maybe_unused]] const FieldIdsSetRef& right_result) {
+  return referenced_field_ids_;
+}
+
+Result<FieldIdsSetRef> ReferenceVisitor::Predicate(
+    const std::shared_ptr<BoundPredicate>& pred) {
+  referenced_field_ids_.insert(pred->reference()->field_id());
+  return referenced_field_ids_;
+}
+
+Result<FieldIdsSetRef> ReferenceVisitor::Predicate(
+    [[maybe_unused]] const std::shared_ptr<UnboundPredicate>& pred) {
+  return referenced_field_ids_;

Review Comment:
   I just took a look at the Java's impl of ReferenceVisitor and 
IsBoundVisitor, it appears that mixed bound and unbound predicate should error, 
I created PR #503 to fix our IsBoundVisitor logic, please correct me if f I'm 
wrong.



-- 
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