Repository navigation
[python] Load system tables and branch schemas in JDBC get_table - #10896
plusplusjiajia wants to merge 4 commits into
Conversation
| raise TableNotExistException(identifier) | ||
| table_path = self.get_table_path(identifier) | ||
| table_schema = self.get_table_schema(identifier) | ||
| table_identifier = identifier |
There was a problem hiding this comment.
[P2] Canonicalize accepted default-main identifiers
For Identifier("db", "t", branch="MAIN"), encoded_branch_name() returns None, so the new guard accepts it, but this assignment preserves the identifier’s cached "MAIN" branch. FileStoreTable.current_branch() then returns "MAIN", causing snapshot and read paths to target a nonexistent uppercase branch rather than main. I reproduced this after writing one row to main: the returned table had current_branch == "MAIN" and read []. Please normalize the base identifier for every accepted default-main input - not only system tables - and extend this test to perform an actual read.
There was a problem hiding this comment.
@Akash3121 Thanks, confirmed: the returned table kept the MAIN branch and read nothing. Fixed in 9cc196d: get_table now builds the table identifier without the system table or the default main branch spelling for every accepted input, and test_get_table_branch writes a row and reads it back through each main identifier, checking current_branch() is main.
69962fd to
f34b2f6
Compare
f34b2f6 to
36f771f
Compare
987f49c to
1384fd7
Compare
dc33090 to
89406ab
Compare
JdbcCatalog.get_table ignored the $ suffix of the identifier: for example
db.t$snapshots, db.t$options and db.t$nosuch all returned the data table,
and db.t$branch_dev returned a table with main's schema even when that
branch did not exist.
As in Java, system tables are now loaded through the shared system table
loader, as in the filesystem catalog, and unknown names raise
TableNotExistException. As in Java JdbcCatalog, a branch other than main
raises NotImplementedError; as in alter_table, only a branch in the name
counts, so Identifier('db', 't', branch='MAIN') still reads db.t.
… get_table
Identifier('db', 't', branch='MAIN') is accepted as the main branch, but
the returned table kept the MAIN branch, so it read a branch that does
not exist and returned no rows. The returned table now uses the
identifier without the system table or such a default main branch
spelling for every accepted input.
Rejecting every branch other than main in JdbcCatalog.get_table removed a working path: a branch table such as db.t$branch_dev reads and writes its own snapshots and data files, and the shared catalog guard test expected it to load. Branch tables are kept, and the two problems they had are fixed as in FileSystemCatalog: get_table_schema reads the schema of the identifier's branch, so a branch with its own schema changes is read with that schema and a branch that does not exist raises TableNotExistException, and db.t$branch_dev$options loads the system table of that branch. The returned table keeps the encoded branch, so a branch whose name is MAIN, which is not the main branch, keeps its identity, and keeps the branch of the identifier, as Java CatalogUtils.loadTable does, so a branch whose name has a '$', such as dev$blue, is not split into a branch and a system table.
A system table rebuilt its identifier with the branch argument of Identifier, which drops any case of main, so the options table of a branch named MAIN reloaded from its identifier read main. Such a branch is now encoded in the name; other branches keep the branch argument, so a branch whose name has a '$', such as dev$blue, is not split. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
89406ab to
ba20087
Compare
Purpose
JdbcCatalog.get_tableignored the$suffix of the identifier and the branch of the schema:db.t$snapshots,db.t$optionsanddb.t$nosuchall returned the data table;db.t$branch_devreturned a table even when that branch did not exist, and read a branch with its own schema changes with main's schema.As in Java
AbstractCatalog.getTableand PyPaimon's filesystem catalog:TableNotExistException;get_table_schemareads the schema of the identifier's branch, asFileSystemCatalog.get_table_schemadoes, so a branch table reads with its own schema, a branch that does not exist raisesTableNotExistException, anddb.t$branch_dev$optionsloads the system table of that branch;Identifier('db', 't', branch='MAIN'), return a table on the main branch, while a branch whose name isMAIN(db.t$branch_MAIN), which is not the main branch, keeps its identity, also in the identifier of its system tables;CatalogUtils.loadTabledoes, so a branch whose name has a$, such asdev$blue, is not split into a branch and a system table.Branch tables stay supported in PyPaimon's JDBC catalog, as before this change; Java's
JdbcCatalogdoes not support them.Tests
JdbcCatalogTest#test_get_system_table:$options,$OPTIONSand$branch_main$optionsload the options system table of the data table, by name and byIdentifier.JdbcCatalogTest#test_get_system_table_not_exist: unknown system tables and system tables of missing tables raiseTableNotExistException.JdbcCatalogTest#test_get_table_branch: a branch reads its own rows, keeps its own schema changes and options and loads its own$options; every main identifier, includingIdentifier('db', 't', branch='MAIN'), reads main; missing branches and tables raiseTableNotExistException; a branch namedMAIN, as left by earlier versions, and its$optionsstay on that branch when their identifiers are reused; a branch nameddev$bluekeeps its name.catalog_table_guard_test.py: the shared guard test still loads$branch_devfor JDBC.