You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2026/02/02 23:20:33 UTC
Re: [PR] Optimize the evaluation of date_part() == when pushed down [datafusion]
alamb commented on code in PR #19733:
URL: https://github.com/apache/datafusion/pull/19733#discussion_r2756440571
##########
datafusion/functions/src/datetime/date_part.rs:
##########
@@ -237,6 +242,71 @@ impl ScalarUDFImpl for DatePartFunc {
})
}
+ // Only casting the year is supported since pruning other IntervalUnit is not possible
+ // date_part(col, YEAR) = 2024 => col >= '2024-01-01' and col < '2025-01-01'
+ // But for anything less than YEAR simplifying is not possible without specifying the bigger interval
+ // date_part(col, MONTH) = 1 => col = '2023-01-01' or col = '2024-01-01' or ... or col = '3000-01-01'
+ fn preimage(
+ &self,
+ args: &[Expr],
+ lit_expr: &Expr,
+ info: &SimplifyContext,
+ ) -> Result<PreimageResult> {
+ let [part, col_expr] = take_function_args(self.name(), args)?;
Review Comment:
I think we should be able to avoid writing all this code
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org