trinodb / trino-python-client

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

Support row count for DML queries #319

Closed mdesmet closed 1 year ago

mdesmet commented 1 year ago

Describe the feature

Row count is exposed by the Trino engine when doing DML queries:

trino> create table iceberg.default.test AS SELECT 1 a;
CREATE TABLE: 1 row

Query 20230109_192533_00333_sy494, FINISHED, 1 node
Splits: 18 total, 18 done (100,00%)
1,88 [0 rows, 0B] [0 rows/s, 0B/s]

trino> INSERT INTO iceberg.default.test (a) values (2);
INSERT: 1 row

This information is not exposed in the Trino Python Client.

It would be nice to expose this information.

DBAPI spec also mentions the following:

.rowcount This read-only attribute specifies the number of rows that the last .execute*() produced (for DQL statements like SELECT) or affected (for DML statements like UPDATE or INSERT). [9] The attribute is -1 in case no .execute*() has been performed on the cursor or the rowcount of the last operation is cannot be determined by the interface. [7]

Describe alternatives you've considered

No response

Are you willing to submit PR?