awadhoot-sq commented on issue #29515:
URL: https://github.com/apache/beam/issues/29515#issuecomment-1822573334

   have implemented Group By as a step, am not seeing any missing records
   
   ```  
     ((appsuccess, possuccess, refundsuccess)
           | "merge success" >> beam.Flatten()
           | "group by org" >> beam.GroupBy(get_destination)
           | "write orders to cloud storage" >> WriteToFiles(
               path=options.outputpath,
               destination=lambda x: x[0],
               sink=GroupedJsonSink(),
               file_naming=success_file_naming(),
               max_writers_per_bundle=100,
       ))
   ```
   modified Json Sink
   
   ```
   @beam.typehints.with_input_types(dict)
   class GroupedJsonSink(FileSink):
       def open(self, fh):
           self._fh = fh
   
       def write(self, records):
           for record in records[1]:
               string = json.dumps(record, default=str)
               self._fh.write(string.encode("utf8"))
               self._fh.write(b"\n")
   
       def flush(self):
           self._fh.flush()
   ```
   
   


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