Download PDFSubmit Feedback

  • Special Syntax Forms
  • Conditional and Function-like Operators
  • Buit-in Functions
  • Aggregate Functions
  • Window Functions

Relational Functions

A function is a set of predefined operations used to compute or convert data.

Special Syntax Forms

The following syntax forms are recognized for compatibility with the SQL standard and PostgreSQL, but are equivalent to regular built-in functions.

Special FormEquivalent to
AT TIME ZONEtimezone()
CURRENT_CATALOGcurrent_database()
COLLATION FORpg_collation_for()
CURRENT_DATEcurrent_date()
CURRENT_ROLEcurrent_user()
CURRENT_SCHEMAcurrent_schema()
CURRENT_TIMESTAMPcurrent_timestamp()
CURRENT_TIMEcurrent_time()
CURRENT_USERcurrent_user()
EXTRACT(<part> FROM <value>)extract("<part>", <value>)
EXTRACT_DURATION(<part>FROM <value>)extract_duration("<part>",<value>)
OVERLAY(<text1> PLACING <text2> FROM <int1> FOR <int2>)overlay(<text1>,<text2>, <int1>, <int2>)
OVERLAY(<text1> PLACING <text2> FROM <int>)overlay(<text1>,<text2>, <int>)
POSITION(<text1> IN <text2>)strpos(<text2>, <text1>)
SESSION_USERcurrent_user()
SUBSTRING(<text>FOR<int1>FROM <int2>)substring(<text>,<int2>, <int1>)
SUBSTRING(<text> FOR <int>)substring(<text>, 1, <int>)
SUBSTRING(<text>FROM<int1>FOR<int2>)substring(<text>,<int1>, <int2>)
SUBSTRING(<text> FROM <int>)substring(<text>, <int>)
TRIM(<text1> FROM <text2>)btrim(<text2>, <text1>)
TRIM(<text1>, <text2>)btrim(<text1>, <text2>)
TRIM(FROM <text>)btrim(<text>)
TRIM(LEADING <text1> FROM <text2>)ltrim(<text2>, <text1>)
TRIM(LEADING FROM <text>)ltrim(<text>)
TRIM(TRAILING <text1> FROM <text2>)rtrim(<text2>, <text1>)
TRIM(TRAILING FROM <text>)rtrim(<text>)
USERcurrent_user()

Conditional and Function-like Operators

This table lists the operators that look like built-in functions but have special evaluation rules.

OperatorDescription
ANNOTATE_TYPE(...)Explicitly typed eExpression
ARRAY(...)Conversion of subquery results to an array
ARRAY[...]Conversion of scalar expressions to an array
CAST(...)Type cast
COALESCE(...)First non-NULL expression with short circuit
EXISTS(...)Existence test on the result of subqueries
IF(...)Conditional evaluation
IFNULL(...)Alias for COALESCE restricted to two operands
Note
- When both operands are explicitly declared, they must have the same type. ​Otherwise, the system cannot evaluate them.
- When one operand is explicitly declared and the other operand is a constant, the system converts the constant to the specified data type and then evaluates them. If failed to convert, the system returns an error.
- When both operands are constants, the system evaluates the operands if they have the same type (numeric or string type). If one operand is a numeric constant and the other one is a string-typed constant, the system converts the string-typed constant to the numeric-typed constant and then evaluates them. If failed to convert, the system returns an error.
NULLIF(...)Return NULL conditionally
Note
- When both operands are explicitly declared, they must have the same type. ​Otherwise, the system cannot evaluate them.
- When one operand is explicitly declared and the other operand is a constant, the system converts the constant to the specified data type and then evaluates them. If failed to convert, the system returns an error.
- When both operands are constants, the system evaluates the operands if they have the same type (numeric or string type). If one operand is a numeric constant and the other one is a string-typed constant, the system converts the string-typed constant to the numeric-typed constant and then evaluates them. If failed to convert, the system returns an error.
ROW(...)Tuple constructor

Buit-in Functions

Array Functions

Function → ReturnsDescription
array_append(array: bool[], elem: bool) → bool[]Append elem to array, returning the result.
array_append(array: bytes[], elem: bytes) → bytes[]Append elem to array, returning the result.
array_append(array: date[], elem: date) → date[]Append elem to array, returning the result.
array_append(array: decimal[], elem: decimal) → decimal[]Append elem to array, returning the result.
array_append(array: float4[], elem: float4) → float4[]Append elem to array, returning the result.
array_append(array: float8[], elem: float8) → float8[]Append elem to array, returning the result.
array_append(array: inet[], elem: inet) → inet[]Append elem to array, returning the result.
array_append(array: int2[], elem: int2) → int8[]Append elem to array, returning the result.
array_append(array: int2[], elem: int4) → int8[]Append elem to array, returning the result.
array_append(array: int2[], elem: int8) → int8[]Append elem to array, returning the result.
array_append(array: int4[], elem: int2) → int8[]Append elem to array, returning the result.
array_append(array: int4[], elem: int4) → int8[]Append elem to array, returning the result.
array_append(array: int4[], elem: int8) → int8[]Append elem to array, returning the result.
array_append(array: int8[], elem: int2) → int8[]Append elem to array, returning the result.
array_append(array: int8[], elem: int4) → int8[]Append elem to array, returning the result.
array_append(array: int8[], elem: int8) → int8[]Append elem to array, returning the result.
array_append(array: interval[], elem: interval) → interval[]Append elem to array, returning the result.
array_append(array: string[], elem: string) → string[]Append elem to array, returning the result.
array_append(array: time[], elem: time) → time[]Append elem to array, returning the result.
array_append(array: timestamp[], elem: timestamp) → timestamp[]Append elem to array, returning the result.
array_append(array: timestamptz[], elem: timestamptz) → timestamptz[]Append elem to array, returning the result.
array_append(array: uuid[], elem: uuid) → uuid[]Append elem to array, returning the result.
array_append(array: oid[], elem: oid) → oid[]Append elem to array, returning the result.
array_append(array: timetz[], elem: timetz) → timetz[]Append elem to array, returning the result.
array_append(array: varbit[], elem: varbit) → varbit[]Append elem to array, returning the result.
array_cat(left: bool[], right: bool[]) → bool[]Append two arrays.
array_cat(left: bytes[], right: bytes[]) → bytes[]Append two arrays.
array_cat(left: date[], right: date[]) → date[]Append two arrays.
array_cat(left: decimal[], right: decimal[]) → decimal[]Append two arrays.
array_cat(left: float4[], right: float4[]) → float8[]Append two arrays.
array_cat(left: float4[], right: float8[]) → float8[]Append two arrays.
array_cat(left: float8[], right: float4[]) → float8[]Append two arrays.
array_cat(left: float8[], right: float8[]) → float8[]Append two arrays.
array_cat(left: inet[], right: inet[]) → inet[]Append two arrays.
array_cat(left: int2[], right: int2[]) → int8[]Append two arrays.
array_cat(left: int2[], right: int4[]) → int8[]Append two arrays.
array_cat(left: int2[], right: int8[]) → int8[]Append two arrays.
array_cat(left: int4[], right: int2[]) → int8[]Append two arrays.
array_cat(left: int4[], right: int4[]) → int8[]Append two arrays.
array_cat(left: int4[], right: int8[]) → int8[]Append two arrays.
array_cat(left: int8[], right: int2[]) → int8[]Append two arrays.
array_cat(left: int8[], right: int4[]) → int8[]Append two arrays.
array_cat(left: int8[], right: int8[]) → int8[]Append two arrays.
array_cat(left: interval[], right: interval[]) → interval[]Append two arrays.
array_cat(left: string[], right: string[]) → string[]Append two arrays.
array_cat(left: time[], right: time[]) → time[]Append two arrays.
array_cat(left: timestamp[], right: timestamp[]) → timestamp[]Append two arrays.
array_cat(left: timestamptz[], right: timestamptz[]) → timestamptz[]Append two arrays.
array_cat(left: uuid[], right: uuid[]) → uuid[]Append two arrays.
array_cat(left: oid[], right: oid[]) → oid[]Append two arrays.
array_cat(left: timetz[], right: timetz[]) → timetz[]Append two arrays.
array_cat(left: varbit[], right: varbit[]) → varbit[]Append two arrays.
array_length(input:anyelement[],array_dimension: int8) → int8Calculate the length of input on the provided array_dimension. But, because KWDB does not yet support multi-dimensional arrays, the only supported array_dimension is 1.
array_lower(input:anyelement[],array_dimension: int8) → int8Calculate the minimum value of input on the provided array_dimension. But, because KWDB does not yet support multi-dimensional arrays, the only supported array_dimension is 1.
array_position(array: bool[], elem: bool) → int8Return the index of the first elem in array.
array_position(array: bytes[], elem: bytes) → int8Return the index of the first elem in array.
array_position(array: date[], elem: date) → int8Return the index of the first elem in array.
array_position(array: decimal[], elem: decimal) → int8Return the index of the first elem in array.
array_position(array: float4[], elem: float4) → int8Return the index of the first elem in array.
array_position(array: float8[], elem: float8) → int8Return the index of the first elem in array.
array_position(array: inet[], elem: inet) → int8Return the index of the first elem in array.
array_position(array: int2[], elem: int2) → int8Return the index of the first elem in array.
array_position(array: int4[], elem: int4) → int8Return the index of the first elem in array.
array_position(array: int8[], elem: int8) → int8Return the index of the first elem in array.
array_position(array: interval[], elem: interval) → int8Return the index of the first elem in array.
array_position(array: string[], elem: string) → int8Return the index of the first elem in array.
array_position(array: time[], elem: time) → int8Return the index of the first elem in array.
array_position(array:timestamp[],elem:timestamp) → int8Return the index of the first elem in array.
array_position(array:timestamptz[],elem:timestamptz) → int8Return the index of the first elem in array.
array_position(array: uuid[], elem: uuid) → int8Return the index of the first elem in array.
array_position(array: oid[], elem: oid) → int8Return the index of the first elem in array.
array_position(array: timetz[], elem: timetz) → int8Return the index of the first elem in array.
array_position(array: varbit[], elem: varbit) → int8Return the index of the first elem in array.
array_positions(array: bool[], elem: bool) → int8[]Return an array of indexes of elem in array.
array_positions(array: bytes[], elem: bytes) → int8[]Return an array of indexes of elem in array.
array_positions(array: date[], elem: date) → int8[]Return an array of indexes of elem in array.
array_positions(array: decimal[], elem: decimal) → int8[]Return an array of indexes of elem in array.
array_positions(array: float4[], elem: float4) → int8[]Return an array of indexes of elem in array.
array_positions(array: float8[], elem: float8) → int8[]Return an array of indexes of elem in array.
array_positions(array: inet[], elem: inet) → int8[]Return an array of indexes of elem in array.
array_positions(array: int2[], elem: int2) → int8[]Return an array of indexes of elem in array.
array_positions(array: int4[], elem: int4) → int8[]Return an array of indexes of elem in array.
array_positions(array: int8[], elem: int8) → int8[]Return an array of indexes of elem in array.
array_positions(array: interval[], elem: interval) → int8[]Return an array of indexes of elem in array.
array_positions(array: string[], elem: string) → int8[]Return an array of indexes of elem in array.
array_positions(array: time[], elem: time) → int8[]Return an array of indexes of elem in array.
array_positions(array:timestamp[],elem:timestamp) → int8[]Return an array of indexes of elem in array.
array_positions(array:timestamptz[],elem:timestamptz) → int8[]Return an array of indexes of elem in array.
array_positions(array: uuid[], elem: uuid) → int8[]Return an array of indexes of elem in array.
array_positions(array: oid[], elem: oid) → int8[]Return an array of indexes of elem in array.
array_positions(array: timetz[], elem: timetz) → int8[]Return an array of indexes of elem in array.
array_positions(array: varbit[], elem: varbit) → int8[]Return an array of indexes of elem in array.
array_prepend(elem: bool, array: bool[]) → bool[]Prepend elem to array, returning the result.
array_prepend(elem: bytes, array: bytes[]) → bytes[]Prepend elem to array, returning the result.
array_prepend(elem: date, array: date[]) → date[]Prepend elem to array, returning the result.
array_prepend(elem: decimal, array: decimal[]) → decimal[]Prepend elem to array, returning the result.
array_prepend(elem: float4, array: float4[]) → float4[]Prepend elem to array, returning the result.
array_prepend(elem: float8, array: float8[]) → float8[]Prepend elem to array, returning the result.
array_prepend(elem: inet, array: inet[]) → inet[]Prepend elem to array, returning the result.
array_prepend(elem: int2, array: int2[]) → int2[]Prepend elem to array, returning the result.
array_prepend(elem: int4, array: int4[]) → int4[]Prepend elem to array, returning the result.
array_prepend(elem: int8, array: int8[]) → int8[]Prepend elem to array, returning the result.
array_prepend(elem: interval, array: interval[]) → interval[]Prepend elem to array, returning the result.
array_prepend(elem: string, array: string[]) → string[]Prepend elem to array, returning the result.
array_prepend(elem: time, array: time[]) → time[]Prepend elem to array, returning the result.
array_prepend(elem:timestamp,array:timestamp[]) → timestamp[]Prepend elem to array, returning the result.
array_prepend(elem:timestamptz,array:timestamptz[]) → timestamptz[]Prepend elem to array, returning the result.
array_prepend(elem: uuid, array: uuid[]) → uuid[]Prepend elem to array, returning the result.
array_prepend(elem: oid, array: oid[]) → oid[]Prepend elem to array, returning the result.
array_prepend(elem: timetz, array: timetz[]) → timetz[]Prepend elem to array, returning the result.
array_prepend(elem: varbit, array: varbit[]) → varbit[]Prepend elem to array, returning the result.
array_remove(array: bool[], elem: bool) → bool[]Equal to elem from array. Remove all elements.
array_remove(array: bytes[], elem: bytes) → bytes[]Remove all elements equal to elem from array.
array_remove(array: date[], elem: date) → date[]Remove all elements equal to elem from array.
array_remove(array: decimal[], elem: decimal) → decimal[]Remove all elements equal to elem from array.
array_remove(array: float4[], elem: float4) → float4[]Remove all elements equal to elem from array.
array_remove(array: float8[], elem: float8) → float8[]Remove all elements equal to elem from array.
array_remove(array: inet[], elem: inet) → inet[]Remove all elements equal to elem from array.
array_remove(array: int2[], elem: int2) → int2[]Remove all elements equal to elem from array.
array_remove(array: int4[], elem: int4) → int4[]Remove all elements equal to elem from array.
array_remove(array: int8[], elem: int8) → int8[]Remove all elements equal to elem from array.
array_remove(array: interval[], elem: interval) → interval[]Remove all elements equal to elem from array.
array_remove(array: string[], elem: string) → string[]Remove all elements equal to elem from array.
array_remove(array: time[], elem: time) → time[]Remove all elements equal to elem from array.
array_remove(array:timestamp[],elem:timestamp) → timestamp[]Remove all elements equal to elem from array.
array_remove(array:timestamptz[],elem:timestamptz) → timestamptz[]Remove all elements equal to elem from array.
array_remove(array: uuid[], elem: uuid) → uuid[]Remove all elements equal to elem from array.
array_remove(array: oid[], elem: oid) → oid[]Remove all elements equal to elem from array.
array_remove(array: timetz[], elem: timetz) → timetz[]Remove all elements equal to elem from array.
array_remove(array: varbit[], elem: varbit) → varbit[]Remove all elements equal to elem from array.
array_replace(array: bool[], toreplace: bool, replacewith: bool) → bool[]Replace toreplace in array with replacewith.
array_replace(array: bytes[], toreplace: bytes, replacewith: bytes) → bytes[]Replace toreplace in array with replacewith.
array_replace(array: date[], toreplace: date, replacewith: date) → date[]Replace toreplace in array with replacewith.
array_replace(array: decimal[], toreplace: decimal, replacewith: decimal) → decimal[]Replace toreplace in array with replacewith.
array_replace(array: float4[], toreplace: float4, replacewith: float4) → float4[]Replace toreplace in array with replacewith.
array_replace(array: float8[], toreplace: float8, replacewith: float8) → float8[]Replace toreplace in array with replacewith.
array_replace(array: inet[], toreplace: inet, replacewith: inet) → inet[]Replace toreplace in array with replacewith.
array_replace(array: int2[], toreplace: int2, replacewith: int2) → int2[]Replace toreplace in array with replacewith.
array_replace(array: int4[], toreplace: int4, replacewith: int4) → int4[]Replace toreplace in array with replacewith.
array_replace(array: int8[], toreplace: int8, replacewith: int8) → int8[]Replace toreplace in array with replacewith.
array_replace(array: interval[], toreplace: interval, replacewith: interval) → interval[]Replace toreplace in array with replacewith.
array_replace(array: string[], toreplace: string, replacewith: string) → string[]Replace toreplace in array with replacewith.
array_replace(array: time[], toreplace: time, replacewith: time) → time[]Replace toreplace in array with replacewith.
array_replace(array: timestamp[], toreplace: timestamp, replacewith: timestamp) → timestamp[]Replace toreplace in array with replacewith.
array_replace(array: timestamptz[], toreplace: timestamptz, replacewith: timestamptz) → timestamptz[]Replace toreplace in array with replacewith.
array_replace(array: uuid[], toreplace: uuid, replacewith: uuid) → uuid[]Replace toreplace in array with replacewith.
array_replace(array: oid[], toreplace: oid, replacewith: oid) → oid[]Replace toreplace in array with replacewith.
array_replace(array: timetz[], toreplace: timetz, replacewith: timetz) → timetz[]Replace toreplace in array with replacewith.
array_replace(array: varbit[], toreplace: varbit, replacewith: varbit) → varbit[]Replace toreplace in array with replacewith.
array_to_string(input: anyelement[], delim: string) → stringJoin an array into a string with a delimiter.
array_to_string(input: anyelement[], delimiter: string, null: string) → stringJoin an array into a string with a delimiter, replacing NULLs with a null string.
array_upper(input: anyelement[], array_dimension: int8) → int8Calculate the maximum value of input on the provided array_dimension. However, because KWDB does not yet support multi-dimensional arrays, the only supported array_dimension is 1.
string_to_array(str: string, delimiter: string) → string[]Split a string into components on a delimiter.
string_to_array(str: string, delimiter: string, null: string) → string[]Split a string into components on a delimiter, replacing NULLs with a null string.

