Documentation
¶
Overview ¶
Package sql provides the ability to parse SQL queries. This pacakge contains some code taking from the Go standard library's time package. Go is licensed as per https://golang.org/LICENSE.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSelectNoName = errors.New("All expressions in SELECT must either reference a column name or include an AS alias") ErrIfArity = errors.New("IF requires two parameters, like IF(dim = 1, SUM(b))") ErrBoundedArity = errors.New("BOUNDED requires three parameters, like BOUNDED(b, 0, 100)") ErrPercentileArity = errors.New("PERCENTILE requires either two or five parameters, like PERCENTILE(b, 99.9, 0, 1000, 3)") ErrPercentileOptWrap = errors.New("PERCENTILE with two parameters may only wrap an existing PERCENTILE expression") ErrShiftArity = errors.New("SHIFT requires two parameters, like SHIFT(SUM(b), '-1h')") ErrCrosshiftArity = errors.New("CROSSHIFT requires three parameters, like CROSSHIFT(SUM(b), '1h', '-1d')") ErrCrosshiftZeroCutoffOrInterval = errors.New("CROSSHIFT cutoff and interval must be non-zero") ErrCROSSTABArity = errors.New("CROSSTAB requires at least one argument") ErrCROSSTABUnique = errors.New("Only one CROSSTAB statement allowed per query") ErrAggregateArity = errors.New("Aggregate functions take only one parameter, like SUM(b)") ErrWildcardNotAllowed = errors.New("Wildcard * is not supported") ErrNestedFunctionCall = errors.New("Nested function calls are not currently supported in SELECT") ErrInvalidPeriod = errors.New("Please specify a period in the form period(5s) where 5s can be any valid Go duration expression") ErrInvalidStride = errors.New("Please specify a stride in the form stride(5s) where 5s can be any valid Go duration expression") )
Functions ¶
func ParseDuration ¶
ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
func RegisterAlias ¶
Types ¶
type Query ¶
type Query struct {
SQL string
// Fields are the fields from the SELECT clause in the order they appear,
// including the synthetic _having field if there's a HAVING clause.
Fields core.FieldSource
// FieldsNoHaving is like Fields but without the synthetic HAVING clause
FieldsNoHaving core.FieldSource
HasSelectAll bool
HasSpecificFields bool
// From is the Table from the FROM clause
From string
FromSubQuery *Query
FromSQL string
Resolution time.Duration
Where goexpr.Expr
WhereSQL string
AsOf time.Time
AsOfOffset time.Duration
Until time.Time
UntilOffset time.Duration
Stride time.Duration
// GroupBy are the GroupBy expressions ordered alphabetically by name.
GroupBy []core.GroupBy
GroupByAll bool
// Crosstab is the goexpr.Expr used for crosstabs (goes into columns rather than rows)
Crosstab goexpr.Expr
CrosstabIncludesTotal bool
HasHaving bool
HavingSQL string
OrderBy []core.OrderBy
Offset int
Limit int
ForceFresh bool
}
Query represents the result of parsing a SELECT query.
Click to show internal directories.
Click to hide internal directories.