fix(dlt): compare dlt version semantically for destination client#5890
Open
anxkhn wants to merge 1 commit into
Open
fix(dlt): compare dlt version semantically for destination client#5890anxkhn wants to merge 1 commit into
anxkhn wants to merge 1 commit into
Conversation
The dlt destination-client gate compared the version as a string (`dlt.__version__ >= "1.10.0"`). String comparison is lexicographic, so it wrongly evaluates "1.9.0" >= "1.10.0" (and "1.2.0", "1.5.10", ...) as True. That sent every 1.x version down the >=1.10.0 branch and made the pre-1.10 `_sql_job_client` fallback unreachable. Use `packaging.version.parse` for a semantic comparison, mirroring the existing idiom in sqlmesh/core/config/connection.py. The client selection is extracted into a small `_get_destination_client` helper so the version gate can be unit tested without a live dlt pipeline. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
StuffbyYuki
reviewed
Jul 9, 2026
StuffbyYuki
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for this!
Given destination_client() exists on all realistically supported dlt versions and is what everyone already hits due to the string-compare bug, would you consider simplifying to always use destination_client() (or pinning dlt>=1.10) instead of maintaining a version gate?
Let me know what you think
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.
The dlt destination-client selection in
sqlmesh/integrations/dlt.pygated the1.10.0 API change with a string comparison:
String comparison is lexicographic, not semantic, so it is wrong for any version
with a double-digit minor. For example
"1.9.0" >= "1.10.0"evaluates toTrue(the character
'9'sorts after'1'), and likewise for"1.2.0"and"1.5.10". The result is that every1.xversion takes the>= 1.10.0branch,and the pre-1.10
_sql_job_clientfallback (added in #4223 for compatibilitywith older dlt) is unreachable.
This is currently latent rather than crashing, because dlt versions below 1.10.0
happen to expose
destination_client()as well. But the version guard issilently incorrect and the intended fallback never runs.
The fix uses
packaging.version.parsefor a semantic comparison, mirroring theidiom already used in
sqlmesh/core/config/connection.py(
version.parse(...) < version.parse("...")).packagingis already atop-level dependency, so no new dependency is introduced.
The client selection is extracted into a small
_get_destination_clienthelperso the version gate can be unit tested without a live dlt pipeline.
Test Plan
test_get_destination_client_version_gateintests/integrations/test_dlt.py: a parametrized, pure-Python test thatmonkeypatches
dlt.__version__and asserts1.9.0,1.2.0,1.5.10select_sql_job_clientwhile1.10.0,1.28.1,2.0.0selectdestination_client. It fails under the old string comparison for the pre-1.10cases and passes after the fix. No warehouse or live dlt pipeline required.
pytest tests/integrations/test_dlt.py-> 7 passed.make style(ruff check, ruff format, mypy) clean.Checklist
make styleand fixed any issuesmake fast-test)git commit -s) per the DCO