From 260dd48d9f7a43f54c038b30097705d08cdbb9f4 Mon Sep 17 00:00:00 2001 From: Yuya Ebihara Date: Sat, 16 May 2026 09:44:36 +0900 Subject: [PATCH] REST: Rename rest-scan-planning-enabled to scan-planning-mode --- pyiceberg/catalog/rest/__init__.py | 14 +++++++++----- tests/catalog/test_rest.py | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pyiceberg/catalog/rest/__init__.py b/pyiceberg/catalog/rest/__init__.py index 7fa81312d1..ecf143b600 100644 --- a/pyiceberg/catalog/rest/__init__.py +++ b/pyiceberg/catalog/rest/__init__.py @@ -225,6 +225,11 @@ class IdentifierKind(Enum): VIEW = "view" +class ScanPlanningMode(Enum): + CLIENT = "client" + SERVER = "server" + + ACCESS_DELEGATION_DEFAULT = "vended-credentials" AUTHORIZATION_HEADER = "Authorization" BEARER_PREFIX = "Bearer" @@ -255,8 +260,8 @@ class IdentifierKind(Enum): SNAPSHOT_LOADING_MODE = "snapshot-loading-mode" AUTH = "auth" CUSTOM = "custom" -REST_SCAN_PLANNING_ENABLED = "rest-scan-planning-enabled" -REST_SCAN_PLANNING_ENABLED_DEFAULT = False +SCAN_PLANNING_MODE = "scan-planning-mode" +SCAN_PLANNING_MODE_DEFAULT = "client" # for backwards compatibility with older REST servers where it can be assumed that a particular # server supports view endpoints but doesn't send the "endpoints" field in the ConfigResponse VIEW_ENDPOINTS_SUPPORTED = "view-endpoints-supported" @@ -480,9 +485,8 @@ def _load_file_io(self, properties: Properties = EMPTY_DICT, location: str | Non @override def supports_server_side_planning(self) -> bool: """Check if the catalog supports server-side scan planning.""" - return Capability.V1_SUBMIT_TABLE_SCAN_PLAN in self._supported_endpoints and property_as_bool( - self.properties, REST_SCAN_PLANNING_ENABLED, REST_SCAN_PLANNING_ENABLED_DEFAULT - ) + scan_planning_mode = ScanPlanningMode(self.properties.get(SCAN_PLANNING_MODE, "client")) + return Capability.V1_SUBMIT_TABLE_SCAN_PLAN in self._supported_endpoints and scan_planning_mode == ScanPlanningMode.SERVER @retry(**_RETRY_ARGS) def _plan_table_scan(self, identifier: str | Identifier, request: PlanTableScanRequest) -> PlanningResponse: diff --git a/tests/catalog/test_rest.py b/tests/catalog/test_rest.py index 2adfe9f06e..3cd7bd616d 100644 --- a/tests/catalog/test_rest.py +++ b/tests/catalog/test_rest.py @@ -2546,7 +2546,7 @@ def test_server_side_planning_enabled_by_property(self, rest_mock: Mocker) -> No "rest", uri=TEST_URI, token=TEST_TOKEN, - **{"rest-scan-planning-enabled": "true"}, + **{"scan-planning-mode": "server"}, ) 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 rest_mock.get( f"{TEST_URI}v1/config", json={ - "defaults": {"rest-scan-planning-enabled": "true"}, + "defaults": {"scan-planning-mode": "server"}, "overrides": {}, "endpoints": ["POST /v1/{prefix}/namespaces/{namespace}/tables/{table}/plan"], },