📝 Snowflake
Description
< What is it? >
Snowflake is a managed cloud data platform used to store, process, and analyze data. A common use is a data warehouse: combine data from operational systems into tables that analysts query with SQL.
Snowflake separates persistent storage from compute resources. Users work with databases, schemas, tables, and compute services while Snowflake manages the underlying infrastructure. See its architecture overview.
- Example: load sales data from several applications, transform it into reporting tables, and let finance and analytics teams query those tables with separate compute resources.
Key points
< Storage, compute, and cloud services >
| Layer | Role |
|---|---|
| Storage | Persists table data independently of running compute |
| Compute | Executes work; a virtual warehouse supplies compute for many SQL queries and data operations |
| Cloud services | Coordinates functions such as authentication, metadata management, and query optimization |
SQL client → Cloud services → Virtual warehouse → Stored table data
A virtual warehouse is compute capacity. A database and its schemas organize data objects. Multiple warehouses can query the same stored data, and suspending a warehouse does not delete the tables. See the virtual warehouse guide.
< Scaling and workload isolation >
Separate warehouses can isolate compute used by loading jobs and interactive reports. Warehouse sizing changes available compute resources; multi-cluster warehouses address concurrency by adding clusters. Auto-suspend and auto-resume help match warehouse activity to demand. These settings affect resource use and query behavior; larger compute is not automatically the best choice for every query.
< Micro-partitions and pruning >
For standard Snowflake tables, data is organized into micro-partitions. Metadata about their contents helps the query engine skip partitions that cannot satisfy a filter. This is called pruning. Query performance depends partly on how much data must be scanned and how well filters align with the data's organization. See micro-partitions and clustering.
Comparison
< Snowflake and Spark >
| Aspect | Snowflake | Apache Spark |
|---|---|---|
| Primary role | Managed platform for storing and processing data | Distributed processing engine that connects to storage |
| Typical interface | SQL and platform APIs | SQL, PySpark, and other Spark APIs |
| Operations | Service manages infrastructure; users configure access and compute | Deployment can be self-managed or provided by a managed service |
| Common use | Shared analytical tables, reporting, and data transformations | Programmable data pipelines, large transformations, and streaming |
Both can perform analytical SQL and transformations. They can also be used together: a Spark pipeline may prepare data that is loaded into Snowflake for reporting. Choose based on workload, existing storage, team skills, and operational requirements.
Implementation
< Aggregate sales with SQL >
Run this query in a Snowflake SQL worksheet with an available warehouse selected and permission to use it. It creates an inline dataset with VALUES, so no persistent table is needed. See the VALUES reference.
WITH sales AS (
SELECT column1 AS region, column2 AS amount
FROM VALUES
('East', 120),
('West', 90),
('East', 60)
)
SELECT region, SUM(amount) AS total
FROM sales
GROUP BY region
ORDER BY region;
Expected result:
| REGION | TOTAL |
|---|---|
| East | 180 |
| West | 90 |
The aggregation matches the PySpark example. In an application, the input would typically be a stored table or another query rather than three inline rows.
Troubleshoot
< Common problems >
| Symptom | What to inspect |
|---|---|
| A query cannot start | Selected warehouse, its state, and the active role's privileges |
| Queries queue during busy periods | Warehouse load and concurrency settings |
| A query scans much more data than expected | Filters, micro-partition pruning, and the query profile |
| Resource use remains high during quiet periods | Auto-suspend settings and jobs that keep compute active |
Related ideas
- Apache Spark provides distributed processing through code and SQL.
- Apache Hadoop groups distributed storage, scheduling, and batch-processing components.
- Distributed Systems & Data Processing compares these systems' roles.