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



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/bitwiseExpressions.scala
##########
@@ -204,3 +205,48 @@ case class BitwiseCount(child: Expression)
     case LongType => java.lang.Long.bitCount(input.asInstanceOf[Long])
   }
 }
+
+object BitwiseGet {
+  def calculate(target: Int, pos: Int): Int = {
+    val bitCount = java.lang.Long.bitCount(target)

Review comment:
       because `checkEvaluation(BitwiseGet(Literal(11), Literal(4)), 0)` will 
fail with `Cause: java.lang.IllegalArgumentException: Invalid bit position: 4 
exceeds the bit length of the target integer`.
   For integer the valid inputs for second parameter should be 0 to 31. 
currently you can't check past the most significant set bit.
   
   And for each different input type the range should be different (for long 
0..63, etc).
   The number of bits are kept in the constants 
`java.lang.Long/Integer/Short/Byte.SIZE`




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