Function Index
This page provides a comprehensive A-Z reference of the most commonly used functions in Apache Pinot, organized by category. Each category section links to its detailed documentation page with full syntax, parameters, and examples.
Functions are available in the Single-Stage Engine (SSE), the Multi-Stage Engine (MSE), or both. Window functions require the multi-stage engine.
Aggregation Functions
For full details, see Aggregation Functions.
DISTINCTCOUNTHLLPLUS(col [, p])
LONG
Approximate distinct count using HyperLogLog++
Both
DISTINCTCOUNTTHETASKETCH(col [, predicates...])
LONG
Distinct count using Theta Sketch
Both
SEGMENTPARTITIONEDDISTINCTCOUNT(col)
LONG
Optimized distinct count for partitioned columns
Both
FIRSTWITHTIME(dataCol, timeCol, 'type')
varies
Value associated with the earliest timestamp
Both
LASTWITHTIME(dataCol, timeCol, 'type')
varies
Value associated with the latest timestamp
Both
FREQUENTSTRINGSSKETCH(col, maxMapSize)
STRING
Frequent items sketch for strings
Both
FUNNELMAXSTEP(stepCol, corCol, settings, step1, step2, ...)
INT
Maximum funnel step reached
Both
FUNNELCOMPLETECOUNT(stepCol, corCol, settings, step1, step2, ...)
INT
Count of completed funnels
Both
FUNNELSTEPDURATIONSTATS(stepCol, corCol, tsCol, settings, step1, step2, ...)
STRING
Step duration statistics
Both
String Functions
For full details, see String Functions.
SUBSTRING
SUBSTRING(str, start [, length])
STRING
Extracts substring by start position and length
Both
LEFT
LEFT(str, length)
STRING
Returns leftmost N characters
Both
RIGHT
RIGHT(str, length)
STRING
Returns rightmost N characters
Both
STRRPOS
STRRPOS(str, find [, instance])
INT
Returns last position of substring
Both
ENDSWITH
ENDSWITH(str, suffix)
BOOLEAN
Checks if string ends with suffix
Both
CONTAINS
CONTAINS(str, substring)
BOOLEAN
Checks if string contains substring
Both
SPLIT
SPLIT(str, delimiter [, limit])
STRING[]
Splits string by delimiter
Both
SPLITPART
SPLITPART(str, delimiter, index)
STRING
Returns Nth part after splitting
Both
REPEAT
REPEAT(str, times)
STRING
Repeats string N times
Both
NORMALIZE
NORMALIZE(str [, form])
STRING
Normalizes Unicode string
Both
STRCMP
STRCMP(str1, str2)
INT
Compares two strings lexicographically
Both
HAMMINGDISTANCE
HAMMINGDISTANCE(str1, str2)
INT
Hamming distance between two strings
Both
Math Functions
For full details, see Math Functions.
CEIL / CEILING
CEIL(val)
DOUBLE
Rounds up to nearest integer
Both
LN / LOG
LN(val)
DOUBLE
Natural logarithm
Both
LOG2
LOG2(val)
DOUBLE
Base-2 logarithm
Both
LOG10
LOG10(val)
DOUBLE
Base-10 logarithm
Both
SIGN
SIGN(val)
DOUBLE
Sign of a number (-1, 0, 1)
Both
POW / POWER
POW(base, exp)
DOUBLE
Raises base to exponent
Both
ROUNDDECIMAL
ROUNDDECIMAL(val [, scale])
DOUBLE
Rounds to specified decimal places
Both
TRUNCATE
TRUNCATE(val [, scale])
DOUBLE
Truncates to specified decimal places
Both
DIV / DIVIDE
DIV(a, b [, default])
DOUBLE
Division with optional default for divide-by-zero
Both
INTDIV
INTDIV(a, b)
LONG
Integer division
Both
LEAST
LEAST(a, b)
DOUBLE
Returns the smaller of two values
Both
GREATEST
GREATEST(a, b)
DOUBLE
Returns the larger of two values
Both
GCD
GCD(a, b)
LONG
Greatest common divisor
Both
LCM
LCM(a, b)
LONG
Least common multiple
Both
HYPOT
HYPOT(a, b)
DOUBLE
Hypotenuse (sqrt(a^2 + b^2))
Both
NEGATE
NEGATE(val)
DOUBLE
Negates the value
Both
RAND
RAND([seed])
DOUBLE
Random number between 0 and 1
Both
SIN
SIN(val)
DOUBLE
Sine
Both
COS
COS(val)
DOUBLE
Cosine
Both
TAN
TAN(val)
DOUBLE
Tangent
Both
COT
COT(val)
DOUBLE
Cotangent
Both
ASIN
ASIN(val)
DOUBLE
Inverse sine
Both
ACOS
ACOS(val)
DOUBLE
Inverse cosine
Both
ATAN
ATAN(val)
DOUBLE
Inverse tangent
Both
ATAN2
ATAN2(y, x)
DOUBLE
Two-argument inverse tangent
Both
DEGREES
DEGREES(radians)
DOUBLE
Converts radians to degrees
Both
RADIANS
RADIANS(degrees)
DOUBLE
Converts degrees to radians
Both
DateTime Functions
For full details, see DateTime Functions.
TOEPOCHSECONDSROUNDED(millis, roundTo)
LONG
Converts millis to rounded epoch seconds
Both
TOEPOCHMINUTESROUNDED(millis, roundTo)
LONG
Converts millis to rounded epoch minutes
Both
TOEPOCHHOURSROUNDED(millis, roundTo)
LONG
Converts millis to rounded epoch hours
Both
TOEPOCHSECONDSBUCKET(millis, bucket)
LONG
Buckets millis into epoch second intervals
Both
FROMEPOCHSECONDSBUCKET(seconds, bucket)
LONG
Converts bucketed epoch seconds to millis
Both
DATETRUNC(unit, timeVal [, inputUnit [, tz [, outputUnit]]])
LONG
Truncates timestamp to specified granularity
Both
DATEBIN
DATEBIN(binWidth, sourceTs, originTs)
TIMESTAMP
Bins a timestamp into intervals
Both
TIMESTAMPADD / DATEADD
TIMESTAMPADD(unit, interval, ts)
LONG
Adds interval to timestamp
Both
TIMESTAMPDIFF / DATEDIFF
TIMESTAMPDIFF(unit, ts1, ts2)
LONG
Difference between two timestamps
Both
DAYOFMONTH / DAY
DAYOFMONTH(millis [, tz])
INT
Extracts day of month (1-31)
Both
TOTIMESTAMP
TOTIMESTAMP(millis)
TIMESTAMP
Converts millis to SQL Timestamp
Both
FROMTIMESTAMP
FROMTIMESTAMP(ts)
LONG
Converts SQL Timestamp to millis
Both
DATETIMECONVERT(col, inFormat, outFormat, granularity)
STRING/LONG
Converts datetime between formats
Both
JSON Functions
For full details, see JSON Functions.
JSONPATHARRAYDEFAULTEMPTY(obj, path)
OBJECT[]
Extracts array, returns empty if null
Both
JSONEXTRACTSCALAR(json, path, type [, default])
varies
Extracts scalar value from JSON
Both
JSONSTRINGTOARRAY
JSONSTRINGTOARRAY(jsonStr)
LIST
Parses JSON string to array
Both
JSONSTRINGTOMAP
JSONSTRINGTOMAP(jsonStr)
MAP
Parses JSON string to map
Both
ISJSON
ISJSON(str)
BOOLEAN
Checks if string is valid JSON
Both
Array Functions
For full details, see Array Functions.
ARRAY_AGG
ARRAY_AGG(col, 'type' [, distinct])
ARRAY
Aggregates values into an array
Both
ARRAYSOVERLAP
ARRAYSOVERLAP(arr1, arr2)
BOOLEAN
True if arrays share any element
Both
ARRAYSUMINT
ARRAYSUMINT(arr)
INT
Sum of integer array elements
Both
ARRAYSUMLONG
ARRAYSUMLONG(arr)
LONG
Sum of long array elements
Both
ARRAYTOSTRING
ARRAYTOSTRING(arr, delimiter [, null])
STRING
Joins array elements into string
Both
Hash Functions
For full details, see Hash Functions.
SHA
SHA(bytes)
STRING
SHA-1 hash
Both
SHA224
SHA224(bytes)
STRING
SHA-224 hash
Both
SHA256
SHA256(bytes)
STRING
SHA-256 hash
Both
SHA512
SHA512(bytes)
STRING
SHA-512 hash
Both
MD2
MD2(bytes)
STRING
MD2 hash
Both
MD5
MD5(bytes)
STRING
MD5 hash
Both
MURMURHASH2
MURMURHASH2(bytes)
INT
32-bit MurmurHash2
Both
MURMURHASH2UTF8
MURMURHASH2UTF8(str)
INT
32-bit MurmurHash2 for strings
Both
MURMURHASH3BIT32
MURMURHASH3BIT32(bytes, seed)
INT
32-bit MurmurHash3
Both
MURMURHASH3BIT64
MURMURHASH3BIT64(bytes, seed)
LONG
64-bit MurmurHash3
Both
MURMURHASH3BIT128
MURMURHASH3BIT128(bytes, seed)
BYTES
128-bit MurmurHash3
Both
CRC32
CRC32(bytes)
INT
32-bit CRC checksum
Both
CRC32C
CRC32C(bytes)
INT
32-bit CRC32C (Castagnoli)
Both
ADLER32
ADLER32(bytes)
INT
32-bit Adler checksum
Both
URL Functions
For full details, see URL Functions.
URLPROTOCOL
URLPROTOCOL(url)
STRING
Extracts protocol/scheme
Both
URLDOMAIN
URLDOMAIN(url)
STRING
Extracts domain
Both
URLDOMAINWITHOUTWWW
URLDOMAINWITHOUTWWW(url)
STRING
Extracts domain without www prefix
Both
URLTOPLEVELDOMAIN
URLTOPLEVELDOMAIN(url)
STRING
Extracts top-level domain
Both
URLPORT
URLPORT(url)
INT
Extracts port number
Both
URLPATH
URLPATH(url)
STRING
Extracts path component
Both
URLQUERYSTRING
URLQUERYSTRING(url)
STRING
Extracts query string
Both
URLFRAGMENT
URLFRAGMENT(url)
STRING
Extracts fragment identifier
Both
EXTRACTURLPARAMETER
EXTRACTURLPARAMETER(url, name)
STRING
Extracts specific query parameter
Both
EXTRACTURLPARAMETERS
EXTRACTURLPARAMETERS(url)
STRING[]
Extracts all query parameters
Both
URLENCODE
URLENCODE(url)
STRING
URL-encodes a string
Both
URLDECODE
URLDECODE(url)
STRING
Decodes URL-encoded string
Both
CUTWWW
CUTWWW(url)
STRING
Removes www prefix from URL
Both
CUTQUERYSTRING
CUTQUERYSTRING(url)
STRING
Removes query string from URL
Both
CUTFRAGMENT
CUTFRAGMENT(url)
STRING
Removes fragment from URL
Both
CUTURLPARAMETER
CUTURLPARAMETER(url, name)
STRING
Removes specific query parameter
Both
Binary Functions
For full details, see Binary Functions.
TOUTF8
TOUTF8(str)
BYTES
Converts string to UTF-8 bytes
Both
FROMUTF8
FROMUTF8(bytes)
STRING
Converts UTF-8 bytes to string
Both
TOASCII
TOASCII(str)
BYTES
Converts string to ASCII bytes
Both
FROMASCII
FROMASCII(bytes)
STRING
Converts ASCII bytes to string
Both
TOBASE64
TOBASE64(bytes)
STRING
Encodes bytes as Base64 string
Both
FROMBASE64
FROMBASE64(str)
BYTES
Decodes Base64 string to bytes
Both
BASE64ENCODE
BASE64ENCODE(bytes)
BYTES
Base64 encodes byte array
Both
BASE64DECODE
BASE64DECODE(bytes)
BYTES
Base64 decodes byte array
Both
HEXTOBYTES
HEXTOBYTES(hex)
BYTES
Converts hex string to bytes
Both
BYTESTOHEX
BYTESTOHEX(bytes)
STRING
Converts bytes to hex string
Both
Geospatial Functions
For full details, see GeoSpatial Functions.
Vector / Similarity Functions
For full details, see Vector Functions.
COSINEDISTANCE
COSINEDISTANCE(arr1, arr2)
DOUBLE
Cosine distance between two vectors
Both
INNERPRODUCT
INNERPRODUCT(arr1, arr2)
DOUBLE
Inner (dot) product of two vectors
Both
L1DISTANCE
L1DISTANCE(arr1, arr2)
DOUBLE
Manhattan distance between two vectors
Both
L2DISTANCE
L2DISTANCE(arr1, arr2)
DOUBLE
Euclidean distance between two vectors
Both
VECTORDIMS
VECTORDIMS(arr)
INT
Number of dimensions in a vector
Both
VECTORNORM
VECTORNORM(arr)
DOUBLE
L2 norm (magnitude) of a vector
Both
IP Address Functions
For full details, see IP Address Functions.
IPPREFIX
IPPREFIX(addr, prefixLen)
STRING
Returns CIDR prefix for IP address
Both
IPSUBNETMIN
IPSUBNETMIN(prefix)
STRING
Returns lowest IP in subnet
Both
IPSUBNETMAX
IPSUBNETMAX(prefix)
STRING
Returns highest IP in subnet
Both
Null Handling Functions
For full details, see Null Handling Functions.
IS NULL
col IS NULL
BOOLEAN
True if value is null
Both
IS NOT NULL
col IS NOT NULL
BOOLEAN
True if value is not null
Both
COALESCE
COALESCE(val1, val2, ...)
varies
Returns first non-null value
Both
NULLIF
NULLIF(val1, val2)
varies
Returns null if values are equal
Both
IS DISTINCT FROM
a IS DISTINCT FROM b
BOOLEAN
Null-safe inequality comparison
Both
IS NOT DISTINCT FROM
a IS NOT DISTINCT FROM b
BOOLEAN
Null-safe equality comparison
Both
CASE WHEN
CASE WHEN cond THEN val ... END
varies
Conditional expression
Both
Type Conversion Functions
For full details, see Type Conversion Functions.
CAST
CAST(val AS type)
varies
Converts value to specified type
Both
BIGDECIMALTOBYTES
BIGDECIMALTOBYTES(decimal)
BYTES
Converts BigDecimal to bytes
Both
BYTESTOBIGDECIMAL
BYTESTOBIGDECIMAL(bytes)
BIGDECIMAL
Converts bytes to BigDecimal
Both
HEXDECIMALTOLONG
HEXDECIMALTOLONG(hex)
LONG
Converts hex string to long
Both
LONGTOHEXDECIMAL
LONGTOHEXDECIMAL(val)
STRING
Converts long to hex string
Both
TOUUIDBYTES
TOUUIDBYTES(uuid)
BYTES
Converts UUID string to bytes
Both
FROMUUIDBYTES
FROMUUIDBYTES(bytes)
STRING
Converts bytes to UUID string
Both
Window Functions
For full details, see Window Functions.
Window functions require the multi-stage query engine (v2).
ROW_NUMBER
ROW_NUMBER() OVER (...)
LONG
Sequential row number within partition
MSE
RANK
RANK() OVER (...)
LONG
Rank with gaps for ties
MSE
DENSE_RANK
DENSE_RANK() OVER (...)
LONG
Rank without gaps for ties
MSE
LAG
LAG(col [, offset [, default]]) OVER (...)
varies
Value from a preceding row
MSE
LEAD
LEAD(col [, offset [, default]]) OVER (...)
varies
Value from a following row
MSE
FIRST_VALUE
FIRST_VALUE(col) OVER (...)
varies
First value in the window frame
MSE
LAST_VALUE
LAST_VALUE(col) OVER (...)
varies
Last value in the window frame
MSE
BOOL_AND
BOOL_AND(col) OVER (...)
BOOLEAN
Windowed boolean AND
MSE
BOOL_OR
BOOL_OR(col) OVER (...)
BOOLEAN
Windowed boolean OR
MSE
Last updated
Was this helpful?

