Privacy-First Analytical Data Masking
Analytical workloads — reporting dashboards, BI tools, ad-hoc queries by analysts — need to see operational data without seeing the personally identifiable information (PII) within it. The wrong pattern is "export to a data warehouse, scrub the PII there, point the analytics tools at the scrubbed copy." That copy is a perpetual liability: another data store to govern, another retention surface, another place for a leak.
The right pattern is masking at query time. The PII stays in the canonical store, encrypted and policy-protected. Analytical queries see a view that masks the PII fields — same query syntax, same query latency, but the analyst's SELECT returns ***-**-6789 where the SSN would be, re****@example.com where the email would be, [REDACTED] where the medical condition would be.
This tutorial walks through configuring a masked analytical view over a customers collection.
Prerequisites
- A Pathmaker-role account on the project
- A
customerscollection with PII fields (e.g.,ssn,email,phone,birth_date) - The Warden's data-classification policy declared (which fields are PII, what the classification level is)
Step 1 — Identify the analytical surface
Analytical views in the platform are first-class objects, distinct from raw collections. Each view declares:
- The source collection(s)
- The visible columns (which can be raw, masked, or derived)
- The audience (which roles can query this view)
- The masking policy per visible column
Open the Console and navigate to Data → Analytical views → New view. Give it a name (customers-analytical-masked), and select customers as the source.
Step 2 — Configure the column visibility
The view editor lists the source collection's columns. For each, choose the visibility:
| Column | Visibility | Mask spec |
|---|---|---|
id | Visible | (none) |
name | Masked | First-letter + asterisks: J*** D** |
email | Masked | Local part redacted: re****@example.com |
phone | Masked | All but last 4: ***-***-1234 |
ssn | Masked | All but last 4: ***-**-6789 |
birth_date | Truncated | Year only: 1985 |
country | Visible | (geographic aggregate is useful for analytics) |
signup_date | Visible | (temporal aggregate) |
lifetime_value | Visible | (numeric aggregate) |
Each visibility option compiles to a different SQL-side transformation:
- Visible — column passes through unchanged
- Masked — column passes through a masking function appropriate to the data shape
- Truncated — column is reduced to a less-specific value (year from date, country from address)
- Hashed — column is replaced with a stable hash (useful for join keys without exposing the underlying value)
- Excluded — column does not appear in the view at all
The masking happens at the database, inside the view's projection. The analyst's query syntax does not have to know about the masking; they SELECT * and get masked output.
Step 3 — Inherit the Warden's classification policy
If the Warden has declared a project-wide data classification policy, the analytical-view composer can inherit it:
Click "Inherit classification policy".
The editor automatically suggests the right visibility per column based on the column's classification level:
| Classification | Suggested visibility |
|---|---|
pii_direct (SSN, full name, full address) | Masked or excluded |
pii_quasi (birth date, ZIP code, ethnicity) | Truncated |
pii_pseudonymous (hashed identifiers) | Visible |
non_pii (counts, aggregates, classifications) | Visible |
The suggestions are starting points; you can override them per-view. But starting from the Warden's classification ensures the analytical surface is consistent with the org's privacy policy.
Step 4 — Set the audience
In the view configuration, set the access policy:
access:
query: [analyst, data-scientist]
no_export: true # rows from this view cannot be exported to CSV
The no_export flag prevents bulk extraction. An analyst can run queries against the view interactively (rows on screen, charts in dashboards) but cannot pull the data into a local CSV or spreadsheet that escapes the platform's visibility controls. The flag is enforced at the platform layer, not by application code.
Step 5 — Save and test
Save the view. The composer compiles it to a database view (PostgreSQL) plus a policy-layer enforcement check. Open the Console's SQL playground:
SELECT name, email, ssn, signup_date, lifetime_value
FROM customers_analytical_masked
WHERE signup_date >= '2025-01-01'
LIMIT 5;
Result:
name | email | ssn | signup_date | lifetime_value
----------+-----------------------+-------------+-------------+---------------
A**** L** | al****@example.com | ***-**-6789 | 2025-01-15 | 12500.00
B*** M*** | be****@example.com | ***-**-4321 | 2025-02-03 | 8200.00
C***** N** | ca****@example.com | ***-**-9876 | 2025-02-22 | 25000.00
The masking is applied at the database; the result set is what the analytical-tool query sees. Bridges to external BI tools (Looker, Tableau, Metabase) see the same masked output via the standard psql connector.
Step 6 — Audit the view's usage
Every query against the masked view appears in the audit log as a normal data event, with the view name as the resource and the masking policy version recorded:
event: data.read
resource: customers_analytical_masked
subject: usr_analyst_42
masking_policy: customers-pii-mask-v3 (active)
rows_returned: 247
The audit chain ties analytical usage to specific subjects. If an analyst's queries spike anomalously, the chain surfaces it.
Step 7 — Iterate when the classification policy changes
The Warden may add a new PII field to the canonical schema (e.g., customers.health_condition). When the classification updates, your analytical view's Inherit classification policy action surfaces a notification: "the source collection has a new pii_sensitive field; update this view to include or exclude it."
The view does not automatically expose new columns — exposure is always explicit. But the classification surfaces the gap so you can decide. This is the structural complement to the runtime masking: schema evolution does not silently leak new PII into analytical surfaces.
What just happened
You added a privacy-respecting analytical surface over a PII-bearing collection without:
- Maintaining a separate scrubbed copy of the data
- Writing application-side scrubbing code
- Trusting analysts to remember which fields they shouldn't see
- Risking PII leakage through exported CSVs
The masking is structural: it happens at the database, inside the view, enforced by the platform. The Warden's classification policy is the source of truth for what's sensitive; the view inherits it; the audit trail records every query against the masked surface.
Next
- Identity-Native Telemetry Mapping — compose Lookout dashboards over the masked view.
- Building Custom Branded Login Pages — earlier in the Pathmaker workflow series.
- Guides → Unified Policy — the policy layer that backs masking enforcement.