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



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashedRelation.scala
##########
@@ -327,11 +327,27 @@ private[joins] object UnsafeHashedRelation {
     // Create a mapping of buildKeys -> rows
     val keyGenerator = UnsafeProjection.create(key)
     var numFields = 0
+    val nullPaddingCombinations: Seq[UnsafeProjection] = if (isNullAware) {
+      // C(numKeys, 0), C(numKeys, 1) ... C(numKeys, numKeys - 1)
+      // In total 2^numKeys - 1 records will be appended.
+      key.indices.flatMap { n =>
+        key.indices.combinations(n).map { combination =>
+          // combination is Seq[Int] indicates which key should be replaced to 
null padding
+          val exprs = key.indices.map { index =>
+            if (combination.contains(index)) {
+              Literal.create(null, key(index).dataType)

Review comment:
       After serious consideration, I think when `key(index).nullable = false` 
case, it should be expand as well.
   Just consider the following case, with streamedSide and buildSide both has 
only one record
   (1, null, 3)   => (1, 2, 3)
   this was consider a MATCH on NAAJ, right? no matter buildSide column is 
nullable or not, NAAJ care about its real key value of the record. if we don't 
expand (1,2,3) to 7X record, we can't find a exact match of (1,null,3)
   
   @maropu @agrawaldevesh
   
   if we don't want extra if-else check on null column, it is needed to do such 
expansion, because I already put all possibilities in HashedRelation, 
streamedSide record just need to lookup, if you got a exact match, bingo.




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