Hi, I tried running some experiments on Interactive Runner before actually running the pipeline on dataflow. Below is what I did though not sure if this is the correct way to do it:-
Let's say I want to check whether the Pcoll named is_empty_check is empty or not and based on which I take a decision. is_empty_check = (dupe_records | "CountGlobally" >> Count.Globally() ) if is_empty_check != 0: ib.show(is_empty_check) else: print("Empty") In the above code it works fine when the Pcoll is not empty in which case it executes the statement under if part. But when the Pcoll is empty it does not execute the else part and instead executes the if part i.e. prints 0. Thanks & Regards Rajnil Guha On Mon, Jul 19, 2021 at 12:32 AM Reuven Lax <re...@google.com> wrote: > You could count the collection (with default value of zero). > > On Sun, Jul 18, 2021, 11:42 AM Rajnil Guha <rajnil94.g...@gmail.com> > wrote: > >> Hi Reuven, >> >> Yes, for now this is a bounded PCollection. >> >> Thanks & Regards >> Rajnil Guha >> >> On Mon, Jul 19, 2021 at 12:02 AM Reuven Lax <re...@google.com> wrote: >> >>> Is this a bounded collection? >>> >>> On Sun, Jul 18, 2021, 11:17 AM Rajnil Guha <rajnil94.g...@gmail.com> >>> wrote: >>> >>>> Hi Beam Users, >>>> >>>> I have a use-case where I need to check whether a Pcollection is empty >>>> or not. If it's not empty I need to write a message to a Pub/Sub topic. I >>>> am using the Python SDK and Dataflow to write and run my pipelines >>>> respectively. I searched but could not come across any concrete way on how >>>> to check whether a Pcollection is empty or not using Python and how to take >>>> action based on the check. Is there any way to implement this using Beam. >>>> >>>> Thanks & Regards >>>> Rajnil Guha >>>> >>>