Skip to content

SnowflakeCheckOperator connection id template issue #33679

@joeknize-bc

Description

@joeknize-bc

Apache Airflow version

2.7.0

What happened

When upgrading to apache-airflow-providers-snowflake==4.4.2, our SnowflakeCheckOperators are all failing with similar messages. The affected code seems to be from this PR.
Code:

    check_order_load = SnowflakeCheckOperator(
        task_id="check_row_count",
        sql='check_orders_load.sql',
        snowflake_conn_id=SF_CONNECTION_ID,
    )

Errors:

[2023-08-23, 20:58:23 UTC] {taskinstance.py:1943} ERROR - Task failed with exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/airflow/models/abstractoperator.py", line 664, in _do_render_template_fields
    value = getattr(parent, attr_name)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SnowflakeCheckOperator' object has no attribute 'snowflake_conn_id'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/airflow/models/taskinstance.py", line 1518, in _run_raw_task
    self._execute_task_with_callbacks(context, test_mode, session=session)
  File "/usr/local/lib/python3.11/site-packages/airflow/models/taskinstance.py", line 1646, in _execute_task_with_callbacks
    task_orig = self.render_templates(context=context)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/airflow/models/taskinstance.py", line 2291, in render_templates
    original_task.render_template_fields(context)
  File "/usr/local/lib/python3.11/site-packages/airflow/models/baseoperator.py", line 1244, in render_template_fields
    self._do_render_template_fields(self, self.template_fields, context, jinja_env, set())
  File "/usr/local/lib/python3.11/site-packages/airflow/utils/session.py", line 77, in wrapper
    return func(*args, session=session, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/airflow/models/abstractoperator.py", line 666, in _do_render_template_fields
    raise AttributeError(
AttributeError: 'snowflake_conn_id' is configured as a template field but SnowflakeCheckOperator does not have this attribute.```

What you think should happen instead

This works fine in apache-airflow-providers-snowflake==4.4.1 - no errors.

How to reproduce

With apache-airflow-providers-snowflake==4.4.2

Try running this code:

from airflow.providers.snowflake.operators.snowflake import SnowflakeCheckOperator

    check_task = SnowflakeCheckOperator(
        task_id='check_gmv_yoy',
        sql='select 1',
        snowflake_conn_id='NAME_OF_CONNECTION_ID',
    )

Operating System

Debian GNU/Linux 11 (bullseye)

Versions of Apache Airflow Providers

apache-airflow-providers-snowflake==4.4.2

Deployment

Astronomer

Deployment details

No response

Anything else

This happens every time with 4.4.2, never with <= 4.4.1.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions