jinja

package
v0.11.604 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Filters *exec.FilterSet

Functions

func BacktickQuoteIdentifier added in v0.11.598

func BacktickQuoteIdentifier(identifier string) string

BacktickQuoteIdentifier quotes an identifier with backticks.

func BigQueryDateSpine added in v0.11.598

func BigQueryDateSpine(datepart, startDate, endDate string) string

BigQueryDateSpine builds date_spine using BigQuery's array generators.

func BigQueryQuoteIdentifier added in v0.11.598

func BigQueryQuoteIdentifier(identifier string) string

BigQueryQuoteIdentifier quotes a GoogleSQL identifier with backticks and backslash-escaped backticks.

func BigQueryURLHelpers added in v0.11.598

func BigQueryURLHelpers() map[string]any

BigQueryURLHelpers returns URL helpers using BigQuery regex functions.

func BigQueryWidthBucket added in v0.11.598

func BigQueryWidthBucket(expr, minValue, maxValue, numBuckets string) string

BigQueryWidthBucket builds standard width_bucket behavior for BigQuery, which has no native function.

func BracketQuoteIdentifier added in v0.11.598

func BracketQuoteIdentifier(identifier string) string

BracketQuoteIdentifier quotes an identifier with SQL Server square brackets.

func BuiltinFunctions added in v0.11.598

func BuiltinFunctions(platform ...Platform) map[string]any

BuiltinFunctions returns a map of built-in SQL helper functions for use in Jinja templates. When a platform is specified, any registered overrides for that platform are merged on top of defaults.

func ClickHouseDateSpine added in v0.11.598

func ClickHouseDateSpine(datepart, startDate, endDate string) string

ClickHouseDateSpine builds date_spine using numbers and dateDiff/dateAdd.

func ClickHouseURLHelpers added in v0.11.598

func ClickHouseURLHelpers() map[string]any

ClickHouseURLHelpers returns URL helpers using ClickHouse regex functions.

func ClickHouseWidthBucket added in v0.11.598

func ClickHouseWidthBucket(expr, minValue, maxValue, numBuckets string) string

ClickHouseWidthBucket builds standard width_bucket behavior for ClickHouse.

func ConcatFunction added in v0.11.598

func ConcatFunction(parts []string) string

ConcatFunction joins expressions with a variadic concat function, returning the expression unchanged for one part.

func ConcatOperator added in v0.11.598

func ConcatOperator(parts []string) string

ConcatOperator joins expressions with the ANSI string concatenation operator.

func DateSpineWithDateAdd added in v0.11.598

func DateSpineWithDateAdd(dateAddFn func(datepart, n, start string) string) func(string, string, string) string

DateSpineWithDateAdd builds a date_spine function using the given date-addition expression builder.

func DateSpineWithDateAddAndDateDiff added in v0.11.598

func DateSpineWithDateAddAndDateDiff(withRecursive bool, suffix string, dateAddFn, dateDiffFn func(datepart, start, end string) string) func(string, string, string) string

DateSpineWithDateAddAndDateDiff builds a recursive date_spine function using an interval count.

func DateSpineWithRecursiveDateAdd added in v0.11.598

func DateSpineWithRecursiveDateAdd(withRecursive bool, suffix string, dateAddFn func(datepart, n, start string) string) func(string, string, string) string

DateSpineWithRecursiveDateAdd builds a recursive CTE date_spine function.

func DoubleQuoteIdentifier added in v0.11.598

func DoubleQuoteIdentifier(identifier string) string

DoubleQuoteIdentifier quotes an identifier with ANSI double quotes.

func DuckDBDateSpine added in v0.11.598

func DuckDBDateSpine(datepart, startDate, endDate string) string

DuckDBDateSpine builds date_spine using DuckDB's generate_series table function.

func DuckDBGenerateSeries added in v0.11.598

func DuckDBGenerateSeries(upperBound int) string

DuckDBGenerateSeries uses DuckDB's native integer series generator.

func HaversineDistanceWithRadians added in v0.11.598

func HaversineDistanceWithRadians(radiansFn func(expr string) string) func(*exec.VarArgs) (*exec.Value, error)

HaversineDistanceWithRadians builds a haversine_distance function using the given radians conversion.

func IntervalStepLiteral added in v0.11.598

func IntervalStepLiteral(datepart string) string

IntervalStepLiteral returns a SQL interval literal body for dateparts that are not universally accepted as interval units.

func IsTimestampDatepart added in v0.11.598

func IsTimestampDatepart(datepart string) bool

IsTimestampDatepart reports whether a date_spine datepart needs timestamp rather than date values.

func LoadMacros added in v0.11.320

func LoadMacros(fs afero.Fs, macrosPath string) (string, error)