BOOL Functions

Function → ReturnsDescription
ilike_escape(unescaped: string, pattern: string, escape: string) → boolMatch case insensitively unescaped with pattern using escape as an escape token.
inet_contained_by_or_equals(val: inet, container: inet) → boolTest for subnet inclusion or equality, using only the network parts of the addresses. The host part of the addresses is ignored.
inet_contains_or_equals(container: inet, val: inet) → boolTest for subnet inclusion or equality, using only the network parts of the addresses. The host part of the addresses is ignored.
inet_same_family(val: inet, val: inet) → boolCheck if two IP addresses are of the same IP family.
like_escape(unescaped: string, pattern: string, escape: string) → boolMatch unescaped with pattern using escape as an escape token.
not_ilike_escape(unescaped: string, pattern: string, escape: string) → boolCheck whether unescaped not matches case insensitively with pattern using escape as an escape token.
not_like_escape(unescaped: string, pattern: string, escape: string) → boolCheck whether unescaped not matches with pattern using escape as an escape token.
not_similar_to_escape(unescaped: string, pattern: string, escape: string) → boolCheck whether unescaped not matches with pattern using escape as an escape token.
similar_to_escape(unescaped: string, pattern: string, escape: string) → boolMatch unescaped with pattern using escape as an escape token.

Comparison Functions

Function → ReturnsDescription
greatest(anyelement...) → anyelementReturn the element with the greatest value.
least(anyelement...) → anyelementReturn the element with the lowest value.

Date and Time Functions

Function → ReturnsDescription
age(end: timestamptz, begin: timestamptz) → intervalCalculate the interval between begin and end.
age(val: timestamptz) → intervalCalculate the interval between val and the current time.
current_date() → dateReturn the date of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
current_timestamp() → dateReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
current_timestamp() → timestampReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
current_timestamp() → timestamptzReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
current_timestamp(precision: int8) → dateReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
current_timestamp(precision: int8) → timestampReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
current_timestamp(precision: int8) → timestamptzReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
date_trunc(element: string, input: date) → timestamptzTruncate input to precision element. Set all fields that are less significant than element to zero (or one, for day and month). Compatible elements: millennium, century, decade, year, quarter, month, week, day, hour, minute, second, millisecond, microsecond.
date_trunc(element: string, input: time) → intervalTruncate input to precision element. Set all fields that are less significant than element to zero. Compatible elements: hour, minute, second, millisecond, microsecond.
date_trunc(element: string, input: timestamp) → timestampTruncate input to precision element. Set all fields that are less significant than element to zero (or one, for day and month). Compatible elements: millennium, century, decade, year, quarter, month, week, day, hour, minute, second, millisecond, microsecond.
date_trunc(element: string, input: timestamptz) → timestamptzTruncate input to precision element. Set all fields that are less significant than element to zero (or one, for day and month). Compatible elements: millennium, century, decade, year, quarter, month, week, day, hour, minute, second, millisecond, microsecond.
experimental_strftime(input: date, extract_format: string) → stringFrom input, extract and format the time as identified in extract_format using standard strftime notation (though not all formatting is supported).
experimental_strftime(input: timestamp, extract_format: string) → stringFrom input, extract and format the time as identified in extract_format using standard strftime notation (though not all formatting is supported).
experimental_strftime(input: timestamptz, extract_format: string) → stringFrom input, extract and format the time as identified in extract_format using standard strftime notation (though not all formatting is supported).
extract(element: string, input: date) → float8Extract element from input. Compatible elements: millennium, century, decade, year, isoyear, quarter, month, week, dayofweek, isodow, dayofyear, julian, hour, minute, second, millisecond, microsecond, epoch.
extract(element: string, input: interval) → float8Extract element from input. Compatible elements: millennium, century, decade, year, month, day, hour, minute, second, millisecond, microsecond, epoch.
extract(element: string, input: time) → float8Extract element from input. Compatible elements: millennium, century, decade, year, month, day, hour, minute, second, millisecond, microsecond, epoch.
extract(element: string, input: timestamp) → float8Extract element from input. Compatible elements: millennium, century, decade, year, isoyear, quarter, month, week, dayofweek, isodow, dayofyear, julian, hour, minute, second, millisecond, microsecond, epoch.
extract(element: string, input: timestamptz) → float8Extract element from input. Compatible elements: millennium, century, decade, year, isoyear, quarter, month, week, dayofweek, isodow, dayofyear, julian, hour, minute, second, millisecond, microsecond, epoch, timezone, timezone_hour, timezone_minute.
extract(element: string, input: timetz) → float8Extract element from input. Compatible elements: hour, minute, second, millisecond, microsecond, epoch, timezone, timezone_hour, timezone_minute.
extract(element: string, input: int2) → float8Extract element from input. Compatible elements: hour, minute, second, millisecond, microsecond, epoch, timezone, timezone_hour, timezone_minute.
extract(element: string, input: int4) → float8Extract element from input. Compatible elements: hour, minute, second, millisecond, microsecond, epoch, timezone, timezone_hour, timezone_minute.
extract(element: string, input: int8) → float8Extract element from input. Compatible elements: hour, minute, second, millisecond, microsecond, epoch, timezone, timezone_hour, timezone_minute.
extract_duration(element: string, input: interval) → int8Extract element from input. Compatible elements: hour, minute, second, millisecond, microsecond.
localtimestamp() → dateReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
localtimestamp() → timestampReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
localtimestamp() → timestamptzReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
localtimestamp(precision: int8) → dateReturn the time of the current transaction based on the specified precision. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions. The precision specifies the count of digits to the right of the decimal point followed the second.
localtimestamp(precision: int8) → timestampReturn the time of the current transaction based on the specified precision. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions. The precision specifies the count of digits to the right of the decimal point followed the second.
localtimestamp(precision: int8) → timestamptzReturn the time of the current transaction based on the specified precision. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions. The precision specifies the count of digits to the right of the decimal point followed the second.
now() → dateReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
now() → timestampReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
now() → timestamptzReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
statement_timestamp() → timestampReturn the start time of the current statement.
statement_timestamp() → timestamptzReturn the start time of the current statement.
timeofday() → stringReturn the current system time on one of the cluster nodes as a string.
timezone(time: time, timezone: string) → timetzTreat given time without time zone as located in the specified time zone.
timezone(timestamp: timestamp, timezone: string) → timestamptzTreat given timestamp without time zone as located in the specified time zone.
timezone(timestamptz: timestamptz, timezone: string) → timestampConvert given timestamp with time zone to the new time zone, with no time zone designation.
timezone(timetz: timetz, timezone: string) → timetzConvert given time with time zone to the new time zone.
timezone(timezone: string, time: time) → timetzTreat given time without time zone as located in the specified time zone.
timezone(timezone: string, timestamp: timestamp) → timestamptzTreat given timestamp without time zone as located in the specified time zone.
timezone(timezone: string, timestamptz: timestamptz) → timestampConvert given timestamp with time zone to the new time zone, with no time zone designation.
timezone(timezone: string, timestamptz_string: string) → timestampConvert given timestamp with time zone to the new time zone, with no time zone designation.
timezone(timezone: string, timetz: timetz) → timetzConvert given time with time zone to the new time zone.
transaction_timestamp() → dateReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
transaction_timestamp() → timestampReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.
transaction_timestamp() → timestamptzReturn the time of the current transaction. The value is based on a timestamp picked when the transaction starts and which stays constant throughout the transaction. This timestamp has no relationship with the commit order of concurrent transactions.

