Returns true if every element of the array satisfies the predicate.

Type parameters. T means matching inputs and outputs use the same type.

Returns true if any element of the array satisfies the predicate.

Type parameters. T means matching inputs and outputs use the same type.

Returns element-wise sum of two arrays.
Examples
SELECT array_add(ARRAY[120.5, 0.0, 42.25, 310.0], ARRAY[15.0, 60.75, 8.0, 0.0]) AS combined_daily_spend;
| combined_daily_spend         |
| ---------------------------- |
| [135.5, 60.75, 50.25, 310.0] |
Returns true if all elements in a boolean array are true.
Examples
SELECT array_all(transform(ARRAY['alice@example.com', 'bob@example.com', 'carol-at-example.com'], e -> strpos(e, '@') > 0)) AS all_emails_valid;
| all_emails_valid |
| ---------------- |
| false            |
SELECT array_all(ARRAY[true, NULL, true]) AS all_true_ignoring_nulls;
| all_true_ignoring_nulls |
| ----------------------- |
| true                    |
Returns true if any element in a boolean array is true.
Examples
SELECT array_any(transform(ARRAY['crypto', 'wire', 'gift card'], k -> strpos(lower('Urgent WIRE transfer to new payee'), k) > 0)) AS memo_is_risky;
| memo_is_risky |
| ------------- |
| true          |
SELECT array_any(ARRAY[false, CAST(NULL AS BOOLEAN), false]) AS any_rule_fired;
| any_rule_fired |
| -------------- |
| false          |
Adds an element to the end of an array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT array_append(ARRAY['login', 'view_cart'], 'checkout') AS session_events;
| session_events               |
| ---------------------------- |
| [login, view_cart, checkout] |
SELECT array_max(array_append(ARRAY[42.50, 18.99, 120.00], 310.75)) AS max_txn_amount_incl_current;
| max_txn_amount_incl_current |
| --------------------------- |
| 310.75                      |
Alias for transform.
Examples
SELECT array_apply(ARRAY['  Groceries', 'FUEL ', 'Dining'], tag -> lower(trim(tag))) AS normalized_tags;
| normalized_tags           |
| ------------------------- |
| [groceries, fuel, dining] |
SELECT array_apply(ARRAY[19.99, 5.0, 120.5], x -> round(x * 1.08, 2)) AS prices_with_tax;
| prices_with_tax      |
| -------------------- |
| [21.59, 5.4, 130.14] |
Returns the index of the maximum element in an array.
Examples
SELECT element_at(ARRAY['groceries', 'travel', 'dining', 'utilities'], array_arg_max(ARRAY[0.12, 0.71, 0.05, 0.12]) + 1) AS predicted_category;
| predicted_category |
| ------------------ |
| travel             |
SELECT array_arg_max(ARRAY[42, 87, NULL, 87, 15]) AS busiest_hour_index;
| busiest_hour_index |
| ------------------ |
| 1                  |
Returns the index of the minimum element in an array.
Examples
SELECT element_at(ARRAY['ups', 'fedex', 'usps', 'dhl'], array_arg_min(ARRAY[412.50, 389.99, 405.00, 395.25]) + 1) AS cheapest_carrier;
| cheapest_carrier |
| ---------------- |
| fedex            |
SELECT array_arg_min(ARRAY[CAST(NULL AS DOUBLE), 0.42, 0.17, 0.88, 0.17]) AS nearest_centroid_idx;
| nearest_centroid_idx |
| -------------------- |
| 2                    |
Calculates the average of numeric values in an array.
Examples
SELECT round(array_average(ARRAY[42.50, 18.99, 120.00, 7.25, 61.30]), 2) AS avg_recent_txn_amount;
| avg_recent_txn_amount |
| --------------------- |
| 50.01                 |
SELECT array_average(ARRAY[4.5, NULL, 5.0, 2.5]) AS avg_review_rating;
| avg_review_rating |
| ----------------- |
| 4.0               |
Removes all null values from an array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT array_compact(ARRAY[CASE WHEN 1250.00 > 1000 THEN 'large_amount' END, CASE WHEN 'US' <> 'BR' THEN 'cross_border' END, CASE WHEN 3 > 5 THEN 'high_velocity' END]) AS triggered_rules;
| triggered_rules              |
| ---------------------------- |
| [large_amount, cross_border] |
SELECT cardinality(array_compact(ARRAY['ada@example.com', NULL, '+1-555-0100', NULL])) AS contact_methods_on_file;
| contact_methods_on_file |
| ----------------------- |
| 2                       |
Creates an array from zero or more values.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT array_constructor(1, 2, 3);
| array_constructor(1, 2, 3) |
| -------------------------- |
| [1, 2, 3]                  |
Alias for contains.
Examples
SELECT array_contains(split(lower('Refund for order 8812 - duplicate charge'), ' '), 'refund') AS memo_mentions_refund;
| memo_mentions_refund |
| -------------------- |
| true                 |
SELECT array_contains(ARRAY[5411, 5812, 7995], 7995) AS has_gambling_mcc;
| has_gambling_mcc |
| ---------------- |
| true             |
Returns true if the array contains the given element.
Examples
SELECT array_contains_element(split(lower('Wire transfer to Crypto exchange'), ' '), 'crypto') AS memo_mentions_crypto;
| memo_mentions_crypto |
| -------------------- |
| true                 |
SELECT array_contains_element(ARRAY[5411, 5812, 5541], 7995) AS used_gambling_mcc;
| used_gambling_mcc |
| ----------------- |
| false             |
Calculates the cumulative sum of numeric values in an array.
Examples
SELECT array_cum_sum(ARRAY[500.00, -120.50, -45.25, 250.00, -80.00]) AS running_balance;
| running_balance                        |
| -------------------------------------- |
| [500.0, 379.5, 334.25, 584.25, 504.25] |
SELECT array_cum_sum(transform(ARRAY[3, 5, NULL, 2], x -> coalesce(x, 0))) AS running_total;
| running_total |
| ------------- |
| [3, 8, 8, 10] |
Returns an array with duplicate elements removed, preserving order.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT array_distinct(ARRAY['card_present', 'online', 'card_present', 'atm', 'online', 'online']) AS distinct_channels;
| distinct_channels           |
| --------------------------- |
| [card_present, online, atm] |
SELECT cardinality(array_distinct(ARRAY['dev_a1', 'dev_b7', 'dev_a1', 'dev_c3', 'dev_b7'])) AS distinct_device_count;
| distinct_device_count |
| --------------------- |
| 3                     |
Returns an array containing only the duplicate elements from the input array.
Examples
SELECT array_duplicates(split('INV-1042,INV-2210,INV-1042,INV-3301,INV-2210,INV-1042', ',')) AS repeated_invoice_ids;
| repeated_invoice_ids |
| -------------------- |
| [INV-1042, INV-2210] |
SELECT cardinality(array_duplicates(ARRAY[4417, 9012, 4417, 3388, 9012, 4417])) AS reused_device_count;
| reused_device_count |
| ------------------- |
| 2                   |
Returns elements from the first array that are not present in the second array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT array_except(ARRAY['electronics', 'books', 'garden', 'toys'], ARRAY['books', 'toys']) AS unexplored_categories;
| unexplored_categories |
| --------------------- |
| [electronics, garden] |
SELECT array_except(ARRAY[412, 205, 412, 309, 205, 118], ARRAY[309, 777]) AS new_merchant_ids;
| new_merchant_ids |
| ---------------- |
| [412, 205, 118]  |
Filters an array using a callback function predicate.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
array:
large_list<item: $T>
The input array or list. T means matching inputs and outputs use the same type.
predicate:
($T) => bool
T means matching inputs and outputs use the same type.
Examples
SELECT array_filter(ARRAY[12.50, -3.00, 249.99, -45.00, 8.75], x -> x < 0) AS refund_amounts;
| refund_amounts |
| -------------- |
| [-3.0, -45.0]  |
SELECT array_filter(split('urgent,billing,,refund,priority:high', ','), t -> t <> '' AND NOT starts_with(t, 'priority:')) AS ticket_tags;
| ticket_tags               |
| ------------------------- |
| [urgent, billing, refund] |
Returns a map of elements to their frequency counts in an array.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
array:
large_list<item: $T>
The input array or list. T means matching inputs and outputs use the same type.
Examples
SELECT array_frequency(ARRAY['card_present','online','online','atm','online']) AS channel_counts;
| channel_counts                       |
| ------------------------------------ |
| {card_present: 1, online: 3, atm: 1} |
SELECT element_at(array_frequency(split(lower('Refund please. I asked for a refund twice and still no refund'), ' ')), 'refund') AS refund_mentions;
| refund_mentions |
| --------------- |
| 3               |
Checks if an array contains duplicate elements.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT array_has_duplicates(ARRAY['dev_a1', 'dev_b7', 'dev_a1', 'dev_c3']) AS reused_device;
| reused_device |
| ------------- |
| true          |
SELECT array_has_duplicates(transform(split('Alice@Example.com,bob@example.com,alice@example.com', ','), e -> lower(e))) AS shared_email;
| shared_email |
| ------------ |
| true         |
Alias for array_position.
Examples
SELECT array_indexof(ARRAY['approved', 'approved', 'declined', 'approved'], 'declined') AS first_decline_attempt;
| first_decline_attempt |
| --------------------- |
| 3                     |
SELECT array_indexof(ARRAY['low', 'medium', 'high', 'urgent'], 'critical') AS priority_rank;
| priority_rank |
| ------------- |
| 0             |
Returns the intersection of two arrays (elements present in both arrays).

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT array_intersect(ARRAY['refund','urgent','billing','shipping'], ARRAY['billing','refund','chargeback']) AS escalation_tags;
| escalation_tags   |
| ----------------- |
| [refund, billing] |
SELECT cardinality(array_intersect(split(lower('Wireless Noise Cancelling Headphones Black'), ' '), split(lower('noise cancelling headphones'), ' '))) AS query_term_matches;
| query_term_matches |
| ------------------ |
| 3                  |
SELECT array_intersect(ARRAY[3, 1, 3, 2], ARRAY[3, 3, 2]) AS shared;
| shared |
| ------ |
| [3, 2] |
Joins array elements into a string using a separator and optional null replacement.

