Skip to content

Commit

Permalink
Add the readme.md dag to example dags
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarsharma2 committed Aug 18, 2022
1 parent bd3f51c commit d5aa768
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
37 changes: 37 additions & 0 deletions example_dags/calculate_popular_movies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from datetime import datetime

from airflow import DAG

from astro import sql as aql
from astro.files import File
from astro.sql.table import Table


@aql.transform()
def top_five_animations(input_table: Table):
return """
SELECT Title, Rating
FROM {{input_table}}
WHERE Genre1=='Animation'
ORDER BY Rating desc
LIMIT 5;
"""


with DAG(
"calculate_popular_movies",
schedule_interval=None,
start_date=datetime(2000, 1, 1),
catchup=False,
) as dag:
imdb_movies = aql.load_file(
File(
"https://raw.githubusercontent.com/astronomer/astro-sdk/main/tests/data/imdb.csv"
),
output_table=Table(conn_id="sqlite_default"),
)
top_five_animations(
input_table=imdb_movies,
output_table=Table(name="top_animation"),
)
aql.cleanup()
1 change: 1 addition & 0 deletions tests/test_example_dags.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def session():
"example_load_file",
"example_transform",
"example_merge_bigquery",
"calculate_popular_movies",
],
)
def test_example_dag(session, dag_id):
Expand Down

0 comments on commit d5aa768

Please sign in to comment.