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

   Write to Files
   ```
   ((appsuccess, possuccess, refundsuccess)
           | "merge success" >> beam.Flatten()
           | "write orders to cloud storage" >> WriteToFiles(
               path=options.outputpath,
               destination=get_destination,
               sink=JsonSink(),
               file_naming=success_file_naming(),
               max_writers_per_bundle=300,
               temp_directory=options.temppath,
       ))
   ```
   
   JsonSink
   ```
   @beam.typehints.with_input_types(dict)
   class JsonSink(FileSink):
       def open(self, fh):
           self._fh = fh
   
       def write(self, record):
           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