You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2023/01/05 15:06:19 UTC

[GitHub] [airflow] josh-fell commented on a diff in pull request #28653: Add guide for Apache Pinot operators

josh-fell commented on code in PR #28653:
URL: https://github.com/apache/airflow/pull/28653#discussion_r1062562406


##########
docs/apache-airflow-providers-apache-pinot/operators.rst:
##########
@@ -0,0 +1,71 @@
+ .. 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. 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
+    :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:`~classairflow.providers.apache.pinot.hooks.pinot.PinotDbApiHook`
+
+.. exampleinclude:: /../../tests/system/providers/apache/pinot/example_pinot_dag.py
+    :language: python
+    :start-after: [START howto_operator_pinot_dbapi_example]
+    :end-before: [END howto_operator_pinot_dbapi_example]

Review Comment:
   ```suggestion
       :language: python
       :dedent: 4
       :start-after: [START howto_operator_pinot_dbapi_example]
       :end-before: [END howto_operator_pinot_dbapi_example]
   ```
   Same idea here.



##########
tests/system/providers/apache/pinot/example_pinot_dag.py:
##########
@@ -0,0 +1,57 @@
+# 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_interval=None,
+    start_date=datetime(2021, 1, 1),  # Override to match your needs
+    tags=["example"],

Review Comment:
   ```suggestion
       tags=["example"],
       catchup=False,
   ```
   We should add `catchup=False` so there aren't a year+ of DAG Runs that get created when this system test runs if the `start_date` isn't updated. This is typical in the example DAGs throughout the repo too.



##########
docs/apache-airflow-providers-apache-pinot/operators.rst:
##########
@@ -0,0 +1,71 @@
+ .. 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. 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
+    :start-after: [START howto_operator_pinot_admin_hook]
+    :end-before: [END howto_operator_pinot_admin_hook]

Review Comment:
   ```suggestion
       :language: python
       :dedent: 4
       :start-after: [START howto_operator_pinot_admin_hook]
       :end-before: [END howto_operator_pinot_admin_hook]
   ```
   Adding the `dedent` directive will provide better formatting of the code snippet in the docs since the `START/END` tags are indented in the example DAG.



##########
tests/system/providers/apache/pinot/example_pinot_dag.py:
##########
@@ -0,0 +1,57 @@
+# 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_interval=None,

Review Comment:
   ```suggestion
       schedule=None,
   ```
   As of 2.4., the `schedule_interval` has been deprecated for the more general `schedule` parameter. [Here are the release notes](https://airflow.apache.org/docs/apache-airflow/2.4.0/release_notes.html#deprecation-of-schedule-interval-and-timetable-arguments-25410) for reference.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org