Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ingest): Glue mapping patch #2930

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions metadata-ingestion/src/datahub/ingestion/source/glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,15 +560,25 @@ def get_column_type(
"varchar": StringTypeClass,
}

field_starts_type_mapping = {
"array": ArrayTypeClass,
"set": ArrayTypeClass,
"map": MapTypeClass,
"struct": MapTypeClass,
"varchar": StringTypeClass,
"decimal": NumberTypeClass,
}

type_class = None
if field_type in field_type_mapping.keys():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: if you want to check if a key is in a dict, there's no need for .keys() – see https://stackoverflow.com/questions/1602934/check-if-a-given-key-already-exists-in-a-dictionary

type_class = field_type_mapping[field_type]
elif field_type.startswith("array"):
type_class = ArrayTypeClass
elif field_type.startswith("map") or field_type.startswith("struct"):
type_class = MapTypeClass
elif field_type.startswith("set"):
type_class = ArrayTypeClass
else:
for key in field_starts_type_mapping.keys():
if field_type.startswith(key):
type_class = field_starts_type_mapping[key]
break

if type_class is None:
glue_source.report.report_warning(
field_type,
f"The type '{field_type}' is not recognised for field '{field_name}' in table '{table_name}', setting as StringTypeClass.",
Expand Down