Skip to content

Commit e9ab47c

Browse files
authored
Wire through missing deletion hints (#254)
1 parent d42f4c7 commit e9ab47c

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎hoptimator-jdbc/src/main/java/com/linkedin/hoptimator/jdbc/TableService.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ public static void delete(Properties connectionProperties, List<String> path) th
106106

107107
DatabaseConfigResolver resolver = DatabaseConfigResolvers.forProperties(connectionProperties);
108108
String database = resolver.databaseName(path);
109-
Source source = new Source(database, path, Map.of());
109+
// Merge connection hints into the Source options, mirroring create(): deployers read their
110+
// configuration from source.options(), so an empty map here would strip hints that a deployer's
111+
// teardown may depend on.
112+
Map<String, String> tableOptions = new HashMap<>(DeploymentService.parseHints(connectionProperties));
113+
Source source = new Source(database, path, tableOptions);
110114
DeploymentContext context = new DirectDeploymentContext(connectionProperties, resolver);
111115

112116
Collection<Deployer> deployers = null;

‎hoptimator-jdbc/src/test/java/com/linkedin/hoptimator/jdbc/TableServiceTest.java‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,27 @@ void deleteRunsValidationAndDeployerTeardown() throws SQLException {
120120
deployment.verify(() -> DeploymentService.restore(any()), never());
121121
}
122122

123+
@Test
124+
void deleteMergesConnectionHintsIntoSourceOptions() throws SQLException {
125+
// Connection hints must reach deployers via source.options() on delete just as they do on create;
126+
// an empty options map would strip hints a deployer's teardown may depend on.
127+
Deployer deployer = mock(Deployer.class);
128+
List<Deployer> deployers = Collections.singletonList(deployer);
129+
DatabaseConfigResolver resolver = stubResolver();
130+
resolvers.when(() -> DatabaseConfigResolvers.forProperties(any())).thenReturn(resolver);
131+
deployment.when(() -> DeploymentService.parseHints(any()))
132+
.thenReturn(Map.of("hintKey", "hintValue"));
133+
deployment.when(() -> DeploymentService.deployers(any(Source.class), any(DeploymentContext.class)))
134+
.thenReturn(deployers);
135+
136+
TableService.delete(new Properties(), path);
137+
138+
ArgumentCaptor<Source> sourceCaptor = ArgumentCaptor.forClass(Source.class);
139+
deployment.verify(() ->
140+
DeploymentService.deployers(sourceCaptor.capture(), any(DeploymentContext.class)));
141+
assertThat(sourceCaptor.getValue().options()).containsEntry("hintKey", "hintValue");
142+
}
143+
123144
@Test
124145
void deleteRestoresAndRethrowsWhenTeardownFails() {
125146
Deployer deployer = mock(Deployer.class);

0 commit comments

Comments
 (0)