maropu commented on a change in pull request #26205: [SPARK-29545][SQL] Add 
support for bit_xor aggregate function
URL: https://github.com/apache/spark/pull/26205#discussion_r338569674
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/bitwiseAggregates.scala
 ##########
 @@ -97,3 +97,42 @@ case class BitOrAgg(child: Expression) extends 
DeclarativeAggregate with Expects
 
   override lazy val evaluateExpression: AttributeReference = bitOr
 }
+
+@ExpressionDescription(
+  usage = "_FUNC_(expr) - Returns the bitwise XOR of all non-null input 
values, or null if none.",
+  examples = """
+    Examples:
+      > SELECT _FUNC_(col) FROM VALUES (3), (5) AS tab(col);
+       6
+  """,
+  since = "3.0.0")
+case class BitXorAgg(child: Expression) extends DeclarativeAggregate with 
ExpectsInputTypes {
 
 Review comment:
   I think you can make it much simpler like this;
   ```
   abstract class BitAggregate extends DeclarativeAggregate with 
ExpectsInputTypes {
   
     ...
     override lazy val updateExpressions: Seq[Expression] =
       If(IsNull(bitAgg),
         child,
         If(IsNull(child), bitAgg, bitOp(bitAgg, child))) :: Nil
   
     override lazy val mergeExpressions: Seq[Expression] =
       If(IsNull(bitAgg.left),
         bitAgg.right,
         If(IsNull(bitAgg.right), bitAgg.left, bitOp(bitAgg.left, 
bitAgg.right))) :: Nil
   }
   
   case class BitAndAgg(child: Expression) extends BitAggregate {
   
     override def nodeName: String = "bit_and"
     override def bitOp(left: Expression, right: Expression): BinaryArithmetic =
       BitwiseAnd(left, right)
   }
   ```

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to