Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. import apache_beam as beam
  2.  
  3. def join_dict(ident, source):
  4.     return {**ident, **source}
  5.  
  6.  
  7. with beam.Pipeline() as pipeline:
  8.   icon_pairs = (
  9.           pipeline | 'Create icons' >> beam.Create([
  10.       {'ident': 'uid2429', 'user_id': '7d1bb900-e491-11ea-8aa1-e86a64ff713e', 'is_exist': 1}])
  11.   | 'key_source' >> beam.Map(lambda dept: (dept['ident'], dept))
  12.   )
  13.  
  14.   duration_pairs = (pipeline | 'Create durations' >> beam.Create([
  15.       {'an': 'cleanmypc', 'ea': 'ea3', 'ec': 'ec4', 'ev': None, 'ident': 'uid2429'}])
  16.   | 'key_user' >> beam.Map(lambda dept: (dept['ident'], dept))
  17.                     )
  18.  
  19.   merge_pipeline = (duration_pairs
  20.                     | 'MergeDict' >> beam.Map(join_dict,  beam.pvalue.AsDict(icon_pairs))
  21.                     )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement