Coder Social home page Coder Social logo

Comments (16)

timon-schmelzer-gcx avatar timon-schmelzer-gcx commented on July 30, 2024 1

...actually updating to 2.1.0 helped solving my issue! The error message changed from:

databricks.sql.thrift_backend: Error during request to server: {...}

to:

databricks.sql.thrift_backend: Error during request to server: : Invalid access token. {...}

So my databricks access token has been expired. After adding a new token to my script everything is running again 👍

from databricks-sql-python.

zhangzuolin16 avatar zhangzuolin16 commented on July 30, 2024

dears,

is there any solution to fix this issue?

from databricks-sql-python.

susodapop avatar susodapop commented on July 30, 2024

As yet I'm not able to reproduce this behaviour in the connector. Even with this specified version of Python. My best recommendation is to try with a fresh installation of Python within a virtual environment.

from databricks-sql-python.

timon-schmelzer-gcx avatar timon-schmelzer-gcx commented on July 30, 2024

I see the same behavior since a few weeks. Before that, everything was fine and a connection could be established. Nothing changed in the code / the SQL endpoint (at least not from my side). Just updated databricks-sql-connector to 2.1.0 but the result is the same.

from databricks-sql-python.

susodapop avatar susodapop commented on July 30, 2024

I'm closing this issue out due to its age. Feel free to reopen or make a new issue if a similar issue arrises.

from databricks-sql-python.

chozillla avatar chozillla commented on July 30, 2024

The issue still exists. I had success with an initial access token, but I am getting RequestError: Error during request to server: : Invalid access token. when I used a new token and revoked the old one.

from databricks-sql-python.

susodapop avatar susodapop commented on July 30, 2024

@chozillla Can you provide reproduction steps?

from databricks-sql-python.

chozillla avatar chozillla commented on July 30, 2024

@susodapop
Screenshot 2023-09-24 at 8 33 55 PM

Interestingly, it works fine when I explicitly put in the values. This is on a jupyter notebook on vscode via Anaconda.

from databricks-sql-python.

chozillla avatar chozillla commented on July 30, 2024

Uh, so I just exited vscode and restarted and it worked. Strange issue.
Screenshot 2023-09-24 at 9 19 51 PM

from databricks-sql-python.

NephilimJaeger avatar NephilimJaeger commented on July 30, 2024

I'm experiencing the same problem, but in my case, it only occurs when I increase the number of rows that will be written to the Databricks table (50 rows).

from databricks-sql-python.

vcakdwivedi avatar vcakdwivedi commented on July 30, 2024

