Skip to main content

Apache Airflow providers for Yandex Clickhouse Database

Project description

apache-airflow-providers-clickhouse-fork

Provider allow connection from Apache Airflow to Yandex Clickhouse Database and perform query using ClickhouseOperator.

Installation

pip install airflow-providers-clickhouse-fork

Using

After installation, you can see provider in the Airflow providers list.

Now, you can add connection on the Airflow connection page.

Example

from datetime import datetime, timedelta

from airflow import DAG
from airflow.operators.dummy import DummyOperator

from apache.airflow.providers.clickhouse.operators.ClickhouseOperator import ClickhouseOperator

with DAG(
    dag_id='example_clickhouse_operator',
    start_date=datetime(2021, 1, 1),
    dagrun_timeout=timedelta(minutes=60),
    tags=['example','clickhouse'],
    catchup=False,
    template_searchpath='$AIRFLOW_HOME/include'
) as dag:

    run_this_last = DummyOperator(task_id='run_this_last')
    # load sql from file
    select_data = ClickhouseOperator(
        task_id='select_quit',
        sql='query.sql',
        click_conn_id='my_clickhouse_connection',
        do_xcom_push=False
    )
    # set sql direct in the code section
    select_push = ClickhouseOperator(
        task_id='select_xcom',
        sql='select * from TestTable;;',
        click_conn_id='my_clickhouse_connection'
    )

    select_data >> select_push >> run_this_last

Get result of query

If property do_xcom_push equals False, no result pushed to XCom. Otherwise, result will be pushed to XCom.

Additional

This code based on clichouse driver.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

airflow-providers-clickhouse-fork-0.0.3.tar.gz (8.8 kB view details)

Uploaded Source

File details

Details for the file airflow-providers-clickhouse-fork-0.0.3.tar.gz.

File metadata

File hashes

Hashes for airflow-providers-clickhouse-fork-0.0.3.tar.gz
Algorithm Hash digest
SHA256 1f2e42af3a80ea29ea261796ff33af8b5d403c2dc010ab1f55fd792e59f142da
MD5 467bc932be4dcf96915bc0a0963e483f
BLAKE2b-256 6ffc3601a0a4bb125b8e79822205b9dc49d6404a622dce3d7b0976c7b12972f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page