explain

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package explain provides EXPLAIN AST output functionality for ClickHouse SQL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Column

func Column(sb *strings.Builder, col *ast.ColumnDeclaration, depth int)

Column handles column declarations

func EscapeIdentifier

func EscapeIdentifier(s string) string

EscapeIdentifier escapes single quotes in identifiers for EXPLAIN AST output ClickHouse escapes ' as \' in identifier names

func Explain

func Explain(stmt ast.Statement) string

Explain returns the EXPLAIN AST output for a statement, matching ClickHouse's format.

func ExplainSelectWithInheritedWith

func ExplainSelectWithInheritedWith(sb *strings.Builder, stmt ast.Statement, inheritedWith []ast.Expression, depth int)

ExplainSelectWithInheritedWith recursively explains a select statement with inherited WITH clause This is used for WITH ... INSERT ... SELECT where the WITH clause belongs to the INSERT but needs to be output at the end of each SelectQuery in the tree

func ExplainStatements

func ExplainStatements(stmts []ast.Statement) string

ExplainStatements returns the EXPLAIN AST output for multiple statements. This handles the special ClickHouse behavior where INSERT VALUES followed by SELECT on the same line outputs the INSERT AST and then executes the SELECT, printing its result.

func FormatDataType

func FormatDataType(dt *ast.DataType) string

FormatDataType formats a DataType for EXPLAIN AST output

func FormatFloat

func FormatFloat(val float64) string

FormatFloat formats a float value for EXPLAIN AST output

func FormatLiteral

func FormatLiteral(lit *ast.Literal) string

FormatLiteral formats a literal value for EXPLAIN AST output

func Index

func Index(sb *strings.Builder, idx *ast.IndexDefinition, depth int)

func Node

func Node(sb *strings.Builder, node interface{}, depth int)

Node writes the EXPLAIN AST output for an AST node.

func NormalizeFunctionName

func NormalizeFunctionName(name string) string

NormalizeFunctionName normalizes function names to match ClickHouse's EXPLAIN AST output

func OperatorToFunction

func OperatorToFunction(op string) string

OperatorToFunction maps binary operators to ClickHouse function names

func TablesWithArrayJoin

func TablesWithArrayJoin(sb *strings.Builder, from *ast.TablesInSelectQuery, arrayJoin *ast.ArrayJoinClause, depth int)

TablesWithArrayJoin handles FROM and ARRAY JOIN together as TablesInSelectQuery

func UnaryOperatorToFunction

func UnaryOperatorToFunction(op string) string

UnaryOperatorToFunction maps unary operators to ClickHouse function names

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL