Skip to content

Commit d5aa768

Browse files
committed
Add the readme.md dag to example dags
1 parent bd3f51c commit d5aa768

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from datetime import datetime
2+
3+
from airflow import DAG
4+
5+
from astro import sql as aql
6+
from astro.files import File
7+
from astro.sql.table import Table
8+
9+
10+
@aql.transform()
11+
def top_five_animations(input_table: Table):
12+
return """
13+
SELECT Title, Rating
14+
FROM {{input_table}}
15+
WHERE Genre1=='Animation'
16+
ORDER BY Rating desc
17+
LIMIT 5;
18+
"""
19+
20+
21+
with DAG(
22+
"calculate_popular_movies",
23+
schedule_interval=None,
24+
start_date=datetime(2000, 1, 1),
25+
catchup=False,
26+
) as dag:
27+
imdb_movies = aql.load_file(
28+
File(
29+
"https://raw.githubusercontent.com/astronomer/astro-sdk/main/tests/data/imdb.csv"
30+
),
31+
output_table=Table(conn_id="sqlite_default"),
32+
)
33+
top_five_animations(
34+
input_table=imdb_movies,
35+
output_table=Table(name="top_animation"),
36+
)
37+
aql.cleanup()

tests/test_example_dags.py

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def session():
6161
"example_load_file",
6262
"example_transform",
6363
"example_merge_bigquery",
64+
"calculate_popular_movies",
6465
],
6566
)
6667
def test_example_dag(session, dag_id):

0 commit comments

Comments
 (0)