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 2021/12/06 20:00:15 UTC

[GitHub] [airflow] malthe commented on a change in pull request #20072: Add method 'callproc' on Oracle hook

malthe commented on a change in pull request #20072:
URL: https://github.com/apache/airflow/pull/20072#discussion_r763341289



##########
File path: airflow/providers/oracle/operators/oracle.py
##########
@@ -47,19 +49,26 @@ class OracleOperator(BaseOperator):
     def __init__(
         self,
         *,
-        sql: Union[str, List[str]],
+        sql: Optional[Union[str, List[str]]] = None,
+        procedure: Optional[str] = None,
         oracle_conn_id: str = 'oracle_default',
         parameters: Optional[Union[Mapping, Iterable]] = None,
         autocommit: bool = False,
         **kwargs,
     ) -> None:
+        if sql is None and procedure is None:
+            raise ValueError("Must provide either 'sql' or 'procedure'")
         super().__init__(**kwargs)
         self.oracle_conn_id = oracle_conn_id
         self.sql = sql
+        self.procedure = procedure
         self.autocommit = autocommit
         self.parameters = parameters
 
     def execute(self, context) -> None:
-        self.log.info('Executing: %s', self.sql)
+        self.log.info('Executing: %s', self.sql or self.procedure)
         hook = OracleHook(oracle_conn_id=self.oracle_conn_id)
-        hook.run(self.sql, autocommit=self.autocommit, parameters=self.parameters)
+        if self.sql:

Review comment:
       @mik-laj it does perhaps make sense considering that autocommit (see also #20085) is disabled in the operator that runs SQL statements while for calling stored procedures – in the context of an Airflow operator – it makes sense to autocommit (given that the stored procedure itself runs inside a subtransaction).




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