Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#5094] Fix(catalog-lakehouse-paimon): make some table properties from reserved to immutable #5095

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.gravitino.catalog.lakehouse.paimon;

import static org.apache.gravitino.connector.PropertyEntry.stringImmutablePropertyEntry;
import static org.apache.gravitino.connector.PropertyEntry.stringReservedPropertyEntry;

import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -51,9 +52,12 @@ public class PaimonTablePropertiesMetadata extends BasePropertiesMetadata {
stringReservedPropertyEntry(COMMENT, "The table comment", true),
stringReservedPropertyEntry(OWNER, "The table owner", false),
stringReservedPropertyEntry(BUCKET_KEY, "The table bucket key", false),
stringReservedPropertyEntry(MERGE_ENGINE, "The table merge engine", false),
stringReservedPropertyEntry(SEQUENCE_FIELD, "The table sequence field", false),
stringReservedPropertyEntry(ROWKIND_FIELD, "The table rowkind field", false),
stringImmutablePropertyEntry(
MERGE_ENGINE, "The table merge engine", false, null, false, false),
stringImmutablePropertyEntry(
SEQUENCE_FIELD, "The table sequence field", false, null, false, false),
stringImmutablePropertyEntry(
ROWKIND_FIELD, "The table rowkind field", false, null, false, false),
stringReservedPropertyEntry(PRIMARY_KEY, "The table primary key", false),
stringReservedPropertyEntry(PARTITION, "The table partition", false));
PROPERTIES_METADATA = Maps.uniqueIndex(propertyEntries, PropertyEntry::getName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,43 +382,60 @@ void testTableProperty() {
try (PaimonCatalogOperations ops = new PaimonCatalogOperations()) {
ops.initialize(
initBackendCatalogProperties(), entity.toCatalogInfo(), PAIMON_PROPERTIES_METADATA);
Map<String, String> map = Maps.newHashMap();
map.put(PaimonTablePropertiesMetadata.COMMENT, "test");
map.put(PaimonTablePropertiesMetadata.OWNER, "test");
map.put(PaimonTablePropertiesMetadata.BUCKET_KEY, "test");
map.put(PaimonTablePropertiesMetadata.MERGE_ENGINE, "test");
map.put(PaimonTablePropertiesMetadata.SEQUENCE_FIELD, "test");
map.put(PaimonTablePropertiesMetadata.ROWKIND_FIELD, "test");
map.put(PaimonTablePropertiesMetadata.PRIMARY_KEY, "test");
map.put(PaimonTablePropertiesMetadata.PARTITION, "test");
for (Map.Entry<String, String> entry : map.entrySet()) {
HashMap<String, String> reservedProps =
new HashMap<String, String>() {
{
put(PaimonTablePropertiesMetadata.COMMENT, "test");
put(PaimonTablePropertiesMetadata.OWNER, "test");
put(PaimonTablePropertiesMetadata.BUCKET_KEY, "test");
put(PaimonTablePropertiesMetadata.PRIMARY_KEY, "test");
put(PaimonTablePropertiesMetadata.PARTITION, "test");
}
};
Assertions.assertThrows(
IllegalArgumentException.class,
() ->
PropertiesMetadataHelpers.validatePropertyForCreate(
paimonCatalog.tablePropertiesMetadata(), reservedProps));
Assertions.assertThrows(
IllegalArgumentException.class,
() ->
PropertiesMetadataHelpers.validatePropertyForAlter(
paimonCatalog.tablePropertiesMetadata(), reservedProps, Collections.emptyMap()));
Assertions.assertThrows(
IllegalArgumentException.class,
() ->
PropertiesMetadataHelpers.validatePropertyForAlter(
paimonCatalog.tablePropertiesMetadata(), Collections.emptyMap(), reservedProps));

Map<String, String> immutableProps =
new HashMap<String, String>() {
{
put(PaimonTablePropertiesMetadata.MERGE_ENGINE, "test");
put(PaimonTablePropertiesMetadata.SEQUENCE_FIELD, "test");
put(PaimonTablePropertiesMetadata.ROWKIND_FIELD, "test");
}
};
for (Map.Entry<String, String> entry : immutableProps.entrySet()) {
HashMap<String, String> properties =
new HashMap<String, String>() {
{
put(entry.getKey(), entry.getValue());
}
};
PropertiesMetadata metadata = paimonCatalog.tablePropertiesMetadata();
Assertions.assertDoesNotThrow(
() -> PropertiesMetadataHelpers.validatePropertyForCreate(metadata, properties));
Assertions.assertThrows(
IllegalArgumentException.class,
() -> PropertiesMetadataHelpers.validatePropertyForCreate(metadata, properties));
}

map = Maps.newHashMap();
map.put("key1", "val1");
map.put("key2", "val2");
for (Map.Entry<String, String> entry : map.entrySet()) {
HashMap<String, String> properties =
new HashMap<String, String>() {
{
put(entry.getKey(), entry.getValue());
}
};
PropertiesMetadata metadata = paimonCatalog.tablePropertiesMetadata();
Assertions.assertDoesNotThrow(
() -> {
PropertiesMetadataHelpers.validatePropertyForCreate(metadata, properties);
});
() ->
PropertiesMetadataHelpers.validatePropertyForAlter(
metadata, properties, Collections.emptyMap()));
Assertions.assertThrows(
IllegalArgumentException.class,
() ->
PropertiesMetadataHelpers.validatePropertyForAlter(
metadata, Collections.emptyMap(), properties));
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions docs/lakehouse-paimon-catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,16 @@ The Gravitino server doesn't allow passing the following reserved fields.
| `comment` | The table comment. |
| `owner` | The table owner. |
| `bucket-key` | The table bucket-key. |
| `primary-key` | The table primary-key. |
| `partition` | The table partition. |
FANNG1 marked this conversation as resolved.
Show resolved Hide resolved

The Gravitino server doesn't allow the following immutable fields to be modified, but allows them to be specified when creating a new table.

| Configuration item | Description |
|------------------------------------|--------------------------------------------------------------|
| `merge-engine` | The table merge-engine. |
| `sequence.field` | The table sequence.field. |
| `rowkind.field` | The table rowkind.field. |
| `primary-key` | The table primary-key. |
| `partition` | The table partition. |

### Table operations

Expand Down
Loading