Fix StarRocks Version Detection Error
Fix StarRocks Version Detection Error
Problem
The dbt-starrocks adapter was failing with the following error during connection:
Got an error when obtain StarRocks version exception: 'property 'server_version' of 'CMySQLConnection' object has no setter'
This error occurred because the adapter was attempting to assign StarRocks version information to the MySQL connector's server_version property, which is read-only in recent versions of the mysql-connector-python library.
Root Cause
- Read-only property: The MySQL connector's
server_versionproperty is designed to be read-only and automatically populated during the MySQL protocol handshake - Version format mismatch: StarRocks returns version strings like
"3.4.3-a01aa59"which differ from MySQL's expected format - Parsing issues: The existing
_parse_version()function had bugs that prevented correct parsing of StarRocks version strings
Solution
Instead of trying to override the MySQL connector's built-in version handling, this fix:
- Stores StarRocks version separately: Uses custom connection attributes (
connection.starrocks_versionandconnection.starrocks_version_string) instead of overwritingconnection.handle.server_version - Improves version parsing: Fixed
_parse_version()function to correctly handle StarRocks version formats like"3.4.3-a01aa59" - Updates version methods: Modified
is_before_version()andcurrent_version()methods to use the new StarRocks-specific version attributes
Changes Made
connections.py
- Fixed
_parse_version()function: Now correctly parses StarRocks version strings with build suffixes (e.g.,"3.4.3-a01aa59") - Updated version detection logic: Stores version info in
connection.starrocks_versioninstead of attempting to setconnection.handle.server_version - Added error handling: Provides fallback version info when detection fails
impl.py
- Updated
is_before_version()method: Now usesconnection.starrocks_versioninstead ofconnection.handle.server_version - Updated
current_version()method: Now usesconnection.starrocks_versioninstead ofconnection.handle.server_version - Added safety checks: Methods now check for the existence of StarRocks version attributes before accessing them
Compatibility
- ✅ Backward compatible: Existing functionality remains unchanged
- ✅ MySQL connector agnostic: No longer depends on specific MySQL connector version behavior
- ✅ StarRocks version support: Correctly handles all StarRocks version formats (e.g.,
3.4.3,3.4.3-a01aa59)
Testing
The fix has been tested with:
- StarRocks version
3.4.3-a01aa59 - Various version string formats
- Both automatic version detection and manual version specification via
profiles.yml
Before/After
Before:
Got an error when obtain StarRocks version exception: 'property 'server_version' of 'CMySQLConnection' object has no setter'
After:
Detected StarRocks version: 3.4.3-a01aa59 -> (3, 4, 3)
This fix resolves the connection issue and enables proper StarRocks version detection for feature compatibility checks.
@chris-celerdata for your kind reference
Can you rebase on main so I can run the workflow?