Skip to content

Allow Common AI SQL imports without DataFusion - #69990

Merged
Lee-W merged 1 commit into
apache:mainfrom
aaron-y-chen:fix-common-ai-sql-import-without-datafusion
Jul 22, 2026
Merged

Allow Common AI SQL imports without DataFusion#69990
Lee-W merged 1 commit into
apache:mainfrom
aaron-y-chen:fix-common-ai-sql-import-without-datafusion

Conversation

@aaron-y-chen

Copy link
Copy Markdown
Contributor

Summary

LLMSQLQueryOperator eagerly imports DataFusionEngine. This works in the development environment because apache-airflow-providers-common-sql[datafusion] is installed as a dev dependency:

"apache-airflow-providers-common-sql[datafusion]",

However, the Common AI sql extra does not install DataFusion, so importing the operator fails in production installations where DataFusion is absent.

Bug Reproduction

Use docker to install airflow and common-ai provider, then import LLMSQLQueryOperator.

$ docker run --rm -it python:3.12-slim bash
$ python -m venv /tmp/airflow-repro
$ . /tmp/airflow-repro/bin/activate
$ python -m pip install --upgrade pip

$ python -m pip install --no-cache-dir "apache-airflow==3.3.0"  "apache-airflow-providers-common-ai[sql]==0.6.0"

$ python -m pip show datafusion
WARNING: Package(s) not found: datafusion

$ python -c "from airflow.providers.common.ai.operators.llm_sql import LLMSQLQueryOperator"
ModuleNotFoundError: No module named 'datafusion'

After fix

Build the Common AI provider wheel from this PR, then install its sql extra with Airflow 3.3.0 in a fresh python:3.12-slim container.

$ python -m pip show datafusion
WARNING: Package(s) not found: datafusion

$ python -c "from airflow.providers.common.ai.operators.llm_sql import LLMSQLQueryOperator; print('operator import: OK')"
operator import: OK

$ python -c "from airflow.providers.common.ai.decorators.llm_sql import llm_sql_task; print('decorator import: OK')"
decorator import: OK


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: [Claude Fable 5] following the guidelines

@aaron-y-chen
aaron-y-chen marked this pull request as ready for review July 19, 2026 12:40
@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jul 20, 2026
@kaxil

kaxil commented Jul 21, 2026

Copy link
Copy Markdown
Member

@nailo2c Can you rebase on main please to resolve merge conflicts?

@aaron-y-chen

Copy link
Copy Markdown
Contributor Author

Sure, let me do it.

@aaron-y-chen
aaron-y-chen force-pushed the fix-common-ai-sql-import-without-datafusion branch from ff79299 to 61eaaba Compare July 22, 2026 02:21
@Lee-W
Lee-W merged commit 532e7d0 into apache:main Jul 22, 2026
95 checks passed
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