Skip to content

Commit eba17c1

Browse files
more explicit typing
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent dc3a1fb commit eba17c1

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/databricks/sql/backend/thrift_backend.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import math
55
import time
66
import threading
7-
from typing import List, Union, Any, TYPE_CHECKING
7+
from typing import List, Optional, Union, Any, TYPE_CHECKING
88

99
if TYPE_CHECKING:
1010
from databricks.sql.client import Cursor
@@ -929,6 +929,7 @@ def execute_command(
929929
parameters=[],
930930
async_op=False,
931931
enforce_embedded_schema_correctness=False,
932+
row_limit: Optional[int] = None,
932933
) -> Union["ResultSet", None]:
933934
thrift_handle = session_id.to_thrift_handle()
934935
if not thrift_handle:

src/databricks/sql/client.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def cursor(
341341
self,
342342
arraysize: int = DEFAULT_ARRAY_SIZE,
343343
buffer_size_bytes: int = DEFAULT_RESULT_BUFFER_SIZE_BYTES,
344-
row_limit: int = None,
344+
row_limit: Optional[int] = None,
345345
) -> "Cursor":
346346
"""
347347
Return a new Cursor object using the connection.
@@ -400,22 +400,23 @@ def __init__(
400400
visible by other cursors or connections.
401401
"""
402402

403-
if not self.connection.session.use_sea and row_limit is not None:
403+
self.connection: Connection = connection
404+
405+
if not connection.session.use_sea and row_limit is not None:
404406
logger.warning(
405407
"Row limit is only supported for SEA protocol. Ignoring row_limit."
406408
)
407409

408-
self.connection = connection
409-
self.rowcount = -1 # Return -1 as this is not supported
410-
self.buffer_size_bytes = result_buffer_size_bytes
410+
self.rowcount: int = -1 # Return -1 as this is not supported
411+
self.buffer_size_bytes: int = result_buffer_size_bytes
411412
self.active_result_set: Union[ResultSet, None] = None
412-
self.arraysize = arraysize
413-
self.row_limit = row_limit
413+
self.arraysize: int = arraysize
414+
self.row_limit: Optional[int] = row_limit
414415
# Note that Cursor closed => active result set closed, but not vice versa
415-
self.open = True
416-
self.executing_command_id = None
417-
self.backend = backend
418-
self.active_command_id = None
416+
self.open: bool = True
417+
self.executing_command_id: Optional[CommandId] = None
418+
self.backend: DatabricksClient = backend
419+
self.active_command_id: Optional[CommandId] = None
419420
self.escaper = ParamEscaper()
420421
self.lastrowid = None
421422

0 commit comments

Comments
 (0)