World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[MINOR] fix(lance): Keep catalog storage options when a table sets the same key (#14895)
Qi Yufa83cb8c7a96
diff --git a/docs/lakehouse-generic-lance-table.md b/docs/lakehouse-generic-lance-table.mdindex 8908a1d20d..02cdcc6579 100644--- a/docs/lakehouse-generic-lance-table.md+++ b/docs/lakehouse-generic-lance-table.md@@ -472,4 +472,7 @@ curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \```-If you need to override storage on a single table, `lance.storage.*` table properties are still supported.+A table can add `lance.storage.*` table properties for keys that the catalog does not set. If the+catalog sets a key, the catalog value is used, and the table value is ignored. This prevents a table+creator from sending the catalog credentials to another endpoint. Put tables that need a different+endpoint or credentials in a separate catalog.diff --git a/lance/lance-common/src/main/java/org/apache/gravitino/lance/common/utils/LancePropertiesUtils.java b/lance/lance-common/src/main/java/org/apache/gravitino/lance/common/utils/LancePropertiesUtils.javaindex 29cb5db621..22a2415b27 100644--- a/lance/lance-common/src/main/java/org/apache/gravitino/lance/common/utils/LancePropertiesUtils.java+++ b/lance/lance-common/src/main/java/org/apache/gravitino/lance/common/utils/LancePropertiesUtils.java@@ -106,8 +106,12 @@ public final class LancePropertiesUtils {}/**- * Resolves the effective Lance storage options using table properties first and catalog- * properties as defaults.+ * Resolves the effective Lance storage options. A key set in the catalog properties keeps the+ * catalog value; table properties can only add keys that the catalog does not set.+ *+ * <p>Table properties come from the table creator, while catalog storage options usually hold the+ * server's credentials. If a table could override a catalog key such as the endpoint, the server+ * would send requests signed with the catalog credentials to a location the table creator chose.** @param catalogProperties the catalog properties* @param tableProperties the table properties@@ -117,7 +121,7 @@ public final class LancePropertiesUtils {Map<String, String> catalogProperties, Map<String, String> tableProperties) {Map<String, String> effectiveStorageOptions =new LinkedHashMap<>(getLanceStorageOptions(catalogProperties));- effectiveStorageOptions.putAll(getLanceStorageOptions(tableProperties));+ getLanceStorageOptions(tableProperties).forEach(effectiveStorageOptions::putIfAbsent);return effectiveStorageOptions;}diff --git a/lance/lance-common/src/test/java/org/apache/gravitino/lance/common/utils/TestLancePropertiesUtils.java b/lance/lance-common/src/test/java/org/apache/gravitino/lance/common/utils/TestLancePropertiesUtils.javaindex 128f352b61..3f10be3f82 100644--- a/lance/lance-common/src/test/java/org/apache/gravitino/lance/common/utils/TestLancePropertiesUtils.java+++ b/lance/lance-common/src/test/java/org/apache/gravitino/lance/common/utils/TestLancePropertiesUtils.java@@ -111,7 +111,7 @@ public class TestLancePropertiesUtils {}@Test- public void testResolveLanceStorageOptionsPrefersTableProperties() {+ public void testResolveLanceStorageOptionsKeepsCatalogValues() {Map<String, String> catalogProperties =ImmutableMap.of("lance.storage.endpoint", "http://catalog:9000",@@ -125,7 +125,8 @@ public class TestLancePropertiesUtils {LancePropertiesUtils.resolveLanceStorageOptions(catalogProperties, tableProperties);Assertions.assertEquals(3, storageOptions.size());- Assertions.assertEquals("http://table:9000", storageOptions.get("endpoint"));+ // The table cannot redirect the catalog credentials to another endpoint.+ Assertions.assertEquals("http://catalog:9000", storageOptions.get("endpoint"));Assertions.assertEquals("us-east-1", storageOptions.get("region"));Assertions.assertEquals("table-ak", storageOptions.get("access_key_id"));Assertions.assertEquals(