nickcaballero opened a new issue, #24868:
URL: https://github.com/apache/beam/issues/24868

   ### What happened?
   
   When using a side input like the one documented 
[here](https://beam.apache.org/documentation/patterns/side-inputs/#slowly-updating-global-window-side-inputs),
 using `org.apache.beam.sdk.transforms.View.AsSingleton#withDefaultValue` to 
configure a default value doesn't seem to work.
   
   - Is a default value supported when using the global window?
   
   Example:
   
   ```
   
   public class SideInputDefaultTest {
   
       @Test
       public void test() {
           final DirectOptions options = 
PipelineOptionsFactory.as(DirectOptions.class);
           options.setBlockOnRun(true);
           final Pipeline pipeline = Pipeline.create(options);
   
           final Duration sideInputWindowSize = Duration.standardSeconds(10);
           final PCollectionView<String> sideInput =
                   pipeline.apply(GenerateSequence.from(1).withRate(1, 
sideInputWindowSize))
                           
.apply(Window.into(FixedWindows.of(sideInputWindowSize)))
                           
.apply(Combine.globally(Max.ofLongs()).withoutDefaults())
                           .apply(ParDo.of(new AlwaysNull()))
                           .apply(Window.<String>into(new GlobalWindows())
                                          
.triggering(Repeatedly.forever(AfterPane.elementCountAtLeast(1)))
                                          .discardingFiredPanes())
                           
.apply(View.<String>asSingleton().withDefaultValue("0"));
   
           final Instant start = Instant.now();
           final Duration windowSize = Duration.standardSeconds(5);
           pipeline.apply(TestStream.create(StringUtf8Coder.of())
                                  .addElements(TimestampedValue.of("a", start))
                                  .addElements(TimestampedValue.of("b", 
start.plus(windowSize)))
                                  .advanceWatermarkToInfinity())
                   .apply(Window.into(FixedWindows.of(windowSize)))
                   .apply(ParDo.of(new 
ConcatFn(sideInput)).withSideInputs(sideInput));
   
           pipeline.run();
       }
   
       private static class ConcatFn extends DoFn<String, String> {
   
           private final PCollectionView<String> sideInput;
   
           public ConcatFn(final PCollectionView<String> sideInput) {
               this.sideInput = sideInput;
           }
   
           @ProcessElement
           public void process(final ProcessContext context, final 
OutputReceiver<String> receiver) {
               receiver.output(context.element() + " " + 
context.sideInput(sideInput));
           }
       }
   
       private static class AlwaysNull extends DoFn<Long, String> {
   
           @ProcessElement
           public void process() {
               // do nothing to force the default
           }
       }
   }
   ```
   
   ### Issue Priority
   
   Priority: 2 (default / most bugs should be filed as P2)
   
   ### Issue Components
   
   - [ ] Component: Python SDK
   - [X] Component: Java SDK
   - [ ] Component: Go SDK
   - [ ] Component: Typescript SDK
   - [ ] Component: IO connector
   - [ ] Component: Beam examples
   - [ ] Component: Beam playground
   - [ ] Component: Beam katas
   - [ ] Component: Website
   - [ ] Component: Spark Runner
   - [ ] Component: Flink Runner
   - [ ] Component: Samza Runner
   - [ ] Component: Twister2 Runner
   - [ ] Component: Hazelcast Jet Runner
   - [ ] Component: Google Cloud Dataflow Runner


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