Skip to content

Commit 9fd440e

Browse files
authored
Deprecate for 0.8.0 release (apache#1269)
* remove deprecated functions * remove deprecated properties * fix tests based on deprecated properties * update readme * get_first_property_value * deprecate properties
1 parent 3bdd458 commit 9fd440e

File tree

9 files changed

+15
-191
lines changed

9 files changed

+15
-191
lines changed

mkdocs/docs/configuration.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ catalog:
340340

341341
<!-- prettier-ignore-start -->
342342

343-
!!! warning "Deprecated Properties"
344-
`profile_name`, `region_name`, `botocore_session`, `aws_access_key_id`, `aws_secret_access_key`, `aws_session_token` are deprecated and will be removed in 0.8.0:
343+
!!! warning "Removed Properties"
344+
The properties `profile_name`, `region_name`, `botocore_session`, `aws_access_key_id`, `aws_secret_access_key`, and `aws_session_token` were deprecated and removed in 0.8.0
345345

346346
<!-- prettier-ignore-end -->
347347

@@ -396,8 +396,8 @@ catalog:
396396

397397
<!-- prettier-ignore-start -->
398398

399-
!!! warning "Deprecated Properties"
400-
`profile_name`, `region_name`, `botocore_session`, `aws_access_key_id`, `aws_secret_access_key`, `aws_session_token` are deprecated and will be removed in 0.8.0:
399+
!!! warning "Removed Properties"
400+
The properties `profile_name`, `region_name`, `botocore_session`, `aws_access_key_id`, `aws_secret_access_key`, and `aws_session_token` were deprecated and removed in 0.8.0
401401

402402
<!-- prettier-ignore-end -->
403403

pyiceberg/catalog/__init__.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,6 @@
106106
re.X,
107107
)
108108

109-
DEPRECATED_PROFILE_NAME = "profile_name"
110-
DEPRECATED_REGION = "region_name"
111-
DEPRECATED_BOTOCORE_SESSION = "botocore_session"
112-
DEPRECATED_ACCESS_KEY_ID = "aws_access_key_id"
113-
DEPRECATED_SECRET_ACCESS_KEY = "aws_secret_access_key"
114-
DEPRECATED_SESSION_TOKEN = "aws_session_token"
115-
DEPRECATED_PROPERTY_NAMES = {
116-
DEPRECATED_PROFILE_NAME,
117-
DEPRECATED_REGION,
118-
DEPRECATED_BOTOCORE_SESSION,
119-
DEPRECATED_ACCESS_KEY_ID,
120-
DEPRECATED_SECRET_ACCESS_KEY,
121-
DEPRECATED_SESSION_TOKEN,
122-
}
123-
124109

125110
class CatalogType(Enum):
126111
REST = "rest"
@@ -794,14 +779,6 @@ class MetastoreCatalog(Catalog, ABC):
794779
def __init__(self, name: str, **properties: str):
795780
super().__init__(name, **properties)
796781

