
Architecture

- Extraction: Data is extracted from an eCommerce store’s API and stored in an object storage bucket.
- Loading: The extracted data is loaded into Snowflake, a cloud-based data warehouse.
- Transformation: The data is transformed in several steps using SQL queries in Snowflake.
- Dashboard: The transformed data is displayed in a dashboard using Streamlit.
Airflow features
The DAGs in this reference architecture highlight several key Airflow best practices and features:- Object Storage: Interaction with files in object storage is simplified using the experimental Airflow Object Storage API. This API allows for easy streaming of large files between object storage locations.
- Data-driven scheduling: The DAGs in this reference architecture run on data-driven schedules as soon as the data they operate on is updated.
- Data quality checks: Data quality checks are performed on the base Snowflake tables using the
SQLColumnCheckOperatorand theSQLTableCheckOperator. There are both quality checks that stop the pipeline upon failure and checks that only send a notification. - Notifications: If certain data quality checks fail, a Slack notification is automatically sent to the data quality team using an
on_failure_callbackat the task-group-level. - Airflow retries: To protect against transient API failures, all tasks are configured to automatically retry after an adjustable delay.
- Dynamic task mapping: Interaction with files in object storage is parallelized per type of record using dynamic task mapping.
- Custom XCom Backend: In the extraction step, new records are passed through XCom to the next task. XComs are stored in S3 using an Object Storage custom XCom backend.
- Modularization: SQL queries are stored in the
includefolder and imported into the DAG file to be used inSQLExecuteQueryOperatortasks. This makes the DAG code more readable and offers the ability to reuse SQL queries across multiple DAGs. Additionally, some Python functions and data quality check definitions are modularized as well.