Type parameters. K is the key type of the input map.

Examples
SELECT array_join(array_constructor('a', 'b', 'c'), ',');
| array_join(array_constructor('a', 'b', 'c'), ',') |
| ------------------------------------------------- |
| a,b,c                                             |
Alias for cardinality.
Examples
SELECT array_length(split('refund requested for order 4821 damaged in shipping', ' ')) AS memo_word_count;
| memo_word_count |
| --------------- |
| 8               |
SELECT array_length(array_distinct(ARRAY['US','US','GB','NG','US'])) AS distinct_login_countries;
| distinct_login_countries |
| ------------------------ |
| 3                        |
Returns the maximum element in an array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT array_max(ARRAY[42.50, 18.99, 129.00, 7.25]) AS largest_purchase;
| largest_purchase |
| ---------------- |
| 129.0            |
SELECT array_max(remove_nulls(ARRAY[0.12, NULL, 0.87, 0.45])) AS peak_fraud_score;
| peak_fraud_score |
| ---------------- |
| 0.87             |
SELECT array_max(ARRAY[DATE '2026-03-14', DATE '2026-09-02', DATE '2026-07-21']) AS latest_login_date;
| latest_login_date |
| ----------------- |
| 2026-09-02        |
Calculates the median value of numeric elements in an array.
Examples
SELECT array_median(ARRAY[42.50, 38.00, 2499.99, 45.25, 40.10]) AS median_txn_amount;
| median_txn_amount |
| ----------------- |
| 42.5              |
SELECT array_median(ARRAY[120, 95, 310, 140]) AS median_response_ms;
| median_response_ms |
| ------------------ |
| 130.0              |
SELECT array_median(remove_nulls(ARRAY[4.5, NULL, 3.0, 5.0])) AS median_rating;
| median_rating |
| ------------- |
| 4.5           |
Returns the minimum element in an array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT array_min(ARRAY[42.5, 18.0, 7.25, 63.1]) AS smallest_txn_amount;
| smallest_txn_amount |
| ------------------- |
| 7.25                |
SELECT array_min(ARRAY[TIMESTAMP '2024-03-14 09:12:00', TIMESTAMP '2024-01-02 18:40:00', TIMESTAMP '2024-02-27 07:05:00']) AS first_login_at;
| first_login_at          |
| ----------------------- |
| 2024-01-02 18:40:00 UTC |
Returns all most frequently occurring elements in an array.
Examples
SELECT array_multimode(ARRAY['grocery','fuel','grocery','dining','fuel','travel']) AS top_categories;
| top_categories  |
| --------------- |
| [grocery, fuel] |
SELECT cardinality(array_multimode(ARRAY['card','ach','card','wire','ach'])) > 1 AS has_tied_payment_method;
| has_tied_payment_method |
| ----------------------- |
| true                    |
Returns the number of distinct non-null elements in an array.
Examples
SELECT array_n_unique(ARRAY['US', 'US', 'MX', NULL, 'BR', 'US']) AS distinct_card_countries;
| distinct_card_countries |
| ----------------------- |
| 3                       |
SELECT array_n_unique(split(lower('Refund refund REFUND please'), ' ')) AS distinct_memo_words;
| distinct_memo_words |
| ------------------- |
| 2                   |
Computes the L_p normalization of a Vector.
Examples
SELECT array_normalize(ARRAY[2.0, -1.0, 4.0, 2.0], 2.0) AS unit_embedding;
| unit_embedding        |
| --------------------- |
| [0.4, -0.2, 0.8, 0.4] |
SELECT array_normalize(ARRAY[12.0, 3.0, 0.0, 5.0], 1.0) AS category_spend_share;
| category_spend_share   |
| ---------------------- |
| [0.6, 0.15, 0.0, 0.25] |
Returns the 1-based position of an element in an array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT array_position(array_constructor('a', 'b', 'a'), 'a');
| array_position(array_constructor('a', 'b', 'a'), 'a') |
| ----------------------------------------------------- |
| 1                                                     |
Applies a reduce function to each element in an array and returns the accumulated value.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type. V is the value type of the input map.