ID Generation Functions

Function → ReturnsDescription
experimental_uuid_v4() → bytesReturn a UUID.
gen_random_uuid() → uuidGenerate a random UUID and return it as a value of the UUID type.
unique_rowid() → int8Return a unique ID used by KWDB to generate unique row IDs if a primary key isn't defined for the table. The value is a combination of the insert timestamp and the ID of the node executing the statement, which guarantees this combination is globally unique.
uuid_v4() → bytesReturn a UUID.

INET Functions

Function → ReturnsDescription
abbrev(val: inet) → stringConvert the combined IP address and prefix length to an abbreviated display format as text. For INET types, this will omit the prefix length if it's not the default (32 for IPv4, 128 for IPv6). For example, abbrev('192.168.1.2/24') returns '192.168.1.2/24'.
broadcast(val: inet) → inetGet the broadcast address for the network address represented by the value. For example, broadcast('192.168.1.2/24') returns '192.168.1.255/24'.
family(val: inet) → int8Extract the IP family of the value. 4 for IPv4, 6 for IPv6. For example, family('::1') returns 6.
host(val: inet) → stringExtract the address part of the combined address/prefixlen value as text. For example, host('192.168.1.2/16') returns '192.168.1.2'.
hostmask(val: inet) → inetCreate an IP host mask corresponding to the prefix length in the value. For example, hostmask('192.168.1.2/16') returns '0.0.255.255'.
masklen(val: inet) → int8Retrieve the prefix length stored in the value. For example, masklen('192.168.1.2/16') returns 16.
netmask(val: inet) → inetCreate an IP network mask corresponding to the prefix length in the value. For example, netmask('192.168.1.2/16') returns '255.255.0.0'.
set_masklen(val: inet, prefixlen: int8) → inetSet the prefix length of val to prefixlen. For example, set_masklen('192.168.1.2', 16) returns '192.168.1.2/16'.
text(val: inet) → stringConvert the combined IP address and prefix length to a format as text.

JSONB Functions

Function → ReturnsDescription
array_to_json(array: anyelement[]) → jsonbReturn the array as JSON or JSONB.
array_to_json(array: anyelement[], pretty_bool: bool) → jsonbReturn the array as JSON or JSONB.
json_array_length(json: jsonb) → int8Return the number of elements in the outermost JSON or JSONB array.
json_build_array(anyelement...) → jsonbBuild a possibly-heterogeneously-typed JSON or JSONB array out of a variadic argument list.
json_build_object(anyelement...) → jsonbBuild a JSON object out of a variadic argument list.
json_extract_path(jsonb, string...) → jsonbReturn the JSON value pointed to by the variadic arguments.
json_object(keys: string[], values: string[]) → jsonbTake keys and values pairwise from two separate arrays. In all other respects it is identical to the one-argument form.
json_object(texts: string[]) → jsonbBuild a JSON or JSONB object out of a text array. The array must have exactly one dimension with an even number of members, in which case they are taken as alternating key/value pairs.
json_remove_path(val: jsonb, path: string[]) → jsonbRemove the specified path from the JSON object.
json_set(val: jsonb, path: string[], to: jsonb) → jsonbReturn the JSON value pointed to by the variadic arguments.
json_set(val: jsonb, path: string[], to: jsonb, create_missing: bool) → jsonbReturn the JSON value pointed to by the variadic arguments. If create_missing is set to false, new keys will not be inserted to objects and values will not be prepended or appended to arrays.
json_strip_nulls(from_json: jsonb) → jsonbReturn from_json with all object fields that have null values omitted. Other null values are unaffected.
json_typeof(val: jsonb) → stringReturn the type of the outermost JSON value as a text string.
jsonb_array_length(json: jsonb) → int8Return the number of elements in the outermost JSON or JSONB array.
jsonb_build_array(anyelement...) → jsonbBuild a possibly-heterogeneously-typed JSON or JSONB array out of a variadic argument list.
jsonb_build_object(anyelement...) → jsonbBuild a JSON object out of a variadic argument list.
jsonb_extract_path(jsonb, string...) → jsonbReturn the JSON value pointed to by the variadic arguments.
jsonb_insert(target: jsonb, path: string[], new_val: jsonb) → jsonbReturn the JSON value pointed to by the variadic arguments. new_val will be inserted before the path target.
jsonb_insert(target: jsonb, path: string[], new_val: jsonb, insert_after: bool) → jsonbReturn the JSON value pointed to by the variadic arguments. If insert_after is set to true (default is false), new_val will be inserted after the path target.
jsonb_object(keys: string[], values: string[]) → jsonbTake keys and values pairwise from two separate arrays. In all other respects it is identical to the one-argument form.
jsonb_object(texts: string[]) → jsonbBuild a JSON or JSONB object out of a text array. The array must have exactly one dimension with an even number of members, in which case they are taken as alternating key/value pairs.
jsonb_pretty(val: jsonb) → stringReturn the given JSON value as a STRING indented and with newlines.
jsonb_set(val: jsonb, path: string[], to: jsonb) → jsonbReturn the JSON value pointed to by the variadic arguments.
jsonb_set(val: jsonb, path: string[], to: jsonb, create_missing: bool) → jsonbReturn the JSON value pointed to by the variadic arguments. If create_missing is set to false, new keys will not be inserted to objects and values will not be prepended or appended to arrays.
jsonb_strip_nulls(from_json: jsonb) → jsonbReturn from_json with all object fields that have null values omitted. Other null values are unaffected.
jsonb_typeof(val: jsonb) → stringReturn the type of the outermost JSON value as a text string.
to_json(val: anyelement) → jsonbReturn the value as JSON or JSONB.
to_jsonb(val: anyelement) → jsonbReturn the value as JSON or JSONB.

FLOAT and INT Functions

