Fokko commented on code in PR #5447:
URL: https://github.com/apache/iceberg/pull/5447#discussion_r943386482
##########
python/pyiceberg/catalog/hive.py:
##########
@@ -201,17 +238,46 @@ def __init__(self, name: str, properties: Properties,
uri: str):
super().__init__(name, properties)
self._client = _HiveClient(uri)
- def _convert_hive_into_iceberg(self, table: HiveTable) -> Table:
- # Requires reading the manifest, will implement this in another PR
- # Check the table type
- return Table(identifier=(table.dbName, table.tableName))
+ def _convert_hive_into_iceberg(self, table: HiveTable, io: FileIO,
metadata_location: Optional[str] = None) -> Table:
+ properties: Dict[str, str] = table.parameters
+ if TABLE_TYPE not in properties:
+ raise NoSuchTableError(f"Property table_type missing, could not
determine type: {table.dbName}.{table.tableName}")
+
+ table_type = properties[TABLE_TYPE]
+ if table_type.lower() != ICEBERG:
+ raise NoSuchTableError(f"Property table_type is {table_type},
expected {ICEBERG}: {table.dbName}.{table.tableName}")
+
+ if not metadata_location:
+ if prop_metadata_location := properties.get(METADATA_LOCATION):
+ metadata_location = prop_metadata_location
+ else:
+ raise NoSuchTableError("Metadata location not found")
+
+ file = io.new_input(metadata_location)
+ metadata = FromInputFile.table_metadata(file)
+ return Table(identifier=(table.dbName, table.tableName),
metadata=metadata, metadata_location=metadata_location)
+
+ def _write_metadata(self, metadata: TableMetadataV2, io: FileIO,
metadata_path: str):
+ ToOutputFile.table_metadata(metadata, io.new_output(metadata_path))
+
+ def _resolve_table_location(self, location: Optional[str], database_name:
str, table_name: str):
+ if not location:
+ if warehouse_location := self.properties.get(WAREHOUSE):
+ warehouse_location = warehouse_location.rstrip("/")
+ return f"{warehouse_location}/{database_name}/{table_name}"
+
+ database_properties = self.load_namespace_properties(database_name)
Review Comment:
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]