This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 5a54d6ad5f [core] Support options in ObjectTable (#7378)
5a54d6ad5f is described below
commit 5a54d6ad5f449a2488c2dff3a3c05a7a67b809d6
Author: shyjsarah <[email protected]>
AuthorDate: Tue Mar 10 11:21:53 2026 +0800
[core] Support options in ObjectTable (#7378)
---
.../org/apache/paimon/catalog/CatalogUtils.java | 1 +
.../apache/paimon/table/object/ObjectTable.java | 9 +++++++-
.../paimon/table/object/ObjectTableImpl.java | 15 +++++++++---
.../org/apache/paimon/rest/RESTCatalogTest.java | 27 ++++++++++++++++++++--
4 files changed, 46 insertions(+), 6 deletions(-)
diff --git
a/paimon-core/src/main/java/org/apache/paimon/catalog/CatalogUtils.java
b/paimon-core/src/main/java/org/apache/paimon/catalog/CatalogUtils.java
index 3059af4d5e..a33dc2c0c1 100644
--- a/paimon-core/src/main/java/org/apache/paimon/catalog/CatalogUtils.java
+++ b/paimon-core/src/main/java/org/apache/paimon/catalog/CatalogUtils.java
@@ -439,6 +439,7 @@ public class CatalogUtils {
.fileIO(fileIO.apply(new Path(location)))
.identifier(identifier)
.location(location)
+ .options(options)
.comment(schema.comment())
.build();
}
diff --git
a/paimon-core/src/main/java/org/apache/paimon/table/object/ObjectTable.java
b/paimon-core/src/main/java/org/apache/paimon/table/object/ObjectTable.java
index 9aae4dd10a..98c95d6d8e 100644
--- a/paimon-core/src/main/java/org/apache/paimon/table/object/ObjectTable.java
+++ b/paimon-core/src/main/java/org/apache/paimon/table/object/ObjectTable.java
@@ -24,6 +24,7 @@ import org.apache.paimon.table.Table;
import org.apache.paimon.types.DataTypes;
import org.apache.paimon.types.RowType;
+import java.util.Collections;
import java.util.Map;
/**
@@ -61,6 +62,7 @@ public interface ObjectTable extends Table {
private Identifier identifier;
private FileIO fileIO;
private String location;
+ private Map<String, String> options = Collections.emptyMap();
private String comment;
public ObjectTable.Builder identifier(Identifier identifier) {
@@ -78,13 +80,18 @@ public interface ObjectTable extends Table {
return this;
}
+ public ObjectTable.Builder options(Map<String, String> options) {
+ this.options = options;
+ return this;
+ }
+
public ObjectTable.Builder comment(String comment) {
this.comment = comment;
return this;
}
public ObjectTable build() {
- return new ObjectTableImpl(identifier, fileIO, location, comment);
+ return new ObjectTableImpl(identifier, fileIO, location, options,
comment);
}
}
}
diff --git
a/paimon-core/src/main/java/org/apache/paimon/table/object/ObjectTableImpl.java
b/paimon-core/src/main/java/org/apache/paimon/table/object/ObjectTableImpl.java
index 1c95708d46..83f3c53536 100644
---
a/paimon-core/src/main/java/org/apache/paimon/table/object/ObjectTableImpl.java
+++
b/paimon-core/src/main/java/org/apache/paimon/table/object/ObjectTableImpl.java
@@ -46,6 +46,7 @@ import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -61,13 +62,19 @@ public class ObjectTableImpl implements ReadonlyTable,
ObjectTable {
private final Identifier identifier;
private final FileIO fileIO;
private final String location;
+ private final Map<String, String> options;
@Nullable private final String comment;
public ObjectTableImpl(
- Identifier identifier, FileIO fileIO, String location, @Nullable
String comment) {
+ Identifier identifier,
+ FileIO fileIO,
+ String location,
+ Map<String, String> options,
+ @Nullable String comment) {
this.identifier = identifier;
this.fileIO = fileIO;
this.location = location;
+ this.options = options;
this.comment = comment;
}
@@ -98,7 +105,7 @@ public class ObjectTableImpl implements ReadonlyTable,
ObjectTable {
@Override
public Map<String, String> options() {
- return Collections.emptyMap();
+ return options;
}
@Override
@@ -123,7 +130,9 @@ public class ObjectTableImpl implements ReadonlyTable,
ObjectTable {
@Override
public ObjectTable copy(Map<String, String> dynamicOptions) {
- return new ObjectTableImpl(identifier, fileIO, location, comment);
+ Map<String, String> newOptions = new HashMap<>(options);
+ newOptions.putAll(dynamicOptions);
+ return new ObjectTableImpl(identifier, fileIO, location, newOptions,
comment);
}
@Override
diff --git
a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
index d2586b92e1..dda98cda0c 100644
--- a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
@@ -2697,15 +2697,38 @@ public abstract class RESTCatalogTest extends
CatalogTestBase {
@Test
public void testObjectTable() throws Exception {
- // create object table
+ // create object table with custom options
catalog.createDatabase("test_db", false);
Identifier identifier = Identifier.create("test_db", "object_table");
- Schema schema = Schema.newBuilder().option(TYPE.key(),
OBJECT_TABLE.toString()).build();
+ Schema schema =
+ Schema.newBuilder()
+ .option(TYPE.key(), OBJECT_TABLE.toString())
+ .option("custom-key", "custom-value")
+ .build();
catalog.createTable(identifier, schema, false);
Table table = catalog.getTable(identifier);
assertThat(table).isInstanceOf(ObjectTable.class);
ObjectTable objectTable = (ObjectTable) table;
+ // verify options are preserved
+ assertThat(objectTable.options()).containsEntry("custom-key",
"custom-value");
+ assertThat(objectTable.options().containsKey("path")).isTrue();
+
+ // verify copy merges dynamic options
+ ObjectTable copiedTable =
+ objectTable.copy(Collections.singletonMap("dynamic-key",
"dynamic-value"));
+ assertThat(copiedTable.options()).containsEntry("custom-key",
"custom-value");
+ assertThat(copiedTable.options()).containsEntry("dynamic-key",
"dynamic-value");
+
+ // verify copy can override existing options
+ ObjectTable overriddenTable =
+ objectTable.copy(Collections.singletonMap("custom-key",
"overridden"));
+ assertThat(overriddenTable.options()).containsEntry("custom-key",
"overridden");
+
+ // verify original table is not modified after copy
+ assertThat(objectTable.options()).containsEntry("custom-key",
"custom-value");
+ assertThat(objectTable.options()).doesNotContainKey("dynamic-key");
+
// write file to object path
FileIO fileIO = objectTable.fileIO();
Path path = new Path(objectTable.location());