plusplusjiajia opened a new pull request, #10915:
URL: https://github.com/apache/paimon/pull/10915

   ### Purpose
   
   `Identifier` treats any case of `main` as the default branch and drops it 
from the encoded name, but `BranchManager.isMainBranch` is case-sensitive and 
branch creation only rejected the exact name `main`:
   
   - a branch named `MAIN` could be created, and every identifier rebuilt from 
its parts, such as the base table of `db.t$branch_MAIN$options`, lost the 
branch and resolved to main;
   - an encoded identifier with a blank branch, such as `db.t$branch_`, was 
loaded as the main branch, so a caller could write to main through an invalid 
branch identifier.
   
   In Java and PyPaimon:
   
   - creating a branch, or renaming one, to `main` in any case is rejected with 
the existing "is the default branch" message, also with `ignoreIfExists` and in 
the REST catalog client;
   - loading a table through an identifier with a blank branch raises 
`TableNotExistException`;
   - the identifier of a system table's base table, including the one used for 
REST data tokens, is derived from the encoded name through the new 
`Identifier.withoutSystemTable()` / `without_system_table()`, so an existing 
branch named `MAIN` keeps its branch. `Identifier`'s equality and JSON form are 
unchanged.
   
   ### Tests
   
   - `IdentifierTest` / `identifier_test.py`: `withoutSystemTable` keeps a 
`MAIN` branch, drops `main`, and returns non-system identifiers unchanged.
   - `FileSystemBranchManagerTest`, `branch_manager_test.py`, 
`filesystem_catalog_branch_test.py`, `file_store_table_test.py`: `main`, `MAIN` 
and `Main` are rejected on create, create with `ignoreIfExists` and rename; an 
existing branch is still skipped with `ignoreIfExists`.
   - `CatalogTestBase`, `JdbcCatalogTest`, `filesystem_catalog_branch_test.py`, 
`jdbc_catalog_test.py`: identifiers with an empty or blank branch raise 
`TableNotExistException`.
   - `RESTCatalogTest`: the REST client rejects `MAIN` with `ignoreIfExists`.
   - `RESTTokenFileIOTest`, `system_table_test.py`: the token request and the 
system table identifier keep the `MAIN` branch.
   - The new PyPaimon tests fail without this change. `IdentifierTest`, 
`RESTTokenFileIOTest`, `FileSystemBranchManagerTest`, `FileSystemCatalogTest`, 
`CachingCatalogTest`, `JdbcCatalogTest` and `MockRESTCatalogTest` (429 tests) 
and the related PyPaimon catalog, branch and system table tests (474 passed, 6 
skipped) pass locally; flake8 is clean.
   


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