Skip to content

chore: adopt released protoyaml for SHOW PLAN NODE canonical output#784

Merged
apstndb merged 1 commit into
mainfrom
chore/adopt-protoyaml-canonical
Jul 8, 2026
Merged

chore: adopt released protoyaml for SHOW PLAN NODE canonical output#784
apstndb merged 1 commit into
mainfrom
chore/adopt-protoyaml-canonical

Conversation

@apstndb

@apstndb apstndb commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Migrates SHOW PLAN NODE from the in-tree spannerplan/protoyaml marshalers to the released standalone module github.com/apstndb/protoyaml v0.1.0 (canonical protojson-over-YAML).

github.com/apstndb/spannerplan stays as a dependency; only the protoyaml subpackage import moves to the standalone module.

What changes for users

SHOW PLAN NODE output switches dialect from an accidental proto-reflection format (snake_case proto field names, numeric enums) to canonical protojson-over-YAML (camelCase, named enums) — matching the field names used in gcloud output and the official query plan visualizer JSON.

The layout is identical: all-scalar sub-maps still render as compact flow ({...}) via protoyaml.WithFlowLeafCollections(). Root-level scalar-only nodes stay as block documents (e.g. index: 1\nkind: RELATIONAL\ndisplayName: Child\n), not inline flow.

structpb data keys (the contents of execution_stats, metadata, etc.) are unchanged — those come from the plan payload, not proto field names.

Before / after

Before (proto-reflection dialect):

index: 1
kind: 1
display_name: Unit Relation
child_links:
- {child_index: 2}
metadata: {execution_method: Row}
execution_stats:
  cpu_time: {total: "0", unit: msecs}

After (canonical protojson-over-YAML):

index: 1
kind: RELATIONAL
displayName: Unit Relation
childLinks:
- {childIndex: 2}
metadata: {execution_method: Row}
executionStats:
  cpu_time: {total: "0", unit: msecs}

Note how the proto field names change (display_name -> displayName, kind: 1 -> kind: RELATIONAL) while the structpb-sourced metadata / execution_stats data keys stay as-is.

Implementation

  • go get github.com/apstndb/protoyaml@v0.1.0 && go mod tidy.
  • Swap the import github.com/apstndb/spannerplan/protoyaml -> github.com/apstndb/protoyaml.
  • Replace the custom option builder call with protoyaml.Marshal(planNode, protoyaml.WithFlowLeafCollections()).
  • Delete ~50 lines of custom goccy/go-yaml marshalers (getGlobalOpts, getStructOpts, hasCompound) and now-unused imports.
  • Update TestShowPlanNodeStatement_Execute golden strings to the canonical output.

Net: 13 insertions, 59 deletions.

Validation

  • go build ./..., go vet ./... clean.
  • make check green (test + lint + fmt-check; golangci-lint 0 issues, formatting correct).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Du9UR1LPdSXk4wAZr4Nf4g

Migrate SHOW PLAN NODE from spannerplan/protoyaml to the released
github.com/apstndb/protoyaml v0.1.0 (canonical protojson-over-YAML).

The previous marshaling relied on ~50 lines of custom goccy/go-yaml
marshalers that emitted an accidental proto-reflection dialect
(snake_case field names, numeric enums). protoyaml.Marshal with
WithFlowLeafCollections now produces canonical protojson field naming
(camelCase, named enums) matching gcloud and the official query plan
visualizer, while keeping the identical layout (compact flow for
all-scalar sub-maps). structpb data keys (execution_stats contents etc.)
are unchanged.

github.com/apstndb/spannerplan stays; only the protoyaml subpackage
import moves to the standalone module.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Du9UR1LPdSXk4wAZr4Nf4g

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the internal protoyaml package and custom YAML marshaling logic with the external github.com/apstndb/protoyaml library. This simplifies statements_explain_describe.go by removing several custom marshaling helper functions. The test cases in statements_explain_describe_test.go have been updated to match the new YAML output format, which uses camelCase keys and string representations for enums. I have no additional feedback to provide as the changes are clean and the tests have been appropriately updated.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Code Metrics Report

📊 View detailed coverage report (available for 7 days)

main (53bd54f) #784 (d97b778) +/-
Coverage 73.2% 73.1% -0.1%
Code to Test Ratio 1:1.3 1:1.3 +0.0
Test Execution Time 1m57s 2m1s +4s
Details
  |                     | main (53bd54f) | #784 (d97b778) |  +/-  |
  |---------------------|----------------|----------------|-------|
- | Coverage            |          73.2% |          73.1% | -0.1% |
  |   Files             |             93 |             93 |     0 |
  |   Lines             |           7933 |           7917 |   -16 |
- |   Covered           |           5808 |           5794 |   -14 |
+ | Code to Test Ratio  |          1:1.3 |          1:1.3 |  +0.0 |
  |   Code              |          18517 |          18472 |   -45 |
  |   Test              |          25146 |          25146 |     0 |
- | Test Execution Time |          1m57s |           2m1s |   +4s |

Code coverage of files in pull request scope (63.2% → 61.7%)

Files Coverage +/- Status
internal/mycli/statements_explain_describe.go 61.7% -1.5% modified

Reported by octocov

@apstndb apstndb merged commit 750c4d2 into main Jul 8, 2026
8 checks passed
@apstndb apstndb deleted the chore/adopt-protoyaml-canonical branch July 8, 2026 03:29
apstndb added a commit that referenced this pull request Jul 8, 2026
PR #784 changed SHOW PLAN NODE output from the accidental reflection
YAML dialect (snake_case proto field names, numeric enums) to canonical
protojson-over-YAML (camelCase field names, named enums). The example in
docs/query_plan.md still showed the old dialect.

Apply the same transformation to the documented node-18 dump:
- kind: 1 -> kind: RELATIONAL
- display_name -> displayName, child_links -> childLinks,
  child_index -> childIndex, execution_stats -> executionStats
Keys inside metadata/executionStats children (execution_method,
cpu_time, scan_method, ...) are plan data and remain unchanged; the
executionStats and childLinks block containers, scanned_rows/histogram
nesting, and root block style are unchanged.

The unchanged metadata line remains the widest content, so the CLI table
frame stays 99 columns wide; only the shrunk lines were re-padded to keep
the box aligned.


Claude-Session: https://claude.ai/code/session_01Du9UR1LPdSXk4wAZr4Nf4g

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to 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.

1 participant