liurenjie1024 commented on code in PR #945:
URL: https://github.com/apache/iceberg-rust/pull/945#discussion_r1952345735
##########
crates/integrations/datafusion/src/physical_plan/expr_to_predicate.rs:
##########
@@ -119,7 +122,53 @@ fn to_iceberg_predicate(expr: &Expr) -> TransformedResult {
_ => TransformedResult::NotTransformed,
}
}
- Expr::Cast(c) => to_iceberg_predicate(&c.expr),
+ Expr::Cast(c) => {
+ if DataType::Date32 == c.data_type || DataType::Date64 ==
c.data_type {
+ match c.expr.as_ref() {
+ Expr::Literal(ScalarValue::Utf8(Some(literal))) => {
+ let date = literal.split('T').next();
+ if let Some(date) = date {
+ return
TransformedResult::Literal(Datum::string(date));
+ }
+ }
+ _ => return TransformedResult::NotTransformed,
+ }
+ }
+ to_iceberg_predicate(&c.expr)
+ }
+ Expr::ScalarFunction(func) => {
+ if func
+ .func
+ .inner()
+ .as_any()
+ .downcast_ref::<ToTimestampFunc>()
Review Comment:
Same as above, I think we should call expression simplification api here
rather using this approach.
##########
crates/integrations/datafusion/src/physical_plan/expr_to_predicate.rs:
##########
@@ -119,7 +122,53 @@ fn to_iceberg_predicate(expr: &Expr) -> TransformedResult {
_ => TransformedResult::NotTransformed,
}
}
- Expr::Cast(c) => to_iceberg_predicate(&c.expr),
+ Expr::Cast(c) => {
+ if DataType::Date32 == c.data_type || DataType::Date64 ==
c.data_type {
Review Comment:
I have concerns handling this case in such a way here. This is a process of
simplifying expression in datafusion, which should call datafusion's
[expression simplification
api](https://docs.rs/datafusion/45.0.0/datafusion/logical_expr/simplify/struct.SimplifyContext.html).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]