Skip to content

Commit d1c2389

Browse files
authored
Merge branch 'main' into samikshya-chand_data/discoveryUrl
2 parents 7a81f73 + 4d50c7b commit d1c2389

4 files changed

Lines changed: 38 additions & 10 deletions

File tree

NEXT_CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
### Bug Fixes
88

9+
* Fixed `selectSparkVersion()` method to use contains() instead of equals() for spark version matching.
10+
911
### Documentation
1012

1113
### Internal Changes

databricks-sdk-java/src/main/java/com/databricks/sdk/mixin/ClustersExt.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public String selectSparkVersion(SparkVersionSelector selector) throws IllegalAr
5050
matches = version.getName().contains("LTS") || version.getKey().contains("-esr-");
5151
}
5252
if (matches && selector.sparkVersion != null) {
53-
matches = ("Apache Spark " + selector.sparkVersion).equals(version.getName());
53+
matches = version.getName().contains("Apache Spark " + selector.sparkVersion);
5454
}
5555
if (matches) {
5656
versions.add(version.getKey());
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
package com.databricks.sdk.integration;
22

3+
import com.databricks.sdk.AccountClient;
4+
import com.databricks.sdk.integration.framework.CollectionUtils;
35
import com.databricks.sdk.integration.framework.EnvContext;
46
import com.databricks.sdk.integration.framework.EnvTest;
7+
import com.databricks.sdk.service.provisioning.CustomerManagedKey;
8+
import org.junit.jupiter.api.Test;
59
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
610
import org.junit.jupiter.api.extension.ExtendWith;
711

812
@EnvContext("account")
913
@DisabledIfEnvironmentVariable(named = "ARM_CLIENT_ID", matches = ".*")
1014
@ExtendWith(EnvTest.class)
1115
public class EncryptionKeysIT {
12-
// TODO: Enable this test when the test account is updated to support this.
13-
// Either by upgrading the test account tier to Enterprise or by adding this
14-
// feature to the test account.
15-
// @Test
16-
// void lists(AccountClient a) {
17-
// Iterable<CustomerManagedKey> list = a.encryptionKeys().list();
16+
@Test
17+
void lists(AccountClient a) {
18+
Iterable<CustomerManagedKey> list = a.encryptionKeys().list();
1819

19-
// java.util.List<CustomerManagedKey> all = CollectionUtils.asList(list);
20+
java.util.List<CustomerManagedKey> all = CollectionUtils.asList(list);
2021

21-
// CollectionUtils.assertUnique(all);
22-
// }
22+
CollectionUtils.assertUnique(all);
23+
}
2324
}

databricks-sdk-java/src/test/java/com/databricks/sdk/mixin/ClustersExtTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,29 @@ void nullComparisonTest() {
118118
String nodeType = clustersExt.selectNodeType(new NodeTypeSelector().withLocalDisk());
119119
assertEquals("testId1", nodeType);
120120
}
121+
122+
private GetSparkVersionsResponse testGetSparkVersionsWithSparkVersion() {
123+
Collection<SparkVersion> versions = new ArrayList<>();
124+
// Mock realistic Databricks Runtime version based on actual API response format
125+
// The key point: version name contains more than just "Apache Spark X.Y.Z"
126+
versions.add(
127+
new SparkVersion()
128+
.setName("13.3 LTS (includes Apache Spark 3.4.1, Scala 2.12)")
129+
.setKey("13.3.x-scala2.12"));
130+
return new GetSparkVersionsResponse().setVersions(versions);
131+
}
132+
133+
@Test
134+
void sparkVersionWithSparkVersionParameter() {
135+
ClustersExt clustersExt = new ClustersExt(clustersMock);
136+
Mockito.doReturn(testGetSparkVersionsWithSparkVersion()).when(clustersMock).sparkVersions();
137+
138+
// Test that sparkVersion parameter works with realistic API response format
139+
// This tests the contains() fix - the version name is "13.3 LTS (includes Apache Spark 3.4.1,
140+
// Scala 2.12)"
141+
// not just "Apache Spark 3.4.1", so equals() would fail but contains() works
142+
String sparkVersion =
143+
clustersExt.selectSparkVersion(new SparkVersionSelector().withSparkVersion("3.4.1"));
144+
assertEquals("13.3.x-scala2.12", sparkVersion);
145+
}
121146
}

0 commit comments

Comments
 (0)