tvalentyn commented on code in PR #24435:
URL: https://github.com/apache/beam/pull/24435#discussion_r1037798432


##########
sdks/python/apache_beam/transforms/core.py:
##########
@@ -2475,7 +2475,7 @@ def typed(transform):
 
       def inject_default(_, combined):
         if combined:
-          assert len(combined) == 1
+          assert len(combined) >= 1

Review Comment:
   the intent of the `_inject_default` function is to add a default element in 
the combined result if the combined result is empty and a default value can be 
well-defined as `combine_fn.apply([], *args, **kwargs)`. 
   
   Users can disable default values if they use `.without_defaults()` value 
when they apply a combiner.  
   
   The replacement of the empty output with default value happens at the last 
step of combining. At this stage, PCollection being combined should be reduced 
to 1 element, or be empty. Default value is not necessary when the result of 
combining is NOT empty - in this case we should take the reduced result. 
However, since this is evaluated after prior combining, we expect that the 
result of prior combining is  a single value. Therefore, we have an assertion 
that checks that prior combining has reduced the pcollection to 1 element. If 
somehow we have more than 1 element, then the result may not be fully combined, 
so we should understand how that happened.



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

Reply via email to