I am trying to write all the elements of a Pub/Sub message (data,attributes,messageId and publish_time) to BigQuery using Apache Beam and wanted the data to be as:
data | attr | key | publishTime |
---|---|---|---|
data | attr | key | publishTime |
I am currently using the following piece of code to transform the message and wanted to save it in the table shown above:
( demo
| "Decoding Pub/Sub Message" + input_subscription >> beam.Map(lambda r : data_decoder.decode_base64(r))
| "Parsing Pub/Sub Message" + input_subscription >> beam.Map(lambda r : data_parser.parseJsonMessage(r))
| "Write to BigQuery Table" + input_subscription >> io.WriteToBigQuery('{0}:{1}'.format(project_name, dest_table_id),
schema=schema, write_disposition=io.BigQueryDisposition.WRITE_APPEND, create_disposition = io.BigQueryDisposition.CREATE_IF_NEEDED ))
I wanted to store data in encoded way, column named as data and value as (element.data) and the values for rest of the columns.
Thanks in advance!