-
-
Save cosmic-cortex/12d21df7a42f378a2ce2ae9bb9711502 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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