Function → ReturnsDescription
abs(val: decimal) → decimalCalculate the absolute value of val.
abs(val: float4) → float4Calculate the absolute value of val.
abs(val: float8) → float8Calculate the absolute value of val.
abs(val: int2) → int2Calculate the absolute value of val.
abs(val: int4) → int4Calculate the absolute value of val.
abs(val: int8) → int8Calculate the absolute value of val.
acos(val: float4) → float8Calculate the inverse cosine of val.
acos(val: float8) → float8Calculate the inverse cosine of val.
asin(val: float4) → float8Calculate the inverse sine of val.
asin(val: float8) → float8Calculate the inverse sine of val.
atan(val: float4) → float8Calculate the inverse tangent of val.
atan(val: float8) → float8Calculate the inverse tangent of val.
atan2(x: float4, y: float4) → float8Calculate the inverse tangent of x/y.
atan2(x: float4, y: float8) → float8Calculate the inverse tangent of x/y.
atan2(x: float8, y: float4) → float8Calculate the inverse tangent of x/y.
atan2(x: float8, y: float8) → float8Calculate the inverse tangent of x/y.
cbrt(val: decimal) → decimalCalculate the cube root (∛) of val.
cbrt(val: float4) → float8Calculate the cube root (∛) of val.
cbrt(val: float8) → float8Calculate the cube root (∛) of val.
ceil(val: decimal) → decimalCalculate the smallest integer not smaller than val.
ceil(val: float4) → float8Calculate the smallest integer not smaller than val.
ceil(val: float8) → float8Calculate the smallest integer not smaller than val.
ceil(val: int2) → float8Calculate the smallest integer not smaller than val.
ceil(val: int4) → float8Calculate the smallest integer not smaller than val.
ceil(val: int8) → float8Calculate the smallest integer not smaller than val.
ceiling(val: decimal) → decimalCalculate the smallest integer not smaller than val.
ceiling(val: float4) → float8Calculate the smallest integer not smaller than val.
ceiling(val: float8) → float8Calculate the smallest integer not smaller than val.
ceiling(val: int2) → float8Calculate the smallest integer not smaller than val.
ceiling(val: int4) → float8Calculate the smallest integer not smaller than val.
ceiling(val: int8) → float8Calculate the smallest integer not smaller than val.
cos(val: float4) → float8Calculate the cosine of val.
cos(val: float8) → float8Calculate the cosine of val.
cot(val: float4) → float8Calculate the cotangent of val.
cot(val: float8) → float8Calculate the cotangent of val.
crc32c(bytes...) → int8Calculate the CRC-32 hash using the Castagnoli polynomial.
crc32c(string...) → int8Calculate the CRC-32 hash using the Castagnoli polynomial.
crc32ieee(bytes...) → int8Calculate the CRC-32 hash using the IEEE polynomial.
crc32ieee(string...) → int8Calculate the CRC-32 hash using the IEEE polynomial.
degrees(val: float4) → float8Convert val as a radian value to a degree value.
degrees(val: float8) → float8Convert val as a radian value to a degree value.
div(x: decimal, y: decimal) → decimalCalculate the integer quotient of x/y.
div(x: float4, y: float4) → float8Calculate the integer quotient of x/y.
div(x: float4, y: float8) → float8Calculate the integer quotient of x/y.
div(x: float8, y: float4) → float8Calculate the integer quotient of x/y.
div(x: float8, y: float8) → float8Calculate the integer quotient of x/y.
div(x: int2, y: int2) → int8Calculate the integer quotient of x/y.
div(x: int2, y: int4) → int8Calculate the integer quotient of x/y.
div(x: int2, y: int8) → int8Calculate the integer quotient of x/y.
div(x: int4, y: int2) → int8Calculate the integer quotient of x/y.
div(x: int4, y: int4) → int8Calculate the integer quotient of x/y.
div(x: int4, y: int8) → int8Calculate the integer quotient of x/y.
div(x: int8, y: int2) → int8Calculate the integer quotient of x/y.
div(x: int8, y: int4) → int8Calculate the integer quotient of x/y.
div(x: int8, y: int8) → int8Calculate the integer quotient of x/y.
exp(val: decimal) → decimalCalculate e ^ val.
exp(val: float4) → float8Calculate e ^ val.
exp(val: float8) → float8Calculate e ^ val.
floor(val: decimal) → decimalCalculate the largest integer not greater than val.
floor(val: float4) → float8Calculate the largest integer not greater than val.
floor(val: float8) → float8Calculate the largest integer not greater than val.
floor(val: int2) → float8Calculate the largest integer not greater than val.
floor(val: int4) → float8Calculate the largest integer not greater than val.
floor(val: int8) → float8Calculate the largest integer not greater than val.
fnv32(bytes...) → int8Calculate the 32-bit FNV-1 hash value of a set of values.
fnv32(string...) → int8Calculate the 32-bit FNV-1 hash value of a set of values.
fnv32a(bytes...) → int8Calculate the 32-bit FNV-1a hash value of a set of values.
fnv32a(string...) → int8Calculate the 32-bit FNV-1a hash value of a set of values.
fnv64(bytes...) → int8Calculate the 64-bit FNV-1 hash value of a set of values.
fnv64(string...) → int8Calculate the 64-bit FNV-1 hash value of a set of values.
fnv64a(bytes...) → int8Calculate the 64-bit FNV-1a hash value of a set of values.
fnv64a(string...) → int8Calculate the 64-bit FNV-1a hash value of a set of values.
isnan(val: decimal) → boolReturn true if val is NaN. Otherwise, return false.
isnan(val: float4) → boolReturn true if val is NaN. Otherwise, return false.
isnan(val: float8) → boolReturn true if val is NaN. Otherwise, return false.
ln(val: decimal) → decimalCalculate the natural log of val.
ln(val: float4) → float8Calculate the natural log of val.
ln(val: float8) → float8Calculate the natural log of val.
log(b: decimal, x: decimal) → decimalCalculate the base b log of val.
log(b: float4, x: float4) → float8Calculate the base b log of val.
log(b: float4, x: float8) → float8Calculate the base b log of val.
log(b: float8, x: float4) → float8Calculate the base b log of val.
log(b: float8, x: float8) → float8Calculate the base b log of val.
log(val: decimal) → decimalCalculate the base 10 log of val.
log(val: float4) → float8Calculate the base 10 log of val.
log(val: float8) → float8Calculate the base 10 log of val.
mod(x: decimal, y: decimal) → decimalCalculate x%y.
mod(x: float4, y: float4) → float8Calculate x%y.
mod(x: float4, y: float8) → float8Calculate x%y.
mod(x: float8, y: float4) → float8Calculate x%y.
mod(x: float8, y: float8) → float8Calculate x%y.
mod(x: int2, y: int2) → int8Calculate x%y.
mod(x: int2, y: int4) → int8Calculate x%y.
mod(x: int2, y: int8) → int8Calculate x%y.
mod(x: int4, y: int2) → int8Calculate x%y.
mod(x: int4, y: int4) → int8Calculate x%y.
mod(x: int4, y: int8) → int8Calculate x%y.
mod(x: int8, y: int2) → int8Calculate x%y.
mod(x: int8, y: int4) → int8Calculate x%y.
mod(x: int8, y: int8) → int8Calculate x%y.
pi() → float8Return the value for pi (3.141592653589793).
pow(x: decimal, y: decimal) → decimalCalculate x^y.
pow(x: float4, y: float4) → float8Calculate x^y.
pow(x: float4, y: float8) → float8Calculate x^y.
pow(x: float8, y: float4) → float8Calculate x^y.
pow(x: float8, y: float8) → float8Calculate x^y.
pow(x: int2, y: int2) → int8Calculate x^y.
pow(x: int2, y: int4) → int8Calculate x^y.
pow(x: int2, y: int8) → int8Calculate x^y.
pow(x: int4, y: int2) → int8Calculate x^y.
pow(x: int4, y: int4) → int8Calculate x^y.
pow(x: int4, y: int8) → int8Calculate x^y.
pow(x: int8, y: int2) → int8Calculate x^y.
pow(x: int8, y: int4) → int8Calculate x^y.
pow(x: int8, y: int8) → int8Calculate x^y.
power(x: decimal, y: decimal) → decimalCalculate x^y.
power(x: float4, y: float4) → float8Calculate x^y.
power(x: float4, y: float8) → float8Calculate x^y.
power(x: float8, y: float4) → float8Calculate x^y.
power(x: float8, y: float8) → float8Calculate x^y.
power(x: int2, y: int2) → int8Calculate x^y.
power(x: int2, y: int4) → int8Calculate x^y.
power(x: int2, y: int8) → int8Calculate x^y.
power(x: int4, y: int2) → int8Calculate x^y.
power(x: int4, y: int4) → int8Calculate x^y.
power(x: int4, y: int8) → int8Calculate x^y.
power(x: int8, y: int2) → int8Calculate x^y.
power(x: int8, y: int4) → int8Calculate x^y.
power(x: int8, y: int8) → int8Calculate x^y.
radians(val: float4) → float8Convert val as a degree value to a radian value.
radians(val: float8) → float8Convert val as a degree value to a radian value.
random() → float8Return a random floating-point number between 0 (inclusive) and 1 (exclusive).
round(input: decimal, decimal_accuracy: int8) → decimalKeep decimal_accuracy number of figures to the right of the zero position in input using half away from zero rounding. If decimal_accuracy is not in the range -2^31…(2^31-1), the results are undefined.
round(input: float4, decimal_accuracy: int8) → float8Keep decimal_accuracy number of figures to the right of the zero position in input using half away from zero rounding.
round(input: float8, decimal_accuracy: int8) → float8Keep decimal_accuracy number of figures to the right of the zero position in input using half away from zero rounding.
round(val: decimal) → decimalRound val to the nearest integer, half away from zero: round(+/-2.4) = +/-2, round(+/-2.5) = +/-3.
round(val: float4) → float8Round val to the nearest integer using half to even (banker's) rounding.
round(val: float8) → float8Round val to the nearest integer using half to even (banker's) rounding.
sign(val: decimal) → decimalDetermine the sign of val.
- 1: positive
- 0: 0
- -1: negative
sign(val: float4) → float8Determine the sign of val.
- 1: positive
- 0: 0
- -1: negative
sign(val: float8) → float8Determine the sign of val.
- 1: positive
- 0: 0
- -1: negative
sign(val: int2) → int8Determine the sign of val.
- 1: positive
- 0: 0
- -1: negative
sign(val: int4) → int8Determine the sign of val.
- 1: positive
- 0: 0
- -1: negative
sign(val: int8) → int8Determine the sign of val.
- 1: positive
- 0: 0
- -1: negative
sin(val: float4) → float8Calculate the sine of val.
sin(val: float8) → float8Calculate the sine of val.
sqrt(val: decimal) → decimalCalculate the square root of val.
sqrt(val: float4) → float8Calculate the square root of val.
sqrt(val: float8) → float8Calculate the square root of val.
tan(val: float4) → float8Calculate the tangent of val.
tan(val: float8) → float8Calculate the tangent of val.
trunc(val: decimal) → decimalTruncate the decimal values of val.
trunc(val: float4) → float8Truncate the decimal values of val.
trunc(val: float8) → float8Truncate the decimal values of val.
width_bucket(operand: decimal, b1: decimal, b2: decimal, count: int8) → int8Return the bucket number to which operand would be assigned in a histogram having count equal-width buckets spanning the range B1 to B2.
width_bucket(operand: int8, b1: int2, b2: int2, count: int8) → int8Return the bucket number to which operand would be assigned in a histogram having count equal-width buckets spanning the range B1 to B2.
width_bucket(operand: int8, b1: int2, b2: int4, count: int8) → int8Return the bucket number to which operand would be assigned in a histogram having count equal-width buckets spanning the range B1 to B2.
width_bucket(operand: int8, b1: int2, b2: int8, count: int8) → int8Return the bucket number to which operand would be assigned in a histogram having count equal-width buckets spanning the range B1 to B2.
width_bucket(operand: int8, b1: int4, b2: int2, count: int8) → int8Return the bucket number to which operand would be assigned in a histogram having count equal-width buckets spanning the range B1 to B2.
width_bucket(operand: int8, b1: int4, b2: int4, count: int8) → int8Return the bucket number to which operand would be assigned in a histogram having count equal-width buckets spanning the range B1 to B2.
width_bucket(operand: int8, b1: int4, b2: int8, count: int8) → int8Return the bucket number to which operand would be assigned in a histogram having count equal-width buckets spanning the range B1 to B2.
width_bucket(operand: int8, b1: int8, b2: int2, count: int8) → int8Return the bucket number to which operand would be assigned in a histogram having count equal-width buckets spanning the range B1 to B2.
width_bucket(operand: int8, b1: int8, b2: int4, count: int8) → int8Return the bucket number to which operand would be assigned in a histogram having count equal-width buckets spanning the range B1 to B2.
width_bucket(operand: int8, b1: int8, b2: int8, count: int8) → int8Return the bucket number to which operand would be assigned in a histogram having count equal-width buckets spanning the range B1 to B2.
width_bucket(operand: anyelement, thresholds: anyelement[]) → int8Return the bucket number to which operand would be assigned given an array listing the lower bounds of the buckets. Return 0 for an input less than the first lower bound. The thresholds array must be sorted, smallest first, or unexpected results will be obtained.

Sequence Functions

Function → ReturnsDescription
currval(sequence_name: string) → int8Return the latest value obtained with nextval for this sequence in this session.
lastval() → int8Return value most recently obtained with nextval in this session.
nextval(sequence_name: string) → int8Advance the given sequence and return its new value.
setval(sequence_name: string, value: int8) → int8Set the given sequence’s current value. The next call to nextval will return value + Increment.
setval(sequence_name: string, value: int8, is_called: bool) → int8Set the given sequence’s current value. If is_called is set to false, the next call to nextval will return value. Otherwise, return value + Increment.

Set-Returning Functions

Function → ReturnsDescription
aclexplode(aclitems: string[]) → tuple{oid AS grantor, oid AS grantee, string AS privilege_type, bool AS is_grantable}Generate a virtual table containing aclitem stuff.
kwdb_internal.testing_callback(name: string) → int8Callback the callback function identified by name. It is only for internal test.
kwdb_internal.unary_table() → tupleGenerate a virtual table containing no values. It is only for internal test.
generate_series(start: int8, end: int8) → int8Generate a virtual table containing the integer values from start to end.
generate_series(start: int8, end: int8, step: int8) → int8Generate a virtual table containing the integer values from start to end, by increment of step.
generate_series(start: timestamp, end: timestamp, step: interval) → timestampGenerate a virtual table containing the timestamp values from start to end, by increment of step.
generate_subscripts(array: anyelement[]) → int8Return a series comprising the given array’s subscripts.
generate_subscripts(array: anyelement[], dim: int8) → int8Return a series comprising the given array’s subscripts.
generate_subscripts(array: anyelement[], dim: int8, reverse: bool) → int8Return a series comprising the given array’s subscripts. When reverse is set to true, the series is returned in reverse order.
information_schema._pg_expandarray(input: anyelement[]) → anyelementReturn the input array as a set of rows with an index.
json_array_elements(input: jsonb) → jsonbExpand a JSON array to a set of JSON values.
json_array_elements_text(input: jsonb) → stringExpand a JSON array to a set of text values.
json_each(input: jsonb) → tuple{string AS key, jsonb AS value}Expand the outermost JSON or JSONB object into a set of key/value pairs.
json_each_text(input: jsonb) → tuple{string AS key, string AS value}Expand the outermost JSON or JSONB object into a set of key/value pairs. The returned values will be of the text type.
json_object_keys(input: jsonb) → stringReturn sorted set of keys in the outermost JSON object.
jsonb_array_elements(input: jsonb) → jsonbExpand a JSON array to a set of JSON values.
jsonb_array_elements_text(input: jsonb) → stringExpand a JSON array to a set of text values.
jsonb_each(input: jsonb) → tuple{string AS key, jsonb AS value}Expand the outermost JSON or JSONB object into a set of key/value pairs.
jsonb_each_text(input: jsonb) → tuple{string AS key, string AS value}Expand the outermost JSON or JSONB object into a set of key/value pairs. The returned values will be of the text type.
jsonb_object_keys(input: jsonb) → stringReturn sorted set of keys in the outermost JSON object.
pg_get_keywords() → tuple{string AS word, string AS catcode, string AS catdesc}Generate a virtual table containing the keywords known to the SQL parser.
unnest(anyelement[], anyelement[], anyelement[]...) → tuple{anyelement AS unnest, anyelement AS unnest, anyelement AS unnest}Return the input array as a set of rows.
unnest(input: anyelement[]) → anyelementReturn the input array as a set of rows.

String and Byte Functions

Function → ReturnsDescription
ascii(val: string) → int8Return the character code of the first character in val. Despite the name, the function supports Unicode too.
bit_length(val: bytes) → int8Calculate the number of bits used to represent val.
bit_length(val: string) → int8Calculate the number of bits used to represent val.
bit_length(val: varbit) → int8Calculate the number of bits used to represent val.
btrim(input: string, trim_chars: string) → stringRemove any characters included in trim_chars from the beginning or end of input (applies recursively). For example, btrim('doggie', 'eod') returns ggi.
btrim(val: string) → stringRemove all spaces from the beginning and end of val.
char_length(val: bytes) → int8Calculate the number of bytes in val.
char_length(val: string) → int8Calculate the number of characters in val.
character_length(val: bytes) → int8Calculate the number of bytes in val.
character_length(val: string) → int8Calculate the number of characters in val.
chr(val: int2) → stringReturn the character with the code given in val. Inverse function of ascii().
chr(val: int4) → stringReturn the character with the code given in val. Inverse function of ascii().
chr(val: int8) → stringReturn the character with the code given in val. Inverse function of ascii().
concat(string...) → stringConcatenate a comma-separated list of strings.
concat_ws(string...) → stringUse the first argument as a separator between the concatenation of the subsequent arguments. For example, concat_ws('!','wow','great') returns wow!great.
convert_from(str: bytes, enc: string) → stringDecode the bytes in str into a string using encoding enc. Support UTF8 and LATIN1 encodings.
convert_to(str: string, enc: string) → bytesEncode the string in str as a byte array using encoding enc. Support UTF8 and LATIN1 encodings.
decode(text: string, format: string) → bytesDecode data using format (hex or escape).
encode(data: bytes, format: string) → stringEncode data using format (hex or escape).
from_ip(val: bytes) → stringConvert the byte string representation of an IP address to its character string representation.
from_uuid(val: bytes) → stringConvert the byte string representation of a UUID to its character string representation.
get_bit(bit_string: varbit, index: int8) → int8Extract a bit at given index in the bit array.
get_bit(byte_string: bytes, index: int8) → int8Extract a bit at given index in the byte array.
initcap(val: string) → stringCapitalize the first letter of val.
left(input: bytes, return_set: int8) → bytesReturn the first return_set bytes from input.
left(input: string, return_set: int8) → stringReturn the first return_set characters from input.
length(val: bytes) → int8Calculate the number of bytes in val.
length(val: string) → int8Calculate the number of characters in val.
length(val: varbit) → int8Calculate the number of characters in val.
lower(val: string) → stringConvert all characters in val to their lower-case equivalents.
lpad(string: string, length: int8) → stringPad string to by adding the double quotation mark ("") to the left of string. If string is longer than length, it is truncated.
lpad(string: string, length: int8, fill: string) → stringPad string to by adding fill to the left of string. If string is longer than length, it is truncated.
ltrim(input: string, trim_chars: string) → stringRemove any characters included in trim_chars from the beginning (left-hand side) of input (applies recursively). For example, ltrim('doggie', 'od') returns ggie.
ltrim(val: string) → stringRemove all spaces from the beginning (left-hand side) of val.
md5(bytes...) → stringCalculate the MD5 hash value of a set of values.
md5(string...) → stringCalculate the MD5 hash value of a set of values.
octet_length(val: bytes) → int8Calculate the number of bytes in val.
octet_length(val: string) → int8Calculate the number of bytes used to represent val.
octet_length(val: varbit) → int8Calculate the number of bits used to represent val.
overlay(input:string,overlay_val: string, start_pos: int8) → stringReplace characters in input with overlay_val starting at start_pos (begins at 1). For example, overlay('doggie', 'CAT', 2) returns dCATie.
overlay(input:string,overlay_val: string, start_pos: int8, end_pos: int8) → stringDelete the characters in input between start_pos and end_pos (count starts at 1), and then insert overlay_val at start_pos.
pg_collation_for(str: anyelement) → stringReturn the collation of the argument.
quote_ident(val: string) → stringReturn val suitably quoted to serve as identifier in a SQL statement.
quote_literal(val: string) → stringReturn val suitably quoted to serve as string literal in a SQL statement.
quote_literal(val: anyelement) → stringCoerce val to a string and then quote it as a literal.
quote_nullable(val: string) → stringCoerce val to a string and then quote it as a literal. If val is NULL, return NULL.
quote_nullable(val: anyelement) → stringCoerce val to a string and then quote it as a literal. If val is NULL, return NULL.
regexp_extract(input: string, regex: string) → stringReturn the first match for the Regular Expression regex in input.
regexp_replace(input: string, regex: string, replace: string) → stringReplace matches for the Regular Expression regex in input with the Regular Expression replace.
regexp_replace(input:string, regex: string, replace: string, flags: string) → stringReplace matches for the Regular Expression regex in input with the Regular Expression replace using flags. KWDB supports the following flags:
- -c: Case-sensitive matching
- -g: Global matching (match each substring instead of only the first)
- -i: Case-insensitive matching
- -m/n: Newline-sensitive (. and ... match newlines: no; \^ and $ match line boundaries: yes)
- -p: Partial newline-sensitive matching (. and ... match newlines: no; \^ and $ match line boundaries: yes)
- -s: Newline-insensitive (default) (. and ... match newlines: no; \^ and $ match line boundaries: yes)
- -w: Inverse partial newline-sensitive matching (. and ... match newlines: no; \^ and $ match line boundaries: yes)
repeat(input: string, repeat_counter: int8) → stringConcatenate input repeat_counter number of times. For example, repeat('dog', 2) returns dogdog.
replace(input: string, find: string, replace: string) → stringReplace find with replace in input.
reverse(val: string) → stringReverse the order of the string’s characters.
right(input: bytes, return_set: int8) → bytesReturn the last return_set bytes from input.
right(input: string, return_set: int8) → stringReturn the last return_set character from input.
rpad(string: string, length: int8) → stringPad string to by adding the double quotation mark ("") to the right of string. If string is longer than length, it is truncated.
rpad(string: string, length: int8, fill: string) → stringPad string to by adding fill to the right of string. If string is longer than length, it is truncated.
rtrim(input: string, trim_chars: string) → stringRemove any characters included in trim_chars from the end (right-hand side) of input (applies recursively). For example, ltrim('doggie', 'od') returns ggie.
rtrim(val: string) → stringRemove all spaces from the end (right-hand side) of val.
set_bit(bit_string: varbit, index: int8, to_set: int8) → varbitSet a bit at given index in the bit array.
set_bit(byte_string: bytes, index: int8, to_set: int8) → bytesSet a bit at given index in the byte array.
sha1(bytes...) → stringCalculate the SHA1 hash value of a set of values.
sha1(string...) → stringCalculate the SHA1 hash value of a set of values.
sha256(bytes...) → stringCalculate the SHA256 hash value of a set of values.
sha256(string...) → stringCalculate the SHA256 hash value of a set of values.
sha512(bytes...) → stringCalculate the SHA512 hash value of a set of values.
sha512(string...) → stringCalculate the SHA512 hash value of a set of values.
split_part(input: string, delimiter: string, return_index_pos: int8) → stringSplit input on delimiter and return the value in the return_index_pos position (starting at 1). For example, split_part('123.456.789.0','.',3) returns 789.
strpos(input: string, find: string) → int8Calculate the position where the string find begins in input. For example, strpos('doggie', 'gie') returns 4.
substr(input: string, regex: string) → stringReturn a substring of input that matches the Regular Expression regex.
substr(input: string, regex: string, escape_char: string) → stringReturn a substring of input that matches the Regular Expression regex using escape_char as your escape character instead of </code>.
substr(input: string, start_pos: int8) → stringReturn a substring of input between sstart_pos and end_pos (count starts at 1).
substr(input: string, start_pos: int8, length: int8) → stringReturn a substring of input starting at substart_pos (count starts at 1).
substring(input: string, regex: string) → stringReturn a substring of input that matches the Regular Expression regex.
substring(input: string, regex: string, escape_char: string) → stringReturn a substring of input that matches the Regular Expression regex using escape_char as your escape character instead of </code>.
substring(input: string, start_pos: int8) → stringReturn a substring of input between sstart_pos and end_pos (count starts at 1).
substring(input: string, start_pos: int8, length: int8) → stringReturn a substring of input starting at substart_pos (count starts at 1).
to_english(val: int8) → stringRepresent the value of its argument using English cardinals.
to_hex(val: bytes) → stringConvert val to its hexadecimal representation.
to_hex(val: int8) → stringConvert val to its hexadecimal representation.
to_hex(val: string) → stringConvert val to its hexadecimal representation.
to_ip(val: string) → bytesConvert the character string representation of an IP address to its byte string representation.
to_uuid(val: string) → bytesConvert the character string representation of a UUID to its byte string representation.
translate(input: string, find: string, replace: string) → stringIn input, replace the first character from find with the first character in replace. Repeat the operation for each character in find. For example, translate('doggie', 'dog', '123'); returns 1233ie.
upper(val: string) → stringConvert all characters in val to their upper-case equivalents.

System Information Functions

Function → ReturnsDescription
kwdb_internal.encode_key(table_id: int8, index_id: int8, row_tuple: tuple) → bytesGenerate a key for a row of a specific table and index.
kwdb_internal.force_assertion_error(msg: string) → int8It is only for internal test.
kwdb_internal.force_error(errorCode: string, msg: string) → int8It is only for internal test.
kwdb_internal.force_log_fatal(msg: string) → int8It is only for internal test.
kwdb_internal.force_panic(msg: string) → int8It is only for internal test.
kwdb_internal.force_retry(val: interval) → int8It is only for internal test.
kwdb_internal.get_namespace_id(parent_id: int8, name: string) → int8Get the namespace ID.
kwdb_internal.get_zone_config(namespace_id: int8) → bytesGet the zone configurations.
kwdb_internal.is_admin() → boolGet the Admin status of the current user.
kwdb_internal.lease_holder(key: bytes) → int8Get the lease holder that matches the request key.
kwdb_internal.locality_value(key: string) → stringReturn the value for a key used for specifying a position.
kwdb_internal.no_constant_folding(input: anyelement) → anyelementIt is only for internal test.
kwdb_internal.node_executable_version() → stringReturn the version of the running KWDB node.
kwdb_internal.notice(msg: string) → int8It is only for internal test.
kwdb_internal.num_inverted_index_entries(val: anyelement[]) → int8It is only for internal test.
kwdb_internal.num_inverted_index_entries(val: jsonb) → int8It is only for internal test.
kwdb_internal.pretty_key(raw_key: bytes, skip_fields: int8) → stringIt is only for internal test.
kwdb_internal.range_stats(key: bytes) → jsonbRetrieve range statistics as the JSON objects .
kwdb_internal.round_decimal_values(val: decimal, scale: int8) → decimal(Internal use) Round the value of a decimal value during a mutation.
kwdb_internal.round_decimal_values(val: decimal[], scale: int8) → decimal[](Internal use) Round the value of a hexadecimal value during a mutation.
kwdb_internal.set_vmodule(vmodule_string: string) → int8Set the equivalent of the --vmodule flag at the gateway node which processes the request. It can control the level of logging details for different files. Syntax example: kwdb_internal.set_vmodule('recordio = 2,file = 1,gfs * = 3'). Reset to kwdb_internal.set_vmodule(''). Improving the level of logging details may cause significant performance degradation.
current_database() → stringReturn the current database.
current_schema() → stringReturn the current schema.
current_schemas(include_pg_catalog: bool) → string[]Return the valid schemas in the search path.
current_user() → stringReturn the current user. This function is compatible with PostgreSQL.
version() → stringReturn the version of the KWDB node.
row_count()Return the number of the rows modified by the DML statement. Support the INSERT, UPDATE, and DELETE statements without the RETURNING clause.
Note
- Except for the INSERT, UPDATE, and DELETE statements, other DML statements have no effection on this function. When this function follows other DML statements, the system returns 0 if no related DML statement was executed before. Otherwise, the system returns the number of rows affected by the last DML statement.
- This function is non-transactional.

Time Functions

Function → ReturnsDescription
current_time() → timeReturn the current transaction’s time with no time zone.
current_time() → timetzReturn the current transaction’s time with time zone.
current_time(precision: INT8) → timeReturn the current transaction’s time with no time zone.
current_time(precision: INT8) → timetzReturn the current transaction’s time with time zone.
localtime() → timeReturn the current transaction’s time with no time zone.
localtime() → timetzReturn the current transaction’s time with time zone.
localtime(precision: INT8) → timeReturn the current transaction’s time with no time zone.
localtime(precision: INT8) → timetzReturn the current transaction’s time with time zone.

Tuple Functions

Function → ReturnsDescription
row_to_JSON(row: tuple) → jsonbReturn the row as a JSON object.

Compatibility Functions

Function → ReturnsDescription
format_type(type_oid: oid, typemod: INT8) → STRINGReturn the SQL name of a data type that is identified by its type OID and possibly a type modifier. Currently, the type modifier is ignored.
getdatabaseencoding() → STRINGReturn the current encoding name used by the database.
has_any_column_privilege(table:STRING, privilege: STRING) → BOOLReturn whether or not the current user has privileges for any column of the table.
has_any_column_privilege(table: oid, privilege: STRING) → BOOLReturn whether or not the current user has privileges for any column of the table.
has_any_column_privilege(user: STRING, table: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for any column of the table.
has_any_column_privilege(user: STRING, table: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for any column of the table.
has_any_column_privilege(user: oid, table: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for any column of the table.
has_any_column_privilege(user: oid, table: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for any column of the table.
has_column_privilege(table: STRING, column: INT8, privilege: STRING) → BOOLReturn whether or not the current user has privileges for a column.
has_column_privilege(table: STRING, column: STRING, privilege: STRING) → BOOLReturn whether or not the current user has privileges for a column.
has_column_privilege(table: oid, column: INT8, privilege: STRING) → BOOLReturn whether or not the current user has privileges for a column.
has_column_privilege(table: oid, column: STRING, privilege: STRING) → BOOLReturn whether or not the current user has privileges for a column.
has_column_privilege(user: STRING, table: STRING, column: INT8, privilege: STRING) → BOOLReturn whether or not the user has privileges for a column.
has_column_privilege(user: STRING, table: STRING, column: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for a column.
has_column_privilege(user: STRING, table: oid, column: INT8, privilege: STRING) → BOOLReturn whether or not the user has privileges for a column.
has_column_privilege(user: STRING, table: oid, column: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for a column.
has_column_privilege(user: oid, table: STRING, column: INT8, privilege: STRING) → BOOLReturn whether or not the user has privileges for a column.
has_column_privilege(user: oid, table: STRING, column: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for a column.
has_column_privilege(user: oid, table: oid, column: INT8, privilege: STRING) → BOOLReturn whether or not the user has privileges for a column.
has_column_privilege(user: oid,table:oid, column: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for a column.
has_database_privilege(database:STRING, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the database.
has_database_privilege(database: oid, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the database.
has_database_privilege(user: STRING, database: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the database.
has_database_privilege(user: STRING, database: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the database.
has_database_privilege(user: oid, database: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the database.
has_database_privilege(user: oid, database: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the database.
has_foreign_data_wrapper_privilege(fdw: STRING, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the foreign-data wrapper.
has_foreign_data_wrapper_privilege(fdw: oid, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the foreign-data wrapper.
has_foreign_data_wrapper_privilege(user: STRING, fdw: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the foreign-data wrapper.
has_foreign_data_wrapper_privilege(user: STRING, fdw: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the foreign-data wrapper.
has_foreign_data_wrapper_privilege(user: oid, fdw: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the foreign-data wrapper.
has_foreign_data_wrapper_privilege(user: oid, fdw: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the foreign-data wrapper.
has_function_privilege(function: STRING, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the function.
has_function_privilege(function: oid, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the function.
has_function_privilege(user: STRING, function: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the function.
has_function_privilege(user: STRING, function: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the function.
has_function_privilege(user: oid, function: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the function.
has_function_privilege(user: oid, function: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the function.
has_language_privilege(language: STRING, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the language.
has_language_privilege(language: oid, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the language.
has_language_privilege(user: STRING, language: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the language.
has_language_privilege(user: STRING, language: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the language.
has_language_privilege(user: oid, language: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the language.
has_language_privilege(user: oid, language: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the language.
has_schema_privilege(schema: STRING, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the schema.
has_schema_privilege(schema: oid, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the schema.
has_schema_privilege(user: STRING, schema: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the schema.
has_schema_privilege(user: STRING, schema: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the schema.
has_schema_privilege(user: oid, schema: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the schema.
has_schema_privilege(user: oid, schema: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the schema.
has_sequence_privilege(sequence: STRING, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the sequence.
has_sequence_privilege(sequence: oid, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the sequence.
has_sequence_privilege(user: STRING, sequence: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the sequence.
has_sequence_privilege(user: STRING, sequence: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the sequence.
has_sequence_privilege(user: oid, sequence: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the sequence.
has_sequence_privilege(user: oid, sequence: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the sequence.
has_server_privilege(server: STRING, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the foreign server.
has_server_privilege(server: oid, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the foreign server.
has_server_privilege(user: STRING, server: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the foreign server.
has_server_privilege(user: STRING, server: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the foreign server.
has_server_privilege(user: oid, server: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the foreign server.
has_server_privilege(user: oid, server: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the foreign server.
has_table_privilege(table: STRING, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the table.
has_table_privilege(table: oid, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the table.
has_table_privilege(user:STRING,table:STRING,privilege: STRING) → BOOLReturn whether or not the user has privileges for the table.
has_table_privilege(user: STRING, table: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the table.
has_table_privilege(user: oid, table: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the table.
has_table_privilege(user: oid, table: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the table.
has_tablespace_privilege(tablespace:STRING,privilege: STRING) → BOOLReturn whether or not the current user has privileges for the tablespace.
has_tablespace_privilege(tablespace: oid, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the tablespace.
has_tablespace_privilege(user: STRING, tablespace: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the tablespace.
has_tablespace_privilege(user: STRING, tablespace: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the tablespace.
has_tablespace_privilege(user: oid, tablespace: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the tablespace.
has_tablespace_privilege(user: oid, tablespace: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the tablespace.
has_type_privilege(type: STRING, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the type.
has_type_privilege(type: oid, privilege: STRING) → BOOLReturn whether or not the current user has privileges for the type.
has_type_privilege(user:STRING,type: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the type.
has_type_privilege(user: STRING, type: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the type.
has_type_privilege(user: oid, type: STRING, privilege: STRING) → BOOLReturn whether or not the user has privileges for the type.
has_type_privilege(user: oid, type: oid, privilege: STRING) → BOOLReturn whether or not the user has privileges for the type.
oid(arg1: INT2) → oidConvert an integer to an OID.
oid(arg1: INT4) → oidConvert an integer to an OID.
oid(arg1: INT8) → oidConvert an integer to an OID.
pg_sleep(seconds: FLOAT4) → BOOLMake the current session's process sleep until specified seconds have elapsed. seconds is a value of double precision, so fractional-second delays can be specified.
pg_sleep(seconds: FLOAT8) → BOOLMake the current session's process sleep until specified seconds have elapsed. seconds is a value of double precision, so fractional-second delays can be specified.

Aggregate Functions

Note

  • Avoid the calculation results of the AVG and SUM functions exceeding the maximum range supported by the function.
  • When aggregate queries work with GROUP BY, avoid excessive rows in the result set for the GROUP BY clause.
Function → ReturnsDescription
array_agg(arg1: BOOL) → BOOL[]Aggregate the selected values into an array.
array_agg(arg1: bytes) → bytes[]Aggregate the selected values into an array.
array_agg(arg1: date) → date[]Aggregate the selected values into an array.
array_agg(arg1: decimal) →decimal[]Aggregate the selected values into an array.
array_agg(arg1: FLOAT4) → FLOAT4[]Aggregate the selected values into an array.
array_agg(arg1: FLOAT8) → FLOAT8[]Aggregate the selected values into an array.
array_agg(arg1: INET) → INET[]Aggregate the selected values into an array.
array_agg(arg1: INT2) → INT2[]Aggregate the selected values into an array.
array_agg(arg1: INT4) → INT4[]Aggregate the selected values into an array.
array_agg(arg1: INT8) → INT8[]Aggregate the selected values into an array.
array_agg(arg1: interval) → interval[]Aggregate the selected values into an array.
array_agg(arg1: STRING) → STRING[]Aggregate the selected values into an array.
array_agg(arg1: time) → time[]Aggregate the selected values into an array.
array_agg(arg1: timestamp) → timestamp[]Aggregate the selected values into an array.
array_agg(arg1: timestamptz) → timestamptz[]Aggregate the selected values into an array.
array_agg(arg1: UUID) → UUID[]Aggregate the selected values into an array.
array_agg(arg1: oid) → oid[]Aggregate the selected values into an array.
array_agg(arg1: timetz) → timetz[]Aggregate the selected values into an array.
array_agg(arg1: varbit) → varbit[]Aggregate the selected values into an array.
avg(arg1: decimal) → decimalCalculate the average of the selected values.
avg(arg1: float4) → float8Calculate the average of the selected values.
avg(arg1: float8) → float8Calculate the average of the selected values.
avg(arg1: INT2) → DECIMALCalculate the average of the selected values.
avg(arg1: INT4) → DECIMALCalculate the average of the selected values.
avg(arg1: INT8) → DECIMALCalculate the average of the selected values.
avg(arg1: interval) → intervalCalculate the average of the selected values.
bit_and(arg1: int2) → int8Calculate the bitwise AND of all non-null input values. If none, it will be null.
bit_and(arg1: int4) → int8Calculate the bitwise AND of all non-null input values. If none, it will be null.
bit_and(arg1: int8) → int8Calculate the bitwise AND of all non-null input values. If none, it will be null.
bit_or(arg1: int2) → int8Calculate the bitwise OR of all non-null input values. If none, it will be null.
bit_or(arg1: int4) → int8Calculate the bitwise OR of all non-null input values. If none, it will be null.
bit_or(arg1: int8) → int8Calculate the bitwise OR of all non-null input values. If none, it will be null.
BOOL_and(arg1: BOOL) → BOOLCalculate the boolean value of the AND operations of all selected values.
BOOL_or(arg1: BOOL) → BOOLCalculate the boolean value of the OR operations of all selected values.
concat_agg(arg1: bytes) → bytesConcatenate all selected values.
concat_agg(arg1: STRING) → STRINGConcatenate all selected values.
corr(arg1: FLOAT4, arg2: FLOAT4) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: FLOAT4, arg2: FLOAT8) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: FLOAT8, arg2: FLOAT4) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: FLOAT8, arg2: FLOAT8) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: FLOAT4, arg2: INT2) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: FLOAT4, arg2: INT4) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: FLOAT4, arg2: INT8) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: FLOAT8, arg2: INT2) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: FLOAT8, arg2: INT4) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: FLOAT8, arg2: INT8) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT2, arg2: FLOAT4) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT2, arg2: FLOAT8) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT4, arg2: FLOAT4) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT4, arg2: FLOAT8) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT8, arg2: FLOAT4) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT8, arg2: FLOAT8) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT2, arg2: INT2) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT2, arg2: INT4) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT2, arg2: INT8) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT4, arg2: INT2) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT4, arg2: INT4) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT4, arg2: INT8) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT8, arg2: INT2) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT8, arg2: INT4) → FLOAT8Calculate the correlation coefficient of the selected values.
corr(arg1: INT8, arg2: INT8) → FLOAT8Calculate the correlation coefficient of the selected values.
count(arg1: anyelement) → INT8Calculate the number of selected elements.
count_rows() → INT8Calculates the number of rows.
every(arg1: BOOL) → BOOLCalculate the boolean value of the OR operations of all selected values.
JSON_agg(arg1: anyelement) → jsonbAggregate values as a JSON or JSONB array.
jsonb_agg(arg1: anyelement) → jsonbAggregate values as a JSON or JSONB array.
MAX(arg1: BOOL) → BOOLIdentify the maximum selected value.
MAX(arg1: bytes) → bytesIdentify the maximum selected value.
MAX(arg1: date) → dateIdentify the maximum selected value.
MAX(arg1: decimal) → decimalIdentify the maximum selected value.
MAX(arg1: FLOAT4) → FLOAT4Identify the maximum selected value.
MAX(arg1: FLOAT8) → FLOAT8Identify the maximum selected value.
MAX(arg1: INET) → INETIdentify the maximum selected value.
MAX(arg1: INT2) → INT2Identify the maximum selected value.
MAX(arg1: INT4) → INT4Identify the maximum selected value.
MAX(arg1: INT8) → INT8Identify the maximum selected value.
MAX(arg1: interval) → intervalIdentify the maximum selected value.
MAX(arg1: STRING) → STRINGIdentify the maximum selected value.
MAX(arg1: time) → timeIdentify the maximum selected value.
MAX(arg1: timestamp) → timestampIdentify the maximum selected value.
MAX(arg1: timestamptz) → timestamptzIdentify the maximum selected value.
MAX(arg1: UUID) → UUIDIdentify the maximum selected value.
MAX(arg1: jsonb) → jsonbIdentify the maximum selected value.
MAX(arg1: oid) → oidIdentify the maximum selected value.
MAX(arg1: timetz) → timetzIdentify the maximum selected value.
MAX(arg1: varbit) → varbitIdentify the maximum selected value.
min(arg1: BOOL) → BOOLIdentify the minimum selected value.
min(arg1: bytes) → bytesIdentify the minimum selected value.
min(arg1: date) → dateIdentify the minimum selected value.
min(arg1: decimal) → decimalIdentify the minimum selected value.
min(arg1: FLOAT4) → FLOAT4Identify the minimum selected value.
min(arg1: FLOAT8) → FLOAT8Identify the minimum selected value.
min(arg1: INET) → INETIdentify the minimum selected value.
min(arg1: INT2) → INT2Identify the minimum selected value.
min(arg1: INT4) → INT4Identify the minimum selected value.
min(arg1: INT8) → INT8Identify the minimum selected value.
min(arg1: interval) → intervalIdentify the minimum selected value.
min(arg1: STRING) → STRINGIdentify the minimum selected value.
min(arg1: time) → timeIdentify the minimum selected value.
min(arg1: timestamp) → timestampIdentify the minimum selected value.
min(arg1: timestamptz) → timestamptzIdentify the minimum selected value.
min(arg1: UUID) → UUIDIdentify the minimum selected value.
min(arg1: jsonb) → jsonbIdentify the minimum selected value.
min(arg1: oid) → oidIdentify the minimum selected value.
min(arg1: timetz) → timetzIdentify the minimum selected value.
min(arg1: varbit) → varbitIdentify the minimum selected value.
sqrdiff(arg1: decimal) → decimalCalculate the sum of squared differences from the mean of the selected values.
sqrdiff(arg1: FLOAT4) → FLOAT8Calculate the sum of squared differences from the mean of the selected values.
sqrdiff(arg1: FLOAT8) → FLOAT8Calculate the sum of squared differences from the mean of the selected values.
sqrdiff(arg1: INT2) → decimalCalculate the sum of squared differences from the mean of the selected values.
sqrdiff(arg1: INT4) → decimalCalculate the sum of squared differences from the mean of the selected values.
sqrdiff(arg1: INT8) → decimalCalculate the sum of squared differences from the mean of the selected values.
stddev(arg1: decimal) → decimalCalculate the standard deviation of the selected values.
stddev(arg1: FLOAT4) → FLOAT8Calculate the standard deviation of the selected values.
stddev(arg1: FLOAT8) → FLOAT8Calculate the standard deviation of the selected values.
stddev(arg1: INT2) → decimalCalculate the standard deviation of the selected values.
stddev(arg1: INT4) → decimalCalculate the standard deviation of the selected values.
stddev(arg1: INT8) → decimalCalculate the standard deviation of the selected values.
stddev_samp(arg1: decimal) → decimalCalculate the standard deviation of the selected values.
stddev_samp(arg1: FLOAT4) → FLOAT8Calculate the standard deviation of the selected values.
stddev_samp(arg1: FLOAT8) → FLOAT8Calculate the standard deviation of the selected values.
stddev_samp(arg1: INT2) → decimalCalculate the standard deviation of the selected values.
stddev_samp(arg1: INT4) → decimalCalculate the standard deviation of the selected values.
stddev_samp(arg1: INT8) → decimalCalculate the standard deviation of the selected values.
STRING_agg(arg1: bytes, arg2: bytes) → bytesConcatenate all selected values using the provided delimiter.
STRING_agg(arg1: STRING, arg2: STRING) → STRINGConcatenate all selected values using the provided delimiter.
SUM(arg1: decimal) → decimalCalculate the sum of the selected values.
SUM(arg1: FLOAT4) → FLOAT8Calculate the sum of the selected values.
SUM(arg1: FLOAT8) → FLOAT8Calculate the sum of the selected values.
SUM(arg1: INT2) → decimalCalculate the sum of the selected values.
SUM(arg1: INT4) → decimalCalculate the sum of the selected values.
SUM(arg1: INT8) → decimalCalculate the sum of the selected values.
SUM(arg1: interval) → intervalCalculate the sum of the selected values.
SUM_INT(arg1: INT2) → INT8Calculate the sum of the selected values.
SUM_INT(arg1: INT4) → INT8Calculate the sum of the selected values.
SUM_INT(arg1: INT8) → INT8Calculate the sum of the selected values.
variance(arg1: decimal) → decimalCalculate the variance of the selected values.
variance(arg1: FLOAT4) → FLOAT8Calculate the variance of the selected values.
variance(arg1: FLOAT8) → FLOAT8Calculate the variance of the selected values.
variance(arg1: INT2) → decimalCalculate the variance of the selected values.
variance(arg1: INT4) → decimalCalculate the variance of the selected values.
variance(arg1: INT8) → decimalCalculate the variance of the selected values.
xor_agg(arg1: bytes) → bytesCalculate the bitwise XOR of the selected values.
xor_agg(arg1: INT2) → INT8Calculate the bitwise XOR of the selected values.
xor_agg(arg1: INT4) → INT8Calculate the bitwise XOR of the selected values.
xor_agg(arg1: INT8) → INT8Calculate the bitwise XOR of the selected values.
matching(val: INT2, excludeRule: INT8, lowerBound: decimal, upperBound: decimal, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
Parameters:
- excludeRule: Whether to include the upper limit or lower limit in condition judgment. Supported values: 0 means all is included; 1 means only the upper limit is included; 2 means only the lower limit is included. 3 means none is included.
- percentage: If the default percentage is 90%, then input 90.
matching(val: INT4, excludeRule: INT8, lowerBound: decimal, upperBound: decimal, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
Parameters:
- excludeRule: Whether to include the upper limit or lower limit in condition judgment. Supported values: 0 means all is included; 1 means only the upper limit is included; 2 means only the lower limit is included. 3 means none is included.
- percentage: If the default percentage is 90%, then input 90.
matching(val: INT8, excludeRule: INT8, lowerBound: decimal, upperBound: decimal, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
Parameters:
- excludeRule: Whether to include the upper limit or lower limit in condition judgment. Supported values: 0 means all is included; 1 means only the upper limit is included; 2 means only the lower limit is included. 3 means none is included.
- percentage: If the default percentage is 90%, then input 90.
matching(val: FLOAT4, excludeRule: INT8, lowerBound: decimal, upperBound: decimal, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
matching(val: FLOAT8, excludeRule: INT8, lowerBound: decimal, upperBound: decimal, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
matching(val: decimal, excludeRule: INT8, lowerBound: decimal, upperBound: decimal, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
matching(val: INT2, excludeRule: INT8, lowerBound: STRING, upperBound: decimal, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
matching(val: INT4, excludeRule: INT8, lowerBound: STRING, upperBound: decimal, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
matching(val: INT8, excludeRule: INT8, lowerBound: STRING, upperBound: decimal, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
matching(val: FLOAT4, excludeRule: INT8, lowerBound: STRING, upperBound: decimal, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
matching(val: FLOAT8, excludeRule: INT8, lowerBound: STRING, upperBound: decimal, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
matching(val: decimal, excludeRule: INT8, lowerBound: STRING, upperBound: decimal, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
matching(val: INT2, excludeRule: INT8, lowerBound: decimal, upperBound: STRING, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
matching(val: INT4, excludeRule: INT8, lowerBound: decimal, upperBound: STRING, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
matching(val: INT8, excludeRule: INT8, lowerBound: decimal, upperBound: STRING, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
matching(val: FLOAT4, excludeRule: INT8, lowerBound: decimal, upperBound: STRING, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
matching(val: FLOAT8, excludeRule: INT8, lowerBound: decimal, upperBound: STRING, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
matching(val: decimal, excludeRule: INT8, lowerBound: decimal, upperBound: STRING, percentage: INT8) → BOOLReturn true if the ratio of the number of values satisfying the condition to the total number is greater than a predefined percentage. Otherwise, return false.
interpolate(method, mode)The interpolate function, working with the time_bucket_gapfill() function. The type of the interpolate result is identical to that of the original value.
Parameters:
- method: interpolate algorithm, only supporting aggregate functions and numeric data type.
- mode: interpolate mode, supporting constant, prev, next, linear, and null.

Window Functions

Function → ReturnsDescription
cume_dist() → FLOAT8Calculate the relative rank of the current row: (number of rows preceding or peer with current row) / (total rows).
dense_rank() → INT8Calculate the rank of the current row without gaps. This function counts peer groups.
first_value(val: BOOL) → BOOLReturn val evaluated at the row that is the first row of the window frame.
first_value(val: bytes) → bytesReturn val evaluated at the row that is the first row of the window frame.
first_value(val: date) → dateReturn val evaluated at the row that is the first row of the window frame.
first_value(val: decimal) → decimalReturn val evaluated at the row that is the first row of the window frame.
first_value(val: FLOAT4) → FLOAT4Return val evaluated at the row that is the first row of the window frame.
first_value(val: FLOAT8) → FLOAT8Return val evaluated at the row that is the first row of the window frame.
first_value(val: INET) → INETReturn val evaluated at the row that is the first row of the window frame.
first_value(val: INT2) → INT2Return val evaluated at the row that is the first row of the window frame.
first_value(val: INT4) → INT4Return val evaluated at the row that is the first row of the window frame.
first_value(val: INT8) → INT8Return val evaluated at the row that is the first row of the window frame.
first_value(val: interval) → intervalReturn val evaluated at the row that is the first row of the window frame.
first_value(val: STRING) → STRINGReturn val evaluated at the row that is the first row of the window frame.
first_value(val: time) → timeReturn val evaluated at the row that is the first row of the window frame.
first_value(val: timestamp) → timestampReturn val evaluated at the row that is the first row of the window frame.
first_value(val: timestamptz) → timestamptzReturn val evaluated at the row that is the first row of the window frame.
first_value(val: UUID) → UUIDReturn val evaluated at the row that is the first row of the window frame.
first_value(val: jsonb) → jsonbReturn val evaluated at the row that is the first row of the window frame.
first_value(val: oid) → oidReturn val evaluated at the row that is the first row of the window frame.
first_value(val: timetz) → timetzReturn val evaluated at the row that is the first row of the window frame.
first_value(val: varbit) → varbitReturn val evaluated at the row that is the first row of the window frame.
lag(val: BOOL) → BOOLReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: BOOL, n: INT8) → BOOLReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: BOOL, n: INT8, default: BOOL) → BOOLReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: bytes) → bytesReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: bytes, n: INT8) → bytesReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: bytes, n: INT8, default: bytes) → bytesReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: date) → dateReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: date, n: INT8) → dateReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: date, n: INT8, default: date) → dateReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: decimal) → decimalReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: decimal, n: INT8) → decimalReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: decimal, n: INT8, default: decimal) → decimalReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: FLOAT4) → FLOAT8Return val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: FLOAT8) → FLOAT8Return val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: FLOAT4, n: INT8) → FLOAT8Return val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: FLOAT8, n: INT8) → FLOAT8Return val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: FLOAT4, n: INT8, default: FLOAT4) → FLOAT8Return val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: FLOAT8, n: INT8, default: FLOAT8) → FLOAT8Return val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: INET) → INETReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: INET, n: INT8) → INETReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: INET, n: INT8, default: INET) → INETReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: INT2) → INT8Return val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: INT4) → INT8Return val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: INT8) → INT8Return val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: INT2, n: INT8) → INT8Return val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: INT4, n: INT8) → INT8Return val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: INT8, n: INT8) → INT8Return val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: INT2, n: INT8, default: INT2) → INT8Return val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: INT4, n: INT8, default: INT4) → INT8Return val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: INT8, n: INT8, default: INT8) → INT8Return val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: interval) → intervalReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: interval, n: INT8) → intervalReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: interval, n: INT8, default: interval) → intervalReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: STRING) → STRINGReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: STRING, n: INT8) → STRINGReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: STRING, n: INT8, default: STRING) → STRINGReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: time) → timeReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: time, n: INT8) → timeReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: time, n: INT8, default: time) → timeReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: timestamp) → timestampReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: timestamp, n: INT8) → timestampReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: timestamp, n: INT8, default: timestamp) → timestampReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: timestamptz) → timestamptzReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: timestamptz, n: INT8) → timestamptzReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: timestamptz, n: INT8, default: timestamptz) → timestamptzReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: UUID) → UUIDReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: UUID, n: INT8) → UUIDReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: UUID, n: INT8, default: UUID) → UUIDReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: jsonb) → jsonbReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: jsonb, n: INT8) → jsonbReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: jsonb, n: INT8, default: jsonb) → jsonbReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: oid) → oidReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: oid, n: INT8) → oidReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: oid, n: INT8, default: oid) → oidReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: timetz) → timetzReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: timetz, n: INT8) → timetzReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: timetz, n: INT8, default: timetz) → timetzReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lag(val: varbit) → varbitReturn val evaluated at the previous row within current row's partition. If there is no such row, return null.
lag(val: varbit, n: INT8) → varbitReturn val evaluated at the previous row within current row's partition. If there is no such row, return null. n is evaluated with respect to the current row.
lag(val: varbit, n: INT8, default: varbit) → varbitReturn val evaluated at the row that is n rows before the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
last_value(val: BOOL) → BOOLReturn val evaluated at the row that is the last row of the window frame.
last_value(val: bytes) → bytesReturn val evaluated at the row that is the last row of the window frame.
last_value(val: date) → dateReturn val evaluated at the row that is the last row of the window frame.
last_value(val: decimal) → decimalReturn val evaluated at the row that is the last row of the window frame.
last_value(val: FLOAT4) → FLOAT4Return val evaluated at the row that is the last row of the window frame.
last_value(val: FLOAT8) → FLOAT8Return val evaluated at the row that is the last row of the window frame.
last_value(val: INET) → INETReturn val evaluated at the row that is the last row of the window frame.
last_value(val: INT2) → INT2Return val evaluated at the row that is the last row of the window frame.
last_value(val: INT4) → INT4Return val evaluated at the row that is the last row of the window frame.
last_value(val: INT8) → INT8Return val evaluated at the row that is the last row of the window frame.
last_value(val: interval) → intervalReturn val evaluated at the row that is the last row of the window frame.
last_value(val: STRING) → STRINGReturn val evaluated at the row that is the last row of the window frame.
last_value(val: time) → timeReturn val evaluated at the row that is the last row of the window frame.
last_value(val: timestamp) → timestampReturn val evaluated at the row that is the last row of the window frame.
last_value(val: timestamptz) → timestamptzReturn val evaluated at the row that is the last row of the window frame.
last_value(val: UUID) → UUIDReturn val evaluated at the row that is the last row of the window frame.
last_value(val: jsonb) → jsonbReturn val evaluated at the row that is the last row of the window frame.
last_value(val: oid) → oidReturn val evaluated at the row that is the last row of the window frame.
last_value(val: timetz) → timetzReturn val evaluated at the row that is the last row of the window frame.
last_value(val: varbit) → varbitReturn val evaluated at the row that is the last row of the window frame.
lead(val: BOOL) → BOOLReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: BOOL, n: INT8) → BOOLReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: BOOL, n: INT8, default: BOOL) → BOOLReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: bytes) → bytesReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: bytes, n: INT8) → bytesReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: bytes, n: INT8, default: bytes) → bytesReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: date) → dateReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: date, n: INT8) → dateReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: date, n: INT8, default: date) → dateReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: decimal) → decimalReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: decimal, n: INT8) → decimalReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: decimal, n: INT8, default: decimal) → decimalReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: FLOAT4) → FLOAT8Return val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: FLOAT8) → FLOAT8Return val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: FLOAT4, n: INT8) → FLOAT8Return val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: FLOAT8, n: INT8) → FLOAT8Return val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: FLOAT4, n: INT8, default: FLOAT4) → FLOAT8Return val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: FLOAT8, n: INT8, default: FLOAT8) → FLOAT8Return val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: INET) → INETReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: INET, n: INT8) → INETReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: INET, n: INT8, default: INET) → INETReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: INT2) → INT8Return val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: INT4) → INT8Return val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: INT8) → INT8Return val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: INT2, n: INT8) → INT8Return val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: INT4, n: INT8) → INT8Return val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: INT8, n: INT8) → INT8Return val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: INT2, n: INT8, default: INT2) → INT8Return val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: INT4, n: INT8, default: INT4) → INT8Return val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: INT8, n: INT8, default: INT8) → INT8Return val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: interval) → intervalReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: interval, n: INT8) → intervalReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: interval, n: INT8, default: interval) → intervalReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: STRING) → STRINGReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: STRING, n: INT8) → STRINGReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: STRING, n: INT8, default: STRING) → STRINGReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: time) → timeReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: time, n: INT8) → timeReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: time, n: INT8, default: time) → timeReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: timestamp) → timestampReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: timestamp, n: INT8) → timestampReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: timestamp, n: INT8, default: timestamp) → timestampReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: timestamptz) → timestamptzReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: timestamptz, n: INT8) → timestamptzReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: timestamptz, n: INT8, default: timestamptz) → timestamptzReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: UUID) → UUIDReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: UUID, n: INT8) → UUIDReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: UUID, n: INT8, default: UUID) → UUIDReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: jsonb) → jsonbReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: jsonb, n: INT8) → jsonbReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: jsonb, n: INT8, default: jsonb) → jsonbReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: oid) → oidReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: oid, n: INT8) → oidReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: oid, n: INT8, default: oid) → oidReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: timetz) → timetzReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: timetz, n: INT8) → timetzReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: timetz, n: INT8, default: timetz) → timetzReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
lead(val: varbit) → varbitReturn val evaluated at the following row within current row's partition. If there is no such row, return null.
lead(val: varbit, n: INT8) → varbitReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return null. n is evaluated with respect to the current row.
lead(val: varbit, n: INT8, default: varbit) → varbitReturn val evaluated at the row that is n rows after the current row within its partition. If there is no such row, return default (which must be of the same type as val). Both n and default are evaluated with respect to the current row.
nth_value(val: BOOL, n: INT8) → BOOLReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: bytes, n: INT8) → bytesReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: date, n: INT8) → dateReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: decimal, n: INT8) → decimalReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: FLOAT4, n: INT8) → FLOAT8Return val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: FLOAT8, n: INT8) → FLOAT8Return val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: INET, n: INT8) → INETReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: INT2, n: INT8) → INT8Return val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: INT4, n: INT8) → INT8Return val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: INT8, n: INT8) → INT8Return val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: interval, n: INT8) → intervalReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: STRING, n: INT8) → STRINGReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: time, n: INT8) → timeReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: timestamp, n: INT8) → timestampReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: timestamptz, n: INT8) → timestamptzReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: UUID, n: INT8) → UUIDReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: jsonb, n: INT8) → jsonbReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: oid, n: INT8) → oidReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: timetz, n: INT8) → timetzReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
nth_value(val: varbit, n: INT8) → varbitReturn val evaluated at the row that is the nth row of the window frame (counting from 1). If there is no such row, return null.
ntile(n: INT2) → INT8Calculate an integer ranging from 1 to n, dividing the partition as equally as possible.
ntile(n: INT4) → INT8Calculate an integer ranging from 1 to n, dividing the partition as equally as possible.
ntile(n: INT8) → INT8Calculate an integer ranging from 1 to n, dividing the partition as equally as possible.
percent_rank() → FLOAT8Calculate the relative rank of the current row: (rank - 1) / (total rows - 1).
rank() → INT8Calculate the rank of the current row with gaps. Same as the row_number of its first peer.
row_number() → INT8Calculate the number of the current row within its partition, counting from 1.