Documentation
¶
Overview ¶
Package duckdb implements the DuckDB SQL dialect for cel2sql.
Index ¶
- Constants
- type Dialect
- func (d *Dialect) ConvertRegex(re2Pattern string) (string, bool, error)
- func (d *Dialect) MaxIdentifierLength() int
- func (d *Dialect) Name() dialect.Name
- func (d *Dialect) RecommendIndex(pattern dialect.IndexPattern) *dialect.IndexRecommendation
- func (d *Dialect) ReservedKeywords() map[string]bool
- func (d *Dialect) SupportedPatterns() []dialect.PatternType
- func (d *Dialect) SupportsIndexAnalysis() bool
- func (d *Dialect) SupportsJSONB() bool
- func (d *Dialect) SupportsNativeArrays() bool
- func (d *Dialect) SupportsRegex() bool
- func (d *Dialect) ValidateFieldName(name string) error
- func (d *Dialect) WriteArrayLength(w *strings.Builder, _ int, writeExpr func() error) error
- func (d *Dialect) WriteArrayLiteralClose(w *strings.Builder)
- func (d *Dialect) WriteArrayLiteralOpen(w *strings.Builder)
- func (d *Dialect) WriteArrayMembership(w *strings.Builder, writeElem func() error, writeArray func() error) error
- func (d *Dialect) WriteArraySubqueryExprClose(_ *strings.Builder)
- func (d *Dialect) WriteArraySubqueryOpen(w *strings.Builder)
- func (d *Dialect) WriteBytesLiteral(w *strings.Builder, value []byte) error
- func (d *Dialect) WriteCastToNumeric(w *strings.Builder)
- func (d *Dialect) WriteContains(w *strings.Builder, writeHaystack, writeNeedle func() error) error
- func (d *Dialect) WriteDuration(w *strings.Builder, value int64, unit string)
- func (d *Dialect) WriteEmptyTypedArray(w *strings.Builder, typeName string)
- func (d *Dialect) WriteEpochExtract(w *strings.Builder, writeExpr func() error) error
- func (d *Dialect) WriteExtract(w *strings.Builder, part string, writeExpr func() error, writeTZ func() error) error
- func (d *Dialect) WriteInterval(w *strings.Builder, writeValue func() error, unit string) error
- func (d *Dialect) WriteJSONArrayElements(w *strings.Builder, _ bool, _ bool, writeExpr func() error) error
- func (d *Dialect) WriteJSONArrayLength(w *strings.Builder, writeExpr func() error) error
- func (d *Dialect) WriteJSONArrayMembership(w *strings.Builder, _ string, writeExpr func() error) error
- func (d *Dialect) WriteJSONExistence(w *strings.Builder, _ bool, fieldName string, writeBase func() error) error
- func (d *Dialect) WriteJSONExtractPath(w *strings.Builder, pathSegments []string, writeRoot func() error) error
- func (d *Dialect) WriteJSONFieldAccess(w *strings.Builder, writeBase func() error, fieldName string, isFinal bool) error
- func (d *Dialect) WriteJoin(w *strings.Builder, writeArray, writeDelim func() error) error
- func (d *Dialect) WriteLikeEscape(w *strings.Builder)
- func (d *Dialect) WriteListIndex(w *strings.Builder, writeArray func() error, writeIndex func() error) error
- func (d *Dialect) WriteListIndexConst(w *strings.Builder, writeArray func() error, index int64) error
- func (d *Dialect) WriteNestedJSONArrayMembership(w *strings.Builder, writeExpr func() error) error
- func (d *Dialect) WriteParamPlaceholder(w *strings.Builder, paramIndex int)
- func (d *Dialect) WriteRegexMatch(w *strings.Builder, writeTarget func() error, pattern string, ...) error
- func (d *Dialect) WriteSplit(w *strings.Builder, writeStr, writeDelim func() error) error
- func (d *Dialect) WriteSplitWithLimit(w *strings.Builder, writeStr, writeDelim func() error, limit int64) error
- func (d *Dialect) WriteStringConcat(w *strings.Builder, writeLHS, writeRHS func() error) error
- func (d *Dialect) WriteStringLiteral(w *strings.Builder, value string)
- func (d *Dialect) WriteStructClose(w *strings.Builder)
- func (d *Dialect) WriteStructOpen(w *strings.Builder)
- func (d *Dialect) WriteTimestampArithmetic(w *strings.Builder, op string, writeTS, writeDur func() error) error
- func (d *Dialect) WriteTimestampCast(w *strings.Builder, writeExpr func() error) error
- func (d *Dialect) WriteTypeName(w *strings.Builder, celTypeName string)
- func (d *Dialect) WriteUnnest(w *strings.Builder, writeSource func() error) error
Constants ¶
const (
IndexTypeART = "ART"
)
DuckDB index type constants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dialect ¶
type Dialect struct{}
Dialect implements dialect.Dialect for DuckDB.
func (*Dialect) ConvertRegex ¶
ConvertRegex converts an RE2 regex pattern to DuckDB-compatible format. DuckDB uses RE2 natively, so minimal conversion is needed.
func (*Dialect) MaxIdentifierLength ¶
MaxIdentifierLength returns 0 as DuckDB has no hard identifier length limit.
func (*Dialect) RecommendIndex ¶
func (d *Dialect) RecommendIndex(pattern dialect.IndexPattern) *dialect.IndexRecommendation
RecommendIndex generates a DuckDB-specific index recommendation for the given pattern. DuckDB uses ART (Adaptive Radix Tree) indexes by default. Returns nil for unsupported patterns.
func (*Dialect) ReservedKeywords ¶
ReservedKeywords returns the set of reserved SQL keywords for DuckDB.
func (*Dialect) SupportedPatterns ¶
func (d *Dialect) SupportedPatterns() []dialect.PatternType
SupportedPatterns returns the pattern types supported by DuckDB.
func (*Dialect) SupportsIndexAnalysis ¶
SupportsIndexAnalysis returns true as DuckDB index analysis is supported.
func (*Dialect) SupportsJSONB ¶
SupportsJSONB returns false as DuckDB has a single JSON type.
func (*Dialect) SupportsNativeArrays ¶
SupportsNativeArrays returns true as DuckDB has native array (LIST) types.
func (*Dialect) SupportsRegex ¶
SupportsRegex returns true as DuckDB supports RE2 regex natively.
func (*Dialect) ValidateFieldName ¶
ValidateFieldName validates a field name against DuckDB naming rules.
func (*Dialect) WriteArrayLength ¶
WriteArrayLength writes COALESCE(array_length(expr), 0) for DuckDB.
func (*Dialect) WriteArrayLiteralClose ¶
WriteArrayLiteralClose writes the DuckDB array literal closing (]).
func (*Dialect) WriteArrayLiteralOpen ¶
WriteArrayLiteralOpen writes the DuckDB array literal opening ([).
func (*Dialect) WriteArrayMembership ¶
func (d *Dialect) WriteArrayMembership(w *strings.Builder, writeElem func() error, writeArray func() error) error
WriteArrayMembership writes a DuckDB array membership test using = ANY().
func (*Dialect) WriteArraySubqueryExprClose ¶
WriteArraySubqueryExprClose is a no-op for DuckDB (no wrapper around the expression).
func (*Dialect) WriteArraySubqueryOpen ¶
WriteArraySubqueryOpen writes ARRAY(SELECT for DuckDB.
func (*Dialect) WriteBytesLiteral ¶
WriteBytesLiteral writes a DuckDB hex-encoded byte literal ('\x...').
func (*Dialect) WriteCastToNumeric ¶
WriteCastToNumeric writes a DuckDB numeric cast (::DOUBLE).
func (*Dialect) WriteContains ¶
WriteContains writes CONTAINS(haystack, needle) for DuckDB.
func (*Dialect) WriteDuration ¶
WriteDuration writes a DuckDB INTERVAL literal.
func (*Dialect) WriteEmptyTypedArray ¶
WriteEmptyTypedArray writes an empty DuckDB typed array.
func (*Dialect) WriteEpochExtract ¶
WriteEpochExtract writes EXTRACT(EPOCH FROM expr)::BIGINT for DuckDB.
func (*Dialect) WriteExtract ¶
func (d *Dialect) WriteExtract(w *strings.Builder, part string, writeExpr func() error, writeTZ func() error) error
WriteExtract writes a DuckDB EXTRACT expression with DOW conversion.
func (*Dialect) WriteInterval ¶
WriteInterval writes a DuckDB INTERVAL expression.
func (*Dialect) WriteJSONArrayElements ¶
func (d *Dialect) WriteJSONArrayElements(w *strings.Builder, _ bool, _ bool, writeExpr func() error) error
WriteJSONArrayElements writes DuckDB JSON array expansion using json_each.
func (*Dialect) WriteJSONArrayLength ¶
WriteJSONArrayLength writes COALESCE(json_array_length(expr), 0) for DuckDB.
func (*Dialect) WriteJSONArrayMembership ¶
func (d *Dialect) WriteJSONArrayMembership(w *strings.Builder, _ string, writeExpr func() error) error
WriteJSONArrayMembership writes DuckDB JSON array membership using json_each.
func (*Dialect) WriteJSONExistence ¶
func (d *Dialect) WriteJSONExistence(w *strings.Builder, _ bool, fieldName string, writeBase func() error) error
WriteJSONExistence writes a DuckDB JSON key existence check using json_exists.
func (*Dialect) WriteJSONExtractPath ¶
func (d *Dialect) WriteJSONExtractPath(w *strings.Builder, pathSegments []string, writeRoot func() error) error
WriteJSONExtractPath writes DuckDB JSON path existence using json_exists.
func (*Dialect) WriteJSONFieldAccess ¶
func (d *Dialect) WriteJSONFieldAccess(w *strings.Builder, writeBase func() error, fieldName string, isFinal bool) error
WriteJSONFieldAccess writes DuckDB JSON field access using -> or ->> operators.
func (*Dialect) WriteLikeEscape ¶
WriteLikeEscape writes the DuckDB LIKE escape clause.
func (*Dialect) WriteListIndex ¶
func (d *Dialect) WriteListIndex(w *strings.Builder, writeArray func() error, writeIndex func() error) error
WriteListIndex writes DuckDB 1-indexed array access.
func (*Dialect) WriteListIndexConst ¶
func (d *Dialect) WriteListIndexConst(w *strings.Builder, writeArray func() error, index int64) error
WriteListIndexConst writes DuckDB constant array index access (0-indexed to 1-indexed).
func (*Dialect) WriteNestedJSONArrayMembership ¶
WriteNestedJSONArrayMembership writes DuckDB nested JSON array membership.
func (*Dialect) WriteParamPlaceholder ¶
WriteParamPlaceholder writes a DuckDB positional parameter ($1, $2, ...).
func (*Dialect) WriteRegexMatch ¶
func (d *Dialect) WriteRegexMatch(w *strings.Builder, writeTarget func() error, pattern string, caseInsensitive bool) error
WriteRegexMatch writes a DuckDB regex match expression using ~ or ~*.
func (*Dialect) WriteSplit ¶
WriteSplit writes DuckDB string split using STRING_SPLIT.
func (*Dialect) WriteSplitWithLimit ¶
func (d *Dialect) WriteSplitWithLimit(w *strings.Builder, writeStr, writeDelim func() error, limit int64) error
WriteSplitWithLimit writes DuckDB string split with array slice.
func (*Dialect) WriteStringConcat ¶
WriteStringConcat writes DuckDB string concatenation using ||.
func (*Dialect) WriteStringLiteral ¶
WriteStringLiteral writes a DuckDB string literal with ” escaping.
func (*Dialect) WriteStructClose ¶
WriteStructClose writes the DuckDB struct literal closing.
func (*Dialect) WriteStructOpen ¶
WriteStructOpen writes the DuckDB struct literal opening.
func (*Dialect) WriteTimestampArithmetic ¶
func (d *Dialect) WriteTimestampArithmetic(w *strings.Builder, op string, writeTS, writeDur func() error) error
WriteTimestampArithmetic writes DuckDB timestamp arithmetic.
func (*Dialect) WriteTimestampCast ¶
WriteTimestampCast writes a DuckDB CAST to TIMESTAMPTZ.
func (*Dialect) WriteTypeName ¶
WriteTypeName writes a DuckDB type name for CAST expressions.