voonhous commented on code in PR #19836:
URL: https://github.com/apache/hudi/pull/19836#discussion_r3948232540


##########
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/HoodieProcedureFilterUtils.scala:
##########
@@ -496,11 +496,15 @@ object HoodieProcedureFilterUtils {
                                                                                
             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)
+    (left.dataType, right.dataType) match {
+      case (_: NumericType, _: NumericType) =>
+        TypeCoercion.findWiderTypeForTwo(left.dataType, right.dataType)

Review Comment:
   The direction is inverted here, inherited from my comment above: 
`AnsiTypeCoercion` gives `DOUBLE` for `BIGINT`/`FLOAT`, `TypeCoercion` gives 
`FLOAT` via `numericPrecedence`. Probed on catalyst 3.5.5:
   
   ```
   TypeCoercion.findWiderTypeForTwo(LONG, FLOAT)     = Some(FloatType)
   AnsiTypeCoercion.findWiderTypeForTwo(LONG, FLOAT) = Some(DoubleType)
   ```
   
   So there is no parity-versus-precision tradeoff to weigh, ANSI is both.
   
   The `evalMode` point is real, but it needs a decimal operand to bite: 
`DECIMAL(38,20)` with `BIGINT` widens to `DECIMAL(38,20)`, 18 integral digits 
against the 19 a Long needs, so a large Long throws under ANSI and nulls 
without it. Integral-to-float widening rounds but never throws. Both shapes are 
now recorded on `widenNumericOperands`.
   



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