Open vinayakmalik95 opened 1 week ago
@ebyhr @hovaesco @hashhar
Kindly allow to raise the PR for the same
Can you share full backtrace?
if key in dict:
is idomatic python. The issue isn't that, the issue is response
itself was probably None
.
See example:
>>> dict_with_key = {"k": "v"}
>>> dict_without_key = {"a": "v"}
>>> empty_dict = {}
>>> none_dict = None
>>>
>>> def check(d):
... if "k" in d:
... print("Exists")
... else:
... print("Does not exist")
...
>>> check(dict_with_key)
Exists
>>> check(dict_without_key)
Does not exist
>>> check(empty_dict)
Does not exist
>>> check(none_dict)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in check
TypeError: argument of type 'NoneType' is not iterable
And this error doesn't match your error, so the cause is probably something else. Please share full backtrace so that we can identify the reason.
Your error was:
ERROR: (builtins.NoneType) None [SQL: 'NoneType' object is not subscriptable] (Background on this error at: https://sqlalche.me/e/14/dbapi)
Expected behavior
When
response is a dict so the logic is not correct over here, actually it should be
if response.get("error") is not None:
Actual behavior
if "error" in response: condition in client.py where error is None it gives
Error: NoneType Object is Not Subscriptable Error
Steps To Reproduce
This occur when I am trying to read via python client when activating data for Apache kyuubi where trinofrontendservice is hosted.
from trino.dbapi import connect from trino.auth import BasicAuthentication from trino import constants
user_name = "sample user" api_key = "somekey"
conn = connect( source="constants.DEFAULT_SOURCE, host="192.168.68.82", port="7732", auth=BasicAuthentication(user_name, api_key), http_scheme="https", )
cur = conn.cursor() query = """SELECT * FROM catalog.database.table""" cur.execute(query) rows = cur.fetchall() print(rows)
Log output
ERROR: (builtins.NoneType) None [SQL: 'NoneType' object is not subscriptable] (Background on this error at: https://sqlalche.me/e/14/dbapi)
Operating System
macos
Trino Python client version
4.0.0
Trino Server version
442
Python version
Python 3.10.4
Are you willing to submit PR?