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.

query information_schema with existing schema name returns columns non-exist error

See original GitHub issue

Hi, I got the following error while running the query trino_cursor.execute('''SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" =uip_chenhao_db''') ERROR: `--------------------------------------------------------------------------- TrinoUserError Traceback (most recent call last) /tmp/ipykernel_45823/3428439138.py in <module> 1 trino_cursor.execute(‘’‘SELECT “table_name” FROM “information_schema”.“tables” WHERE “table_schema” =uip_chenhao_db AND “table_name” =chenhao_test_pandastotrino’‘’) ----> 2 data = trino_cursor.fetchall()

/opt/python3common/lib/python3.7/site-packages/trino/dbapi.py in fetchall(self) 455 456 def fetchall(self) -> List[List[Any]]: –> 457 return list(self.genall()) 458 459 def cancel(self):

/opt/python3common/lib/python3.7/site-packages/trino/client.py in iter(self) 441 # Subsequent fetches from GET requests until next_uri is empty. 442 while not self._query.finished: –> 443 rows = self._query.fetch() 444 for row in rows: 445 self._rownumber += 1

/opt/python3common/lib/python3.7/site-packages/trino/client.py in fetch(self) 518 “”“Continue fetching data for the current query_id”“” 519 response = self._request.get(self._request.next_uri) –> 520 status = self._request.process(response) 521 if status.columns: 522 self._columns = status.columns

/opt/python3common/lib/python3.7/site-packages/trino/client.py in process(self, http_response) 388 logger.debug(“HTTP %s: %s”, http_response.status_code, response) 389 if “error” in response: –> 390 raise self._process_error(response[“error”], response.get(“id”)) 391 392 if constants.HEADER_CLEAR_SESSION in http_response.headers:

TrinoUserError: TrinoUserError(type=USER_ERROR, name=COLUMN_NOT_FOUND, message=“line 1:78: Column ‘uip_chenhao_db’ cannot be resolved”, query_id=20211213_230106_00075_bhywy)`

And I can verify the corresponding schema entry exist in the table_schema column: trino_cursor.execute('''SELECT * FROM "information_schema"."tables"''') column_names = [desc[0] for desc in trino_cursor.description] df = pd.DataFrame(trino_cursor.fetchall(), columns=column_names) 'uip_chenhao_db' in df.table_schema.values

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hashharcommented, Dec 14, 2021

Sorry for my mistake. The literal value should be single quoted, not double quoted.

-trino_cursor.execute('''SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" =uip_chenhao_db''') 
+trino_cursor.execute('''SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" = 'uip_chenhao_db' ''') 
0reactions
therealJacobWucommented, Dec 14, 2021

Sorry for my mistake. The literal value should be single quoted, not double quoted.

-trino_cursor.execute('''SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" =uip_chenhao_db''') 
+trino_cursor.execute('''SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" = 'uip_chenhao_db' ''') 

Thanks, this does solve the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

sql - Postgresql tables exists, but getting "relation does not ...
I will get a list of the columns returned properly. However, when I query: SELECT * FROM "my_table";. I get the error:
Read more >
Query Error - Schema Does Not Exist - MSDN
I get the following error when creating stored procedure: Msg 2797, Level 16, State 1, Procedure SearchAllTables, Line 90
Read more >
How to use INFORMATION_SCHEMA Views in SQL Server
To Show the TABLES and COLUMNS in the database or find TABLES and COLUMNS . This first query will return all of the...
Read more >
table listed in information_schema.tables does not exist [closed]
Once you have the correct schema, you can try querying the table with the schema name prefixed to it, e.g. SELECT * FROM...
Read more >
A Walkthrough of SQL Schema - SQLShack
Retrieve all schema and their owners in a database. We can query sys.schemas system table to find out schema in a database and...
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