---
title: "Warehouse SQL Templates, Leakage Audit Queries & SHA-256 Hash Tester | pltv.io"
description: "Read-only append-only SQL views for BigQuery, Snowflake, Databricks, and Redshift, plus backfilling leakage audit SQL, decile-skew readiness SQL, and a browser Web Crypto SHA-256 verifier."
url: https://pltv.io/sql
updated: 2026-12-05
maintainer: "Churney (https://churney.io)"
---

# Warehouse SQL Templates & PII Hash Tester

> Read-only, append-only SQL view templates for BigQuery, Snowflake, Databricks, and Redshift, plus backfilling leakage audit SQL, value-spread SQL, and a browser SHA-256 verifier at https://pltv.io/sql.

## 1. BigQuery Hashed Acquisition View

```sql
CREATE OR REPLACE VIEW `your_project.pltv_share.v_users_acquisition` AS
SELECT
  CAST(user_id AS STRING) AS user_id,
  TO_HEX(SHA256(LOWER(TRIM(email)))) AS email_sha256,
  TO_HEX(SHA256(REGEXP_REPLACE(TRIM(phone), r'[^0-9]', ''))) AS phone_sha256,
  created_at AS acquired_at_utc,
  fbp, fbc, gclid, wbraid, gbraid, ttclid,
  country_code, device_os
FROM `your_project.analytics.users`
WHERE created_at >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 730 DAY);
```

## 2. Diagnostic Queries

- **Leakage Check:** Compare `updated_at` vs `created_at` on user dimension tables; if rows mutate >24h after acquisition, reconstruct features strictly from append-only event logs.
- **Value Spread & Top-Decile Share:** Compute `p95 / p05` realized D90 revenue spread and top-10% customer share across a mature historical cohort (acquired 90-180 days ago).

## Frequently Asked Questions

### Why should pLTV warehouse views hash email and phone inside the warehouse?

Hashing normalized PII inside your own data warehouse (via SHA-256) ensures raw customer emails and phone numbers never leave your cloud environment while still matching Meta Conversions API and Google Enhanced Conversions requirements.

### How can I check if my warehouse tables have backfilling leakage?

Run the Leakage Audit SQL on this page: it compares updated_at timestamps against acquisition timestamps and flags mutable user attributes that were modified after Day 1. Features that mutate after score time must be reconstructed from append-only event logs.

### Does the SHA-256 hash tester on pltv.io send my input to a server?

No. It runs 100% locally in your browser using the native Web Crypto API (crypto.subtle.digest). Nothing is transmitted or logged.

---
Source: https://pltv.io/sql | Open technical reference maintained by Churney (https://churney.io).
