morningman opened a new pull request, #70735:
URL: https://github.com/apache/doris/pull/70735

   ### Background
   
   Flight SQL clients discover catalogs, schemas and tables through metadata 
commands and read the resulting Arrow rows with DoGet. The protocol defines the 
row order, while Doris uses FE metadata services to determine visible objects.
   
   ### What problem does this PR solve?
   
   Issue Number: #67578
   Related PR: #46217 (introduced metadata helper), #70176 (complementary 
catalog-filter and loopback fixes)
   PR Type: Bugfix
   
   Problem Summary:
   
   Metadata follows map enumeration order, and GetCatalogs returns catalogs 
that SHOW CATALOGS hides from the same user. Sort metadata by the protocol keys 
and reuse the existing catalog visibility check with authenticated session 
roles. Most of the diff adds tests, including a regression that records wire 
order without sorting it on the client.
   
   For a user allowed to see only the fixture catalog `flight_order_a` and 
`internal`:
   
   | GetCatalogs before | GetCatalogs after |
   | --- | --- |
   | `internal;flight_order_z;flight_order_a` | `flight_order_a;internal` |
   
   ### Details
   
   - **Change map:** Production code +33/-25; tests +376/-0; generated 
regression output +31/-0; no documentation or build changes. The helper handles 
catalog visibility and ordered emission; the tests cover exact tuples, role 
propagation and schema associations.
   - **Frequency:** Always when catalog enumeration contains an unauthorized 
catalog; ordering differs whenever the underlying enumeration is not already 
sorted. Both were reproduced locally.
   - **Root cause:** The helper forces internal first and then preserves 
unordered service results. GetCatalogs enumerates all catalogs without the 
shared SHOW visibility check.
   - **Why existing tests missed it:** Helper table-type tests supply sorted 
fixtures and mock metadata services. The table-type regression sorts client 
results before comparison; schema discovery tests check types rather than 
metadata row order. They do not check GetCatalogs as a restricted user.
   - **Fix:** Sort authorized catalog names, preserve catalog/schema pairs 
while sorting, and sort filtered tables before describing them. Obtain a 
request-scoped identity through the existing RPC identity conversion so session 
roles are retained without modifying the stored account.
   - **Other paths and branches:** GetDbSchemas and GetTables share database 
ordering; GetTableTypes already sorts. The defect dates to #46217 and remains 
on branch-3.1, branch-4.0, branch-4.1 and branch-4.2. Backports need package 
and role-API adaptation. MySQL metadata behavior is unchanged.
   
   ### Testing
   
   - Locally ran four focused FE test classes with Arrow allocator debugging: 
43 passed, none skipped. On the baseline, six of the eight new cases fail for 
ordering or visibility assertions, with zero errors; all eight pass after the 
fix.
   - Ran `test_metadata_order` through `run-regression-test.sh`: one suite 
passed, none skipped. Its ten generated result blocks were checked against 
fixture names, grants and table schemas before a normal verification run.
   - Rebuilt and restarted the local FE and checked 196 Flight RPC requests as 
administrator and restricted user, including external SQLite metadata, 
patterns, table types and optional schemas. Returned rows are ordered and 
catalog discovery matches independent SHOW CATALOGS. The 36 requests for a 
nonexistent catalog retain the existing error behavior.
   
   ### Notes for Reviewers
   
   Catalog-presence filters, raw schema names and loopback behavior remain with 
#70176. That patch predates master role forwarding and its insertion-order 
expectations need adaptation when integrated; it was not included in this 
verification. No multi-FE, mixed-version or TLS matrix was run.
   
   ### Release note
   
   Fix the order of Flight SQL catalog, schema and table metadata. GetCatalogs 
now returns only catalogs visible to the current session under the existing 
SHOW CATALOGS policy.
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: No
   - Pre-submission status: Ready
   
   ### AI Disclosure
   
   - Tool: Codex (GPT-6)
   - Generated: code, tests and this description
   - Human review: not stated
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to