Skip to content

Instantly share code, notes, and snippets.

@cosmic-cortex
Last active May 5, 2020 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosmic-cortex/12d21df7a42f378a2ce2ae9bb9711502 to your computer and use it in GitHub Desktop.
Save cosmic-cortex/12d21df7a42f378a2ce2ae9bb9711502 to your computer and use it in GitHub Desktop.
def _pad_table(table: Set[Record], with_cols: List):
padding_row = {col: None for col in with_cols}
padded_table = {Record({**row, **padding_row}) for row in table}
return padded_table
def union(left: Set[Record], right: Set[Record]) -> Set[Record]:
# padding
left_cols = _columns_in_table(left)
right_cols = _columns_in_table(right)
left = _pad_table(left, right_cols.difference(left_cols))
right = _pad_table(right, left_cols.difference(right_cols))
table_out = left.union(right)
return table_out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment