Skip to content

Commit 98bf76d

Browse files
authored
add a demo bug scenario (#5)
* simple bug demo * get it working * trigger
1 parent 3d7f2b2 commit 98bf76d

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ deploy: ## Deploy the entire stack
6464
make dbt
6565
@echo "Deployment completed successfully. Run 'make app' to view the app."
6666

67+
debug: ## Clean up everything and redeploy to fix bugs
68+
@echo "Running debug cleanup and redeploy..."
69+
snow sql -c localstack -q "USE DATABASE FACTORY_PIPELINE_DEMO; USE SCHEMA PUBLIC; DROP FILE FORMAT IF EXISTS csv_format;"
70+
snow sql -c localstack -q "DROP PIPE IF EXISTS FACTORY_PIPELINE_DEMO.PUBLIC.SENSOR_DATA_PIPE;"
71+
snow sql -c localstack -q "DROP TABLE IF EXISTS FACTORY_PIPELINE_DEMO.PUBLIC_RAW.SENSOR_DATA;"
72+
awslocal s3 rb s3://factory-sensor-data-local --force
73+
make deploy
74+
@echo "Debug cleanup and redeploy completed successfully."
75+
6776
test: ## Run tests
6877
@echo "Running tests..."
6978
bash -c "source env/bin/activate && pytest tests/"
@@ -90,4 +99,4 @@ ready: ## Make sure the LocalStack container is up
9099
logs: ## Save the logs in a separate file
91100
@localstack logs > logs.txt
92101

93-
.PHONY: install seed aws upload pipeline dbt app deploy test start stop ready logs
102+
.PHONY: install seed aws upload pipeline dbt app deploy test start stop ready logs debug

models/marts/schema.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ version: 2
22

33
models:
44
- name: processed_machine_health
5+
tests:
6+
- table_not_empty
57
description: "Final processed machine health metrics"
68
columns:
79
- name: machine_id

models/staging/schema.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ version: 2
22

33
models:
44
- name: sensor_readings_view
5+
tests:
6+
- table_not_empty
57
description: "Cleaned and validated sensor readings"
68
columns:
79
- name: machine_id

setup/01_setup_snowflake.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ CREATE OR REPLACE TABLE RAW_SENSOR_DATA (
1717
-- Create a file format for CSV files
1818
CREATE OR REPLACE FILE FORMAT csv_format
1919
TYPE = CSV
20+
-- 🐛 DEMO BUG: Incorrect CSV delimiter configuration
21+
-- The actual CSV file uses commas, not semicolons.
22+
-- This mismatch causes data parsing to fail in dbt test "table_not_empty"
23+
-- Snowpipe will fail to parse CSV data correctly and Streamlit app shows no data
24+
-- FIELD_DELIMITER = ';' -- 🚨 BUG: Causes "RAW_SENSOR_DATA" table to remain empty
2025
FIELD_DELIMITER = ','
2126
SKIP_HEADER = 1
2227
NULL_IF = ('NULL', 'null')

tests/generic/table_not_empty.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% test table_not_empty(model) %}
2+
select 1 as id
3+
where not exists (select 1 from {{ model }} limit 1)
4+
{% endtest %}

0 commit comments

Comments
 (0)