-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add method 'callproc' on Oracle hook #20072
Conversation
4eb8424
to
13d731c
Compare
hook = OracleHook(oracle_conn_id=self.oracle_conn_id) | ||
hook.run(self.sql, autocommit=self.autocommit, parameters=self.parameters) | ||
if self.sql: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should be two separate operators- one for running SQL statements and one for calling procedures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mik-laj I have split the functionality now, introducing a new operator OracleStoredProcedureOperator
. This always has autocommit
enabled – because that's really what makes sense.
446627f
to
4be2aaf
Compare
This adds a new method:
(In the actual code, the
parameters
argument are assigned a type variableParameterType
since the return type of the method is determined by the type of theparameters
argument).The call mirrors the
Cursor.callproc()
method provided by the driver except:cursor
object (which is not available to us using the DB API hook abstraction), the user must instead pass a Python type reference (e.g.,int
) as the value of the parameter.cursor.var
to create a bind variable in the first place.In addition, an optional
procedure
argument has been added toOracleOperator
. This can be used instead ofsql
to call a stored procedure directly from the operator.This functionality builds on #15581.