Skip to main content

Narrative-specific functions

These functions are specific to the Narrative platform.

NORMALIZE_EMAIL

Normalizes an email address for consistent matching.
Normalization: Other addresses keep their periods and + tag: NORMALIZE_EMAIL('[email protected]') returns '[email protected]'. A value that can’t be parsed as an email address returns NULL.

NORMALIZE_PHONE

Normalizes a phone number to a standard format.
NORMALIZE_PHONE(format, phone, default_country) parses phone and writes it in format: E164, INTERNATIONAL, NATIONAL or RFC3966. It drops spaces, punctuation and extensions. default_country is the ISO country code to assume for a number written without +. With null, only numbers that carry their country code get a value:
Pick a default country only when every number without + is from that country. A national number from another country is read as the default country’s and comes out wrong: NORMALIZE_PHONE('E164', '07700 900013', 'US') returns '+107700900013'. It returns NULL for a value it can’t parse, such as '' or 'n/a'. It doesn’t check that the number exists: NORMALIZE_PHONE('E164', '0000000000', 'US') returns '+10000000000'.

HASH

Generates a hash from one or more values.

MD5 / SHA1 / SHA2

Standard cryptographic hash functions.

HMAC_SHA256

HMAC using SHA-256.

ADDRESS_HASHES

Generates hash variants for address matching.

NARRATIVE_ID_ENCODE

Encodes a clear text identifier into a Narrative ID within a specific encoding space. Narrative IDs are per-partner pseudonymous identifiers that enable privacy-safe data collaboration. Syntax:
Parameters: Returns: string - The encoded Narrative ID Examples:
The same identifier encoded with different key_id values produces different Narrative IDs. Always normalize identifiers (lowercase, trim whitespace) before encoding for consistent matching.
Related: Narrative ID Concepts, Using Narrative ID

NARRATIVE_ID_TRANSLATE

Translates a Narrative ID from one partner’s encoding space to another. This enables secure data collaboration by converting identifiers without exposing the underlying clear text values. Syntax:
Parameters: Returns: string - The translated Narrative ID in the target encoding space Examples:
Use case: When sharing data with a partner, translate your Narrative IDs to their encoding space so they can match against their own Narrative IDs. This enables cross-organization matching without exposing underlying identifiers. Related: Narrative ID Concepts, Using Narrative ID

UNIVERSE_SAMPLE

Deterministic sampling based on an identifier.

DETERMINISTIC_RAND

Generates a deterministic random number from a seed.

PARSE_JSON / TRY_PARSE_JSON

Parses a JSON string.

OBJECT_REMOVE_NULLS

Returns a struct with null-valued fields removed. On AWS hosted data planes, the function is accepted for cross-platform query compatibility but operates as a no-op.

TOKENIZE

Tokenizes text using a specified model.

TOKENIZE_SIZE

Returns the token count for text.

COSINE_SIMILARITY

Calculates the cosine similarity between two embeddings of the given dimension, such as two outputs of AI_EMBED from the same model.
Scores text relevance against a search query.

UUID_GENERATE

Generates a random UUID.

Aggregate Functions

GROUP BY computations

SELECT

DELTA tables and budget clauses

All Functions

Browse all function categories

NQL Design Philosophy

Why NQL extends standard SQL