COUNT_VALUES_IF
Returns the number of true
values in a given array.
This can be used with conditional operators to count the number of array elements that fulfil a condition. For example, COUNT_VALUES_IF(my_values[] > 3)
will return the number of elements that are greater than 3.
Syntax
COUNT_VALUES_IF(input)
Arguments
Name
Type
Description
Default Value
input
Boolean
The input array
Returns
the number of times true
appeared in the input array. a primitive value is considered to be an array with one element.
Examples
input
Output
null::Boolean
0
array[true, false, true]
2
Transformation job example
SQL
CREATE JOB function_operator_example
ADD_MISSING_COLUMNS = true
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data
MAP_COLUMNS_BY_NAME
SELECT input,
COUNT_VALUES_IF(input) AS Output
FROM default_glue_catalog.upsolver_samples.orders_raw_data
LET input = null::boolean
WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
LIMIT 1;
Query result
input
Output
null::Boolean
0
Last updated