uranusjr commented on code in PR #27319:
URL: https://github.com/apache/airflow/pull/27319#discussion_r1015387980
##########
airflow/providers/oracle/operators/oracle.py:
##########
@@ -93,4 +99,11 @@ def __init__(
def execute(self, context: Context):
self.log.info("Executing: %s", self.procedure)
hook = OracleHook(oracle_conn_id=self.oracle_conn_id)
- return hook.callproc(self.procedure, autocommit=True,
parameters=self.parameters)
+ ti = context.get("task_instance")
+ try:
+ return hook.callproc(self.procedure, autocommit=True,
parameters=self.parameters)
+ except oracledb.DatabaseError as e:
+ code_match = re.search("^ORA-(\\d+):.+", str(e))
+ if code_match and self.do_xcom_push and ti:
+ ti.xcom_push(key="ORA", value=code_match.group(1))
Review Comment:
```suggestion
if not self.do_xcom_push or not ti:
raise
code_match = re.search("^ORA-(\\d+):.+", str(e))
if code_match:
ti.xcom_push(key="ORA", value=code_match.group(1))
```
This saves the regex match unless needed.
--
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]