How we handle sensitive data in BigQuery
incident.io masks sensitive data in BigQuery by default: a daily Python job applies PII and confidential policy tags to every untagged STRING/BYTES column replicated by Fivetran, so humans see only SHA256-hashed values. Non-sensitive columns are allow-listed via PR-edited YAML files, and a slim run diffs against the previous YAML version stored in GCS so only affected tables are processed. dbt is split into a customer-facing pipeline with unmasked access and an internal analytics pipeline that persists masked values downstream. Tagging once at the source cuts human error, at the cost of being unable to derive non-sensitive values such as email domains. The job also syncs a Notion data catalogue and sends Slack alerts.
Related posts
- Updating our data stack
incident.io mediumAdeptincident.io's two-person data team reworked its BigQuery/dbt analytics stack as the company grew from 10 to 30 people. Fivetran moved to a separate BigQuery project after dbt tests in CI timed out because concurrent interactive queries exceeded BigQuery's 100-query quota. A CircleCI queue orb now serialises overlapping dbt runs that were creating and dropping the same tables. Unreliable GOOGLEFINANCE FX rates were replaced with a version-controlled seed plus a daily APILayer pull, checked by uniqueness and gaplessness tests. Models now materialise as tables rather than views, intermediate models sit between staging and fact/dimension models to avoid duplicated logic, SQLFluff enforces formatting, and Metabase folders separate sandbox work from locked-down core dashboards.
- How to Handle PII in Staging Databases Without Losing Realistic Data
Neon mediumAdept
Four common ways to get realistic but PII-safe staging data are compared, with code for each: manual CSV export plus Python anonymization scripts, Faker-based masking libraries with deterministic seeding to preserve referential integrity, fully synthetic data generators, and replication into staging with SQL masking views or the PostgreSQL Anonymizer extension (declarative security labels, dynamic masking, anonymized dumps, k-anonymity checks). Scripts and libraries break silently when schemas add new PII columns, synthetic data loses production's skew and messiness, and replication with masking is robust but operationally heavy. The recommended approach is Neon's copy-on-write branches combined with user-defined masking rules, so a masked staging copy of production can be created or refreshed cheaply.
- pg_redact: Content-aware PII redaction with Jev, enforced in Postgres
Neon mediumAdept
Column-level masking in Postgres can't redact PII buried in free text, and regex alone can't tell an SSN from an invoice number. pg_redact generates candidate spans with regex and capitalization rules, asks TypeSafe's Jev model to label each one (name, email, phone, address, id_number, none) with calibrated probabilities, and stores spans above 0.5 confidence as JSONB next to the message. A plpgsql redact() function compares each span's sensitivity rank against the caller's clearance, replacing longest spans first. Because labels and enforcement are decoupled, role clearances and sensitivity levels can change without reclassifying text.
- From one switch to a control panel: meet `dataCollection`
Sentry mediumAdeptSentry's JavaScript SDK v11 replaces the all-or-nothing `sendDefaultPii` boolean with `dataCollection`, a per-category config covering user info, cookies, HTTP headers and bodies, query params, GenAI inputs/outputs, database queries and more. The new defaults collect more than v10 did, including user info, cookies, truncated request/response bodies, GenAI I/O and DB query data. Sensitive values such as tokens and passwords are still filtered by a built-in denylist, and manually attached data is always sent. Users who had `sendDefaultPii: true` can simply delete it, while those relying on the old restrictive default must set explicit allow/deny options. Because span streaming is now on by default, span filtering should move to `beforeSendSpan` and `ignoreSpans`.
- Data stack 2024
incident.io mediumAdeptincident.io's 2024 data stack runs Fivetran and Segment into BigQuery, dbt (run via Docker on CircleCI) for transforms, and Hightouch for reverse ETL. Analysis is split across Omni for internal BI, Explo for customer-facing embedded insights, and Hex for ad-hoc notebook work. Omni was chosen for its layered schema, shared and workbook models, which balance governance with flexibility. Local dbt development got faster by uploading each production manifest.json to GCS and wrapping `--defer --state` in bash aliases. Data pipeline failures, including flaky retries, now declare incidents and page responders automatically through incident.io's own On-call product, with urgency based on customer impact.