Skip to content

Commit 3eb582f

Browse files
add strong typing for backend parameters arg
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent df9f849 commit 3eb582f

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/databricks/sql/backend/databricks_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def execute_command(
8282
lz4_compression: bool,
8383
cursor: "Cursor",
8484
use_cloud_fetch: bool,
85-
parameters: List[ttypes.TSparkParameter],
85+
parameters: List,
8686
async_op: bool,
8787
enforce_embedded_schema_correctness: bool,
8888
) -> Union["ResultSet", None]:

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ class SeaDatabricksClient(DatabricksClient):
8585
STATEMENT_PATH_WITH_ID = STATEMENT_PATH + "/{}"
8686
CANCEL_STATEMENT_PATH_WITH_ID = STATEMENT_PATH + "/{}/cancel"
8787

88+
# SEA constants
89+
POLL_INTERVAL_SECONDS = 0.2
90+
8891
def __init__(
8992
self,
9093
server_hostname: str,
@@ -383,6 +386,7 @@ def _wait_until_command_done(
383386
command_id = CommandId.from_sea_statement_id(response.statement_id)
384387

385388
while state in [CommandState.PENDING, CommandState.RUNNING]:
389+
time.sleep(self.POLL_INTERVAL_SECONDS)
386390
state = self.get_query_state(command_id)
387391

388392
self._check_command_not_in_failed_or_closed_state(state, command_id)
@@ -432,9 +436,9 @@ def execute_command(
432436
for param in parameters:
433437
sea_parameters.append(
434438
StatementParameter(
435-
name=param.name,
436-
value=param.value,
437-
type=param.type if hasattr(param, "type") else None,
439+
name=param["name"],
440+
value=param["value"],
441+
type=param["type"] if "type" in param else None,
438442
)
439443
)
440444

tests/unit/test_sea_backend.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,7 @@ def test_command_execution_advanced(
354354
"status": {"state": "SUCCEEDED"},
355355
}
356356
mock_http_client._make_request.return_value = execute_response
357-
param = MagicMock()
358-
param.name = "param1"
359-
param.value = "value1"
360-
param.type = "STRING"
357+
param = {"name": "param1", "value": "value1", "type": "STRING"}
361358

362359
with patch.object(sea_client, "get_execution_result"):
363360
sea_client.execute_command(

0 commit comments

Comments
 (0)