Aranya7 opened a new pull request, #69594:
URL: https://github.com/apache/doris/pull/69594
### What problem does this PR solve?
**Issue Number:** N/A
**Related PR:** N/A
**Problem Summary:**
`SHOW QUERY STATS FOR <db_name>` throws a `NullPointerException` when a
database is explicitly specified.
In `ShowQueryStatsCommand.validate()`, `ShowQueryStatsType.DATABASE` is
assigned only when the database name is resolved from the current session. For
an explicitly specified database, `type` remains null, causing `getMetaData()`
to fail.
**Fix:**
Move the `ShowQueryStatsType.DATABASE` assignment into the database-level
statistics handling branch, ensuring correct metadata initialization for both
implicit and explicit database queries.
Added regression coverage to verify both forms return the expected result
schema.
### Release note
None
### Check List (For Author)
- Test
- [x] Regression test
- [ ] Unit Test
- [x] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason
**Test details:**
- Successfully built Doris FE from source.
- Added regression assertions in `query_stats_test.groovy` for implicit and
explicit database-level query statistics and result metadata.
- Regression framework compiled successfully; all 50 framework unit tests
passed.
- Manually verified the database-level commands on a standalone FE:
```sql
CREATE DATABASE IF NOT EXISTS query_stats_npe_test;
USE query_stats_npe_test;
SHOW QUERY STATS;
SHOW QUERY STATS FOR query_stats_npe_test;
```
- Verified that an invalid database name returns an appropriate error
instead of a `NullPointerException`.
- Behavior changed:
- [ ] No.
- [x] Yes. Explicit database-level `SHOW QUERY STATS` queries now
execute successfully instead of throwing a `NullPointerException`.
- Does this need documentation?
- [x] No.
- [ ] Yes.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
--
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]