Skip to content

Commit 40bed86

Browse files
Initial commit
0 parents  commit 40bed86

22 files changed

+1641
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## Advanced Data Engineering with Snowflake
2+
3+
#### How to use this repo throughout the course:
4+
5+
To successfully follow along with the instructor during the course, you'll need to make use of the code in this repo. To follow along, you can either:
6+
7+
* Keep the URL to this repo handy, so that you can easily find and use any code referenced by the instructor during the course
8+
9+
* Clone the repo to your local computing environment (required)
10+
11+
> **Note:** There are a couple of exercises that make use of Snowflake's command line interface, Snowflake CLI. To successfully follow along during those exercises, you'll need to have the repo cloned to your local computing environment, so that the Snowflake CLI can make use of files and code within this repo.
12+
13+
#### How to clone the repo to your local computing environment:
14+
15+
1. Fork the repo to create a copy associated with your GitHub Account: https://github.com/Snowflake-Labs/advanced-data-engineering-snowflake/fork
16+
17+
2. Clone your fork:
18+
19+
```bash
20+
git clone https://github.com/<your-GitHub-user-name>/modern-data-engineering-snowflake.git
21+
```
22+
23+
Where `<your-GitHub-user-name>` is replaced by your GitHub user name. This workflow is covered in the course.
24+
25+
You can then open the repo in your preferred code editor. Throughout the course, the instructor will use Visual Studio Code as the code editor.
26+
27+
#### How to navigate this repo
28+
29+
All of the code that you need to successfully complete the course is within this repo. Each folder in this repo corresponds to a module in the online course.
30+
31+
* **module-1** – Corresponds to "Module 1: DevOps with Snowflake" in the course.
32+
33+
* **module-2** – Corresponds to "Module 2: Observability with Snowflake" in the course.
34+
35+
The course instructor will also be sure to reference the exact folder and name of the file to use throughout the course, so that you can follow along.
36+
37+
#### Reporting issues or errata
38+
39+
If you encounter technical issues with this code as you complete the course (i.e. typos, missing code, broken links, etc.), please report those issues in the course through Coursera. Ensure the issue contains sufficient detail so that it can be properly addressed.

cleanup.sql

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
USE ROLE accountadmin;
2+
USE WAREHOUSE compute_wh;
3+
4+
USE DATABASE tasty_bytes;
5+
DROP VIEW tasty_bytes.harmonized.daily_weather_v;
6+
7+
DROP VIEW tasty_bytes.harmonized.windspeed_hamburg;
8+
9+
DROP FUNCTION tasty_bytes.analytics.fahrenheit_to_celsius();
10+
11+
DROP FUNCTION tasty_bytes.analytics.inch_to_millimeter();
12+
13+
DROP VIEW tasty_bytes.harmonized.weather_hamburg;
14+
15+
DROP VIEW tasty_bytes.analytics.daily_city_metrics_v;
16+
17+
DROP STREAM tasty_bytes.raw_pos.order_header_stream ON TABLE tasty_bytes.raw_pos.order_header;
18+
19+
DROP PROCEDURE tasty_bytes.raw_pos.process_order_headers_stream();

config.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# DO NOT EDIT THIS FILE - DO NOT EDIT THIS FILE - DO NOT EDIT THIS FILE
2+
3+
default_connection_name = "advanced_data_engineering_snowflake"
4+
5+
[connections]
6+
[connections.advanced_data_engineering_snowflake]
7+
account=""
8+
user=""
9+
password=""

module-1/api_integration.sql

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
USE ROLE accountadmin;
2+
CREATE DATABASE course_repo;
3+
USE SCHEMA public;
4+
5+
-- Create credentials
6+
CREATE OR REPLACE SECRET course_repo.public.github_pat
7+
TYPE = password
8+
USERNAME = ''
9+
PASSWORD = '';
10+
11+
-- Create the API integration
12+
CREATE OR REPLACE API INTEGRATION
13+
API_PROVIDER = git_https_api
14+
API_ALLOWED_PREFIXES = ('') -- URL to your GitHub profile
15+
ALLOWED_AUTHENTICATION_SECRETS = ()
16+
ENABLED = TRUE;
17+
18+
-- Create the git repository object
19+
CREATE OR REPLACE GIT REPOSITORY course_repo.public.advanced_data_engineering_snowflake
20+
API_INTEGRATION = -- Name of the API integration defined above
21+
ORIGIN = '' -- Insert URL of forked repo
22+
GIT_CREDENTIALS = ;
23+
24+
-- List the git repositories
25+
SHOW GIT REPOSITORIES;

