Skip to main content

Quickstart

Learn Tabular in 5 minutes with a complete validation pipeline.


Step 1: Load the Extension

LOAD anofox_tabular;

Step 2: Create Sample Customer Data

CREATE TABLE customers AS
SELECT
1 as customer_id, 'john.doe@example.com' as email, 'DE123456789' as vat_id, 1500.50 as amount
UNION ALL
SELECT 2, 'invalid.email@', 'FR12345678', 2000.00
UNION ALL
SELECT 3, 'jane@company.org', 'INVALID', -50.00
UNION ALL
SELECT 4, 'bob+test@domain.co.uk', 'GB123456789', 3500.75;

Step 3: Validate Emails

SELECT
customer_id,
email,
anofox_email_validate(email, 'regex') as regex_valid,
anofox_email_validate(email, 'dns') as dns_valid
FROM customers;

Output:

customer_id | email                     | regex_valid | dns_valid
1 | john.doe@example.com | true | true
2 | invalid.email@ | false | false
3 | jane@company.org | true | true
4 | bob+test@domain.co.uk | true | true

Step 4: Validate VAT IDs

SELECT
customer_id,
vat_id,
anofox_vat_is_valid(vat_id) as vat_valid,
anofox_vat_get_country(vat_id) as country
FROM customers;

Output:

customer_id | vat_id        | vat_valid | country
1 | DE123456789 | true | DE
2 | FR12345678 | false | FR
3 | INVALID | false | null
4 | GB123456789 | true | GB

Step 5: Validate Monetary Amounts

SELECT
customer_id,
amount,
anofox_money_is_positive(amount) as positive,
anofox_money_is_valid_amount(amount, 0.01, 9999999.99) as in_range
FROM customers;

Output:

customer_id | amount  | positive | in_range
1 | 1500.50 | true | true
2 | 2000.00 | true | true
3 | -50.00 | false | false
4 | 3500.75 | true | true

Step 6: Combine All Validations

CREATE TABLE customers_validated AS
SELECT
customer_id,
email,
vat_id,
amount,
CASE WHEN anofox_email_validate(email, 'dns') IS TRUE THEN TRUE ELSE FALSE END as email_valid,
CASE WHEN anofox_vat_is_valid(vat_id) IS TRUE THEN TRUE ELSE FALSE END as vat_valid,
CASE WHEN anofox_money_is_positive(amount) IS TRUE THEN TRUE ELSE FALSE END as amount_valid,
CASE
WHEN anofox_email_validate(email, 'dns') IS TRUE
AND anofox_vat_is_valid(vat_id) IS TRUE
AND anofox_money_is_positive(amount) IS TRUE
THEN 'PASS'
ELSE 'FAIL'
END as validation_status
FROM customers;

SELECT * FROM customers_validated WHERE validation_status = 'PASS';

Output:

customer_id | email                  | vat_id      | amount  | email_valid | vat_valid | amount_valid | validation_status
1 | john.doe@example.com | DE123456789 | 1500.50 | true | true | true | PASS
4 | bob+test@domain.co.uk | GB123456789 | 3500.75 | true | true | true | PASS

Step 7: Detect Anomalies

-- Add some outlier-prone values
CREATE TABLE sales_transactions AS
SELECT
1 as transaction_id, 100.00 as amount
UNION ALL
SELECT 2, 105.00
UNION ALL
SELECT 3, 110.00
UNION ALL
SELECT 4, 5000.00 -- Obvious outlier
UNION ALL
SELECT 5, 102.00;

-- Detect anomalies using Z-Score
SELECT
transaction_id,
amount,
anofox_zscore_anomaly(amount, 3.0) OVER () as is_anomaly
FROM sales_transactions;

Output:

transaction_id | amount   | is_anomaly
1 | 100.00 | false
2 | 105.00 | false
3 | 110.00 | false
4 | 5000.00 | true
5 | 102.00 | false

Step 8: Calculate Data Quality Metrics

SELECT
COUNT(*) as total_records,
COUNT(*) FILTER (WHERE email IS NOT NULL) as email_non_null,
COUNT(DISTINCT email) as distinct_emails,
ROUND(COUNT(*) FILTER (WHERE email IS NOT NULL) * 100.0 / COUNT(*), 2) as completeness_pct
FROM customers;

Output:

total_records | email_non_null | distinct_emails | completeness_pct
4 | 4 | 4 | 100.00

What You Learned

✅ Email validation (regex, DNS checks)
✅ VAT ID validation (country-specific rules)
✅ Monetary amount validation
✅ Anomaly detection (Z-Score)
✅ Data quality metrics


Next Steps

🍪 Cookie Settings