You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "Fokko (via GitHub)" <gi...@apache.org> on 2023/01/22 21:11:20 UTC

[GitHub] [iceberg] Fokko commented on a diff in pull request #6644: Python: Add support for static table

Fokko commented on code in PR #6644:
URL: https://github.com/apache/iceberg/pull/6644#discussion_r1083543881


##########
python/pyiceberg/table/__init__.py:
##########
@@ -167,6 +169,32 @@ def __eq__(self, other: Any) -> bool:
         )
 
 
+class StaticTable(Table):
+    """Load a table directly from a metadata file (i.e., without using a catalog)."""
+
+    def refresh(self) -> Table:
+        """StaticTable metadata cannot be refreshed."""
+        raise StaticTableImmutableError("StaticTable metadata cannot be refreshed.")
+
+    @classmethod
+    def from_metadata(cls, metadata_location: str, properties: Properties = EMPTY_DICT) -> StaticTable:
+
+        metadata = cls._load_metadata(metadata_location, properties)
+
+        return cls(
+            identifier=("static-table", metadata_location),
+            metadata_location=metadata_location,
+            metadata=metadata,
+            io=load_file_io({**properties, **metadata.properties}),
+        )
+
+    @staticmethod
+    def _load_metadata(metadata_location: str, properties: Properties) -> TableMetadata:

Review Comment:
   How do you feel about merging this logic into `from_metadata`? I t looks like we don't reuse this anywhere.



##########
python/pyiceberg/exceptions.py:
##########
@@ -90,3 +90,7 @@ class SignError(Exception):
 
 class ResolveError(Exception):
     pass
+
+
+class StaticTableImmutableError(Exception):

Review Comment:
   How do you feel like re-using the internal `NotImplementedError`?



##########
python/pyiceberg/catalog/rest.py:
##########
@@ -175,11 +175,7 @@ class RestCatalog(Catalog):
     session: Session
     properties: Properties
 
-    def __init__(
-        self,
-        name: str,
-        **properties: str,
-    ):
+    def __init__(self, name: str, **properties: str):

Review Comment:
   Why did this change? I always assumed that black was deterministic.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org