morningman opened a new pull request, #71344:
URL: https://github.com/apache/doris/pull/71344
Backport of #70735 to `branch-4.1`.
### Background
Flight SQL clients discover catalogs, schemas, and tables by reading Arrow
rows from DoGet. The protocol defines their order, and Doris checks catalog
visibility through the same grants used by SHOW CATALOGS.
### What problem does this PR solve?
Issue Number: #67578
Related PR: #70735, #46217, #68631, #68614
PR Type: Bugfix
Problem Summary:
Flight SQL returned discovery rows in metadata enumeration order and listed
catalogs outside the caller's SHOW privileges. In the regression fixture,
`GetCatalogs` for a restricted user returned
`internal;flight_order_z;flight_order_a` before the fix and returns
`flight_order_a;internal` after it.
### Details
- **Change map**. The helper adds 42 lines and removes 24. The remaining 430
additions cover FE unit tests, the Flight regression, and generated results.
- **Frequency**. Every catalog discovery request includes ungranted catalogs
if they exist. Schema and table order differs whenever service enumeration is
unsorted.
- **Root cause**. `FlightSqlSchemaHelper` puts `internal` first and
enumerates all catalogs. It writes schemas and tables in the order returned by
the metadata service.
- **Fix**. Reuse the SHOW CATALOGS privilege check and bind the Flight
session while 4.1 resolves authenticated roles. Restore the previous thread
context after the check. Sort catalog and schema pairs together. Order tables
before describing them so each row keeps its Arrow schema.
- **Branch adaptation**. The patch uses the 4.1 Arrow Flight package,
session identity, table-type filter, and schema builder. The regression checks
mixed table types and the branch's `VIEW` filter. The unit test uses Java 8
collection APIs.
- **Why existing tests missed it**. The closest FE tests check Arrow types,
query schemas, or the table-type vocabulary. `test_table_types` and
`test_schema_only` exercise those paths as an administrator. Neither checks the
wire order of discovery rows or catalog filtering for a role-granted user.
- **Other paths and branches**. This backport covers GetCatalogs,
GetDbSchemas, and GetTables. GetTableTypes already sorts its results. #46217
introduced the discovery helper. The inspected 3.1, 4.0, and 4.2 branch
snapshots still put `internal` first.
### Testing
- `./build.sh --fe` passed with Checkstyle enabled. Five focused FE classes
passed 58 cases with zero errors, failures, or skips. On the target baseline,
the same eight new cases produced six expected assertion failures for discovery
order or visibility.
- `./run-regression-test.sh --run -d arrow_flight_sql_p0 -s
test_metadata_order` passed one suite with no skips using the candidate FE and
a 4.1.5 BE in ARM64 Docker. The real Flight responses checked administrator and
restricted-user visibility, wire order, table types, and optional Arrow
schemas. All 12 generated result blocks matched the fixture and grants before
the normal rerun.
- The same suite reached GetCatalogs and failed its order comparison on an
unpatched 4.1.5 FE. The baseline uses the same helper source as the target and
also returned the ungranted catalog in the restricted-user snapshot.
### Release note
Flight SQL catalog, schema, and table discovery now follows protocol order.
`GetCatalogs` returns catalogs visible under the current session's SHOW
CATALOGS privileges.
### Check List (For Author)
- Test
- [x] Regression test
- [x] Unit Test
- Behavior changed:
- [x] Yes. Flight metadata rows are ordered, and catalog discovery honors
SHOW privileges.
- Does this need documentation?
- [x] No.
- Pre-submission status: Ready
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
### AI Disclosure
- Tool: Codex (GPT-6)
- Generated: backport conflict resolution, test adaptations, and PR
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]