-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug fix: - Support using SQL operators (`run_raw_sql`, `transform`, `dataframe`) to convert a Pandas dataframe into a table when using a DuckDB in-memory database. [#1831](#1833)
- Loading branch information
Showing
9 changed files
with
136 additions
and
64 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
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
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,44 @@ | ||
""" | ||
pipeline_2 | ||
DAG auto-generated by Astro Cloud IDE. | ||
""" | ||
|
||
import pandas as pd | ||
import pendulum | ||
from airflow.decorators import dag | ||
|
||
from astro import sql as aql | ||
from astro.table import Table | ||
|
||
|
||
@aql.dataframe(task_id="python_1") | ||
def python_1_func(): | ||
return pd.DataFrame({"a": [1, 2, 3]}) | ||
|
||
|
||
@aql.run_raw_sql( | ||
conn_id="duckdb_memory", | ||
task_id="sql_duck", | ||
handler=lambda x: pd.DataFrame(x.fetchall(), columns=x.keys()), | ||
) | ||
def sql_duck_func(python_1: Table): | ||
return """ | ||
SELECT * FROM {{python_1}} | ||
""" | ||
|
||
|
||
@dag( | ||
schedule_interval="0 0 * * * *", | ||
start_date=pendulum.from_format("2023-02-23", "YYYY-MM-DD").in_tz("UTC"), | ||
) | ||
def pipeline_2(): | ||
python_1 = python_1_func() | ||
|
||
sql_duck = sql_duck_func( | ||
python_1, | ||
) | ||
|
||
sql_duck << python_1 # skipcq: PYL-W0104 | ||
|
||
|
||
dag_obj = pipeline_2() |
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
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
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
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
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
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