mkaravel commented on a change in pull request #34056:
URL: https://github.com/apache/spark/pull/34056#discussion_r713280761



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
##########
@@ -2649,3 +2649,192 @@ case class Sentences(
     copy(str = newFirst, language = newSecond, country = newThird)
 
 }
+
+/**
+ * A function that returns the bitwise AND of two binary strings.
+ * The byte length of the result is the maximum of the byte lengths of the two 
input binary
+ * strings. If the two input binary strings are of different byte length they 
aligned according
+ * to their least significant (right-most) bit.  The shorter binary string is 
semantically
+ * left-padded with zeros.
+ */
+@ExpressionDescription(
+  usage = """
+    _FUNC_(bytes1, bytes2) - Returns the bitwise AND of two binary strings.
+  """,
+  examples = """
+    Examples:
+      > SELECT hex(_FUNC_(unhex('AABB'), unhex('11223344')));
+       00002200
+  """,
+  since = "3.3.0",
+  group = "string_funcs")
+case class BitAnd(bytes1: Expression, bytes2: Expression)
+  extends BinaryExpression with ExpectsInputTypes with NullIntolerant {
+
+  override def inputTypes: Seq[AbstractDataType] = Seq(BinaryType, BinaryType)
+
+  override def dataType: DataType = BinaryType
+
+  override def left: Expression = bytes1
+  override def right: Expression = bytes2
+
+  override def nullSafeEval(left: Any, right: Any): Any = {
+    bytes1.dataType match {
+      case BinaryType => ByteArray.bitwiseAnd(left.asInstanceOf[Array[Byte]],

Review comment:
       Done.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala
##########
@@ -2649,3 +2649,192 @@ case class Sentences(
     copy(str = newFirst, language = newSecond, country = newThird)
 
 }
+
+/**
+ * A function that returns the bitwise AND of two binary strings.

Review comment:
       Done. Referring to expressions now.




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

To unsubscribe, e-mail: [email protected]

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