Documentation
¶
Index ¶
- func Db2QuoteIdentifier(identifier string) string
- func Db2QuoteIfNeeded(identifier string) string
- func IsLower(s string) bool
- func IsUpper(s string) bool
- func MSSQLQuoteIdentifier(identifier string) string
- func OracleQuoteIdentifier(identifier string) string
- func OracleQuoteIfNeeded(identifier string) string
- func PqQuoteIdentifierIfUpper(identifier string) string
- func QuoteForFoldLower(identifier string) string
- func QuoteForFoldUpper(identifier string) string
- func QuoteWithBackticksIfNeeded(identifier string) string
- func QuoteWithBracketsIfNeeded(identifier string) string
- func QuoteWithDoubleQuotesIfNeeded(identifier string) string
- func SplitQualifiedIdent(text string) []string
- func StandardSQLStringLiteral(s string) string
- type AggregationColumnReferenceExpr
- type AliasExpr
- type AndGroupsExpr
- type ArgExpr
- type AsExpr
- type BetweenExpr
- type BigQueryDialect
- func (d *BigQueryDialect) AddTime(expr Expr, duration time.Duration) Expr
- func (d *BigQueryDialect) AggregationColumnReference(expression Expr, alias string) Expr
- func (d *BigQueryDialect) CeilTime(expr Expr, interval time.Duration) Expr
- func (d *BigQueryDialect) Coalesce(exprs ...Expr) Expr
- func (d *BigQueryDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
- func (d *BigQueryDialect) Count(expr Expr) Expr
- func (d *BigQueryDialect) CountIf(expr Expr) Expr
- func (d *BigQueryDialect) CurrentTimestamp() Expr
- func (d *BigQueryDialect) DateLiteral(t time.Time) string
- func (d *BigQueryDialect) FoldIdent(name string) string
- func (d *BigQueryDialect) FormatLimit(rowsSql string) string
- func (d *BigQueryDialect) Identifier(identifier string) string
- func (d *BigQueryDialect) Median(expr Expr) Expr
- func (d *BigQueryDialect) NumericLiteral(s string) (string, error)
- func (d *BigQueryDialect) QuoteIdent(name string) string
- func (d *BigQueryDialect) ResolveFieldRef(name string) string
- func (d *BigQueryDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
- func (d *BigQueryDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
- func (d *BigQueryDialect) ResolveTime(t time.Time) (string, error)
- func (d *BigQueryDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
- func (d *BigQueryDialect) RoundTime(expr Expr, duration time.Duration) Expr
- func (d *BigQueryDialect) Stddev(expr Expr) Expr
- func (d *BigQueryDialect) StringLength(expr Expr) Expr
- func (d *BigQueryDialect) StringLiteral(s string) string
- func (d *BigQueryDialect) SubString(expr Expr, start int64, length int64) Expr
- func (d *BigQueryDialect) SubTime(expr Expr, duration time.Duration) Expr
- func (d *BigQueryDialect) SupportsAsBeforeTableAlias() bool
- func (d *BigQueryDialect) SupportsCrossDatabaseQueries() bool
- func (d *BigQueryDialect) TimestampLiteral(t time.Time) string
- func (d *BigQueryDialect) TimestampTzLiteral(t time.Time) string
- func (d *BigQueryDialect) ToFloat64(expr Expr) Expr
- func (d *BigQueryDialect) ToString(expr Expr) Expr
- func (d *BigQueryDialect) UUIDLiteral(s string) string
- func (d *BigQueryDialect) UnquoteIdent(text string) (string, bool)
- type CaseExpr
- type ClickHouseDialect
- func (d *ClickHouseDialect) AddTime(expr Expr, duration time.Duration) Expr
- func (d *ClickHouseDialect) AggregationColumnReference(expression Expr, alias string) Expr
- func (d *ClickHouseDialect) CeilTime(expr Expr, interval time.Duration) Expr
- func (d *ClickHouseDialect) Coalesce(exprs ...Expr) Expr
- func (d *ClickHouseDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
- func (d *ClickHouseDialect) Count(expr Expr) Expr
- func (d *ClickHouseDialect) CountIf(expr Expr) Expr
- func (d *ClickHouseDialect) CurrentTimestamp() Expr
- func (d *ClickHouseDialect) DateLiteral(t time.Time) string
- func (d *ClickHouseDialect) FoldIdent(name string) string
- func (d *ClickHouseDialect) FormatLimit(rowsSql string) string
- func (d *ClickHouseDialect) Identifier(identifier string) string
- func (d *ClickHouseDialect) Median(expr Expr) Expr
- func (d *ClickHouseDialect) NumericLiteral(s string) (string, error)
- func (d *ClickHouseDialect) QuoteIdent(name string) string
- func (d *ClickHouseDialect) ResolveFieldRef(name string) string
- func (d *ClickHouseDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
- func (d *ClickHouseDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
- func (d *ClickHouseDialect) ResolveTime(t time.Time) (string, error)
- func (d *ClickHouseDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
- func (d *ClickHouseDialect) RoundTime(expr Expr, duration time.Duration) Expr
- func (d *ClickHouseDialect) Stddev(expr Expr) Expr
- func (d *ClickHouseDialect) StringLength(expr Expr) Expr
- func (d *ClickHouseDialect) StringLiteral(s string) string
- func (d *ClickHouseDialect) SubString(expr Expr, start int64, length int64) Expr
- func (d *ClickHouseDialect) SubTime(expr Expr, duration time.Duration) Expr
- func (d *ClickHouseDialect) SupportsAsBeforeTableAlias() bool
- func (d *ClickHouseDialect) SupportsCrossDatabaseQueries() bool
- func (d *ClickHouseDialect) TimestampLiteral(t time.Time) string
- func (d *ClickHouseDialect) TimestampTzLiteral(t time.Time) string
- func (d *ClickHouseDialect) ToFloat64(expr Expr) Expr
- func (d *ClickHouseDialect) ToString(expr Expr) Expr
- func (d *ClickHouseDialect) UUIDLiteral(s string) string
- func (d *ClickHouseDialect) UnquoteIdent(text string) (string, bool)
- type CoalesceExpr
- type ColBaseExpr
- type CompareExpr
- type CompareFn
- type CondExpr
- type CountAllExpr
- type CrossJoinExpr
- type Cte
- type CteAliasExpr
- type CteExpr
- type DatabricksDialect
- func (d *DatabricksDialect) AddTime(expr Expr, duration time.Duration) Expr
- func (d *DatabricksDialect) AggregationColumnReference(expression Expr, alias string) Expr
- func (d *DatabricksDialect) CeilTime(expr Expr, interval time.Duration) Expr
- func (d *DatabricksDialect) Coalesce(exprs ...Expr) Expr
- func (d *DatabricksDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
- func (d *DatabricksDialect) Count(expr Expr) Expr
- func (d *DatabricksDialect) CountIf(expr Expr) Expr
- func (d *DatabricksDialect) CurrentTimestamp() Expr
- func (d *DatabricksDialect) DateLiteral(t time.Time) string
- func (d *DatabricksDialect) FoldIdent(name string) string
- func (d *DatabricksDialect) FormatLimit(rowsSql string) string
- func (d *DatabricksDialect) Identifier(identifier string) string
- func (d *DatabricksDialect) Median(expr Expr) Expr
- func (d *DatabricksDialect) NumericLiteral(s string) (string, error)
- func (d *DatabricksDialect) QuoteIdent(name string) string
- func (d *DatabricksDialect) ResolveFieldRef(name string) string
- func (d *DatabricksDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
- func (d *DatabricksDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
- func (d *DatabricksDialect) ResolveTime(t time.Time) (string, error)
- func (d *DatabricksDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
- func (d *DatabricksDialect) RoundTime(expr Expr, duration time.Duration) Expr
- func (d *DatabricksDialect) Stddev(expr Expr) Expr
- func (d *DatabricksDialect) StringLength(expr Expr) Expr
- func (d *DatabricksDialect) StringLiteral(s string) string
- func (d *DatabricksDialect) SubString(expr Expr, start int64, length int64) Expr
- func (d *DatabricksDialect) SubTime(expr Expr, duration time.Duration) Expr
- func (d *DatabricksDialect) SupportsAsBeforeTableAlias() bool
- func (d *DatabricksDialect) SupportsCrossDatabaseQueries() bool
- func (d *DatabricksDialect) TimestampLiteral(t time.Time) string
- func (d *DatabricksDialect) TimestampTzLiteral(t time.Time) string
- func (d *DatabricksDialect) ToFloat64(expr Expr) Expr
- func (d *DatabricksDialect) ToString(expr Expr) Expr
- func (d *DatabricksDialect) UUIDLiteral(s string) string
- func (d *DatabricksDialect) UnquoteIdent(text string) (string, bool)
- type Db2Dialect
- func (d *Db2Dialect) AddTime(expr Expr, duration time.Duration) Expr
- func (d *Db2Dialect) AggregationColumnReference(expression Expr, alias string) Expr
- func (d *Db2Dialect) CeilTime(expr Expr, interval time.Duration) Expr
- func (d *Db2Dialect) Coalesce(exprs ...Expr) Expr
- func (d *Db2Dialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
- func (d *Db2Dialect) Count(expr Expr) Expr
- func (d *Db2Dialect) CountIf(expr Expr) Expr
- func (d *Db2Dialect) CurrentTimestamp() Expr
- func (d *Db2Dialect) DateLiteral(t time.Time) string
- func (d *Db2Dialect) FoldIdent(name string) string
- func (d *Db2Dialect) FormatLimit(rowsSql string) string
- func (d *Db2Dialect) Identifier(identifier string) string
- func (d *Db2Dialect) Median(expr Expr) Expr
- func (d *Db2Dialect) NumericLiteral(s string) (string, error)
- func (d *Db2Dialect) QuoteIdent(name string) string
- func (d *Db2Dialect) ResolveFieldRef(name string) string
- func (d *Db2Dialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
- func (d *Db2Dialect) ResolveTableFunction(t *TableFnExpr) (string, error)
- func (d *Db2Dialect) ResolveTime(t time.Time) (string, error)
- func (d *Db2Dialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
- func (d *Db2Dialect) RoundTime(expr Expr, interval time.Duration) Expr
- func (d *Db2Dialect) Stddev(expr Expr) Expr
- func (d *Db2Dialect) StringLength(expr Expr) Expr
- func (d *Db2Dialect) StringLiteral(s string) string
- func (d *Db2Dialect) SubString(expr Expr, start int64, length int64) Expr
- func (d *Db2Dialect) SubTime(expr Expr, duration time.Duration) Expr
- func (d *Db2Dialect) SupportsAsBeforeTableAlias() bool
- func (d *Db2Dialect) SupportsCrossDatabaseQueries() bool
- func (d *Db2Dialect) TimestampLiteral(t time.Time) string
- func (d *Db2Dialect) TimestampTzLiteral(t time.Time) string
- func (d *Db2Dialect) ToFloat64(expr Expr) Expr
- func (d *Db2Dialect) ToString(expr Expr) Expr
- func (d *Db2Dialect) UUIDLiteral(s string) string
- func (d *Db2Dialect) UnquoteIdent(text string) (string, bool)
- type Dialect
- type DistinctExpr
- type DuckDBDialect
- func (d *DuckDBDialect) AddTime(expr Expr, duration time.Duration) Expr
- func (d *DuckDBDialect) AggregationColumnReference(expression Expr, alias string) Expr
- func (d *DuckDBDialect) CeilTime(expr Expr, interval time.Duration) Expr
- func (d *DuckDBDialect) Coalesce(exprs ...Expr) Expr
- func (d *DuckDBDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
- func (d *DuckDBDialect) Count(expr Expr) Expr
- func (d *DuckDBDialect) CountIf(expr Expr) Expr
- func (d *DuckDBDialect) CurrentTimestamp() Expr
- func (d *DuckDBDialect) DateLiteral(t time.Time) string
- func (d *DuckDBDialect) FoldIdent(name string) string
- func (d *DuckDBDialect) FormatLimit(rowsSql string) string
- func (d *DuckDBDialect) Identifier(identifier string) string
- func (d *DuckDBDialect) Median(expr Expr) Expr
- func (d *DuckDBDialect) NumericLiteral(s string) (string, error)
- func (d *DuckDBDialect) QuoteIdent(name string) string
- func (d *DuckDBDialect) ResolveFieldRef(name string) string
- func (d *DuckDBDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
- func (d *DuckDBDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
- func (d *DuckDBDialect) ResolveTime(t time.Time) (string, error)
- func (d *DuckDBDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
- func (d *DuckDBDialect) RoundTime(expr Expr, interval time.Duration) Expr
- func (d *DuckDBDialect) Stddev(expr Expr) Expr
- func (d *DuckDBDialect) StringLength(expr Expr) Expr
- func (d *DuckDBDialect) StringLiteral(s string) string
- func (d *DuckDBDialect) SubString(expr Expr, start int64, length int64) Expr
- func (d *DuckDBDialect) SubTime(expr Expr, duration time.Duration) Expr
- func (d *DuckDBDialect) SupportsAsBeforeTableAlias() bool
- func (d *DuckDBDialect) SupportsCrossDatabaseQueries() bool
- func (d *DuckDBDialect) TimestampLiteral(t time.Time) string
- func (d *DuckDBDialect) TimestampTzLiteral(t time.Time) string
- func (d *DuckDBDialect) ToFloat64(expr Expr) Expr
- func (d *DuckDBDialect) ToString(expr Expr) Expr
- func (d *DuckDBDialect) UUIDLiteral(s string) string
- func (d *DuckDBDialect) UnquoteIdent(text string) (string, bool)
- type Expr
- type FabricDialect
- func (d *FabricDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
- func (d *FabricDialect) SupportsCrossDatabaseQueries() bool
- func (d *FabricDialect) TimestampLiteral(t time.Time) string
- func (d *FabricDialect) TimestampTzLiteral(t time.Time) string
- func (d *FabricDialect) ToString(expr Expr) Expr
- type FnCondExpr
- type FnExpr
- type Ident
- type IdentifierExpr
- type InExpr
- type IntLitExpr
- type JoinDefExpr
- type JoinExpr
- type JoinOnExpr
- type JoinTableExpr
- type JoinUsingExpr
- type LimitClauseExpr
- type LimitExpr
- type MSSQLDialect
- func (d *MSSQLDialect) AddTime(expr Expr, duration time.Duration) Expr
- func (d *MSSQLDialect) AggregationColumnReference(expression Expr, alias string) Expr
- func (d *MSSQLDialect) CeilTime(expr Expr, interval time.Duration) Expr
- func (d *MSSQLDialect) Coalesce(exprs ...Expr) Expr
- func (d *MSSQLDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
- func (d *MSSQLDialect) Count(expr Expr) Expr
- func (d *MSSQLDialect) CountIf(expr Expr) Expr
- func (d *MSSQLDialect) CurrentTimestamp() Expr
- func (d *MSSQLDialect) DateLiteral(t time.Time) string
- func (d *MSSQLDialect) FoldIdent(name string) string
- func (d *MSSQLDialect) FormatLimit(rowsSql string) string
- func (d *MSSQLDialect) FormatSelectTop(rowsSql string) string
- func (d *MSSQLDialect) Identifier(identifier string) string
- func (d *MSSQLDialect) Median(expr Expr) Expr
- func (d *MSSQLDialect) NumericLiteral(s string) (string, error)
- func (d *MSSQLDialect) QuoteIdent(name string) string
- func (d *MSSQLDialect) ResolveFieldRef(name string) string
- func (d *MSSQLDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
- func (d *MSSQLDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
- func (d *MSSQLDialect) ResolveTime(t time.Time) (string, error)
- func (d *MSSQLDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
- func (d *MSSQLDialect) RoundTime(expr Expr, interval time.Duration) Expr
- func (d *MSSQLDialect) Stddev(expr Expr) Expr
- func (d *MSSQLDialect) StringLength(expr Expr) Expr
- func (d *MSSQLDialect) StringLiteral(s string) string
- func (d *MSSQLDialect) SubString(expr Expr, start int64, length int64) Expr
- func (d *MSSQLDialect) SubTime(expr Expr, duration time.Duration) Expr
- func (d *MSSQLDialect) SupportsAsBeforeTableAlias() bool
- func (d *MSSQLDialect) SupportsCrossDatabaseQueries() bool
- func (d *MSSQLDialect) TimestampLiteral(t time.Time) string
- func (d *MSSQLDialect) TimestampTzLiteral(t time.Time) string
- func (d *MSSQLDialect) ToFloat64(expr Expr) Expr
- func (d *MSSQLDialect) ToString(expr Expr) Expr
- func (d *MSSQLDialect) UUIDLiteral(s string) string
- func (d *MSSQLDialect) UnquoteIdent(text string) (string, bool)
- type MySQLDialect
- func (d *MySQLDialect) AddTime(expr Expr, duration time.Duration) Expr
- func (d *MySQLDialect) AggregationColumnReference(expression Expr, alias string) Expr
- func (d *MySQLDialect) CeilTime(expr Expr, interval time.Duration) Expr
- func (d *MySQLDialect) Coalesce(exprs ...Expr) Expr
- func (d *MySQLDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
- func (d *MySQLDialect) Count(expr Expr) Expr
- func (d *MySQLDialect) CountIf(expr Expr) Expr
- func (d *MySQLDialect) CurrentTimestamp() Expr
- func (d *MySQLDialect) DateLiteral(t time.Time) string
- func (d *MySQLDialect) FoldIdent(name string) string
- func (d *MySQLDialect) FormatLimit(rowsSql string) string
- func (d *MySQLDialect) Identifier(identifier string) string
- func (d *MySQLDialect) Median(expr Expr) Expr
- func (d *MySQLDialect) NumericLiteral(s string) (string, error)
- func (d *MySQLDialect) QuoteIdent(name string) string
- func (d *MySQLDialect) ResolveFieldRef(name string) string
- func (d *MySQLDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
- func (d *MySQLDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
- func (d *MySQLDialect) ResolveTime(t time.Time) (string, error)
- func (d *MySQLDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
- func (d *MySQLDialect) RoundTime(expr Expr, interval time.Duration) Expr
- func (d *MySQLDialect) Stddev(expr Expr) Expr
- func (d *MySQLDialect) StringLength(expr Expr) Expr
- func (d *MySQLDialect) StringLiteral(s string) string
- func (d *MySQLDialect) SubString(expr Expr, start int64, length int64) Expr
- func (d *MySQLDialect) SubTime(expr Expr, duration time.Duration) Expr
- func (d *MySQLDialect) SupportsAsBeforeTableAlias() bool
- func (d *MySQLDialect) SupportsCrossDatabaseQueries() bool
- func (d *MySQLDialect) TimestampLiteral(t time.Time) string
- func (d *MySQLDialect) TimestampTzLiteral(t time.Time) string
- func (d *MySQLDialect) ToFloat64(expr Expr) Expr
- func (d *MySQLDialect) ToString(expr Expr) Expr
- func (d *MySQLDialect) UUIDLiteral(s string) string
- func (d *MySQLDialect) UnquoteIdent(text string) (string, bool)
- type NotImplementedExpr
- type NotInExpr
- type NullExpr
- type NumericColExpr
- type NumericExpr
- type OrExpr
- type OracleDialect
- func (d *OracleDialect) AddTime(expr Expr, duration time.Duration) Expr
- func (d *OracleDialect) AggregationColumnReference(expression Expr, alias string) Expr
- func (d *OracleDialect) CeilTime(expr Expr, interval time.Duration) Expr
- func (d *OracleDialect) Coalesce(exprs ...Expr) Expr
- func (d *OracleDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
- func (d *OracleDialect) Count(expr Expr) Expr
- func (d *OracleDialect) CountIf(expr Expr) Expr
- func (d *OracleDialect) CurrentTimestamp() Expr
- func (d *OracleDialect) DateLiteral(t time.Time) string
- func (d *OracleDialect) FoldIdent(name string) string
- func (d *OracleDialect) FormatLimit(rowsSql string) string
- func (d *OracleDialect) Identifier(identifier string) string
- func (d *OracleDialect) Median(expr Expr) Expr
- func (d *OracleDialect) NumericLiteral(s string) (string, error)
- func (d *OracleDialect) QuoteIdent(name string) string
- func (d *OracleDialect) ResolveFieldRef(name string) string
- func (d *OracleDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
- func (d *OracleDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
- func (d *OracleDialect) ResolveTime(t time.Time) (string, error)
- func (d *OracleDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
- func (d *OracleDialect) RoundTime(expr Expr, interval time.Duration) Expr
- func (d *OracleDialect) Stddev(expr Expr) Expr
- func (d *OracleDialect) StringLength(expr Expr) Expr
- func (d *OracleDialect) StringLiteral(s string) string
- func (d *OracleDialect) SubString(expr Expr, start int64, length int64) Expr
- func (d *OracleDialect) SubTime(expr Expr, duration time.Duration) Expr
- func (d *OracleDialect) SupportsAsBeforeTableAlias() bool
- func (d *OracleDialect) SupportsCrossDatabaseQueries() bool
- func (d *OracleDialect) TimestampLiteral(t time.Time) string
- func (d *OracleDialect) TimestampTzLiteral(t time.Time) string
- func (d *OracleDialect) ToFloat64(expr Expr) Expr
- func (d *OracleDialect) ToString(expr Expr) Expr
- func (d *OracleDialect) UUIDLiteral(s string) string
- func (d *OracleDialect) UnquoteIdent(text string) (string, bool)
- type OrderByExpr
- type OrderExpr
- type PostgresDialect
- func (d *PostgresDialect) AddTime(expr Expr, duration time.Duration) Expr
- func (d *PostgresDialect) AggregationColumnReference(expression Expr, alias string) Expr
- func (d *PostgresDialect) CeilTime(expr Expr, interval time.Duration) Expr
- func (d *PostgresDialect) Coalesce(exprs ...Expr) Expr
- func (d *PostgresDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
- func (d *PostgresDialect) Count(expr Expr) Expr
- func (d *PostgresDialect) CountIf(expr Expr) Expr
- func (d *PostgresDialect) CurrentTimestamp() Expr
- func (d *PostgresDialect) DateLiteral(t time.Time) string
- func (d *PostgresDialect) FoldIdent(name string) string
- func (d *PostgresDialect) FormatLimit(rowsSql string) string
- func (d *PostgresDialect) Identifier(identifier string) string
- func (d *PostgresDialect) Median(expr Expr) Expr
- func (d *PostgresDialect) NumericLiteral(s string) (string, error)
- func (d *PostgresDialect) QuoteIdent(name string) string
- func (d *PostgresDialect) ResolveFieldRef(name string) string
- func (d *PostgresDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
- func (d *PostgresDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
- func (d *PostgresDialect) ResolveTime(t time.Time) (string, error)
- func (d *PostgresDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
- func (d *PostgresDialect) RoundTime(expr Expr, interval time.Duration) Expr
- func (d *PostgresDialect) Stddev(expr Expr) Expr
- func (d *PostgresDialect) StringLength(expr Expr) Expr
- func (d *PostgresDialect) StringLiteral(s string) string
- func (d *PostgresDialect) SubString(expr Expr, start int64, length int64) Expr
- func (d *PostgresDialect) SubTime(expr Expr, duration time.Duration) Expr
- func (d *PostgresDialect) SupportsAsBeforeTableAlias() bool
- func (d *PostgresDialect) SupportsCrossDatabaseQueries() bool
- func (d *PostgresDialect) TimestampLiteral(t time.Time) string
- func (d *PostgresDialect) TimestampTzLiteral(t time.Time) string
- func (d *PostgresDialect) ToFloat64(expr Expr) Expr
- func (d *PostgresDialect) ToString(expr Expr) Expr
- func (d *PostgresDialect) UUIDLiteral(s string) string
- func (d *PostgresDialect) UnquoteIdent(text string) (string, bool)
- type QualifiedColExpr
- type QualifiedIdentExpr
- type RedshiftDialect
- func (d *RedshiftDialect) AddTime(expr Expr, duration time.Duration) Expr
- func (d *RedshiftDialect) AggregationColumnReference(expression Expr, alias string) Expr
- func (d *RedshiftDialect) CeilTime(expr Expr, interval time.Duration) Expr
- func (d *RedshiftDialect) Coalesce(exprs ...Expr) Expr
- func (d *RedshiftDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
- func (d *RedshiftDialect) Count(expr Expr) Expr
- func (d *RedshiftDialect) CountIf(expr Expr) Expr
- func (d *RedshiftDialect) CurrentTimestamp() Expr
- func (d *RedshiftDialect) DateLiteral(t time.Time) string
- func (d *RedshiftDialect) FoldIdent(name string) string
- func (d *RedshiftDialect) FormatLimit(rowsSql string) string
- func (d *RedshiftDialect) Identifier(identifier string) string
- func (d *RedshiftDialect) Median(expr Expr) Expr
- func (d *RedshiftDialect) NumericLiteral(s string) (string, error)
- func (d *RedshiftDialect) QuoteIdent(name string) string
- func (d *RedshiftDialect) ResolveFieldRef(name string) string
- func (d *RedshiftDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
- func (d *RedshiftDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
- func (d *RedshiftDialect) ResolveTime(t time.Time) (string, error)
- func (d *RedshiftDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
- func (d *RedshiftDialect) RoundTime(expr Expr, interval time.Duration) Expr
- func (d *RedshiftDialect) Stddev(expr Expr) Expr
- func (d *RedshiftDialect) StringLength(expr Expr) Expr
- func (d *RedshiftDialect) StringLiteral(s string) string
- func (d *RedshiftDialect) SubString(expr Expr, start int64, length int64) Expr
- func (d *RedshiftDialect) SubTime(expr Expr, duration time.Duration) Expr
- func (d *RedshiftDialect) SupportsAsBeforeTableAlias() bool
- func (d *RedshiftDialect) SupportsCrossDatabaseQueries() bool
- func (d *RedshiftDialect) TimestampLiteral(t time.Time) string
- func (d *RedshiftDialect) TimestampTzLiteral(t time.Time) string
- func (d *RedshiftDialect) ToFloat64(expr Expr) Expr
- func (d *RedshiftDialect) ToString(expr Expr) Expr
- func (d *RedshiftDialect) UUIDLiteral(s string) string
- func (d *RedshiftDialect) UnquoteIdent(text string) (string, bool)
- type RowCompareExpr
- type Select
- func (s *Select) Cols(cols ...Expr) *Select
- func (s *Select) CrossJoin(other TableExpr) *Select
- func (s *Select) Cte(alias *CteAliasExpr, sql CteExpr) *Select
- func (s *Select) From(table TableExpr) *Select
- func (s *Select) GroupBy(groupBy ...Expr) *Select
- func (s *Select) Having(having ...CondExpr) *Select
- func (s *Select) IsCteExpr()
- func (s *Select) Join(other TableExpr, how JoinDefExpr) *Select
- func (s *Select) OrderBy(orderBy ...OrderByExpr) *Select
- func (s *Select) RecursiveCte(alias *CteAliasExpr, sql *Select, recursive ...string) *Select
- func (s *Select) ToSql(dialect Dialect) (string, error)
- func (s *Select) Where(conds ...CondExpr) *Select
- func (s *Select) WithLimit(limit LimitClauseExpr) *Select
- type SelectTopDialect
- type SnowflakeDialect
- func (d *SnowflakeDialect) AddTime(expr Expr, duration time.Duration) Expr
- func (d *SnowflakeDialect) AggregationColumnReference(expression Expr, alias string) Expr
- func (d *SnowflakeDialect) CeilTime(expr Expr, interval time.Duration) Expr
- func (d *SnowflakeDialect) Coalesce(exprs ...Expr) Expr
- func (d *SnowflakeDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
- func (d *SnowflakeDialect) Count(expr Expr) Expr
- func (d *SnowflakeDialect) CountIf(expr Expr) Expr
- func (d *SnowflakeDialect) CurrentTimestamp() Expr
- func (d *SnowflakeDialect) DateLiteral(t time.Time) string
- func (d *SnowflakeDialect) FoldIdent(name string) string
- func (d *SnowflakeDialect) FormatLimit(rowsSql string) string
- func (d *SnowflakeDialect) Identifier(identifier string) string
- func (d *SnowflakeDialect) Median(expr Expr) Expr
- func (d *SnowflakeDialect) NumericLiteral(s string) (string, error)
- func (d *SnowflakeDialect) QuoteIdent(name string) string
- func (d *SnowflakeDialect) ResolveFieldRef(name string) string
- func (d *SnowflakeDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
- func (d *SnowflakeDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
- func (d *SnowflakeDialect) ResolveTime(t time.Time) (string, error)
- func (d *SnowflakeDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
- func (d *SnowflakeDialect) RoundTime(expr Expr, duration time.Duration) Expr
- func (d *SnowflakeDialect) Stddev(expr Expr) Expr
- func (d *SnowflakeDialect) StringLength(expr Expr) Expr
- func (d *SnowflakeDialect) StringLiteral(s string) string
- func (d *SnowflakeDialect) SubString(expr Expr, start int64, length int64) Expr
- func (d *SnowflakeDialect) SubTime(expr Expr, duration time.Duration) Expr
- func (d *SnowflakeDialect) SupportsAsBeforeTableAlias() bool
- func (d *SnowflakeDialect) SupportsCrossDatabaseQueries() bool
- func (d *SnowflakeDialect) TimestampLiteral(t time.Time) string
- func (d *SnowflakeDialect) TimestampTzLiteral(t time.Time) string
- func (d *SnowflakeDialect) ToFloat64(expr Expr) Expr
- func (d *SnowflakeDialect) ToString(expr Expr) Expr
- func (d *SnowflakeDialect) UUIDLiteral(s string) string
- func (d *SnowflakeDialect) UnquoteIdent(text string) (string, bool)
- type SqlExpr
- type StarExpr
- type StringLitExpr
- type SubStringExpr
- type SubqueryTableExpr
- type TableExpr
- type TableFnExpr
- type TableFqnExpr
- type TestedDialect
- type TextColExpr
- type TextExpr
- type TimeColExpr
- type TimeExpr
- type TimeLitExpr
- type TimeUnit
- type ToCondExpr
- type ToFloat64Expr
- type ToStringExpr
- type TrimExpr
- type TrinoDialect
- func (d *TrinoDialect) AddTime(expr Expr, duration time.Duration) Expr
- func (d *TrinoDialect) AggregationColumnReference(expression Expr, alias string) Expr
- func (d *TrinoDialect) CeilTime(expr Expr, interval time.Duration) Expr
- func (d *TrinoDialect) Coalesce(exprs ...Expr) Expr
- func (d *TrinoDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
- func (d *TrinoDialect) Count(expr Expr) Expr
- func (d *TrinoDialect) CountIf(expr Expr) Expr
- func (d *TrinoDialect) CurrentTimestamp() Expr
- func (d *TrinoDialect) DateLiteral(t time.Time) string
- func (d *TrinoDialect) FoldIdent(name string) string
- func (d *TrinoDialect) FormatLimit(rowsSql string) string
- func (d *TrinoDialect) Identifier(identifier string) string
- func (d *TrinoDialect) Median(expr Expr) Expr
- func (d *TrinoDialect) NumericLiteral(s string) (string, error)
- func (d *TrinoDialect) QuoteIdent(name string) string
- func (d *TrinoDialect) ResolveFieldRef(name string) string
- func (d *TrinoDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
- func (d *TrinoDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
- func (d *TrinoDialect) ResolveTime(t time.Time) (string, error)
- func (d *TrinoDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
- func (d *TrinoDialect) RoundTime(expr Expr, interval time.Duration) Expr
- func (d *TrinoDialect) Stddev(expr Expr) Expr
- func (d *TrinoDialect) StringLength(expr Expr) Expr
- func (d *TrinoDialect) StringLiteral(s string) string
- func (d *TrinoDialect) SubString(expr Expr, start int64, length int64) Expr
- func (d *TrinoDialect) SubTime(expr Expr, duration time.Duration) Expr
- func (d *TrinoDialect) SupportsAsBeforeTableAlias() bool
- func (d *TrinoDialect) SupportsCrossDatabaseQueries() bool
- func (d *TrinoDialect) TimestampLiteral(t time.Time) string
- func (d *TrinoDialect) TimestampTzLiteral(t time.Time) string
- func (d *TrinoDialect) ToFloat64(expr Expr) Expr
- func (d *TrinoDialect) ToString(expr Expr) Expr
- func (d *TrinoDialect) UUIDLiteral(s string) string
- func (d *TrinoDialect) UnquoteIdent(text string) (string, bool)
- type WindowExpr
- type WrapSqlExpr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Db2QuoteIdentifier ¶ added in v0.20.0
func Db2QuoteIfNeeded ¶ added in v0.20.0
Db2QuoteIfNeeded quotes an identifier the way QuoteForFoldUpper does, and additionally quotes one that does not begin with a letter: like Oracle, Db2 rejects an unquoted identifier starting with `_` (SQLCODE -20521).
func MSSQLQuoteIdentifier ¶ added in v0.9.0
func OracleQuoteIdentifier ¶ added in v0.9.0
func OracleQuoteIfNeeded ¶ added in v0.17.2
OracleQuoteIfNeeded quotes an identifier the way QuoteForFoldUpper does, and additionally quotes one that does not begin with a letter.
Oracle requires an unquoted identifier to start with a letter — `_` and `$` and `#` are legal inside it but not at the front. Every other dialect we support takes a leading underscore, so a generated alias like `_recon_base` reads fine everywhere else and fails here with "ORA-00911: _: invalid character", pointing at the underscore rather than at the alias.
func PqQuoteIdentifierIfUpper ¶ added in v0.4.5
func QuoteForFoldLower ¶ added in v0.14.4
QuoteForFoldLower quotes an identifier with double quotes for fold-to-lower dialects (Postgres, Redshift, Trino). Leaves only pure-lower identifiers with no characters requiring quoting unquoted. Any uppercase letter or special char would otherwise fold or parse incorrectly. MUST NOT be used for fold-to-upper dialects (Snowflake, Oracle) — pure-upper input would be needlessly quoted. Use QuoteForFoldUpper there.
func QuoteForFoldUpper ¶ added in v0.14.4
QuoteForFoldUpper quotes an identifier with double quotes for fold-to-upper dialects (Snowflake, Oracle). Leaves pure-upper AND pure-lower identifiers unquoted (pure-upper matches catalog canonical case directly; pure-lower folds up to match). Quotes mixed-case and identifiers containing characters requiring quoting. Examples (Snowflake/Oracle): `INGESTED_AT` -> `INGESTED_AT` (already canonical), `ingested_at` -> `ingested_at` (folds up to `INGESTED_AT`), `ingestedAt` -> `"ingestedAt"` (mixed case must be quoted to survive). MUST NOT be used for fold-to-lower dialects (Postgres, Redshift, Trino) — pure-upper input would slip through unquoted and fold to lower, missing the catalog entry. Use QuoteForFoldLower there.
func QuoteWithBackticksIfNeeded ¶ added in v0.14.4
QuoteWithBackticksIfNeeded quotes an identifier with backticks only when needed. Returns the identifier raw when it contains only safe chars. Used by BigQuery, ClickHouse, MySQL.
func QuoteWithBracketsIfNeeded ¶ added in v0.14.4
QuoteWithBracketsIfNeeded quotes an identifier with [brackets] (MSSQL syntax) only when needed. Returns the identifier raw when it contains only safe chars. Internal `]` characters are escaped by doubling.
func QuoteWithDoubleQuotesIfNeeded ¶ added in v0.14.4
QuoteWithDoubleQuotesIfNeeded quotes an identifier with double quotes (ANSI SQL standard) only when needed. Returns the identifier raw when it contains only safe chars. Used by Trino, Postgres, Redshift, DuckDB.
func SplitQualifiedIdent ¶ added in v0.18.0
SplitQualifiedIdent splits a dotted identifier into its parts, on the dots that sit outside quotes only. `db.schema.table` is three parts; `"a.b".c` is two, the first of which is the single name `a.b`. Each part is returned in the form it was written, quotes included, for CanonicalIdent or WrittenIdent to interpret.
It takes no dialect because it runs where none is known yet — parsing a `table:` entry — so it knows every dialect's delimiters and has to decide, without knowing which one applies, where each quote ends. A doubled closing delimiter never ends a quote. A backslash escapes the character after it only inside backticks, which is where BigQuery's escaped delimiter lives; inside a double quote or a bracket a backslash is a literal character on every dialect that uses those, so Postgres `"a\\".orders` still splits into two parts. The one shape left ambiguous is a MySQL backtick name ending in a backslash, which reads as escaping its closing backtick and so comes back as one part; the benefit is that BigQuery's escaped backtick does not cut a name in half.
An unterminated quote is not an error here: the remainder comes back as one part, and whichever engine receives it reports the problem in its own terms.
func StandardSQLStringLiteral ¶ added in v0.4.34
StandardSQLStringLiteral implements the standard SQL string literal escaping where single quotes are escaped by doubling them (”). This is used by most SQL dialects: Snowflake, BigQuery, Postgres, Redshift, Databricks, DuckDB, Trino, and MySQL.
Types ¶
type AggregationColumnReferenceExpr ¶
type AggregationColumnReferenceExpr struct {
// contains filtered or unexported fields
}
func AggregationColumnReference ¶
func AggregationColumnReference(expression Expr, alias string) *AggregationColumnReferenceExpr
type AliasExpr ¶ added in v0.17.2
type AliasExpr struct {
// contains filtered or unexported fields
}
AliasExpr is the name a builder gives a result column, spelled so that reading the value back and referring to the alias one level up both resolve to the same thing.
Identifier is the wrong tool for this. It quotes unconditionally on the dialects whose Identifier is a quoting function (Oracle, ClickHouse, BigQuery), which pins the alias to the exact case it was written in, while every reference to it — a QualifiedCol, an outer WHERE, a GROUP BY — goes through ResolveFieldRef and folds. `as "key_val"` next to a reference to `key_val` is two different columns on Oracle, and the query fails or, worse, resolves to a same-named column of the inner table.
Alias therefore resolves through ResolveFieldRef, the same path every reference takes, so the two agree by construction. What the warehouse then reports the column as is still its own choice — a folding account spells `key_val` back as KEY_VAL — so reads must stay case-insensitive (exec.QueryMapResult.Get).
func (*AliasExpr) IsTextExpr ¶ added in v0.17.2
func (e *AliasExpr) IsTextExpr()
type AndGroupsExpr ¶ added in v0.4.3
type AndGroupsExpr struct {
// contains filtered or unexported fields
}
func AndGroups ¶ added in v0.4.3
func AndGroups(conds ...CondExpr) *AndGroupsExpr
func (*AndGroupsExpr) IsCondExpr ¶ added in v0.4.3
func (e *AndGroupsExpr) IsCondExpr()
type BetweenExpr ¶
type BetweenExpr struct {
// contains filtered or unexported fields
}
func Between ¶
func Between(col, from, to Expr) *BetweenExpr
func (*BetweenExpr) IsCondExpr ¶
func (e *BetweenExpr) IsCondExpr()
type BigQueryDialect ¶
type BigQueryDialect struct{}
func NewBigQueryDialect ¶
func NewBigQueryDialect() *BigQueryDialect
func (*BigQueryDialect) AddTime ¶
func (d *BigQueryDialect) AddTime(expr Expr, duration time.Duration) Expr
func (*BigQueryDialect) AggregationColumnReference ¶
func (d *BigQueryDialect) AggregationColumnReference(expression Expr, alias string) Expr
func (*BigQueryDialect) CeilTime ¶
func (d *BigQueryDialect) CeilTime(expr Expr, interval time.Duration) Expr
func (*BigQueryDialect) Coalesce ¶
func (d *BigQueryDialect) Coalesce(exprs ...Expr) Expr
func (*BigQueryDialect) ConcatWithSeparator ¶ added in v0.9.0
func (d *BigQueryDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
func (*BigQueryDialect) Count ¶
func (d *BigQueryDialect) Count(expr Expr) Expr
func (*BigQueryDialect) CountIf ¶
func (d *BigQueryDialect) CountIf(expr Expr) Expr
func (*BigQueryDialect) CurrentTimestamp ¶ added in v0.4.17
func (d *BigQueryDialect) CurrentTimestamp() Expr
func (*BigQueryDialect) DateLiteral ¶ added in v0.19.0
func (d *BigQueryDialect) DateLiteral(t time.Time) string
func (*BigQueryDialect) FoldIdent ¶ added in v0.18.0
func (d *BigQueryDialect) FoldIdent(name string) string
FoldIdent returns the name an unquoted reference resolves to. Dataset and table names are case-sensitive and column names are matched case-insensitively, so an unquoted reference resolves to the name as written and there is nothing to fold.
func (*BigQueryDialect) FormatLimit ¶ added in v0.9.0
func (d *BigQueryDialect) FormatLimit(rowsSql string) string
func (*BigQueryDialect) Identifier ¶
func (d *BigQueryDialect) Identifier(identifier string) string
func (*BigQueryDialect) Median ¶
func (d *BigQueryDialect) Median(expr Expr) Expr
func (*BigQueryDialect) NumericLiteral ¶ added in v0.19.0
func (d *BigQueryDialect) NumericLiteral(s string) (string, error)
NumericLiteral is a BIGNUMERIC: an unadorned decimal is FLOAT64 on BigQuery, and comparing a NUMERIC column with one goes through float64. BIGNUMERIC holds every NUMERIC and INT64 value, so either compares with it exactly.
func (*BigQueryDialect) QuoteIdent ¶ added in v0.18.0
func (d *BigQueryDialect) QuoteIdent(name string) string
QuoteIdent renders name wrapped in this dialect's identifier delimiters, always — unlike Identifier, which quotes only when a character demands it and so lets a reserved word through bare.
func (*BigQueryDialect) ResolveFieldRef ¶ added in v0.14.4
func (d *BigQueryDialect) ResolveFieldRef(name string) string
ResolveFieldRef returns the SQL reference for a user-supplied field name. Expressions (containing function calls, casts, JSON operators, etc.) are returned as-is; plain identifiers are backtick-quoted only when needed.
func (*BigQueryDialect) ResolveFqn ¶
func (d *BigQueryDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
func (*BigQueryDialect) ResolveTableFunction ¶ added in v0.4.15
func (d *BigQueryDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
func (*BigQueryDialect) ResolveTime ¶
func (d *BigQueryDialect) ResolveTime(t time.Time) (string, error)
func (*BigQueryDialect) ResolveTimeColumn ¶
func (d *BigQueryDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
func (*BigQueryDialect) RoundTime ¶
func (d *BigQueryDialect) RoundTime(expr Expr, duration time.Duration) Expr
func (*BigQueryDialect) Stddev ¶
func (d *BigQueryDialect) Stddev(expr Expr) Expr
func (*BigQueryDialect) StringLength ¶ added in v0.12.6
func (d *BigQueryDialect) StringLength(expr Expr) Expr
func (*BigQueryDialect) StringLiteral ¶ added in v0.4.34
func (d *BigQueryDialect) StringLiteral(s string) string
StringLiteral escapes backslashes and quotes with a backslash: BigQuery string literals take C-style escape sequences, so a `\s` in the input would otherwise be read as an escape (and rejected), and a newline would end the literal. A doubled quote is not an escape on BigQuery: it is rejected as two string literals missing the whitespace between them.
func (*BigQueryDialect) SubString ¶ added in v0.1.11
func (d *BigQueryDialect) SubString(expr Expr, start int64, length int64) Expr
func (*BigQueryDialect) SubTime ¶
func (d *BigQueryDialect) SubTime(expr Expr, duration time.Duration) Expr
func (*BigQueryDialect) SupportsAsBeforeTableAlias ¶ added in v0.17.2
func (d *BigQueryDialect) SupportsAsBeforeTableAlias() bool
func (*BigQueryDialect) SupportsCrossDatabaseQueries ¶ added in v0.10.4
func (d *BigQueryDialect) SupportsCrossDatabaseQueries() bool
func (*BigQueryDialect) TimestampLiteral ¶ added in v0.19.0
func (d *BigQueryDialect) TimestampLiteral(t time.Time) string
func (*BigQueryDialect) TimestampTzLiteral ¶ added in v0.19.0
func (d *BigQueryDialect) TimestampTzLiteral(t time.Time) string
func (*BigQueryDialect) ToFloat64 ¶
func (d *BigQueryDialect) ToFloat64(expr Expr) Expr
func (*BigQueryDialect) ToString ¶
func (d *BigQueryDialect) ToString(expr Expr) Expr
func (*BigQueryDialect) UUIDLiteral ¶ added in v0.19.0
func (d *BigQueryDialect) UUIDLiteral(s string) string
UUIDLiteral is text: BigQuery has no UUID type.
func (*BigQueryDialect) UnquoteIdent ¶ added in v0.18.0
func (d *BigQueryDialect) UnquoteIdent(text string) (string, bool)
UnquoteIdent is the inverse: it strips one layer of delimiters and decodes the escape inside, reporting whether the text carried any.
type CaseExpr ¶ added in v0.9.0
type CaseExpr struct {
// contains filtered or unexported fields
}
CaseExpr represents a SQL CASE expression
func (*CaseExpr) IsNumericExpr ¶ added in v0.9.0
func (e *CaseExpr) IsNumericExpr()
type ClickHouseDialect ¶
type ClickHouseDialect struct{}
func NewClickHouseDialect ¶
func NewClickHouseDialect() *ClickHouseDialect
func (*ClickHouseDialect) AddTime ¶
func (d *ClickHouseDialect) AddTime(expr Expr, duration time.Duration) Expr
func (*ClickHouseDialect) AggregationColumnReference ¶
func (d *ClickHouseDialect) AggregationColumnReference(expression Expr, alias string) Expr
func (*ClickHouseDialect) CeilTime ¶
func (d *ClickHouseDialect) CeilTime(expr Expr, interval time.Duration) Expr
func (*ClickHouseDialect) Coalesce ¶
func (d *ClickHouseDialect) Coalesce(exprs ...Expr) Expr
func (*ClickHouseDialect) ConcatWithSeparator ¶ added in v0.9.0
func (d *ClickHouseDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
func (*ClickHouseDialect) Count ¶
func (d *ClickHouseDialect) Count(expr Expr) Expr
func (*ClickHouseDialect) CountIf ¶
func (d *ClickHouseDialect) CountIf(expr Expr) Expr
func (*ClickHouseDialect) CurrentTimestamp ¶ added in v0.4.17
func (d *ClickHouseDialect) CurrentTimestamp() Expr
func (*ClickHouseDialect) DateLiteral ¶ added in v0.19.0
func (d *ClickHouseDialect) DateLiteral(t time.Time) string
DateLiteral is a Date32, whose range covers both Date and Date32 columns.
func (*ClickHouseDialect) FoldIdent ¶ added in v0.18.0
func (d *ClickHouseDialect) FoldIdent(name string) string
FoldIdent returns the name an unquoted reference resolves to. Identifiers are case-sensitive, quoted or not, so there is nothing to fold.
func (*ClickHouseDialect) FormatLimit ¶ added in v0.9.0
func (d *ClickHouseDialect) FormatLimit(rowsSql string) string
func (*ClickHouseDialect) Identifier ¶
func (d *ClickHouseDialect) Identifier(identifier string) string
func (*ClickHouseDialect) Median ¶
func (d *ClickHouseDialect) Median(expr Expr) Expr
func (*ClickHouseDialect) NumericLiteral ¶ added in v0.19.0
func (d *ClickHouseDialect) NumericLiteral(s string) (string, error)
NumericLiteral is a Decimal256 at the text's own scale: an unadorned decimal is Float64 on ClickHouse.
func (*ClickHouseDialect) QuoteIdent ¶ added in v0.18.0
func (d *ClickHouseDialect) QuoteIdent(name string) string
QuoteIdent renders name wrapped in this dialect's identifier delimiters, always — unlike Identifier, which quotes only when a character demands it and so lets a reserved word through bare.
func (*ClickHouseDialect) ResolveFieldRef ¶ added in v0.14.4
func (d *ClickHouseDialect) ResolveFieldRef(name string) string
ResolveFieldRef returns the SQL reference for a user-supplied field name. Expressions (containing function calls, casts, JSON operators, etc.) are returned as-is; plain identifiers are backtick-quoted only when needed.
func (*ClickHouseDialect) ResolveFqn ¶
func (d *ClickHouseDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
func (*ClickHouseDialect) ResolveTableFunction ¶ added in v0.4.15
func (d *ClickHouseDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
func (*ClickHouseDialect) ResolveTime ¶
func (d *ClickHouseDialect) ResolveTime(t time.Time) (string, error)
func (*ClickHouseDialect) ResolveTimeColumn ¶
func (d *ClickHouseDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
func (*ClickHouseDialect) RoundTime ¶
func (d *ClickHouseDialect) RoundTime(expr Expr, duration time.Duration) Expr
func (*ClickHouseDialect) Stddev ¶
func (d *ClickHouseDialect) Stddev(expr Expr) Expr
func (*ClickHouseDialect) StringLength ¶ added in v0.12.6
func (d *ClickHouseDialect) StringLength(expr Expr) Expr
func (*ClickHouseDialect) StringLiteral ¶ added in v0.4.34
func (d *ClickHouseDialect) StringLiteral(s string) string
StringLiteral doubles backslashes as well as quotes: ClickHouse reads a backslash in a string literal as an escape, so `a\nb` would become a newline.
func (*ClickHouseDialect) SubString ¶ added in v0.1.11
func (d *ClickHouseDialect) SubString(expr Expr, start int64, length int64) Expr
func (*ClickHouseDialect) SubTime ¶
func (d *ClickHouseDialect) SubTime(expr Expr, duration time.Duration) Expr
func (*ClickHouseDialect) SupportsAsBeforeTableAlias ¶ added in v0.17.2
func (d *ClickHouseDialect) SupportsAsBeforeTableAlias() bool
func (*ClickHouseDialect) SupportsCrossDatabaseQueries ¶ added in v0.10.4
func (d *ClickHouseDialect) SupportsCrossDatabaseQueries() bool
func (*ClickHouseDialect) TimestampLiteral ¶ added in v0.19.0
func (d *ClickHouseDialect) TimestampLiteral(t time.Time) string
TimestampLiteral is a DateTime64 in UTC, like TimestampTzLiteral: every ClickHouse DateTime is an instant, a column without a zone of its own is read in the server's.
func (*ClickHouseDialect) TimestampTzLiteral ¶ added in v0.19.0
func (d *ClickHouseDialect) TimestampTzLiteral(t time.Time) string
func (*ClickHouseDialect) ToFloat64 ¶
func (d *ClickHouseDialect) ToFloat64(expr Expr) Expr
func (*ClickHouseDialect) ToString ¶
func (d *ClickHouseDialect) ToString(expr Expr) Expr
func (*ClickHouseDialect) UUIDLiteral ¶ added in v0.19.0
func (d *ClickHouseDialect) UUIDLiteral(s string) string
func (*ClickHouseDialect) UnquoteIdent ¶ added in v0.18.0
func (d *ClickHouseDialect) UnquoteIdent(text string) (string, bool)
UnquoteIdent is the inverse: it strips one layer of delimiters and decodes the escape inside, reporting whether the text carried any.
type CoalesceExpr ¶
type CoalesceExpr struct {
// contains filtered or unexported fields
}
func Coalesce ¶
func Coalesce(exprs ...Expr) *CoalesceExpr
type ColBaseExpr ¶
type ColBaseExpr struct {
// contains filtered or unexported fields
}
type CompareExpr ¶
type CompareExpr struct {
// contains filtered or unexported fields
}
func Eq ¶
func Eq(a, b Expr) *CompareExpr
func Gt ¶
func Gt(a, b Expr) *CompareExpr
func Gte ¶
func Gte(a, b Expr) *CompareExpr
func IsNotNull ¶ added in v0.4.3
func IsNotNull(a Expr) *CompareExpr
func IsNull ¶ added in v0.4.3
func IsNull(a Expr) *CompareExpr
func Lt ¶
func Lt(a, b Expr) *CompareExpr
func Lte ¶
func Lte(a, b Expr) *CompareExpr
func (*CompareExpr) IsCondExpr ¶
func (e *CompareExpr) IsCondExpr()
type CondExpr ¶
type CondExpr interface {
Expr
IsCondExpr()
}
func RowCompare ¶ added in v0.15.1
RowCompare builds a lexicographic comparison of a column tuple against a value tuple: `(cols...) <fn> (vals...)`, where fn is one of <, <=, >, >= (equality should use per-column Eq). It is the dialect-aware way to express a half-open key-range scan `(a, b) >= (lo0, lo1) AND (a, b) < (hi0, hi1)` for a composite key.
The two equivalent renderings differ wildly in how engines optimise them, and the better one is engine-specific, so RowCompare lets each dialect pick:
- Native row-value constructor `(a, b) >= (x, y)` — Postgres and MySQL decompose this into a leading-column index range scan (sargable). The lexicographic OR-expansion, by contrast, confuses their planners into a bitmap union that over-scans.
- Lexicographic OR-expansion `(a > x) OR (a = x AND b >= y)` — ClickHouse prunes its primary-key granules from this form, but does NOT prune from a native tuple comparison (it scans every granule). BigQuery / Snowflake / Redshift / MSSQL don't support `<`/`>` on row constructors at all, so the expansion is also their only valid form.
Both renderings are semantically identical (same total order, NULLs aside). A dialect opts into the native form by implementing rowValueComparer; every other dialect falls back to the portable expansion, which is valid SQL everywhere.
type CountAllExpr ¶ added in v0.1.8
type CountAllExpr struct{}
func CountAll ¶ added in v0.1.8
func CountAll() *CountAllExpr
func (CountAllExpr) IsNumericExpr ¶ added in v0.1.8
func (c CountAllExpr) IsNumericExpr()
type CrossJoinExpr ¶ added in v0.14.5
type CrossJoinExpr struct {
// contains filtered or unexported fields
}
CrossJoinExpr renders a CROSS JOIN against another table expression. Unlike a regular Join it carries no join condition, producing the Cartesian product of the two inputs (commonly used to combine two single-row subqueries).
func (*CrossJoinExpr) IsJoinExpr ¶ added in v0.14.5
func (t *CrossJoinExpr) IsJoinExpr()
func (*CrossJoinExpr) IsTableExpr ¶ added in v0.14.5
func (t *CrossJoinExpr) IsTableExpr()
type Cte ¶ added in v0.4.3
type Cte struct {
Alias *CteAliasExpr
Select CteExpr
Recursive []string
}
CteExpr
type CteAliasExpr ¶ added in v0.4.16
type CteAliasExpr struct {
// contains filtered or unexported fields
}
func CteFqn ¶ added in v0.4.3
func CteFqn(alias string) *CteAliasExpr
CteFqn names a CTE. The same expression renders both the declaration (`with <name> AS (...)`) and every FROM that reads it, and it resolves through ResolveFieldRef like SubqueryTable's alias does, so a QualifiedCol naming the CTE spells it the same way. That quotes a name the dialect cannot take bare, such as a leading underscore on Oracle and Db2.
func (*CteAliasExpr) IsTableExpr ¶ added in v0.4.16
func (t *CteAliasExpr) IsTableExpr()
type DatabricksDialect ¶
type DatabricksDialect struct{}
func NewDatabricksDialect ¶
func NewDatabricksDialect() *DatabricksDialect
func (*DatabricksDialect) AddTime ¶
func (d *DatabricksDialect) AddTime(expr Expr, duration time.Duration) Expr
func (*DatabricksDialect) AggregationColumnReference ¶
func (d *DatabricksDialect) AggregationColumnReference(expression Expr, alias string) Expr
func (*DatabricksDialect) CeilTime ¶
func (d *DatabricksDialect) CeilTime(expr Expr, interval time.Duration) Expr
func (*DatabricksDialect) Coalesce ¶
func (d *DatabricksDialect) Coalesce(exprs ...Expr) Expr
func (*DatabricksDialect) ConcatWithSeparator ¶ added in v0.9.0
func (d *DatabricksDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
func (*DatabricksDialect) Count ¶
func (d *DatabricksDialect) Count(expr Expr) Expr
func (*DatabricksDialect) CountIf ¶
func (d *DatabricksDialect) CountIf(expr Expr) Expr
func (*DatabricksDialect) CurrentTimestamp ¶ added in v0.4.17
func (d *DatabricksDialect) CurrentTimestamp() Expr
func (*DatabricksDialect) DateLiteral ¶ added in v0.19.0
func (d *DatabricksDialect) DateLiteral(t time.Time) string
func (*DatabricksDialect) FoldIdent ¶ added in v0.18.0
func (d *DatabricksDialect) FoldIdent(name string) string
FoldIdent returns the name an unquoted reference resolves to. "Identifiers are case-insensitive when referenced", quoted or not, so there is nothing to fold.
func (*DatabricksDialect) FormatLimit ¶ added in v0.9.0
func (d *DatabricksDialect) FormatLimit(rowsSql string) string
func (*DatabricksDialect) Identifier ¶
func (d *DatabricksDialect) Identifier(identifier string) string
func (*DatabricksDialect) Median ¶
func (d *DatabricksDialect) Median(expr Expr) Expr
func (*DatabricksDialect) NumericLiteral ¶ added in v0.19.0
func (d *DatabricksDialect) NumericLiteral(s string) (string, error)
NumericLiteral uses the BD suffix, which makes the literal a DECIMAL at any length; without it a literal past 38 digits would become a DOUBLE.
func (*DatabricksDialect) QuoteIdent ¶ added in v0.18.0
func (d *DatabricksDialect) QuoteIdent(name string) string
QuoteIdent renders name wrapped in this dialect's identifier delimiters, always — unlike Identifier, which quotes only when a character demands it and so lets a reserved word through bare.
func (*DatabricksDialect) ResolveFieldRef ¶ added in v0.14.4
func (d *DatabricksDialect) ResolveFieldRef(name string) string
ResolveFieldRef returns the SQL reference for a user-supplied field name. Expressions (containing function calls, casts, JSON operators, etc.) are returned as-is; plain identifiers are backtick-quoted only when needed.
func (*DatabricksDialect) ResolveFqn ¶
func (d *DatabricksDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
func (*DatabricksDialect) ResolveTableFunction ¶ added in v0.4.15
func (d *DatabricksDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
func (*DatabricksDialect) ResolveTime ¶
func (d *DatabricksDialect) ResolveTime(t time.Time) (string, error)
func (*DatabricksDialect) ResolveTimeColumn ¶
func (d *DatabricksDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
func (*DatabricksDialect) RoundTime ¶
func (d *DatabricksDialect) RoundTime(expr Expr, duration time.Duration) Expr
func (*DatabricksDialect) Stddev ¶
func (d *DatabricksDialect) Stddev(expr Expr) Expr
func (*DatabricksDialect) StringLength ¶ added in v0.12.6
func (d *DatabricksDialect) StringLength(expr Expr) Expr
func (*DatabricksDialect) StringLiteral ¶ added in v0.4.34
func (d *DatabricksDialect) StringLiteral(s string) string
StringLiteral escapes backslashes and quotes with a backslash: Spark SQL reads a backslash in a string literal as an escape, and reads a doubled quote as the end of one literal and the start of the next, which it concatenates, so the quote is lost.
func (*DatabricksDialect) SubString ¶ added in v0.1.11
func (d *DatabricksDialect) SubString(expr Expr, start int64, length int64) Expr
func (*DatabricksDialect) SubTime ¶
func (d *DatabricksDialect) SubTime(expr Expr, duration time.Duration) Expr
func (*DatabricksDialect) SupportsAsBeforeTableAlias ¶ added in v0.17.2
func (d *DatabricksDialect) SupportsAsBeforeTableAlias() bool
func (*DatabricksDialect) SupportsCrossDatabaseQueries ¶ added in v0.10.4
func (d *DatabricksDialect) SupportsCrossDatabaseQueries() bool
func (*DatabricksDialect) TimestampLiteral ¶ added in v0.19.0
func (d *DatabricksDialect) TimestampLiteral(t time.Time) string
func (*DatabricksDialect) TimestampTzLiteral ¶ added in v0.19.0
func (d *DatabricksDialect) TimestampTzLiteral(t time.Time) string
func (*DatabricksDialect) ToFloat64 ¶
func (d *DatabricksDialect) ToFloat64(expr Expr) Expr
func (*DatabricksDialect) ToString ¶
func (d *DatabricksDialect) ToString(expr Expr) Expr
func (*DatabricksDialect) UUIDLiteral ¶ added in v0.19.0
func (d *DatabricksDialect) UUIDLiteral(s string) string
UUIDLiteral is text: Databricks has no UUID type.
func (*DatabricksDialect) UnquoteIdent ¶ added in v0.18.0
func (d *DatabricksDialect) UnquoteIdent(text string) (string, bool)
UnquoteIdent is the inverse: it strips one layer of delimiters and decodes the escape inside, reporting whether the text carried any.
type Db2Dialect ¶ added in v0.20.0
type Db2Dialect struct{}
Db2Dialect is IBM Db2 for Linux, UNIX and Windows (LUW).
func NewDb2Dialect ¶ added in v0.20.0
func NewDb2Dialect() *Db2Dialect
func (*Db2Dialect) AddTime ¶ added in v0.20.0
func (d *Db2Dialect) AddTime(expr Expr, duration time.Duration) Expr
func (*Db2Dialect) AggregationColumnReference ¶ added in v0.20.0
func (d *Db2Dialect) AggregationColumnReference(expression Expr, alias string) Expr
func (*Db2Dialect) CeilTime ¶ added in v0.20.0
func (d *Db2Dialect) CeilTime(expr Expr, interval time.Duration) Expr
func (*Db2Dialect) Coalesce ¶ added in v0.20.0
func (d *Db2Dialect) Coalesce(exprs ...Expr) Expr
func (*Db2Dialect) ConcatWithSeparator ¶ added in v0.20.0
func (d *Db2Dialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
func (*Db2Dialect) Count ¶ added in v0.20.0
func (d *Db2Dialect) Count(expr Expr) Expr
func (*Db2Dialect) CountIf ¶ added in v0.20.0
func (d *Db2Dialect) CountIf(expr Expr) Expr
func (*Db2Dialect) CurrentTimestamp ¶ added in v0.20.0
func (d *Db2Dialect) CurrentTimestamp() Expr
func (*Db2Dialect) DateLiteral ¶ added in v0.20.0
func (d *Db2Dialect) DateLiteral(t time.Time) string
func (*Db2Dialect) FoldIdent ¶ added in v0.20.0
func (d *Db2Dialect) FoldIdent(name string) string
FoldIdent returns the name an unquoted reference resolves to. An unquoted reference folds to upper case.
func (*Db2Dialect) FormatLimit ¶ added in v0.20.0
func (d *Db2Dialect) FormatLimit(rowsSql string) string
func (*Db2Dialect) Identifier ¶ added in v0.20.0
func (d *Db2Dialect) Identifier(identifier string) string
func (*Db2Dialect) Median ¶ added in v0.20.0
func (d *Db2Dialect) Median(expr Expr) Expr
func (*Db2Dialect) NumericLiteral ¶ added in v0.20.0
func (d *Db2Dialect) NumericLiteral(s string) (string, error)
func (*Db2Dialect) QuoteIdent ¶ added in v0.20.0
func (d *Db2Dialect) QuoteIdent(name string) string
QuoteIdent renders name wrapped in this dialect's identifier delimiters, always — unlike Identifier, which quotes only when a character demands it and so lets a reserved word through bare.
func (*Db2Dialect) ResolveFieldRef ¶ added in v0.20.0
func (d *Db2Dialect) ResolveFieldRef(name string) string
func (*Db2Dialect) ResolveFqn ¶ added in v0.20.0
func (d *Db2Dialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
ResolveFqn renders schema.table: a connection is bound to one database, so the database part of the name is never written.
func (*Db2Dialect) ResolveTableFunction ¶ added in v0.20.0
func (d *Db2Dialect) ResolveTableFunction(t *TableFnExpr) (string, error)
func (*Db2Dialect) ResolveTime ¶ added in v0.20.0
func (d *Db2Dialect) ResolveTime(t time.Time) (string, error)
func (*Db2Dialect) ResolveTimeColumn ¶ added in v0.20.0
func (d *Db2Dialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
func (*Db2Dialect) RoundTime ¶ added in v0.20.0
func (d *Db2Dialect) RoundTime(expr Expr, interval time.Duration) Expr
RoundTime truncates with TRUNC(ts, format), which takes the same format elements as Oracle's.
func (*Db2Dialect) Stddev ¶ added in v0.20.0
func (d *Db2Dialect) Stddev(expr Expr) Expr
func (*Db2Dialect) StringLength ¶ added in v0.20.0
func (d *Db2Dialect) StringLength(expr Expr) Expr
StringLength counts characters: LENGTH counts bytes of the database's encoding (11 for 'zamówienia').
func (*Db2Dialect) StringLiteral ¶ added in v0.20.0
func (d *Db2Dialect) StringLiteral(s string) string
func (*Db2Dialect) SubString ¶ added in v0.20.0
func (d *Db2Dialect) SubString(expr Expr, start int64, length int64) Expr
SubString uses SUBSTRING with CODEUNITS32: SUBSTR fails with SQLCODE -138 when start+length runs past the string, where every other engine returns what is there, and both SUBSTR and LENGTH count bytes by default.
func (*Db2Dialect) SubTime ¶ added in v0.20.0
func (d *Db2Dialect) SubTime(expr Expr, duration time.Duration) Expr
SubTime and AddTime use labeled durations (`ts - 3 HOUR`): Db2 has no INTERVAL type.
func (*Db2Dialect) SupportsAsBeforeTableAlias ¶ added in v0.20.0
func (d *Db2Dialect) SupportsAsBeforeTableAlias() bool
func (*Db2Dialect) SupportsCrossDatabaseQueries ¶ added in v0.20.0
func (d *Db2Dialect) SupportsCrossDatabaseQueries() bool
func (*Db2Dialect) TimestampLiteral ¶ added in v0.20.0
func (d *Db2Dialect) TimestampLiteral(t time.Time) string
func (*Db2Dialect) TimestampTzLiteral ¶ added in v0.20.0
func (d *Db2Dialect) TimestampTzLiteral(t time.Time) string
TimestampTzLiteral is a zone-less TIMESTAMP in UTC: Db2 LUW has no TIMESTAMP WITH TIME ZONE.
func (*Db2Dialect) ToFloat64 ¶ added in v0.20.0
func (d *Db2Dialect) ToFloat64(expr Expr) Expr
func (*Db2Dialect) ToString ¶ added in v0.20.0
func (d *Db2Dialect) ToString(expr Expr) Expr
func (*Db2Dialect) UUIDLiteral ¶ added in v0.20.0
func (d *Db2Dialect) UUIDLiteral(s string) string
UUIDLiteral is text: Db2 has no UUID type.
func (*Db2Dialect) UnquoteIdent ¶ added in v0.20.0
func (d *Db2Dialect) UnquoteIdent(text string) (string, bool)
UnquoteIdent is the inverse: it strips one layer of delimiters and decodes the escape inside, reporting whether the text carried any.
type Dialect ¶
type Dialect interface {
ResolveFqn(fqn *TableFqnExpr) (string, error)
Count(expr Expr) Expr
CountIf(Expr) Expr
Median(Expr) Expr
Stddev(Expr) Expr
RoundTime(Expr, time.Duration) Expr
CeilTime(Expr, time.Duration) Expr
SubTime(Expr, time.Duration) Expr
AddTime(Expr, time.Duration) Expr
CurrentTimestamp() Expr
Identifier(string) string
ResolveFieldRef(string) string
// QuoteIdent wraps a name in this dialect's identifier delimiters,
// always. Identifier quotes only when a character demands it, which is a
// character-class test and therefore blind to reserved words: a column
// called `group` comes back bare and the statement fails to parse. Reach
// for it through Ident rather than directly — that type also settles
// whether the name still has to be folded.
QuoteIdent(name string) string
// UnquoteIdent strips one layer of identifier delimiters from text and
// decodes the escape inside, reporting whether the text carried any. It is
// the inverse of QuoteIdent, and dialect-specific for the same reason:
// BigQuery escapes its backtick as `\“, everyone else doubles the
// delimiter.
UnquoteIdent(text string) (string, bool)
// FoldIdent returns the name an unquoted reference resolves to on this
// engine — upper case on Snowflake and Oracle, lower on Postgres and the
// Presto family, unchanged where the comparison ignores case. Quoting an
// identifier pins its case, so a written name is folded first to keep it
// addressing the object it addressed unquoted.
FoldIdent(name string) string
// StringLiteral quotes s as a string literal, escaping it the way this
// engine reads one back: doubled quotes everywhere, and a doubled
// backslash on the engines that treat a backslash as an escape.
StringLiteral(string) string
// TimestampLiteral, TimestampTzLiteral, DateLiteral, NumericLiteral and
// UUIDLiteral write a value read from a column of that type back as a
// literal of the same type, so that `column = literal` holds (see
// literal.go). Times are written in UTC at the engine's full precision:
// TimestampLiteral takes a zone-less timestamp's wall clock, as decoded
// in UTC, and TimestampTzLiteral an instant. NumericLiteral takes plain
// decimal text and keeps every digit.
//
// ResolveTime is not one of these: it truncates to the second, and every
// monitor's SQL depends on what it renders.
TimestampLiteral(time.Time) string
TimestampTzLiteral(time.Time) string
DateLiteral(time.Time) string
NumericLiteral(decimal string) (string, error)
UUIDLiteral(string) string
ToString(Expr) Expr
Coalesce(exprs ...Expr) Expr
ConcatWithSeparator(separator string, exprs ...Expr) Expr
ToFloat64(Expr) Expr
SubString(expr Expr, start int64, length int64) Expr
StringLength(expr Expr) Expr
ResolveTime(time.Time) (string, error)
ResolveTimeColumn(col *TimeColExpr) (string, error)
AggregationColumnReference(expression Expr, alias string) Expr
ResolveTableFunction(t *TableFnExpr) (string, error)
FormatLimit(rowsSql string) string
// SupportsCrossDatabaseQueries returns true if the dialect supports referencing
// the database/catalog as part of the SQL FQN (e.g. database.schema.table).
SupportsCrossDatabaseQueries() bool
// SupportsAsBeforeTableAlias reports whether the optional AS keyword may sit
// between a derived table and its alias — `(select ...) AS t` rather than
// `(select ...) t`.
//
// The keyword is optional in the SQL standard and most dialects document it
// as accepted, but Oracle rejects it outright (ORA-03048: SQL reserved word
// 'AS' is not syntactically valid), which used to fail every query that
// wrapped a caller's SQL as a subquery. Dropping it everywhere would be the
// smaller change but leaves the generated SQL harder to read on the
// dialects that do take it, so the keyword is a per-dialect answer.
SupportsAsBeforeTableAlias() bool
}
type DistinctExpr ¶
type DistinctExpr struct {
// contains filtered or unexported fields
}
func Distinct ¶
func Distinct(exprs ...Expr) *DistinctExpr
type DuckDBDialect ¶
type DuckDBDialect struct{}
func NewDuckDBDialect ¶
func NewDuckDBDialect() *DuckDBDialect
func (*DuckDBDialect) AddTime ¶
func (d *DuckDBDialect) AddTime(expr Expr, duration time.Duration) Expr
func (*DuckDBDialect) AggregationColumnReference ¶
func (d *DuckDBDialect) AggregationColumnReference(expression Expr, alias string) Expr
func (*DuckDBDialect) CeilTime ¶
func (d *DuckDBDialect) CeilTime(expr Expr, interval time.Duration) Expr
func (*DuckDBDialect) Coalesce ¶
func (d *DuckDBDialect) Coalesce(exprs ...Expr) Expr
func (*DuckDBDialect) ConcatWithSeparator ¶ added in v0.9.0
func (d *DuckDBDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
func (*DuckDBDialect) Count ¶
func (d *DuckDBDialect) Count(expr Expr) Expr
func (*DuckDBDialect) CountIf ¶
func (d *DuckDBDialect) CountIf(expr Expr) Expr
func (*DuckDBDialect) CurrentTimestamp ¶ added in v0.4.17
func (d *DuckDBDialect) CurrentTimestamp() Expr
func (*DuckDBDialect) DateLiteral ¶ added in v0.19.0
func (d *DuckDBDialect) DateLiteral(t time.Time) string
func (*DuckDBDialect) FoldIdent ¶ added in v0.18.0
func (d *DuckDBDialect) FoldIdent(name string) string
FoldIdent returns the name an unquoted reference resolves to. Identifiers compare case-insensitively whether or not they are quoted, and the written case is preserved, so an unquoted reference resolves to the name as written and there is nothing to fold.
func (*DuckDBDialect) FormatLimit ¶ added in v0.9.0
func (d *DuckDBDialect) FormatLimit(rowsSql string) string
func (*DuckDBDialect) Identifier ¶
func (d *DuckDBDialect) Identifier(identifier string) string
func (*DuckDBDialect) Median ¶
func (d *DuckDBDialect) Median(expr Expr) Expr
func (*DuckDBDialect) NumericLiteral ¶ added in v0.19.0
func (d *DuckDBDialect) NumericLiteral(s string) (string, error)
func (*DuckDBDialect) QuoteIdent ¶ added in v0.18.0
func (d *DuckDBDialect) QuoteIdent(name string) string
QuoteIdent renders name wrapped in this dialect's identifier delimiters, always — unlike Identifier, which quotes only when a character demands it and so lets a reserved word through bare.
func (*DuckDBDialect) ResolveFieldRef ¶ added in v0.14.4
func (d *DuckDBDialect) ResolveFieldRef(name string) string
ResolveFieldRef returns the SQL reference for a user-supplied field name. Expressions (containing function calls, casts, JSON operators, etc.) are returned as-is; plain identifiers are double-quoted only when needed.
func (*DuckDBDialect) ResolveFqn ¶
func (d *DuckDBDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
func (*DuckDBDialect) ResolveTableFunction ¶ added in v0.4.15
func (d *DuckDBDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
func (*DuckDBDialect) ResolveTime ¶
func (d *DuckDBDialect) ResolveTime(t time.Time) (string, error)
func (*DuckDBDialect) ResolveTimeColumn ¶
func (d *DuckDBDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
func (*DuckDBDialect) RoundTime ¶
func (d *DuckDBDialect) RoundTime(expr Expr, interval time.Duration) Expr
func (*DuckDBDialect) Stddev ¶
func (d *DuckDBDialect) Stddev(expr Expr) Expr
func (*DuckDBDialect) StringLength ¶ added in v0.12.6
func (d *DuckDBDialect) StringLength(expr Expr) Expr
func (*DuckDBDialect) StringLiteral ¶ added in v0.4.34
func (d *DuckDBDialect) StringLiteral(s string) string
func (*DuckDBDialect) SubString ¶ added in v0.1.11
func (d *DuckDBDialect) SubString(expr Expr, start int64, length int64) Expr
func (*DuckDBDialect) SubTime ¶
func (d *DuckDBDialect) SubTime(expr Expr, duration time.Duration) Expr
func (*DuckDBDialect) SupportsAsBeforeTableAlias ¶ added in v0.17.2
func (d *DuckDBDialect) SupportsAsBeforeTableAlias() bool
func (*DuckDBDialect) SupportsCrossDatabaseQueries ¶ added in v0.10.4
func (d *DuckDBDialect) SupportsCrossDatabaseQueries() bool
func (*DuckDBDialect) TimestampLiteral ¶ added in v0.19.0
func (d *DuckDBDialect) TimestampLiteral(t time.Time) string
func (*DuckDBDialect) TimestampTzLiteral ¶ added in v0.19.0
func (d *DuckDBDialect) TimestampTzLiteral(t time.Time) string
func (*DuckDBDialect) ToFloat64 ¶
func (d *DuckDBDialect) ToFloat64(expr Expr) Expr
func (*DuckDBDialect) ToString ¶
func (d *DuckDBDialect) ToString(expr Expr) Expr
func (*DuckDBDialect) UUIDLiteral ¶ added in v0.19.0
func (d *DuckDBDialect) UUIDLiteral(s string) string
func (*DuckDBDialect) UnquoteIdent ¶ added in v0.18.0
func (d *DuckDBDialect) UnquoteIdent(text string) (string, bool)
UnquoteIdent is the inverse: it strips one layer of delimiters and decodes the escape inside, reporting whether the text carried any.
type Expr ¶
func OracleMd5OfLongText ¶ added in v0.21.0
OracleMd5OfLongText returns the MD5 digest of text as a RAW(16), the value STANDARD_HASH(text, 'MD5') returns, for a text that may not fit a VARCHAR2.
STANDARD_HASH takes no LOB, and joining VARCHAR2 values fails with ORA-01489 once the result passes 4000 bytes, which a wide row or a few long values reach. When text is a ConcatWs, a row whose values add up to more than that is joined as a CLOB and hashed with DBMS_CRYPTO.HASH, which hashes a CLOB as its AL32UTF8 bytes, the bytes STANDARD_HASH hashes in an AL32UTF8 database. A shorter row still goes through STANDARD_HASH. Either way the digest is the MD5 of the text's UTF-8 bytes, the one every other engine computes for the same values, so a row hashes the same whichever branch it took. Any other text is hashed by STANDARD_HASH alone.
The statement names DBMS_CRYPTO whatever the row, and Oracle grants EXECUTE on it to no one by default, so the querying user needs
GRANT EXECUTE ON SYS.DBMS_CRYPTO TO <user>
or the statement fails to parse with ORA-00904 "DBMS_CRYPTO"."HASH": invalid identifier. A caller that may lack the grant keeps STANDARD_HASH for texts it knows stay under 4000 bytes.
func ToExprSlice ¶ added in v0.2.6
type FabricDialect ¶ added in v0.16.0
type FabricDialect struct {
*MSSQLDialect
}
FabricDialect targets Microsoft Fabric Warehouse (the T-SQL surface exposed by the workspace SQL analytics endpoint). Fabric Warehouse runs a Synapse-derived engine ("Azure SQL Data Warehouse 12.0.2000.8") whose T-SQL is a subset of SQL Server, so it reuses the MSSQL dialect for almost everything and only overrides where Fabric genuinely diverges.
Known divergence handled here:
- No NVARCHAR / NCHAR. Fabric Warehouse rejects the national-character types entirely (validated against the live engine — see the dwhtesting Fabric seed). So string casts must target VARCHAR(MAX), not NVARCHAR(MAX).
Everything else the MSSQL dialect emits (LEN, DATEADD/DATEDIFF truncation, CONCAT_WS, GETUTCDATE(), CAST AS FLOAT, TOP row-capping, PERCENTILE_CONT being window-only so Median→NULL, bracket quoting) is valid Fabric T-SQL.
func NewFabricDialect ¶ added in v0.16.0
func NewFabricDialect() *FabricDialect
func (*FabricDialect) ResolveFqn ¶ added in v0.16.0
func (d *FabricDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
ResolveFqn emits a three-part [database].[schema].[table] name when a database (projectId) is present, so monitors/metrics can target tables in any workspace database from a single connection. Falls back to [schema].[table] otherwise.
func (*FabricDialect) SupportsCrossDatabaseQueries ¶ added in v0.16.0
func (d *FabricDialect) SupportsCrossDatabaseQueries() bool
SupportsCrossDatabaseQueries is true for Fabric: the workspace SQL endpoint exposes every warehouse/lakehouse in the workspace as a database and supports three-part-name queries across them (verified live). This is what makes the integration workspace-centric rather than bound to a single database.
func (*FabricDialect) TimestampLiteral ¶ added in v0.19.0
func (d *FabricDialect) TimestampLiteral(t time.Time) string
TimestampLiteral is DATETIME2(6): Fabric Warehouse caps the precision at 6.
func (*FabricDialect) TimestampTzLiteral ¶ added in v0.19.0
func (d *FabricDialect) TimestampTzLiteral(t time.Time) string
TimestampTzLiteral is a DATETIME2 too: Fabric Warehouse has no DATETIMEOFFSET.
func (*FabricDialect) ToString ¶ added in v0.16.0
func (d *FabricDialect) ToString(expr Expr) Expr
ToString casts to VARCHAR(MAX). Fabric Warehouse has no NVARCHAR, so the MSSQL dialect's CAST(... AS NVARCHAR(MAX)) would be rejected at parse time.
type FnCondExpr ¶ added in v0.4.14
type FnCondExpr struct {
// contains filtered or unexported fields
}
func FnCond ¶ added in v0.4.14
func FnCond(name string, ops ...Expr) *FnCondExpr
func (*FnCondExpr) IsCondExpr ¶ added in v0.4.14
func (e *FnCondExpr) IsCondExpr()
type FnExpr ¶
type FnExpr struct {
// contains filtered or unexported fields
}
func Ntile ¶ added in v0.17.2
Ntile builds an NTILE(buckets) call, which splits the ordered partition into that many groups. It is only valid inside an Over, and every dialect we support requires that Over to carry an ORDER BY.
type Ident ¶ added in v0.18.0
type Ident struct {
// contains filtered or unexported fields
}
Ident is one SQL identifier — a database, schema, table, column or alias name — carried as a name rather than as SQL text, and always rendered wrapped in the dialect's quote characters.
The type exists because a bare string does not say which of the two it is, and guessing is wrong in both directions:
- read as a name that needs no quoting, a reserved word (`order`, `group`) reaches the engine bare and the statement fails to parse;
- read as a name, text whose author already quoted it (`"events"`) is quoted a second time, and `"""events"""` addresses a different object;
- and splitting `"public.table"` on its dot turns one identifier into two.
Every "quote only when needed" helper in this package decides by character class, which cannot see a reserved word, so an Ident quotes unconditionally.
Nothing is decoded at construction, because both the delimiters and the escape inside them belong to the dialect: BigQuery writes a backtick inside a quoted identifier as a backslash followed by the backtick, after the manner of a string literal, and everyone else doubles the delimiter.
func CanonicalIdent ¶ added in v0.18.0
CanonicalIdent builds an Ident from a name already in the engine's own spelling — a QueryShape column, a catalog row, anything the warehouse itself handed back. It is rendered exactly as given, case and all.
Nothing is unwrapped, because at this end of the pipe a delimiter is part of the name: a Postgres column really called `"foo"`, quotes included, comes back from QueryShape spelled that way, and reading the quotes as syntax would address the column `foo` instead. Text a person wrote is the other case — see WrittenIdent.
func WrittenIdent ¶ added in v0.18.0
WrittenIdent builds an Ident from text a person wrote — a `table:` entry in a config file, a column named in a request.
Quotes the author wrote are honoured: the name inside them is the name, case included. An unquoted name is folded the way the engine resolves an unquoted reference, so that quoting it here addresses the same object it addressed before — `users` against Snowflake stays `"USERS"`, not a lower-case `users` the catalog does not hold. Dialect.FoldIdent says what that does and, just as importantly, does not touch.
func (Ident) IsEmpty ¶ added in v0.18.0
IsEmpty reports whether the identifier holds no text, which is how an absent FQN part — a database on a dialect that has none — is spelled.
func (Ident) IsTextExpr ¶ added in v0.18.0
func (i Ident) IsTextExpr()
type IdentifierExpr ¶
type IdentifierExpr struct {
// contains filtered or unexported fields
}
IdentifierExpr
func Identifier ¶
func Identifier(identifier string) *IdentifierExpr
func (*IdentifierExpr) IsTextExpr ¶
func (s *IdentifierExpr) IsTextExpr()
type InExpr ¶
type InExpr struct {
// contains filtered or unexported fields
}
func (*InExpr) IsCondExpr ¶
func (e *InExpr) IsCondExpr()
type IntLitExpr ¶
type IntLitExpr struct {
// contains filtered or unexported fields
}
func Int64 ¶
func Int64(val int64) *IntLitExpr
func (*IntLitExpr) IsNumericExpr ¶
func (e *IntLitExpr) IsNumericExpr()
type JoinDefExpr ¶
type JoinDefExpr interface {
Expr
IsJoinDefExpr()
}
type JoinExpr ¶
type JoinExpr struct {
// contains filtered or unexported fields
}
func Join ¶
func Join(other TableExpr, how JoinDefExpr) *JoinExpr
func (*JoinExpr) IsJoinExpr ¶
func (t *JoinExpr) IsJoinExpr()
func (*JoinExpr) IsTableExpr ¶ added in v0.1.11
func (t *JoinExpr) IsTableExpr()
type JoinOnExpr ¶
type JoinOnExpr struct {
// contains filtered or unexported fields
}
func On ¶
func On(conds ...CondExpr) *JoinOnExpr
func (*JoinOnExpr) IsJoinDefExpr ¶
func (t *JoinOnExpr) IsJoinDefExpr()
type JoinTableExpr ¶ added in v0.14.5
type JoinTableExpr interface {
TableExpr
IsJoinExpr()
}
JoinTableExpr is a table expression that contributes a join clause to a Select — either a conditional JOIN (*JoinExpr) or a CROSS JOIN (*CrossJoinExpr).
func CrossJoin ¶ added in v0.14.5
func CrossJoin(other TableExpr) JoinTableExpr
CrossJoin builds a CROSS JOIN expression against the given table.
type JoinUsingExpr ¶
type JoinUsingExpr struct {
// contains filtered or unexported fields
}
func Using ¶
func Using(exprs ...Expr) *JoinUsingExpr
func (*JoinUsingExpr) IsJoinDefExpr ¶
func (t *JoinUsingExpr) IsJoinDefExpr()
type LimitClauseExpr ¶ added in v0.14.5
type LimitClauseExpr interface {
Expr
IsLimitExpr()
// contains filtered or unexported methods
}
LimitClauseExpr is a LIMIT clause expression.
func Limit ¶
func Limit(rows *IntLitExpr) LimitClauseExpr
type LimitExpr ¶
type LimitExpr struct {
// contains filtered or unexported fields
}
func (*LimitExpr) IsLimitExpr ¶ added in v0.14.5
func (e *LimitExpr) IsLimitExpr()
type MSSQLDialect ¶ added in v0.9.0
type MSSQLDialect struct{}
func NewMSSQLDialect ¶ added in v0.9.0
func NewMSSQLDialect() *MSSQLDialect
func (*MSSQLDialect) AddTime ¶ added in v0.9.0
func (d *MSSQLDialect) AddTime(expr Expr, duration time.Duration) Expr
func (*MSSQLDialect) AggregationColumnReference ¶ added in v0.9.0
func (d *MSSQLDialect) AggregationColumnReference(expression Expr, alias string) Expr
func (*MSSQLDialect) CeilTime ¶ added in v0.9.0
func (d *MSSQLDialect) CeilTime(expr Expr, interval time.Duration) Expr
func (*MSSQLDialect) Coalesce ¶ added in v0.9.0
func (d *MSSQLDialect) Coalesce(exprs ...Expr) Expr
func (*MSSQLDialect) ConcatWithSeparator ¶ added in v0.9.0
func (d *MSSQLDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
func (*MSSQLDialect) Count ¶ added in v0.9.0
func (d *MSSQLDialect) Count(expr Expr) Expr
func (*MSSQLDialect) CountIf ¶ added in v0.9.0
func (d *MSSQLDialect) CountIf(expr Expr) Expr
func (*MSSQLDialect) CurrentTimestamp ¶ added in v0.9.0
func (d *MSSQLDialect) CurrentTimestamp() Expr
func (*MSSQLDialect) DateLiteral ¶ added in v0.19.0
func (d *MSSQLDialect) DateLiteral(t time.Time) string
func (*MSSQLDialect) FoldIdent ¶ added in v0.18.0
func (d *MSSQLDialect) FoldIdent(name string) string
FoldIdent returns the name an unquoted reference resolves to. Case sensitivity is a property of the collation, not of the quoting, so an unquoted reference resolves to the name as written.
func (*MSSQLDialect) FormatLimit ¶ added in v0.9.0
func (d *MSSQLDialect) FormatLimit(rowsSql string) string
FormatLimit returns "" because MSSQL caps rows in the SELECT clause via FormatSelectTop (TOP), not a trailing clause. T-SQL's OFFSET/FETCH paging is only valid when the query has an ORDER BY, whereas TOP works with or without one — so TOP is the safe form for an arbitrary capped query (e.g. a preview).
func (*MSSQLDialect) FormatSelectTop ¶ added in v0.16.0
func (d *MSSQLDialect) FormatSelectTop(rowsSql string) string
FormatSelectTop renders the T-SQL `TOP (n)` row cap placed after SELECT.
func (*MSSQLDialect) Identifier ¶ added in v0.9.0
func (d *MSSQLDialect) Identifier(identifier string) string
func (*MSSQLDialect) Median ¶ added in v0.9.0
func (d *MSSQLDialect) Median(expr Expr) Expr
func (*MSSQLDialect) NumericLiteral ¶ added in v0.19.0
func (d *MSSQLDialect) NumericLiteral(s string) (string, error)
func (*MSSQLDialect) QuoteIdent ¶ added in v0.18.0
func (d *MSSQLDialect) QuoteIdent(name string) string
QuoteIdent renders name wrapped in this dialect's identifier delimiters, always — unlike Identifier, which quotes only when a character demands it and so lets a reserved word through bare.
func (*MSSQLDialect) ResolveFieldRef ¶ added in v0.14.4
func (d *MSSQLDialect) ResolveFieldRef(name string) string
ResolveFieldRef returns the SQL reference for a user-supplied field name. Passes through likely SQL expressions unchanged; otherwise quotes with brackets only when needed.
func (*MSSQLDialect) ResolveFqn ¶ added in v0.9.0
func (d *MSSQLDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
func (*MSSQLDialect) ResolveTableFunction ¶ added in v0.9.0
func (d *MSSQLDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
func (*MSSQLDialect) ResolveTime ¶ added in v0.9.0
func (d *MSSQLDialect) ResolveTime(t time.Time) (string, error)
func (*MSSQLDialect) ResolveTimeColumn ¶ added in v0.9.0
func (d *MSSQLDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
func (*MSSQLDialect) RoundTime ¶ added in v0.9.0
func (d *MSSQLDialect) RoundTime(expr Expr, interval time.Duration) Expr
func (*MSSQLDialect) Stddev ¶ added in v0.9.0
func (d *MSSQLDialect) Stddev(expr Expr) Expr
func (*MSSQLDialect) StringLength ¶ added in v0.12.6
func (d *MSSQLDialect) StringLength(expr Expr) Expr
func (*MSSQLDialect) StringLiteral ¶ added in v0.9.0
func (d *MSSQLDialect) StringLiteral(s string) string
func (*MSSQLDialect) SubString ¶ added in v0.9.0
func (d *MSSQLDialect) SubString(expr Expr, start int64, length int64) Expr
func (*MSSQLDialect) SubTime ¶ added in v0.9.0
func (d *MSSQLDialect) SubTime(expr Expr, duration time.Duration) Expr
func (*MSSQLDialect) SupportsAsBeforeTableAlias ¶ added in v0.17.2
func (d *MSSQLDialect) SupportsAsBeforeTableAlias() bool
func (*MSSQLDialect) SupportsCrossDatabaseQueries ¶ added in v0.10.4
func (d *MSSQLDialect) SupportsCrossDatabaseQueries() bool
func (*MSSQLDialect) TimestampLiteral ¶ added in v0.19.0
func (d *MSSQLDialect) TimestampLiteral(t time.Time) string
func (*MSSQLDialect) TimestampTzLiteral ¶ added in v0.19.0
func (d *MSSQLDialect) TimestampTzLiteral(t time.Time) string
func (*MSSQLDialect) ToFloat64 ¶ added in v0.9.0
func (d *MSSQLDialect) ToFloat64(expr Expr) Expr
func (*MSSQLDialect) ToString ¶ added in v0.9.0
func (d *MSSQLDialect) ToString(expr Expr) Expr
func (*MSSQLDialect) UUIDLiteral ¶ added in v0.19.0
func (d *MSSQLDialect) UUIDLiteral(s string) string
func (*MSSQLDialect) UnquoteIdent ¶ added in v0.18.0
func (d *MSSQLDialect) UnquoteIdent(text string) (string, bool)
UnquoteIdent is the inverse: it strips one layer of delimiters and decodes the escape inside, reporting whether the text carried any.
type MySQLDialect ¶
type MySQLDialect struct{}
func NewMySQLDialect ¶
func NewMySQLDialect() *MySQLDialect
func (*MySQLDialect) AddTime ¶
func (d *MySQLDialect) AddTime(expr Expr, duration time.Duration) Expr
func (*MySQLDialect) AggregationColumnReference ¶
func (d *MySQLDialect) AggregationColumnReference(expression Expr, alias string) Expr
func (*MySQLDialect) CeilTime ¶
func (d *MySQLDialect) CeilTime(expr Expr, interval time.Duration) Expr
func (*MySQLDialect) Coalesce ¶
func (d *MySQLDialect) Coalesce(exprs ...Expr) Expr
func (*MySQLDialect) ConcatWithSeparator ¶ added in v0.9.0
func (d *MySQLDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
func (*MySQLDialect) Count ¶
func (d *MySQLDialect) Count(expr Expr) Expr
func (*MySQLDialect) CountIf ¶
func (d *MySQLDialect) CountIf(expr Expr) Expr
func (*MySQLDialect) CurrentTimestamp ¶ added in v0.4.17
func (d *MySQLDialect) CurrentTimestamp() Expr
func (*MySQLDialect) DateLiteral ¶ added in v0.19.0
func (d *MySQLDialect) DateLiteral(t time.Time) string
func (*MySQLDialect) FoldIdent ¶ added in v0.18.0
func (d *MySQLDialect) FoldIdent(name string) string
FoldIdent returns the name an unquoted reference resolves to. Whether a table name is case-sensitive is a property of the filesystem and lower_case_table_names, not of the quoting, and column names are matched case-insensitively — so an unquoted reference resolves to the name as written.
func (*MySQLDialect) FormatLimit ¶ added in v0.9.0
func (d *MySQLDialect) FormatLimit(rowsSql string) string
func (*MySQLDialect) Identifier ¶
func (d *MySQLDialect) Identifier(identifier string) string
func (*MySQLDialect) Median ¶
func (d *MySQLDialect) Median(expr Expr) Expr
func (*MySQLDialect) NumericLiteral ¶ added in v0.19.0
func (d *MySQLDialect) NumericLiteral(s string) (string, error)
func (*MySQLDialect) QuoteIdent ¶ added in v0.18.0
func (d *MySQLDialect) QuoteIdent(name string) string
QuoteIdent renders name wrapped in this dialect's identifier delimiters, always — unlike Identifier, which quotes only when a character demands it and so lets a reserved word through bare.
func (*MySQLDialect) ResolveFieldRef ¶ added in v0.14.4
func (d *MySQLDialect) ResolveFieldRef(name string) string
ResolveFieldRef returns the SQL reference for a user-supplied field name. Expressions (containing function calls, casts, JSON operators, etc.) are returned as-is; plain identifiers are backtick-quoted only when needed.
func (*MySQLDialect) ResolveFqn ¶
func (d *MySQLDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
func (*MySQLDialect) ResolveTableFunction ¶ added in v0.4.15
func (d *MySQLDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
func (*MySQLDialect) ResolveTime ¶
func (d *MySQLDialect) ResolveTime(t time.Time) (string, error)
func (*MySQLDialect) ResolveTimeColumn ¶
func (d *MySQLDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
func (*MySQLDialect) RoundTime ¶
func (d *MySQLDialect) RoundTime(expr Expr, interval time.Duration) Expr
func (*MySQLDialect) Stddev ¶
func (d *MySQLDialect) Stddev(expr Expr) Expr
func (*MySQLDialect) StringLength ¶ added in v0.12.6
func (d *MySQLDialect) StringLength(expr Expr) Expr
func (*MySQLDialect) StringLiteral ¶ added in v0.4.34
func (d *MySQLDialect) StringLiteral(s string) string
StringLiteral doubles backslashes as well as quotes: MySQL and MariaDB read a backslash in a string literal as an escape unless the server runs with NO_BACKSLASH_ESCAPES, which is not the default.
func (*MySQLDialect) SubString ¶ added in v0.1.11
func (d *MySQLDialect) SubString(expr Expr, start int64, length int64) Expr
func (*MySQLDialect) SubTime ¶
func (d *MySQLDialect) SubTime(expr Expr, duration time.Duration) Expr
func (*MySQLDialect) SupportsAsBeforeTableAlias ¶ added in v0.17.2
func (d *MySQLDialect) SupportsAsBeforeTableAlias() bool
func (*MySQLDialect) SupportsCrossDatabaseQueries ¶ added in v0.10.4
func (d *MySQLDialect) SupportsCrossDatabaseQueries() bool
func (*MySQLDialect) TimestampLiteral ¶ added in v0.19.0
func (d *MySQLDialect) TimestampLiteral(t time.Time) string
func (*MySQLDialect) TimestampTzLiteral ¶ added in v0.19.0
func (d *MySQLDialect) TimestampTzLiteral(t time.Time) string
TimestampTzLiteral is a DATETIME too: MySQL has no zoned type. A TIMESTAMP column is read in the session's time zone, and a DATETIME literal is compared in it, so the round trip holds.
func (*MySQLDialect) ToFloat64 ¶
func (d *MySQLDialect) ToFloat64(expr Expr) Expr
func (*MySQLDialect) ToString ¶
func (d *MySQLDialect) ToString(expr Expr) Expr
func (*MySQLDialect) UUIDLiteral ¶ added in v0.19.0
func (d *MySQLDialect) UUIDLiteral(s string) string
UUIDLiteral is text: MySQL has no UUID type.
func (*MySQLDialect) UnquoteIdent ¶ added in v0.18.0
func (d *MySQLDialect) UnquoteIdent(text string) (string, bool)
UnquoteIdent is the inverse: it strips one layer of delimiters and decodes the escape inside, reporting whether the text carried any.
type NotImplementedExpr ¶
type NotImplementedExpr struct {
// contains filtered or unexported fields
}
func NotImplemented ¶
func NotImplemented() *NotImplementedExpr
func NotImplementedWithExplanation ¶
func NotImplementedWithExplanation(msg string) *NotImplementedExpr
type NotInExpr ¶
type NotInExpr struct {
// contains filtered or unexported fields
}
func (*NotInExpr) IsCondExpr ¶
func (e *NotInExpr) IsCondExpr()
type NumericColExpr ¶
type NumericColExpr struct {
ColBaseExpr
}
func NumericCol ¶
func NumericCol(name string) *NumericColExpr
func (*NumericColExpr) IsNumericExpr ¶
func (s *NumericColExpr) IsNumericExpr()
type NumericExpr ¶
type NumericExpr interface {
Expr
IsNumericExpr()
}
type OrExpr ¶ added in v0.4.3
type OrExpr struct {
// contains filtered or unexported fields
}
func (*OrExpr) IsCondExpr ¶ added in v0.4.3
func (e *OrExpr) IsCondExpr()
type OracleDialect ¶ added in v0.9.0
type OracleDialect struct{}
func NewOracleDialect ¶ added in v0.9.0
func NewOracleDialect() *OracleDialect
func (*OracleDialect) AddTime ¶ added in v0.9.0
func (d *OracleDialect) AddTime(expr Expr, duration time.Duration) Expr
func (*OracleDialect) AggregationColumnReference ¶ added in v0.9.0
func (d *OracleDialect) AggregationColumnReference(expression Expr, alias string) Expr
func (*OracleDialect) CeilTime ¶ added in v0.9.0
func (d *OracleDialect) CeilTime(expr Expr, interval time.Duration) Expr
func (*OracleDialect) Coalesce ¶ added in v0.9.0
func (d *OracleDialect) Coalesce(exprs ...Expr) Expr
func (*OracleDialect) ConcatWithSeparator ¶ added in v0.9.0
func (d *OracleDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
func (*OracleDialect) Count ¶ added in v0.9.0
func (d *OracleDialect) Count(expr Expr) Expr
func (*OracleDialect) CountIf ¶ added in v0.9.0
func (d *OracleDialect) CountIf(expr Expr) Expr
func (*OracleDialect) CurrentTimestamp ¶ added in v0.9.0
func (d *OracleDialect) CurrentTimestamp() Expr
func (*OracleDialect) DateLiteral ¶ added in v0.19.0
func (d *OracleDialect) DateLiteral(t time.Time) string
func (*OracleDialect) FoldIdent ¶ added in v0.18.0
func (d *OracleDialect) FoldIdent(name string) string
FoldIdent returns the name an unquoted reference resolves to. An unquoted reference folds to upper case.
func (*OracleDialect) FormatLimit ¶ added in v0.9.0
func (d *OracleDialect) FormatLimit(rowsSql string) string
func (*OracleDialect) Identifier ¶ added in v0.9.0
func (d *OracleDialect) Identifier(identifier string) string
func (*OracleDialect) Median ¶ added in v0.9.0
func (d *OracleDialect) Median(expr Expr) Expr
func (*OracleDialect) NumericLiteral ¶ added in v0.19.0
func (d *OracleDialect) NumericLiteral(s string) (string, error)
func (*OracleDialect) QuoteIdent ¶ added in v0.18.0
func (d *OracleDialect) QuoteIdent(name string) string
QuoteIdent renders name wrapped in this dialect's identifier delimiters, always — unlike Identifier, which quotes only when a character demands it and so lets a reserved word through bare.
func (*OracleDialect) ResolveFieldRef ¶ added in v0.14.4
func (d *OracleDialect) ResolveFieldRef(name string) string
func (*OracleDialect) ResolveFqn ¶ added in v0.9.0
func (d *OracleDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
func (*OracleDialect) ResolveTableFunction ¶ added in v0.9.0
func (d *OracleDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
func (*OracleDialect) ResolveTime ¶ added in v0.9.0
func (d *OracleDialect) ResolveTime(t time.Time) (string, error)
func (*OracleDialect) ResolveTimeColumn ¶ added in v0.9.0
func (d *OracleDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
func (*OracleDialect) RoundTime ¶ added in v0.9.0
func (d *OracleDialect) RoundTime(expr Expr, interval time.Duration) Expr
func (*OracleDialect) Stddev ¶ added in v0.9.0
func (d *OracleDialect) Stddev(expr Expr) Expr
func (*OracleDialect) StringLength ¶ added in v0.12.6
func (d *OracleDialect) StringLength(expr Expr) Expr
func (*OracleDialect) StringLiteral ¶ added in v0.9.0
func (d *OracleDialect) StringLiteral(s string) string
func (*OracleDialect) SubString ¶ added in v0.9.0
func (d *OracleDialect) SubString(expr Expr, start int64, length int64) Expr
func (*OracleDialect) SubTime ¶ added in v0.9.0
func (d *OracleDialect) SubTime(expr Expr, duration time.Duration) Expr
func (*OracleDialect) SupportsAsBeforeTableAlias ¶ added in v0.17.2
func (d *OracleDialect) SupportsAsBeforeTableAlias() bool
SupportsAsBeforeTableAlias is false: Oracle rejects the keyword with ORA-03048 ("SQL reserved word 'AS' is not syntactically valid"). It takes AS only before a column alias.
func (*OracleDialect) SupportsCrossDatabaseQueries ¶ added in v0.10.4
func (d *OracleDialect) SupportsCrossDatabaseQueries() bool
func (*OracleDialect) TimestampLiteral ¶ added in v0.19.0
func (d *OracleDialect) TimestampLiteral(t time.Time) string
func (*OracleDialect) TimestampTzLiteral ¶ added in v0.19.0
func (d *OracleDialect) TimestampTzLiteral(t time.Time) string
func (*OracleDialect) ToFloat64 ¶ added in v0.9.0
func (d *OracleDialect) ToFloat64(expr Expr) Expr
func (*OracleDialect) ToString ¶ added in v0.9.0
func (d *OracleDialect) ToString(expr Expr) Expr
func (*OracleDialect) UUIDLiteral ¶ added in v0.19.0
func (d *OracleDialect) UUIDLiteral(s string) string
UUIDLiteral is text: Oracle has no UUID type.
func (*OracleDialect) UnquoteIdent ¶ added in v0.18.0
func (d *OracleDialect) UnquoteIdent(text string) (string, bool)
UnquoteIdent is the inverse: it strips one layer of delimiters and decodes the escape inside, reporting whether the text carried any.
type OrderByExpr ¶ added in v0.14.5
type OrderByExpr interface {
Expr
IsOrderByExpr()
}
OrderByExpr is an ORDER BY term (an expression with an optional direction).
func Asc ¶
func Asc(expr Expr) OrderByExpr
func Desc ¶
func Desc(expr Expr) OrderByExpr
type OrderExpr ¶
type OrderExpr struct {
// contains filtered or unexported fields
}
func (*OrderExpr) IsOrderByExpr ¶ added in v0.14.5
func (e *OrderExpr) IsOrderByExpr()
type PostgresDialect ¶
type PostgresDialect struct{}
func NewPostgresDialect ¶
func NewPostgresDialect() *PostgresDialect
func (*PostgresDialect) AddTime ¶
func (d *PostgresDialect) AddTime(expr Expr, duration time.Duration) Expr
func (*PostgresDialect) AggregationColumnReference ¶
func (d *PostgresDialect) AggregationColumnReference(expression Expr, alias string) Expr
func (*PostgresDialect) CeilTime ¶
func (d *PostgresDialect) CeilTime(expr Expr, interval time.Duration) Expr
func (*PostgresDialect) Coalesce ¶
func (d *PostgresDialect) Coalesce(exprs ...Expr) Expr
func (*PostgresDialect) ConcatWithSeparator ¶ added in v0.9.0
func (d *PostgresDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
func (*PostgresDialect) Count ¶
func (d *PostgresDialect) Count(expr Expr) Expr
func (*PostgresDialect) CountIf ¶
func (d *PostgresDialect) CountIf(expr Expr) Expr
func (*PostgresDialect) CurrentTimestamp ¶ added in v0.4.17
func (d *PostgresDialect) CurrentTimestamp() Expr
func (*PostgresDialect) DateLiteral ¶ added in v0.19.0
func (d *PostgresDialect) DateLiteral(t time.Time) string
func (*PostgresDialect) FoldIdent ¶ added in v0.18.0
func (d *PostgresDialect) FoldIdent(name string) string
FoldIdent returns the name an unquoted reference resolves to. An unquoted reference folds to lower case: "Key words and unquoted identifiers are case-insensitive" and are "folded to lower case".
func (*PostgresDialect) FormatLimit ¶ added in v0.9.0
func (d *PostgresDialect) FormatLimit(rowsSql string) string
func (*PostgresDialect) Identifier ¶
func (d *PostgresDialect) Identifier(identifier string) string
func (*PostgresDialect) Median ¶
func (d *PostgresDialect) Median(expr Expr) Expr
func (*PostgresDialect) NumericLiteral ¶ added in v0.19.0
func (d *PostgresDialect) NumericLiteral(s string) (string, error)
func (*PostgresDialect) QuoteIdent ¶ added in v0.18.0
func (d *PostgresDialect) QuoteIdent(name string) string
QuoteIdent renders name wrapped in this dialect's identifier delimiters, always — unlike Identifier, which quotes only when a character demands it and so lets a reserved word through bare.
func (*PostgresDialect) ResolveFieldRef ¶ added in v0.14.4
func (d *PostgresDialect) ResolveFieldRef(name string) string
func (*PostgresDialect) ResolveFqn ¶
func (d *PostgresDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
func (*PostgresDialect) ResolveTableFunction ¶ added in v0.4.15
func (d *PostgresDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
func (*PostgresDialect) ResolveTime ¶
func (d *PostgresDialect) ResolveTime(t time.Time) (string, error)
func (*PostgresDialect) ResolveTimeColumn ¶
func (d *PostgresDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
func (*PostgresDialect) RoundTime ¶
func (d *PostgresDialect) RoundTime(expr Expr, interval time.Duration) Expr
func (*PostgresDialect) Stddev ¶
func (d *PostgresDialect) Stddev(expr Expr) Expr
func (*PostgresDialect) StringLength ¶ added in v0.12.6
func (d *PostgresDialect) StringLength(expr Expr) Expr
func (*PostgresDialect) StringLiteral ¶ added in v0.4.34
func (d *PostgresDialect) StringLiteral(s string) string
func (*PostgresDialect) SubString ¶ added in v0.1.11
func (d *PostgresDialect) SubString(expr Expr, start int64, length int64) Expr
func (*PostgresDialect) SubTime ¶
func (d *PostgresDialect) SubTime(expr Expr, duration time.Duration) Expr
func (*PostgresDialect) SupportsAsBeforeTableAlias ¶ added in v0.17.2
func (d *PostgresDialect) SupportsAsBeforeTableAlias() bool
func (*PostgresDialect) SupportsCrossDatabaseQueries ¶ added in v0.10.4
func (d *PostgresDialect) SupportsCrossDatabaseQueries() bool
func (*PostgresDialect) TimestampLiteral ¶ added in v0.19.0
func (d *PostgresDialect) TimestampLiteral(t time.Time) string
func (*PostgresDialect) TimestampTzLiteral ¶ added in v0.19.0
func (d *PostgresDialect) TimestampTzLiteral(t time.Time) string
func (*PostgresDialect) ToFloat64 ¶
func (d *PostgresDialect) ToFloat64(expr Expr) Expr
func (*PostgresDialect) ToString ¶
func (d *PostgresDialect) ToString(expr Expr) Expr
func (*PostgresDialect) UUIDLiteral ¶ added in v0.19.0
func (d *PostgresDialect) UUIDLiteral(s string) string
func (*PostgresDialect) UnquoteIdent ¶ added in v0.18.0
func (d *PostgresDialect) UnquoteIdent(text string) (string, bool)
UnquoteIdent is the inverse: it strips one layer of delimiters and decodes the escape inside, reporting whether the text carried any.
type QualifiedColExpr ¶ added in v0.17.2
type QualifiedColExpr struct {
// contains filtered or unexported fields
}
QualifiedColExpr renders `qualifier.name`, both halves resolved by the dialect.
Formatting `alias.col` into a string does not survive case folding: Oracle and Snowflake fold an unquoted identifier to upper case, Postgres, Redshift and Trino fold it to lower, and a quoted one keeps the case it was written in. The qualifier therefore has to be spelled the same way the alias it refers to was emitted — which is what SubqueryTableExpr and this expression both do by running the identifier through ResolveFieldRef.
Passing the whole `alias.col` string to TextCol instead would not work: ResolveFieldRef treats a `.` as the marker of an expression and passes the string through raw, so neither half gets quoted.
func QualifiedCol ¶ added in v0.17.2
func QualifiedCol(qualifier string, name string) *QualifiedColExpr
QualifiedCol builds a column reference qualified by a table alias.
func (*QualifiedColExpr) IsNumericExpr ¶ added in v0.17.2
func (e *QualifiedColExpr) IsNumericExpr()
func (*QualifiedColExpr) IsTextExpr ¶ added in v0.17.2
func (e *QualifiedColExpr) IsTextExpr()
type QualifiedIdentExpr ¶ added in v0.18.0
type QualifiedIdentExpr struct {
// contains filtered or unexported fields
}
QualifiedIdentExpr is a dot-joined run of identifiers, each quoted on its own. The parts are never joined first and quoted after: `"public.table"` is one object and `"public"."table"` is another.
func QualifiedIdent ¶ added in v0.18.0
func QualifiedIdent(parts ...Ident) *QualifiedIdentExpr
QualifiedIdent joins the parts with dots, skipping empty ones so a caller can pass an absent database or schema straight through.
func (*QualifiedIdentExpr) IsTableExpr ¶ added in v0.18.0
func (q *QualifiedIdentExpr) IsTableExpr()
type RedshiftDialect ¶
type RedshiftDialect struct{}
func NewRedshiftDialect ¶
func NewRedshiftDialect() *RedshiftDialect
func (*RedshiftDialect) AddTime ¶
func (d *RedshiftDialect) AddTime(expr Expr, duration time.Duration) Expr
func (*RedshiftDialect) AggregationColumnReference ¶
func (d *RedshiftDialect) AggregationColumnReference(expression Expr, alias string) Expr
func (*RedshiftDialect) CeilTime ¶
func (d *RedshiftDialect) CeilTime(expr Expr, interval time.Duration) Expr
func (*RedshiftDialect) Coalesce ¶
func (d *RedshiftDialect) Coalesce(exprs ...Expr) Expr
func (*RedshiftDialect) ConcatWithSeparator ¶ added in v0.9.0
func (d *RedshiftDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
ConcatWithSeparator joins with `||`: Redshift has no CONCAT_WS, only a two-argument CONCAT. Unlike CONCAT_WS, `||` makes the whole result NULL when any value is NULL, so COALESCE values that may be NULL first.
func (*RedshiftDialect) Count ¶
func (d *RedshiftDialect) Count(expr Expr) Expr
func (*RedshiftDialect) CountIf ¶
func (d *RedshiftDialect) CountIf(expr Expr) Expr
func (*RedshiftDialect) CurrentTimestamp ¶ added in v0.4.17
func (d *RedshiftDialect) CurrentTimestamp() Expr
func (*RedshiftDialect) DateLiteral ¶ added in v0.19.0
func (d *RedshiftDialect) DateLiteral(t time.Time) string
func (*RedshiftDialect) FoldIdent ¶ added in v0.18.0
func (d *RedshiftDialect) FoldIdent(name string) string
FoldIdent returns the name an unquoted reference resolves to. An unquoted reference folds to lower case. So does a quoted one, unless the cluster sets enable_case_sensitive_identifier: "ASCII letters in standard and delimited identifiers are case-insensitive and are folded to lowercase in the database." Quoting therefore buys reserved words and punctuation here, not case.
func (*RedshiftDialect) FormatLimit ¶ added in v0.9.0
func (d *RedshiftDialect) FormatLimit(rowsSql string) string
func (*RedshiftDialect) Identifier ¶
func (d *RedshiftDialect) Identifier(identifier string) string
func (*RedshiftDialect) Median ¶
func (d *RedshiftDialect) Median(expr Expr) Expr
func (*RedshiftDialect) NumericLiteral ¶ added in v0.19.0
func (d *RedshiftDialect) NumericLiteral(s string) (string, error)
func (*RedshiftDialect) QuoteIdent ¶ added in v0.18.0
func (d *RedshiftDialect) QuoteIdent(name string) string
QuoteIdent renders name wrapped in this dialect's identifier delimiters, always — unlike Identifier, which quotes only when a character demands it and so lets a reserved word through bare.
func (*RedshiftDialect) ResolveFieldRef ¶ added in v0.14.4
func (d *RedshiftDialect) ResolveFieldRef(name string) string
func (*RedshiftDialect) ResolveFqn ¶
func (d *RedshiftDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
func (*RedshiftDialect) ResolveTableFunction ¶ added in v0.4.15
func (d *RedshiftDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
func (*RedshiftDialect) ResolveTime ¶
func (d *RedshiftDialect) ResolveTime(t time.Time) (string, error)
func (*RedshiftDialect) ResolveTimeColumn ¶
func (d *RedshiftDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
func (*RedshiftDialect) RoundTime ¶
func (d *RedshiftDialect) RoundTime(expr Expr, interval time.Duration) Expr
func (*RedshiftDialect) Stddev ¶
func (d *RedshiftDialect) Stddev(expr Expr) Expr
func (*RedshiftDialect) StringLength ¶ added in v0.12.6
func (d *RedshiftDialect) StringLength(expr Expr) Expr
func (*RedshiftDialect) StringLiteral ¶ added in v0.4.34
func (d *RedshiftDialect) StringLiteral(s string) string
StringLiteral doubles backslashes as well as quotes: unlike Postgres, Redshift reads a backslash in a string literal as an escape.
func (*RedshiftDialect) SubString ¶ added in v0.1.11
func (d *RedshiftDialect) SubString(expr Expr, start int64, length int64) Expr
func (*RedshiftDialect) SubTime ¶
func (d *RedshiftDialect) SubTime(expr Expr, duration time.Duration) Expr
func (*RedshiftDialect) SupportsAsBeforeTableAlias ¶ added in v0.17.2
func (d *RedshiftDialect) SupportsAsBeforeTableAlias() bool
func (*RedshiftDialect) SupportsCrossDatabaseQueries ¶ added in v0.10.4
func (d *RedshiftDialect) SupportsCrossDatabaseQueries() bool
func (*RedshiftDialect) TimestampLiteral ¶ added in v0.19.0
func (d *RedshiftDialect) TimestampLiteral(t time.Time) string
func (*RedshiftDialect) TimestampTzLiteral ¶ added in v0.19.0
func (d *RedshiftDialect) TimestampTzLiteral(t time.Time) string
func (*RedshiftDialect) ToFloat64 ¶
func (d *RedshiftDialect) ToFloat64(expr Expr) Expr
func (*RedshiftDialect) ToString ¶
func (d *RedshiftDialect) ToString(expr Expr) Expr
func (*RedshiftDialect) UUIDLiteral ¶ added in v0.19.0
func (d *RedshiftDialect) UUIDLiteral(s string) string
UUIDLiteral is text: Redshift has no UUID type.
func (*RedshiftDialect) UnquoteIdent ¶ added in v0.18.0
func (d *RedshiftDialect) UnquoteIdent(text string) (string, bool)
UnquoteIdent is the inverse: it strips one layer of delimiters and decodes the escape inside, reporting whether the text carried any.
type RowCompareExpr ¶ added in v0.15.1
type RowCompareExpr struct {
// contains filtered or unexported fields
}
func (*RowCompareExpr) IsCondExpr ¶ added in v0.15.1
func (e *RowCompareExpr) IsCondExpr()
type Select ¶
type Select struct {
// contains filtered or unexported fields
}
func (*Select) OrderBy ¶
func (s *Select) OrderBy(orderBy ...OrderByExpr) *Select
func (*Select) RecursiveCte ¶ added in v0.4.3
func (s *Select) RecursiveCte(alias *CteAliasExpr, sql *Select, recursive ...string) *Select
func (*Select) WithLimit ¶
func (s *Select) WithLimit(limit LimitClauseExpr) *Select
type SelectTopDialect ¶ added in v0.16.0
SelectTopDialect is implemented by dialects that cap the number of returned rows with a SELECT-clause prefix — T-SQL's `TOP (n)` — instead of a trailing LIMIT/FETCH clause. When a dialect implements this and a limit is set, the Select builder places the cap right after SELECT (and such dialects' FormatLimit returns "" so no trailing clause is emitted). This matters because T-SQL only allows OFFSET/FETCH paging when an ORDER BY is present, whereas TOP works with or without one.
type SnowflakeDialect ¶
type SnowflakeDialect struct{}
func NewSnowflakeDialect ¶
func NewSnowflakeDialect() *SnowflakeDialect
func (*SnowflakeDialect) AddTime ¶
func (d *SnowflakeDialect) AddTime(expr Expr, duration time.Duration) Expr
func (*SnowflakeDialect) AggregationColumnReference ¶
func (d *SnowflakeDialect) AggregationColumnReference(expression Expr, alias string) Expr
func (*SnowflakeDialect) CeilTime ¶
func (d *SnowflakeDialect) CeilTime(expr Expr, interval time.Duration) Expr
func (*SnowflakeDialect) Coalesce ¶
func (d *SnowflakeDialect) Coalesce(exprs ...Expr) Expr
func (*SnowflakeDialect) ConcatWithSeparator ¶ added in v0.9.0
func (d *SnowflakeDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
func (*SnowflakeDialect) Count ¶
func (d *SnowflakeDialect) Count(expr Expr) Expr
func (*SnowflakeDialect) CountIf ¶
func (d *SnowflakeDialect) CountIf(expr Expr) Expr
func (*SnowflakeDialect) CurrentTimestamp ¶ added in v0.4.17
func (d *SnowflakeDialect) CurrentTimestamp() Expr
func (*SnowflakeDialect) DateLiteral ¶ added in v0.19.0
func (d *SnowflakeDialect) DateLiteral(t time.Time) string
func (*SnowflakeDialect) FoldIdent ¶ added in v0.18.0
func (d *SnowflakeDialect) FoldIdent(name string) string
FoldIdent returns the name an unquoted reference resolves to. An unquoted reference folds to upper case: unquoted identifiers "are stored and resolved as uppercase characters".
func (*SnowflakeDialect) FormatLimit ¶ added in v0.9.0
func (d *SnowflakeDialect) FormatLimit(rowsSql string) string
func (*SnowflakeDialect) Identifier ¶
func (d *SnowflakeDialect) Identifier(identifier string) string
func (*SnowflakeDialect) Median ¶
func (d *SnowflakeDialect) Median(expr Expr) Expr
func (*SnowflakeDialect) NumericLiteral ¶ added in v0.19.0
func (d *SnowflakeDialect) NumericLiteral(s string) (string, error)
func (*SnowflakeDialect) QuoteIdent ¶ added in v0.18.0
func (d *SnowflakeDialect) QuoteIdent(name string) string
QuoteIdent renders name wrapped in this dialect's identifier delimiters, always — unlike Identifier, which quotes only when a character demands it and so lets a reserved word through bare.
func (*SnowflakeDialect) ResolveFieldRef ¶ added in v0.14.4
func (d *SnowflakeDialect) ResolveFieldRef(name string) string
func (*SnowflakeDialect) ResolveFqn ¶
func (d *SnowflakeDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
func (*SnowflakeDialect) ResolveTableFunction ¶ added in v0.4.15
func (d *SnowflakeDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
func (*SnowflakeDialect) ResolveTime ¶
func (d *SnowflakeDialect) ResolveTime(t time.Time) (string, error)
func (*SnowflakeDialect) ResolveTimeColumn ¶
func (d *SnowflakeDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
func (*SnowflakeDialect) RoundTime ¶
func (d *SnowflakeDialect) RoundTime(expr Expr, duration time.Duration) Expr
func (*SnowflakeDialect) Stddev ¶
func (d *SnowflakeDialect) Stddev(expr Expr) Expr
func (*SnowflakeDialect) StringLength ¶ added in v0.12.6
func (d *SnowflakeDialect) StringLength(expr Expr) Expr
func (*SnowflakeDialect) StringLiteral ¶ added in v0.4.34
func (d *SnowflakeDialect) StringLiteral(s string) string
StringLiteral doubles backslashes as well as quotes: Snowflake reads a backslash in a single-quoted literal as an escape.
func (*SnowflakeDialect) SubString ¶ added in v0.1.11
func (d *SnowflakeDialect) SubString(expr Expr, start int64, length int64) Expr
func (*SnowflakeDialect) SubTime ¶
func (d *SnowflakeDialect) SubTime(expr Expr, duration time.Duration) Expr
func (*SnowflakeDialect) SupportsAsBeforeTableAlias ¶ added in v0.17.2
func (d *SnowflakeDialect) SupportsAsBeforeTableAlias() bool
func (*SnowflakeDialect) SupportsCrossDatabaseQueries ¶ added in v0.10.4
func (d *SnowflakeDialect) SupportsCrossDatabaseQueries() bool
func (*SnowflakeDialect) TimestampLiteral ¶ added in v0.19.0
func (d *SnowflakeDialect) TimestampLiteral(t time.Time) string
func (*SnowflakeDialect) TimestampTzLiteral ¶ added in v0.19.0
func (d *SnowflakeDialect) TimestampTzLiteral(t time.Time) string
func (*SnowflakeDialect) ToFloat64 ¶
func (d *SnowflakeDialect) ToFloat64(expr Expr) Expr
func (*SnowflakeDialect) ToString ¶
func (d *SnowflakeDialect) ToString(expr Expr) Expr
func (*SnowflakeDialect) UUIDLiteral ¶ added in v0.19.0
func (d *SnowflakeDialect) UUIDLiteral(s string) string
UUIDLiteral is text: Snowflake has no UUID type.
func (*SnowflakeDialect) UnquoteIdent ¶ added in v0.18.0
func (d *SnowflakeDialect) UnquoteIdent(text string) (string, bool)
UnquoteIdent is the inverse: it strips one layer of delimiters and decodes the escape inside, reporting whether the text carried any.
type SqlExpr ¶
type SqlExpr struct {
// contains filtered or unexported fields
}
func (*SqlExpr) IsCondExpr ¶
func (s *SqlExpr) IsCondExpr()
func (*SqlExpr) IsJoinExpr ¶
func (s *SqlExpr) IsJoinExpr()
func (*SqlExpr) IsNumericExpr ¶
func (s *SqlExpr) IsNumericExpr()
func (*SqlExpr) IsTableExpr ¶
func (s *SqlExpr) IsTableExpr()
func (*SqlExpr) IsTextExpr ¶
func (s *SqlExpr) IsTextExpr()
func (*SqlExpr) IsTimeExpr ¶
func (s *SqlExpr) IsTimeExpr()
type StringLitExpr ¶
type StringLitExpr struct {
// contains filtered or unexported fields
}
func String ¶
func String(val string) *StringLitExpr
func Stringf ¶
func Stringf(format string, val ...any) *StringLitExpr
func (*StringLitExpr) IsTextExpr ¶ added in v0.1.11
func (e *StringLitExpr) IsTextExpr()
type SubStringExpr ¶ added in v0.1.11
type SubStringExpr struct {
// contains filtered or unexported fields
}
func SubString ¶ added in v0.1.11
func SubString(expr Expr, start int64, length int64) *SubStringExpr
func (SubStringExpr) IsTextExpr ¶ added in v0.2.6
func (s SubStringExpr) IsTextExpr()
type SubqueryTableExpr ¶ added in v0.9.0
type SubqueryTableExpr struct {
// contains filtered or unexported fields
}
func SubqueryTable ¶ added in v0.9.0
func SubqueryTable(rawSql string, alias string) *SubqueryTableExpr
SubqueryTable creates a subquery table expression
func (*SubqueryTableExpr) IsTableExpr ¶ added in v0.9.0
func (e *SubqueryTableExpr) IsTableExpr()
type TableFnExpr ¶ added in v0.4.15
type TableFnExpr struct {
// contains filtered or unexported fields
}
func TableFn ¶ added in v0.4.15
func TableFn(name string, ops ...Expr) *TableFnExpr
func (*TableFnExpr) IsTableExpr ¶ added in v0.4.15
func (t *TableFnExpr) IsTableExpr()
type TableFqnExpr ¶
type TableFqnExpr struct {
// contains filtered or unexported fields
}
func TableFqn ¶
func TableFqn(projectId, datasetId, tableId string) *TableFqnExpr
TableFqn names a table through the dialect's ResolveFqn, whose per-dialect quoting is inconsistent by history: some engines protect the case of the parts, others hand them to the engine raw and let it fold them, and none of them quote a part that happens to be a reserved word.
QualifiedIdent is the replacement for anything being written now: an Ident says which form its name is in, so the rendering does not have to guess.
func (*TableFqnExpr) DatasetId ¶ added in v0.8.0
func (t *TableFqnExpr) DatasetId() string
func (*TableFqnExpr) IsTableExpr ¶
func (t *TableFqnExpr) IsTableExpr()
func (*TableFqnExpr) ProjectId ¶ added in v0.8.0
func (t *TableFqnExpr) ProjectId() string
func (*TableFqnExpr) TableId ¶ added in v0.8.0
func (t *TableFqnExpr) TableId() string
type TestedDialect ¶ added in v0.4.5
func DialectsToTest ¶ added in v0.4.5
func DialectsToTest() []*TestedDialect
type TextColExpr ¶
type TextColExpr struct {
ColBaseExpr
}
func TextCol ¶
func TextCol(name string) *TextColExpr
func (*TextColExpr) IsTextExpr ¶
func (s *TextColExpr) IsTextExpr()
type TimeColExpr ¶
type TimeColExpr struct {
// contains filtered or unexported fields
}
func TimeCol ¶
func TimeCol(name string) *TimeColExpr
func (*TimeColExpr) IsTimeExpr ¶
func (t *TimeColExpr) IsTimeExpr()
type TimeLitExpr ¶
type TimeLitExpr struct {
// contains filtered or unexported fields
}
func Time ¶
func Time(val time.Time) *TimeLitExpr
func (*TimeLitExpr) IsTimeExpr ¶
func (e *TimeLitExpr) IsTimeExpr()
type ToCondExpr ¶ added in v0.1.8
type ToCondExpr interface {
ToCondExpr() CondExpr
}
type ToFloat64Expr ¶
type ToFloat64Expr struct {
// contains filtered or unexported fields
}
func ToFloat64 ¶
func ToFloat64(expr Expr) *ToFloat64Expr
func (*ToFloat64Expr) IsNumericExpr ¶ added in v0.1.11
func (e *ToFloat64Expr) IsNumericExpr()
type ToStringExpr ¶
type ToStringExpr struct {
// contains filtered or unexported fields
}
func ToString ¶
func ToString(expr Expr) *ToStringExpr
func (*ToStringExpr) IsTextExpr ¶ added in v0.2.6
func (e *ToStringExpr) IsTextExpr()
type TrinoDialect ¶ added in v0.4.2
type TrinoDialect struct{}
func NewTrinoDialect ¶ added in v0.4.2
func NewTrinoDialect() *TrinoDialect
func (*TrinoDialect) AddTime ¶ added in v0.4.2
func (d *TrinoDialect) AddTime(expr Expr, duration time.Duration) Expr
func (*TrinoDialect) AggregationColumnReference ¶ added in v0.4.2
func (d *TrinoDialect) AggregationColumnReference(expression Expr, alias string) Expr
func (*TrinoDialect) CeilTime ¶ added in v0.4.2
func (d *TrinoDialect) CeilTime(expr Expr, interval time.Duration) Expr
func (*TrinoDialect) Coalesce ¶ added in v0.4.2
func (d *TrinoDialect) Coalesce(exprs ...Expr) Expr
func (*TrinoDialect) ConcatWithSeparator ¶ added in v0.9.0
func (d *TrinoDialect) ConcatWithSeparator(separator string, exprs ...Expr) Expr
func (*TrinoDialect) Count ¶ added in v0.4.2
func (d *TrinoDialect) Count(expr Expr) Expr
func (*TrinoDialect) CountIf ¶ added in v0.4.2
func (d *TrinoDialect) CountIf(expr Expr) Expr
func (*TrinoDialect) CurrentTimestamp ¶ added in v0.4.17
func (d *TrinoDialect) CurrentTimestamp() Expr
func (*TrinoDialect) DateLiteral ¶ added in v0.19.0
func (d *TrinoDialect) DateLiteral(t time.Time) string
func (*TrinoDialect) FoldIdent ¶ added in v0.18.0
func (d *TrinoDialect) FoldIdent(name string) string
FoldIdent returns the name an unquoted reference resolves to. An unquoted reference folds to lower case.
func (*TrinoDialect) FormatLimit ¶ added in v0.9.0
func (d *TrinoDialect) FormatLimit(rowsSql string) string
func (*TrinoDialect) Identifier ¶ added in v0.4.2
func (d *TrinoDialect) Identifier(identifier string) string
func (*TrinoDialect) Median ¶ added in v0.4.2
func (d *TrinoDialect) Median(expr Expr) Expr
func (*TrinoDialect) NumericLiteral ¶ added in v0.19.0
func (d *TrinoDialect) NumericLiteral(s string) (string, error)
NumericLiteral is a DECIMAL literal: Trino will not compare a decimal with text.
func (*TrinoDialect) QuoteIdent ¶ added in v0.18.0
func (d *TrinoDialect) QuoteIdent(name string) string
QuoteIdent renders name wrapped in this dialect's identifier delimiters, always — unlike Identifier, which quotes only when a character demands it and so lets a reserved word through bare.
func (*TrinoDialect) ResolveFieldRef ¶ added in v0.14.4
func (d *TrinoDialect) ResolveFieldRef(name string) string
func (*TrinoDialect) ResolveFqn ¶ added in v0.4.2
func (d *TrinoDialect) ResolveFqn(fqn *TableFqnExpr) (string, error)
func (*TrinoDialect) ResolveTableFunction ¶ added in v0.4.15
func (d *TrinoDialect) ResolveTableFunction(t *TableFnExpr) (string, error)
func (*TrinoDialect) ResolveTime ¶ added in v0.4.2
func (d *TrinoDialect) ResolveTime(t time.Time) (string, error)
func (*TrinoDialect) ResolveTimeColumn ¶ added in v0.4.2
func (d *TrinoDialect) ResolveTimeColumn(expr *TimeColExpr) (string, error)
func (*TrinoDialect) RoundTime ¶ added in v0.4.2
func (d *TrinoDialect) RoundTime(expr Expr, interval time.Duration) Expr
func (*TrinoDialect) Stddev ¶ added in v0.4.2
func (d *TrinoDialect) Stddev(expr Expr) Expr
func (*TrinoDialect) StringLength ¶ added in v0.12.6
func (d *TrinoDialect) StringLength(expr Expr) Expr
func (*TrinoDialect) StringLiteral ¶ added in v0.4.34
func (d *TrinoDialect) StringLiteral(s string) string
func (*TrinoDialect) SubString ¶ added in v0.4.2
func (d *TrinoDialect) SubString(expr Expr, start int64, length int64) Expr
func (*TrinoDialect) SubTime ¶ added in v0.4.2
func (d *TrinoDialect) SubTime(expr Expr, duration time.Duration) Expr
func (*TrinoDialect) SupportsAsBeforeTableAlias ¶ added in v0.17.2
func (d *TrinoDialect) SupportsAsBeforeTableAlias() bool
func (*TrinoDialect) SupportsCrossDatabaseQueries ¶ added in v0.10.4
func (d *TrinoDialect) SupportsCrossDatabaseQueries() bool
func (*TrinoDialect) TimestampLiteral ¶ added in v0.19.0
func (d *TrinoDialect) TimestampLiteral(t time.Time) string
func (*TrinoDialect) TimestampTzLiteral ¶ added in v0.19.0
func (d *TrinoDialect) TimestampTzLiteral(t time.Time) string
func (*TrinoDialect) ToFloat64 ¶ added in v0.4.2
func (d *TrinoDialect) ToFloat64(expr Expr) Expr
func (*TrinoDialect) ToString ¶ added in v0.4.2
func (d *TrinoDialect) ToString(expr Expr) Expr
func (*TrinoDialect) UUIDLiteral ¶ added in v0.19.0
func (d *TrinoDialect) UUIDLiteral(s string) string
UUIDLiteral is a UUID literal: Trino will not compare a uuid with text.
func (*TrinoDialect) UnquoteIdent ¶ added in v0.18.0
func (d *TrinoDialect) UnquoteIdent(text string) (string, bool)
UnquoteIdent is the inverse: it strips one layer of delimiters and decodes the escape inside, reporting whether the text carried any.
type WindowExpr ¶ added in v0.17.2
type WindowExpr struct {
// contains filtered or unexported fields
}
WindowExpr renders a window function call: the function, then an OVER clause carrying an optional PARTITION BY and ORDER BY.
Frame clauses (ROWS/RANGE BETWEEN) are deliberately not modelled — nothing needs them yet, and they are the part of the window syntax the dialects disagree most about.
func Over ¶ added in v0.17.2
func Over(fn Expr) *WindowExpr
Over wraps a function call in an OVER clause. Call PartitionBy and OrderBy to fill the clause in.
func (*WindowExpr) IsNumericExpr ¶ added in v0.17.2
func (e *WindowExpr) IsNumericExpr()
func (*WindowExpr) OrderBy ¶ added in v0.17.2
func (e *WindowExpr) OrderBy(orderBy ...OrderByExpr) *WindowExpr
OrderBy appends ORDER BY terms to the window, using the same Asc/Desc terms as a Select's ORDER BY.
func (*WindowExpr) PartitionBy ¶ added in v0.17.2
func (e *WindowExpr) PartitionBy(exprs ...Expr) *WindowExpr
PartitionBy appends PARTITION BY terms.
type WrapSqlExpr ¶
type WrapSqlExpr struct {
// contains filtered or unexported fields
}
func WrapSql ¶
func WrapSql(sql string, wrapped ...Expr) *WrapSqlExpr
Source Files
¶
- alias.go
- base.go
- case_expr.go
- cond.go
- dialect.go
- dialect_bigquery.go
- dialect_clickhouse.go
- dialect_databricks.go
- dialect_db2.go
- dialect_duckdb.go
- dialect_fabric.go
- dialect_mssql.go
- dialect_mysql.go
- dialect_oracle.go
- dialect_postgres.go
- dialect_redshift.go
- dialect_snowflake.go
- dialect_trino.go
- dialects.go
- helpers.go
- ident.go
- literal.go
- oracle_md5.go
- row_compare.go
- window.go