Skip to content

Commit 931371a

Browse files
committed
feat: Implement a Bitcoin data updater pipeline with multiple Airflow DAGs to fetch and load various metrics into Snowflake.
1 parent 71d5b25 commit 931371a

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

dags/dataset_updater.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,14 +808,24 @@ def cleanup_stage(**context):
808808
dag=dags[i]
809809
)
810810

811+
create_stage = SnowflakeOperator(
812+
task_id='create_stage',
813+
snowflake_conn_id='snowflake_default',
814+
sql="""
815+
CREATE STAGE IF NOT EXISTS BITCOIN_DATA.DATA.my_stage
816+
FILE_FORMAT = BITCOIN_DATA.DATA.json_format;
817+
""",
818+
dag=dags[i]
819+
)
820+
811821
# Create download and merge tasks for batches 1-4
812822
for batch_num in range(1, 5):
813823
prev_task = None
814824
dag = dags[batch_num]
815825

816826
# Start with file format
817827
format_task = [task for task in dag.tasks if task.task_id == 'create_file_format'][0]
818-
prev_task = format_task
828+
stage_task = [task for task in dag.tasks if task.task_id == 'create_stage'][0]
819829

820830
# Create sequential download and merge for each metric
821831
for metric_name in batch_metrics[batch_num]:
@@ -832,7 +842,7 @@ def cleanup_stage(**context):
832842
)
833843

834844
# Chain: previous_task >> download >> merge
835-
prev_task >> download_task >> merge_task
845+
format_task >> stage_task >> download_task >> merge_task
836846
prev_task = merge_task
837847

838848

0 commit comments

Comments
 (0)