Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make names of ROW datatype available in result set #335

Merged
merged 1 commit into from
Mar 31, 2023

Conversation

mdesmet
Copy link
Contributor

@mdesmet mdesmet commented Feb 17, 2023

Description

cur = trino_connection.cursor()
cur.execute("SELECT CAST(ROW(1, 2e0) AS ROW(x BIGINT, y DOUBLE))")
rows = cur.fetchall()

assert rows[0][0] == (1, 2.0)
assert rows[0][0].x == 1
assert rows[0][0].y == 2.0

cur = trino_connection.cursor()
cur.execute("SELECT CAST(ROW(1, ROW(1, 2e0)) AS ROW(x BIGINT, y ROW(x BIGINT, y DOUBLE)))")
rows = cur.fetchall()

assert rows[0][0] == (1, (1, 2.0))
assert rows[0][0].x == 1
assert rows[0][0].y.x == 1
assert rows[0][0].y.y == 2.0

Non-technical explanation

Release notes

( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
(x) Release notes are required, with the following suggested text:

* Make names of ROW datatype available in result set

Fixes #338

@cla-bot cla-bot bot added the cla-signed label Feb 17, 2023
@mdesmet mdesmet force-pushed the feat/named_rows branch 3 times, most recently from 3f35ce1 to 5513ac2 Compare February 18, 2023 09:26
@mdesmet mdesmet requested a review from hashhar February 28, 2023 09:02
@mdesmet mdesmet self-assigned this Feb 28, 2023
@mdesmet
Copy link
Contributor Author

mdesmet commented Mar 1, 2023

@hashhar: i didn't change the repr it still uses tuple's implementation. Do you think we should also adapt to show the attributes?

trino/client.py Show resolved Hide resolved
tests/integration/test_dbapi_integration.py Outdated Show resolved Hide resolved
@mdesmet mdesmet requested a review from damian3031 March 1, 2023 08:10
@mdesmet mdesmet force-pushed the feat/named_rows branch 2 times, most recently from 6030d10 to 8947f9b Compare March 6, 2023 22:01
trino/client.py Show resolved Hide resolved
@mdesmet
Copy link
Contributor Author

mdesmet commented Mar 31, 2023

I also changed the __repr__ to also include attributes. I think that will be beneficial for debugging purposes.

@hashhar
Copy link
Member

hashhar commented Mar 31, 2023

@mdesmet Did you forget to push some changes? I don't see any after your comment.

@hashhar hashhar merged commit e10bc53 into trinodb:master Mar 31, 2023
@mdesmet mdesmet deleted the feat/named_rows branch March 31, 2023 13:34
@Raghav-254
Copy link

Raghav-254 commented Apr 10, 2023

Hi folks, when are you planning to release the new version 0.323.0.

@hashhar
Copy link
Member

hashhar commented Apr 10, 2023

I plan to do a release sometime this week. There's a few PRs we're waiting for.

@Raghav-254
Copy link

Great
Currently at Linkedin we are using trino-python-client version 0.306.0 and for one of the column we are getting it's value as below
Screenshot 2023-04-10 at 3 49 33 PM

But now after upgrading it to 0.322.0, the output doesn't seem to be correct.
Screenshot 2023-04-10 at 3 45 43 PM

It seems that it is not handling the special characters properly. Can you please check this issue as well?

It is also giving the below error sometimes
Unsupported UTF-8 sequence length when encoding string

@hashhar
Copy link
Member

hashhar commented Apr 10, 2023

@Raghav-254 Could you file an issue with some reproduction steps? At-least having the table DDL (or at-least data-type for the problematic column) + some snippet of how you use the client would be helpful.

@Raghav-254
Copy link

Hi @hashhar, thanks for responding so quickly.
I have opened up this issue: #355 including the steps to reproduce it.
Regards,
Raghav Mittal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Represent ROW types as dict instead of tuple
4 participants