Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/databricks/sql/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
CursorAlreadyClosedError,
)
from databricks.sql.thrift_backend import ThriftBackend
from databricks.sql.utils import ExecuteResponse, ParamEscaper, inject_parameters
from databricks.sql.utils import ExecuteResponse, ParamEscaper
from databricks.sql.types import Row
from databricks.sql.auth.auth import get_python_sql_connector_auth_provider
from databricks.sql.experimental.oauth_persistence import OAuthPersistence
Expand Down Expand Up @@ -482,21 +482,17 @@ def _handle_staging_remove(self, presigned_url: str, headers: dict = None):
)

def execute(
self, operation: str, parameters: Optional[Dict[str, str]] = None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we allowed users to do this I think we should continue to support it, but instead of injecting the parameter values in the driver we should convert to the format expected by the backend and pass it on.

self, operation: str, parameters: Optional[Dict[str, Any]] = None
) -> "Cursor":
"""
Execute a query and wait for execution to complete.
Parameters should be given in extended param format style: %(...)<s|d|f>.
Named parameters should be given in this format: :param.
For example:
operation = "SELECT * FROM table WHERE field = %(some_value)s"
parameters = {"some_value": "foo"}
Will result in the query "SELECT * FROM table WHERE field = 'foo' being sent to the server
operation = "SELECT * FROM table WHERE field = :some_param"
parameters = {"some_param": "foo"}
Will result in the query with the parameters sent to the server for server-side parameterization
:returns self
"""
if parameters is not None:
operation = inject_parameters(
operation, self.escaper.escape_args(parameters)
)

self._check_not_closed()
self._close_and_clear_active_result_set()
Expand All @@ -507,6 +503,7 @@ def execute(
max_bytes=self.buffer_size_bytes,
lz4_compression=self.connection.lz4_compression,
cursor=self,
parameters=parameters,
use_cloud_fetch=self.connection.use_cloud_fetch,
)
self.active_result_set = ResultSet(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# Autogenerated by Thrift Compiler (0.17.0)
# Autogenerated by Thrift Compiler (0.18.1)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
Expand Down Expand Up @@ -45,7 +45,6 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print(' TGetDelegationTokenResp GetDelegationToken(TGetDelegationTokenReq req)')
print(' TCancelDelegationTokenResp CancelDelegationToken(TCancelDelegationTokenReq req)')
print(' TRenewDelegationTokenResp RenewDelegationToken(TRenewDelegationTokenReq req)')
print(' TDBSqlGetLoadInformationResp GetLoadInformation(TDBSqlGetLoadInformationReq req)')
print('')
sys.exit(0)

Expand Down Expand Up @@ -251,12 +250,6 @@ elif cmd == 'RenewDelegationToken':
sys.exit(1)
pp.pprint(client.RenewDelegationToken(eval(args[0]),))

elif cmd == 'GetLoadInformation':
if len(args) != 1:
print('GetLoadInformation requires 1 args')
sys.exit(1)
pp.pprint(client.GetLoadInformation(eval(args[0]),))

else:
print('Unrecognized method %s' % cmd)
sys.exit(1)
Expand Down
191 changes: 1 addition & 190 deletions src/databricks/sql/thrift_api/TCLIService/TCLIService.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/databricks/sql/thrift_api/TCLIService/constants.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading