Skip to content

Commit 677a7b0

Browse files
SEA volume operations fix: assign manifest.is_volume_operation to is_staging_operation in ExecuteResponse (#610)
* assign manifest.is_volume_operation to is_staging_operation Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com> * introduce unit test to ensure correct assignment of is_staging_op Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com> --------- Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent e380654 commit 677a7b0

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

src/databricks/sql/backend/sea/backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def _results_message_to_execute_response(
353353
description=description,
354354
has_been_closed_server_side=False,
355355
lz4_compressed=lz4_compressed,
356-
is_staging_operation=False,
356+
is_staging_operation=response.manifest.is_volume_operation,
357357
arrow_schema_bytes=None,
358358
result_format=response.manifest.format,
359359
)

src/databricks/sql/backend/sea/models/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ class ResultManifest:
9292
truncated: bool = False
9393
chunks: Optional[List[ChunkInfo]] = None
9494
result_compression: Optional[str] = None
95-
is_volume_operation: Optional[bool] = None
95+
is_volume_operation: bool = False

src/databricks/sql/backend/sea/models/responses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _parse_manifest(data: Dict[str, Any]) -> ResultManifest:
6565
truncated=manifest_data.get("truncated", False),
6666
chunks=chunks,
6767
result_compression=manifest_data.get("result_compression"),
68-
is_volume_operation=manifest_data.get("is_volume_operation"),
68+
is_volume_operation=manifest_data.get("is_volume_operation", False),
6969
)
7070

7171

tests/unit/test_sea_backend.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,31 @@ def test_utility_methods(self, sea_client):
633633
sea_client._extract_description_from_manifest(no_columns_manifest) is None
634634
)
635635

636+
def test_results_message_to_execute_response_is_staging_operation(self, sea_client):
637+
"""Test that is_staging_operation is correctly set from manifest.is_volume_operation."""
638+
# Test when is_volume_operation is True
639+
response = MagicMock()
640+
response.statement_id = "test-statement-123"
641+
response.status.state = CommandState.SUCCEEDED
642+
response.manifest.is_volume_operation = True
643+
response.manifest.result_compression = "NONE"
644+
response.manifest.format = "JSON_ARRAY"
645+
646+
# Mock the _extract_description_from_manifest method to return None
647+
with patch.object(
648+
sea_client, "_extract_description_from_manifest", return_value=None
649+
):
650+
result = sea_client._results_message_to_execute_response(response)
651+
assert result.is_staging_operation is True
652+
653+
# Test when is_volume_operation is False
654+
response.manifest.is_volume_operation = False
655+
with patch.object(
656+
sea_client, "_extract_description_from_manifest", return_value=None
657+
):
658+
result = sea_client._results_message_to_execute_response(response)
659+
assert result.is_staging_operation is False
660+
636661
def test_get_catalogs(self, sea_client, sea_session_id, mock_cursor):
637662
"""Test the get_catalogs method."""
638663
# Mock the execute_command method

0 commit comments

Comments
 (0)