Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
21 changes: 21 additions & 0 deletions packages/gooddata-sdk/src/gooddata_sdk/compute/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Loading