databricks/databricks-sdk-py

[ISSUE] 'dict' object is not callable when m2m authentication

Opened this issue · 0 comments

Description
I´m trying to connect m2m to databricks following the instructions in Databricks but when running the code I am getting the following error:

INFO:databricks.sql.thrift_backend:Error during request to server: {"method": "OpenSession", "session-id": null, "query-id": null, "http-code": null, "error-message": "", "original-exception": "'dict' object is not callable", "no-retry-reason": "non-retryable error", "bounded-retry-delay": null, "attempt": "1/4", "elapsed-seconds": "0.00045418739318847656/900.0"}
Traceback (most recent call last):
  File "/Users/test/Projects/databricks-test/dabricks_test.py", line 134, in <module>
    measures3 = measure_databricks_sql_performance(dbsql_config_m2m_pro, "SELECT * FROM catalog.schema.table LIMIT 2")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/test/Projects/databricks-test/dabricks_test.py", line 99, in measure_databricks_sql_performance
    with sql.connect(**dbsql_config, _retry_stop_after_attempts_count=4, _tls_trusted_ca_file="/Users/test/Desktop/certificate/zscaler.pem") as connection:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/test/miniconda3/envs/databricks/lib/python3.11/site-packages/databricks/sql/__init__.py", line 90, in connect
    return Connection(server_hostname, http_path, access_token, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/test/miniconda3/envs/databricks/lib/python3.11/site-packages/databricks/sql/client.py", line 247, in __init__
    self._open_session_resp = self.thrift_backend.open_session(
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/test/miniconda3/envs/databricks/lib/python3.11/site-packages/databricks/sql/thrift_backend.py", line 549, in open_session
    response = self.make_request(self._client.OpenSession, open_session_req)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/test/miniconda3/envs/databricks/lib/python3.11/site-packages/databricks/sql/thrift_backend.py", line 478, in make_request
    self._handle_request_error(error_info, attempt, elapsed)
  File "/Users/test/miniconda3/envs/databricks/lib/python3.11/site-packages/databricks/sql/thrift_backend.py", line 308, in _handle_request_error
    raise network_request_error

From what I could see the class OAuthCredentialsProvider extends from CredentialsProvider, however the class CredentialsProvider in the databricks-sql-connector dont match the output, one directly return dict while the other return Callable[[], Dict[str, str]].

Is there something I am missing? Shouldnt these two classes be compatible?

Reproduction
Available in Databricks

Expected behavior
Everything work and return the result query.

Is it a regression?
Did this work in a previous version of the SDK? If so, which versions did you try?
Didn´t test

Other Information

  • OS: macOS
  • Version: 0.32.3