47.1 Analytical SQL Example (Redshift)
-- Trend analysis by category and dimension
SELECT
d.dimension_name,
c.category_code,
COUNT(*) AS total_records,
SUM(CASE WHEN c.status = 'flagged' THEN 1 ELSE 0 END) AS flagged_count,
ROUND(SUM(CASE WHEN c.status = 'flagged' THEN 1 ELSE 0 END)::float
/ COUNT(*) * 100, 2) AS flag_rate,
SUM(c.amount) AS total_amount,
AVG(c.days_open) AS avg_days_open
FROM records c
JOIN dimensions d ON c.dimension_id = d.dimension_id
WHERE c.event_date >= DATEADD(month, -6, GETDATE())
GROUP BY d.dimension_name, c.category_code
HAVING COUNT(*) > 100
ORDER BY flag_rate DESC;
47.2 Warehouse Comparison
| Feature | Redshift | BigQuery | Snowflake | Databricks SQL |
|---|---|---|---|---|
| Pricing | Node-based + Serverless | Per-query (on-demand) | Credit-based, separate storage/compute | DBU-based |
| Scaling | Manual or Serverless | Auto | Auto (multi-cluster) | Auto |
| ML Integration | Redshift ML (SageMaker) | BigQuery ML | Snowpark ML | MLflow native |
| Streaming | Streaming ingestion | Streaming inserts | Snowpipe Streaming | Structured Streaming |
| Cloud | AWS | GCP | Multi-cloud | Multi-cloud |
| Best for | AWS-heavy, predictable workloads | Variable workloads, GCP-native | Multi-cloud, elastic concurrency | Unified analytics + ML |
47.3 Databricks Lakehouse Architecture
┌─────────────────────────────────────────────┐
│ Databricks Lakehouse Platform │
│ │
│ Unity Catalog (Governance) │
│ ┌─────────────────────────────────────┐ │
│ │ Delta Lake (Storage Format) │ │
│ │ - ACID transactions │ │
│ │ - Schema evolution │ │
│ │ - Time travel (data versioning) │ │
│ │ - Change Data Feed (CDC) │ │
│ └─────────────────────────────────────┘ │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ SQL │ │ ML │ │ Streaming│ │
│ │ Warehouse │ │ (MLflow) │ │ (Spark) │ │
│ └──────────┘ └──────────┘ └──────────┘ │
└─────────────────────────────────────────────┘
| Feature | Purpose |
|---|---|
| MLflow | Experiment tracking, model registry |
| Feature Store | Centralized, shared feature management across models |
| Delta Live Tables | Declarative ETL pipelines with built-in quality checks |
| Unity Catalog | Data governance, lineage, fine-grained access control |
| Model Serving | Real-time inference |
47.4 Q&A
Q: When would you choose Databricks over EMR+Redshift?
- Choose Databricks when the team wants a unified ETL+analytics+ML platform, needs MLflow for experiment/model lifecycle, wants Delta Lake features (ACID, time travel, CDC), and the data science team prefers a collaborative notebook workspace.
- Choose EMR+Redshift when already deep in the AWS ecosystem, cost optimization matters (EMR spot instances are cheaper), data engineering and data science are separate teams, BI tool integration with Redshift is important, or fine-grained Spark configuration control is needed.
- Recommendation for a greenfield build: Databricks, because Unity Catalog provides the governance/lineage needed for compliance, MLflow manages the model lifecycle, and the unified platform reduces integration complexity. If already invested in EMR+Redshift, optimize that stack rather than migrate purely for platform elegance.
Q: BigQuery vs. Snowflake — how do you choose? BigQuery wins for GCP-native shops with highly variable, spiky workloads (true serverless, pay-per-query with no idle cost). Snowflake wins for multi-cloud flexibility and elastic concurrency scaling (separate compute clusters per workload so a heavy ETL job never starves BI dashboard users) — its architecture is purpose-built for that isolation in a way BigQuery’s flat serverless model is not.