LoadMacros loads all macro files from the given directory and returns them as a single string.

func MergeBuiltinOverrides added in v0.11.598

func MergeBuiltinOverrides(overrides ...map[string]any) map[string]any

MergeBuiltinOverrides combines override maps left-to-right.

func MySQLDateSpine added in v0.11.598

func MySQLDateSpine(datepart, startDate, endDate string) string

MySQLDateSpine builds a recursive date_spine with MySQL casts and a per-query recursion-depth hint.

func MySQLURLHelpers added in v0.11.598

func MySQLURLHelpers() map[string]any

MySQLURLHelpers returns URL helpers using MySQL string functions.

func NativeWidthBucket added in v0.11.598

func NativeWidthBucket(expr, minValue, maxValue, numBuckets string) string

NativeWidthBucket returns a platform-native width_bucket implementation.

func OracleDateSpine added in v0.11.598

func OracleDateSpine(datepart, startDate, endDate string) string

OracleDateSpine builds date_spine using CONNECT BY LEVEL.

func OracleURLHelpers added in v0.11.598

func OracleURLHelpers() map[string]any

OracleURLHelpers returns URL helpers using Oracle regex functions.

func PivotWithIdentifierQuote added in v0.11.598

func PivotWithIdentifierQuote(quoteIdentifier func(string) string) func(*exec.VarArgs) *exec.Value

PivotWithIdentifierQuote builds a pivot function using platform-specific quoted identifier syntax.

func PostgresDateSpine added in v0.11.598

func PostgresDateSpine(datepart, startDate, endDate string) string

PostgresDateSpine builds date_spine using Postgres generate_series.

func PrestoDateSpine added in v0.11.598

func PrestoDateSpine(datepart, startDate, endDate string) string

PrestoDateSpine builds date_spine for Trino/Athena using sequence + unnest.

func PrestoURLHelpers added in v0.11.598

func PrestoURLHelpers() map[string]any

PrestoURLHelpers returns URL helpers for Trino/Athena.

func PythonEnvVariables added in v0.5.7

func PythonEnvVariables(startDate, endDate, executionDate *time.Time, pipelineName, runID string, fullRefresh bool, commitHash string) map[string]string

func RegisterPlatformOverrides added in v0.11.598

func RegisterPlatformOverrides(platform Platform, overrides map[string]any)

RegisterPlatformOverrides registers platform-specific function overrides. Platform packages call this in their init() to replace default built-in functions with platform-appropriate SQL generation. The platform package must be imported (directly or transitively) for its init() to execute.

func SparkDateSpine added in v0.11.598

func SparkDateSpine(datepart, startDate, endDate string) string

SparkDateSpine builds date_spine using Spark/Databricks sequence + explode.

func SparkURLHelpers added in v0.11.598

func SparkURLHelpers() map[string]any

SparkURLHelpers returns URL helpers using Spark/Databricks regex functions.

func SplitPartURLHelpers added in v0.11.598

func SplitPartURLHelpers(castType string) map[string]any

SplitPartURLHelpers returns URL helpers for dialects that support split_part, position, right, and SQL-standard casts.

func SurrogateKeyNullValue added in v0.11.598

func SurrogateKeyNullValue() string

SurrogateKeyNullValue returns the sentinel used to preserve null positions while hashing.

func SurrogateKeyWith added in v0.11.598

func SurrogateKeyWith(castType string, hashFn func(concatExpr string) string) func(*exec.VarArgs) *exec.Value

SurrogateKeyWith builds a generate_surrogate_key function using the given cast type and hash wrapper.

func SurrogateKeyWithCoalesceExpr added in v0.11.598

func SurrogateKeyWithCoalesceExpr(valueFn func(field string) string, concatFn func(parts []string) string, hashFn func(concatExpr string) string) func(*exec.VarArgs) *exec.Value

SurrogateKeyWithCoalesceExpr builds a generate_surrogate_key function using a caller-provided per-field expression.

func SurrogateKeyWithConcat added in v0.11.598

func SurrogateKeyWithConcat(castType string, concatFn func(parts []string) string, hashFn func(concatExpr string) string) func(*exec.VarArgs) *exec.Value

SurrogateKeyWithConcat builds a generate_surrogate_key function using platform-specific concat and hash syntax.

func TSQLDateSpine added in v0.11.598

func TSQLDateSpine(datepart, startDate, endDate string) string

TSQLDateSpine builds date_spine for SQL Server-family dialects.

func TSQLDateSpineWithTally added in v0.11.598

func TSQLDateSpineWithTally(datepart, startDate, endDate string) string

TSQLDateSpineWithTally builds date_spine without recursive CTEs for Synapse/Fabric.

func TSQLURLHelpers added in v0.11.598

func TSQLURLHelpers() map[string]any

