Fokko commented on code in PR #945:
URL: https://github.com/apache/iceberg-rust/pull/945#discussion_r1952815822


##########
crates/integrations/datafusion/src/physical_plan/expr_to_predicate.rs:
##########
@@ -403,4 +452,55 @@ mod tests {
             
Reference::new("ts").greater_than_or_equal_to(Datum::string("2023-01-05T00:00:00"));
         assert_eq!(predicate, expected_predicate);
     }
+
+    #[test]
+    fn test_to_timestamp_comparison_creates_predicate() {
+        let sql = "ts >= timestamp '2023-01-05T00:00:00'";
+        let predicate = convert_to_iceberg_predicate(sql).unwrap();
+        let expected_predicate =
+            
Reference::new("ts").greater_than_or_equal_to(Datum::string("2023-01-05T00:00:00"));
+        assert_eq!(predicate, expected_predicate);
+    }
+
+    #[test]
+    fn test_to_timestamp_comparison_to_cast_creates_predicate() {
+        let sql = "ts >= CAST('2023-01-05T00:00:00' AS TIMESTAMP)";
+        let predicate = convert_to_iceberg_predicate(sql).unwrap();
+        let expected_predicate =
+            
Reference::new("ts").greater_than_or_equal_to(Datum::string("2023-01-05T00:00:00"));
+        assert_eq!(predicate, expected_predicate);
+    }
+
+    #[test]
+    fn test_to_timestamp_with_custom_format_does_not_create_predicate() {
+        let sql =
+            "TO_TIMESTAMP(ts, 'YYYY-DD-MMTmm:HH:SS') >= 
CAST('2023-01-05T00:00:00' AS TIMESTAMP)";
+        let predicate = convert_to_iceberg_predicate(sql);
+        assert_eq!(predicate, None);
+    }
+
+    #[test]
+    fn test_to_date_comparison_creates_predicate() {
+        let sql = "ts >= CAST('2023-01-05T11:11:11' AS DATE)";

Review Comment:
   I'm surprised to see that this works:
   
   ```
   spark-sql (default)> SELECT CAST('2023-01-05T11:11:11' AS DATE);
   2023-01-05
   ```



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