Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions pyiceberg/catalog/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/catalog/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"],
},
Expand Down
Loading