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 2020/12/22 03:14:33 UTC

[GitHub] [airflow] xinbinhuang commented on a change in pull request #12677: Refactor SQL/BigQuery/Qubole Check operators

xinbinhuang commented on a change in pull request #12677:
URL: https://github.com/apache/airflow/pull/12677#discussion_r547043547



##########
File path: airflow/providers/qubole/operators/qubole_check.py
##########
@@ -16,17 +16,40 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-from typing import Iterable, Optional, Union
+from typing import Callable, Iterable, Optional, Union
 
 from airflow.exceptions import AirflowException
-from airflow.operators.check_operator import CheckOperator, ValueCheckOperator
-from airflow.providers.qubole.hooks.qubole import QuboleHook
+from airflow.operators.sql import SQLCheckOperator, SQLValueCheckOperator
 from airflow.providers.qubole.hooks.qubole_check import QuboleCheckHook
 from airflow.providers.qubole.operators.qubole import QuboleOperator
 from airflow.utils.decorators import apply_defaults
 
 
-class QuboleCheckOperator(CheckOperator, QuboleOperator):
+class _QuboleCheckOperatorMixin:
+    """This is a Mixin for Qubole related check operators"""
+
+    def execute(self, context=None) -> None:
+        """Execute a check operation againt Qubole"""
+        try:
+            self._hook_context = context
+            super().execute(context=context)
+        except AirflowException as e:
+            handle_airflow_exception(e, self.get_hook())
+
+    def get_db_hook(self) -> QuboleCheckHook:
+        """Get QuboleCheckHook"""
+        return self.get_hook()
+
+    # this overwrite the original QuboleOperator.get_hook() which returns a QuboleHook.
+    def get_hook(self) -> QuboleCheckHook:
+        """Reinitialising the hook, as some template fields might have changed"""
+        return QuboleCheckHook(
+            context=self._hook_context, results_parser_callable=self.results_parser_callable, **self.kwargs
+        )
+
+
+# pylint: disable=too-many-ancestors

Review comment:
       Temporarily disable pylint for these 2 operators. Will submit a second PR in the future to simplify the inheritance.




----------------------------------------------------------------
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.

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