Hi Everyone,
Is there any fix for above issue? I tried everything mentioned above.
main(server_hostname = args.server_hostname, http_path = args.http_path, schema = args.schema, access_token = args.access_token)
File "extract.py", line 24, in main
dbx_extractor.execute_sql(sql_query, server_hostname, http_path, access_token)
File "/mnt/azureml/cr/j/2c91464c9e0743f5860e8f48b407683d/exe/wd/dbextractor.py", line 23, in execute_sql
with db_sql.connect(
File "/azureml-envs/azureml_9806bfc7c716eaf0df12bea8512e961b/lib/python3.8/site-packages/databricks/sql/init.py", line 50, in connect
return Connection(server_hostname, http_path, access_token, **kwargs)
File "/azureml-envs/azureml_9806bfc7c716eaf0df12bea8512e961b/lib/python3.8/site-packages/databricks/sql/client.py", line 189, in init
self._session_handle = self.thrift_backend.open_session(
File "/azureml-envs/azureml_9806bfc7c716eaf0df12bea8512e961b/lib/python3.8/site-packages/databricks/sql/thrift_backend.py", line 464, in open_session
response = self.make_request(self._client.OpenSession, open_session_req)
File "/azureml-envs/azureml_9806bfc7c716eaf0df12bea8512e961b/lib/python3.8/site-packages/databricks/sql/thrift_backend.py", line 393, in make_request
self._handle_request_error(error_info, attempt, elapsed)
File "/azureml-envs/azureml_9806bfc7c716eaf0df12bea8512e961b/lib/python3.8/site-packages/databricks/sql/thrift_backend.py", line 261, in _handle_request_error
raise network_request_error
databricks.sql.exc.RequestError: Error during request to server

from databricks-sql-python.

susodapop avatar susodapop commented on July 30, 2024

from databricks-sql-python.

Ownmarc avatar Ownmarc commented on July 30, 2024

Hello,

We are seeing the same error, here is the relevant exception text. We use polars (0.20.6) to make requests to our Databricks endpoint using sql.connect. This works fine for some time until it stops working. Then if we simply restart our pod (lives as a docker container in kubernetes), it starts working again.

def get_databricks_connection():
    return sql.connect(
        server_hostname=os.getenv("DATABRICKS_SERVER_HOSTNAME"),
        http_path=os.getenv("DATABRICKS_HTTP_PATH"),
        access_token=os.getenv("DATABRICKS_TOKEN"),
        use_inline_params=True,
    )

databricks_connection = get_databricks_connection()

pl.read_database(
            query=QUERY,
            connection=databricks_connection,
            execute_options={
                "parameters": {
                    "some_param": some_param,
                }
            },
        )
certifi==2024.2.2
polars==0.20.6
databricks-sql-connector==3.0.3
thrift==0.16.0
pyarrow==14.0.2
flask==2.2.5
requests==2.28.2
urllib3==1.26.18

line 255, in _query_event\n return pl.read_database(\n File \"/home/python/.local/lib/python3.10/site-packages/polars/io/database.py\", line 582, in read_database\n return cx.execute(\n File \"/home/python/.local/lib/python3.10/site-packages/polars/io/database.py\", line 345, in execute\n result = cursor_execute(query, **options)\n File \"/home/python/.local/lib/python3.10/site-packages/databricks/sql/client.py\", line 761, in execute\n execute_response = self.thrift_backend.execute_command(\n File \"/home/python/.local/lib/python3.10/site-packages/databricks/sql/thrift_backend.py\", line 868, in execute_command\n resp = self.make_request(self._client.ExecuteStatement, req)\n File \"/home/python/.local/lib/python3.10/site-packages/databricks/sql/thrift_backend.py\", line 507, in make_request\n self._handle_request_error(error_info, attempt, elapsed)\n File \"/home/python/.local/lib/python3.10/site-packages/databricks/sql/thrift_backend.py\", line 337, in _handle_request_error\n raise network_request_error\ndatabricks.sql.exc.RequestError: Error during request to server"

from databricks-sql-python.

sfc-gh-smao avatar sfc-gh-smao commented on July 30, 2024

Hello, I'm seeing the same error.

Code:

from databricks import sql
import os

with sql.connect(
    server_hostname="****************.cloud.databricks.com",
    http_path="/sql/1.0/warehouses/****************",
    access_token="****************",
) as connection:
    cursor = connection.cursor()

    cursor.execute("SELECT * from range(10)")
    print(cursor.fetchall())

    cursor.close()
    connection.close()

Error:

   with sql.connect(
         ^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/databricks/sql/__init__.py", line 84, in connect
    return Connection(server_hostname, http_path, access_token, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/databricks/sql/client.py", line 232, in __init__
    self._open_session_resp = self.thrift_backend.open_session(
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/databricks/sql/thrift_backend.py", line 578, in open_session
    response = self.make_request(self._client.OpenSession, open_session_req)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/databricks/sql/thrift_backend.py", line 507, in make_request
    self._handle_request_error(error_info, attempt, elapsed)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/databricks/sql/thrift_backend.py", line 337, in _handle_request_error
    raise network_request_error
databricks.sql.exc.RequestError: Error during request to server

from databricks-sql-python.

sfc-gh-smao avatar sfc-gh-smao commented on July 30, 2024

@susodapop Can you please reopen this issue? There are new reports for this issue since the issue was closed.

from databricks-sql-python.

susodapop avatar susodapop commented on July 30, 2024

I'm not able to reopen issues any longer. But I would encourage you to turn on DEBUG logging for your connector and share what you find. RequestError is a very generic exception and could point to any number of issues. Without more detail it's impossible to say what the root cause is.

from databricks-sql-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.