This is an automated email from the ASF dual-hosted git repository.
kevinjqliu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git
The following commit(s) were added to refs/heads/main by this push:
new cbbffc5d maint: use `URI` constant instead of 'uri' strings (#2094)
cbbffc5d is described below
commit cbbffc5df22385c37419168efcdc2af110ac4c95
Author: Jayce Slesar <[email protected]>
AuthorDate: Sun Jun 15 16:58:48 2025 -0400
maint: use `URI` constant instead of 'uri' strings (#2094)
---
pyiceberg/catalog/__init__.py | 2 +-
pyiceberg/catalog/hive.py | 5 +++--
pyiceberg/catalog/memory.py | 5 +++--
pyiceberg/catalog/sql.py | 3 ++-
pyiceberg/cli/console.py | 4 ++--
pyiceberg/io/fsspec.py | 4 ++--
6 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/pyiceberg/catalog/__init__.py b/pyiceberg/catalog/__init__.py
index 81d3a34e..4da11643 100644
--- a/pyiceberg/catalog/__init__.py
+++ b/pyiceberg/catalog/__init__.py
@@ -195,7 +195,7 @@ def infer_catalog_type(name: str, catalog_properties:
RecursiveDict) -> Optional
Raises:
ValueError: Raises a ValueError in case properties are missing, or the
wrong type.
"""
- if uri := catalog_properties.get("uri"):
+ if uri := catalog_properties.get(URI):
if isinstance(uri, str):
if uri.startswith("http"):
return CatalogType.REST
diff --git a/pyiceberg/catalog/hive.py b/pyiceberg/catalog/hive.py
index 54e5100e..05dd408f 100644
--- a/pyiceberg/catalog/hive.py
+++ b/pyiceberg/catalog/hive.py
@@ -63,6 +63,7 @@ from pyiceberg.catalog import (
LOCATION,
METADATA_LOCATION,
TABLE_TYPE,
+ URI,
MetastoreCatalog,
PropertiesUpdateSummary,
)
@@ -307,7 +308,7 @@ class HiveCatalog(MetastoreCatalog):
@staticmethod
def _create_hive_client(properties: Dict[str, str]) -> _HiveClient:
last_exception = None
- for uri in properties["uri"].split(","):
+ for uri in properties[URI].split(","):
try:
return _HiveClient(
uri,
@@ -319,7 +320,7 @@ class HiveCatalog(MetastoreCatalog):
if last_exception is not None:
raise last_exception
else:
- raise ValueError(f"Unable to connect to hive using uri:
{properties['uri']}")
+ raise ValueError(f"Unable to connect to hive using uri:
{properties[URI]}")
def _convert_hive_into_iceberg(self, table: HiveTable) -> Table:
properties: Dict[str, str] = table.parameters
diff --git a/pyiceberg/catalog/memory.py b/pyiceberg/catalog/memory.py
index 7d6053ba..024d14fb 100644
--- a/pyiceberg/catalog/memory.py
+++ b/pyiceberg/catalog/memory.py
@@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.
+from pyiceberg.catalog import URI
from pyiceberg.catalog.sql import SqlCatalog
@@ -27,6 +28,6 @@ class InMemoryCatalog(SqlCatalog):
def __init__(self, name: str, warehouse: str =
"file:///tmp/iceberg/warehouse", **kwargs: str) -> None:
self._warehouse_location = warehouse
- if "uri" not in kwargs:
- kwargs["uri"] = "sqlite:///:memory:"
+ if URI not in kwargs:
+ kwargs[URI] = "sqlite:///:memory:"
super().__init__(name=name, warehouse=warehouse, **kwargs)
diff --git a/pyiceberg/catalog/sql.py b/pyiceberg/catalog/sql.py
index b4b06e3a..880a4db4 100644
--- a/pyiceberg/catalog/sql.py
+++ b/pyiceberg/catalog/sql.py
@@ -44,6 +44,7 @@ from sqlalchemy.orm import (
from pyiceberg.catalog import (
METADATA_LOCATION,
+ URI,
Catalog,
MetastoreCatalog,
PropertiesUpdateSummary,
@@ -119,7 +120,7 @@ class SqlCatalog(MetastoreCatalog):
def __init__(self, name: str, **properties: str):
super().__init__(name, **properties)
- if not (uri_prop := self.properties.get("uri")):
+ if not (uri_prop := self.properties.get(URI)):
raise NoSuchPropertyException("SQL connection URI is required")
echo_str = str(self.properties.get("echo", DEFAULT_ECHO_VALUE)).lower()
diff --git a/pyiceberg/cli/console.py b/pyiceberg/cli/console.py
index 25a536d2..6be4df12 100644
--- a/pyiceberg/cli/console.py
+++ b/pyiceberg/cli/console.py
@@ -29,7 +29,7 @@ import click
from click import Context
from pyiceberg import __version__
-from pyiceberg.catalog import Catalog, load_catalog
+from pyiceberg.catalog import URI, Catalog, load_catalog
from pyiceberg.cli.output import ConsoleOutput, JsonOutput, Output
from pyiceberg.exceptions import NoSuchNamespaceError,
NoSuchPropertyException, NoSuchTableError
from pyiceberg.table import TableProperties
@@ -75,7 +75,7 @@ def run(
if ugi:
properties["ugi"] = ugi
if uri:
- properties["uri"] = uri
+ properties[URI] = uri
if credential:
properties["credential"] = credential
diff --git a/pyiceberg/io/fsspec.py b/pyiceberg/io/fsspec.py
index cc80725d..6febff0a 100644
--- a/pyiceberg/io/fsspec.py
+++ b/pyiceberg/io/fsspec.py
@@ -36,7 +36,7 @@ from fsspec import AbstractFileSystem
from fsspec.implementations.local import LocalFileSystem
from requests import HTTPError
-from pyiceberg.catalog import TOKEN
+from pyiceberg.catalog import TOKEN, URI
from pyiceberg.exceptions import SignError
from pyiceberg.io import (
ADLS_ACCOUNT_HOST,
@@ -91,7 +91,7 @@ if TYPE_CHECKING:
def s3v4_rest_signer(properties: Properties, request: "AWSRequest", **_: Any)
-> "AWSRequest":
- signer_url = properties.get(S3_SIGNER_URI, properties["uri"]).rstrip("/")
# type: ignore
+ signer_url = properties.get(S3_SIGNER_URI, properties[URI]).rstrip("/") #
type: ignore
signer_endpoint = properties.get(S3_SIGNER_ENDPOINT,
S3_SIGNER_ENDPOINT_DEFAULT)
signer_headers = {}