You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "prabhnoor0212 (via GitHub)" <gi...@apache.org> on 2026/10/15 01:17:42 UTC
[PR] Make OpenLineage SQL schema lookup configurable [airflow]
prabhnoor0212 opened a new pull request, #74776:
URL: https://github.com/apache/airflow/pull/74776
Allow SQL OpenLineage extraction to skip external database schema lookups when they are slow or unreliable. When disabled, the SQLAlchemy engine is not created, while connection details remain available for database namespace and dialect identification.
This preserves table-level lineage parsing while allowing schema facets to be less complete.
Validation completed:
- OpenLineage suite: 1,049 passed, 91 skipped
- Common SQL suite: 571 passed, 14 skipped
- Focused regression test and Ruff checks passed
- `prek run --from-ref main --stage pre-commit` passed with Python 3.11
- `git diff --check` passed
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (OpenAI ChatGPT)
Generated-by: OpenAI ChatGPT following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
---
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make OpenLineage SQL schema lookup configurable [airflow]
Posted by "prabhnoor0212 (via GitHub)" <gi...@apache.org>.
prabhnoor0212 commented on code in PR #74776:
URL: https://github.com/apache/airflow/pull/74776#discussion_r4303502137
##########
providers/common/sql/src/airflow/providers/common/sql/operators/sql.py:
##########
@@ -321,7 +321,7 @@ def get_openlineage_facets_on_start(self) -> OperatorLineage | None:
hook=hook,
database_info=database_info,
database=self.database,
- sqlalchemy_engine=hook.get_sqlalchemy_engine(),
+ sqlalchemy_engine=hook.get_sqlalchemy_engine() if use_external_connection else None,
Review Comment:
Thanks, addressed in the latest commit. When `sql_use_external_connection` is disabled, the default schema is no longer queried for Postgres, Redshift, MSSQL and Oracle. A new get_default_schema helper in sqlparser.py returns a static default instead: public, dbo, and the uppercased login for Oracle. Both SQLExecuteQueryOperator and the shared helper use it. Hooks that already take the schema from connection settings (Snowflake, Databricks, Trino, etc.) are still asked as before, so their schema is kept. Oracle connections without a login still query; the config description says so.
But, I'd like your view on the design, since there's a tradeoff:
1. *Keep static defaults in the OpenLineage provider (current approach).* This is correct for the common setup, but it can be confidently wrong: Postgres search_path defaults to "$user", public, MSSQL users can have a non-dbo default schema, and Oracle CURRENT_SCHEMA can differ from the login. It also relies on a dialect list so a third party hook that queries for its default schema would still query.
2. *Let each hook opt in with an offline default-schema method,* and leave the schema unqualified when a hook doesn't provide one. That avoids guessing and doesn't depend on a dialect list. But from_table_meta would need to omit a missing schema (today it renders db.None.table), and the change would touch the postgres, amazon, microsoft.mssql and oracle providers.
Do you have a preference, or a different approach in mind?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make OpenLineage SQL schema lookup configurable [airflow]
Posted by "mobuchowski (via GitHub)" <gi...@apache.org>.
mobuchowski commented on code in PR #74776:
URL: https://github.com/apache/airflow/pull/74776#discussion_r4281405098
##########
providers/openlineage/src/airflow/providers/openlineage/utils/utils.py:
##########
@@ -2242,8 +2242,9 @@ def get_filtered_unknown_operator_keys(operator: BaseOperator) -> dict:
def should_use_external_connection(hook) -> bool:
- # If we're at Airflow 2.10, the execution is process-isolated, so we can safely run those again.
- return True
+ from airflow.providers.openlineage import conf
+
+ return conf.sql_use_external_connection()
Review Comment:
Changing should_use_external_connection() does not cover all SQL lineage extraction paths. For example, MySQLToGCSOperator calls get_openlineage_facets_with_sql() through common.compat. With a current OpenLineage provider, that resolves to the implementation in openlineage/sqlparser.py, which defaults to use_connection=True and never checks should_use_external_connection().
The check in common.compat only runs in its fallback implementation for older OpenLineage versions. Consequently, MySQLToGCSOperator can still query information_schema when sql_use_external_connection=False.
Please make the shared helper in openlineage/sqlparser.py honor the setting too, while preserving use_connection=False when explicitly passed by a caller.
##########
providers/common/sql/src/airflow/providers/common/sql/operators/sql.py:
##########
@@ -321,7 +321,7 @@ def get_openlineage_facets_on_start(self) -> OperatorLineage | None:
hook=hook,
database_info=database_info,
database=self.database,
- sqlalchemy_engine=hook.get_sqlalchemy_engine(),
+ sqlalchemy_engine=hook.get_sqlalchemy_engine() if use_external_connection else None,
Review Comment:
When the setting is false and the operator uses PostgresHook or MsSqlHook, extraction still calls get_openlineage_default_schema() before reaching this guard. Those implementations execute SELECT CURRENT_SCHEMA; and SELECT SCHEMA_NAME();, respectively, opening an external database connection. A slow or unavailable database can therefore still block extraction or raise before table-only lineage is generated. The disabled path also needs to avoid database-backed default-schema discovery or provide an offline fallback.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make OpenLineage SQL schema lookup configurable [airflow]
Posted by "prabhnoor0212 (via GitHub)" <gi...@apache.org>.
prabhnoor0212 commented on code in PR #74776:
URL: https://github.com/apache/airflow/pull/74776#discussion_r4303505011
##########
providers/openlineage/src/airflow/providers/openlineage/utils/utils.py:
##########
@@ -2242,8 +2242,9 @@ def get_filtered_unknown_operator_keys(operator: BaseOperator) -> dict:
def should_use_external_connection(hook) -> bool:
- # If we're at Airflow 2.10, the execution is process-isolated, so we can safely run those again.
- return True
+ from airflow.providers.openlineage import conf
+
+ return conf.sql_use_external_connection()
Review Comment:
`get_openlineage_facets_with_sql` in `openlineage/sqlparser.py` now checks `should_use_external_connection()` too, so operators going through the shared helper (such as MySQLToGCSOperator) honor sql_use_external_connection=False. An explicit use_connection=False from a caller is still respected: the effective value is use_connection and should_use_external_connection(hook)
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make OpenLineage SQL schema lookup configurable [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #74776:
URL: https://github.com/apache/airflow/pull/74776#issuecomment-6182142298
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our [Contributors' Guide](https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:
- Pay attention to the quality of your code (ruff, mypy and type annotations). Our [prek-hooks]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-prek-hooks) will help you with that.
- In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/airflow-core/docs/howto/custom-operator.rst) Consider adding an example Dag that shows how users should use it.
- Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
- Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
- Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
- Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
- Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
Apache Airflow is a community-driven project and together we are making it better 🚀.
In case of doubts contact the developers at:
Mailing List: dev@airflow.apache.org
Slack: https://s.apache.org/airflow-slack
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make OpenLineage SQL schema lookup configurable [airflow]
Posted by "github-actions[bot] (via GitHub) via commits" <co...@airflow.apache.org>.
github-actions[bot] commented on PR #74776:
URL: https://github.com/apache/airflow/pull/74776#issuecomment-7330409675
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make OpenLineage SQL schema lookup configurable [airflow]
Posted by "kacpermuda (via GitHub) via commits" <co...@airflow.apache.org>.
kacpermuda commented on code in PR #74776:
URL: https://github.com/apache/airflow/pull/74776#discussion_r4771585397
##########
providers/openlineage/src/airflow/providers/openlineage/conf.py:
##########
@@ -175,6 +175,12 @@ def execute_in_thread() -> bool:
return conf.getboolean(_CONFIG_SECTION, "execute_in_thread", fallback="False")
+@cache
Review Comment:
Instead of a general kill switch, can we look into extending current emission policy for that use case? In that case, it could be scoped as needed, globally or per operator, hook etc. I'd prefer such solution over this one - it allows more users to tweak OL to their specific needs.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org