support new Cursor attribute that provides information on completed commands
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with DatabricksConnectionManager.get_response() in dbt-databricks, where the issue identifies the hardcoded "OK" message, and inspect the connector's cursor and command-result handling. Compare the desired output with PostgreSQL's CommandComplete tags and the listed driver attributes. Done means completed commands expose an appropriate cursor attribute and get_response() reports the operation and affected-row count.
Written by the indexing model from the issue text.
Description
similar to: https://github.com/aws/amazon-redshift-python-driver/issues/220
While a Cursor attribute providing SQL State Code is not officially a part of PEP 249: Python DB API 2.0 spec, it's a common enough convention and would greatly enhance the user experience of dbt-databricks users (👀 @benc-db)
Many database drivers provide this as a Cursor attribute, dbt was able to depend on these drivers to provide it for a ConnectionManager.get_response() method, which reports to users after successful queries the kind of operation performed (SELECT, INSERT, CREATE) and the numbers of rows affected.
However, this is not fully supported today in dbt-databrick, see DatabricksConnectionManager.get_response() where message is hardcoded as "OK" instead of returning more information.
Support for SQL state amongst popular analytics database drivers
| Driver | Cursor attribute (docs) |
|---|---|
| psycopg2 | statusmessage |
snowflake-connector-python |
sqlstate |
Ideal implementation
Follow Postgres's CommandComplete message
| Command | Tag | rows indicates the number of rows |
|---|---|---|
INSERT |
INSERT 0 rows |
inserted |
DELETE |
DELETE rows |
deleted |
UPDATE |
UPDATE rows |
updated |
MERGE |
MERGE rows |
inserted, updated, or deleted |
SELECT / CREATE TABLE AS |
SELECT rows |
retrieved |
MOVE |
MOVE rows |
ursor's position has been changed by |
FETCH |
FETCH rows |
that have been retrieved from the cursor |
COPY |
COPY rows |
copied, only in PostgreSQL 8.2 and later |
- Dominant language
- Python
- Stars
- 233
- Forks
- 152
- Avg merge
- 21h 5m
- Merged PRs (30d)
- 10
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from databricks/databricks-sql-python
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
All issues in databricks/databricks-sql-python
Similar issues
-
fix: inaccuracy ⚠️
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
uabrc/uabrc.github.io#1255 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
ethereum-optimism/factory#64 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
duckdb/duckdb-python#627 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Qiskit/qiskit-addon-sqd#376 ·