This is an automated email from the ASF dual-hosted git repository.

eladkal pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 487b174073 Add guide for Apache Pinot operators (#28653)
487b174073 is described below

commit 487b174073c01e03ae64760405a8d88f6a488ca6
Author: Shahar Epstein <[email protected]>
AuthorDate: Thu Jan 12 10:07:02 2023 +0200

    Add guide for Apache Pinot operators (#28653)
    
    * add guide for Apache Pinot operators
---
 airflow/providers/apache/pinot/provider.yaml       |  6 ++
 .../index.rst                                      | 12 ++++
 .../operators.rst                                  | 73 ++++++++++++++++++++++
 .../system/providers/apache/pinot/__init__.py      | 37 -----------
 .../providers/apache/pinot/example_pinot_dag.py    | 58 +++++++++++++++++
 5 files changed, 149 insertions(+), 37 deletions(-)

diff --git a/airflow/providers/apache/pinot/provider.yaml 
b/airflow/providers/apache/pinot/provider.yaml
index 8976103e4f..b283ea9ca2 100644
--- a/airflow/providers/apache/pinot/provider.yaml
+++ b/airflow/providers/apache/pinot/provider.yaml
@@ -46,8 +46,14 @@ integrations:
     external-doc-url: https://pinot.apache.org/
     logo: /integration-logos/apache/pinot.png
     tags: [apache]
+    how-to-guide:
+      - /docs/apache-airflow-providers-apache-pinot/operators.rst
 
 hooks:
   - integration-name: Apache Pinot
     python-modules:
       - airflow.providers.apache.pinot.hooks.pinot
+
+connection-types:
+  - hook-class-name: airflow.providers.apache.pinot.hooks.pinot.PinotHook
+    connection-type: pinot
diff --git a/docs/apache-airflow-providers-apache-pinot/index.rst 
b/docs/apache-airflow-providers-apache-pinot/index.rst
index d557ab9c24..1b30243507 100644
--- a/docs/apache-airflow-providers-apache-pinot/index.rst
+++ b/docs/apache-airflow-providers-apache-pinot/index.rst
@@ -20,15 +20,27 @@
 
 Content
 -------
+.. toctree::
+    :maxdepth: 1
+    :caption: Guides
+
+    Operators <operators>
 
 .. toctree::
     :maxdepth: 1
     :caption: References
 
+    Example DAGs 
<https://github.com/apache/airflow/tree/providers-apache-pinot/|version|/tests/system/providers/apache/pinot>
     Python API <_api/airflow/providers/apache/pinot/index>
     PyPI Repository 
<https://pypi.org/project/apache-airflow-providers-apache-pinot/>
     Installing from sources <installing-providers-from-sources>
 
+.. toctree::
+    :hidden:
+    :caption: System tests
+
+    System Tests <_api/tests/system/providers/apache/pinot/index>
+
 .. THE REMAINDER OF THE FILE IS AUTOMATICALLY GENERATED. IT WILL BE 
OVERWRITTEN AT RELEASE TIME!
 
 
diff --git a/docs/apache-airflow-providers-apache-pinot/operators.rst 
b/docs/apache-airflow-providers-apache-pinot/operators.rst
new file mode 100644
index 0000000000..4e62dad25e
--- /dev/null
+++ b/docs/apache-airflow-providers-apache-pinot/operators.rst
@@ -0,0 +1,73 @@
+ .. 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 Pinot Hooks
+==================
+
+
+`Apache Pinot <https://pinot.apache.org/>`__ is a column-oriented, 
open-source, distributed data store written in Java. Pinot is designed to 
execute OLAP queries with low latency. It is suited in contexts where fast 
analytics, such as aggregations, are needed on immutable data, possibly, with 
real-time data ingestion.
+
+
+Prerequisite
+------------
+
+.. To use Pinot hooks, you must configure :doc:`Pinot Connection 
<connections/pinot>`.
+
+.. _howto/operator:PinotHooks:
+
+PinotAdminHook
+--------------
+
+This hook is a wrapper around the pinot-admin.sh script, which is used for 
administering a Pinot cluster and provided by Apache Pinot distribution. For 
now, only small subset of its subcommands are implemented, which are required 
to ingest offline data into Apache Pinot (i.e., AddSchema, AddTable, 
CreateSegment, and UploadSegment). Their command options are based on Pinot 
v0.1.0.
+
+Parameters
+----------
+
+For parameter definition, take a look at 
:class:`~airflow.providers.apache.pinot.hooks.pinot.PinotAdminHook`
+
+.. exampleinclude:: 
/../../tests/system/providers/apache/pinot/example_pinot_dag.py
+    :language: python
+    :dedent: 4
+    :start-after: [START howto_operator_pinot_admin_hook]
+    :end-before: [END howto_operator_pinot_admin_hook]
+
+Reference
+^^^^^^^^^
+
+For more information, please see the documentation at ``Apache Pinot 
improvements for PinotAdminHook<https://pinot.apache.org/>``
+
+PinotDbApiHook
+--------------
+
+This hook uses standard-SQL endpoint since PQL endpoint is soon to be 
deprecated.
+
+Parameters
+----------
+
+For parameter definition, take a look at 
:class:`~airflow.providers.apache.pinot.hooks.pinot.PinotDbApiHook`
+
+.. exampleinclude:: 
/../../tests/system/providers/apache/pinot/example_pinot_dag.py
+    :language: python
+    :dedent: 4
+    :start-after: [START howto_operator_pinot_dbapi_example]
+    :end-before: [END howto_operator_pinot_dbapi_example]
+
+Reference
+^^^^^^^^^
+
+For more information, please see the documentation at ``Pinot documentation on 
querrying data 
<https://docs.pinot.apache.org/users/api/querying-pinot-using-standard-sql>``
diff --git a/airflow/providers/apache/pinot/provider.yaml 
b/tests/system/providers/apache/pinot/__init__.py
similarity index 54%
copy from airflow/providers/apache/pinot/provider.yaml
copy to tests/system/providers/apache/pinot/__init__.py
index 8976103e4f..13a83393a9 100644
--- a/airflow/providers/apache/pinot/provider.yaml
+++ b/tests/system/providers/apache/pinot/__init__.py
@@ -14,40 +14,3 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-
----
-package-name: apache-airflow-providers-apache-pinot
-name: Apache Pinot
-description: |
-    `Apache Pinot <https://pinot.apache.org/>`__
-
-versions:
-  - 4.0.1
-  - 4.0.0
-  - 3.2.1
-  - 3.2.0
-  - 3.1.0
-  - 3.0.0
-  - 2.0.4
-  - 2.0.3
-  - 2.0.2
-  - 2.0.1
-  - 2.0.0
-  - 1.0.1
-  - 1.0.0
-
-dependencies:
-  - apache-airflow>=2.3.0
-  - apache-airflow-providers-common-sql>=1.3.1
-  - pinotdb>0.4.7
-
-integrations:
-  - integration-name: Apache Pinot
-    external-doc-url: https://pinot.apache.org/
-    logo: /integration-logos/apache/pinot.png
-    tags: [apache]
-
-hooks:
-  - integration-name: Apache Pinot
-    python-modules:
-      - airflow.providers.apache.pinot.hooks.pinot
diff --git a/tests/system/providers/apache/pinot/example_pinot_dag.py 
b/tests/system/providers/apache/pinot/example_pinot_dag.py
new file mode 100644
index 0000000000..eecd6a4c2a
--- /dev/null
+++ b/tests/system/providers/apache/pinot/example_pinot_dag.py
@@ -0,0 +1,58 @@
+# 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 DAG demonstrating the usage of the PinotAdminHook and 
PinotDbApiHook."""
+
+from __future__ import annotations
+
+from datetime import datetime
+
+from airflow import DAG
+from airflow.decorators import task
+from airflow.providers.apache.pinot.hooks.pinot import PinotAdminHook, 
PinotDbApiHook
+
+with DAG(
+    dag_id="example_pinot_hook",
+    schedule=None,
+    start_date=datetime(2021, 1, 1),  # Override to match your needs
+    tags=["example"],
+    catchup=False,
+) as dag:
+    # [START howto_operator_pinot_admin_hook]
+    @task
+    def pinot_admin():
+        PinotAdminHook(conn_id="pinot_admin_default", 
cmd_path="pinot-admin.sh", pinot_admin_system_exit=True)
+
+    # [END howto_operator_pinot_admin_hook]
+    # [START howto_operator_pinot_dbapi_example]
+    @task
+    def pinot_dbi_api():
+        PinotDbApiHook(
+            task_id="run_example_pinot_script",
+            pinot="ls /;",
+            pinot_options="-x local",
+        )
+
+    # [END howto_operator_pinot_dbapi_example]
+
+    pinot_admin()
+    pinot_dbi_api()
+
+from tests.system.utils import get_test_run
+
+# Needed to run the example DAG with pytest (see: 
tests/system/README.md#run_via_pytest)
+test_run = get_test_run(dag)

Reply via email to