Parameters
array:
large_list<item: $T>
The input array or list. T means matching inputs and outputs use the same type.
U is a second generic value type.
inputFunction:
($U, $T) => $U
T means matching inputs and outputs use the same type. U is a second generic value type.
outputFunction:
($U) => $V
V is the value type of the input map. U is a second generic value type.
Examples
SELECT array_reduce(ARRAY[0.02, -0.01, 0.03, 0.015], 1.0, (growth, r) -> growth * (1 + r), growth -> round((growth - 1) * 100, 2)) AS cumulative_return_pct;
| cumulative_return_pct |
| --------------------- |
| 5.57                  |
SELECT array_reduce(ARRAY['ok', 'fail', 'fail', 'ok', 'fail', 'fail', 'fail', 'ok'], struct_pack(cur := 0, best := 0), (s, status) -> IF(status = 'fail', struct_pack(cur := s.cur + 1, best := greatest(s.best, s.cur + 1)), struct_pack(cur := 0, best := s.best)), s -> s.best) AS longest_failure_streak;
| longest_failure_streak |
| ---------------------- |
| 3                      |
Reduces an array with Python-style loop control. Lambda returns (new_state, control_code, result), where control_code is 0=normal, 1=return, 2=continue, 3=break. Returns row(final_state, control_code, result|null).

Type parameters. T means matching inputs and outputs use the same type. S is the callback state type. R is the callback result type.

Parameters
array:
large_list<item: $T>
The input array or list. T means matching inputs and outputs use the same type.
The initial accumulator state. S is the callback state type.
function:
($S, $T) => struct<state: $S, control: int64, result: $R>
The callback function applied to the elements. T means matching inputs and outputs use the same type. R is the callback result type. S is the callback state type.
Removes all occurrences of a specified element from an array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT array_remove(split('POS  PURCHASE   ACME COFFEE', ' '), '') AS memo_tokens;
| memo_tokens                   |
| ----------------------------- |
| [POS, PURCHASE, ACME, COFFEE] |
SELECT cardinality(array_remove(ARRAY[42, -1, 17, -1, 8], -1)) AS valid_reading_count;
| valid_reading_count |
| ------------------- |
| 3                   |
Returns the array with elements in reverse order.
Examples
SELECT array_reverse(ARRAY['login', 'view_cart', 'add_payment', 'checkout']) AS events_newest_first;
| events_newest_first                       |
| ----------------------------------------- |
| [checkout, add_payment, view_cart, login] |
SELECT element_at(array_reverse(split('electronics/computers/laptops/gaming', '/')), 1) AS leaf_category;
| leaf_category |
| ------------- |
| gaming        |
Returns a slice from an array, string, or binary value.

Type parameters. E is the element type of the input array or list.

Examples
SELECT array_slice(array_constructor(1, 2, 3, 4), 2, 3);
| array_slice(array_constructor(1, 2, 3, 4), 2, 3) |
| ------------------------------------------------ |
| [2, 3, 4]                                        |
Sorts an array in ascending order, optionally using a key extraction function.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type.

Examples
SELECT array_sort(array_constructor(3, 1, 2));
| array_sort(array_constructor(3, 1, 2)) |
| -------------------------------------- |
| [1, 2, 3]                              |
Sorts an array in descending order, optionally using a key extraction function.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type.

Examples
SELECT array_sort_desc(array_constructor(3, 1, 2));
| array_sort_desc(array_constructor(3, 1, 2)) |
| ------------------------------------------- |
| [3, 2, 1]                                   |
Calculates the standard deviation of numeric values in an array.
Examples
SELECT round(array_stddev(ARRAY[42.50, 38.75, 45.10, 40.00, 512.99], false), 2) AS txn_amount_stddev;
| txn_amount_stddev |
| ----------------- |
| 188.57            |
SELECT round(array_stddev(ARRAY[1200.0, 1350.0, 1180.0, 1420.0], true), 2) AS daily_spend_sample_stddev;
| daily_spend_sample_stddev |
| ------------------------- |
| 116.44                    |
Calculates the sum of numeric values in an array.
Examples
SELECT array_sum(ARRAY[3, NULL, 0, 5, NULL, 2, 4]) AS logins_last_7_days;
| logins_last_7_days |
| ------------------ |
| 14                 |
SELECT array_sum(transform(ARRAY[2, 1, 3], qty -> qty * 19.99)) AS order_total;
| order_total |
| ----------- |
| 119.94      |
Alias for array_join.
Examples
SELECT array_to_string(array_sort(ARRAY['travel', 'electronics', 'grocery']), '|') AS category_key;
| category_key                 |
| ---------------------------- |
| electronics\|grocery\|travel |
SELECT array_to_string(ARRAY['US', NULL, 'CA'], ',') AS ship_countries;
| ship_countries |
| -------------- |
| US,CA          |
Applies a transformation function to each element in an array and returns a new array.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type.

Parameters
array:
large_list<item: $T>
The input array or list. T means matching inputs and outputs use the same type.
function:
($T) => $U
The callback function applied to the elements. T means matching inputs and outputs use the same type. U is a second generic value type.
Examples
SELECT array_transform(ARRAY['  Groceries', 'DINING ', 'Travel'], tag -> lower(trim(tag))) AS normalized_tags;
| normalized_tags             |
| --------------------------- |
| [groceries, dining, travel] |
SELECT array_transform(ARRAY[1200, 45, 8800], amount_cents -> amount_cents >= 5000) AS is_large_txn;
| is_large_txn         |
| -------------------- |
| [false, false, true] |
Alias for array_distinct.
Examples
SELECT array_unique(split('login,view,login,purchase,view,login', ',')) AS distinct_events;
| distinct_events         |
| ----------------------- |
| [login, view, purchase] |
SELECT cardinality(array_unique(ARRAY['US', 'US', 'MX', 'US', 'BR', 'MX'])) AS distinct_card_countries;
| distinct_card_countries |
| ----------------------- |
| 3                       |
Examples
SELECT array_value('electronics', 'books', 'toys') AS categories;
| categories                 |
| -------------------------- |
| [electronics, books, toys] |
SELECT contains(array_value('US', 'CA', 'GB'), upper('ca')) AS is_supported_country;
| is_supported_country |
| -------------------- |
| true                 |
SELECT array_max(array_value(0.12, 0.87, 0.35)) AS max_risk_signal;
| max_risk_signal |
| --------------- |
| 0.87            |
Checks if two arrays have any elements in common.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT arrays_overlap(split(lower('Wire transfer to CRYPTO exchange'), ' '), ARRAY['crypto', 'casino', 'gift']) AS memo_mentions_risky_merchant;
| memo_mentions_risky_merchant |
| ---------------------------- |
| true                         |
SELECT arrays_overlap(ARRAY['electronics', 'gaming'], ARRAY['groceries', 'pharmacy']) AS shares_category;
| shares_category |
| --------------- |
| false           |
Returns a list of the distinct elements of the common elements

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT arrays_union(ARRAY['electronics', 'gift', 'sale'], ARRAY['sale', 'clearance', 'gift']) AS merged_tags;
| merged_tags                          |
| ------------------------------------ |
| [electronics, gift, sale, clearance] |
SELECT cardinality(arrays_union(ARRAY['ios', 'web', 'ios'], ARRAY['web', 'android'])) AS distinct_device_platforms;
| distinct_device_platforms |
| ------------------------- |
| 3                         |
Returns the number of elements in an array or entries in a map.

Type parameters. V is the value type of the input map. K is the key type of the input map.

Examples
SELECT cardinality(array_constructor(1, 2, 3));
| cardinality(array_constructor(1, 2, 3)) |
| --------------------------------------- |
| 3                                       |
Returns all possible combinations of the given size from an array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT combinations(array_sort(array_distinct(ARRAY['laptop','mouse','laptop','usb_hub'])), 2) AS basket_pairs;
| basket_pairs                                           |
| ------------------------------------------------------ |
| [[laptop, mouse], [laptop, usb_hub], [mouse, usb_hub]] |
SELECT transform(combinations(ARRAY['card','wallet','bank'], 2), p -> array_join(p, '+')) AS channel_pairs;
| channel_pairs                         |
| ------------------------------------- |
| [card+wallet, card+bank, wallet+bank] |
Checks if a list contains a specific element.

Type parameters. V is the value type of the input map.

Parameters
array:
large_list<item: $V>
The input array or list. V is the value type of the input map.
The element to search for. V is the value type of the input map.
Examples
SELECT contains(split(lower('Wire transfer for CRYPTO exchange deposit'), ' '), 'crypto') AS memo_mentions_crypto;
| memo_mentions_crypto |
| -------------------- |
| true                 |
SELECT contains(ARRAY[7995, 6051, 4829], 5411) AS is_high_risk_mcc;
| is_high_risk_mcc |
| ---------------- |
| false            |
Returns an element from an array or map.

Type parameters. E is the element type of the input array or list. K is the key type of the input map. V is the value type of the input map.

Examples
SELECT element_at(array_constructor('a', 'b'), 2);
| element_at(array_constructor('a', 'b'), 2) |
| ------------------------------------------ |
| b                                          |
Returns the first element in an array that matches the given predicate function.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT find_first(ARRAY[120.0, 45.5, 980.0, 2500.0, 60.0], x -> x > 500) AS first_large_txn;
| first_large_txn |
| --------------- |
| 980.0           |
SELECT find_first(ARRAY['gmail.com', 'acme-corp.com', 'yahoo.com'], d -> d NOT IN ('gmail.com', 'yahoo.com', 'hotmail.com')) AS work_domain;
| work_domain   |
| ------------- |
| acme-corp.com |
Returns the 1-based index of the first element in an array that matches the given predicate function.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT find_first_index(ARRAY[42.10, 18.75, 1250.00, 9.99, 3400.00], x -> x > 1000) AS first_large_txn_position;
| first_large_txn_position |
| ------------------------ |
| 3                        |
SELECT find_first_index(ARRAY['viewed', 'added_to_cart', 'viewed', 'purchased'], e -> e = 'purchased') AS steps_to_purchase;
| steps_to_purchase |
| ----------------- |
| 4                 |
Flattens a nested array by one level, combining all sub-arrays into a single array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT flatten(ARRAY[ARRAY['electronics', 'audio'], ARRAY['audio', 'accessories'], ARRAY['books']]) AS order_categories;
| order_categories                                |
| ----------------------------------------------- |
| [electronics, audio, audio, accessories, books] |
SELECT flatten(ARRAY[ARRAY[ARRAY[1, 2], ARRAY[3]], ARRAY[ARRAY[4]]]) AS one_level;
| one_level          |
| ------------------ |
| [[1, 2], [3], [4]] |
Returns the largest value from a list of values.

Type parameters. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.

Examples
SELECT greatest(3.0, 7.0, 5.0);
| greatest(3.0, 7.0, 5.0) |
| ----------------------- |
| 7.0                     |
SELECT greatest(3, 7, 5);
| greatest(3, 7, 5) |
| ----------------- |
| 7                 |
Returns the smallest value from a list of values.

Type parameters. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.

Examples
SELECT least(3.0, 7.0, 5.0);
| least(3.0, 7.0, 5.0) |
| -------------------- |
| 3.0                  |
SELECT least(3, 7, 5);
| least(3, 7, 5) |
| -------------- |
| 3              |
Alias for transform.
Examples
SELECT list_apply(ARRAY['  Groceries ', 'GAS', 'groceries'], t -> lower(trim(t))) AS normalized_tags;
| normalized_tags             |
| --------------------------- |
| [groceries, gas, groceries] |
SELECT list_apply(ARRAY[12.5, 250.0, 4999.99], amt -> amt > 1000) AS is_large_txn;
| is_large_txn         |
| -------------------- |
| [false, false, true] |
Alias for array_average.
Examples
SELECT list_avg(ARRAY[42.50, 18.99, 120.00, 7.25]) AS avg_txn_amount;
| avg_txn_amount |
| -------------- |
| 47.185         |
SELECT list_avg(ARRAY[4, 5, NULL, 3, 5]) AS avg_review_rating;
| avg_review_rating |
| ----------------- |
| 4.25              |
Alias for concat.
Examples
SELECT list_concat(ARRAY['electronics','laptops'], ARRAY['clearance'], ARRAY['back_to_school']) AS merged_tags;
| merged_tags                                       |
| ------------------------------------------------- |
| [electronics, laptops, clearance, back_to_school] |
SELECT array_max(list_concat(ARRAY[42.50, 18.00, 7.25], ARRAY[310.00, 299.99])) AS max_txn_amount;
| max_txn_amount |
| -------------- |
| 310.0          |
Alias for contains.
Examples
SELECT list_contains(split(lower('Wire transfer to CRYPTO exchange'), ' '), 'crypto') AS memo_mentions_crypto;
| memo_mentions_crypto |
| -------------------- |
| true                 |
SELECT list_contains(ARRAY[5411, 5812, 7995], 7995) AS is_gambling_mcc;
| is_gambling_mcc |
| --------------- |
| true            |
Alias for cardinality.
Examples
SELECT list_count(regexp_split_to_array('Refund request: duplicate charge on order #4821, card ending 1234', ' ')) AS memo_word_count;
| memo_word_count |
| --------------- |
| 10              |
SELECT list_count(array_distinct(ARRAY['electronics', 'gift_card', 'electronics', 'jewelry'])) AS distinct_category_count;
| distinct_category_count |
| ----------------------- |
| 3                       |
Alias for array_distinct.
Examples
SELECT list_distinct(regexp_split(lower('Refund refund REFUND card fee card'), ' ')) AS memo_tokens;
| memo_tokens         |
| ------------------- |
| [refund, card, fee] |
SELECT cardinality(list_distinct(ARRAY['ios', 'web', 'ios', 'android', 'web', 'ios'])) AS distinct_devices;
| distinct_devices |
| ---------------- |
| 3                |
Either:
  • Returns the element at the specified index in a list.
  • Retrieves the value associated with a key from a map.

Type parameters. E is the element type of the input array or list. K is the key type of the input map. V is the value type of the input map.

Examples
SELECT list_extract(split('Amazon Mktplace*2K4LP1 Seattle WA', ' '), 1) AS merchant_token;
| merchant_token |
| -------------- |
| Amazon         |
SELECT list_extract(split('Amazon Mktplace*2K4LP1 Seattle WA', ' '), -1) AS state_code;
| state_code |
| ---------- |
| WA         |
SELECT list_extract(MAP(ARRAY['US', 'CA', 'MX'], ARRAY[0.02, 0.05, 0.11]), 'CA') AS country_risk;
| country_risk |
| ------------ |
| 0.05         |
Filters a list using a callback function predicate.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT list_filter([12.50, 899.00, 3.25, 1450.00, 64.10], amt -> amt > 500) AS large_transactions;
| large_transactions |
| ------------------ |
| [899.0, 1450.0]    |
SELECT list_filter(['wire transfer to acct', 'grocery store', 'crypto exchange deposit', 'coffee'], memo -> memo LIKE '%wire%' OR memo LIKE '%crypto%') AS risky_memos;
| risky_memos                                      |
| ------------------------------------------------ |
| [wire transfer to acct, crypto exchange deposit] |
SELECT cardinality(list_filter(['success', 'failed', 'failed', 'success', 'failed'], status -> status = 'failed')) AS failed_login_count;
| failed_login_count |
| ------------------ |
| 3                  |
Alias for contains.
Examples
SELECT list_has(split(lower('POS PURCHASE ACH REVERSAL 0423'), ' '), 'reversal') AS is_reversal;
| is_reversal |
| ----------- |
| true        |
SELECT list_has(ARRAY[200, 201, 204], 404) AS is_success_status;
| is_success_status |
| ----------------- |
| false             |
Alias for arrays_overlap.
Examples
SELECT list_has_any(['refund', 'chargeback', 'dispute'], split(lower('Customer filed a DISPUTE for order 4412'), ' ')) AS mentions_dispute_term;
| mentions_dispute_term |
| --------------------- |
| true                  |
SELECT list_has_any(['gift_cards', 'crypto', 'wire_transfer'], ['electronics', 'books', 'groceries']) AS has_high_risk_category;
| has_high_risk_category |
| ---------------------- |
| false                  |
Alias for array_intersect.
Examples
SELECT cardinality(list_intersect(split(lower('Refund for DUPLICATE charge, possible fraud'), ' '), ARRAY['refund','chargeback','dispute','duplicate','fraud'])) AS dispute_keyword_hits;
| dispute_keyword_hits |
| -------------------- |
| 3                    |
SELECT list_intersect(ARRAY[101, 205, 205, 330, 412], ARRAY[205, 412, 412, 999]) AS shared_merchant_ids;
| shared_merchant_ids |
| ------------------- |
| [205, 412]          |
Alias for array_max.
Examples
SELECT list_max(ARRAY[42.50, 1299.99, 18.75, 310.00]) AS largest_purchase;
| largest_purchase |
| ---------------- |
| 1299.99          |
SELECT list_max(ARRAY['2026-03-14', '2026-09-30', '2026-07-02']) AS latest_login_date;
| latest_login_date |
| ----------------- |
| 2026-09-30        |
Alias for array_median.
Examples
SELECT list_median([42.5, 18.0, 1250.0, 37.25, 29.99]) AS median_order_amount;
| median_order_amount |
| ------------------- |
| 37.25               |
SELECT list_median([12, 45, 8, 30]) AS median_session_minutes;
| median_session_minutes |
| ---------------------- |
| 21.0                   |
Alias for array_min.
Examples
SELECT list_min(ARRAY[42.50, 18.99, 7.25, 103.00]) AS smallest_txn_amount;
| smallest_txn_amount |
| ------------------- |
| 7.25                |
SELECT list_min(ARRAY[DATE '2026-03-14', DATE '2025-11-02', DATE '2026-01-20']) AS first_order_date;
| first_order_date |
| ---------------- |
| 2025-11-02       |
Alias for array_mode.
Examples
SELECT array_mode(array_constructor(1, 2, 2, 3));
| array_mode(array_constructor(1, 2, 2, 3)) |
| ----------------------------------------- |
| 2                                         |
Examples
SELECT remove_nulls(list_pack(CASE WHEN 950.0 > 500 THEN 'large_amount' END, CASE WHEN 'NG' <> 'US' THEN 'foreign_ip' END, CASE WHEN 2 > 5 THEN 'high_velocity' END)) AS risk_flags;
| risk_flags                 |
| -------------------------- |
| [large_amount, foreign_ip] |
SELECT array_max(list_pack(120.0, 87.5, 342.0, 15.25)) AS max_txn_amount;
| max_txn_amount |
| -------------- |
| 342.0          |
Alias for array_position.
Examples
SELECT list_position(ARRAY['card_present', 'ecommerce', 'atm_withdrawal', 'wire'], 'atm_withdrawal') AS channel_index;
| channel_index |
| ------------- |
| 3             |
SELECT list_position(ARRAY['low', 'medium', 'high', 'critical'], 'unknown') AS severity_rank;
| severity_rank |
| ------------- |
| 0             |
Alias for array_slice.
Examples
SELECT list_slice(ARRAY[12.50, 8.99, 240.00, 15.25, 980.00, 1250.00], -3, -1) AS last_3_txn_amounts;
| last_3_txn_amounts     |
| ---------------------- |
| [15.25, 980.0, 1250.0] |
SELECT list_slice(ARRAY['login','view_item','add_to_cart','view_item','checkout','purchase'], 1, 6, 2) AS every_other_event;
| every_other_event              |
| ------------------------------ |
| [login, add_to_cart, checkout] |
SELECT list_slice('ACCT-2024-00918', 6, 9) AS account_year;
| account_year |
| ------------ |
| 2024         |
Alias for array_sort.
Examples
SELECT list_sort(ARRAY[42.50, NULL, 7.99, 120.00, 15.25]) AS sorted_amounts;
| sorted_amounts                   |
| -------------------------------- |
| [7.99, 15.25, 42.5, 120.0, NULL] |
SELECT slice(list_sort(ARRAY[42.50, 7.99, 120.00, 15.25, 89.00], x -> -x), 1, 3) AS top_3_amounts;
| top_3_amounts       |
| ------------------- |
| [120.0, 89.0, 42.5] |
Alias for array_stddev.
Examples
SELECT round(list_stddev_pop([12.5, 48.0, 9.99, 130.0, 22.75], false), 2) AS txn_amount_stddev;
| txn_amount_stddev |
| ----------------- |
| 44.74             |
SELECT round(list_stddev_pop([12.5, 48.0, 9.99, 130.0, 22.75], true), 2) AS txn_amount_sample_stddev;
| txn_amount_sample_stddev |
| ------------------------ |
| 50.03                    |
Alias for array_sum.
Examples
SELECT list_sum(ARRAY[3, 0, 7, 2]) AS failed_logins_last_4h;
| failed_logins_last_4h |
| --------------------- |
| 12                    |
SELECT list_sum(ARRAY[19.99, NULL, 5.01]) AS cart_total;
| cart_total |
| ---------- |
| 25.0       |
Alias for transform.
Examples
SELECT list_transform(split('  Electronics , HOME_garden,Toys ', ','), t -> lower(trim(t))) AS normalized_tags;
| normalized_tags                  |
| -------------------------------- |
| [electronics, home_garden, toys] |
SELECT list_transform(ARRAY[1299, 450, 8000], cents -> cents / 100.0) AS line_item_dollars;
| line_item_dollars  |
| ------------------ |
| [12.99, 4.5, 80.0] |
Alias for array_distinct.
Examples
SELECT list_unique(split('electronics,books,electronics,toys,books', ',')) AS purchased_categories;
| purchased_categories       |
| -------------------------- |
| [electronics, books, toys] |
SELECT cardinality(list_unique(ARRAY['dev-a1', 'dev-b7', 'dev-a1', 'dev-a1', 'dev-c3'])) AS distinct_devices_used;
| distinct_devices_used |
| --------------------- |
| 3                     |
Examples
SELECT list_value(0.42, 1.0, 3.7) AS score_vector;
| score_vector     |
| ---------------- |
| [0.42, 1.0, 3.7] |
SELECT cardinality(array_distinct(list_value('visa', 'mastercard', 'visa', 'amex'))) AS distinct_card_networks;
| distinct_card_networks |
| ---------------------- |
| 3                      |
Returns all N-grams (contiguous subsequences of length n) from an array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT transform(ngrams(split(lower('WIRE TRANSFER INTL FEE'), ' '), 2), g -> array_join(g, ' ')) AS memo_bigrams;
| memo_bigrams                             |
| ---------------------------------------- |
| [wire transfer, transfer intl, intl fee] |
SELECT contains(ngrams(ARRAY['login', 'reset_password', 'change_email', 'withdraw', 'logout'], 3), ARRAY['reset_password', 'change_email', 'withdraw']) AS has_takeover_pattern;
| has_takeover_pattern |
| -------------------- |
| true                 |
SELECT ngrams(ARRAY['login', 'reset_password', 'change_email'], 5) AS short_session_ngrams;
| short_session_ngrams                    |
| --------------------------------------- |
| [[login, reset_password, change_email]] |
Returns true if no element of the array satisfies the predicate.

Type parameters. T means matching inputs and outputs use the same type.

Returns the element at the specified Python-style index in a list.

Type parameters. E is the element type of the input array or list.

Examples
SELECT python_element_at(split('Home > Electronics > Audio > Headphones', ' > '), -1) AS leaf_category;
| leaf_category |
| ------------- |
| Headphones    |
SELECT python_element_at(ARRAY['login','browse','add_to_cart','checkout'], 0) AS first_event;
| first_event |
| ----------- |
| login       |
Creates a range of integers with Python-like semantics.
Examples
SELECT transform(python_range(0, length('STARBUCKS') - 2), i -> substr('STARBUCKS', i + 1, 3)) AS merchant_trigrams;
| merchant_trigrams                   |
| ----------------------------------- |
| [STA, TAR, ARB, RBU, BUC, UCK, CKS] |
SELECT python_range(90, 0, -30) AS lookback_days;
| lookback_days |
| ------------- |
| [90, 60, 30]  |
Combines multiple lists element-wise into a list of paired structures with Python semantics.

Type parameters. E is the element type of the input array or list.

Examples
SELECT python_zip(ARRAY['groceries', 'fuel', 'dining', 'travel'], ARRAY[0.42, 0.31]) AS category_shares;
| category_shares                                   |
| ------------------------------------------------- |
| [{f0: groceries, f1: 0.42}, {f0: fuel, f1: 0.31}] |
SELECT transform(python_zip(ARRAY[100, 105, 98, 120], slice(ARRAY[100, 105, 98, 120], 2, 3)), p -> p.f1 - p.f0) AS balance_deltas;
| balance_deltas |
| -------------- |
| [5, -7, 22]    |
Alias for python_range.
Examples
SELECT range(0, 25, 5) AS score_bucket_edges;
| score_bucket_edges |
| ------------------ |
| [0, 5, 10, 15, 20] |
SELECT transform(range(0, 30, 7), d -> date_add('day', -d, DATE '2024-03-31')) AS weekly_lookback_dates;
| weekly_lookback_dates                                                                                                         |
| ----------------------------------------------------------------------------------------------------------------------------- |
| [2024-03-31 00:00:00 UTC, 2024-03-24 00:00:00 UTC, 2024-03-17 00:00:00 UTC, 2024-03-10 00:00:00 UTC, 2024-03-03 00:00:00 UTC] |
SELECT range(10, 0, -3) AS countdown;
| countdown     |
| ------------- |
| [10, 7, 4, 1] |
Removes all null values from an array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT remove_nulls(ARRAY[CASE WHEN 0.92 > 0.8 THEN 'high_risk_score' END, CASE WHEN 'US' <> 'NG' THEN 'geo_mismatch' END, CASE WHEN 3 > 5 THEN 'velocity_spike' END]) AS fired_rules;
| fired_rules                     |
| ------------------------------- |
| [high_risk_score, geo_mismatch] |
SELECT cardinality(remove_nulls(ARRAY['+1-415-555-0100', NULL, 'alice@example.com', NULL])) AS verified_contact_count;
| verified_contact_count |
| ---------------------- |
| 2                      |
Returns an array containing the element repeated count times.

Type parameters. E is the element type of the input array or list.

Parameters
The element to search for. E is the element type of the input array or list.
count:
int32
The number of values to return or repeat.
Examples
SELECT concat(ARRAY['wire', 'refund'], repeat('<pad>', CAST(greatest(0, 4 - cardinality(ARRAY['wire', 'refund'])) AS INTEGER))) AS padded_tokens;
| padded_tokens                |
| ---------------------------- |
| [wire, refund, <pad>, <pad>] |
Generates a sequence of integers with an optional step.
Examples
SELECT sequence(1, 5);
| sequence(1, 5)  |
| --------------- |
| [1, 2, 3, 4, 5] |
Randomly shuffles the elements of an array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT slice(shuffle(ARRAY['sku_101', 'sku_202', 'sku_303', 'sku_404', 'sku_505']), 1, 2) AS sampled_recs;
| sampled_recs       |
| ------------------ |
| [sku_303, sku_101] |
SELECT array_sort(shuffle(ARRAY['sku_303', 'sku_101', 'sku_505', 'sku_202'])) = array_sort(ARRAY['sku_303', 'sku_101', 'sku_505', 'sku_202']) AS is_permutation;
| is_permutation |
| -------------- |
| true           |
Returns a slice of a list starting at the given position for the specified length.

Type parameters. E is the element type of the input array or list.

Examples
SELECT slice(ARRAY['login', 'view_item', 'add_to_cart', 'checkout', 'purchase'], 1, 3) AS first_three_events;
| first_three_events              |
| ------------------------------- |
| [login, view_item, add_to_cart] |
SELECT slice(ARRAY[120.0, 45.5, 300.0, 18.25, 999.99, 62.0], -3, 3) AS last_three_amounts;
| last_three_amounts    |
| --------------------- |
| [18.25, 999.99, 62.0] |
SELECT array_join(slice(split('Wireless Noise Cancelling Over-Ear Headphones with Mic', ' '), 1, 3), ' ') AS title_prefix;
| title_prefix              |
| ------------------------- |
| Wireless Noise Cancelling |
Returns the element at the specified 1-based index in the array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT subscript(split('jane.doe@acme-corp.com', '@'), 2) AS email_domain;
| email_domain  |
| ------------- |
| acme-corp.com |
SELECT subscript(split('/shop/electronics/audio/headphones', '/'), cardinality(split('/shop/electronics/audio/headphones', '/'))) AS leaf_category;
| leaf_category |
| ------------- |
| headphones    |
Applies a transformation function to each element in an array and returns a new array.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type.

Examples
SELECT transform(ARRAY['  AMZN Mktp US ', 'Uber *Trip', 'STARBUCKS #1234'], m -> upper(trim(m))) AS merchant_keys;
| merchant_keys                               |
| ------------------------------------------- |
| [AMZN MKTP US, UBER *TRIP, STARBUCKS #1234] |
SELECT transform(ARRAY[12.50, 840.00, 45.10, 2300.00], amt -> CASE WHEN amt >= 500 THEN 'high' ELSE 'normal' END) AS amount_buckets;
| amount_buckets               |
| ---------------------------- |
| [normal, high, normal, high] |
Removes the last n elements from the array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT trim_array(ARRAY['login', 'view_cart', 'checkout', 'heartbeat', 'heartbeat'], 2) AS user_actions;
| user_actions                 |
| ---------------------------- |
| [login, view_cart, checkout] |
SELECT array_average(trim_array(ARRAY[120.0, 95.5, 143.0, 110.25, 18.0], 1)) AS avg_complete_day_spend;
| avg_complete_day_spend |
| ---------------------- |
| 117.1875               |
Combines two lists element-wise into a list of paired structures.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type.

Parameters
array1:
large_list<item: $T>
The first input array. T means matching inputs and outputs use the same type.
array2:
large_list<item: $U>
The second input array. U is a second generic value type.
Examples
SELECT zip(ARRAY['amount', 'velocity', 'geo_mismatch'], ARRAY[0.42, 0.31, 0.27]) AS feature_weights;
| feature_weights                                                                  |
| -------------------------------------------------------------------------------- |
| [{f1: amount, f2: 0.42}, {f1: velocity, f2: 0.31}, {f1: geo_mismatch, f2: 0.27}] |
SELECT zip(ARRAY['ord_1001', 'ord_1002', 'ord_1003'], ARRAY[5, 4]) AS order_ratings;
| order_ratings                                                            |
| ------------------------------------------------------------------------ |
| [{f1: ord_1001, f2: 5}, {f1: ord_1002, f2: 4}, {f1: ord_1003, f2: NULL}] |
Combines two lists element-wise using a callback function to transform paired elements.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type. R is the callback result type.

Parameters
array1:
large_list<item: $T>
The first input array. T means matching inputs and outputs use the same type.
array2:
large_list<item: $U>
The second input array. U is a second generic value type.
function:
($T, $U) => $R
The callback function applied to the elements. T means matching inputs and outputs use the same type. U is a second generic value type. R is the callback result type.
Examples
SELECT zip_with(ARRAY[2, 1, 3], ARRAY[4.99, 19.50, 2.25], (qty, price) -> qty * price) AS line_totals;
| line_totals        |
| ------------------ |
| [9.98, 19.5, 6.75] |
SELECT zip_with(ARRAY['US', 'GB', 'DE'], ARRAY['US', 'FR'], (billing, shipping) -> billing = shipping) AS country_matches;
| country_matches     |
| ------------------- |
| [true, false, NULL] |
operator alias for list_has_any

Type parameters. E is the element type of the input array or list.

Examples
SELECT split(lower('Wire transfer to Binance via Coinbase'), ' ') && ARRAY['binance','coinbase','kraken'] AS mentions_crypto_exchange;
| mentions_crypto_exchange |
| ------------------------ |
| true                     |
SELECT ARRAY['US','CA'] && ARRAY['KP','IR','SY'] AS ships_to_sanctioned_country;
| ships_to_sanctioned_country |
| --------------------------- |
| false                       |