wgtmac commented on code in PR #177:
URL: https://github.com/apache/iceberg-cpp/pull/177#discussion_r2376056465


##########
src/iceberg/expression/expressions.cc:
##########
@@ -0,0 +1,356 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "iceberg/expression/expressions.h"
+
+#include "iceberg/exception.h"
+#include "iceberg/transform.h"
+#include "iceberg/type.h"
+
+namespace iceberg {
+
+// Logical operations
+
+std::shared_ptr<Expression> Expressions::And(std::shared_ptr<Expression> left,
+                                             std::shared_ptr<Expression> 
right) {
+  if (left->op() == Expression::Operation::kFalse ||
+      right->op() == Expression::Operation::kFalse) {
+    return AlwaysFalse();
+  }
+
+  if (left->op() == Expression::Operation::kTrue) {
+    return right;
+  }
+
+  if (right->op() == Expression::Operation::kTrue) {
+    return left;
+  }
+
+  return std::make_shared<::iceberg::And>(std::move(left), std::move(right));
+}
+
+std::shared_ptr<Expression> Expressions::Or(std::shared_ptr<Expression> left,
+                                            std::shared_ptr<Expression> right) 
{
+  if (left->op() == Expression::Operation::kTrue ||
+      right->op() == Expression::Operation::kTrue) {
+    return AlwaysTrue();
+  }
+
+  if (left->op() == Expression::Operation::kFalse) {
+    return right;
+  }
+
+  if (right->op() == Expression::Operation::kFalse) {
+    return left;
+  }
+
+  return std::make_shared<::iceberg::Or>(std::move(left), std::move(right));
+}
+
+// Transform functions
+
+std::shared_ptr<UnboundTransform> Expressions::Bucket(std::string name,
+                                                      int32_t num_buckets) {
+  return std::make_shared<UnboundTransform>(Ref(std::move(name)),
+                                            Transform::Bucket(num_buckets));
+}
+
+std::shared_ptr<UnboundTransform> Expressions::Year(std::string name) {
+  return std::make_shared<UnboundTransform>(Ref(std::move(name)), 
Transform::Year());
+}
+
+std::shared_ptr<UnboundTransform> Expressions::Month(std::string name) {
+  return std::make_shared<UnboundTransform>(Ref(std::move(name)), 
Transform::Month());
+}
+
+std::shared_ptr<UnboundTransform> Expressions::Day(std::string name) {
+  return std::make_shared<UnboundTransform>(Ref(std::move(name)), 
Transform::Day());
+}
+
+std::shared_ptr<UnboundTransform> Expressions::Hour(std::string name) {
+  return std::make_shared<UnboundTransform>(Ref(std::move(name)), 
Transform::Hour());
+}
+
+std::shared_ptr<UnboundTransform> Expressions::Truncate(std::string name, 
int32_t width) {
+  return std::make_shared<UnboundTransform>(Ref(std::move(name)),
+                                            Transform::Truncate(width));
+}
+
+std::shared_ptr<UnboundTransform> Expressions::Transform(
+    std::string name, std::shared_ptr<::iceberg::Transform> transform) {
+  return std::make_shared<UnboundTransform>(Ref(std::move(name)), 
std::move(transform));
+}
+
+// Template implementations for unary predicates
+
+std::shared_ptr<UnboundPredicate<BoundReference>> 
Expressions::IsNull(std::string name) {
+  return IsNull<BoundReference>(Ref(std::move(name)));
+}

Review Comment:
   This is indeed a unbound reference. It is calling IsNull function with 
template parameter `BoundReference` to indicate its bound type.



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