TSQLURLHelpers returns URL helpers for SQL Server-family dialects.

func TSQLWidthBucket added in v0.11.598

func TSQLWidthBucket(expr, minValue, maxValue, numBuckets string) string

TSQLWidthBucket builds standard width_bucket behavior using T-SQL math functions.

func VariantRendererFactory added in v0.11.557

func VariantRendererFactory(vars map[string]any, variantName string) pipeline.RenderFunc

VariantRendererFactory satisfies pipeline.VariantRendererFactory using a fresh Jinja renderer per call. Pass it into pipeline.NewBuilder so WithVariant / CreatePipelinesFromPath can materialize variants without callers having to construct a renderer.

The renderer's context exposes only `var` (the merged variable values) and `variant` (the variant name). Run-time variables like start_date / end_date / this are deliberately absent — variant materialization is only meant to resolve identity and structural fields.

Types

type Context

type Context map[string]any

type FileSystemLoader added in v0.11.320

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

FileSystemLoader loads templates from a file system directory.

func NewFileSystemLoader added in v0.11.320

func NewFileSystemLoader(fs afero.Fs, baseDir string) *FileSystemLoader

NewFileSystemLoader creates a new FileSystemLoader for the given base directory.

func (*FileSystemLoader) Inherit added in v0.11.320

func (l *FileSystemLoader) Inherit(from string) (interface{}, error)

Inherit creates a new loader relative to the given path.

func (*FileSystemLoader) Read added in v0.11.320

func (l *FileSystemLoader) Read(path string) (io.Reader, error)

Read returns an io.Reader for the template's content.

func (*FileSystemLoader) Resolve added in v0.11.320

func (l *FileSystemLoader) Resolve(path string) (string, error)

Resolve resolves the given path in the current context.

type Platform added in v0.11.598

type Platform string

Platform represents a target database platform for SQL generation.

const (
	PlatformDefault    Platform = ""
	PlatformBigQuery   Platform = "bigquery"
	PlatformSnowflake  Platform = "snowflake"
	PlatformPostgres   Platform = "postgres"
	PlatformRedshift   Platform = "redshift"
	PlatformMySQL      Platform = "mysql"
	PlatformDuckDB     Platform = "duckdb"
	PlatformDatabricks Platform = "databricks"
	PlatformMSSQL      Platform = "mssql"
	PlatformClickhouse Platform = "clickhouse"
	PlatformAthena     Platform = "athena"
	PlatformTrino      Platform = "trino"
	PlatformSynapse    Platform = "synapse"
	PlatformOracle     Platform = "oracle"
	PlatformFabric     Platform = "fabric"
	PlatformVertica    Platform = "vertica"
)

func PlatformForAssetType added in v0.11.598

func PlatformForAssetType(assetType pipeline.AssetType) Platform

PlatformForAssetType resolves the SQL generation platform for the given asset type.

type Renderer

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

func NewRenderer

func NewRenderer(context Context) *Renderer

func NewRendererWithMacros added in v0.11.320

func NewRendererWithMacros(context Context, macroContent string) *Renderer

NewRendererWithMacros creates a new Renderer with the given context and macro content.

func NewRendererWithStartEndDates

func NewRendererWithStartEndDates(startDate, endDate, executionDate *time.Time, pipelineName, runID string, vars Context) *Renderer

func NewRendererWithStartEndDatesAndMacros added in v0.11.320

func NewRendererWithStartEndDatesAndMacros(startDate, endDate, executionDate *time.Time, pipelineName, runID string, vars Context, macroContent string) *Renderer

NewRendererWithStartEndDatesAndMacros creates a new Renderer with the given dates, context, and macro content.

func NewRendererWithYesterday added in v0.5.3

func NewRendererWithYesterday(pipelineName, runID string) *Renderer

func (*Renderer) CloneForAsset added in v0.11.209

func (r *Renderer) CloneForAsset(ctx context.Context, pipe *pipeline.Pipeline, asset *pipeline.Asset) (RendererInterface, error)

func (*Renderer) Render

func (r *Renderer) Render(query string) (string, error)

func (*Renderer) SetContextValue added in v0.11.488

func (r *Renderer) SetContextValue(key string, value any)

SetContextValue sets a top-level variable in the Jinja rendering context. Note: values set this way are NOT preserved across CloneForAsset calls; callers must re-apply them on the cloned renderer.

type RendererInterface added in v0.11.209

type RendererInterface interface {
	Render(query string) (string, error)
	CloneForAsset(ctx context.Context, pipeline *pipeline.Pipeline, asset *pipeline.Asset) (RendererInterface, error)
}

this ugly interface is needed to avoid circular dependencies and the ability to create different renderer instances per asset.

Jump to

Keyboard shortcuts

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