Skip to content

Conversation

@mohit7705
Copy link
Contributor

This PR makes SQLAlchemy an optional dependency for the Postgres provider, following the same pattern already applied to other providers (for example Presto and Exasol).

Summary of changes

  • Removed hard SQLAlchemy imports from module level
  • Imported SQLAlchemy lazily inside methods that require it
  • Raised AirflowOptionalProviderFeatureException when SQLAlchemy-dependent functionality is used without SQLAlchemy installed
  • Kept SQLAlchemy as an optional extra dependency

This aligns the Postgres provider with the guidance described in the parent issue.

Note

Apologies for any confusion earlier — I had to delete the previous PR due to some local issues and have opened this new PR with the corrected and final changes.

References

@mohit7705
Copy link
Contributor Author

hi @potiuk
can you pls review this ,
tell me if any correction needed .

@mohit7705 mohit7705 requested a review from potiuk January 8, 2026 06:16
@mohit7705
Copy link
Contributor Author

Hi @justinpazkad @potiuk , I’m currently seeing a CI failure from a pre-commit hook related to imports in postgres.py.
I’m not fully sure whether the preferred approach here is to remove one of the imports, adjust the TYPE_CHECKING usage, or use an alternative pattern.
Could you please suggest the recommended way to handle this? Thanks!

@mohit7705 mohit7705 requested a review from justinpakzad January 8, 2026 08:36
@Prab-27
Copy link
Contributor

Prab-27 commented Jan 8, 2026

You need to install prek hook and run prek run --all-files .this will automatically fix the static checks

"apache-airflow-providers-openlineage",
# Additional devel dependencies (do not remove this line and add extra development dependencies)
"apache-airflow-providers-common-sql[pandas]",
"apache-airflow-providers-common-sql[polars]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add dependency here : related discussion : here

# Additional devel dependencies (do not remove this line and add extra development dependencies)
"apache-airflow-providers-common-sql[pandas]",
"apache-airflow-providers-common-sql[polars]",
"psycopg[binary]>=3.2.9",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@potiuk do we need to add just dependency without min version constraint ? (since min version already defined in optional dependency)
like : here

@mohit7705 mohit7705 closed this Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants