Skip to content

Commit ca71815

Browse files
committed
refactor glue to iceberg conversion
1 parent 8817781 commit ca71815

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

pyiceberg/catalog/glue.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -355,34 +355,29 @@ def __init__(self, name: str, client: Optional["GlueClient"] = None, **propertie
355355
_register_glue_catalog_id_with_glue_client(self.glue, glue_catalog_id)
356356

357357
def _convert_glue_to_iceberg(self, glue_table: "TableTypeDef") -> Table:
358-
properties: Properties = glue_table["Parameters"]
359-
360-
database_name = glue_table.get("DatabaseName", None)
361-
if database_name is None:
358+
if (database_name := glue_table.get("DatabaseName")) is None:
362359
raise ValueError("Glue table is missing DatabaseName property")
363360

364-
parameters = glue_table.get("Parameters", None)
365-
if parameters is None:
366-
raise ValueError("Glue table is missing Parameters property")
361+
if (table_name := glue_table.get("Name")) is None:
362+
raise ValueError("Glue table is missing Name property")
367363

368-
table_name = glue_table["Name"]
364+
if (parameters := glue_table.get("Parameters")) is None:
365+
raise ValueError("Glue table is missing Parameters property")
369366

370-
if TABLE_TYPE not in properties:
367+
if (glue_table_type := parameters.get(TABLE_TYPE)) is None:
371368
raise NoSuchPropertyException(
372369
f"Property {TABLE_TYPE} missing, could not determine type: {database_name}.{table_name}"
373370
)
374-
glue_table_type = properties[TABLE_TYPE]
375371

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

381-
if METADATA_LOCATION not in properties:
377+
if (metadata_location := parameters.get(METADATA_LOCATION)) is None:
382378
raise NoSuchPropertyException(
383379
f"Table property {METADATA_LOCATION} is missing, cannot find metadata for: {database_name}.{table_name}"
384380
)
385-
metadata_location = properties[METADATA_LOCATION]
386381

387382
io = self._load_file_io(location=metadata_location)
388383
file = io.new_input(metadata_location)

0 commit comments

Comments
 (0)