duckdbsql

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AST added in v0.29.1

type AST struct {
	// contains filtered or unexported fields
}

func Parse added in v0.29.1

func Parse(sql string) (*AST, error)

func (*AST) ExtractAnnotations added in v0.29.1

func (a *AST) ExtractAnnotations() map[string]*Annotation

ExtractAnnotations extracts annotations from comments prefixed with '@', and optionally a value after a ':'. Examples: "-- @materialize" and "-- @materialize: true".

func (*AST) ExtractColumnRefs added in v0.29.1

func (a *AST) ExtractColumnRefs() []*ColumnRef

ExtractColumnRefs extracts column references from the outermost SELECT of a DuckDB SQL statement

func (*AST) Format added in v0.29.1

func (a *AST) Format() (string, error)

Format normalizes a DuckDB SQL statement

func (*AST) RewriteLimit added in v0.29.1

func (a *AST) RewriteLimit(limit, offset int) error

RewriteLimit rewrites a DuckDB SQL statement to limit the result size

func (*AST) RewriteTableRefs added in v0.29.1

func (a *AST) RewriteTableRefs(fn func(table *TableRef) (*TableRef, bool)) error

RewriteTableRefs replaces table references in a DuckDB SQL query. Only replacing with a base table reference is supported right now.

type Annotation

type Annotation struct {
	Key   string
	Value string
}

Annotation is key-value annotation extracted from a DuckDB SQL comment

type ColumnRef

type ColumnRef struct {
	Name         string
	RelationName string
	Expr         string
	IsAggr       bool
	IsStar       bool
	IsExclude    bool
}

ColumnRef has information about a column in the select list of a DuckDB SQL statement

type TableRef

type TableRef struct {
	Name       string
	Function   string
	Path       string
	Properties map[string]any
	LocalAlias bool
}

TableRef has information extracted about a DuckDB table or table function reference

Jump to

Keyboard shortcuts

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