Skip to content

fix: select_spark_version(latest=True) no longer implicitly filters to scala 2.12 - #1542

Open
mittalpk wants to merge 1 commit into
databricks:mainfrom
mittalpk:fix/select-spark-version-latest-scala-filter
Open

fix: select_spark_version(latest=True) no longer implicitly filters to scala 2.12#1542
mittalpk wants to merge 1 commit into
databricks:mainfrom
mittalpk:fix/select-spark-version-latest-scala-filter

Conversation

@mittalpk

Copy link
Copy Markdown

Fixes #1487.

What's wrong

select_spark_version()'s scala parameter defaulted to "2.12", and the filter loop applies it unconditionally — so select_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's SparkVersionRequest.Scala has no default, so an unset Scala is "" (its zero value), and strings.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 when scala is truthy, matching the Go SDK's actual behavior exactly. Callers who explicitly pass scala="2.12" (or any other version) are unaffected.

Testing

Added two tests to tests/test_compute_mixins.py using the existing w/requests_mock fixtures: one confirming select_spark_version(latest=True) now returns the true latest across scala versions (reproduces the exact issue scenario — 16.4.x-scala2.12 vs 18.2.x-scala2.13), one confirming an explicit scala="2.12" still filters correctly. Confirmed the first test fails on unpatched code with the exact reported wrong result, passes after the fix (git stash isolation).

ruff check/ruff format --check clean. Full unit suite (pytest -m 'not integration and not benchmark'): 2118 passed, 7 pre-existing failures in test_open_ai_mixin.py (missing optional openai/langchain extras in this environment) — unrelated, confirmed by the failure content (ImportError/ModuleNotFoundError for those packages).

…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
@github-actions

Copy link
Copy Markdown

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-py

Inputs:

  • PR number: 1542
  • Commit SHA: ec50afd4821f5aa0b2ee6cfbd176c1a9b7770748

Checks will be approved automatically on success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ISSUE] select_spark_version(latest=True) doesn't return the latest DBR overall because it implicitly filters to Scala 2.12

1 participant