query

package
v0.11.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultJinjaRenderer = jinja.NewRenderer(jinja.Context{
	"ds":                  time.Now().Format("2006-01-02"),
	"ds_nodash":           time.Now().Format("20060102"),
	"data_interval_start": time.Now().AddDate(0, 0, -1).Format(time.RFC3339),
	"data_interval_end":   time.Now().Format(time.RFC3339),
	"utils": map[string]interface{}{
		"date_add": func(str string, days int) string {
			return str
		},
		"date_format": func(str, inputFormat, outputFormat string) string {
			return str
		},
	},
})

Functions

This section is empty.

Types

type FileQuerySplitterExtractor

type FileQuerySplitterExtractor struct {
	Fs       afero.Fs
	Renderer renderer
}

FileQuerySplitterExtractor is a regular file extractor, but it splits the queries in the given file into multiple instances. For usecases that require EXPLAIN statements, such as validating Snowflake queries, it is not possible to EXPLAIN a multi-query string directly, therefore we have to split them.

func (FileQuerySplitterExtractor) ExtractQueriesFromFile

func (f FileQuerySplitterExtractor) ExtractQueriesFromFile(filepath string) ([]*Query, error)

type Query

type Query struct {
	VariableDefinitions []string
	Query               string
}

func (Query) String

func (q Query) String() string

func (Query) ToDryRunQuery

func (q Query) ToDryRunQuery() string

func (Query) ToExplainQuery

func (q Query) ToExplainQuery() string

type Renderer

type Renderer struct {
	Args map[string]string
}

func (Renderer) Render

func (r Renderer) Render(query string) string

type WholeFileExtractor

type WholeFileExtractor struct {
	Fs       afero.Fs
	Renderer renderer
}

WholeFileExtractor is a regular file extractor that returns the whole file content as the query string. It is useful for cases where the whole file content can be treated as a single query, such as validating GoogleCloudPlatform queries via dry-run.

func (*WholeFileExtractor) ExtractQueriesFromFile

func (f *WholeFileExtractor) ExtractQueriesFromFile(filepath string) ([]*Query, error)

Jump to

Keyboard shortcuts

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