Knowledge Base
Working with Narrative ID in NQL
This reference details the NQL commands for encoding raw identifiers as Narrative IDs and translating them across partner-specific ID spaces.
Narrative enables privacy-safe collaboration between companies by providing a pseudonymous identifier called the Narrative ID. This ID supports secure data sharing by replacing clear text identifiers with pseudonymous IDs, thereby eliminating the risk of revealing personal identifiers.
For more information, please see What is Narrative ID?
Note that the key_id
parameter must be in single quotes in all commands (or selected from a table).
1. Encoding a Raw Identifier to a Narrative ID (narrative_id_encode
)
The narrative_id_encode
command securely encodes a raw identifier (e.g., hashed email or device ID) into a Narrative ID that is unique to a partner’s data space.
narrative_id_encode(raw_identifier, 'key_id')
- Parameters:
raw_identifier
: The raw identifier to be encoded (e.g., SHA256 hashed email).'key_id'
: The encoding key identifier in single quotes (e.g.,'AAAAAA'
).
- Example:
SELECT narrative_id_encode(sha256_hashed_email, 'AAAAAA') AS narrative_id FROM company_data.dataset_id
This command generates a unique encode Narrative ID for the given raw identifier and key_id
.
2. Translating a Narrative ID Across Partner Spaces (narrative_id_translate
)
The narrative_id_translate
command translates a Narrative ID from one partner’s ID space to another’s by specifying the receiving partner’s key_id
.
narrative_id_translate(narrative_id, 'key_id')
- Parameters:
narrative_id
: The Narrative ID produced bynarrative_id_encode
.'key_id'
: The receiving partner's encoding key identifier, in single quotes (e.g.,'BBBBBB'
).
- Example:
SELECT narrative_id_translate(narrative_id, 'BBBBBB') AS translated_narrative_id FROM partner_data.access_rule_id
This command transforms the Narrative ID into the format specific to the receiving partner’s key_id
, facilitating cross-partner data sharing.