[ 
https://issues.apache.org/jira/browse/PHOENIX-7918?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrew Kyle Purtell updated PHOENIX-7918:
-----------------------------------------
    Description: 
Introduce {{EXPLAIN (VERBOSE)}} mode with three related disclosures: a 
{{PROJECT}} line, predicate source attribution on every {{SERVER FILTER BY}} / 
{{CLIENT FILTER BY}} line, and ignored hint comments. 

The {{verbose}} flag is read from {{ExplainOptions}} by 
{{PhoenixStatement.ExecutableExplainStatement}} and threaded onto 
{{StatementContext}} so {{ExplainTable.explain(...)}} can branch on it. 
{{ExplainTable}} reads the post-compile projector via 
{{plan.getProjector().getColumnProjectors()}} (skipped when null) and 
{{ExplainPlanAttributes}} gains {{serverProject : List}}, populated whenever 
known and gated by VERBOSE. 

The per-scan {{!INDEX}} text rendering wired by PHOENIX-7891 (and consumed by 
PHOENIX-7903 for the {{path expression does not match}} reason) is gated behind 
{{verbose}}. The chosen-plan {{INDEX}} line stays in plain {{EXPLAIN}}, and the 
{{indexRejected}} attribute keeps populating regardless of mode. PHOENIX-7891 
connectionless {{ExplainPlanTest}} cases that asserted on {{!INDEX}} text are 
migrated to assert on the structured {{indexRejected}} attribute or switched to 
{{EXPLAIN (VERBOSE)}}, and the affected plain-{{EXPLAIN}} baselines are 
regenerated.

Every {{Expression}} rewriter that produces a fresh node inherits input tags so 
identity-keyed lookup survives deep clones. Under VERBOSE {{ExplainTable}} 
walks the top-level filter expression and, if it is an {{AndExpression}} whose 
children are each in the origin map, emits one {{SERVER FILTER BY}} per child, 
or otherwise a single line with the comma-separated union of origins. 
{{StatementContext}} adds {{predicateOrigins : Map<Expression, Set>}} keyed by 
{{IdentityHashMap}} with {{tagPredicate(Expression, String)}} and 
{{getPredicateOrigins()}} accessors that is wired into {{WhereCompiler}} 
({{"WHERE"}} per AND-child, with {{WhereOptimizer}} row-key-range / 
residual-server-filter splits inheriting origins and partial-evaluation fusion 
unioning the sets), {{HavingCompiler}} ({{"HAVING (lifted)"}}), 
{{JoinCompiler}} ({{"JOIN ON"}} for surviving ON predicates and {{"decorrelated 
from "}} from the rewriter context), {{IndexStatementRewriter}} ({{"INDEX 
WHERE"}}), and {{RVCOffsetCompiler}} ({{"RVC OFFSET"}}).

For path-test functions ({{JsonExistsFunction}}, 
{{BsonConditionExpressionFunction}}) {{(JSON EXISTS)}} / {{(BSON CONDITION)}} 
is appended to the trailing comment, detected by expression class. 
{{ExplainPlanAttributes}} adds {{serverFilters : List<expr, origin : List, 
pathTestSubtag : String>}} alongside the existing {{serverWhereFilter}} 
narrowed by PHOENIX-7886.

For ignored-hint comments, {{StatementContext}} adds {{Map<Hint, 
IgnoredHintReason>}} populated at sites involving the {{HintNode.Hint}} set — 
{{Hint.NO_INDEX}} in {{QueryOptimizer.getApplicablePlansForSingleFlatQuery}}, 
{{Hint.USE_SORT_MERGE_JOIN}} in {{JoinCompiler.useSortMergeJoin}}, 
{{Hint.SMALL}} in {{ExplainTable.explain}} — and {{ExplainTable}} emits one 
{{/- HINT(args) -- */}} comment per ignored hint under VERBOSE in the per-scan 
render order. Partially honored hints (e.g. {{INDEX(t a, b)}} where only {{a}} 
was used) are treated as honored if any arg was used. 

Matching {{ExplainPlanTestUtil}} fluent getters, setters, and testers are added 
for {{serverProject}}, {{serverFilters}}, and the ignored-hint map.

  was:
Introduce {{EXPLAIN (VERBOSE)}} mode with three related disclosures: a 
{{PROJECT }} line, predicate source attribution on every {{SERVER FILTER BY}} / 
{{CLIENT FILTER BY}} line, and ignored hint comments. 

The {{verbose}} flag is read from {{ExplainOptions}} by 
{{PhoenixStatement.ExecutableExplainStatement}} and threaded onto 
{{StatementContext}} so {{ExplainTable.explain(...)}} can branch on it. 
{{ExplainTable}} reads the post-compile projector via 
{{plan.getProjector().getColumnProjectors()}} (skipped when null) and 
{{ExplainPlanAttributes}} gains {{serverProject : List}}, populated whenever 
known and gated by VERBOSE. 

The per-scan {{!INDEX}} text rendering wired by PHOENIX-7891 (and consumed by 
PHOENIX-7903 for the {{path expression does not match}} reason) is gated behind 
{{verbose}}. The chosen-plan {{INDEX}} line stays in plain {{EXPLAIN}}, and the 
{{indexRejected}} attribute keeps populating regardless of mode. PHOENIX-7891 
connectionless {{ExplainPlanTest}} cases that asserted on {{!INDEX}} text are 
migrated to assert on the structured {{indexRejected}} attribute or switched to 
{{EXPLAIN (VERBOSE)}}, and the affected plain-{{EXPLAIN}} baselines are 
regenerated.

Every {{Expression}} rewriter that produces a fresh node inherits input tags so 
identity-keyed lookup survives deep clones. Under VERBOSE {{ExplainTable}} 
walks the top-level filter expression and, if it is an {{AndExpression}} whose 
children are each in the origin map, emits one {{SERVER FILTER BY}} per child, 
or otherwise a single line with the comma-separated union of origins. 
{{StatementContext}} adds {{predicateOrigins : Map<Expression, Set>}} keyed by 
{{IdentityHashMap}} with {{tagPredicate(Expression, String)}} and 
{{getPredicateOrigins()}} accessors that is wired into {{WhereCompiler}} 
({{"WHERE"}} per AND-child, with {{WhereOptimizer}} row-key-range / 
residual-server-filter splits inheriting origins and partial-evaluation fusion 
unioning the sets), {{HavingCompiler}} ({{"HAVING (lifted)"}}), 
{{JoinCompiler}} ({{"JOIN ON"}} for surviving ON predicates and {{"decorrelated 
from "}} from the rewriter context), {{IndexStatementRewriter}} ({{"INDEX 
WHERE"}}), and {{RVCOffsetCompiler}} ({{"RVC OFFSET"}}).

For path-test functions ({{JsonExistsFunction}}, 
{{BsonConditionExpressionFunction}}) {{(JSON EXISTS)}} / {{(BSON CONDITION)}} 
is appended to the trailing comment, detected by expression class. 
{{ExplainPlanAttributes}} adds {{serverFilters : List<expr, origin : List, 
pathTestSubtag : String>}} alongside the existing {{serverWhereFilter}} 
narrowed by PHOENIX-7886.

For ignored-hint comments, {{StatementContext}} adds {{Map<Hint, 
IgnoredHintReason>}} populated at sites involving the {{HintNode.Hint}} set — 
{{Hint.NO_INDEX}} in {{QueryOptimizer.getApplicablePlansForSingleFlatQuery}}, 
{{Hint.USE_SORT_MERGE_JOIN}} in {{JoinCompiler.useSortMergeJoin}}, 
{{Hint.SMALL}} in {{ExplainTable.explain}} — and {{ExplainTable}} emits one 
{{/- HINT(args) -- */}} comment per ignored hint under VERBOSE in the per-scan 
render order. Partially honored hints (e.g. {{INDEX(t a, b)}} where only {{a}} 
was used) are treated as honored if any arg was used. 

Matching {{ExplainPlanTestUtil}} fluent getters, setters, and testers are added 
for {{serverProject}}, {{serverFilters}}, and the ignored-hint map.


> Implement EXPLAIN VERBOSE disclosures
> -------------------------------------
>
>                 Key: PHOENIX-7918
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-7918
>             Project: Phoenix
>          Issue Type: Sub-task
>            Reporter: Andrew Kyle Purtell
>            Assignee: Andrew Kyle Purtell
>            Priority: Major
>             Fix For: PHOENIX-7876-feature
>
>
> Introduce {{EXPLAIN (VERBOSE)}} mode with three related disclosures: a 
> {{PROJECT}} line, predicate source attribution on every {{SERVER FILTER BY}} 
> / {{CLIENT FILTER BY}} line, and ignored hint comments. 
> The {{verbose}} flag is read from {{ExplainOptions}} by 
> {{PhoenixStatement.ExecutableExplainStatement}} and threaded onto 
> {{StatementContext}} so {{ExplainTable.explain(...)}} can branch on it. 
> {{ExplainTable}} reads the post-compile projector via 
> {{plan.getProjector().getColumnProjectors()}} (skipped when null) and 
> {{ExplainPlanAttributes}} gains {{serverProject : List}}, populated whenever 
> known and gated by VERBOSE. 
> The per-scan {{!INDEX}} text rendering wired by PHOENIX-7891 (and consumed by 
> PHOENIX-7903 for the {{path expression does not match}} reason) is gated 
> behind {{verbose}}. The chosen-plan {{INDEX}} line stays in plain 
> {{EXPLAIN}}, and the {{indexRejected}} attribute keeps populating regardless 
> of mode. PHOENIX-7891 connectionless {{ExplainPlanTest}} cases that asserted 
> on {{!INDEX}} text are migrated to assert on the structured {{indexRejected}} 
> attribute or switched to {{EXPLAIN (VERBOSE)}}, and the affected 
> plain-{{EXPLAIN}} baselines are regenerated.
> Every {{Expression}} rewriter that produces a fresh node inherits input tags 
> so identity-keyed lookup survives deep clones. Under VERBOSE {{ExplainTable}} 
> walks the top-level filter expression and, if it is an {{AndExpression}} 
> whose children are each in the origin map, emits one {{SERVER FILTER BY}} per 
> child, or otherwise a single line with the comma-separated union of origins. 
> {{StatementContext}} adds {{predicateOrigins : Map<Expression, Set>}} keyed 
> by {{IdentityHashMap}} with {{tagPredicate(Expression, String)}} and 
> {{getPredicateOrigins()}} accessors that is wired into {{WhereCompiler}} 
> ({{"WHERE"}} per AND-child, with {{WhereOptimizer}} row-key-range / 
> residual-server-filter splits inheriting origins and partial-evaluation 
> fusion unioning the sets), {{HavingCompiler}} ({{"HAVING (lifted)"}}), 
> {{JoinCompiler}} ({{"JOIN ON"}} for surviving ON predicates and 
> {{"decorrelated from "}} from the rewriter context), 
> {{IndexStatementRewriter}} ({{"INDEX WHERE"}}), and {{RVCOffsetCompiler}} 
> ({{"RVC OFFSET"}}).
> For path-test functions ({{JsonExistsFunction}}, 
> {{BsonConditionExpressionFunction}}) {{(JSON EXISTS)}} / {{(BSON CONDITION)}} 
> is appended to the trailing comment, detected by expression class. 
> {{ExplainPlanAttributes}} adds {{serverFilters : List<expr, origin : List, 
> pathTestSubtag : String>}} alongside the existing {{serverWhereFilter}} 
> narrowed by PHOENIX-7886.
> For ignored-hint comments, {{StatementContext}} adds {{Map<Hint, 
> IgnoredHintReason>}} populated at sites involving the {{HintNode.Hint}} set — 
> {{Hint.NO_INDEX}} in {{QueryOptimizer.getApplicablePlansForSingleFlatQuery}}, 
> {{Hint.USE_SORT_MERGE_JOIN}} in {{JoinCompiler.useSortMergeJoin}}, 
> {{Hint.SMALL}} in {{ExplainTable.explain}} — and {{ExplainTable}} emits one 
> {{/- HINT(args) -- */}} comment per ignored hint under VERBOSE in the 
> per-scan render order. Partially honored hints (e.g. {{INDEX(t a, b)}} where 
> only {{a}} was used) are treated as honored if any arg was used. 
> Matching {{ExplainPlanTestUtil}} fluent getters, setters, and testers are 
> added for {{serverProject}}, {{serverFilters}}, and the ignored-hint map.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to