forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'datahub-project:master' into master
- Loading branch information
Showing
18 changed files
with
1,536 additions
and
45 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
43 changes: 43 additions & 0 deletions
43
metadata-ingestion-modules/airflow-plugin/tests/integration/dags/athena_operator.py
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,43 @@ | ||
from datetime import datetime | ||
|
||
from airflow import DAG | ||
from airflow.providers.amazon.aws.operators.athena import AthenaOperator | ||
|
||
ATHENA_COST_TABLE = "costs" | ||
ATHENA_PROCESSED_TABLE = "processed_costs" | ||
|
||
|
||
def _fake_athena_execute(*args, **kwargs): | ||
pass | ||
|
||
|
||
with DAG( | ||
"athena_operator", | ||
start_date=datetime(2023, 1, 1), | ||
schedule_interval=None, | ||
catchup=False, | ||
) as dag: | ||
# HACK: We don't want to send real requests to Athena. As a workaround, | ||
# we can simply monkey-patch the operator. | ||
AthenaOperator.execute = _fake_athena_execute # type: ignore | ||
|
||
transform_cost_table = AthenaOperator( | ||
aws_conn_id="my_aws", | ||
task_id="transform_cost_table", | ||
database="athena_db", | ||
query=""" | ||
CREATE OR REPLACE TABLE {{ params.out_table_name }} AS | ||
SELECT | ||
id, | ||
month, | ||
total_cost, | ||
area, | ||
total_cost / area as cost_per_area | ||
FROM {{ params.in_table_name }} | ||
""", | ||
params={ | ||
"in_table_name": ATHENA_COST_TABLE, | ||
"out_table_name": ATHENA_PROCESSED_TABLE, | ||
}, | ||
output_location="s3://athena-results-bucket/", | ||
) |
Oops, something went wrong.