Skip to content

Commit 7916b62

Browse files
committed
[fix](fe) Allow unrelated alters on legacy HA catalogs
### What problem does this PR solve? Issue Number: None Related PR: #68585 Problem Summary: A legacy HMS catalog can contain an empty HDFS nameservice list, such as `dfs.nameservices=,`. Runtime binding tolerates this persisted value, but ALTER validation checked the merged catalog properties and rejected even an unrelated statement such as `ALTER CATALOG ... SET PROPERTIES ("test_connection"="false")`. Validate empty nameservice values against the properties submitted by the current statement. CREATE and ALTER still reject explicitly submitted empty values, while unrelated ALTERs preserve legacy values. The complete merged configuration continues through storage binding and HA validation. ### Release note Allow unrelated property changes on legacy Hive catalogs containing an empty HDFS nameservice list. ### Check List (For Author) - Test - [x] Unit Test - Added `PluginDrivenExternalCatalogConcurrencyTest` coverage for legacy comma-only, whitespace, and empty-string nameservice values during unrelated ALTERs, and explicit CREATE/ALTER rejection of these values. - Community FE UT and COMPILE passed on commit `2fcc2ef6e0c93582414a50037394f094012f34f9`. - Local focused FE UT compiled and reached execution, but all 18 tests failed during Mockito initialization because the inline mock maker could not self-attach. This local run is not counted as passing. - [x] Regression test - Community External, P0, NonConcurrent, Cloud P0, and Vault P0 checks passed on the same commit. No new regression suite was added; the legacy persisted-property case is covered by FE unit tests. - Behavior changed: - [ ] No. - [x] Yes. Unrelated ALTERs accept legacy empty nameservice values; explicitly submitted empty values remain rejected. - Does this need documentation? - [x] No. - [ ] Yes.
1 parent 7d23148 commit 7916b62

2 files changed

Lines changed: 40 additions & 5 deletions

File tree

‎fe/fe-core/src/main/java/org/apache/doris/datasource/plugin/PluginDrivenExternalCatalog.java‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public void checkProperties() throws DdlException {
232232
} catch (IllegalArgumentException e) {
233233
throw new DdlException(e.getMessage());
234234
}
235-
validateStorageProperties(catalogProperty);
235+
validateStorageProperties(catalogProperty, catalogProperty.getProperties());
236236
// Validate function_rules JSON if present (shared across all connector types).
237237
String functionRules = catalogProperty.getOrDefault("function_rules", null);
238238
ExternalFunctionRules.check(functionRules);
@@ -256,7 +256,7 @@ public boolean validatePropertiesBeforeUpdate(
256256
} catch (IllegalArgumentException e) {
257257
throw new DdlException(e.getMessage(), e);
258258
}
259-
validateStorageProperties(candidateProperty);
259+
validateStorageProperties(candidateProperty, updatedProperties);
260260
checkDriverUrlsAgainstOperatorGate(candidate, updatedProperties);
261261
ExternalFunctionRules.check(candidateProperty.getOrDefault("function_rules", null));
262262
return true;
@@ -266,13 +266,15 @@ public boolean validatePropertiesBeforeUpdate(
266266
* Bind Hive catalog storage properties during DDL validation so HDFS configuration errors are
267267
* reported by CREATE/ALTER instead of being deferred until the first table access.
268268
*/
269-
private void validateStorageProperties(CatalogProperty property) throws DdlException {
269+
private void validateStorageProperties(CatalogProperty property, Map<String, String> submittedProperties)
270+
throws DdlException {
270271
if (!"hms".equalsIgnoreCase(getType())) {
271272
return;
272273
}
273-
String nameservices = property.getProperties().get("dfs.nameservices");
274+
// Reject newly submitted empty values without blocking unrelated ALTERs of legacy catalogs.
275+
String nameservices = submittedProperties.get("dfs.nameservices");
274276
if (nameservices != null
275-
&& java.util.Arrays.stream(nameservices.split(","))
277+
&& Arrays.stream(nameservices.split(","))
276278
.map(String::trim).noneMatch(value -> !value.isEmpty())) {
277279
throw new DdlException("Property dfs.nameservices must contain a nameservice");
278280
}

‎fe/fe-core/src/test/java/org/apache/doris/datasource/plugin/PluginDrivenExternalCatalogConcurrencyTest.java‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,39 @@ public void testAlterRejectsIncompleteHiveHaConfiguration() {
123123
Assertions.assertTrue(exception.getMessage().contains("dfs.ha.namenodes.ns1"), exception.getMessage());
124124
}
125125

126+
@Test
127+
public void testAlterPreservesLegacyEmptyNameservices() throws Exception {
128+
for (String nameservices : new String[] {",", " ", ""}) {
129+
Map<String, String> properties = hiveCatalogProperties();
130+
properties.put("dfs.nameservices", nameservices);
131+
PluginDrivenExternalCatalog catalog = new PluginDrivenExternalCatalog(
132+
1L, "test-catalog", null, properties, "", null);
133+
134+
Assertions.assertTrue(catalog.validatePropertiesBeforeUpdate(properties,
135+
Collections.singletonMap("test_connection", "false")));
136+
Assertions.assertEquals(nameservices, catalog.getProperties().get("dfs.nameservices"));
137+
}
138+
}
139+
140+
@Test
141+
public void testDdlRejectsSubmittedEmptyNameservices() {
142+
for (String nameservices : new String[] {",", " ", ""}) {
143+
Map<String, String> properties = hiveCatalogProperties();
144+
PluginDrivenExternalCatalog catalog = new PluginDrivenExternalCatalog(
145+
1L, "test-catalog", null, properties, "", null);
146+
DdlException alterException = Assertions.assertThrows(DdlException.class,
147+
() -> catalog.validatePropertiesBeforeUpdate(properties,
148+
Collections.singletonMap("dfs.nameservices", nameservices)));
149+
Assertions.assertTrue(alterException.getMessage().contains("dfs.nameservices"));
150+
151+
properties.put("dfs.nameservices", nameservices);
152+
PluginDrivenExternalCatalog createCatalog = new PluginDrivenExternalCatalog(
153+
2L, "create-catalog", null, properties, "", null);
154+
DdlException createException = Assertions.assertThrows(DdlException.class, createCatalog::checkProperties);
155+
Assertions.assertTrue(createException.getMessage().contains("dfs.nameservices"));
156+
}
157+
}
158+
126159
private static Map<String, String> hiveCatalogProperties() {
127160
Map<String, String> properties = new HashMap<>();
128161
properties.put("type", "hms");

0 commit comments

Comments
 (0)