Dev-iL opened a new pull request, #69526:
URL: https://github.com/apache/airflow/pull/69526

    <!-- SPDX-License-Identifier: Apache-2.0
         https://www.apache.org/licenses/LICENSE-2.0 -->
   
   <!--
   Thank you for contributing!
   
   Please provide above a brief description of the changes made in this pull 
request.
   Write a good git commit message following this guide: 
http://chris.beams.io/posts/git-commit/
   
   Please make sure that your code changes are covered with tests.
   And in case of new features or big changes remember to adjust the 
documentation.
   
   For user-facing UI changes, please attach before/after screenshots (or a 
short
   screen recording) so reviewers can assess the visual impact.
   
   Feel free to ping (in general) for the review if you do not see reaction for 
a few days
   (72 Hours is the minimum reaction time you can expect from volunteers) - we 
sometimes miss notifications.
   
   In case of an existing issue, reference it using one of the following:
   
   * closes: #ISSUE
   * related: #ISSUE
   -->
   
   closes: 
   - #69443
   
   related:
   - #68453
   
   depends on:
   - #69469
   
   ---
   
   ### What changed (6 commits, one per package)
   
   1. **`providers/postgres`** — `psycopg2-binary` moves from a hard dependency 
to an optional `[psycopg2]` extra. The psycopg2-specific 
connection/cursor/`execute_values` imports are now lazy/guarded, raising a 
clear `AirflowOptionalProviderFeatureException` if genuinely needed but missing.
   2. **`providers/celery`** — the `[celery] result_backend` derivation from a 
driverless `sql_alchemy_conn` now targets `postgresql+psycopg://` (matching the 
new sync default) when psycopg (v3) is importable, falling back to 
`postgresql+psycopg2://` otherwise — mirroring the same guard `PostgresHook` 
uses.
   3. **`providers/google`** — `BigQueryToPostgresOperator`'s psycopg2-specific 
`register_adapter(list/dict, Json)` now only runs when the resolved 
`PostgresHook` connection is actually on psycopg2 (a no-op on psycopg3), so the 
module imports cleanly without psycopg2 installed.
   4. **`providers/pgvector`** — `PgVectorIngestOperator._register_vector` now 
calls the registration helper matching the connection's actual driver 
(`pgvector.psycopg2.register_vector` vs. `pgvector.psycopg.register_vector`) 
instead of always assuming psycopg2, fixing a pre-existing bug.
   5. **`providers/amazon`** — `RedshiftSQLHook.get_sqlalchemy_engine()` 
resolves an explicit driver (prefers psycopg, falls back to psycopg2, clear 
error if neither) instead of relying on SQLAlchemy's implicit psycopg2 default 
for a bare `postgresql://` URI. `get_uri()`'s own bare-scheme contract is 
untouched. Also updates the Batch/ECS/Lambda executor docs' example connection 
strings to `postgresql+psycopg://`.
   6. **`providers/common/sql`** — `DbApiHook.get_sqlalchemy_engine()` retries 
with an explicit driver only for the specific "bare `postgresql` scheme, driver 
import failed" case; any other scheme's failure still propagates unchanged, 
keeping the class DB-agnostic. This is the general safety net: any current or 
future `DbApiHook` subclass with a postgres-compatible `conn_type` that doesn't 
override `sqlalchemy_url` is covered by this fix, not just the two concrete 
cases (amazon, google) found so far.
   
   ### Test plan
   
   - New/updated tests per commit cover: the optional-psycopg2 fallback itself, 
both `USE_PSYCOPG3` branches in celery/google/pgvector, 
`PgVectorIngestOperator` registering against **both** a psycopg2-backed and 
psycopg3-backed connection, and `get_sqlalchemy_engine`'s 
driver-resolution/retry/re-raise/no-retry-for-other-schemes behavior in both 
amazon and common.sql.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, 
please
   change below checkbox to `[X]` followed by the name of the tool, uncomment 
the "Generated-by".
   -->
   
   - [x] Yes (please specify the tool below)
   
   <!--
   Generated-by: Claude Code Sonnet 5 following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->
   
   ---
   
   * Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information. Note: commit author/co-author name and email in commits 
become permanently public when merged.
   * For fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: 
`{pr_number}.significant.rst`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
 You can add this file in a follow-up commit after the PR is created so you 
know the PR number.
   


-- 
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]

Reply via email to