Search code examples
airflowtasksensorsdirected-acyclic-graphs

Apache Airflow SqlSensor


I trying to make SqlSensor to work with Oracle database, I've installed all the required provider and successfully tested the connection. When I run SqlSensor I got this error message

ERROR - Failed to execute job 32 for task check_exec_date (The connection type is not supported by SqlSensor. The associated hook should be a subclass of `DbApiHook`. Got OracleHook; 419)

I'm running Apache Airflow version 2.3.3 and installed Oracle provider apache-airflow-providers-oracle version 3.2.0


Solution

  • TL;DR:

    You are probably importing the sensor as:

    from airflow.sensors import SqlSensor
    

    Which cause the issue. If you will import as

    from airflow.providers.common.sql.sensors import SqlSensors
    

    It will work.

    Full Details:

    There is a bug in apache-airflow-providers-common-sql==1.0.0 which causes from airflow.sensors import SqlSensor not to work properly. The bug is fixed in https://github.com/apache/airflow/pull/25293 thus upgrading to apache-airflow-providers-common-sql>1.0.0 will allow also the old import style. Regardless of the bug, you should use

    from airflow.providers.common.sql.sensors import SqlSensors
    

    as from airflow.sensors import SqlSensor is deprecated.