Files
airflow-dags/clickhouse_dag_new.py

26 lines
913 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from airflow import DAG
from airflow_clickhouse_plugin.operators.clickhouse import ClickHouseOperator
from airflow.utils.dates import days_ago
# Аргументы DAG по умолчанию
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': days_ago(1),
}
# Создаем DAG
with DAG(
dag_id='test_clickhouse_connection',
default_args=default_args,
schedule_interval=None, # Запуск только вручную
tags=['test'],
) as dag:
# Задача с использованием ClickHouseOperator
test_query = ClickHouseOperator(
task_id='run_simple_query',
# Простой запрос для проверки соединения
sql='SELECT 1 AS test_value',
# clickhouse_conn_id='clickhouse_default' можно не указывать, т.к. это значение по умолчанию
)