sdf-jkl commented on code in PR #18789:
URL: https://github.com/apache/datafusion/pull/18789#discussion_r2611724287


##########
datafusion/expr/src/udf.rs:
##########
@@ -696,6 +696,33 @@ pub trait ScalarUDFImpl: Debug + DynEq + DynHash + Send + 
Sync {
         Ok(ExprSimplifyResult::Original(args))
     }
 
+    /// Attempts to convert a literal value to in interval of the 
corresponding datatype
+    /// of a column expression so that a **preimage** can be computed for
+    /// pruning comparison predicates.
+    ///
+    /// This is used during predicate-pushdown optimization
+    /// (see 
`datafusion-optimizer-udf_preimage::preimage_in_comparison_for_binary`)
+    ///
+    /// Currently is only implemented by:
+    /// - `date_part(YEAR, expr)`
+    ///
+    /// # Arguments:
+    /// * `lit_value`:  The literal `&ScalarValue` used in comparison
+    /// * `target_type`: The datatype of the column expression inside the 
function
+    ///
+    /// # Returns
+    ///
+    /// Returns an `Interval` of the appropriate target type if a
+    /// preimage cast is supported for the given function/operator combination;
+    /// otherwise returns `None`.
+    fn preimage(
+        &self,
+        _lit_value: &ScalarValue,
+        _target_type: &DataType,

Review Comment:
   `target_type` should be the type of the `left_expression` column, not the 
`lit_value: ScalarValue` we are comparing it to. 
   
   We also can't remove `lit_value` from the function parameters, since it's 
not one of the `args` used when calling the function. (We could extend the 
`args` list to add the `lit_value` to it before calling the function, but it 
seems to make things less clear)



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