Metadata-Version: 2.1
Name: airflow-providers-clickhouse-fork
Version: 0.0.3
Summary: Apache Airflow providers for Yandex Clickhouse Database
Home-page: https://github.com/0xMihalich/apache-airflow-providers-clickhouse
Author: Ivan Klimenko
Author-email: klimenko.iv@gmail.com
License: Apache License 2.0
Project-URL: Bug Tracker, https://github.com/0xMihalich/apache-airflow-providers-clickhouse/issues
Keywords: clickhouse,airflow,providers,database,ClickhouseHook,ClickhouseOperator
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: apache-airflow>=2.0
Requires-Dist: clickhouse_driver>=0.2.1
Requires-Dist: pandas>=1.3.2

# apache-airflow-providers-clickhouse-fork

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

## Installation

```shell
pip install airflow-providers-clickhouse-fork
```

## Using

After installation, you can see provider in the Airflow providers list.
![](docs/provider_list.png)

Now, you can add connection on the Airflow connection page.
![](docs/create_connection.png)

## Example

```python
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](https://clickhouse-driver.readthedocs.io/en/latest/#). 
