marvinlanhenke commented on issue #264: URL: https://github.com/apache/iceberg-rust/issues/264#issuecomment-1997524951
@liurenjie1024 ...just to make sure I'm on the right track - and to confirm the idea. Here is what I would (high-level): - implement `fn project` on Transform - match Transform & orginal BoundPredicate - handle each Transform (e.g. Bucket) and Predicate according to Java Implementation - return `Option<Predicate>` In order to implement the `ProjectionEvaluator` later, we can then get the `PartitionSpec` from the manifest, iterate over `fields: Vec<PartitionField>` and call `fn project(...)` on each field's transform... some pseudo-implementation to illustrate: ```rust impl Transform { // ... pub fn project(&self, name: String, pred: &BoundPredicate) -> Option<Predicate> { match self { Transform::Bucket(_) => match pred { BoundPredicate::Unary(expr) => Some(Predicate::Unary(UnaryExpression::new( expr.op(), Reference::new(name), ))), _ => unimplemented!(), }, _ => unimplemented!(), } } } ``` ```rust #[test] fn test_bucket_project() { let trans = Transform::Bucket(8); let name = "projected_name".to_string(); let field = NestedField::required(1, "a", Type::Primitive(PrimitiveType::Int)); let pred = BoundPredicate::Unary(UnaryExpression::new( PredicateOperator::IsNull, BoundReference::new("original_name", Arc::new(field)), )); let result = trans.project(name, &pred).unwrap(); assert_eq!(format!("{result}"), "projected_name IS NULL"); } ``` -- 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