This is an automated email from the ASF dual-hosted git repository.
yuqi1129 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new fa83cb8c7a [MINOR] fix(lance): Keep catalog storage options when a
table sets the same key (#14895)
fa83cb8c7a is described below
commit fa83cb8c7a960e81c54536645f957fe5af6f9434
Author: Qi Yu <[email protected]>
AuthorDate: Thu Nov 12 20:13:18 2026 +0800
[MINOR] fix(lance): Keep catalog storage options when a table sets the same
key (#14895)
### What changes were proposed in this pull request?
`LancePropertiesUtils.resolveLanceStorageOptions` now keeps the catalog
value for any `lance.storage.*` key that the catalog sets. Table
properties can only add keys that the catalog does not set.
### Why are the changes needed?
Table properties come from the table creator. Catalog storage options
usually hold the server's credentials. A user with `CREATE_TABLE` could
register a table with `lance.storage.endpoint` (or a similar key) set to
another address. The server then opens that table with the catalog
credentials and sends signed requests to the address the user chose.
Describe also returned the table value. This was found while checking
#13696.
### Does this PR introduce _any_ user-facing change?
Yes. A table property can no longer override a storage option that the
catalog sets. Tables that need a different endpoint or credentials
should use a separate catalog. The docs are updated.
### How was this patch tested?
- Updated `TestLancePropertiesUtils`.
- `TestLanceTableOperations`, `LanceRESTServiceIT`,
`LanceTableAuthorizationIT` and `CatalogGenericCatalogLanceIT`
(embedded) pass.
---
docs/lakehouse-generic-lance-table.md | 5 ++++-
.../gravitino/lance/common/utils/LancePropertiesUtils.java | 10 +++++++---
.../gravitino/lance/common/utils/TestLancePropertiesUtils.java | 5 +++--
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/docs/lakehouse-generic-lance-table.md
b/docs/lakehouse-generic-lance-table.md
index 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.java
index 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.java
index 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(