Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guide for Apache Druid operators #18527

Merged
merged 2 commits into from
Sep 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions airflow/providers/apache/druid/example_dags/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
52 changes: 52 additions & 0 deletions airflow/providers/apache/druid/example_dags/example_druid_dag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

"""
Example Airflow DAG to submit Apache Druid json index file using `DruidOperator`
"""
from airflow.models import DAG
from airflow.providers.apache.druid.operators.druid import DruidOperator
from airflow.utils.dates import days_ago

with DAG(
dag_id='example_druid_operator',
schedule_interval=None,
start_date=days_ago(2),
tags=['example'],
) as dag:
# [START howto_operator_druid_submit]
submit_job = DruidOperator(
task_id='spark_submit_job',
json_index_file='json_index.json',
druid_ingest_conn_id='druid_ingest_default',
)
# Example content of json_index.json:
JSON_INDEX_STR = """
{
"type": "index_hadoop",
"datasource": "datasource_prd",
"spec": {
"dataSchema": {
"granularitySpec": {
"intervals": ["2021-09-01/2021-09-02"]
}
}
}
}
"""
# [END howto_operator_druid_submit]
4 changes: 3 additions & 1 deletion airflow/providers/apache/druid/provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package-name: apache-airflow-providers-apache-druid
name: Apache Druid
description: |
`Apache Druid <https://druid.apache.org/>`__.
`Apache Druid <https://druid.apache.org/>`__.

versions:
- 2.0.2
Expand All @@ -36,6 +36,8 @@ integrations:
- integration-name: Apache Druid
external-doc-url: https://druid.apache.org/
logo: /integration-logos/apache/druid-1.png
how-to-guide:
- /docs/apache-airflow-providers-apache-druid/operators.rst
tags: [apache]

operators:
Expand Down
7 changes: 7 additions & 0 deletions docs/apache-airflow-providers-apache-druid/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@
Content
-------

.. toctree::
:maxdepth: 1
:caption: Guides

Operators <operators>

.. toctree::
:maxdepth: 1
:caption: References

Python API <_api/airflow/providers/apache/druid/index>
PyPI Repository <https://pypi.org/project/apache-airflow-providers-apache-druid/>
Installing from sources <installing-providers-from-sources>
Example DAGs <https://github.com/apache/airflow/tree/main/airflow/providers/apache/druid/example_dags>

.. THE REMAINDER OF THE FILE IS AUTOMATICALLY GENERATED. IT WILL BE OVERWRITTEN AT RELEASE TIME!

Expand Down
52 changes: 52 additions & 0 deletions docs/apache-airflow-providers-apache-druid/operators.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.. Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

.. http://www.apache.org/licenses/LICENSE-2.0

.. Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.


Apache Druid Operators
======================

.. contents::
:depth: 1
:local:

Prerequisite
------------

To use ``DruidOperator``, you must configure a Druid Connection first.

DruidOperator
-------------------

Submit a task directly to Druid, you need to provide the filepath to the Druid index specification ``json_index_file``, and the connection id of the Druid overlord ``druid_ingest_conn_id`` which accepts index jobs in Airflow Connections.

There is also a example content of the Druid Ingestion specification below.

For parameter definition take a look at :class:`~airflow.providers.apache.druid.operators.druid.DruidOperator`.

Using the operator
""""""""""""""""""

.. exampleinclude:: /../../airflow/providers/apache/druid/example_dags/example_druid_dag.py
:language: python
:dedent: 4
:start-after: [START howto_operator_druid_submit]
:end-before: [END howto_operator_druid_submit]

Reference
"""""""""

For more information, please refer to `Apache Druid Ingestion spec reference <https://druid.apache.org/docs/latest/ingestion/ingestion-spec.html>`_.