mjsax commented on a change in pull request #9186:
URL: https://github.com/apache/kafka/pull/9186#discussion_r485096090



##########
File path: 
streams/src/main/java/org/apache/kafka/streams/kstream/internals/KStreamKTableJoinProcessor.java
##########
@@ -58,22 +58,23 @@ public void init(final ProcessorContext context) {
 
     @Override
     public void process(final K1 key, final V1 value) {
-        // we do join iff keys are equal, thus, if key is null we cannot join 
and just ignore the record
-        // If {@code keyMapper} returns {@code null} it implies there is no 
match,
+        // We allow null keys unless {@code keyMapper} returns {@code null} 
and we ignore it as invalid.
+        // This happens for GlobalKTables but never for KTables since 
keyMapper just returns the key.
+        // For non-null keys, if {@code keyMapper} returns {@code null} it 
implies there is no match,
         // so ignore unless it is a left join
         //
         // we also ignore the record if value is null, because in a key-value 
data model a null-value indicates
         // an empty message (ie, there is nothing to be joined) -- this 
contrast SQL NULL semantics
         // furthermore, on left/outer joins 'null' in ValueJoiner#apply() 
indicates a missing record --
         // thus, to be consistent and to avoid ambiguous null semantics, null 
values are ignored
-        if (key == null || value == null) {
+        final K2 mappedKey = keyMapper.apply(key, value);
+        if ((key == null && mappedKey == null) || (!leftJoin && mappedKey == 
null) || value == null) {

Review comment:
       This condition seems unnecessary complex. Should it not just be:
   ```
   if (mappedKey == null || value == null) {
   ```




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to