Created
May 1, 2021 07:51
-
-
Save shreyasms17/0b8b83a01ae28741a18d638b414d08e7 to your computer and use it in GitHub Desktop.
AutoFlatten get_bottom_to_top
This file contains hidden or 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 get_bottom_to_top(self, order, all_cols_in_explode_cols): | |
''' | |
Description: | |
This function gets the mutually exclusive leaf fields in every array type column | |
:param order: [type: list] contains the fields in order in which array explode has to take place | |
:param all_cols_in_explode_cols: [type: set] contains all fields in array type fields | |
:return bottom_to_top: [type: dict] contains list of mutually exclusive leaf fields for every | |
array type / struct type (parent to array type) field | |
''' | |
bottom_to_top = {} | |
for column in reversed(order): | |
x_cols = set(filter(lambda x: x.startswith(column), list(all_cols_in_explode_cols))) | |
bottom_to_top[column] = list(x_cols) | |
all_cols_in_explode_cols = all_cols_in_explode_cols.difference(x_cols) | |
return bottom_to_top |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment