Uh oh!
There was an error while loading. Please reload this page.
PHOENIX-7903 Functional index match rule EXPLAIN disclosure - #2523
Conversation
Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR enhances optimizer EXPLAIN disclosure for functional indexes by surfacing which query path expression(s) matched a functional index and by using a more specific rejection reason when a functional index’s expression matches nothing in the query.
Changes:
- Track and disclose functional-index expression substitutions that actually fired, enabling
matches <expr>rule labeling for the chosen functional index. - Re-tag certain functional-index rejections as
path expression does not matchwhen no query expression matched the functional index expression. - Add unit tests covering functional-index rule labeling and rejection reason behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| phoenix-core/src/test/java/org/apache/phoenix/compile/QueryOptimizerTest.java | Adds tests asserting functional-index matches <expr> rule labeling and updated rejection reasons. |
| phoenix-core-client/src/main/java/org/apache/phoenix/parse/IndexExpressionParseNodeRewriter.java | Tracks which functional substitutions actually fired during rewrite to support EXPLAIN disclosure. |
| phoenix-core-client/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java | Records fired matches into the rewrite context and adjusts rule/rejection labels for functional indexes. |
| phoenix-core-client/src/main/java/org/apache/phoenix/compile/StatementContext.java | Stores per-index “applied expression matches” and marks indexes as functional during rewriting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
apurtell
commented
Jun 12, 2026
Test ResultsUnit tests — PASS
New tests added by the commit (all passing):
Integration tests ( |
| Test class | Tests | Failures | Errors | Skipped |
|---|---|---|---|---|
IndexUsageIT (functional indexes `s2 | '_' | s3, k1/k2`) | ||
JsonFunctionsIT (JSON path functional indexes) | 15 | 0 | 0 | 0 |
| Total | 54 | 0 | 0 | 0 |
Both IT classes exercise the changed optimizer code paths via real plan compilation against a minicluster and assert on indexRule / indexRejected.
Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
Disclose
OptimizerReasonsfor functional indexes.The chosen functional index's per-scan
INDEXline gains the rulematches <expr>where<expr>is the user's original path expression. Candidates discarded because no query expression matched their indexed expression are taggedpath expression does not match.QueryOptimizer.recordDecision,labelComparatorRule, and theRULE_ONLY_CANDIDATEpath ingetApplicablePlansForSingleFlatQueryoverride the rule label withOptimizerReasons.matches(sourceExpression.toString())when the winning candidate is a functional index, sourcingsourceExpressionfromStatementContext.getIndexExpressionSubstitutions()of the winning index.QueryOptimizer.addPlanandtagComparatorRejectionsswitch the rejection tag for functional index candidates toREASON_PATH_EXPRESSION_DOES_NOT_MATCH.A functional index is detected by an index column with a non-null
PColumn.getExpressionStr().Co-authored-by: Claude Opus 4.8[1m] noreply@anthropic.com