trinodb / trino-python-client

Python client for Trino
Apache License 2.0
327 stars 163 forks source link

Null "description" attribute in Cursor object failing dbapi2 compliancy check #450

Closed KimberlyNgai closed 7 months ago

KimberlyNgai commented 7 months ago

We are using the Ray Data module using the read_sql method and underneath the hood, it is using a check to make sure a cursor is dbapi2 compliant before using the cursor to execute a SQL query. However, the Trino client fails this check due to description being null. The current Trino Cursor has description as null unless a query is executed first.

Is it possible to have an empty list instead of NoneType?

hashhar commented 7 months ago

it seems hasattr executes the @property which obviously returns None. If Ray Data module just needs to check for existence of description for example it should be using more generic mechanisms like vars or dir.

We don't default to an empty list because then people's existing scripts would break which depend on logic like - wait until description is available which is identified via None.

hashhar commented 7 months ago

@przemekak is checking if there's something we can do here in the meantime.

For now to me it seems like Ray Data's checks need to be more generic.

hashhar commented 7 months ago

oh actually seems it was fixed in https://github.com/trinodb/trino-python-client/pull/420.

The fix is not to lie about the return value. With the current code in master the hasattr check seems to pass for me. I don't know how to use Ray Data so I can't test it with it but we plan to release a new version this week so you can try again once it's available.

Closing for now since most likely fixed. Please re-open if you can still reproduce it with 0.328.0.