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).
That is, for a stored procedure operator I would have autocommit enabled as
the default setting.
(Probably even for the SQL statement operator, but such defaults are not
easily changed.)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]