Finds all matches of a regular expression pattern in a string and returns them as a list.
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Examples
SELECT boost_regexp_findall('[A-Z]{3}-[0-9]{4}', 'Blocked by ENG-1042; see also OPS-0077 and ENG-1190') AS ticket_refs;
| ticket_refs                    |
| ------------------------------ |
| [ENG-1042, OPS-0077, ENG-1190] |
SELECT boost_regexp_findall('[$]([0-9]+[.][0-9]{2})', 'UBER TRIP $23.40 + tip $5.00, refund $12.15') AS amounts;
| amounts              |
| -------------------- |
| [23.40, 5.00, 12.15] |
Searches for the first occurrence of a pattern in a string using the Boyer-Moore algorithm. Returns the 0-based byte offset of the first match, or -1 if not found.
Parameters
string:
large_string
The input string.
substring:
large_string
The substring to search for.
Examples
SELECT transform(ARRAY['REFUND AMAZON MKTPL', 'ACH DEBIT PAYROLL ACME CORP', 'POS REFUND TARGET #1123'], memo -> boyer_moore_search(memo, 'REFUND')) AS refund_offsets;
| refund_offsets |
| -------------- |
| [0, -1, 4]     |
SELECT substr('POS PURCHASE 04/12 WHOLEFDS MKT #10234 AUSTIN TX', boyer_moore_search('POS PURCHASE 04/12 WHOLEFDS MKT #10234 AUSTIN TX', '#') + 2, 5) AS store_number;
| store_number |
| ------------ |
| 10234        |
Converts an integer to its corresponding ASCII character.
Parameters
n:
int64
The Unicode code point to convert to a character.
Examples
SELECT replace('WIRE' || chr(9) || 'ACME CORP' || chr(9) || 'INV-2231', chr(9), ' | ') AS cleaned_memo;
| cleaned_memo                  |
| ----------------------------- |
| WIRE \| ACME CORP \| INV-2231 |
SELECT chr(65 + CAST(floor(0.47 * 5) AS BIGINT)) AS risk_grade;
| risk_grade |
| ---------- |
| C          |
Returns the Unicode code point of the only character of the string.
Examples
SELECT codepoint(substr('Émile Zola', 1, 1)) AS first_letter_codepoint;
| first_letter_codepoint |
| ---------------------- |
| 201                    |
SELECT codepoint(substr('🛒 Grocery run', 1, 1)) > 127 AS memo_starts_non_ascii;
| memo_starts_non_ascii |
| --------------------- |
| true                  |
Concatenates two or more strings or lists.

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

Examples
SELECT concat('feature', '_', 'store');
| concat('feature', '_', 'store') |
| ------------------------------- |
| feature_store                   |
Counts the number of non-overlapping regex matches in a string.
Examples
SELECT count_matches('Refund not received. REFUND requested twice; please refund ASAP', '(?i)\brefund') AS refund_mentions;
| refund_mentions |
| --------------- |
| 3               |
SELECT count_matches('Call me at 415-555-0123 or 415-555-0199, email jo@example.com', '\d{3}-\d{3}-\d{4}') AS phone_numbers;
| phone_numbers |
| ------------- |
| 2             |
Examples
SELECT editdist3('Amazon Mktplace', 'Amazon Marketplace') AS memo_edit_distance;
| memo_edit_distance |
| ------------------ |
| 3                  |
SELECT round(1.0 - editdist3(lower('Jon Smith'), lower('JOHN SMITH')) / CAST(greatest(length('Jon Smith'), length('JOHN SMITH')) AS DOUBLE), 2) AS name_similarity;
| name_similarity |
| --------------- |
| 0.9             |
Checks if a string ends with a specified suffix.
Parameters
string:
large_string
The input string.
substring:
large_string
The substring to search for.
Examples
SELECT ends_with('feature_store', 'store');
| ends_with('feature_store', 'store') |
| ----------------------------------- |
| true                                |
Returns the Hamming distance of string1 and string2, i.e. the number of positions at which the corresponding characters are different. Note that the two strings must have the same length.
Examples
SELECT hamming_distance('paypal.com', 'paypa1.com') AS lookalike_domain_edits;
| lookalike_domain_edits |
| ---------------------- |
| 1                      |
SELECT hamming_distance('1HGCM82633A004352', '1HGCM82633A004325') AS vin_char_mismatches;
| vin_char_mismatches |
| ------------------- |
| 2                   |
Case-insensitive like
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Examples
SELECT ilike('UBER *TRIP HELP.UBER.COM', '%uber%trip%') AS is_rideshare;
| is_rideshare |
| ------------ |
| true         |
SELECT ilike('Order SKU: tsh-blk-m', '%TSH-___-M') AS is_medium_tshirt;
| is_medium_tshirt |
| ---------------- |
| true             |
SELECT 'RE: Refund request for order #4521' ILIKE '%refund%' AS is_refund_ticket;
| is_refund_ticket |
| ---------------- |
| true             |
Alias for strpos.
Examples
SELECT strpos('chalk data', 'data');
| strpos('chalk data', 'data') |
| ---------------------------- |
| 7                            |
Calculates the Jaccard similarity coefficient between two strings based on character sets.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
Examples
SELECT round(jaccard_similarity(lower('AMZN Mktp US'), lower('Amazon Marketplace')), 3) AS merchant_name_similarity;
| merchant_name_similarity |
| ------------------------ |
| 0.533                    |
SELECT jaccard_similarity('listen', 'silent') AS anagram_similarity;
| anagram_similarity |
| ------------------ |
| 1.0                |
Calculates the Jaro similarity between two strings.
Parameters
a:
large_string
b:
large_string
Examples
SELECT round(jaro_similarity(lower('Jon Smith'), lower('JOHN SMITH')), 3) AS name_match;
| name_match |
| ---------- |
| 0.967      |
SELECT jaro_similarity(lower(trim('  Katherine Johnson')), lower('CATHERINE JOHNSON')) >= 0.9 AS payee_matches_account_holder;
| payee_matches_account_holder |
| ---------------------------- |
| true                         |
Calculates the Jaro-Winkler distance between two strings.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
The Jaro-Winkler prefix scaling factor.
Examples
SELECT round(jaro_winkler_distance(upper(trim('  Jonathon Smyth ')), 'JONATHAN SMITH', 0.1), 4) AS cardholder_name_distance;
| cardholder_name_distance |
| ------------------------ |
| 0.0571                   |
SELECT ARRAY[round(jaro_winkler_distance('MARTHA', 'MARHTA', 0.0), 4), round(jaro_winkler_distance('MARTHA', 'MARHTA', 0.1), 4), round(jaro_winkler_distance('MARTHA', 'MARHTA', 0.25), 4)] AS distance_by_prefix_weight;
| distance_by_prefix_weight |
| ------------------------- |
| [0.0556, 0.0389, 0.0139]  |
Calculates the Jaro-Winkler similarity between two strings.
Examples
SELECT round(jaro_winkler_similarity(lower('Jonathan Smith'), lower('JONATHON SMITH')), 3) AS cardholder_name_match;
| cardholder_name_match |
| --------------------- |
| 0.971                 |
SELECT round(jaro_winkler_similarity(lower('Jonathan Smith'), lower('JONATHON SMITH'), 0.0), 3) AS match_without_prefix_bonus;
| match_without_prefix_bonus |
| -------------------------- |
| 0.952                      |
Searches for the first occurrence of a pattern in a string using the Knuth-Morris-Pratt algorithm. Returns the 0-based byte offset of the first match, or -1 if not found.
Parameters
string:
large_string
The input string.
substring:
large_string
The substring to search for.
Examples
SELECT substr('ACH DEBIT VENMO PAYMENT REF:8841273', knuth_morris_pratt_search('ACH DEBIT VENMO PAYMENT REF:8841273', 'REF:') + 5) AS payment_ref;
| payment_ref |
| ----------- |
| 8841273     |
SELECT knuth_morris_pratt_search(lower('Where is my REFUND for order 5512?'), 'refund') >= 0 AS mentions_refund;
| mentions_refund |
| --------------- |
| true            |
Either:
  • Returns the length of the binary in bytes.
  • Returns the length of a string in characters.
  • Returns the number of elements in a list.

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

Examples
SELECT length('chalk');
| length('chalk') |
| --------------- |
| 5               |
Returns the byte length of a string.
Examples
SELECT len_bytes('Café ☕ order #42') AS memo_bytes;
| memo_bytes |
| ---------- |
| 19         |
SELECT len_bytes('Café ☕ order #42') > length('Café ☕ order #42') AS has_non_ascii;
| has_non_ascii |
| ------------- |
| true          |
Returns the length of a string, binary, array, or map.

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

Examples
SELECT length('chalk');
| length('chalk') |
| --------------- |
| 5               |
SELECT length(array_constructor(1, 2, 3));
| length(array_constructor(1, 2, 3)) |
| ---------------------------------- |
| 3                                  |
Examples
SELECT levenshtein('paypa1-secure.com', 'paypal-secure.com') AS email_domain_edit_distance;
| email_domain_edit_distance |
| -------------------------- |
| 1                          |
SELECT round(1.0 - CAST(levenshtein(lower('AMZN Mktplace'), lower('Amazon Marketplace')) AS DOUBLE) / greatest(length('AMZN Mktplace'), length('Amazon Marketplace')), 3) AS merchant_name_similarity;
| merchant_name_similarity |
| ------------------------ |
| 0.722                    |
Calculates the Levenshtein distance between two strings.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
Examples
SELECT levenshtein_distance('Jonathon Smyth', 'Jonathan Smith') AS name_edit_distance;
| name_edit_distance |
| ------------------ |
| 2                  |
SELECT round(1.0 - levenshtein_distance(lower('Acme Corp.'), lower('ACME Corporation')) / greatest(length('Acme Corp.'), length('ACME Corporation')), 3) AS merchant_name_similarity;
| merchant_name_similarity |
| ------------------------ |
| 0.563                    |
Checks if a string matches a pattern using SQL LIKE syntax with wildcards.
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Examples
SELECT like('ACH DEBIT NETFLIX.COM 866-579-7172', '%NETFLIX%') AS is_netflix_charge;
| is_netflix_charge |
| ----------------- |
| true              |
SELECT like('SKU-48210-XL', 'SKU-____-XL') AS matches_sku_format;
| matches_sku_format |
| ------------------ |
| false              |
SELECT like('Save 20% on your next order', '%20#%%', '#') AS mentions_20_pct_off;
| mentions_20_pct_off |
| ------------------- |
| true                |
Calculates the longest common subsequence between two strings.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
Examples
SELECT longest_common_subsequence(lower('AMZN MKTP US*2K4'), lower('amazon marketplace')) AS lcs_length;
| lcs_length |
| ---------- |
| 9          |
SELECT round(CAST(longest_common_subsequence(lower('Jonathan Smith'), lower('JON SMITH')) AS DOUBLE) / greatest(length('Jonathan Smith'), length('JON SMITH')), 2) AS name_match_score;
| name_match_score |
| ---------------- |
| 0.64             |
Converts a string to lowercase.
Parameters
string:
large_string
The input string.
Examples
SELECT lower('Chalk');
| lower('Chalk') |
| -------------- |
| chalk          |
Left pads a string or binary value to a target length.
Examples
SELECT lpad('42', 5, '0');
| lpad('42', 5, '0') |
| ------------------ |
| 00042              |
Removes whitespace or specified characters from the left side of a string.
Examples
SELECT ltrim('  chalk');
| ltrim('  chalk') |
| ---------------- |
| chalk            |
Render a Jinja2 template using the provided JSON context via minijinja.
Examples
SELECT minijinja_render('Classify this transaction memo: "{{ memo }}" (amount: ${{ amount }}, merchant: {{ merchant|upper }})', '{"memo": "UBER *TRIP 8XK2", "amount": 23.5, "merchant": "uber"}') AS llm_prompt;
| llm_prompt                                                                        |
| --------------------------------------------------------------------------------- |
| Classify this transaction memo: "UBER *TRIP 8XK2" (amount: $23.5, merchant: UBER) |
SELECT minijinja_render('{% if score >= 0.8 %}HIGH{% elif score >= 0.5 %}MEDIUM{% else %}LOW{% endif %} risk: {{ flags|join(", ") }}', '{"score": 0.86, "flags": ["new_device", "foreign_ip"]}') AS risk_summary;
| risk_summary                      |
| --------------------------------- |
| HIGH risk: new_device, foreign_ip |
Normalizes a string using a Unicode normalization form.
Examples
SELECT normalize('chalk');
| normalize('chalk') |
| ------------------ |
| chalk              |
Returns the byte length of a string or binary value.
Examples
SELECT octet_length('chalk');
| octet_length('chalk') |
| --------------------- |
| 5                     |
Calculates the partial ratio similarity between two strings using fuzzy matching.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
Examples
SELECT partial_ratio('starbucks', lower('SQ *STARBUCKS STORE #1234 SEATTLE WA')) AS merchant_match_score;
| merchant_match_score |
| -------------------- |
| 100.0                |
SELECT round(partial_ratio('starbucks', lower('SQ *STARBUKS COFFEE SEATTLE WA')), 1) AS merchant_match_score;
| merchant_match_score |
| -------------------- |
| 88.9                 |
SELECT partial_ratio('starbucks', 'SQ *STARBUCKS STORE #1234 SEATTLE WA') AS case_sensitive_score;
| case_sensitive_score |
| -------------------- |
| 0.0                  |
Alias for starts_with.
Examples
SELECT starts_with('feature_store', 'feature');
| starts_with('feature_store', 'feature') |
| --------------------------------------- |
| true                                    |
Returns true if all characters in the string are alphanumeric and there is at least one character, matching Python's str.isalnum() behavior.
Examples
SELECT transform(ARRAY['SAVE20', 'SAVE-20', 'save 20', ''], code -> python_is_alnum(code)) AS promo_code_is_alnum;
| promo_code_is_alnum         |
| --------------------------- |
| [true, false, false, false] |
SELECT transform(ARRAY['José99', '東京2024', 'x²', 'user_1'], handle -> python_is_alnum(handle)) AS handle_is_alnum;
| handle_is_alnum           |
| ------------------------- |
| [true, true, true, false] |
Returns true if all characters in the string are alphabetic and there is at least one character, matching Python's str.isalpha() behavior.
Examples
SELECT transform(ARRAY['Zoë', 'Ελλάδα', 'O''Brien', 'Mary Ann', 'R2D2', ''], n -> python_is_alpha(n)) AS valid_given_name;
| valid_given_name                         |
| ---------------------------------------- |
| [true, true, false, false, false, false] |
SELECT python_is_alpha(regexp_replace('Jean-Luc O''Néill', '[\s''-]', '')) AS full_name_is_letters;
| full_name_is_letters |
| -------------------- |
| true                 |
Returns true if all characters are digit characters and there is at least one character, matching Python's str.isdigit() behavior.
Examples
SELECT python_is_digit(replace('4111-1111-1111-1111', '-', '')) AS is_numeric_card;
| is_numeric_card |
| --------------- |
| true            |
SELECT transform(ARRAY['94107', '9410A', '-42', '3.14', '', '²'], z -> python_is_digit(z)) AS is_digit_flags;
| is_digit_flags                           |
| ---------------------------------------- |
| [true, false, false, false, false, true] |
Returns true if all cased characters are lowercase and there is at least one cased character, matching Python's str.islower() behavior.
Examples
SELECT transform(ARRAY['refund issued', 'URGENT: Call Me', 'order #48213 shipped', '12345'], s -> python_is_lower(s)) AS is_lower;
| is_lower                   |
| -------------------------- |
| [true, false, true, false] |
Returns true if all characters are numeric characters and there is at least one character, matching Python's str.isnumeric() behavior.
Examples
SELECT CASE WHEN python_is_numeric(split_part('ACH PMT 4471 REF 20240115', ' ', 3)) THEN CAST(split_part('ACH PMT 4471 REF 20240115', ' ', 3) AS BIGINT) END AS payee_id;
| payee_id |
| -------- |
| 4471     |
SELECT transform(ARRAY['94107', '12.50', '-3', '', '½', 'Ⅻ', '٣٤'], s -> python_is_numeric(s)) AS is_numeric;
| is_numeric                                    |
| --------------------------------------------- |
| [true, false, false, false, true, true, true] |
Returns true if all characters are whitespace and there is at least one character, matching Python's str.isspace() behavior.
Examples
SELECT python_is_space(chr(9) || '   ' || chr(13) || chr(10)) AS ticket_body_is_blank;
| ticket_body_is_blank |
| -------------------- |
| true                 |
SELECT transform(ARRAY['  ' || chr(9) || chr(10), '', ' refund pls '], memo -> python_is_space(memo)) AS memo_is_blank;
| memo_is_blank        |
| -------------------- |
| [true, false, false] |
SELECT python_is_space(chr(160) || chr(8195)) AS unicode_space;
| unicode_space |
| ------------- |
| true          |
Returns true if the string is titlecased and there is at least one cased character, matching Python's str.istitle() behavior.
Examples
SELECT transform(ARRAY['Wireless Mouse', 'wireless mouse', 'USB-C Cable', 'iPhone Case', '2024 Model', 'ACME'], t -> python_is_title(t)) AS is_title_case;
| is_title_case                            |
| ---------------------------------------- |
| [true, false, false, false, true, false] |
SELECT CASE WHEN python_is_title('Mary-Jane O''Brien') THEN 'clean' ELSE 'needs_normalization' END AS name_entry_quality;
| name_entry_quality |
| ------------------ |
| clean              |
Returns true if all cased characters are uppercase and there is at least one cased character, matching Python's str.isupper() behavior.
Examples
SELECT python_is_upper('URGENT: REFUND ORDER #4471 NOW!!') AS is_all_caps_ticket;
| is_all_caps_ticket |
| ------------------ |
| true               |
SELECT python_is_upper('4471-0092') AS is_all_caps_ticket;
| is_all_caps_ticket |
| ------------------ |
| false              |
Strips leading Python whitespace (Unicode-aware), matching Python's str.lstrip() with no arguments.
Examples
SELECT starts_with(python_lstrip(chr(160) || chr(9) || ' REFUND: duplicate charge'), 'REFUND') AS is_refund_memo;
| is_refund_memo |
| -------------- |
| true           |
SELECT '[' || python_lstrip(chr(160) || chr(12288) || '  Refund for order #8812  ') || ']' AS cleaned_memo;
| cleaned_memo               |
| -------------------------- |
| [Refund for order #8812  ] |
Removes the prefix from the string if present, matching Python's str.removeprefix().
Examples
SELECT transform(ARRAY['POS DEBIT STARBUCKS #1123', 'ACH PAYROLL ACME INC'], m -> python_remove_prefix(m, 'POS DEBIT ')) AS merchants;
| merchants                               |
| --------------------------------------- |
| [STARBUCKS #1123, ACH PAYROLL ACME INC] |
SELECT python_remove_prefix('Re: Re: Refund request #4821', 'Re: ') AS ticket_subject;
| ticket_subject           |
| ------------------------ |
| Re: Refund request #4821 |
Removes the suffix from the string if present, matching Python's str.removesuffix().
Examples
SELECT python_remove_suffix('Acme Corp Inc.', ' Inc.') AS merchant_name;
| merchant_name |
| ------------- |
| Acme Corp     |
SELECT transform(ARRAY['events_2024.csv', 'events_2025.parquet', 'users.csv'], f -> python_remove_suffix(f, '.csv')) AS table_names;
| table_names                               |
| ----------------------------------------- |
| [events_2024, events_2025.parquet, users] |
Strips trailing Python whitespace (Unicode-aware), matching Python's str.rstrip() with no arguments.
Examples
SELECT '[' || python_rstrip('  UBER *TRIP HELP.UBER.COM' || chr(160) || chr(12288) || chr(13) || chr(10)) || ']' AS cleaned_memo;
| cleaned_memo                 |
| ---------------------------- |
| [  UBER *TRIP HELP.UBER.COM] |
SELECT python_rstrip('Wireless Earbuds' || chr(160)) = 'Wireless Earbuds' AS matches_catalog_title;
| matches_catalog_title |
| --------------------- |
| true                  |
Slices a string with exact Python s[start:stop:step] semantics. All integer arguments are nullable (NULL = Python None / unspecified).
Examples
SELECT python_string_slice('4111111111111111', -4, NULL, NULL) AS card_last4;
| card_last4 |
| ---------- |
| 1111       |
SELECT python_string_slice('2024-03-15T09:30:00Z', 5, -10, NULL) AS month_day;
| month_day |
| --------- |
| 03-15     |
SELECT python_string_slice('A1B2C3D4', 1, NULL, 2) AS digits;
| digits |
| ------ |
| 1234   |
Strips leading and trailing Python whitespace (Unicode-aware), matching Python's str.strip() with no arguments.
Examples
SELECT python_strip(chr(160) || '  Wireless Mouse - Black' || chr(9) || chr(10)) AS product_title;
| product_title          |
| ---------------------- |
| Wireless Mouse - Black |
SELECT python_strip(chr(160) || ' ACME COFFEE ' || chr(9) || chr(10)) = 'ACME COFFEE' AS memo_matches_merchant;
| memo_matches_merchant |
| --------------------- |
| true                  |
SELECT nullif(python_strip(chr(12288) || chr(10) || chr(9) || '  '), '') IS NULL AS is_blank_note;
| is_blank_note |
| ------------- |
| true          |
Returns the first substring matched by a regular expression.
Examples
SELECT regexp_extract('user_123', 'user_([0-9]+)', 1);
| regexp_extract('user_123', 'user_([0-9]+)', 1) |
| ---------------------------------------------- |
| 123                                            |
Returns all substrings matched by a regular expression.
Examples
SELECT regexp_extract_all('a1 b2 c3', '[a-z][0-9]');
| regexp_extract_all('a1 b2 c3', '[a-z][0-9]') |
| -------------------------------------------- |
| [a1, b2, c3]                                 |
Checks if a string matches a regular expression pattern.
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Examples
SELECT regexp_full_match('POS PURCHASE STARBUCKS #4471 SEATTLE WA', '(?i)starbucks|dunkin|peet''s') AS is_coffee_shop;
| is_coffee_shop |
| -------------- |
| true           |
SELECT regexp_full_match('ORD-2024-00981-RETRY', '^ORD-[0-9]{4}-[0-9]{5}$') AS is_valid_order_id;
| is_valid_order_id |
| ----------------- |
| false             |
Checks if a string matches a regular expression pattern.
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Examples
SELECT regexp_like('user_123', '^user_[0-9]+$');
| regexp_like('user_123', '^user_[0-9]+$') |
| ---------------------------------------- |
| true                                     |
Alias for regexp_like.
Examples
SELECT regexp_like('user_123', '^user_[0-9]+$');
| regexp_like('user_123', '^user_[0-9]+$') |
| ---------------------------------------- |
| true                                     |
Replaces or removes substrings matched by a regular expression.
Examples
SELECT regexp_replace('user_123', '[0-9]+', '456');
| regexp_replace('user_123', '[0-9]+', '456') |
| ------------------------------------------- |
| user_456                                    |
Splits ``string`` using the regular expression ``pattern`` into a list of strings.
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Examples
SELECT regexp_split('POS PURCHASE*STARBUCKS #1234  SEATTLE WA', '[\s*#]+') AS memo_tokens;
| memo_tokens                                   |
| --------------------------------------------- |
| [POS, PURCHASE, STARBUCKS, 1234, SEATTLE, WA] |
SELECT cardinality(regexp_split('My order never arrived and support has not replied in 3 days', '\s+')) AS ticket_word_count;
| ticket_word_count |
| ----------------- |
| 12                |
Alias for regexp_split.
Examples
SELECT regexp_split_to_array('ACH DEBIT | PAYROLL;ACME CORP  |ref#88213', '\s*[|;]\s*') AS memo_parts;
| memo_parts                                 |
| ------------------------------------------ |
| [ACH DEBIT, PAYROLL, ACME CORP, ref#88213] |
SELECT cardinality(regexp_split_to_array('Wireless noise-cancelling over-ear headphones', '[\s-]+')) AS title_token_count;
| title_token_count |
| ----------------- |
| 6                 |
Replaces or removes occurrences of a substring.
Examples
SELECT replace('hello chalk', 'hello', 'hi');
| replace('hello chalk', 'hello', 'hi') |
| ------------------------------------- |
| hi chalk                              |
Reverses a string, binary value, or array.

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

Examples
SELECT reverse('chalk');
| reverse('chalk') |
| ---------------- |
| klahc            |
Right pads a string or binary value to a target length.
Examples
SELECT rpad('42', 5, '0');
| rpad('42', 5, '0') |
| ------------------ |
| 42000              |
Removes whitespace or specified characters from the right side of a string.
Examples
SELECT rtrim('chalk  ');
| rtrim('chalk  ') |
| ---------------- |
| chalk            |
Computes the similarity ratio between two strings using sequence matching.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
Examples
SELECT round(sequence_matcher_ratio(lower(trim('  Jonathan Smith ')), lower(trim('JONATHAN SMYTH'))), 3) AS payee_name_similarity;
| payee_name_similarity |
| --------------------- |
| 0.929                 |
SELECT round(sequence_matcher_ratio('Jonathan Smith', 'JONATHAN SMITH'), 3) AS raw_ratio;
| raw_ratio |
| --------- |
| 0.214     |
Splits a string by a delimiter, optionally limiting the number of splits.
Examples
SELECT split('a,b,c', ',');
| split('a,b,c', ',') |
| ------------------- |
| [a, b, c]           |
Splits a string by delimiter and returns the part at the specified index (1-based).
Parameters
string:
large_string
The input string.
delimiter:
large_string
The delimiter used to split or join the string.
index:
int64
The index to read.
Examples
SELECT split_part('features.user.id', '.', 2);
| split_part('features.user.id', '.', 2) |
| -------------------------------------- |
| user                                   |
Checks if a string starts with a specified prefix.
Parameters
string:
large_string
The input string.
substring:
large_string
The substring to search for.
Examples
SELECT starts_with('feature_store', 'feature');
| starts_with('feature_store', 'feature') |
| --------------------------------------- |
| true                                    |
Alias for split.
Examples
SELECT element_at(str_split('electronics>computers>laptops', '>'), -1) AS leaf_category;
| leaf_category |
| ------------- |
| laptops       |
SELECT str_split('ERROR: payment failed: card declined', ': ', 2) AS level_and_message;
| level_and_message                      |
| -------------------------------------- |
| [ERROR, payment failed: card declined] |
Alias for regexp_split.
Examples
SELECT str_split_regex('wireless headphones, noise-cancelling;  bluetooth 5.3 |black', '\s*[,;|]\s*') AS product_tags;
| product_tags                                                  |
| ------------------------------------------------------------- |
| [wireless headphones, noise-cancelling, bluetooth 5.3, black] |
SELECT str_split_regex('POS PURCHASE #4821 STARBUCKS STORE 1123', '\s*#\d+\s*')[2] AS merchant_part;
| merchant_part        |
| -------------------- |
| STARBUCKS STORE 1123 |
Alias for split.
Examples
SELECT element_at(string_split('POS PURCHASE*STARBUCKS #1042*SEATTLE WA', '*'), 2) AS merchant_name;
| merchant_name   |
| --------------- |
| STARBUCKS #1042 |
SELECT string_split('DECLINED:card_issuer:Insufficient funds: retry after 24h', ':', 3) AS decline_parts;
| decline_parts                                                |
| ------------------------------------------------------------ |
| [DECLINED, card_issuer, Insufficient funds: retry after 24h] |
Alias for regexp_split.
Examples
SELECT string_split_regex('organic, gluten-free;vegan |  non-gmo', '\s*[,;|]\s*') AS product_tags;
| product_tags                           |
| -------------------------------------- |
| [organic, gluten-free, vegan, non-gmo] |
SELECT element_at(string_split_regex('POS PURCHASE   STARBUCKS #4821   SEATTLE WA', '\s{2,}'), 2) AS merchant_name;
| merchant_name   |
| --------------- |
| STARBUCKS #4821 |
Alias for split.
Examples
SELECT element_at(string_to_array('Electronics > Computers > Laptops', ' > '), -1) AS leaf_category;
| leaf_category |
| ------------- |
| Laptops       |
SELECT string_to_array('POS PURCHASE*STARBUCKS #1234*SEATTLE WA', '*', 2) AS memo_parts;
| memo_parts                                 |
| ------------------------------------------ |
| [POS PURCHASE, STARBUCKS #1234*SEATTLE WA] |
Alias for from_base64.
Examples
SELECT json_extract_scalar(from_utf8(string_to_bytes_base64('eyJldmVudCI6ImNoYXJnZS5zdWNjZWVkZWQiLCJhbW91bnQiOjQyMDB9')), '$.event') AS event_type;
| event_type       |
| ---------------- |
| charge.succeeded |
SELECT length(string_to_bytes_base64('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==')) AS image_num_bytes;
| image_num_bytes |
| --------------- |
| 70              |
Alias for from_hex.
Examples
SELECT string_to_bytes_hex('92ef9352c4a90c97d49718afa80788b91c407e18729a267a16b866d9bf3bc243') = sha256(to_utf8('{"order_id":1042,"amount":59.99}')) AS payload_digest_matches;
| payload_digest_matches |
| ---------------------- |
| true                   |
SELECT from_utf8(string_to_bytes_hex('636172645f7465737465645f3432')) AS decoded_event;
| decoded_event  |
| -------------- |
| card_tested_42 |
Alias for to_utf8.
Examples
SELECT length(string_to_bytes_utf8('Café ☕ München')) AS memo_byte_length;
| memo_byte_length |
| ---------------- |
| 18               |
SELECT to_hex(sha256(string_to_bytes_utf8('user@example.com'))) AS email_sha256;
| email_sha256                                                     |
| ---------------------------------------------------------------- |
| b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514 |
Returns the position of a substring within a string.
Examples
SELECT strpos('chalk data', 'data');
| strpos('chalk data', 'data') |
| ---------------------------- |
| 7                            |
Returns the position of the last matching substring within a string.
Examples
SELECT strrpos('chalk data data', 'data');
| strrpos('chalk data data', 'data') |
| ---------------------------------- |
| 12                                 |
Returns a substring starting at the specified position, optionally with a specified length.
Examples
SELECT substr('feature_store', 9);
| substr('feature_store', 9) |
| -------------------------- |
| store                      |
SELECT substr('feature_store', 1, 7);
| substr('feature_store', 1, 7) |
| ----------------------------- |
| feature                       |
Alias for substr.
Examples
SELECT substr('feature_store', 9);
| substr('feature_store', 9) |
| -------------------------- |
| store                      |
SELECT substr('feature_store', 1, 7);
| substr('feature_store', 1, 7) |
| ----------------------------- |
| feature                       |
Alias for ends_with.
Examples
SELECT ends_with('feature_store', 'store');
| ends_with('feature_store', 'store') |
| ----------------------------------- |
| true                                |
Converts a string to title case.
Examples
SELECT titlecase(trim('  BLUE BOTTLE coffee   ')) AS merchant_name;
| merchant_name      |
| ------------------ |
| Blue Bottle Coffee |
SELECT titlecase('mary-jane o''brien') AS customer_name;
| customer_name     |
| ----------------- |
| Mary-jane O'brien |
Calculates the token set ratio similarity between two strings using fuzzy matching.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
Examples
SELECT token_set_ratio(lower('Starbucks Coffee Store 1234 Seattle'), lower('STARBUCKS COFFEE')) AS merchant_match_score;
| merchant_match_score |
| -------------------- |
| 100.0                |
SELECT round(token_set_ratio(lower('Sony WH-1000XM5 Wireless Headphones Black'), lower('Sony WH-1000XM4 Wireless Headphones')), 1) AS title_similarity;
| title_similarity |
| ---------------- |
| 89.5             |
SELECT token_set_ratio('Starbucks Coffee', 'STARBUCKS COFFEE') AS case_sensitive_score;
| case_sensitive_score |
| -------------------- |
| 18.75                |
Calculates the token sort ratio similarity between two strings using fuzzy matching.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
Examples
SELECT token_sort_ratio('john a smith', 'smith john a') AS name_match_score;
| name_match_score |
| ---------------- |
| 100.0            |
SELECT token_sort_ratio(lower('Acme Corp Payroll Deposit'), lower('PAYROLL DEPOSIT ACME CORP')) >= 90 AS is_same_payee;
| is_same_payee |
| ------------- |
| true          |
Returns the last N characters of the input string, up to at most the length of string.
Examples
SELECT concat('**** **** **** ', trail('4111 1111 1111 4242', 4)) AS masked_card;
| masked_card         |
| ------------------- |
| **** **** **** 4242 |
SELECT trail('MX', 5) AS short_code_tail;
| short_code_tail |
| --------------- |
| MX              |
Removes whitespace or specified characters from both ends of a string.
Examples
SELECT trim('  chalk  ');
| trim('  chalk  ') |
| ----------------- |
| chalk             |
SELECT trim('xychalkyx', 'xy');
| trim('xychalkyx', 'xy') |
| ----------------------- |
| chalk                   |
Normalizes Unicode characters to their closest ASCII equivalents with whitespace normalization.
Parameters
string:
large_string
The input string.
Converts Unicode characters to their closest ASCII equivalents.
Parameters
string:
large_string
The input string.
Converts a string to uppercase.
Parameters
string:
large_string
The input string.
Examples
SELECT upper('chalk');
| upper('chalk') |
| -------------- |
| CHALK          |
Generates a UUID string: a random version 4 UUID with no arguments, or the deterministic version 5 UUID of a name within a namespace UUID with two arguments.
Examples
SELECT uuid_string();
SELECT uuid_string('fe971b24-9572-4005-b22f-351e9c09274d', 'chalk');
Returns the stem of a word using stemming algorithms.
Examples
SELECT array_join(transform(split(lower('Customer requested refunds after charges were disputed'), ' '), w -> word_stem(w)), ' ') AS stemmed_memo;
| stemmed_memo                                  |
| --------------------------------------------- |
| custom request refund after charg were disput |
SELECT word_stem('Zahlungen', 'de') AS stem_de;
| stem_de |
| ------- |
| zahlung |
Left-pads a string with zeros to the given width.
Examples
SELECT zfill(CAST(2134 AS VARCHAR), 5) AS zip_code;
| zip_code |
| -------- |
| 02134    |
SELECT zfill('-42', 6) AS signed_offset;
| signed_offset |
| ------------- |
| -00042        |
Splits a string by delimiter and returns the part at the specified zero-based index.
Parameters
string:
large_string
The input string.
delimiter:
large_string
The delimiter used to split or join the string.
index:
int64
The index to read.
Examples
SELECT lower(zi_split_part('Jane.Doe@Example.COM', '@', 1)) AS email_domain;
| email_domain |
| ------------ |
| example.com  |
SELECT zi_split_part('POS 4821 STARBUCKS #1123 SEATTLE WA', ' ', 2) AS merchant;
| merchant  |
| --------- |
| STARBUCKS |
SELECT coalesce(zi_split_part('electronics>audio', '>', 2), 'none') AS third_level_category;
| third_level_category |
| -------------------- |
| none                 |
operator alias for not like
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Examples
SELECT lower('REFUND - Order #48213') !~~ 'refund%' AS is_purchase;
| is_purchase |
| ----------- |
| false       |
SELECT 'SKU-A1-RED' !~~ 'SKU-___-%' AS bad_sku_format;
| bad_sku_format |
| -------------- |
| true           |
operator alias for not ilike
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Examples
SELECT 'Hi, I need a REFUND for order 88123' !~~* '%refund%' AS is_not_refund_request;
| is_not_refund_request |
| --------------------- |
| false                 |
SELECT 'promo10' !~~* 'PROMO__' AS fails_promo_code_format;
| fails_promo_code_format |
| ----------------------- |
| false                   |
Alias for starts_with.
Examples
SELECT starts_with('feature_store', 'feature');
| starts_with('feature_store', 'feature') |
| --------------------------------------- |
| true                                    |
Alias for concat.
Examples
SELECT 'MERCH-' || upper('acme coffee') || '-' || CAST(42 AS VARCHAR) AS merchant_key;
| merchant_key         |
| -------------------- |
| MERCH-ACME COFFEE-42 |
SELECT 'Title: ' || 'Wireless Earbuds' || ' | Brand: ' || coalesce(NULL, 'unknown') AS embedding_input;
| embedding_input                           |
| ----------------------------------------- |
| Title: Wireless Earbuds \| Brand: unknown |
operator alias for like
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Examples
SELECT 'POS PURCHASE STARBUCKS #1234 SEATTLE WA' ~~ '%STARBUCKS%' AS is_coffee_purchase;
| is_coffee_purchase |
| ------------------ |
| true               |
SELECT lower('Pos Purchase STARBUCKS #1234') ~~ '%starbucks%' AS is_coffee_purchase;
| is_coffee_purchase |
| ------------------ |
| true               |
SELECT 'ORD-2024-A7' ~~ 'ORD-____-__' AS is_valid_order_id;
| is_valid_order_id |
| ----------------- |
| true              |
Case-insensitive like
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Examples
SELECT 'Payment to UBER *TRIP 8821' ~~* '%uber%trip%' AS is_rideshare;
| is_rideshare |
| ------------ |
| true         |
SELECT 'sku-ab12-RED' ~~* 'SKU-__12-%' AS is_ab12_family;
| is_ab12_family |
| -------------- |
| true           |