hudi-agent commented on code in PR #19836:
URL: https://github.com/apache/hudi/pull/19836#discussion_r3949890528


##########
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/HoodieProcedureFilterUtils.scala:
##########
@@ -516,17 +528,91 @@ object HoodieProcedureFilterUtils {
     }
   }
 
-  private def applyTypeCoercion[T <: 
org.apache.spark.sql.catalyst.expressions.Expression](
-                                                                               
             left: org.apache.spark.sql.catalyst.expressions.Expression,
-                                                                               
             right: org.apache.spark.sql.catalyst.expressions.Expression,
-                                                                               
             constructor: 
(org.apache.spark.sql.catalyst.expressions.Expression, 
org.apache.spark.sql.catalyst.expressions.Expression) => T,
-                                                                               
             original: T): T = {
-    (left, right) match {
-      case (boundRef: 
org.apache.spark.sql.catalyst.expressions.BoundReference, literal: 
org.apache.spark.sql.catalyst.expressions.Literal)
-        if boundRef.dataType == org.apache.spark.sql.types.LongType && 
literal.dataType == org.apache.spark.sql.types.IntegerType =>
-        val castExpr = 
org.apache.spark.sql.catalyst.expressions.Cast(boundRef, 
org.apache.spark.sql.types.IntegerType)
-        constructor(castExpr, literal)
+  private def applyTypeCoercion[T <: Expression](left: Expression,
+                                                 right: Expression,
+                                                 constructor: (Expression, 
Expression) => T,
+                                                 original: T): T = {
+    widenNumericOperands(Seq(left, right)) match {
+      case Some(Seq(widenedLeft, widenedRight)) => constructor(widenedLeft, 
widenedRight)
       case _ => original
     }
   }
+
+  private def applyInTypeCoercion(in: In): Expression = {
+    widenNumericOperands(in.value +: in.list) match {
+      case Some(widened) => In(widened.head, widened.tail)
+      case _ => in
+    }
+  }
+
+  private def applyArithmeticTypeCoercion(arith: BinaryArithmetic): Expression 
= {
+    widenNumericOperands(Seq(arith.left, arith.right)) match {

Review Comment:
   🤖 Widening to the common numeric type leaves `Divide` on integrals 
unresolved (`Divide.inputType` is `TypeCollection(DoubleType, DecimalType)`), 
so `ts / 2 > 500` now fails validation with "Unsupported filter expression" 
while `price / 2 > 5` works. Would it be worth mirroring Spark's `Division` 
rule and widening `Divide` operands to `DoubleType`?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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

Reply via email to