Yukang-Lian opened a new pull request, #70288: URL: https://github.com/apache/doris/pull/70288
### Background `ADMIN COMPACT TABLE db.tbl PARTITION p WHERE type = 'BASE/CUMULATIVE/FULL'` sends a compaction task for every replica of one partition. The command requires exactly one partition; for a non-partitioned table the single partition has the same name as the table. ### What problem does this PR solve? Issue Number: None Related PR: #44861 (introduced the bug) PR Type: Bugfix Problem Summary: When the `PARTITION` clause is omitted, `AdminCompactTableCommand.validate()` throws a `NullPointerException` and the user sees `Cannot invoke "PartitionNamesInfo.getPartitionNames()" because the return value of "TableRefInfo.getPartitionNamesInfo()" is null` instead of `No partition selected for compaction`. This PR checks the `PartitionNamesInfo` itself for null, so the command returns the intended error again. ### Details - **Frequency:** Every `ADMIN COMPACT TABLE` without a `PARTITION` clause, on both partitioned and non-partitioned tables. - **Root cause:** When the legacy `AdminCompactTableStmt` was ported to Nereids in #44861, the null check moved from the `PartitionNames` object to the inner list. The parser passes a null `PartitionNamesInfo` when there is no `PARTITION` clause, and the inner list of a non-null `PartitionNamesInfo` is never null, so the check could never fire. - **Why existing tests missed it:** There was no test for this command. - **Fix:** Check `tableRefInfo.getPartitionNamesInfo()` for null, matching the legacy statement. `run()` reads the partition names only after `validate()` passes, so it needs no change. - **Other paths and branches:** Branches that still use the legacy `AdminCompactTableStmt` are not affected. ### Testing Added `AdminCompactTableCommandTest` (FE UT): no `PARTITION` clause on a partitioned and a non-partitioned table, multiple partitions, missing `WHERE`, and an invalid `type`. The no-partition case fails with the NPE before this fix and passes after it. Ran locally with `mvn -pl fe-core -am test -Dtest=AdminCompactTableCommandTest`. ### Release note Fix a NullPointerException when `ADMIN COMPACT TABLE` is run without a `PARTITION` clause; it now returns "No partition selected for compaction". ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: - Generated: - Human review: -- 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]
