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

   ### Background
   
   Several Nereids SHOW statements take an optional database as `(FROM | IN) 
database=multipartIdentifier`. Most visitors in `LogicalPlanBuilder`, such as 
`visitShowFunctions`, map one part to the database and two parts to catalog and 
database.
   
   ### What problem does this PR solve?
   
   Issue Number: close #70463
   Related PR: #45832 (moved SHOW COLUMNS to Nereids with the `getText()` 
database name)
   PR Type: Bugfix
   
   Problem Summary:
   
   SHOW DELETE, SHOW ENCRYPTKEYS, SHOW FILE and SHOW DYNAMIC PARTITION TABLES 
keep only the first part of the database name, so `SHOW DELETE FROM 
internal.db1` looks up a database called `internal`. `SHOW COLUMNS FROM t1 FROM 
internal.db1` fails with `Unknown database 'internal.db1'`. After this PR, 
`FROM internal.db1` works on all five.
   
   ### Details
   
   - **Frequency:** every one of these statements with a two-part database name.
   - **Root cause:** the four visitors take `nameParts.get(0)` (`// only one 
entry possible`); `visitShowColumns` uses `ctx.database.getText()`.
   - **Why existing tests missed it:** no test used a qualified database here.
   - **Fix:** the four internal-only commands share a new `getInternalDbName`: 
two parts must start with `internal`, longer names are rejected. SHOW COLUMNS 
accepts any catalog.
   - **Other paths and branches:** SHOW OPEN TABLES and SHOW TABLE CREATION 
truncate too, but never read the database, so they are unchanged. SHOW 
ENCRYPTKEYS still rejects an external session catalog, as before.
   - **Behavior change:** other catalogs and 3+ part names now fail on the four 
commands. In SHOW COLUMNS, a dotted Iceberg namespace must be backquoted.
   
   ### Testing
   
   - `ShowDbNameParsingTest` checks the database name parsed from one-, two- 
and three-part names and the non-internal catalog error. Three of its five 
tests fail without the fix.
   - `ShowColumnsCommandTest` runs SHOW COLUMNS: `FROM internal.<db>` returns 
the columns, and `FROM nonexist_ctl.<db>` must fail with `Unknown catalog`, 
which catches a dropped catalog part. Both fail without the fix.
   
   ### Release note
   
   SHOW DELETE, SHOW ENCRYPTKEYS, SHOW FILE and SHOW DYNAMIC PARTITION TABLES 
accept `FROM internal.db`; SHOW COLUMNS accepts `FROM catalog.db`. Names with 
more than two parts are rejected, and a dotted Iceberg namespace in SHOW 
COLUMNS must be backquoted.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details)
   - Does this need documentation: No
   - Pre-submission status: Ready
   
   ### AI Disclosure
   
   - Tool: Claude Opus
   - Generated: the fix, the tests, and this description
   - Human review: the author chose the scope; the author's line-by-line review 
of the diff is pending
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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