-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ingestion/glue): delta schemas (#10299)
Co-authored-by: Mayuri Nehate <33225191+mayurinehate@users.noreply.github.com>
- Loading branch information
1 parent
ad41d20
commit 0059960
Showing
9 changed files
with
1,973 additions
and
440 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import Any | ||
|
||
|
||
def delta_type_to_hive_type(field_type: Any) -> str: | ||
if isinstance(field_type, str): | ||
""" | ||
return the field type | ||
""" | ||
return field_type | ||
else: | ||
if field_type.get("type") == "array": | ||
""" | ||
if array is of complex type, recursively parse the | ||
fields and create the native datatype | ||
""" | ||
return ( | ||
"array<" + delta_type_to_hive_type(field_type.get("elementType")) + ">" | ||
) | ||
elif field_type.get("type") == "struct": | ||
parsed_struct = "" | ||
for field in field_type.get("fields"): | ||
""" | ||
if field is of complex type, recursively parse | ||
and create the native datatype | ||
""" | ||
parsed_struct += ( | ||
"{}:{}".format( | ||
field.get("name"), | ||
delta_type_to_hive_type(field.get("type")), | ||
) | ||
+ "," | ||
) | ||
return "struct<" + parsed_struct.rstrip(",") + ">" | ||
return "" |
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
Oops, something went wrong.