PHOENIX-7919 Support EXPLAIN FORMAT JSON#2527
Merged
Merged
Conversation
Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds end-to-end support for EXPLAIN (FORMAT JSON) <stmt> by rendering the ExplainPlanAttributes tree as a pretty-printed JSON document and returning it as a single-row result set.
Changes:
- Introduces
ExplainJsonRendererto serializeExplainPlanAttributesto pretty-printed JSON (2-space indentation for objects and arrays). - Updates
PhoenixStatement#ExecutableExplainStatement.compilePlanto branch onExplainOptions.Format.JSONand return exactly one row for JSON format. - Adds a new end-to-end test validating JSON output and the
(REGIONS, FORMAT JSON)combination.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainJsonOutputTest.java | New E2E tests for EXPLAIN (FORMAT JSON) output shape and equivalence to in-process attributes (post-normalization). |
| phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java | Routes EXPLAIN rendering based on format; JSON produces a single rendered-document row. |
| phoenix-core-client/src/main/java/org/apache/phoenix/compile/ExplainJsonRenderer.java | New renderer encapsulating Jackson configuration for EXPLAIN JSON serialization and pretty-printing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
Test ResultsUnit tests
Integration tests
Notes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EXPLAIN (FORMAT JSON) <stmt>returns a single VARCHAR cell whose value is the Jackson serialization of the in-memoryExplainPlanAttributestree. A newExplainJsonRendererowns a private staticObjectWriterconfigured for the EXPLAIN JSON contract and aDefaultPrettyPrinterwhoseDefaultIndenteris set on both the object and array indenters, so the output is human readable with two space indentation for both objects and arrays,render(...)wrapsJsonProcessingExceptionasSQLException.PhoenixStatement#ExecutableExplainStatement.compilePlanbranches ongetOptions().getFormat().TEXTis unchanged.JSONskipsrenderTopOfPlanTextand emits exactly one row carrying the rendered document, with the three plan-total estimate cells attached to the first row.regionLocationspopulates under(REGIONS, FORMAT JSON)and isnullotherwise.Co-authored-by: Claude Opus 4.8[1m] noreply@anthropic.com