Data Architecture & Reliability
Data Quality at Pipeline Boundaries
What to Validate, Where to Enforce It (Using Great Expectations 2.0)

Effective data quality systems validate assumptions at ingestion, domain, and serving boundaries — preventing bad data from propagating while avoiding over-validation inside pipelines.
Data quality succeeds when it stops bad data early, not when it explains failures late.
TL;DR
- Data quality is not about percentages or green dashboards
- Most pipelines fail silently, not catastrophically
- Schema validity ≠ data correctness
- Great Expectations 2.0 works only if expectations are scoped correctly
- Validate at boundaries, not everywhere
- Bad data that flows is worse than data that fails
If your data quality system:
- blocks pipelines randomly
- floods Slack with alerts
- validates everything everywhere
…it’s not protecting you. It’s adding noise.
Introduction — Why “Passing Pipelines” Still Ship Wrong Data 🚨
Most teams discover data quality problems after:
- dashboards drift
- ML features degrade
- finance disputes numbers
- trust erodes quietly
And the worst part?
The pipeline was green.
Data quality failures are rarely:
- nulls everywhere
- empty tables
- obvious explosions
They’re usually:
- subtle shifts
- partial drops
- semantic violations
- delayed correctness
Data quality is not a reporting problem.
It’s a systems boundary problem.
🧠 1. What Data Quality Actually Means (Engineering Definition)
Data quality is not:
- completeness %
- row counts
- “looks fine to me”
Data quality means:
- data matches its intended semantics
- assumptions remain true over time
- downstream systems can rely on it
Quality is contextual.
The same dataset can be:
- valid for analytics
- invalid for billing
- dangerous for ML
There is no universal “good data”.
🧠 Data Quality vs Data Observability (Don’t Confuse These)
- Data Quality answers: Is this data valid and meaningful?
- Data Observability answers: Is this data behaving unexpectedly?
Quality:
- enforces rules
- blocks or quarantines bad data
- protects correctness
Observability:
- detects anomalies
- highlights drift
- triggers investigation
Observability without quality is late detection.
Quality without observability is silent decay.
You need both — in the right order.
🧱 2. Why Data Quality Is Harder in Streaming & Modern Pipelines
Modern pipelines are:
- distributed
- asynchronous
- replayable
- schema-evolving
This creates failure modes like:
- late data passing validation
- partial batches masking loss
- replay changing historical truth
- valid schemas with invalid meaning
Traditional “row checks” don’t survive this.
🧪 3. Where Great Expectations 2.0 Fits (And Where It Doesn’t)
Great Expectations is a validation framework, not a magic shield.
It excels at:
- declarative expectations
- repeatable checks
- human-readable failures
- integration with batch + Spark
It does not:
- define business meaning for you
- decide where to enforce quality
- prevent upstream garbage
- replace domain understanding
Tools don’t create quality.
Boundaries do.
🔍 4. Expectation Types That Actually Matter
Not all expectations are equal.
🟢 Structural Expectations (Low Signal)
- not null
- type checks
- basic ranges
Useful — but insufficient.
🟡 Distribution Expectations (Medium Signal)
- value sets
- min/max drift
- quantiles
Good for catching slow decay.
🔴 Semantic Expectations (High Signal)
- uniqueness where it matters
- referential integrity
- cross-field logic
- business invariants
These are expensive — and worth it.
If you validate only structure, you’re validating syntax, not truth.
👥 Expectation Ownership (Why Most Suites Rot)
Every expectation must have:
- an owner
- a reason
- a consequence
Ownership model that works:
- Structural expectations → platform team
- Semantic expectations → domain owners
- Metric-level expectations → analytics / finance
If no one owns an expectation:
- failures get ignored
- alerts get muted
- trust collapses
Data quality without ownership becomes decoration.
🧭 5. Where to Enforce Data Quality (This Matters More Than How)
❌ Bad Places
- after analytics
- inside dashboards
- in every downstream consumer
✅ Correct Places (Boundaries)
- Ingestion boundary
- prevent garbage from entering the system
2. Domain boundary
- enforce business invariants
3. Serving boundary
- protect consumers from surprises
Data quality is a gate, not a decoration.
🧱 6. Canonical Architecture (Production-Grade)
Source
↓
Ingestion (Schema + Basic DQ)
↓
Raw / Bronze
↓
Transform (Semantic DQ)
↓
Clean / Silver
↓
Aggregate (Metric-level DQ)
↓
Gold / ServingEach layer answers a different question:
- Is this data shaped correctly?
- Does it make sense?
- Can we trust it for decisions?
One tool.
Different expectations.
🧪 7. Real-World Example: Payments Pipeline
Scenario
- Events from payment gateway
- Used for revenue reporting
- Used for refunds
- Used for ML fraud detection
Expectations That Matter
amount > 0currency ∈ supported set(status = "REFUND") ⇒ original_payment_id IS NOT NULL(status = "SUCCESS") ⇒ settled_at IS NOT NULL
Row counts don’t catch this.
Null checks don’t catch this.
Semantics do.
🧬 8. Writing Expectations (Example)
Spark + Great Expectations (Simplified)
import great_expectations as ge
df = spark.read.parquet("silver/payments")
ge_df = ge.dataset.SparkDFDataset(df)
ge_df.expect_column_values_to_be_between(
"amount", min_value=0.01
)
ge_df.expect_column_values_to_be_in_set(
"currency", ["USD", "EUR", "GBP"]
)
ge_df.expect_compound_columns_to_be_unique(
["payment_id", "event_type"]
)This is not “extra code”.
This is making assumptions executable.
🚨 9. Alerting: What to Wake Humans For
Alerting on every failure guarantees alert fatigue.
Alert only when:
- business invariants break
- volume deviates materially
- critical freshness SLOs fail
- correctness impacts decisions
Do not alert on:
- single bad rows
- known edge cases
- quarantined data
Bad alerting kills trust faster than bad data.
🚦 Blocking vs Non-Blocking Expectations
Not every failure should stop the pipeline.
Blocking expectations (fail fast):
- schema violations
- impossible values (negative revenue)
- broken invariants
Non-blocking expectations (monitor):
- distribution drift
- rare edge cases
- early warning signals
Default rule:
Block structural violations.
Observe semantic drift.
Blocking everything kills velocity.
Blocking nothing kills trust.
🔁 10. Data Quality + Replay (The Forgotten Problem)
If you replay data:
- expectations must be deterministic
- failures must be reproducible
- alerts must be suppressible
If replay:
- suddenly fails old data
- changes historical truth
Your expectations are wrong.
Replay is the ultimate quality test.
⚡ Streaming-Specific Data Quality Constraints
In streaming systems:
- late data is normal
- duplicates are expected
- ordering is unreliable
- completeness is eventual
This means:
- expectations must be time-aware
- validation windows must slide
- failures must tolerate partial truth
Batch-style expectations applied to streams create false alarms.
Streaming quality is about eventual correctness, not instant perfection.
🧨 11. Common Anti-Patterns (Seen Everywhere)
❌ Validating everything
❌ Expectation sprawl
❌ Treating DQ as blocking by default
❌ Encoding business logic without ownership
❌ Letting tools define correctness
If no one owns an expectation, it will rot.
🚨 12. Production Incident: “Green Pipeline, Wrong Numbers”
- Pipeline passed all schema checks
- Great Expectations suite was green
- Revenue dropped 7% overnight
- Root cause: new
status = "PENDING_REVIEW"introduced - Downstream logic assumed only SUCCESS / FAILED
What went wrong:
- schema valid
- expectations incomplete
- semantics undocumented
Lesson:
Green checks do not mean correct data.
They mean checked assumptions — nothing more.
🧠 Mental Model to Lock In
- Schemas protect structure
- Expectations protect meaning
- Alerts protect humans
- Replay protects truth
If you validate without context, you generate noise.
If you validate without ownership, you generate chaos.
🧠 Data Quality Rules to Memorize
- Validate at boundaries, not everywhere
- Encode assumptions, not guesses
- Block invariants, observe drift
- Own every expectation
- Replay is the ultimate test
If a rule feels inconvenient — it’s probably important.
🔧 Debugging These Failures in Practice
If you’re hitting errors like these in production — Airflow failures, Spark OOM,Kafka SSL issues — I built a tool to help.
Paste your broken code + error logs into Vayu and get back:
→ Exact root cause
→ Before/After code fix
→ Confidence score (HIGH/MEDIUM/LOW)
Free to try at vayufix.com
No signup needed for first 3 fixes.
Conclusion — Data Quality Is About Trust, Not Metrics 🧪
Great Expectations 2.0 is a powerful tool — when used with restraint.
Data quality succeeds when:
- expectations encode real assumptions
- enforcement happens at boundaries
- failures are actionable
- humans trust alerts
It fails when:
- everything is validated
- nothing is owned
- dashboards look good
- reality disagrees
A pipeline with no data quality checks is fast — until it destroys trust, and then speed no longer matters.
One rule to remember:
Data quality is successful only when people trust the data enough to stop double-checking it.
🔥 Next in Series
🔍 Data Observability Tools — Monte Carlo, Databand, OpenLineage
Next, we move from preventing bad data to detecting silent failures:
- freshness vs correctness
- lineage that actually helps
- why “green pipelines” still lie
This is where monitoring meets accountability.
🔔 Follow for More
Follow TheDataForge for high-signal deep dives on Spark, Kafka, Streaming, Lakehouse, and real-world data engineering — no fluff, only engineering truth.
⚡️Let’s connect — I post daily Big Data & Spark insights at DataForgeX on X.
💬 Comment Below:
What broke your data last time?
- late data?
- missing records?
- “valid but wrong” values?
Data quality stories are painful — and the fastest way to learn.
🏷️ Tags
#DataEngineering #DataQuality #GreatExpectations #Streaming #AnalyticsEngineering #DataReliability