← Back to Pull requests

[fix](nereids) Fix NPE in ADMIN COMPACT TABLE without PARTITION clause #70288

Closed
unknown closed this pull request without merging on Nov 27, 2026 09:55 UTC
View on GitHub
unknown unknown commented on Nov 05, 2026 10:28 UTC
Author

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:
  • Diff: 296 lines (+222 / -74) across 3 files Reviewer: morrySnow Review duration: 31646m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 296 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.341
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #70288"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.0% (MEDIUM) · Higher = larger blast radius
    40.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.8% · Safe to merge
    15.8%
    Repository