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


##########
crates/iceberg/src/spec/transform.rs:
##########
@@ -398,6 +679,80 @@ mod tests {
         }
     }
 
+    #[test]
+    fn test_none_projection() -> Result<()> {
+        let name = "projected_name".to_string();
+        let preds = TestPredicates::new();
+
+        let transform = Transform::Void;
+        let result_unary = transform.project(name.clone(), &preds.unary)?;
+        assert!(result_unary.is_none());
+
+        let transform = Transform::Year;
+        let result_binary = transform.project(name.clone(), &preds.binary)?;
+        assert!(result_binary.is_none());
+
+        let transform = Transform::Month;
+        let result_set = transform.project(name.clone(), &preds.set)?;
+        assert!(result_set.is_none());
+
+        Ok(())
+    }
+
+    #[test]
+    fn test_truncate_project() -> Result<()> {
+        let name = "projected_name".to_string();
+        let preds = TestPredicates::new();
+
+        let transform = Transform::Truncate(10);
+
+        let result_unary = transform.project(name.clone(), 
&preds.unary)?.unwrap();
+        let result_binary = transform.project(name.clone(), 
&preds.binary)?.unwrap();
+        let result_set = transform.project(name.clone(), &preds.set)?.unwrap();
+
+        assert_eq!(format!("{}", result_unary), "projected_name IS NULL");
+        assert_eq!(format!("{}", result_binary), "projected_name = 0");
+        assert_eq!(format!("{}", result_set), "projected_name IN (0)");

Review Comment:
   Just trying to follow what's happening here so that I understand. 
   
   So in the case of `result_binary`, the value of 5 gets truncated to 0, since 
the truncate transform when applied to an int effectively divides by 10, 
rounding down for all fractional values (ie, 1-9 get truncated to 0, 10-19 get 
truncated to 1, 20-29 get truncated to 2)?
   
   And in the case of `result_set`, since both 5 and 6 get truncated to the 
same value of 0, a set of (5, 6) becomes a set of (0)?
   
   



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