dbt-starrocks icon indicating copy to clipboard operation
dbt-starrocks copied to clipboard

Fix StarRocks Version Detection Error

Open progammer3000 opened this issue 6 months ago • 2 comments

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

  1. Read-only property: The MySQL connector's server_version property is designed to be read-only and automatically populated during the MySQL protocol handshake
  2. Version format mismatch: StarRocks returns version strings like "3.4.3-a01aa59" which differ from MySQL's expected format
  3. 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:

  1. Stores StarRocks version separately: Uses custom connection attributes (connection.starrocks_version and connection.starrocks_version_string) instead of overwriting connection.handle.server_version
  2. Improves version parsing: Fixed _parse_version() function to correctly handle StarRocks version formats like "3.4.3-a01aa59"
  3. Updates version methods: Modified is_before_version() and current_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_version instead of attempting to set connection.handle.server_version
  • Added error handling: Provides fallback version info when detection fails

impl.py

  • Updated is_before_version() method: Now uses connection.starrocks_version instead of connection.handle.server_version
  • Updated current_version() method: Now uses connection.starrocks_version instead of connection.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.

progammer3000 avatar Jun 06 '25 12:06 progammer3000

@chris-celerdata for your kind reference

progammer3000 avatar Oct 24 '25 08:10 progammer3000

Can you rebase on main so I can run the workflow?

chris-celerdata avatar Oct 24 '25 17:10 chris-celerdata