Fix DDL transaction handling for StarRocks #88
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.
Fix DDL transaction handling to resolve error 5305
Problem
When running dbt unit tests, StarRocks throws error 5305:
This occurs because StarRocks does not support DDL statements (CREATE, DROP, ALTER, TRUNCATE) within explicit transactions. The current implementation sends COMMIT after DDL execution, which triggers this error.
Root Cause
add_commit_query()was not overridden, using parent class which sends COMMIT ✗When DDL statements are executed, the COMMIT causes StarRocks to fail.
Solution
Add
_is_ddl_statement()static method - Detects DDL statements using regex patterns:CREATE TABLE/VIEW/DATABASE/SCHEMA/INDEX/MATERIALIZED VIEWDROP TABLE/VIEW/DATABASE/SCHEMA/INDEX/MATERIALIZED VIEWALTER TABLE/VIEW/DATABASE/SCHEMATRUNCATE TABLEOverride
add_commit_query()- Skip COMMIT for DDL context, send COMMIT for DMLChanges
dbt/adapters/starrocks/connections.py_is_ddl_statement()andadd_commit_query()tests/unit/test_connections.pyBehavior
Testing
Test Cases
Checklist