Documentation
¶
Overview ¶
Package reference provides a reference implementation for rendering Spanner query plans as ASCII tables with various formatting options.
Go callers should prefer RenderTreeTableWithOptions with functional options. Cross-language integrations, such as WebAssembly or JavaScript wrappers that start from JSON-like configuration, can use RenderTreeTableWithConfig and RenderConfig.
For browser or WebAssembly embeddings, this package is the recommended high-level renderer entrypoint: decode serialized query plan JSON into spannerpb.QueryPlan with protojson, parse string inputs with ParseRenderMode and ParseFormat, then call RenderTreeTableWithConfig with plan.GetPlanNodes(). The repository's examples/wasm/render example shows a small syscall/js wrapper with that flow.
Index ¶
- func RenderTreeTable(planNodes []*sppb.PlanNode, mode RenderMode, format Format, wrapWidth int) (string, error)
- func RenderTreeTableWithConfig(planNodes []*sppb.PlanNode, mode RenderMode, format Format, ...) (string, error)
- func RenderTreeTableWithOptions(planNodes []*sppb.PlanNode, mode RenderMode, format Format, opts ...Option) (string, error)
- type Format
- type Option
- type RenderConfig
- type RenderMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderTreeTable ¶
func RenderTreeTable(planNodes []*sppb.PlanNode, mode RenderMode, format Format, wrapWidth int) (string, error)
RenderTreeTable renders Spanner plan nodes as an ASCII table. It supports different render modes (AUTO, PLAN, PROFILE) and formats (TRADITIONAL, CURRENT, COMPACT). The wrapWidth parameter controls text wrapping (0 disables wrapping).
func RenderTreeTableWithConfig ¶ added in v0.1.8
func RenderTreeTableWithConfig(planNodes []*sppb.PlanNode, mode RenderMode, format Format, config RenderConfig) (string, error)
RenderTreeTableWithConfig renders Spanner plan nodes as an ASCII table using serialization-friendly rendering configuration.
func RenderTreeTableWithOptions ¶ added in v0.1.5
func RenderTreeTableWithOptions(planNodes []*sppb.PlanNode, mode RenderMode, format Format, opts ...Option) (string, error)
RenderTreeTableWithOptions renders Spanner plan nodes as an ASCII table with optional rendering configuration.
Types ¶
type Format ¶
type Format string
Format specifies the formatting style for the query plan output.
const ( // FormatTraditional uses raw metadata format in node titles. FormatTraditional Format = "TRADITIONAL" // FormatCurrent uses modern formatting with labels and angle brackets. FormatCurrent Format = "CURRENT" // FormatCompact uses compact tree rendering with minimal spacing. FormatCompact Format = "COMPACT" )
func ParseFormat ¶
ParseFormat parses a string into a Format. Valid values are "TRADITIONAL", "CURRENT", and "COMPACT" (case-insensitive).
type Option ¶ added in v0.1.5
type Option func(*options)
Option configures optional rendering behavior for RenderTreeTableWithOptions.
func WithHangingIndent ¶ added in v0.1.5
func WithHangingIndent() Option
WithHangingIndent hangs wrapped continuation lines after node-local prefixes such as `[Input] ` and `[Map] ` instead of keeping the default tree-aligned indentation.
func WithWrapWidth ¶ added in v0.1.5
WithWrapWidth sets the maximum total rendered line width, including the tree prefix. A value of 0 disables wrapping. Negative values make RenderTreeTableWithOptions return an error.
type RenderConfig ¶ added in v0.1.8
type RenderConfig struct {
// WrapWidth sets the maximum total rendered line width, including the tree prefix.
// A value of 0 disables wrapping. Negative values make [RenderTreeTableWithConfig] return an error.
WrapWidth int `json:"wrapWidth,omitempty"`
// HangingIndent hangs wrapped continuation lines after node-local prefixes such as
// `[Input] ` and `[Map] ` instead of keeping the default tree-aligned indentation.
HangingIndent bool `json:"hangingIndent,omitempty"`
}
RenderConfig configures optional rendering behavior using serialization-friendly fields.
Use this type for cross-language integrations that start from JSON-like configuration, such as WebAssembly or JavaScript callers. Go callers can continue to use functional Option values with RenderTreeTableWithOptions.
type RenderMode ¶
type RenderMode string
RenderMode specifies how to render the query plan output.
const ( // RenderModeAuto automatically determines whether to show statistics based on availability. RenderModeAuto RenderMode = "AUTO" // RenderModePlan shows only the query plan without statistics. RenderModePlan RenderMode = "PLAN" // RenderModeProfile shows the query plan with execution statistics. RenderModeProfile RenderMode = "PROFILE" )
func ParseRenderMode ¶
func ParseRenderMode(s string) (RenderMode, error)
ParseRenderMode parses a string into a RenderMode. Valid values are "AUTO", "PLAN", and "PROFILE" (case-insensitive).