omerhadari opened a new issue, #933:
URL: https://github.com/apache/iceberg-rust/issues/933

   Currently, for queries that compare timestamps/dates using `TO_DATE` in 
order to for example truncate a timestamp column, no pushdown predicates are 
applied. This is because the functions `TO_DATE`, `TO_TIMESTAMP` are not casts, 
and so they reach the function `to_iceberg_predicate` as `ScalarFunction`s, and 
not matched on any branch.
   
   It would be nice to identify these cases because it is very common to have a 
partition key on a timestamp column with a Day Transformation, and currently 
queries such as `SELECT * FROM table WHERE TO_DATE(table.timestamp_col) = 
'2025-01-01'` result in no pushdown predicates at all.
   
   
   Something along the line of these tests would ideally pass:
   
   ```Rust
       #[test]
       fn test_to_timestamp_comparison_creates_predicate() {
           let sql = "TO_TIMESTAMP(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_creates_predicate() {
           let sql = "TO_TIMESTAMP(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_date_comparison_creates_predicate() {
           let sql = "TO_DATE(ts) >= CAST('2023-01-05T00:00:00' AS DATE)";
           let predicate = convert_to_iceberg_predicate(sql).unwrap();
           let expected_predicate =
               
Reference::new("ts").greater_than_or_equal_to(Datum::string("2023-01-05"));
           assert_eq!(predicate, expected_predicate);
       }
   
   ```


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