query information_schema with existing schema name returns columns non-exist error
See original GitHub issueHi, 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:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Sorry for my mistake. The literal value should be single quoted, not double quoted.
Thanks, this does solve the issue.