Documentation
¶
Overview ¶
Package plantree provides functionality to render PlanNode as ASCII tree (EXPERIMENTAL).
RowWithPredicates and tree prefix ¶
The tree prefix is exposed without tying callers to a particular struct field shape:
- RowWithPredicates.TreePartString — one string (newline-separated lines), stable with historical encoding
- RowWithPredicates.TreePartLines — one string per line of RowWithPredicates.NodeText
Prefer these methods over reading the TreePart field directly so future internal representations can change with less churn. Typical rendering uses RowWithPredicates.Text, which combines tree prefix and node title.
The TreePart field remains exported for struct literals and cmp.Diff in tests; new code should use the accessors above when not constructing rows by hand.
A []string field would avoid one strings.Join in the renderer and one strings.Split in Text, but it is a breaking API change for modules that build RowWithPredicates literals in tests (for example github.com/apstndb/spanner-mycli). Downstream production code reviewed at the time of this change uses ProcessPlan and Text/FormatID only, not TreePart field access.
Breaking changes in this package are called out in the release / PR description when they affect exported options or types.
Stability ¶
This package is still marked EXPERIMENTAL. The shape of exported row types (including how TreePart is represented) may change in a future version if we adopt a different internal representation—callers should prefer RowWithPredicates.Text and stable Option entrypoints where possible, and pin module versions when upgrading.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContinuationIndent
deprecated
added in
v0.1.5
type ContinuationIndent int
ContinuationIndent controls how wrapped continuation lines are aligned.
Deprecated: use WithHangingIndent to opt into hanging indent, or omit the option to keep the default tree-aligned continuation behavior.
const ( // ContinuationIndentTree preserves the current behavior: continuation lines align only to the tree prefix. // // Deprecated: omit [WithHangingIndent] to keep the default tree-aligned continuation behavior. ContinuationIndentTree ContinuationIndent = iota // ContinuationIndentNodePrefix hangs continuation lines after a node-local prefix such as `[Input] `. // // Deprecated: use [WithHangingIndent]. ContinuationIndentNodePrefix )
type Option ¶
type Option func(*options)
func DisallowUnknownStats ¶
func DisallowUnknownStats() Option
func WithContinuationIndent
deprecated
added in
v0.1.5
func WithContinuationIndent(indent ContinuationIndent) Option
WithContinuationIndent selects how wrapped continuation lines are aligned. The default ContinuationIndentTree preserves the current behavior. ContinuationIndentNodePrefix is opt-in and hangs continuation lines after a node-local prefix such as `[Input] ` or `[Map] ` when present.
Deprecated: use WithHangingIndent to opt into hanging indent, or omit the option to keep the default tree-aligned continuation behavior.
func WithHangingIndent ¶ added in v0.1.6
func WithHangingIndent() Option
WithHangingIndent hangs wrapped continuation lines after a node-local prefix such as `[Input] ` or `[Map] ` instead of keeping the default tree-aligned indentation.
func WithQueryPlanOptions ¶
func WithQueryPlanOptions(opts ...spannerplan.Option) Option
func WithWrapWidth ¶
WithWrapWidth sets the maximum total rendered line width, including the tree prefix. Node title text is wrapped to the remaining width after accounting for the tree prefix. A value of 0 disables wrapping (consistent with the rendertree CLI default of 0). Negative values make ProcessPlan return an error.
type RowWithPredicates ¶
type RowWithPredicates struct {
ID int32
// TreePart stores everything rendered before NodeText on each visual line: the ASCII tree prefix
// plus any continuation padding inserted by the renderer for wrapping / hanging indent.
// Prefer [RowWithPredicates.TreePartString] or [RowWithPredicates.TreePartLines] instead of
// reading this field directly, so callers stay decoupled if the storage shape changes.
TreePart string
NodeText string
Predicates []string
Keys map[string][]string
ExecutionStats stats.ExecutionStats
ChildLinks map[string][]*spannerplan.ResolvedChildLink
}
func ProcessPlan ¶
func ProcessPlan(qp *spannerplan.QueryPlan, opts ...Option) (rows []RowWithPredicates, err error)
func (RowWithPredicates) FormatID ¶
func (r RowWithPredicates) FormatID() string
func (RowWithPredicates) Text ¶
func (r RowWithPredicates) Text() string
func (RowWithPredicates) TreePartLines ¶ added in v0.1.5
func (r RowWithPredicates) TreePartLines() []string
TreePartLines returns the tree prefix as one string per line of RowWithPredicates.NodeText.
func (RowWithPredicates) TreePartString ¶ added in v0.1.5
func (r RowWithPredicates) TreePartString() string
TreePartString returns the full tree-prefix string (newline-separated lines), matching the historical field encoding. Use this when you need a single string; use RowWithPredicates.TreePartLines for per-line access.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package reference provides a reference implementation for rendering Spanner query plans as ASCII tables with various formatting options.
|
Package reference provides a reference implementation for rendering Spanner query plans as ASCII tables with various formatting options. |
|
tools/genexpected
command
|