DISTINCT
- DISTINCT(array)[source]
Returns an array containing only the distinct values from the input array.
This function removes duplicates from the provided array, preserving the order of first occurrences. It works on any scalar or object array type.
- Parameters:
array (
Operand) –The array from which duplicates will be removed.
Supported types:
INTEGER_ARRAY
DECIMAL_ARRAY
STRING_ARRAY
BOOLEAN_ARRAY
DATE_ARRAY
TIME_ARRAY
DATETIME_ARRAY
OBJECT_ARRAY
- Return type:
- Returns:
A formula object representing the array of distinct values.
Supported types:
INTEGER_ARRAY
DECIMAL_ARRAY
STRING_ARRAY
BOOLEAN_ARRAY
DATE_ARRAY
TIME_ARRAY
DATETIME_ARRAY
OBJECT_ARRAY
- Raises:
ValueError – If the input is not an array type or is a MAP type.
Examples
Removing duplicates from numbers:
DISTINCT([1, 2, 2, 3, 1]) # Returns [1, 2, 3]
Removing duplicates from strings:
DISTINCT(["apple", "banana", "apple", "cherry"]) # Returns ["apple", "banana", "cherry"]