tanelk commented on a change in pull request #31170:
URL: https://github.com/apache/spark/pull/31170#discussion_r557372707



##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/BitwiseExpressionsSuite.scala
##########
@@ -131,4 +132,35 @@ class BitwiseExpressionsSuite extends SparkFunSuite with 
ExpressionEvalHelper {
       checkConsistencyBetweenInterpretedAndCodegen(BitwiseXor, dt, dt)
     }
   }
+
+  test("BitGet") {
+    val nullLongLiteral = Literal.create(null, LongType)
+    val nullIntLiteral = Literal.create(null, IntegerType)
+    checkEvaluation(BitwiseGet(nullLongLiteral, Literal(1)), null)
+    checkEvaluation(BitwiseGet(Literal(11L), nullIntLiteral), null)
+    checkEvaluation(BitwiseGet(nullLongLiteral, nullIntLiteral), null)
+    checkEvaluation(BitwiseGet(Literal(11L), Literal(3)), 1L)
+    checkEvaluation(BitwiseGet(Literal(11L), Literal(2)), 0L)
+    checkEvaluation(BitwiseGet(Literal(11L), Literal(1)), 1L)
+    checkEvaluation(BitwiseGet(Literal(11L), Literal(0)), 1L)
+    checkEvaluation(BitwiseGet(Literal(11L), Literal(63)), 0L)
+
+    val row1 = create_row(11L, -1)
+    val row2 = create_row(11L, 64)
+
+    val t = 't.long.at(0)
+    val p = 'p.int.at(1)
+
+    val expr = BitwiseGet(t, p)
+    checkExceptionInExpression[IllegalArgumentException](
+      expr, row1, "Invalid bit position: -1 less than zero")
+
+    checkExceptionInExpression[IllegalArgumentException](
+      expr, row2, "Invalid bit position: 64 exceeds the bit length of the 
target long")
+
+    DataTypeTestUtils.integralType.foreach { _ =>

Review comment:
       The foreach is not required, if Long is only datatype.




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

Reply via email to