|
12 | 12 | SeaDatabricksClient, |
13 | 13 | _filter_session_configuration, |
14 | 14 | ) |
| 15 | +from databricks.sql.backend.sea.models.base import ServiceError, StatementStatus |
15 | 16 | from databricks.sql.backend.types import SessionId, CommandId, CommandState, BackendType |
16 | 17 | from databricks.sql.parameters.native import IntegerParameter, TDbsqlParameter |
17 | 18 | from databricks.sql.thrift_api.TCLIService import ttypes |
@@ -408,7 +409,7 @@ def test_command_execution_advanced( |
408 | 409 | async_op=False, |
409 | 410 | enforce_embedded_schema_correctness=False, |
410 | 411 | ) |
411 | | - assert "Command test-statement-123 failed" in str(excinfo.value) |
| 412 | + assert "Command failed" in str(excinfo.value) |
412 | 413 |
|
413 | 414 | # Test missing statement ID |
414 | 415 | mock_http_client.reset_mock() |
@@ -529,30 +530,35 @@ def test_command_management( |
529 | 530 | def test_check_command_state(self, sea_client, sea_command_id): |
530 | 531 | """Test _check_command_not_in_failed_or_closed_state method.""" |
531 | 532 | # Test with RUNNING state (should not raise) |
532 | | - sea_client._check_command_not_in_failed_or_closed_state( |
533 | | - CommandState.RUNNING, sea_command_id |
534 | | - ) |
| 533 | + status = StatementStatus(state=CommandState.RUNNING) |
| 534 | + sea_client._check_command_not_in_failed_or_closed_state(status, sea_command_id) |
535 | 535 |
|
536 | 536 | # Test with SUCCEEDED state (should not raise) |
537 | | - sea_client._check_command_not_in_failed_or_closed_state( |
538 | | - CommandState.SUCCEEDED, sea_command_id |
539 | | - ) |
| 537 | + status = StatementStatus(state=CommandState.SUCCEEDED) |
| 538 | + sea_client._check_command_not_in_failed_or_closed_state(status, sea_command_id) |
540 | 539 |
|
541 | 540 | # Test with CLOSED state (should raise DatabaseError) |
| 541 | + status = StatementStatus(state=CommandState.CLOSED) |
542 | 542 | with pytest.raises(DatabaseError) as excinfo: |
543 | 543 | sea_client._check_command_not_in_failed_or_closed_state( |
544 | | - CommandState.CLOSED, sea_command_id |
| 544 | + status, sea_command_id |
545 | 545 | ) |
546 | 546 | assert "Command test-statement-123 unexpectedly closed server side" in str( |
547 | 547 | excinfo.value |
548 | 548 | ) |
549 | 549 |
|
550 | 550 | # Test with FAILED state (should raise ServerOperationError) |
| 551 | + status = StatementStatus( |
| 552 | + state=CommandState.FAILED, |
| 553 | + error=ServiceError( |
| 554 | + message="Syntax error in SQL", error_code="SYNTAX_ERROR" |
| 555 | + ), |
| 556 | + ) |
551 | 557 | with pytest.raises(ServerOperationError) as excinfo: |
552 | 558 | sea_client._check_command_not_in_failed_or_closed_state( |
553 | | - CommandState.FAILED, sea_command_id |
| 559 | + status, sea_command_id |
554 | 560 | ) |
555 | | - assert "Command test-statement-123 failed" in str(excinfo.value) |
| 561 | + assert "Command failed" in str(excinfo.value) |
556 | 562 |
|
557 | 563 | def test_utility_methods(self, sea_client): |
558 | 564 | """Test utility methods.""" |
|
0 commit comments