Last active
May 1, 2021 07:54
-
-
Save shreyasms17/41c2a61c7e8a6196965d23b39aaadfaa to your computer and use it in GitHub Desktop.
AutoFlatten is_leaf
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 is_leaf(self, data): | |
''' | |
Description: | |
This function checks if the particular field in the schema is a leaf or not. | |
Types not considered as a leaf : struct, array | |
:param data: [type: dict] a dictionary containing metadata about a field | |
:return leaf: [type: bool] indicates whether a given field is a leaf or not | |
''' | |
try: | |
if isinstance(data['type'], str): | |
leaf = True if data['type'] != 'struct' else False | |
else: | |
leaf = True if data['type']['type'] == 'map' else False | |
except: | |
leaf = False | |
finally: | |
return leaf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment