Skip to content

Commit dc1cb6d

Browse files
fix type issues
Signed-off-by: varun-edachali-dbx <[email protected]>
1 parent 6d4701f commit dc1cb6d

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

src/databricks/sql/backend/databricks_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def execute_command(
8282
parameters: List[ttypes.TSparkParameter],
8383
async_op: bool,
8484
enforce_embedded_schema_correctness: bool,
85+
row_limit: Optional[int] = None,
8586
) -> Union[ResultSet, None]:
8687
"""
8788
Executes a SQL command or query within the specified session.
@@ -100,6 +101,7 @@ def execute_command(
100101
parameters: List of parameters to bind to the query
101102
async_op: Whether to execute the command asynchronously
102103
enforce_embedded_schema_correctness: Whether to enforce schema correctness
104+
row_limit: Maximum number of rows in the response.
103105
104106
Returns:
105107
If async_op is False, returns a ResultSet object containing the

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
WaitTimeout,
1515
MetadataCommands,
1616
)
17+
from databricks.sql.thrift_api.TCLIService import ttypes
1718

1819
if TYPE_CHECKING:
1920
from databricks.sql.client import Cursor
@@ -402,7 +403,7 @@ def execute_command(
402403
lz4_compression: bool,
403404
cursor: Cursor,
404405
use_cloud_fetch: bool,
405-
parameters: List[Dict[str, Any]],
406+
parameters: List[ttypes.TSparkParameter],
406407
async_op: bool,
407408
enforce_embedded_schema_correctness: bool,
408409
row_limit: Optional[int] = None,
@@ -437,9 +438,11 @@ def execute_command(
437438
for param in parameters:
438439
sea_parameters.append(
439440
StatementParameter(
440-
name=param["name"],
441-
value=param["value"],
442-
type=param["type"] if "type" in param else None,
441+
name=param.name,
442+
value=(
443+
param.value.stringValue if param.value is not None else None
444+
),
445+
type=param.type,
443446
)
444447
)
445448

src/databricks/sql/backend/thrift_backend.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,6 @@ def __init__(
239239
def max_download_threads(self) -> int:
240240
return self._max_download_threads
241241

242-
@property
243-
def max_download_threads(self) -> int:
244-
return self._max_download_threads
245-
246242
# TODO: Move this bounding logic into DatabricksRetryPolicy for v3 (PECO-918)
247243
def _initialize_retry_args(self, kwargs):
248244
# Configure retries & timing: use user-settings or defaults, and bound

tests/unit/test_sea_backend.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
_filter_session_configuration,
1414
)
1515
from databricks.sql.backend.types import SessionId, CommandId, CommandState, BackendType
16+
from databricks.sql.parameters.native import IntegerParameter, TDbsqlParameter
17+
from databricks.sql.thrift_api.TCLIService import ttypes
1618
from databricks.sql.types import SSLOptions
1719
from databricks.sql.auth.authenticators import AuthProvider
1820
from databricks.sql.exc import (
@@ -355,7 +357,8 @@ def test_command_execution_advanced(
355357
"status": {"state": "SUCCEEDED"},
356358
}
357359
mock_http_client._make_request.return_value = execute_response
358-
param = {"name": "param1", "value": "value1", "type": "STRING"}
360+
dbsql_param = IntegerParameter(name="param1", value=1)
361+
param = dbsql_param.as_tspark_param(named=True)
359362

360363
with patch.object(sea_client, "get_execution_result"):
361364
sea_client.execute_command(
@@ -374,8 +377,8 @@ def test_command_execution_advanced(
374377
assert "parameters" in kwargs["data"]
375378
assert len(kwargs["data"]["parameters"]) == 1
376379
assert kwargs["data"]["parameters"][0]["name"] == "param1"
377-
assert kwargs["data"]["parameters"][0]["value"] == "value1"
378-
assert kwargs["data"]["parameters"][0]["type"] == "STRING"
380+
assert kwargs["data"]["parameters"][0]["value"] == "1"
381+
assert kwargs["data"]["parameters"][0]["type"] == "INT"
379382

380383
# Test execution failure
381384
mock_http_client.reset_mock()

0 commit comments

Comments
 (0)