similar to: aws/amazon-redshift-python-driver#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
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 |
similar to: aws/amazon-redshift-python-driver#220
While a
Cursorattribute 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
Cursorattribute, dbt was able to depend on these drivers to provide it for aConnectionManager.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()wheremessageis hardcoded as"OK"instead of returning more information.Support for SQL state amongst popular analytics database drivers
Cursorattribute (docs)statusmessagesnowflake-connector-pythonsqlstateIdeal implementation
Follow Postgres's
CommandCompletemessagerowsindicates the number of rowsINSERTINSERT 0 rowsDELETEDELETE rowsUPDATEUPDATE rowsMERGEMERGE rowsSELECT/CREATE TABLE ASSELECT rowsMOVEMOVE rowsFETCHFETCH rowsCOPYCOPY rowsPostgreSQL8.2 and later