sdf-jkl commented on issue #18320:
URL: https://github.com/apache/datafusion/issues/18320#issuecomment-3504798402

   I checked the clickhouse implementation of preimage and they only support 
the 
[`toYear`](https://github.com/ClickHouse/ClickHouse/blob/master/src/Functions/DateTimeTransforms.h#L1404)
 and 
[`toYYYYMM`](https://github.com/ClickHouse/ClickHouse/blob/master/src/Functions/DateTimeTransforms.h#L2284)
 functions. 
   
   The duckdb 
[date_part_simplification](https://github.com/duckdb/duckdb/blob/main/src/optimizer/rule/date_part_simplification.cpp)
 is similar to `ScalarUDF::simplify` - it does not actually simplify the 
predicate expression like date_trunc
   
   We can only support `date_part('year', col)` in DataFusion (out of those 
that can be simplified).
   
   What kind of function simplification support do we have in DataFusion in 
general?
   
   I think we can extend `ScalarUDF` API to add another function(or extend 
`ScalarUDF::simplify`). 
   
   Something like `simplify_predicate_function(info, args, op, const)` to try 
to move the function call to the right side of the predicate expression:
   ```
   func(<col>) op <constant> -> <col> op func(<constant>)/(<col> >= <constant> 
and <col> < <constant+1>)`
   ```
   


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

Reply via email to