fn

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayAgg

func ArrayAgg(exp builder.Exp) builder.AggExpBuilder

ArrayAgg builds the array_agg aggregate function.

array_agg ( anynonarray ) → anyarray

Collects all the input values, including nulls, into an array.

array_agg ( anyarray ) → anyarray

Concatenates all the input arrays into an array of one higher dimension.

func Avg

Avg builds the avg aggregate function.

avg ( T ) → T

Computes the average (arithmetic mean) of all the non-null input values.

func BitAnd

func BitAnd(exp builder.Exp) builder.AggExpBuilder

BitAnd builds the bit_and aggregate function.

bit_and ( T ) → T

Computes the bitwise AND of all non-null input values.

func BitOr

func BitOr(exp builder.Exp) builder.AggExpBuilder

BitOr builds the bit_or aggregate function.

bit_or ( T ) → T

Computes the bitwise OR of all non-null input values.

func BitXor

func BitXor(exp builder.Exp) builder.AggExpBuilder

BitXor builds the bit_xor aggregate function.

bit_xor ( T ) → T

Computes the bitwise exclusive OR of all non-null input values. Can be useful as a checksum for an unordered set of values.

func BoolAnd

func BoolAnd(exp builder.Exp) builder.AggExpBuilder

BoolAnd builds the bool_and aggregate function.

bool_and ( boolean ) → boolean

Returns true if all non-null input values are true, otherwise false.

func BoolOr

func BoolOr(exp builder.Exp) builder.AggExpBuilder

BoolOr builds the bool_or aggregate function.

bool_or ( boolean ) → boolean

Returns true if any non-null input value is true, otherwise false.

func Count

func Count(exp builder.Exp) builder.AggExpBuilder

Count builds the count aggregate function.

count ( * ) → bigint

Computes the number of input rows.

count ( expression ) → bigint

Computes the number of input rows in which the input value is not null.

Example:

builder.Select(fn.Count(builder.N("*"))).From("table")

func CumeDist

func CumeDist(args ...builder.Exp) builder.AggExpBuilder

CumeDist builds the cume_dist aggregate function.

cume_dist ( args ) WITHIN GROUP ( ORDER BY sorted_args ) → double precision

Computes the cumulative distribution, that is (number of rows preceding or peers with hypothetical row) / (total rows). The value thus ranges from 1/N to 1.

func DenseRank

func DenseRank(args ...builder.Exp) builder.AggExpBuilder

DenseRank builds the dense_rank aggregate function.

dense_rank ( args ) WITHIN GROUP ( ORDER BY sorted_args ) → bigint

Computes the rank of the hypothetical row, without gaps; this function effectively counts peer groups.

func Extract added in v0.2.2

func Extract(field string, from builder.Exp) builder.ExpBase

Extract builds the EXTRACT(field FROM source) function.

func Grouping

func Grouping(exps ...builder.Exp) builder.AggExpBuilder

Grouping builds the grouping operation.

GROUPING ( group_by_expression(s) ) → integer

Returns a bit mask indicating which GROUP BY expressions are not included in the current grouping set. Bits are assigned with the rightmost argument corresponding to the least-significant bit; each bit is 0 if the corresponding expression is included in the grouping criteria of the grouping set generating the current result row, and 1 if it is not included.

func JsonAgg

func JsonAgg(exp builder.Exp) builder.AggExpBuilder

JsonAgg builds the json_agg aggregate function.

json_agg ( anyelement ) → json

Collects all the input values, including nulls, into a JSON array. Values are converted to JSON as per to_json.

func JsonBuildObject

func JsonBuildObject() builder.JsonBuildObjectBuilder

func JsonObjectAgg

func JsonObjectAgg(key, value builder.Exp) builder.AggExpBuilder

JsonObjectAgg builds the json_object_agg aggregate function.

json_object_agg ( key "any", value "any" ) → json

Collects all the key/value pairs into a JSON object. Key arguments are coerced to text; value arguments are converted as per to_json. Values can be null, but not keys.

func JsonbAgg

func JsonbAgg(exp builder.Exp) builder.AggExpBuilder

JsonbAgg builds the json_agg aggregate function.

jsonb_agg ( anyelement ) → jsonb

Collects all the input values, including nulls, into a JSON array. Values are converted to JSON as per to_jsonb.

func JsonbObjectAgg

func JsonbObjectAgg(key, value builder.Exp) builder.AggExpBuilder

JsonbObjectAgg builds the jsonb_object_agg aggregate function.

jsonb_object_agg ( key "any", value "any" ) → jsonb

