PDGGK opened a new pull request, #14573:
URL: https://github.com/apache/gravitino/pull/14573
### What changes were proposed in this pull request?
`PaimonSchema.toPaimonProperties()` now returns a copy of the schema
properties with the schema comment added under the reserved `comment` property.
`PaimonCatalogOperations.createSchema` passes this map to Paimon's
`createDatabase`, so the comment is written to the Paimon database.
`comment` is the key Paimon defines for database comments
(`Catalog.COMMENT_PROP`), and it is the key `PaimonSchema.fromPaimonProperties`
already reads in `loadSchema`. `IcebergSchema.toCreateRequest` stores the
comment of an Iceberg namespace the same way.
### Why are the changes needed?
A Paimon schema created with a comment loses the comment. The create
response still shows it, because that response is built from the request. But
`createSchema` passed only the user properties to Paimon, so the comment was
never stored, and every later load returns `comment: null`. #5719 shows this on
the JDBC backend.
The Paimon catalog docs say that only the filesystem backend cannot store
schema comments, but the code dropped them on every backend. This change makes
the code match the docs. The catalog already declares `comment` as a reserved,
hidden schema property, and `loadSchema` already reads it from there.
Reproduction on the 1.3.1 Docker image (`apache/gravitino:1.3.1`), with a
Paimon catalog using `catalog-backend=jdbc` on PostgreSQL 16:
```
POST /api/metalakes/repro_ml/catalogs/paimon_jdbc/schemas
{"name":"sales","comment":"Sales data owned by the finance
team","properties":{"owner-team":"finance"}}
-> code=0 name=sales comment='Sales data owned by the finance team'
properties={'owner-team': 'finance'}
GET /api/metalakes/repro_ml/catalogs/paimon_jdbc/schemas/sales
-> code=0 name=sales comment=None properties={'owner-team': 'finance',
'location': 'file:/tmp/paimon_wh/sales.db'}
SELECT property_key, property_value FROM paimon_database_properties WHERE
database_name = 'sales';
exists | true
gravitino.identifier | gravitino.v1.uid3161155087733269982
location | file:/tmp/paimon_wh/sales.db
owner-team | finance
```
I then compiled this change into
`gravitino-catalog-lakehouse-paimon-1.3.1.jar` and repeated the same steps on
the same image. `PaimonSchema.java` is identical on 1.3.1 and `main`.
```
GET /api/metalakes/repro_ml/catalogs/paimon_jdbc/schemas/sales
-> code=0 name=sales comment='Sales data owned by the finance team'
properties={'owner-team': 'finance', 'location': 'file:/tmp/paimon_wh/sales.db'}
SELECT property_key, property_value FROM paimon_database_properties WHERE
database_name = 'sales';
comment | Sales data owned by the finance team
exists | true
gravitino.identifier | gravitino.v1.uid3969426464095332289
location | file:/tmp/paimon_wh/sales.db
owner-team | finance
```
Fixes #5719
### Does this PR introduce _any_ user-facing change?
Yes. On backends that store database properties, a schema comment is now
persisted and returned when the schema is loaded. This was checked on the JDBC
backend. Paimon's `HiveCatalog` maps the same `comment` property to the Hive
database description, but I did not run this change against a Hive metastore.
The filesystem backend behaves as before: Paimon logs that it cannot store
database properties and discards them, as the docs already say. `comment` stays
hidden from the returned schema properties. There are no API or property key
changes.
### How was this patch tested?
- The new test `TestPaimonSchema#testLoadSchemaCommentWithJdbcBackend`
creates one schema with a comment and one without on a JDBC backend (in-memory
H2), then loads both back. Without the change, it fails with `expected:
<comment> but was: <null>`.
- `./gradlew :catalogs:catalog-lakehouse-paimon:test -PskipITs`, run with
`--tests` for `TestPaimonSchema`, `TestPaimonCatalog`,
`TestGravitinoPaimonTable`, `TestPaimonCatalogPropertiesMetadata` and
`ops.TestPaimonCatalogOps`: 47 tests, 0 failures.
- `./gradlew :catalogs:catalog-lakehouse-paimon:spotlessCheck
:catalogs:catalog-lakehouse-paimon:javadoc` passes.
- I ran the manual check on the 1.3.1 image shown above. On the same patched
server, I also checked two other cases:
- A filesystem-backend catalog still creates a schema with a comment, and
loading it returns no comment, as before.
- A JDBC schema created without a comment loads with `comment=None` and
has no `comment` row in the database.
- I left the Paimon integration tests (`CatalogPaimon*IT`) to CI.
--
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]