sdd commented on code in PR #269:
URL: https://github.com/apache/iceberg-rust/pull/269#discussion_r1527606344


##########
crates/iceberg/src/spec/transform.rs:
##########
@@ -261,6 +269,50 @@ impl Transform {
             _ => self == other,
         }
     }
+    /// Projects predicate to `Transform`
+    pub fn project(&self, name: String, pred: &BoundPredicate) -> 
Result<Option<Predicate>> {
+        let func = create_transform_function(self)?;
+
+        let projection = match self {
+            Transform::Bucket(_) => match pred {
+                BoundPredicate::Unary(expr) => 
Some(Predicate::Unary(UnaryExpression::new(
+                    expr.op(),
+                    Reference::new(name),
+                ))),
+                BoundPredicate::Binary(expr) => {
+                    if expr.op() != PredicateOperator::Eq {
+                        return Ok(None);
+                    }
+
+                    let result = match expr.as_primitive_literal() {
+                        PrimitiveLiteral::Int(v) => func
+                            .transform(Arc::new(Int32Array::from_value(v, 1)))?
+                            .as_any()
+                            .downcast_ref::<Int32Array>()
+                            .ok_or_else(|| Error::new(ErrorKind::Unexpected, 
"Failed to downcast"))?
+                            .value(0),
+                        PrimitiveLiteral::Long(v) => func
+                            .transform(Arc::new(Int64Array::from_value(v, 1)))?
+                            .as_any()
+                            .downcast_ref::<Int32Array>()

Review Comment:
   Should this be `Int64Array`?



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to