Collects all the key/value pairs into a JSON object. Key arguments are coerced to text; value arguments are converted as per to_jsonb. Values can be null, but not keys.

func Max

Max builds the max aggregate function.

max ( see text ) → same as input type

Computes the maximum of the non-null input values. Available for any numeric, string, date/time, or enum type, as well as inet, interval, money, oid, pg_lsn, tid, xid8, and arrays of any of these types.

func Min

Min builds the min aggregate function.

min ( see text ) → same as input type

Computes the minimum of the non-null input values. Available for any numeric, string, date/time, or enum type, as well as inet, interval, money, oid, pg_lsn, tid, xid8, and arrays of any of these types.

func Mode

func Mode() builder.AggExpBuilder

Mode builds the mode aggregate function.

mode () WITHIN GROUP ( ORDER BY anyelement ) → anyelement

Computes the mode, the most frequent value of the aggregated argument (arbitrarily choosing the first one if there are multiple equally-frequent values). The aggregated argument must be of a sortable type.

func PercentRank

func PercentRank(args ...builder.Exp) builder.AggExpBuilder

PercentRank builds the percent_rank aggregate function.

percent_rank ( args ) WITHIN GROUP ( ORDER BY sorted_args ) → double precision

Computes the relative rank of the hypothetical row, that is (rank - 1) / (total rows - 1). The value thus ranges from 0 to 1 inclusive.

func PercentileCont

func PercentileCont(fraction builder.Exp) builder.AggExpBuilder

PercentileCont builds the percentile_cont aggregate function.

percentile_cont ( fraction double precision ) WITHIN GROUP ( ORDER BY double precision ) → double precision
percentile_cont ( fraction double precision ) WITHIN GROUP ( ORDER BY interval ) → interval
percentile_cont ( fractions double precision[] ) WITHIN GROUP ( ORDER BY double precision ) → double precision[]
percentile_cont ( fractions double precision[] ) WITHIN GROUP ( ORDER BY interval ) → interval[]

Computes the continuous percentile, a value corresponding to the specified fraction within the ordered set of aggregated argument values. This will interpolate between adjacent input items if needed.

func PercentileDisc

func PercentileDisc(fraction builder.Exp) builder.AggExpBuilder

PercentileDisc builds the percentile_disc aggregate function.

percentile_disc ( fraction double precision ) WITHIN GROUP ( ORDER BY anyelement ) → anyelement

Computes the discrete percentile, the first value within the ordered set of aggregated argument values whose position in the ordering equals or exceeds the specified fraction. The aggregated argument must be of a sortable type.

percentile_disc ( fractions double precision[] ) WITHIN GROUP ( ORDER BY anyelement ) → anyarray

Computes multiple discrete percentiles. The result is an array of the same dimensions as the fractions parameter, with each non-null element replaced by the input value corresponding to that percentile. The aggregated argument must be of a sortable type.

func RangeAgg

func RangeAgg(value builder.Exp) builder.AggExpBuilder

RangeAgg builds the range_agg aggregate function.

range_agg ( value anyrange ) → anymultirange
range_agg ( value anymultirange ) → anymultirange

Computes the union of the non-null input values.

func RangeIntersectAgg

func RangeIntersectAgg(value builder.Exp) builder.AggExpBuilder

RangeIntersectAgg builds the range_intersect_agg aggregate function.

range_intersect_agg ( value anyrange ) → anyrange
range_intersect_agg ( value anymultirange ) → anymultirange

Computes the intersection of the non-null input values.

func Rank

func Rank(args ...builder.Exp) builder.AggExpBuilder

Rank builds the rank aggregate function.

rank ( args ) WITHIN GROUP ( ORDER BY sorted_args ) → bigint

Computes the rank of the hypothetical row, with gaps; that is, the row number of the first row in its peer group.

func StringAgg

func StringAgg(value, delimiter builder.Exp) builder.AggExpBuilder

StringAgg builds the string_agg aggregate function.

string_agg ( value text, delimiter text ) → text
string_agg ( value bytea, delimiter bytea ) → bytea

Concatenates the non-null input values into a string. Each value after the first is preceded by the corresponding delimiter (if it's not null).

func Sum

Sum builds the sum aggregate function.

sum ( T ) → T

Computes the sum of the non-null input values.

func Xmlagg

func Xmlagg(exp builder.Exp) builder.AggExpBuilder

Xmlagg builds the xmlagg aggregate function.

xmlagg ( xml ) → xml

Concatenates the non-null XML input values.

Types

This section is empty.

Jump to

Keyboard shortcuts

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