fix: select_spark_version(latest=True) no longer implicitly filters to scala 2.12 - #1542
Open
mittalpk wants to merge 1 commit into
Open
Conversation
…o scala 2.12 The scala parameter defaulted to "2.12" and the filter applied it unconditionally, so select_spark_version(latest=True) silently narrowed to scala-2.12 runtimes before picking the latest instead of considering every scala version. This diverged from the Go SDK this logic is ported from: Go's SparkVersionRequest.Scala has no default, so an unset Scala is "" (its zero value), and strings.Contains(key, "-scala"+"") matches every version's key -- Go's real default is no scala filter. Changed the Python default to "" and only apply the filter when scala is truthy, matching the Go SDK's actual behavior. Callers who explicitly pass scala="2.12" are unaffected. Fixes databricks#1487
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
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.
Fixes #1487.
What's wrong
select_spark_version()'sscalaparameter defaulted to"2.12", and the filter loop applies it unconditionally — soselect_spark_version(latest=True)silently narrows to scala-2.12 runtimes before picking "latest," instead of returning the true latest across all scala versions.The code is explicitly a port of the Go SDK's
ext_spark_version.go— checking that source confirms this is a porting bug, not intentional behavior: Go'sSparkVersionRequest.Scalahas no default, so an unsetScalais""(its zero value), andstrings.Contains(key, "-scala"+"")matches every version's key (all contain the literal substring"-scala") — i.e. Go's real default is "no scala filter." Python's explicit"2.12"default diverged from that.Fix
Changed the default to
scala: str = ""and only apply the filter whenscalais truthy, matching the Go SDK's actual behavior exactly. Callers who explicitly passscala="2.12"(or any other version) are unaffected.Testing
Added two tests to
tests/test_compute_mixins.pyusing the existingw/requests_mockfixtures: one confirmingselect_spark_version(latest=True)now returns the true latest across scala versions (reproduces the exact issue scenario —16.4.x-scala2.12vs18.2.x-scala2.13), one confirming an explicitscala="2.12"still filters correctly. Confirmed the first test fails on unpatched code with the exact reported wrong result, passes after the fix (git stashisolation).ruff check/ruff format --checkclean. Full unit suite (pytest -m 'not integration and not benchmark'): 2118 passed, 7 pre-existing failures intest_open_ai_mixin.py(missing optionalopenai/langchainextras in this environment) — unrelated, confirmed by the failure content (ImportError/ModuleNotFoundErrorfor those packages).