Skip to content

Commit 5b116c2

Browse files
committed
add additional sql and json files because the workflow goes far beyond table creation
1 parent eae2927 commit 5b116c2

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

sql/06_ai_functions.sql

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-- Spam detection demo
2+
CREATE TABLE IF NOT EXISTS dbsql_samuel.demo.inbox_messages (
3+
timestamp TIMESTAMP,
4+
from_number STRING,
5+
text STRING
6+
);
7+
8+
SELECT
9+
text,
10+
ai_query(
11+
"databricks-meta-llama-3-3-70b-instruct",
12+
"Classify the following message as spam or not spam: " || text
13+
) AS is_spam
14+
FROM dbsql_samuel.demo.inbox_messages
15+
LIMIT 10;
16+
17+
-- Airline type classification demo
18+
SELECT
19+
IATA,
20+
ai_classify(
21+
content => IATA,
22+
labels => array('full service carriers','low cost carriers','regional airlines','charter airlines')
23+
) AS airline_category
24+
FROM dbsql_samuel.demo.airports
25+
LIMIT 10;

sql/07_alerts_and_permissions.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- ATL delay alert
2+
CREATE ALERT IF NOT EXISTS atl_flight_delay_alert
3+
AS
4+
SELECT COUNT(*) AS delayed_flights
5+
FROM dbsql_samuel.demo.flights_silver_mv
6+
WHERE Dest='ATL' AND IsArrDelayed='YES'
7+
HAVING delayed_flights > 100;
8+
9+
-- Permissions example
10+
GRANT SELECT ON TABLE dbsql_samuel.demo.flights_silver_mv TO `data_analyst`;

sql/08_lakeflow_job.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "Flight Orchestration Workflow",
3+
"tasks": [
4+
{ "task_key": "ingest_airports_bronze", "type": "sql", "sql_task": { "query_name": "airports ST" } },
5+
{ "task_key": "replace_airports_mv", "type": "sql", "depends_on": ["ingest_airports_bronze"], "sql_task": { "query_name": "airports MV" } },
6+
{ "task_key": "check_atl_alert", "type": "sql", "depends_on": ["replace_airports_mv"], "sql_task": { "alert_name": "ATL Flight Alert" } },
7+
{ "task_key": "refresh_flight_dashboard", "type": "dashboard", "depends_on": ["check_atl_alert"], "dashboard_task": { "dashboard_name": "Flight Data Dashboard" } }
8+
]
9+
}

0 commit comments

Comments
 (0)