Skip to content
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
19 changes: 7 additions & 12 deletions pyiceberg/catalog/glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,34 +355,29 @@ def __init__(self, name: str, client: Optional["GlueClient"] = None, **propertie
_register_glue_catalog_id_with_glue_client(self.glue, glue_catalog_id)

def _convert_glue_to_iceberg(self, glue_table: "TableTypeDef") -> Table:
properties: Properties = glue_table["Parameters"]

database_name = glue_table.get("DatabaseName", None)
if database_name is None:
if (database_name := glue_table.get("DatabaseName")) is None:
raise ValueError("Glue table is missing DatabaseName property")

parameters = glue_table.get("Parameters", None)
if parameters is None:
raise ValueError("Glue table is missing Parameters property")
if (table_name := glue_table.get("Name")) is None:
raise ValueError("Glue table is missing Name property")

table_name = glue_table["Name"]
if (parameters := glue_table.get("Parameters")) is None:
raise ValueError("Glue table is missing Parameters property")

if TABLE_TYPE not in properties:
if (glue_table_type := parameters.get(TABLE_TYPE)) is None:
raise NoSuchPropertyException(
f"Property {TABLE_TYPE} missing, could not determine type: {database_name}.{table_name}"
)
glue_table_type = properties[TABLE_TYPE]

if glue_table_type.lower() != ICEBERG:
raise NoSuchIcebergTableError(
f"Property table_type is {glue_table_type}, expected {ICEBERG}: {database_name}.{table_name}"
)

if METADATA_LOCATION not in properties:
if (metadata_location := parameters.get(METADATA_LOCATION)) is None:
raise NoSuchPropertyException(
f"Table property {METADATA_LOCATION} is missing, cannot find metadata for: {database_name}.{table_name}"
)
metadata_location = properties[METADATA_LOCATION]

io = self._load_file_io(location=metadata_location)
file = io.new_input(metadata_location)
Expand Down