deepaknettem commented on code in PR #1154:
URL: https://github.com/apache/iceberg-cpp/pull/1154#discussion_r4659530768


##########
src/iceberg/expression/strict_metrics_evaluator.cc:
##########
@@ -429,7 +431,46 @@ class StrictMetricsVisitor : public BoundVisitor<bool> {
 
   Result<bool> StartsWith(const std::shared_ptr<Bound>& expr,
                           const Literal& lit) override {
-    return kRowsMightNotMatch;
+    RETURN_IF_NOT_REFERENCE(expr);
+
+    int32_t id = expr->reference()->field().field_id();
+
+    ICEBERG_ASSIGN_OR_RAISE(auto is_nested, IsNestedColumn(id));
+    if (is_nested) {
+      return kRowsMightNotMatch;
+    }
+
+    ICEBERG_ASSIGN_OR_RAISE(auto has_nulls, CanContainNulls(id));
+    if (has_nulls) {
+      return kRowsMightNotMatch;
+    }
+
+    auto lower_it = data_file_.lower_bounds.find(id);
+    auto upper_it = data_file_.upper_bounds.find(id);
+    if (lower_it == data_file_.lower_bounds.cend() ||
+        upper_it == data_file_.upper_bounds.cend()) {
+      return kRowsMightNotMatch;
+    }
+
+    ICEBERG_DCHECK(expr->reference()->type()->type_id() == TypeId::kString &&

Review Comment:
   Good point. I had InvalidExpression in my first iteration and tried to write 
a test case to catch it, but then switched DCHECK after seeing Binder::Bind 
already enforces the safety (added three new StartsWithRejects*OnBind tests).
   
   Agree that a strict check is more appropriate and looks consistent with the 
rest of the code. Updated accordingly :)



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