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

Add Cursor.describe to retrieve the schema of a query #302

Merged
merged 1 commit into from
Dec 22, 2022

Conversation

mdesmet
Copy link
Contributor

@mdesmet mdesmet commented Dec 14, 2022

Description

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.
( ) Release notes are required, with the following suggested text:

* Fix some things. ({issue}`issuenumber`)

@cla-bot cla-bot bot added the cla-signed label Dec 14, 2022
@mdesmet mdesmet self-assigned this Dec 14, 2022
schema='tiny',
table='nation',
type='varchar(152)',
type_size=0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is type_size?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not exactly sure it is returned by DESCRIBE OUTPUT

❯ trino
trino> prepare test FROM select * from tpch.tiny.customer;
PREPARE
trino> describe output test;
 Column Name | Catalog | Schema |  Table   |     Type     | Type Size | Aliased
-------------+---------+--------+----------+--------------+-----------+---------
 custkey     | tpch    | tiny   | customer | bigint       |         8 | false
 name        | tpch    | tiny   | customer | varchar(25)  |         0 | false
 address     | tpch    | tiny   | customer | varchar(40)  |         0 | false
 nationkey   | tpch    | tiny   | customer | bigint       |         8 | false
 phone       | tpch    | tiny   | customer | varchar(15)  |         0 | false
 acctbal     | tpch    | tiny   | customer | double       |         8 | false
 mktsegment  | tpch    | tiny   | customer | varchar(10)  |         0 | false
 comment     | tpch    | tiny   | customer | varchar(117) |         0 | false
(8 rows)

Query 20221214_180638_00003_8aypw, FINISHED, 1 node
Splits: 1 total, 1 done (100,00%)
0,72 [0 rows, 0B] [0 rows/s, 0B/s]

trino/dbapi.py Show resolved Hide resolved
@mdesmet mdesmet requested a review from hashhar December 14, 2022 18:07
Copy link
Member

@hovaesco hovaesco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

trino/dbapi.py Outdated Show resolved Hide resolved
Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Looks useful. Similar to ResultSetMetaData from JDBC land.

@hashhar hashhar merged commit 8affa61 into trinodb:master Dec 22, 2022
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.

3 participants