Logical operators and functions

Operator/FunctionDescription
! or notLogical not
<Less than
<=Less than or equal to
=Equal to
>Greater than
>=Greater than or equal to
^Bitwise exclusive or
|Bitwise or
~Bitwise not
arrays_overlapReturns the common elements
assert_trueAsserts if the expression is true
ifIf the expression evaluates to true, return the second expression. Otherwise, return the third expression.
ifnullIf the expression is null, it returns the second expression. Otherwise, it returns the first expression.
inReturns true if the first expression is in any of the subsequent expressions.
isnanReturns true if the value is not a number
isnotnullReturns true if the value is not null
isnullReturns true if the value is null
nanvlReturns the first expression if not a number, returns the second expression otherwise
orLogical or
whenWhen can be used to create branch conditions for comparison
xpath_booleanReturns true if the XPath expression evaluates to true or if a matching node is found

Date/time functions

FunctionDescription
add_monthsAdd months to date
date_addAdd days to date
date_formatModify date format
date_subSubtract days from date
date_truncReturns the date truncated to the specified unit
datediffReturns the difference between dates in days
day, dayofmonthReturns the day of the month
dayofweekReturns the day of week (1-7)
dayofyearReturns the day of year
from_unixtimeReturns date in UNIX® time
from_utc_timestampReturns date in UTC time
hourReturns the hour of the input
last_dayReturns the last day of the month that the date belongs to
minuteReturns the minute of the input
monthReturns the month of the input
months_betweenNumber of months between
next_dayReturns the first day later than the input
quarterReturns the quarter of the input
secondReturns the second of the string
to_dateConverts the string to a date. Note: The string must be in the format yyyy-mm-ddTHH24:MM:SS.
to_timestampConverts the string to a timestamp. Note: The string must be in the format yyyy-mm-ddTHH24:MM:SS.
to_unix_timestampConverts the string to a UNIX® timestamp
to_utc_timestampConverts the string to a UTC timestamp
truncTruncates the date
unix_timestampReturns the UNIX® timestamp
weekdayDay of the week (0-6)
weekofyearReturns the week of the year for a given date
yearReturns the year of the string

Arrays

FunctionDescription
arrayCreates an array with the given elements
array_containsChecks if the array contains the value
array_distinctRemoves duplicate values from the array
array_exceptReturns an array of the elements in the first array, but not the second
array_intersectReturns the intersection of the two arrays
array_joinJoins two arrays together
array_maxReturns the maximum value of the array
array_minReturns the minimum value of the array
array_positionReturns the 1-based position of the element
array_removeRemoves all elements that are equal to the element
array_repeatCreates an array containing the value counted times
array_sortSorts the array
array_unionJoins the array together, without any duplicates
arrays_zipCombines the values of given arrays with the values of the original collection at a given index
cardinalityReturn the size of the array
element_atReturn the element at position
explodeSeparate elements of array into multiple rows, excluding null
explode_outerSeparate elements of array into multiple rows, including null
find_in_setReturns the 1 based position of array
flattenFlattens an array of arrays
inlineSeparate array of structs into a table, excluding null
inline_outerSeparate array of structs into a table, including null
posexplodeSeparate elements of an array into multiple rows with positions, excluding null
reverseReverse elements of the array
shuffleReturn a random permutation of the array
sliceSubsets an array
sort_arraySort an array, given an order
zip_withMerges the two arrays into a single array, before applying a function