mchades opened a new pull request, #11597:
URL: https://github.com/apache/gravitino/pull/11597

   Fix https://github.com/apache/gravitino/issues/10909
   
   ### What changes were proposed in this pull request?
   
   Fix the `list*`/`load*` inconsistency for MySQL schemas and tables whose 
names contain dots (e.g. a MySQL database named `db.v2` created externally with 
`` CREATE DATABASE `db.v2` ``).
   
   - `GenericSchema`: replace `MetadataObjects.of(String parent, String name, 
Type)` with `MetadataObjects.of(List, Type)`, consistent with `GenericFileset`, 
`GenericTopic`, and `GenericModel`.
   - `RelationalTable`: replace `MetadataObjects.parse(tableFullName(...), 
TABLE)` with `MetadataObjects.of(List, TABLE)`, and remove the now-unused 
`tableFullName()` helper and `DOT_JOINER` field.
   
   ### Why are the changes needed?
   
   `MetadataObjects.of(String parent, String name, Type)` joins parent and name 
with `.` then re-parses by splitting on `.`. When `name` itself contains a dot 
(e.g. `"db.v2"`), the split produces too many segments and the length check 
throws `IllegalArgumentException`:
   
   ```
   IllegalArgumentException: If the type is SCHEMA, the length of names must be 
2
     at GenericSchema.<init>(GenericSchema.java:48)
     at BaseSchemaCatalog.loadSchema(BaseSchemaCatalog.java:216)
   ```
   
   `listSchemas()` had already returned the dotted name successfully, so 
`loadSchema()` crashing breaks the `list*`/`load*` contract.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No API changes. Bug fix only: `loadSchema` and `loadTable` now correctly 
handle names containing dots, consistent with what `listSchemas`/`listTables` 
already returns.
   
   ### How was this patch tested?
   
   Added `testObjectNamesWithDots()` to `CatalogMysqlIT` 
(`@Tag("gravitino-docker-test")`). The test:
   1. Creates a MySQL database with a dot in its name directly via JDBC.
   2. Asserts `listSchemas()` returns that schema.
   3. Asserts `loadSchema()` succeeds for the same name.
   4. Creates a table in that schema directly via JDBC.
   5. Asserts `listTables()` returns the table.
   6. Asserts `loadTable()` succeeds for the same name.


-- 
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]

Reply via email to