From 8883def00e36fe3a409feda733b5492fe61224ed Mon Sep 17 00:00:00 2001 From: Auto Implementation Date: Wed, 18 Mar 2026 09:51:43 +0000 Subject: [PATCH] feat(gooddata-sdk): [AUTO] add retrieve_result_binary wrapper for Arrow binary endpoint Expose the new retrieveResultBinary API endpoint (GET /result/{resultId}/binary) in the SDK wrapper layer. Adds read_result_binary() to BareExecutionResponse and Execution, and retrieve_result_binary() to ComputeService. Co-Authored-By: Claude Sonnet 4.6 --- .../gooddata_sdk/compute/model/execution.py | 21 +++++++++ .../src/gooddata_sdk/compute/service.py | 21 +++++++++ .../compute/test_retrieve_result_binary.py | 45 +++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 packages/gooddata-sdk/tests/compute/test_retrieve_result_binary.py diff --git a/packages/gooddata-sdk/src/gooddata_sdk/compute/model/execution.py b/packages/gooddata-sdk/src/gooddata_sdk/compute/model/execution.py index a81b807ac..224acf6c0 100644 --- a/packages/gooddata-sdk/src/gooddata_sdk/compute/model/execution.py +++ b/packages/gooddata-sdk/src/gooddata_sdk/compute/model/execution.py @@ -372,6 +372,21 @@ def read_result( ) return ExecutionResult(execution_result) + def read_result_binary(self) -> bytes: + """ + Reads execution result in binary Apache Arrow format. + + The server performs content negotiation based on the Accept header and returns + either Apache Arrow IPC File or Stream format. + """ + response = self._actions_api.retrieve_result_binary( + workspace_id=self._workspace_id, + result_id=self.result_id, + _check_return_type=False, + _preload_content=False, + ) + return response.data + def cancel(self) -> None: """ Cancels the execution backing this execution result. @@ -464,6 +479,12 @@ def read_result( ) -> ExecutionResult: return self.bare_exec_response.read_result(limit, offset, timeout) + def read_result_binary(self) -> bytes: + """ + Reads execution result in binary Apache Arrow format. + """ + return self.bare_exec_response.read_result_binary() + def cancel(self) -> None: """ Cancels the execution. diff --git a/packages/gooddata-sdk/src/gooddata_sdk/compute/service.py b/packages/gooddata-sdk/src/gooddata_sdk/compute/service.py index 6163798b9..3208e38d3 100644 --- a/packages/gooddata-sdk/src/gooddata_sdk/compute/service.py +++ b/packages/gooddata-sdk/src/gooddata_sdk/compute/service.py @@ -73,6 +73,27 @@ def for_exec_def( else None, ) + def retrieve_result_binary(self, workspace_id: str, result_id: str) -> bytes: + """ + Gets a single execution result in binary Apache Arrow format from a GoodData.CN workspace. + + The server performs content negotiation and returns either Apache Arrow IPC File + or Stream format based on its preference. + + Args: + workspace_id (str): workspace identifier + result_id (str): execution result ID + Returns: + bytes: raw Apache Arrow binary data + """ + response = self._actions_api.retrieve_result_binary( + workspace_id=workspace_id, + result_id=result_id, + _check_return_type=False, + _preload_content=False, + ) + return response.data + def retrieve_result_cache_metadata(self, workspace_id: str, result_id: str) -> ResultCacheMetadata: """ Gets execution result's metadata from GoodData.CN workspace for given execution result ID. diff --git a/packages/gooddata-sdk/tests/compute/test_retrieve_result_binary.py b/packages/gooddata-sdk/tests/compute/test_retrieve_result_binary.py new file mode 100644 index 000000000..acf377912 --- /dev/null +++ b/packages/gooddata-sdk/tests/compute/test_retrieve_result_binary.py @@ -0,0 +1,45 @@ +# (C) 2025 GoodData Corporation +from __future__ import annotations + +from unittest.mock import MagicMock + +from gooddata_sdk.compute.service import ComputeService + + +def _make_service(mock_actions_api: MagicMock) -> ComputeService: + api_client = MagicMock() + api_client.actions_api = mock_actions_api + api_client.entities_api = MagicMock() + return ComputeService(api_client) + + +def test_retrieve_result_binary_calls_api_with_correct_params(): + mock_actions_api = MagicMock() + expected_bytes = b"arrow_binary_data" + mock_response = MagicMock() + mock_response.data = expected_bytes + mock_actions_api.retrieve_result_binary.return_value = mock_response + + service = _make_service(mock_actions_api) + result = service.retrieve_result_binary("ws1", "result-42") + + mock_actions_api.retrieve_result_binary.assert_called_once_with( + workspace_id="ws1", + result_id="result-42", + _check_return_type=False, + _preload_content=False, + ) + assert result == expected_bytes + + +def test_retrieve_result_binary_returns_bytes(): + mock_actions_api = MagicMock() + mock_response = MagicMock() + mock_response.data = b"\x00\x01\x02" + mock_actions_api.retrieve_result_binary.return_value = mock_response + + service = _make_service(mock_actions_api) + result = service.retrieve_result_binary("workspace", "rid") + + assert isinstance(result, bytes) + assert result == b"\x00\x01\x02"