You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While a Cursor attribute providing SQL State Code is not officially a part of PEP 249: Python DB API 2.0 spec, there is an ANSI-standardized "SQL state code".
Many database drivers provide this as a Cursor attribute, dbt was able to depend on these drivers to provide it for ConnectionManager.get_response() method, which will report to users after successful queries the kind of operation performed (SELECT, INSERT, CREATE) and the numbers of rows affected. Originally the Redshift adapter for dbt, was supported by the psycopg2 driver, which provides this information in statusmessage.
As reported in dbt-labs/dbt-redshift#785, after migrating the driver dependency to redshift-connector, users are in a degraded state and receive less information than previously due to the SQL state not being available.
Support for SQL state amongst popular analytics database drivers
Hi @dataders , my apologies for the delay in response on this issue. Thank you for raising this gap and for providing an in-depth explanation of the feature request.
From a quick look at the redshift_connector handler for COMMAND COMPLETE, it appears this should be extremely straight forward i.e. modifying this method to set the value of some SQL state attribute on the Cursor.
The only place I anticipate friction is if there are commands for which Redshift server is not providing a command tag within the COMMAND COMPLETE message.
Things may have changed since I last looked into it, but last I remember SELECT commands are such a case i.e. Redshift server does not send the command tag in the COMMAND COMPLETE message following SELECT command execution.
Regardless, I will raise this feature request with the Redshift drivers team and advocate it's inclusion in our roadmap to help ease transitions to redshift-connector for DBT and all other customers coming from drivers which offer this attribute.
While a
Cursor
attribute providing SQL State Code is not officially a part of PEP 249: Python DB API 2.0 spec, there is an ANSI-standardized "SQL state code".Many database drivers provide this as a
Cursor
attribute, dbt was able to depend on these drivers to provide it forConnectionManager.get_response()
method, which will report to users after successful queries the kind of operation performed (SELECT
,INSERT
,CREATE
) and the numbers of rows affected. Originally the Redshift adapter for dbt, was supported by thepsycopg2
driver, which provides this information instatusmessage
.As reported in dbt-labs/dbt-redshift#785, after migrating the driver dependency to
redshift-connector
, users are in a degraded state and receive less information than previously due to the SQL state not being available.Support for SQL state amongst popular analytics database drivers
Cursor
attribute (docs)statusmessage
snowflake-connector-python
sqlstate
Ideal implementation
Postgres's
CommandComplete
messagerows
indicates the number of rowsINSERT
INSERT 0 rows
DELETE
DELETE rows
UPDATE
UPDATE rows
MERGE
MERGE rows
SELECT
/CREATE TABLE AS
SELECT rows
MOVE
MOVE rows
FETCH
FETCH rows
COPY
COPY rows
PostgreSQL
8.2 and laterThe text was updated successfully, but these errors were encountered: