Skip to content

Commit

Permalink
Remove useless DatabaseTypeEngine.getStorageTypes (apache#33990)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Dec 10, 2024
1 parent 7a1663c commit ffce9b2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,6 @@ private static Map<String, DataSource> getDataSources(final DatabaseConfiguratio
.collect(Collectors.toMap(Entry::getKey, entry -> entry.getValue().getDataSource(), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
}

/**
* Get storage types.
*
* @param databaseConfig database configuration
* @return storage types
*/
public static Map<String, DatabaseType> getStorageTypes(final DatabaseConfiguration databaseConfig) {
Map<String, DatabaseType> result = new LinkedHashMap<>(databaseConfig.getStorageUnits().size(), 1F);
Map<String, DataSource> dataSources = getDataSources(databaseConfig);
for (Entry<String, DataSource> entry : dataSources.entrySet()) {
result.put(entry.getKey(), getStorageType(entry.getValue()));
}
return result;
}

/**
* Get storage type.
* Similar to <a href="https://github.com/apache/hive/pull/5554">apache/hive#5554</a>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand All @@ -65,14 +64,6 @@ void assertGetProtocolTypeFromDataSource() throws SQLException {
assertThat(DatabaseTypeEngine.getProtocolType(Collections.singletonMap("foo_db", databaseConfig), new ConfigurationProperties(new Properties())), instanceOf(PostgreSQLDatabaseType.class));
}

@Test
void assertGetStorageTypes() throws SQLException {
DataSource datasource = mockDataSource(TypedSPILoader.getService(DatabaseType.class, "MySQL"));
DatabaseConfiguration databaseConfig = new DataSourceProvidedDatabaseConfiguration(Collections.singletonMap("foo_db", datasource), Collections.singletonList(new FixtureRuleConfiguration()));
assertTrue(DatabaseTypeEngine.getStorageTypes(databaseConfig).containsKey("foo_db"));
assertThat(DatabaseTypeEngine.getStorageTypes(databaseConfig).get("foo_db"), instanceOf(MySQLDatabaseType.class));
}

@Test
void assertGetStorageType() throws SQLException {
assertThat(DatabaseTypeEngine.getStorageType(mockDataSource(TypedSPILoader.getService(DatabaseType.class, "H2"))).getType(), is("H2"));
Expand Down

0 comments on commit ffce9b2

Please sign in to comment.