Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions providers/src/airflow/providers/oracle/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
Changelog
---------


main
.....

.. warning::
All deprecated classes, parameters and features have been removed from the oracle provider package.
The following breaking changes were introduced:

* ``Removed deprecated OracleOperator. Use airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator instead.``
* ``Removed using conn.schema to pass the Oracle Service Name as its deprecated. Use conn.extra.service_name instead.``

3.12.1
......

Expand Down
9 changes: 0 additions & 9 deletions providers/src/airflow/providers/oracle/hooks/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import oracledb

from airflow.exceptions import AirflowProviderDeprecationWarning
from airflow.providers.common.sql.hooks.sql import DbApiHook

PARAM_TYPES = {bool, float, int, str}
Expand Down Expand Up @@ -197,14 +196,6 @@ def get_conn(self) -> oracledb.Connection:
dsn += f":{conn.port}"
if service_name:
dsn += f"/{service_name}"
elif conn.schema:
warnings.warn(
"""Using conn.schema to pass the Oracle Service Name is deprecated.
Please use conn.extra.service_name instead.""",
AirflowProviderDeprecationWarning,
stacklevel=2,
)
dsn += f"/{conn.schema}"
conn_config["dsn"] = dsn

if "events" in conn.extra_dejson:
Expand Down
40 changes: 1 addition & 39 deletions providers/src/airflow/providers/oracle/operators/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,55 +19,17 @@

import re
from collections.abc import Sequence
from typing import TYPE_CHECKING, ClassVar
from typing import TYPE_CHECKING

import oracledb
from deprecated import deprecated

from airflow.exceptions import AirflowProviderDeprecationWarning
from airflow.models import BaseOperator
from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
from airflow.providers.oracle.hooks.oracle import OracleHook

if TYPE_CHECKING:
from airflow.utils.context import Context


@deprecated(
reason="Please use `airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator`.",
category=AirflowProviderDeprecationWarning,
)
class OracleOperator(SQLExecuteQueryOperator):
"""
Executes sql code in a specific Oracle database.

This class is deprecated.

Please use :class:`airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator`.

:param sql: the sql code to be executed. Can receive a str representing a sql statement,
a list of str (sql statements), or reference to a template file.
Template reference are recognized by str ending in '.sql'
(templated)
:param oracle_conn_id: The :ref:`Oracle connection id <howto/connection:oracle>`
reference to a specific Oracle database.
:param parameters: (optional, templated) the parameters to render the SQL query with.
:param autocommit: if True, each command is automatically committed.
(default value: False)
"""

template_fields: Sequence[str] = (
"parameters",
"sql",
)
template_ext: Sequence[str] = (".sql",)
template_fields_renderers: ClassVar[dict] = {"sql": "sql"}
ui_color = "#ededed"

def __init__(self, *, oracle_conn_id: str = "oracle_default", **kwargs) -> None:
super().__init__(conn_id=oracle_conn_id, **kwargs)


class OracleStoredProcedureOperator(BaseOperator):
"""
Executes stored procedure in a specific Oracle database.
Expand Down
32 changes: 1 addition & 31 deletions providers/tests/oracle/operators/test_oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,9 @@
import oracledb
import pytest

from airflow.exceptions import AirflowProviderDeprecationWarning
from airflow.models import TaskInstance
from airflow.providers.common.sql.hooks.sql import fetch_all_handler
from airflow.providers.oracle.hooks.oracle import OracleHook
from airflow.providers.oracle.operators.oracle import OracleOperator, OracleStoredProcedureOperator


class TestOracleOperator:
@mock.patch("airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator.get_db_hook")
def test_execute(self, mock_get_db_hook):
sql = "SELECT * FROM test_table"
oracle_conn_id = "oracle_default"
parameters = {"parameter": "value"}
autocommit = False
context = "test_context"
task_id = "test_task_id"

with pytest.warns(AirflowProviderDeprecationWarning, match="Call to deprecated class *"):
operator = OracleOperator(
sql=sql,
oracle_conn_id=oracle_conn_id,
parameters=parameters,
autocommit=autocommit,
task_id=task_id,
)
operator.execute(context=context)
mock_get_db_hook.return_value.run.assert_called_once_with(
sql=sql,
autocommit=autocommit,
parameters=parameters,
handler=fetch_all_handler,
return_last=True,
)
from airflow.providers.oracle.operators.oracle import OracleStoredProcedureOperator


class TestOracleStoredProcedureOperator:
Expand Down
Loading