cockroach: Index | Files

package builtins

import ""


Package Files

aggregate_builtins.go all_builtins.go builtins.go generator_builtins.go geo_builtins.go math_builtins.go notice.go pg_builtins.go window_builtins.go window_frame_builtins.go


const AnyNotNull = "any_not_null"

AnyNotNull is the name of the aggregate returned by NewAnyNotNullAggregate.

const NodeIDBits = 15

NodeIDBits is the number of bits stored in the lower portion of GenerateUniqueInt.


var (
    // DatEncodingUTFId is the encoding ID for our only supported database
    // encoding, UTF8.
    DatEncodingUTFId = tree.NewDInt(6)
    // DatEncodingEnUTF8 is the encoding name for our only supported database
    // encoding, UTF8.
    DatEncodingEnUTF8 = tree.NewDString("en_US.utf8")

var AllAggregateBuiltinNames []string

AllAggregateBuiltinNames is an array containing the subset of AllBuiltinNames that corresponds to aggregate functions.

var AllBuiltinNames []string

AllBuiltinNames is an array containing all the built-in function names, sorted in alphabetical order. This can be used for a deterministic walk through the Builtins map.

var AllWindowBuiltinNames []string

AllWindowBuiltinNames is an array containing the subset of AllBuiltinNames that corresponds to window functions.

var EvalFollowerReadOffset func(clusterID uuid.UUID, _ *cluster.Settings) (time.Duration, error)

EvalFollowerReadOffset is a function used often with AS OF SYSTEM TIME queries to determine the appropriate offset from now which is likely to be safe for follower reads. It is injected by followerreadsccl. An error may be returned if an enterprise license is not installed.

var (

    // SequenceNameArg represents the name of sequence (string) arguments in
    // builtin functions.
    SequenceNameArg = "sequence_name"

func CleanEncodingName Uses

func CleanEncodingName(s string) string

CleanEncodingName sanitizes the string meant to represent a recognized encoding. This ignores any non-alphanumeric character.

See function clean_encoding_name() in postgres' sources in backend/utils/mb/encnames.c.

func EmptyGenerator Uses

func EmptyGenerator() tree.ValueGenerator

EmptyGenerator returns a new, empty generator. Used when a SRF evaluates to NULL.

func GenerateUniqueID Uses

func GenerateUniqueID(instanceID int32, timestamp uint64) tree.DInt

GenerateUniqueID encapsulates the logic to generate a unique number from a nodeID and timestamp.

func GenerateUniqueInt Uses

func GenerateUniqueInt(instanceID base.SQLInstanceID) tree.DInt

GenerateUniqueInt creates a unique int composed of the current time at a 10-microsecond granularity and the instance-id. The instance-id is stored in the lower 15 bits of the returned value and the timestamp is stored in the upper 48 bits. The top-bit is left empty so that negative values are not returned. The 48-bit timestamp field provides for 89 years of timestamps. We use a custom epoch (Jan 1, 2015) in order to utilize the entire timestamp range.

Note that GenerateUniqueInt() imposes a limit on instance IDs while generateUniqueBytes() does not.

TODO(pmattis): Do we have to worry about persisting the milliseconds value periodically to avoid the clock ever going backwards (e.g. due to NTP adjustment)?

func GetBuiltinProperties Uses

func GetBuiltinProperties(name string) (*tree.FunctionProperties, []tree.Overload)

GetBuiltinProperties provides low-level access to a built-in function's properties. For a better, semantic-rich interface consider using tree.FunctionDefinition instead, and resolve function names via ResolvableFunctionReference.Resolve().

func NewAggregateWindowFunc Uses

func NewAggregateWindowFunc(
    aggConstructor func(*tree.EvalContext, tree.Datums) tree.AggregateFunc,
) func(*tree.EvalContext) tree.WindowFunc

NewAggregateWindowFunc creates a constructor of aggregateWindowFunc with agg initialized by provided aggConstructor.

func NewAnyNotNullAggregate Uses

func NewAnyNotNullAggregate(evalCtx *tree.EvalContext, _ tree.Datums) tree.AggregateFunc

NewAnyNotNullAggregate returns an aggregate function that returns an arbitrary not-NULL value passed to Add (or NULL if no such value). This is particularly useful for "passing through" values for columns which we know are constant within any aggregation group (for example, the grouping columns themselves).

Note that NULL values do not affect the result of the aggregation; this is important in a few different contexts:

- in distributed multi-stage aggregations, we can have a local stage with
  multiple (parallel) instances feeding into a final stage. If some of the
  instances see no rows, they emit a NULL into the final stage which needs
  to be ignored.

- for query optimization, when moving aggregations across left joins (which
  add NULL values).

func PGIOBuiltinPrefix Uses

func PGIOBuiltinPrefix(typ *types.T) string

PGIOBuiltinPrefix returns the string prefix to a type's IO functions. This is either the type's postgres display name or the type's postgres display name plus an underscore, depending on the type.

func ShouldReset Uses

func ShouldReset(w tree.WindowFunc)

ShouldReset sets shouldReset to true if w is framableAggregateWindowFunc.

Package builtins imports 73 packages (graph) and is imported by 94 packages. Updated 2020-08-09. Refresh now. Tools for package owners.