Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/3528#discussion_r21128111
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
---
@@ -185,11 +184,11 @@ case class BitwiseNot(child: Expression) extends
UnaryExpression {
null
} else {
dataType match {
- case ByteType => (~(evalE.asInstanceOf[Byte])).toByte
- case ShortType => (~(evalE.asInstanceOf[Short])).toShort
- case IntegerType => ~(evalE.asInstanceOf[Int])
- case LongType => ~(evalE.asInstanceOf[Long])
- case other => sys.error(s"Unsupported bitwise ~ operation on
${other}")
+ case ByteType => ~evalE.asInstanceOf[Byte]
--- End diff --
I think this is actually introducing a bug. Above we set `def dataType =
child.dataType` but this is changing the type to an `Int`.
```scala
scala> ~1.toByte
res0: Int = -2
```
Can you fix and add some test cases to the expression evaluation suite to
make sure this doesn't regress again?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]