Skip to content

Commit 7e51a99

Browse files
committed
REST: Rename rest-scan-planning-enabled to scan-planning-mode
1 parent 0bdff48 commit 7e51a99

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

‎pyiceberg/catalog/rest/__init__.py‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ class IdentifierKind(Enum):
225225
VIEW = "view"
226226

227227

228+
class ScanPlanningMode(Enum):
229+
CLIENT = "client"
230+
SERVER = "server"
231+
232+
228233
ACCESS_DELEGATION_DEFAULT = "vended-credentials"
229234
AUTHORIZATION_HEADER = "Authorization"
230235
BEARER_PREFIX = "Bearer"
@@ -255,8 +260,8 @@ class IdentifierKind(Enum):
255260
SNAPSHOT_LOADING_MODE = "snapshot-loading-mode"
256261
AUTH = "auth"
257262
CUSTOM = "custom"
258-
REST_SCAN_PLANNING_ENABLED = "rest-scan-planning-enabled"
259-
REST_SCAN_PLANNING_ENABLED_DEFAULT = False
263+
SCAN_PLANNING_MODE = "scan-planning-mode"
264+
SCAN_PLANNING_MODE_DEFAULT = ScanPlanningMode.CLIENT.value
260265
# for backwards compatibility with older REST servers where it can be assumed that a particular
261266
# server supports view endpoints but doesn't send the "endpoints" field in the ConfigResponse
262267
VIEW_ENDPOINTS_SUPPORTED = "view-endpoints-supported"
@@ -480,9 +485,8 @@ def _load_file_io(self, properties: Properties = EMPTY_DICT, location: str | Non
480485
@override
481486
def supports_server_side_planning(self) -> bool:
482487
"""Check if the catalog supports server-side scan planning."""
483-
return Capability.V1_SUBMIT_TABLE_SCAN_PLAN in self._supported_endpoints and property_as_bool(
484-
self.properties, REST_SCAN_PLANNING_ENABLED, REST_SCAN_PLANNING_ENABLED_DEFAULT
485-
)
488+
scan_planning_mode = ScanPlanningMode(self.properties.get(SCAN_PLANNING_MODE, SCAN_PLANNING_MODE_DEFAULT))
489+
return Capability.V1_SUBMIT_TABLE_SCAN_PLAN in self._supported_endpoints and scan_planning_mode == ScanPlanningMode.SERVER
486490

487491
@retry(**_RETRY_ARGS)
488492
def _plan_table_scan(self, identifier: str | Identifier, request: PlanTableScanRequest) -> PlanningResponse:

‎tests/catalog/test_rest.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,7 +2546,7 @@ def test_server_side_planning_enabled_by_property(self, rest_mock: Mocker) -> No
25462546
"rest",
25472547
uri=TEST_URI,
25482548
token=TEST_TOKEN,
2549-
**{"rest-scan-planning-enabled": "true"},
2549+
**{"scan-planning-mode": "server"},
25502550
)
25512551

25522552
assert catalog.supports_server_side_planning() is True
@@ -2581,7 +2581,7 @@ def test_server_side_planning_enabled_from_server_config(self, rest_mock: Mocker
25812581
rest_mock.get(
25822582
f"{TEST_URI}v1/config",
25832583
json={
2584-
"defaults": {"rest-scan-planning-enabled": "true"},
2584+
"defaults": {"scan-planning-mode": "server"},
25852585
"overrides": {},
25862586
"endpoints": ["POST /v1/{prefix}/namespaces/{namespace}/tables/{table}/plan"],
25872587
},

0 commit comments

Comments
 (0)