module-1/hamburg_weather/main.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Deploy Templatized Data Environment
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- staging
8+
- main
9+
push:
10+
branches:
11+
- staging
12+
- main
13+
14+
jobs:
15+
deploy_data_environment:
16+
# Only run when PR is merged or on direct push to environment branches
17+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
18+
runs-on: ubuntu-latest
19+
20+
env:
21+
# Read connection secret
22+
SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
23+
SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }}
24+
SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
25+
26+
steps:
27+
# Checkout step is necessary to access repository files
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
# Determine environment based on target branch
32+
- name: Set environment
33+
id: set_env
34+
run: |
35+
TARGET_BRANCH="${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}"
36+
37+
if [[ $TARGET_BRANCH == "staging" ]]; then
38+
echo "DEPLOY_ENV=staging" >> $GITHUB_ENV
39+
echo "Environment set to staging"
40+
elif [[ $TARGET_BRANCH == "main" ]]; then
41+
echo "DEPLOY_ENV=prod" >> $GITHUB_ENV
42+
echo "Environment set to production"
43+
else
44+
echo "Unexpected branch: $TARGET_BRANCH"
45+
exit 1
46+
fi
47+
48+
# Install Snowflake CLI GitHub Action and point to config file
49+
- name: Install SnowflakeCLI
50+
uses: snowflakedb/snowflake-cli-action@v1.5
51+
with:
52+
cli-version: "latest"
53+
default-config-file-path: "config.toml"
54+
55+
# Fetch latest changes from the repository to Snowflake
56+
- name: Fetch latest changes to Snowflake
57+
run: snow git fetch course_repo.public.advanced_data_engineering_snowflake
58+
59+
# Deploy templates to the data environment -
60+
- name: Deploy templates to data environment
61+
run: |
62+
# Export TARGET_BRANCH for use in this step
63+
echo "Using branch: ${GITHUB_REF_NAME}"
64+
snow git execute @advanced_data_engineering_snowflake/branches/FIX-ME/module-1/hamburg_weather/pipeline/data/ \
65+
-D "env='${{ }}'" \
66+
--database=COURSE_REPO \
67+
--schema=PUBLIC
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "3775908f-ca36-4846-8f38-5adca39217f2",
7+
"metadata": {
8+
"language": "sql",
9+
"name": "cell1"
10+
},
11+
"outputs": [],
12+
"source": [
13+
"-- Set context\n",
14+
"USE ROLE accountadmin;\n",
15+
"USE DATABASE staging_tasty_bytes;\n",
16+
"USE SCHEMA raw_pos;\n",
17+
"USE WAREHOUSE compute_wh;"
18+
]
19+
},
20+
{
21+
"cell_type": "code",
22+
"execution_count": null,
23+
"id": "dfd78d46-46f3-40a7-be43-4ab79cf72a9f",
24+
"metadata": {
25+
"language": "sql",
26+
"name": "cell2"
27+
},
28+
"outputs": [],
29+
"source": [
30+
"SHOW TABLES IN staging_tasty_bytes.raw_pos;"
31+
]
32+
}
33+
],
34+
"metadata": {
35+
"kernelspec": {
36+
"display_name": "Streamlit Notebook",
37+
"name": "streamlit"
38+
},
39+
"lastEditStatus": {
40+
"authorEmail": "gilberto.hernandez@snowflake.com",
41+
"authorId": "6002244633419",
42+
"authorName": "GILBERTO",
43+
"lastEditTime": 1741667434593,
44+
"notebookId": "sd4b3qffhw3yzmzwpcr2",
45+
"sessionId": "2ad2d56d-f367-4eba-abad-28f4dc5b5f95"
46+
}
47+
},
48+
"nbformat": 4,
49+
"nbformat_minor": 5
50+
}

0 commit comments

Comments
 (0)