[DRAFT] feat: expose rows_affected in adapter_response - #1614
Closed
ericvinicius wants to merge 1 commit into
Closed
[DRAFT] feat: expose rows_affected in adapter_response#1614ericvinicius wants to merge 1 commit into
ericvinicius wants to merge 1 commit into
Conversation
Add 'rows_affected' field to AdapterResponse that reflects cursor.rowcount reported by the databricks-sql-connector after DML statements (INSERT/UPDATE/DELETE/MERGE). For SELECT or queries where the backend does not report a count, the field is None. This makes affected-row counts available in 'run_results.json' → adapter_response, enabling downstream monitoring and validation pipelines. Resolves: databricks#1607
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add
rows_affectedtoDatabricksAdapterResponseso downstream consumers (monitoring, validation pipelines) can read the number of rows affected by DML operations (INSERT/UPDATE/DELETE/MERGE) directly fromrun_results.json.Changes
rows_affected: Optional[int]field toDatabricksAdapterResponsedataclasscursor.rowcountfrom the Databricks SQL connector, usinggetattrwith defensive type checkingWhy
cursor.rowcount?The value is sourced from the public
cursor.rowcountattribute, which thedatabricks-sql-connectorpopulates after executing DML statements.In
databricks-sql-connector(client.py, around line 1384-1390), the connector surfaces the affected-row count from the backend:Implementation Details
cursor.rowcountafter execution (no additional query required)getattrwith defensive type checking to handle edge cases (missing attribute, wrong types)Nonewhenrowcountis-1(default for SELECT/DDL) or not availableRelated Issues