diff --git a/dev/breeze/tests/test_selective_checks.py b/dev/breeze/tests/test_selective_checks.py index 9b26f0385021f..16468447e81c8 100644 --- a/dev/breeze/tests/test_selective_checks.py +++ b/dev/breeze/tests/test_selective_checks.py @@ -627,7 +627,7 @@ def assert_outputs_are_printed(expected_outputs: dict[str, str], stderr: str): "providers/postgres/tests/unit/postgres/file.py", ), { - "selected-providers-list-as-string": "amazon common.sql google " + "selected-providers-list-as-string": "amazon common.compat common.sql google " "microsoft.azure openlineage pgvector postgres", "all-python-versions": f"['{DEFAULT_PYTHON_MAJOR_MINOR_VERSION}']", "all-python-versions-list-as-string": DEFAULT_PYTHON_MAJOR_MINOR_VERSION, @@ -650,7 +650,7 @@ def assert_outputs_are_printed(expected_outputs: dict[str, str], stderr: str): { "description": "amazon...google", "test_types": "Providers[amazon] " - "Providers[common.sql,microsoft.azure,openlineage,pgvector,postgres] " + "Providers[common.compat,common.sql,microsoft.azure,openlineage,pgvector,postgres] " "Providers[google]", } ] diff --git a/providers/postgres/pyproject.toml b/providers/postgres/pyproject.toml index 6a2e1aee0ab7c..b835a54b7b3a5 100644 --- a/providers/postgres/pyproject.toml +++ b/providers/postgres/pyproject.toml @@ -58,6 +58,7 @@ requires-python = ">=3.10" # After you modify the dependencies, and rebuild your Breeze CI image with ``breeze ci-image build`` dependencies = [ "apache-airflow>=2.10.0", + "apache-airflow-providers-common-compat>=1.7.4", # + TODO: bump to next version "apache-airflow-providers-common-sql>=1.23.0", "psycopg2-binary>=2.9.9; python_version < '3.13'", "psycopg2-binary>=2.9.10; python_version >= '3.13'", @@ -93,6 +94,7 @@ dev = [ "apache-airflow-task-sdk", "apache-airflow-devel-common", "apache-airflow-providers-amazon", + "apache-airflow-providers-common-compat", "apache-airflow-providers-common-sql", "apache-airflow-providers-microsoft-azure", "apache-airflow-providers-openlineage", diff --git a/providers/postgres/src/airflow/providers/postgres/hooks/postgres.py b/providers/postgres/src/airflow/providers/postgres/hooks/postgres.py index 5fecc36556a20..1b678160591bb 100644 --- a/providers/postgres/src/airflow/providers/postgres/hooks/postgres.py +++ b/providers/postgres/src/airflow/providers/postgres/hooks/postgres.py @@ -35,14 +35,10 @@ AirflowException, AirflowOptionalProviderFeatureException, ) +from airflow.providers.common.compat.sdk import Connection from airflow.providers.common.sql.hooks.sql import DbApiHook from airflow.providers.postgres.dialects.postgres import PostgresDialect -try: - from airflow.sdk import Connection -except ImportError: - from airflow.models.connection import Connection # type: ignore[assignment] - USE_PSYCOPG3: bool try: import psycopg as psycopg # needed for patching in unit tests