Skip to content

Snowflake connections do not work correctly with SqlSensor #15948

@drboyer

Description

@drboyer

Apache Airflow version: 1.10.x (issue was partially fixed with #9843 in 1.10.12, but is not completely fixed in 1.10.15)

Kubernetes version (if you are using kubernetes) (use kubectl version): n/a

Environment: not relevant here

What happened:

When using a Snowflake connection with the SqlSensor, the following exception is thrown:

[2021-05-12 13:51:09,356] {taskinstance.py:1150} ERROR - Unknown hook type snowflake
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/airflow/models/taskinstance.py", line 984, in _run_raw_task
    result = task_copy.execute(context=context)
  File "/usr/local/lib/python3.7/site-packages/airflow/sensors/base_sensor_operator.py", line 107, in execute
    while not self.poke(context):
  File "/usr/local/lib/python3.7/site-packages/airflow/sensors/sql_sensor.py", line 87, in poke
    hook = self._get_hook()
  File "/usr/local/lib/python3.7/site-packages/airflow/sensors/sql_sensor.py", line 84, in _get_hook
    return conn.get_hook()
  File "/usr/local/lib/python3.7/site-packages/airflow/models/connection.py", line 309, in get_hook
    raise AirflowException("Unknown hook type {}".format(self.conn_type))
airflow.exceptions.AirflowException: Unknown hook type snowflake

What you expected to happen:

The Snowflake connection is used successfully and the SQL query runs on Snowflake.

How to reproduce it:

  • Add a Snowflake connection
  • Add a SqlSensor task to a DAG where the conn_id is the Snowflake connection
  • Attempt to run the DAG

Anything else we need to know:

I have a fix that I've made on our internal Airflow instances, but want to contribute it back upstream.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:bugThis is a clearly a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions