Skip to content

Commit ddf6119

Browse files
committed
Merge branch 'main' of github.com:apache/iceberg-python into fd-add-ability-to-delete-full-data-files
2 parents 4ceacb8 + e08cc9d commit ddf6119

File tree

9 files changed

+930
-452
lines changed

9 files changed

+930
-452
lines changed

mkdocs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ mkdocstrings-python==1.10.3
2323
mkdocs-literate-nav==0.6.1
2424
mkdocs-autorefs==1.0.1
2525
mkdocs-gen-files==0.5.0
26-
mkdocs-material==9.5.24
26+
mkdocs-material==9.5.25
2727
mkdocs-material-extensions==1.3.1
2828
mkdocs-section-index==0.3.9

poetry.lock

Lines changed: 150 additions & 150 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyiceberg/catalog/__init__.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ def identifier_to_tuple(identifier: Union[str, Identifier]) -> Identifier:
588588
If the identifier is a string, it is split into a tuple on '.'. If it is a tuple, it is used as-is.
589589
590590
Args:
591-
identifier (str | Identifier: an identifier, either a string or tuple of strings.
591+
identifier (str | Identifier): an identifier, either a string or tuple of strings.
592592
593593
Returns:
594594
Identifier: a tuple of strings.
@@ -619,6 +619,29 @@ def namespace_from(identifier: Union[str, Identifier]) -> Identifier:
619619
"""
620620
return Catalog.identifier_to_tuple(identifier)[:-1]
621621

622+
@staticmethod
623+
def namespace_to_string(
624+
identifier: Union[str, Identifier], err: Union[Type[ValueError], Type[NoSuchNamespaceError]] = ValueError
625+
) -> str:
626+
"""Transform a namespace identifier into a string.
627+
628+
Args:
629+
identifier (Union[str, Identifier]): a namespace identifier.
630+
err (Union[Type[ValueError], Type[NoSuchNamespaceError]]): the error type to raise when identifier is empty.
631+
632+
Returns:
633+
Identifier: Namespace identifier.
634+
"""
635+
tuple_identifier = Catalog.identifier_to_tuple(identifier)
636+
if len(tuple_identifier) < 1:
637+
raise err("Empty namespace identifier")
638+
639+
# Check if any segment of the tuple is an empty string
640+
if any(segment.strip() == "" for segment in tuple_identifier):
641+
raise err("Namespace identifier contains an empty segment or a segment with only whitespace")
642+
643+
return ".".join(segment.strip() for segment in tuple_identifier)
644+
622645
@staticmethod
623646
def identifier_to_database(
624647
identifier: Union[str, Identifier], err: Union[Type[ValueError], Type[NoSuchNamespaceError]] = ValueError

pyiceberg/catalog/sql.py

Lines changed: 95 additions & 64 deletions
Large diffs are not rendered by default.

pyiceberg/cli/console.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,13 @@ def list(ctx: Context, parent: Optional[str]) -> None: # pylint: disable=redefi
112112
"""List tables or namespaces."""
113113
catalog, output = _catalog_and_output(ctx)
114114

115-
identifiers = catalog.list_namespaces(parent or ())
116-
if not identifiers and parent:
115+
identifiers = []
116+
if parent:
117+
# Do we have tables under parent namespace?
117118
identifiers = catalog.list_tables(parent)
119+
if not identifiers:
120+
# List hierarchical namespaces if parent, root namespaces otherwise.
121+
identifiers = catalog.list_namespaces(parent or ())
118122
output.identifiers(identifiers)
119123

120124

pyiceberg/io/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@
5757
HDFS_PORT = "hdfs.port"
5858
HDFS_USER = "hdfs.user"
5959
HDFS_KERB_TICKET = "hdfs.kerberos_ticket"
60+
ADLFS_CONNECTION_STRING = "adlfs.connection-string"
61+
ADLFS_ACCOUNT_NAME = "adlfs.account-name"
62+
ADLFS_ACCOUNT_KEY = "adlfs.account-key"
63+
ADLFS_SAS_TOKEN = "adlfs.sas-token"
64+
ADLFS_TENANT_ID = "adlfs.tenant-id"
65+
ADLFS_CLIENT_ID = "adlfs.client-id"
66+
ADLFS_ClIENT_SECRET = "adlfs.client-secret"
6067
GCS_TOKEN = "gcs.oauth2.token"
6168
GCS_TOKEN_EXPIRES_AT_MS = "gcs.oauth2.token-expires-at"
6269
GCS_PROJECT_ID = "gcs.project-id"

pyiceberg/io/fsspec.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
from pyiceberg.catalog import TOKEN
4141
from pyiceberg.exceptions import SignError
4242
from pyiceberg.io import (
43+
ADLFS_ACCOUNT_KEY,
44+
ADLFS_ACCOUNT_NAME,
45+
ADLFS_CLIENT_ID,
46+
ADLFS_CONNECTION_STRING,
47+
ADLFS_SAS_TOKEN,
48+
ADLFS_TENANT_ID,
4349
GCS_ACCESS,
4450
GCS_CACHE_TIMEOUT,
4551
GCS_CONSISTENCY,
@@ -57,6 +63,7 @@
5763
S3_REGION,
5864
S3_SECRET_ACCESS_KEY,
5965
S3_SESSION_TOKEN,
66+
ADLFS_ClIENT_SECRET,
6067
FileIO,
6168
InputFile,
6269
InputStream,
@@ -163,13 +170,13 @@ def _adlfs(properties: Properties) -> AbstractFileSystem:
163170
from adlfs import AzureBlobFileSystem
164171

165172
return AzureBlobFileSystem(
166-
connection_string=properties.get("adlfs.connection-string"),
167-
account_name=properties.get("adlfs.account-name"),
168-
account_key=properties.get("adlfs.account-key"),
169-
sas_token=properties.get("adlfs.sas-token"),
170-
tenant_id=properties.get("adlfs.tenant-id"),
171-
client_id=properties.get("adlfs.client-id"),
172-
client_secret=properties.get("adlfs.client-secret"),
173+
connection_string=properties.get(ADLFS_CONNECTION_STRING),
174+
account_name=properties.get(ADLFS_ACCOUNT_NAME),
175+
account_key=properties.get(ADLFS_ACCOUNT_KEY),
176+
sas_token=properties.get(ADLFS_SAS_TOKEN),
177+
tenant_id=properties.get(ADLFS_TENANT_ID),
178+
client_id=properties.get(ADLFS_CLIENT_ID),
179+
client_secret=properties.get(ADLFS_ClIENT_SECRET),
173180
)
174181

175182

0 commit comments

Comments
 (0)