duckdbsql

package
v0.29.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(sql string) (string, error)

Format normalizes a DuckDB SQL statement

func RewriteLimit

func RewriteLimit(sql string, limit, offset int) (string, error)

RewriteLimit rewrites a DuckDB SQL statement to limit the result size

func RewriteTableRefs

func RewriteTableRefs(sql string, fn func(table *TableRef) (*TableRef, bool)) (string, error)

RewriteTableRefs replaces table references in a DuckDB SQL query

func Sanitize

func Sanitize(sql string) (string, error)

Sanitize strips comments and normalizes a DuckDB SQL statement

Types

type Annotation

type Annotation struct {
	Key   string
	Value string
}

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

func ExtractAnnotations

func ExtractAnnotations() ([]*Annotation, error)

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

type ColumnRef

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

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

func ExtractColumnRefs

func ExtractColumnRefs(sql string) ([]*ColumnRef, error)

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

type TableRef

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

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

func ExtractTableRefs

func ExtractTableRefs(sql string) ([]*TableRef, error)

ExtractTableRefs extracts table references from a DuckDB SQL query

Jump to

Keyboard shortcuts

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