leanken commented on a change in pull request #29304:
URL: https://github.com/apache/spark/pull/29304#discussion_r464100593



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/BroadcastHashJoinExec.scala
##########
@@ -245,7 +244,7 @@ case class BroadcastHashJoinExec(
            |boolean $found = false;
            |// generate join key for stream side
            |${keyEv.code}
-           |if ($anyNull) {
+           |if (${if (isLongHashedRelation) s"$anyNull" else 
s"${keyEv.value}.allNull()"}) {

Review comment:
       > Oh you can combine multiple keys into a single long key ? I believe 
the reason for this special case with the long hashed relation is because the 
long hashed relation can only take a single long key. But it would be 
interesting if we can get multiple "multiple real keys packed into it".
   
   FYI, it is ok to pack multi key into a Long, as long as there are 
IntegralType and defaultSizeSum is less or equal than 8
   ```
   def rewriteKeyExpr(keys: Seq[Expression]): Seq[Expression] = {
       assert(keys.nonEmpty)
       // TODO: support BooleanType, DateType and TimestampType
       if (keys.exists(!_.dataType.isInstanceOf[IntegralType])
         || keys.map(_.dataType.defaultSize).sum > 8) {
         return keys
       }
   
       var keyExpr: Expression = if (keys.head.dataType != LongType) {
         Cast(keys.head, LongType)
       } else {
         keys.head
       }
       keys.tail.foreach { e =>
         val bits = e.dataType.defaultSize * 8
         keyExpr = BitwiseOr(ShiftLeft(keyExpr, Literal(bits)),
           BitwiseAnd(Cast(e, LongType), Literal((1L << bits) - 1)))
       }
       keyExpr :: Nil
     }
   ```




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