Skip to content

PHOENIX-7924 EXPLAIN improvement bug fixes - #2531

Merged
apurtell merged 2 commits into
apache:PHOENIX-7876-featurefrom
apurtell:PHOENIX-7924
Jun 15, 2026
Merged

PHOENIX-7924 EXPLAIN improvement bug fixes#2531
apurtell merged 2 commits into
apache:PHOENIX-7876-featurefrom
apurtell:PHOENIX-7924

Conversation

@apurtell

Copy link
Copy Markdown
Contributor

Three fixes for bugs discovered while generating EXPLAIN/EXPLAIN VERBOSE/EXPLAIN JSON examples.

LiteralExpression.toString() rendered typed-null literals as empty. Output now shows BSON_VALUE(..., null) instead of BSON_VALUE(..., ).

Leading whitespace was baked into functional index column names. Fixed by trimming at creation. Output now shows PROJECT "BSON_VALUE(...)" instead of PROJECT " BSON_VALUE(...)".

REWRITE INDEX EXPRESSION <expr> AS <index col> breadcrumb was missing because it was always silently dropped. Drop the eager emission, store the col to expr substitution pairs on StatementContext, and emit one breadcrumb per actually fired substitution from QueryOptimizer.recordDecision.

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 addresses multiple EXPLAIN output correctness issues discovered while generating EXPLAIN/VERBOSE/JSON examples: typed-null literal rendering, functional index column name whitespace, and missing functional-index rewrite breadcrumbs by deferring breadcrumb emission until after the winning plan is chosen.

Changes:

  • Fix LiteralExpression.toString() so typed-null literals render as null (avoids empty trailing arguments in function strings).
  • Trim top-level functional index expression SQL when creating index column names to avoid leading whitespace being persisted into PColumn names.
  • Capture functional-index substitution pairs on StatementContext and emit one rewrite breadcrumb per actually-applied substitution for the chosen plan in QueryOptimizer.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTest.javaUpdates expected EXPLAIN JSON/text output for BSON_VALUE to include null for typed-null default argument.
phoenix-core-client/src/main/java/org/apache/phoenix/schema/MetaDataClient.javaTrims serialized functional index expressions before building index column names to prevent leading whitespace in names.
phoenix-core-client/src/main/java/org/apache/phoenix/parse/IndexExpressionParseNodeRewriter.javaStops eagerly emitting rewrite breadcrumbs during candidate enumeration; retains constructor for compatibility and keeps substitution tracking.
phoenix-core-client/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.javaRecords substitution pairs during rewrite and emits rewrite breadcrumbs only for the winner plan.
phoenix-core-client/src/main/java/org/apache/phoenix/expression/LiteralExpression.javaRenders typed-null literals as "null" instead of an empty string.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/StatementContext.javaAdds storage/accessors for applied functional-index substitution pairs to support winner-only breadcrumb emission.

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

@apurtell
apurtell merged commit 114f3f9 into apache:PHOENIX-7876-featureJun 15, 2026
@apurtell
apurtell deleted the PHOENIX-7924 branch June 15, 2026 02:53
apurtell added a commit to apurtell/phoenix that referenced this pull request Jun 17, 2026
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
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
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