cfmcgrady commented on a change in pull request #32488:
URL: https://github.com/apache/spark/pull/32488#discussion_r634893418
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/UnwrapCastInBinaryComparison.scala
##########
@@ -121,6 +129,24 @@ object UnwrapCastInBinaryComparison extends
Rule[LogicalPlan] {
if canImplicitlyCast(fromExp, toType, literalType) =>
simplifyNumericComparison(be, fromExp, toType, value)
+ case in @ In(Cast(fromExp, toType: NumericType, _), list)
+ if list.forall(v =>
+ v.isInstanceOf[Literal] && canImplicitlyCast(fromExp, toType,
v.dataType)
+ ) =>
+ val (newValueList, exp) =
+ list.map(lit => unwrapCast(EqualTo(in.value, lit)))
+ .partition {
Review comment:
As @sunchao mentioned before, we `partition` results because the
`unwrapCast` converts a `EqualTo` to a different expression.
For instance:
```
x = 1 => x = 1
```
```
x = 2147483648 => if(isnull(x), null, false)
```
if `x` is of integer type.
Do you mean we can simply do `x in (1, 2147483648) => x in (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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]