Skip to content

PHOENIX-7902 SERVER ARRAY|JSON|BSON PROJECTION counted forms in EXPLAIN - #2522

Merged
apurtell merged 1 commit into
apache:PHOENIX-7876-featurefrom
apurtell:PHOENIX-7902
Jun 12, 2026
Merged

PHOENIX-7902 SERVER ARRAY|JSON|BSON PROJECTION counted forms in EXPLAIN#2522
apurtell merged 1 commit into
apache:PHOENIX-7876-featurefrom
apurtell:PHOENIX-7902

Conversation

@apurtell

@apurtellapurtell commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Replace the two opaque per-scan markers SERVER ARRAY ELEMENT PROJECTION and SERVER JSON FUNCTION PROJECTION with per-type clauses SERVER ARRAY PROJECTION <count>, SERVER JSON PROJECTION <count>, and SERVER BSON PROJECTION <count>, emitted only when at least one path expression of the corresponding type is pushed server side, and each followed by one indented detail line per expression via Expression.toString() indented to the next level.

ProjectionCompiler.compileSelectClause stashes the per-attribute expression buckets (the serverAttributeToFuncExpressionMap it already builds before scan serialization) on StatementContext as serverParsedProjections : Map<String, List<Expression>> keyed by scan attribute name. ExplainTable.explain(...) replaces the existing code with new code that processes "ARRAY", "JSON", and "BSON" buckets, emits the counted header, and the additional indented detail lines.

ExplainPlanAttributes retires the serverArrayElementProjection boolean and adds a serverParsedProjections: Map<String,List<String>> map, with up to three buckets ("ARRAY", "JSON", and "BSON" ) each holding a List<String>, with matching ExplainPlanTestUtil fluent assertion getters, setters, and testers.

Co-authored-by: Claude Opus 4.8[1m] noreply@anthropic.com

Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Phoenix EXPLAIN output to replace the prior opaque server-side projection markers with per-type, counted SERVER ARRAY|JSON|BSON PROJECTION <count> clauses, and includes one additional indented line per pushed-down path expression. It also updates explain-plan attribute plumbing and tests accordingly.

Changes:

  • Emit SERVER ARRAY|JSON|BSON PROJECTION <count> plus per-expression detail lines in ExplainTable.
  • Plumb server-side parsed projection expressions through StatementContext and expose them via ExplainPlanAttributes as serverParsedProjections.
  • Update unit/integration tests to assert the new explain text and attribute structure.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
phoenix-core-client/src/main/java/org/apache/phoenix/iterate/ExplainTable.javaReplaces old per-scan markers with per-type counted projection clauses and detail lines; populates new explain attributes.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/StatementContext.javaAdds storage for server-parsed projection expressions so EXPLAIN can render details.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.javaStashes per-attribute server-parsed function expression buckets onto the statement context during compilation.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/ExplainPlanAttributes.javaRetires serverArrayElementProjection and adds serverParsedProjections with builder support and defensive copying.
phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTestUtil.javaAdds fluent assertions for serverParsedProjections and removes old array-element boolean assertion usage.
phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTest.javaUpdates expected explain text and expected JSON attributes; adds JSON/BSON projection coverage.
phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.javaUpdates compilation-plan assertions to use serverParsedProjections APIs.
phoenix-core/src/it/java/org/apache/phoenix/end2end/ProjectArrayElemAfterHashJoinIT.javaUpdates IT expectations to assert pushed-down array projection counts.
phoenix-core/src/it/java/org/apache/phoenix/end2end/json/JsonFunctionsIT.javaUpdates IT string assertions for the new JSON projection explain marker.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@apurtell

Copy link
Copy Markdown
ContributorAuthor

Test Results

SuiteTests runFailuresErrorsSkippedResult
Unit tests (full phoenix-core suite)2539009PASS
Integration tests (impacted subset)69006PASS

Unit tests

Result: Tests run: 2539, Failures: 0, Errors: 0, Skipped: 9BUILD SUCCESS.

The count rose from the previous baseline of 2537 to 2539 because two new connectionless cases were added to ExplainPlanTest:

  • testJsonFunctionProjection — validates SERVER JSON PROJECTION 1 plus the JSON_VALUE(JSONCOL, '$.type') detail line.
  • testBsonValueProjection — validates SERVER BSON PROJECTION 1 plus the BSON_VALUE(PAYLOAD, 'user.id', 'VARCHAR', ) detail line.

The pre-existing testArrayElementProjection covers SERVER ARRAY PROJECTION 1 plus ARRAY_ELEM(A_STRING_ARRAY, 1).

Directly relevant unit classes:

ClassTests runResult
org.apache.phoenix.query.explain.ExplainPlanTest85PASS
org.apache.phoenix.compile.QueryCompilerTest(full class)PASS

Integration tests

Result: BUILD SUCCESS. Per-class breakdown:

ClassTests runFailuresErrorsSkippedResult
org.apache.phoenix.end2end.json.JsonFunctionsIT15000PASS
org.apache.phoenix.end2end.ProjectArrayElemAfterHashJoinIT2000PASS
org.apache.phoenix.end2end.Bson2IT2000PASS
org.apache.phoenix.end2end.Bson3IT16000PASS
org.apache.phoenix.end2end.Bson4IT32006PASS
org.apache.phoenix.end2end.Bson5IT2000PASS
Total69006PASS

The behavior change touches three EXPLAIN code paths:

  • SERVER ARRAY ELEMENT PROJECTIONSERVER ARRAY PROJECTION <n> + detail lines.
  • SERVER JSON FUNCTION PROJECTIONSERVER JSON PROJECTION <n> + detail lines.
  • BSON path projections now emit a new SERVER BSON PROJECTION <n> clause.

JsonFunctionsIT and ProjectArrayElemAfterHashJoinIT directly assert on the renamed JSON/array projection output and were migrated to the new serverParsedProjections API. The four Bson*IT suites assert table/iterator/scan-type attributes. Other explain-asserting ITs (e.g. ExplainPlanWithStatsEnabledIT) do not use array/JSON/BSON projections and were excluded.

@apurtell
apurtell merged commit c06c96f into apache:PHOENIX-7876-featureJun 12, 2026
@apurtell
apurtell deleted the PHOENIX-7902 branch June 12, 2026 01:42
apurtell added a commit to apurtell/phoenix that referenced this pull request Jun 17, 2026
…IN (apache#2522)
Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
asf-gitbox-commits pushed a commit that referenced this pull request Jul 24, 2026
…IN (#2522)
Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
apurtell added a commit to apurtell/phoenix that referenced this pull request Aug 4, 2026
…IN (apache#2522)
Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@apurtell