trinodb / trino-python-client

Python client for Trino
Apache License 2.0
309 stars 151 forks source link

Send extra client_tags with cursor.execute #264

Closed benrifkind closed 1 year ago

benrifkind commented 1 year ago

Describe the feature

Currently you can only specify client_tags when you create a Trino Connection. I want to be able to update the tags whenever I run cursor.execute. My workflow is generally to create one cursor from one connection. And then use cursor.execute multiple times. Each query that I send with execute is different and so I want to tag it differently for tracking purposes.

Describe alternatives you've considered

One alternative is just to add additional_http_headers to the Cursor.execute method and pass it through to the trino.client.TrinoQuery.execute method. Then the user can update the tags by setting the header key "X-Trino-Client-Tags"

Are you willing to submit PR?

benrifkind commented 1 year ago

It looks like client_tags was was initially implemented on a per query basis but then it was changed. So probably I'm missing something. From my reading of the comment, I guess per the name client_tags is meant to be used on a per client basis. So Trino does not support something like query tags...

https://github.com/trinodb/trino-python-client/pull/154/files/9dc1e697f2141c1fc89083654b599015679bc456#r795281894

benrifkind commented 1 year ago

Seems like the suggested thing to do is just to create a connection per query.

https://github.com/trinodb/trino-python-client/pull/265#pullrequestreview-1141127795