Skip to content

Commit 3b9ffeb

Browse files
committed
feat(gooddata-sdk): [AUTO] Add retrieveResultBinary endpoint; remove Arrow formats from retrieveResult
1 parent 37d0593 commit 3b9ffeb

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

packages/gooddata-sdk/src/gooddata_sdk/compute/model/execution.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,15 @@ def read_result(
504504
) -> ExecutionResult:
505505
return self.bare_exec_response.read_result(limit, offset, timeout)
506506

507+
def read_result_arrow(self) -> pyarrow.Table:
508+
"""
509+
Reads the full execution result as a pyarrow Table via the binary endpoint.
510+
511+
The binary endpoint returns the complete result in one shot (no paging).
512+
Requires pyarrow to be installed (pip install gooddata-sdk[arrow]).
513+
"""
514+
return self.bare_exec_response.read_result_arrow()
515+
507516
def cancel(self) -> None:
508517
"""
509518
Cancels the execution.

packages/gooddata-sdk/tests/compute/test_bare_execution_response.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,31 @@ def readinto(self, b: bytearray) -> int:
4242
return n
4343

4444

45+
def _make_execution(ipc_bytes: bytes):
46+
"""Return an Execution backed by a mock API client."""
47+
from gooddata_sdk.compute.model.execution import Execution
48+
49+
mock_api_client = MagicMock()
50+
mock_response = _FakeResponse(ipc_bytes)
51+
mock_api_client.actions_api.api_client.call_api.return_value = mock_response
52+
53+
afm_exec_response = {
54+
"execution_response": {
55+
"links": {"executionResult": "result-id-123"},
56+
"dimensions": [],
57+
}
58+
}
59+
mock_exec_def = MagicMock()
60+
61+
execution = Execution(
62+
api_client=mock_api_client,
63+
workspace_id="ws-id",
64+
exec_def=mock_exec_def,
65+
response=afm_exec_response,
66+
)
67+
return execution, mock_response
68+
69+
4570
def _make_bare(ipc_bytes: bytes):
4671
"""Return a BareExecutionResponse backed by a mock API client."""
4772
from gooddata_sdk.compute.model.execution import BareExecutionResponse
@@ -108,3 +133,33 @@ def test_read_result_arrow_no_pyarrow_raises() -> None:
108133

109134
with patch.object(_exec_mod, "_ipc", None), pytest.raises(ImportError, match="pyarrow is required"):
110135
bare.read_result_arrow()
136+
137+
138+
# ---------------------------------------------------------------------------
139+
# Execution.read_result_arrow – delegates to BareExecutionResponse
140+
# ---------------------------------------------------------------------------
141+
142+
143+
def test_execution_read_result_arrow_returns_table() -> None:
144+
"""Execution.read_result_arrow() delegates to BareExecutionResponse and returns a pa.Table."""
145+
import pyarrow as pa
146+
147+
ipc_bytes = _make_ipc_stream_bytes()
148+
execution, mock_response = _make_execution(ipc_bytes)
149+
150+
result = execution.read_result_arrow()
151+
152+
assert isinstance(result, pa.Table)
153+
mock_response.release_conn.assert_called_once()
154+
155+
156+
def test_execution_read_result_arrow_calls_binary_endpoint() -> None:
157+
"""Execution.read_result_arrow() hits the /binary endpoint with the correct Accept header."""
158+
ipc_bytes = _make_ipc_stream_bytes()
159+
execution, _ = _make_execution(ipc_bytes)
160+
161+
execution.read_result_arrow()
162+
163+
call_kwargs = execution.bare_exec_response._actions_api.api_client.call_api.call_args.kwargs
164+
assert call_kwargs["header_params"]["Accept"] == "application/vnd.apache.arrow.stream"
165+
assert "/binary" in call_kwargs["resource_path"]

0 commit comments

Comments
 (0)