Represents a time duration specified in a given unit. Supported units: - milliseconds / millisecond - seconds / second - minutes / minute - hours / hour - days / day
Functions
The following SQL functions are supported. For Window function, see the separate Window function section in this documentation.
Function
Return Type
Description
MIN(variable v)
typeof v
Returns the smallest value in a set of data.
MAX(variable v)
typeof v
Returns the maximum value across all input values.
COUNT(any a)
numeric
Returns the number of input values that are not null.
SUM(numeric n)
numeric
Returns the summation across all input values.
AVG(numeric n)
numeric
Returns the average value (arithmetic mean) across all input values.
CEIL(numeric n)
numeric
Returns the value rounded up to the nearest integer.
FLOOR(numeric n)
numeric
Returns the value rounded down to the nearest integer.
ROUND(numeric n)
numeric
Returns the value rounded to the nearest integer.
LOWER(string s)
string
Returns the string as lowercase.
UPPER(string s)
string
Returns the string as uppercase.
ABS(numeric n)
numeric
Returns the absolute value.
COALESCE(args a)
typeof first non-null a OR null
Returns the first non-null value or null if all are null.
CAST(value AS type)
type
Converts the given value to the specified data type.
LENGTH(string s)
integer
Returns the number of characters in the string.
TRIM(string s)
string
Removes leading and trailing whitespace from the string.
REPLACE(string s, string from, string to)
string
Replaces occurrences of a substring within a string with another substring.
SUBSTRING(string s, int start, int length)
string
Extracts a substring from a string, starting at a given position and for a specified length.
STRPOS(string s, string substring)
integer
Returns the first index position of the substring in a given string, or 0 if there is no match.
This table provides an overview of the supprted window functions. For comprehensive details and examples, see the PostgreSQL documentation.
Function
Return Type
Description
OVER
N/A
Defines a window for a set of rows for other window functions to operate on.
PARTITION BY
N/A
Divides the result set into partitions, specifically for applying window functions.
RANK()
integer
Assigns a rank to each row within a partition, with gaps for ties.
ROW_NUMBER()
integer
Assigns a unique sequential number to each row within a partition.
LEAD(column n)
typeof column
Returns the value from the next row in the partition.
LAG(column n)
typeof column
Returns the value from the previous row in the partition.
FIRST_VALUE(column n)
typeof column
Returns the first value in an ordered set of values.
LAST_VALUE(column n)
typeof column
Returns the last value in an ordered set of values.
NTH_VALUE(column n, offset)
typeof column
Returns the value at the specified offset in an ordered set of values.
Tags
DDSQL exposes tags as an hstore type, which you can query using the PostgreSQL arrow operator. For example:
SELECTinstance_type,count(instance_type)FROMaws.ec2_instanceWHEREtags->'region'='us-east-1'-- region is a tag, not a column
GROUPBYinstance_type
Tags are key-value pairs where each key can have zero, one, or multiple values. When accessed, the tag value returns a string containing all corresponding values.
You can also compare tag values as strings or entire tag sets:
SELECT*FROMk8s.daemonsetsdaINNERJOINk8s.deploymentsdeONda.tags=de.tags-- for a specific tag: da.tags->'app' = de.tags->'app'
Further reading
Additional helpful documentation, links, and articles: