array are true.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 |array is true.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 |element to the end of an array.Type parameters. T means matching inputs and outputs use the same type.
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 |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] |array.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 |array.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 |array.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 |array.Type parameters. T means matching inputs and outputs use the same type.
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 |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 |array contains the given element.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 |array.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] |array with duplicate elements removed, preserving order.Type parameters. T means matching inputs and outputs use the same type.
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 |array containing only the duplicate elements from the input array.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 |Type parameters. T means matching inputs and outputs use the same type.
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] |array using a callback function predicate.Type parameters. T means matching inputs and outputs use the same type.
array or list. T means matching inputs and outputs use the same type.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] |array.Type parameters. T means matching inputs and outputs use the same type.
array or list. T means matching inputs and outputs use the same type.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 |array contains duplicate elements.Type parameters. T means matching inputs and outputs use the same type.
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 |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 |Type parameters. T means matching inputs and outputs use the same type.
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] |array elements into a string using a separator and optional null replacement.Type parameters. K is the key type of the input map.
SELECT array_join(array_constructor('a', 'b', 'c'), ',');
| array_join(array_constructor('a', 'b', 'c'), ',') |
| ------------------------------------------------- |
| a,b,c |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 |array.Type parameters. T means matching inputs and outputs use the same type.
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 |array.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 |array.Type parameters. T means matching inputs and outputs use the same type.
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 |array.SELECT array_mode(array_constructor(1, 2, 2, 3));
| array_mode(array_constructor(1, 2, 2, 3)) |
| ----------------------------------------- |
| 2 |array.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 |array.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 |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] |element in an array.Type parameters. T means matching inputs and outputs use the same type.
SELECT array_position(array_constructor('a', 'b', 'a'), 'a');
| array_position(array_constructor('a', 'b', 'a'), 'a') |
| ----------------------------------------------------- |
| 1 |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.
array or list. T means matching inputs and outputs use the same type.T means matching inputs and outputs use the same type. U is a second generic value type.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 |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.
array or list. T means matching inputs and outputs use the same type.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.element from an array.Type parameters. T means matching inputs and outputs use the same type.
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 |array with elements in reverse order.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 |Type parameters. E is the element type of the input array or list.
SELECT array_slice(array_constructor(1, 2, 3, 4), 2, 3);
| array_slice(array_constructor(1, 2, 3, 4), 2, 3) |
| ------------------------------------------------ |
| [2, 3, 4] |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.
SELECT array_sort(array_constructor(3, 1, 2));
| array_sort(array_constructor(3, 1, 2)) |
| -------------------------------------- |
| [1, 2, 3] |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.
SELECT array_sort_desc(array_constructor(3, 1, 2));
| array_sort_desc(array_constructor(3, 1, 2)) |
| ------------------------------------------- |
| [3, 2, 1] |array.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 |array.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 |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 |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.
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] |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 |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 |Type parameters. T means matching inputs and outputs use the same type.
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 |Type parameters. T means matching inputs and outputs use the same type.
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 |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.
SELECT cardinality(array_constructor(1, 2, 3));
| cardinality(array_constructor(1, 2, 3)) |
| --------------------------------------- |
| 3 |array.Type parameters. T means matching inputs and outputs use the same type.
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] |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 |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.
SELECT element_at(array_constructor('a', 'b'), 2);
| element_at(array_constructor('a', 'b'), 2) |
| ------------------------------------------ |
| b |array that matches the given predicate function.Type parameters. T means matching inputs and outputs use the same type.
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 |array that matches the given predicate function.Type parameters. T means matching inputs and outputs use the same type.
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 |array by one level, combining all sub-arrays into a single array.Type parameters. T means matching inputs and outputs use the same type.
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]] |Type parameters. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.
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 |Type parameters. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.
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 |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] |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 |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 |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 |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 |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 |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.
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 |list using a callback function predicate.Type parameters. T means matching inputs and outputs use the same type.
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 |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 |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 |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] |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 |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 |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 |SELECT array_mode(array_constructor(1, 2, 2, 3));
| array_mode(array_constructor(1, 2, 2, 3)) |
| ----------------------------------------- |
| 2 |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 |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 |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 |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] |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 |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 |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] |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 |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 |n) from an array.Type parameters. T means matching inputs and outputs use the same type.
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]] |index in a list.Type parameters. E is the element type of the input array or list.
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 |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] |Type parameters. E is the element type of the input array or list.
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] |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] |array.Type parameters. T means matching inputs and outputs use the same type.
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 |array.Type parameters. T means matching inputs and outputs use the same type.
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 |length.Type parameters. E is the element type of the input array or list.
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 |index in the array.Type parameters. T means matching inputs and outputs use the same type.
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 |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.
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] |n elements from the array.Type parameters. T means matching inputs and outputs use the same type.
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 |Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type.
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}] |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.
T means matching inputs and outputs use the same type.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.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] |Type parameters. E is the element type of the input array or list.
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 |