-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the readme.md dag to example dags
- Loading branch information
1 parent
bd3f51c
commit d5aa768
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters