Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

### Bug Fixes

* Fixed `selectSparkVersion()` method to use contains() instead of equals() for spark version matching.

### Documentation

### Internal Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public String selectSparkVersion(SparkVersionSelector selector) throws IllegalAr
matches = version.getName().contains("LTS") || version.getKey().contains("-esr-");
}
if (matches && selector.sparkVersion != null) {
matches = ("Apache Spark " + selector.sparkVersion).equals(version.getName());
matches = version.getName().contains("Apache Spark " + selector.sparkVersion);
}
if (matches) {
versions.add(version.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,29 @@ void nullComparisonTest() {
String nodeType = clustersExt.selectNodeType(new NodeTypeSelector().withLocalDisk());
assertEquals("testId1", nodeType);
}

private GetSparkVersionsResponse testGetSparkVersionsWithSparkVersion() {
Collection<SparkVersion> versions = new ArrayList<>();
// Mock realistic Databricks Runtime version based on actual API response format
// The key point: version name contains more than just "Apache Spark X.Y.Z"
versions.add(
new SparkVersion()
.setName("13.3 LTS (includes Apache Spark 3.4.1, Scala 2.12)")
.setKey("13.3.x-scala2.12"));
return new GetSparkVersionsResponse().setVersions(versions);
}

@Test
void sparkVersionWithSparkVersionParameter() {
ClustersExt clustersExt = new ClustersExt(clustersMock);
Mockito.doReturn(testGetSparkVersionsWithSparkVersion()).when(clustersMock).sparkVersions();

// Test that sparkVersion parameter works with realistic API response format
// This tests the contains() fix - the version name is "13.3 LTS (includes Apache Spark 3.4.1,
// Scala 2.12)"
// not just "Apache Spark 3.4.1", so equals() would fail but contains() works
String sparkVersion =
clustersExt.selectSparkVersion(new SparkVersionSelector().withSparkVersion("3.4.1"));
assertEquals("13.3.x-scala2.12", sparkVersion);
}
}
Loading