Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ A task defined or implemented by a operator is a unit of work in your data pipel
The purpose of this guide is to define tasks involving interactions with a PostgreSQL database with
the :class:`~airflow.providers.common.sql.operators.SQLExecuteQueryOperator`.

.. warning::
Previously, PostgresOperator was used to perform this kind of operation. But at the moment PostgresOperator is deprecated and will be removed in future versions of the provider. Please consider to switch to SQLExecuteQueryOperator as soon as possible.
.. note::
Previously, PostgresOperator was used to perform this kind of operation. After deprecation this has been removed. Please use SQLExecuteQueryOperator instead.

Common Database Operations with SQLExecuteQueryOperator
-------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions docs/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ getframe
getint
GetPartitions
getsource
getters
gevent
GH
GiB
Expand Down
15 changes: 15 additions & 0 deletions providers/src/airflow/providers/postgres/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@
Changelog
---------

main
....

Breaking changes
~~~~~~~~~~~~~~~~

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

* Hooks
* The ``schema`` arg has been renamed to ``database`` as it contained the database name. Deprecated parameters, getters and setters have been removed. Please use ``database`` to set the database name.
* Operators
* Remove ``airflow.providers.postgres.operators.postgres.PostgresOperator``. Please use ``airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator`` instead.

5.14.0
......

Expand Down
33 changes: 0 additions & 33 deletions providers/src/airflow/providers/postgres/hooks/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from __future__ import annotations

import os
import warnings
from collections.abc import Iterable
from contextlib import closing
from copy import deepcopy
Expand All @@ -27,11 +26,9 @@
import psycopg2
import psycopg2.extensions
import psycopg2.extras
from deprecated import deprecated
from psycopg2.extras import DictCursor, NamedTupleCursor, RealDictCursor
from sqlalchemy.engine import URL

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

if TYPE_CHECKING:
Expand Down Expand Up @@ -92,42 +89,12 @@ class PostgresHook(DbApiHook):
def __init__(
self, *args, options: str | None = None, enable_log_db_messages: bool = False, **kwargs
) -> None:
if "schema" in kwargs:
warnings.warn(
'The "schema" arg has been renamed to "database" as it contained the database name.'
'Please use "database" to set the database name.',
AirflowProviderDeprecationWarning,
stacklevel=2,
)
kwargs["database"] = kwargs["schema"]
super().__init__(*args, **kwargs)
self.conn: connection = None
self.database: str | None = kwargs.pop("database", None)
self.options = options
self.enable_log_db_messages = enable_log_db_messages

@property
@deprecated(
reason=(
'The "schema" variable has been renamed to "database" as it contained the database name.'
'Please use "database" to get the database name.'
),
category=AirflowProviderDeprecationWarning,
)
def schema(self):
return self.database

@schema.setter
@deprecated(
reason=(
'The "schema" variable has been renamed to "database" as it contained the database name.'
'Please use "database" to set the database name.'
),
category=AirflowProviderDeprecationWarning,
)
def schema(self, value):
self.database = value

@property
def sqlalchemy_url(self) -> URL:
conn = self.get_connection(self.get_conn_id())
Expand Down
17 changes: 0 additions & 17 deletions providers/src/airflow/providers/postgres/operators/__init__.py

This file was deleted.

88 changes: 0 additions & 88 deletions providers/src/airflow/providers/postgres/operators/postgres.py

This file was deleted.

5 changes: 0 additions & 5 deletions providers/src/airflow/providers/postgres/provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ integrations:
logo: /integration-logos/postgres/Postgres.png
tags: [software]

operators:
- integration-name: PostgreSQL
python-modules:
- airflow.providers.postgres.operators.postgres

hooks:
- integration-name: PostgreSQL
python-modules:
Expand Down
10 changes: 0 additions & 10 deletions providers/tests/postgres/hooks/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import psycopg2.extras
import pytest

from airflow.exceptions import AirflowProviderDeprecationWarning
from airflow.models import Connection
from airflow.providers.postgres.hooks.postgres import PostgresHook
from airflow.utils.types import NOTSET
Expand Down Expand Up @@ -340,15 +339,6 @@ def test_get_uri_from_connection_with_database_override(self):
)
assert hook.get_uri() == "postgresql://login:password@host:1/database-override"

def test_schema_kwarg_database_kwarg_compatibility(self):
database = "database-override"
with pytest.warns(
AirflowProviderDeprecationWarning,
match='The "schema" arg has been renamed to "database" as it contained the database name.Please use "database" to set the database name.',
):
hook = PostgresHook(schema=database)
assert hook.database == database

@mock.patch("airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook")
@pytest.mark.parametrize("aws_conn_id", [NOTSET, None, "mock_aws_conn"])
@pytest.mark.parametrize("port", [5432, 5439, None])
Expand Down
17 changes: 0 additions & 17 deletions providers/tests/postgres/operators/__init__.py

This file was deleted.

Loading