question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`get_table_names` raises `trino.exceptions.FailedToObtainAddedPrepareHeader` in trino 398

See original GitHub issue

Expected behavior

I was expecting the list of tables to be returned (similar to what we can see with previous versions of trino – tested up to 394).

Actual behavior

Trino raises the below error:

sqlalchemy.exc.DBAPIError: (trino.exceptions.FailedToObtainAddedPrepareHeader) 

Details In trino[sqlalchemy]==0.316.0 when iterating over results in dbapi.py line 333 and fetching the results in client.py line 723 it seems that self._row_mapper always evaluates to None. This causes lines 334-337 to never evaluate and therefore the method to raise trino.exceptions.FailedToObtainAddedPrepareHeader.

In trino[sqlalchemy]==0.313.0 in client.py line 677 status will never have a row attribute as response line 463 will never have a data key.

Steps To Reproduce

docker run --name trino -d -p 8080:8080 trinodb/trino
from sqlalchemy import create_engine, inspect

url_ = "trino://user:@localhost:8080/tpcds"
engine = create_engine(url_)
inspect(engine).get_table_names("sf1000")

Log output

Traceback (most recent call last):
  File "/Users/teddycrepineau/LocalDocuments/professional/OMD/playground.py", line 7, in <module>
    print(inspect(engine).get_table_names("sf1000"))
  File "/Users/teddycrepineau/.venv/omd_3_9/lib/python3.9/site-packages/sqlalchemy/engine/reflection.py", line 266, in get_table_names
    return self.dialect.get_table_names(
  File "/Users/teddycrepineau/.venv/omd_3_9/lib/python3.9/site-packages/trino/sqlalchemy/dialect.py", line 196, in get_table_names
    res = connection.execute(sql.text(query), schema=schema)
  File "/Users/teddycrepineau/.venv/omd_3_9/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1306, in execute
    return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
  File "/Users/teddycrepineau/.venv/omd_3_9/lib/python3.9/site-packages/sqlalchemy/sql/elements.py", line 325, in _execute_on_connection
    return connection._execute_clauseelement(
  File "/Users/teddycrepineau/.venv/omd_3_9/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1498, in _execute_clauseelement
    ret = self._execute_context(
  File "/Users/teddycrepineau/.venv/omd_3_9/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1862, in _execute_context
    self._handle_dbapi_exception(
  File "/Users/teddycrepineau/.venv/omd_3_9/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2043, in _handle_dbapi_exception
    util.raise_(
  File "/Users/teddycrepineau/.venv/omd_3_9/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 208, in raise_
    raise exception
  File "/Users/teddycrepineau/.venv/omd_3_9/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1819, in _execute_context
    self.dialect.do_execute(
  File "/Users/teddycrepineau/.venv/omd_3_9/lib/python3.9/site-packages/trino/sqlalchemy/dialect.py", line 346, in do_execute
    cursor.execute(statement, parameters)
  File "/Users/teddycrepineau/.venv/omd_3_9/lib/python3.9/site-packages/trino/dbapi.py", line 460, in execute
    added_prepare_header = self._prepare_statement(
  File "/Users/teddycrepineau/.venv/omd_3_9/lib/python3.9/site-packages/trino/dbapi.py", line 339, in _prepare_statement
    raise trino.exceptions.FailedToObtainAddedPrepareHeader
sqlalchemy.exc.DBAPIError: (trino.exceptions.FailedToObtainAddedPrepareHeader) 

Operating System

macOS Monterey

Trino Python client version

0.313 and 0.316

Trino Server version

398

Python version

3.9.9

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
hashharcommented, Oct 5, 2022

Once you verify we can be sure there’s not another related bug.

0reactions
hashharcommented, Oct 5, 2022

Fixed in #242 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Supersets Trino integration not able to list table schemas
I can successfully connect using both the hive and ubuntu user in the connection string.. however when I go to create a dataset.....
Read more >
Release 398 (28 Sep 2022) — Trino 403 Documentation
Release 398 (28 Sep 2022)# ; General# · Show local cost estimates when using EXPLAIN ; Accumulo connector# · Move column mapping and...
Read more >
Fault-tolerant execution — Trino 403 Documentation
By default, if a Trino node lacks the resources to execute a task or otherwise fails during query execution, the query fails and...
Read more >
Release 0.107 — Trino 403 Documentation
Note: this session property cannot increase the limit above the limit set by the query.max-memory configuration option. Fixed task leak caused by queries ......
Read more >
Release 374 (17 Mar 2022) — Trino 403 Documentation
Release 374 (17 Mar 2022)#. General#. Add support for query parameters in CREATE SCHEMA . (#11485). Improve performance when reading from S3-based spool...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found