Skip to content

Commit f55fbae

Browse files
committed
wrong symbol for bitwise not
1 parent 120a350 commit f55fbae

File tree

1 file changed

+10
-11
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions

1 file changed

+10
-11
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package org.apache.spark.sql.catalyst.expressions
1919

2020
import org.apache.spark.sql.catalyst.analysis.UnresolvedException
2121
import org.apache.spark.sql.catalyst.types._
22-
import scala.math.pow
2322

2423
case class UnaryMinus(child: Expression) extends UnaryExpression {
2524
type EvaluatedType = Any
@@ -43,7 +42,7 @@ case class Sqrt(child: Expression) extends UnaryExpression {
4342
override def toString = s"SQRT($child)"
4443

4544
override def eval(input: Row): Any = {
46-
n1(child, input, ((na,a) => math.sqrt(na.toDouble(a))))
45+
n1(child, input, (na,a) => math.sqrt(na.toDouble(a)))
4746
}
4847
}
4948

@@ -134,7 +133,7 @@ case class BitwiseAnd(left: Expression, right: Expression) extends BinaryArithme
134133
case ShortType => (evalE1.asInstanceOf[Short] & evalE2.asInstanceOf[Short]).toShort
135134
case IntegerType => evalE1.asInstanceOf[Int] & evalE2.asInstanceOf[Int]
136135
case LongType => evalE1.asInstanceOf[Long] & evalE2.asInstanceOf[Long]
137-
case other => sys.error(s"Unsupported bitwise & operation on ${other}")
136+
case other => sys.error(s"Unsupported bitwise & operation on $other")
138137
}
139138
}
140139

@@ -149,7 +148,7 @@ case class BitwiseOr(left: Expression, right: Expression) extends BinaryArithmet
149148
case ShortType => (evalE1.asInstanceOf[Short] | evalE2.asInstanceOf[Short]).toShort
150149
case IntegerType => evalE1.asInstanceOf[Int] | evalE2.asInstanceOf[Int]
151150
case LongType => evalE1.asInstanceOf[Long] | evalE2.asInstanceOf[Long]
152-
case other => sys.error(s"Unsupported bitwise | operation on ${other}")
151+
case other => sys.error(s"Unsupported bitwise | operation on $other")
153152
}
154153
}
155154

@@ -164,7 +163,7 @@ case class BitwiseXor(left: Expression, right: Expression) extends BinaryArithme
164163
case ShortType => (evalE1.asInstanceOf[Short] ^ evalE2.asInstanceOf[Short]).toShort
165164
case IntegerType => evalE1.asInstanceOf[Int] ^ evalE2.asInstanceOf[Int]
166165
case LongType => evalE1.asInstanceOf[Long] ^ evalE2.asInstanceOf[Long]
167-
case other => sys.error(s"Unsupported bitwise ^ operation on ${other}")
166+
case other => sys.error(s"Unsupported bitwise ^ operation on $other")
168167
}
169168
}
170169

@@ -177,19 +176,19 @@ case class BitwiseNot(child: Expression) extends UnaryExpression {
177176
def dataType = child.dataType
178177
override def foldable = child.foldable
179178
def nullable = child.nullable
180-
override def toString = s"-$child"
179+
override def toString = s"~$child"
181180

182181
override def eval(input: Row): Any = {
183182
val evalE = child.eval(input)
184183
if (evalE == null) {
185184
null
186185
} else {
187186
dataType match {
188-
case ByteType => (~(evalE.asInstanceOf[Byte])).toByte
189-
case ShortType => (~(evalE.asInstanceOf[Short])).toShort
190-
case IntegerType => ~(evalE.asInstanceOf[Int])
191-
case LongType => ~(evalE.asInstanceOf[Long])
192-
case other => sys.error(s"Unsupported bitwise ~ operation on ${other}")
187+
case ByteType => ~evalE.asInstanceOf[Byte]
188+
case ShortType => ~evalE.asInstanceOf[Short]
189+
case IntegerType => ~evalE.asInstanceOf[Int]
190+
case LongType => ~evalE.asInstanceOf[Long]
191+
case other => sys.error(s"Unsupported bitwise ~ operation on $other")
193192
}
194193
}
195194
}

0 commit comments

Comments
 (0)