797-
for property_name in DEPRECATED_PROPERTY_NAMES:
798-
if self.properties.get(property_name):
799-
deprecation_message(
800-
deprecated_in="0.7.0",
801-
removed_in="0.8.0",
802-
help_message=f"The property {property_name} is deprecated. Please use properties that start with client., glue., and dynamo. instead",
803-
)
804-
805782
def create_table_transaction(
806783
self,
807784
identifier: Union[str, Identifier],

pyiceberg/catalog/dynamodb.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@
3030
import boto3
3131

3232
from pyiceberg.catalog import (
33-
DEPRECATED_ACCESS_KEY_ID,
34-
DEPRECATED_BOTOCORE_SESSION,
35-
DEPRECATED_PROFILE_NAME,
36-
DEPRECATED_REGION,
37-
DEPRECATED_SECRET_ACCESS_KEY,
38-
DEPRECATED_SESSION_TOKEN,
3933
ICEBERG,
4034
METADATA_LOCATION,
4135
PREVIOUS_METADATA_LOCATION,
@@ -102,18 +96,11 @@ def __init__(self, name: str, **properties: str):
10296
super().__init__(name, **properties)
10397

10498
session = boto3.Session(
105-
profile_name=get_first_property_value(properties, DYNAMODB_PROFILE_NAME, DEPRECATED_PROFILE_NAME),
106-
region_name=get_first_property_value(properties, DYNAMODB_REGION, AWS_REGION, DEPRECATED_REGION),
107-
botocore_session=properties.get(DEPRECATED_BOTOCORE_SESSION),
108-
aws_access_key_id=get_first_property_value(
109-
properties, DYNAMODB_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID, DEPRECATED_ACCESS_KEY_ID
110-
),
111-
aws_secret_access_key=get_first_property_value(
112-
properties, DYNAMODB_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY, DEPRECATED_SECRET_ACCESS_KEY
113-
),
114-
aws_session_token=get_first_property_value(
115-
properties, DYNAMODB_SESSION_TOKEN, AWS_SESSION_TOKEN, DEPRECATED_SESSION_TOKEN
116-
),
99+
profile_name=properties.get(DYNAMODB_PROFILE_NAME),
100+
region_name=get_first_property_value(properties, DYNAMODB_REGION, AWS_REGION),
101+
aws_access_key_id=get_first_property_value(properties, DYNAMODB_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID),
102+
aws_secret_access_key=get_first_property_value(properties, DYNAMODB_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY),
103+
aws_session_token=get_first_property_value(properties, DYNAMODB_SESSION_TOKEN, AWS_SESSION_TOKEN),
117104
)
118105
self.dynamodb = session.client(DYNAMODB_CLIENT)
119106
self.dynamodb_table_name = self.properties.get(DYNAMODB_TABLE_NAME, DYNAMODB_TABLE_NAME_DEFAULT)

pyiceberg/catalog/glue.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@
4040
)
4141

4242
from pyiceberg.catalog import (
43-
DEPRECATED_ACCESS_KEY_ID,
44-
DEPRECATED_BOTOCORE_SESSION,
45-
DEPRECATED_PROFILE_NAME,
46-
DEPRECATED_REGION,
47-
DEPRECATED_SECRET_ACCESS_KEY,
48-
DEPRECATED_SESSION_TOKEN,
4943
EXTERNAL_TABLE,
5044
ICEBERG,
5145
LOCATION,
@@ -303,18 +297,11 @@ def __init__(self, name: str, **properties: Any):
303297
super().__init__(name, **properties)
304298

305299
session = boto3.Session(
306-
profile_name=get_first_property_value(properties, GLUE_PROFILE_NAME, DEPRECATED_PROFILE_NAME),
307-
region_name=get_first_property_value(properties, GLUE_REGION, AWS_REGION, DEPRECATED_REGION),
308-
botocore_session=properties.get(DEPRECATED_BOTOCORE_SESSION),
309-
aws_access_key_id=get_first_property_value(
310-
properties, GLUE_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID, DEPRECATED_ACCESS_KEY_ID
311-
),
312-
aws_secret_access_key=get_first_property_value(
313-
properties, GLUE_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY, DEPRECATED_SECRET_ACCESS_KEY
314-
),
315-
aws_session_token=get_first_property_value(
316-
properties, GLUE_SESSION_TOKEN, AWS_SESSION_TOKEN, DEPRECATED_SESSION_TOKEN
317-
),
300+
profile_name=properties.get(GLUE_PROFILE_NAME),
301+
region_name=get_first_property_value(properties, GLUE_REGION, AWS_REGION),
302+
aws_access_key_id=get_first_property_value(properties, GLUE_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID),
303+
aws_secret_access_key=get_first_property_value(properties, GLUE_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY),
304+
aws_session_token=get_first_property_value(properties, GLUE_SESSION_TOKEN, AWS_SESSION_TOKEN),
318305
)
319306
self.glue: GlueClient = session.client("glue", endpoint_url=properties.get(GLUE_CATALOG_ENDPOINT))
320307

pyiceberg/io/pyarrow.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,23 +1688,6 @@ def project_batches(
16881688
total_row_count += len(batch)
16891689

16901690

1691-
@deprecated(
1692-
deprecated_in="0.7.0",
1693-
removed_in="0.8.0",
1694-
help_message="The public API for 'to_requested_schema' is deprecated and is replaced by '_to_requested_schema'",
1695-
)
1696-
def to_requested_schema(requested_schema: Schema, file_schema: Schema, table: pa.Table) -> pa.Table:
1697-
struct_array = visit_with_partner(requested_schema, table, ArrowProjectionVisitor(file_schema), ArrowAccessor(file_schema))
1698-
1699-
arrays = []
1700-
fields = []
1701-
for pos, field in enumerate(requested_schema.fields):
1702-
array = struct_array.field(pos)
1703-
arrays.append(array)
1704-
fields.append(pa.field(field.name, array.type, field.optional))
1705-
return pa.Table.from_arrays(arrays, schema=pa.schema(fields))
1706-
1707-
17081691
def _to_requested_schema(
17091692
requested_schema: Schema,
17101693
file_schema: Schema,

pyiceberg/table/__init__.py

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
from pyiceberg.table.update import (
9090
AddPartitionSpecUpdate,
9191
AddSchemaUpdate,
92-
AddSnapshotUpdate,
9392
AddSortOrderUpdate,
9493
AssertCreate,
9594
AssertRefSnapshotId,
@@ -314,55 +313,6 @@ def set_properties(self, properties: Properties = EMPTY_DICT, **kwargs: Any) ->
314313
updates = properties or kwargs
315314
return self._apply((SetPropertiesUpdate(updates=updates),))
316315

317-
@deprecated(
318-
deprecated_in="0.7.0",
319-
removed_in="0.8.0",
320-
help_message="Please use one of the functions in ManageSnapshots instead",
321-
)
322-
def add_snapshot(self, snapshot: Snapshot) -> Transaction:
323-
"""Add a new snapshot to the table.
324-
325-
Returns:
326-
The transaction with the add-snapshot staged.
327-
"""
328-
updates = (AddSnapshotUpdate(snapshot=snapshot),)
329-
330-
return self._apply(updates, ())
331-
332-
@deprecated(
333-
deprecated_in="0.7.0",
334-
removed_in="0.8.0",
335-
help_message="Please use one of the functions in ManageSnapshots instead",
336-
)
337-
def set_ref_snapshot(
338-
self,
339-
snapshot_id: int,
340-
parent_snapshot_id: Optional[int],
341-
ref_name: str,
342-
type: str,
343-
max_ref_age_ms: Optional[int] = None,
344-
max_snapshot_age_ms: Optional[int] = None,
345-
min_snapshots_to_keep: Optional[int] = None,
346-
) -> Transaction:
347-
"""Update a ref to a snapshot.
348-
349-
Returns:
350-
The transaction with the set-snapshot-ref staged
351-
"""
352-
updates = (
353-
SetSnapshotRefUpdate(
354-
snapshot_id=snapshot_id,
355-
ref_name=ref_name,
356-
type=type,
357-
max_ref_age_ms=max_ref_age_ms,
358-
max_snapshot_age_ms=max_snapshot_age_ms,
359-
min_snapshots_to_keep=min_snapshots_to_keep,
360-
),
361-
)
362-
363-
requirements = (AssertRefSnapshotId(snapshot_id=parent_snapshot_id, ref="main"),)
364-
return self._apply(updates, requirements)
365-
366316
def _set_ref_snapshot(
367317
self,
368318
snapshot_id: int,

tests/catalog/test_dynamodb.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
from pyiceberg.typedef import Properties
4646
from tests.conftest import (
4747
BUCKET_NAME,
48-
DEPRECATED_AWS_SESSION_PROPERTIES,
4948
TABLE_METADATA_LOCATION_REGEX,
5049
UNIFIED_AWS_SESSION_PROPERTIES,
5150
)
@@ -563,28 +562,6 @@ def test_update_namespace_properties_overlap_update_removal(_bucket_initialize:
563562
assert test_catalog.load_namespace_properties(database_name) == test_properties
564563

565564

566-
def test_passing_provided_profile() -> None:
567-
catalog_name = "test_ddb_catalog"
568-
session_props = {
569-
"aws_access_key_id": "abc",
570-
"aws_secret_access_key": "def",
571-
"aws_session_token": "ghi",
572-
"region_name": "eu-central-1",
573-
"botocore_session": None,
574-
"profile_name": None,
575-
}
576-
props = {"py-io-impl": "pyiceberg.io.fsspec.FsspecFileIO"}
577-
props.update(session_props) # type: ignore
578-
with mock.patch("boto3.Session", return_value=mock.Mock()) as mock_session:
579-
mock_client = mock.Mock()
580-
mock_session.return_value.client.return_value = mock_client
581-
mock_client.describe_table.return_value = {"Table": {"TableStatus": "ACTIVE"}}
582-
test_catalog = DynamoDbCatalog(catalog_name, **props)
583-
assert test_catalog.dynamodb is mock_client
584-
mock_session.assert_called_with(**session_props)
585-
assert test_catalog.dynamodb is mock_session().client()
586-
587-
588565
@mock_aws
589566
def test_passing_glue_session_properties() -> None:
590567
session_properties: Properties = {
@@ -594,7 +571,6 @@ def test_passing_glue_session_properties() -> None:
594571
"dynamodb.region": "dynamodb.region",
595572
"dynamodb.session-token": "dynamodb.session-token",
596573
**UNIFIED_AWS_SESSION_PROPERTIES,
597-
**DEPRECATED_AWS_SESSION_PROPERTIES,
598574
}
599575

600576
with mock.patch("boto3.Session") as mock_session:
@@ -609,7 +585,6 @@ def test_passing_glue_session_properties() -> None:
609585
aws_session_token="dynamodb.session-token",
610586
region_name="dynamodb.region",
611587
profile_name="dynamodb.profile-name",
612-
botocore_session=None,
613588
)
614589
assert test_catalog.dynamodb is mock_session().client()
615590

@@ -619,7 +594,6 @@ def test_passing_unified_session_properties_to_dynamodb() -> None:
619594
session_properties: Properties = {
620595
"dynamodb.profile-name": "dynamodb.profile-name",
621596
**UNIFIED_AWS_SESSION_PROPERTIES,
622-
**DEPRECATED_AWS_SESSION_PROPERTIES,
623597
}
624598

625599
with mock.patch("boto3.Session") as mock_session:
@@ -634,7 +608,6 @@ def test_passing_unified_session_properties_to_dynamodb() -> None:
634608
aws_session_token="client.session-token",
635609
region_name="client.region",
636610
profile_name="dynamodb.profile-name",
637-
botocore_session=None,
638611
)
639612
assert test_catalog.dynamodb is mock_session().client()
640613

tests/catalog/test_glue.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
from typing import Any, Dict, List
17+
from typing import List
1818
from unittest import mock
1919

2020
import boto3
@@ -40,7 +40,6 @@
4040
from pyiceberg.types import IntegerType
4141
from tests.conftest import (
4242
BUCKET_NAME,
43-
DEPRECATED_AWS_SESSION_PROPERTIES,
4443
TABLE_METADATA_LOCATION_REGEX,
4544
UNIFIED_AWS_SESSION_PROPERTIES,
4645
)
@@ -638,26 +637,6 @@ def test_update_namespace_properties_overlap_update_removal(
638637
assert test_catalog.load_namespace_properties(database_name) == test_properties
639638

640639

641-
@mock_aws
642-
def test_passing_profile_name() -> None:
643-
session_properties: Dict[str, Any] = {
644-
"aws_access_key_id": "abc",
645-
"aws_secret_access_key": "def",
646-
"aws_session_token": "ghi",
647-
"region_name": "eu-central-1",
648-
"profile_name": "sandbox",
649-
"botocore_session": None,
650-
}
651-
test_properties = {"type": "glue"}
652-
test_properties.update(session_properties)
653-
654-
with mock.patch("boto3.Session") as mock_session:
655-
test_catalog = GlueCatalog("glue", **test_properties)
656-
657-
mock_session.assert_called_with(**session_properties)
658-
assert test_catalog.glue is mock_session().client()
659-
660-
661640
@mock_aws
662641
def test_passing_glue_session_properties() -> None:
663642
session_properties: Properties = {
@@ -667,7 +646,6 @@ def test_passing_glue_session_properties() -> None:
667646
"glue.region": "glue.region",
668647
"glue.session-token": "glue.session-token",
669648
**UNIFIED_AWS_SESSION_PROPERTIES,
670-
**DEPRECATED_AWS_SESSION_PROPERTIES,
671649
}
672650

673651
with mock.patch("boto3.Session") as mock_session:
@@ -679,7 +657,6 @@ def test_passing_glue_session_properties() -> None:
679657
aws_session_token="glue.session-token",
680658
region_name="glue.region",
681659
profile_name="glue.profile-name",
682-
botocore_session=None,
683660
)
684661
assert test_catalog.glue is mock_session().client()
685662

@@ -689,7 +666,6 @@ def test_passing_unified_session_properties_to_glue() -> None:
689666
session_properties: Properties = {
690667
"glue.profile-name": "glue.profile-name",
691668
**UNIFIED_AWS_SESSION_PROPERTIES,
692-
**DEPRECATED_AWS_SESSION_PROPERTIES,
693669
}
694670

695671
with mock.patch("boto3.Session") as mock_session:
@@ -701,7 +677,6 @@ def test_passing_unified_session_properties_to_glue() -> None:
701677
aws_session_token="client.session-token",
702678
region_name="client.region",
703679
profile_name="glue.profile-name",
704-
botocore_session=None,
705680
)
706681
assert test_catalog.glue is mock_session().client()
707682

tests/conftest.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,14 +2029,6 @@ def hierarchical_namespace_list(hierarchical_namespace_name: str) -> List[str]:
20292029
re.X,
20302030
)
20312031

2032-
DEPRECATED_AWS_SESSION_PROPERTIES = {
2033-
"aws_access_key_id": "aws_access_key_id",
2034-
"aws_secret_access_key": "aws_secret_access_key",
2035-
"aws_session_token": "aws_session_token",
2036-
"region_name": "region_name",
2037-
"profile_name": "profile_name",
2038-
}
2039-
20402032
UNIFIED_AWS_SESSION_PROPERTIES = {
20412033
"client.access-key-id": "client.access-key-id",
20422034
"client.secret-access-key": "client.secret-access-key",

0 commit comments

Comments
 (0)