Fix DDL transaction handling for StarRocks#88
Open
inhouseaccman wants to merge 1 commit into
Open
Conversation
20ef84b to
64b863d
Compare
StarRocks does not support DDL statements in explicit transactions, causing error 5305 when running dbt unit tests. Changes: - Add _is_ddl_statement() to detect DDL statements - Override add_commit_query() to skip COMMIT for DDL - Add unit tests for DDL/DML transaction handling Signed-off-by: wkho <wkho@smg.gov.mo>
64b863d to
5198ff1
Compare
Collaborator
|
@inhouseaccman Is it complete to solve the problem? |
Author
Yes. |
Collaborator
|
I cannot reproduce the bug this PR is supposed to fix on the current version. These lines were added in v1.10. def add_begin_query(self):
return self.add_query("", auto_begin=False)Can you try updating to v1.10 to confirm whether these changes are needed? |
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.
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