justinmclean opened a new issue, #10325:
URL: https://github.com/apache/gravitino/issues/10325
### What would you like to be improved?
When altering a schema on the non-managed path, SchemaOperationDispatcher
updates the stored SchemaEntity by building a new entity with only id, name,
namespace, and auditInfo. Persisted comment and properties are omitted, and
storage update semantics write those fields from the new object, which can
null/erase previously stored schema metadata. This is reproducible by creating
a schema with comment/properties, altering it, then reading the stored
SchemaEntity.
### How should we improve?
In the updater lambda inside alterSchema, preserve metadata fields when
building the updated entity. At minimum, carry forward and/or refresh:
- comment (e.g., from current entity or altered schema)
- properties (e.g., from alteredSchema.properties())
Here a unit test to help:
```
@Test
public void testAlterSchemaKeepsStoredCommentAndProperties() throws
IOException {
NameIdentifier schemaIdent = NameIdentifier.of(metalake, catalog,
"schema_preserve_metadata");
Map<String, String> props = ImmutableMap.of("k1", "v1", "k2", "v2");
dispatcher.createSchema(schemaIdent, "comment", props);
SchemaChange[] changes =
new SchemaChange[] {
SchemaChange.setProperty("k3", "v3"),
SchemaChange.removeProperty("k1")
};
dispatcher.alterSchema(schemaIdent, changes);
SchemaEntity storedSchema = entityStore.get(schemaIdent, SCHEMA,
SchemaEntity.class);
Assertions.assertEquals("comment", storedSchema.comment());
Assertions.assertEquals(ImmutableMap.of("k2", "v2", "k3", "v3"),
storedSchema.properties());
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]