Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SnowflakeCheckOperator connection id template issue #33679

Closed
1 of 2 tasks
joeknize-bc opened this issue Aug 23, 2023 · 2 comments · Fixed by #33681
Closed
1 of 2 tasks

SnowflakeCheckOperator connection id template issue #33679

joeknize-bc opened this issue Aug 23, 2023 · 2 comments · Fixed by #33681
Assignees
Labels
area:providers kind:bug This is a clearly a bug provider:snowflake Issues related to Snowflake provider

Comments

@joeknize-bc
Copy link
Contributor

joeknize-bc commented Aug 23, 2023

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

@joeknize-bc joeknize-bc added area:core kind:bug This is a clearly a bug needs-triage label for new issues that we didn't triage yet labels Aug 23, 2023
@joeknize-bc joeknize-bc changed the title SnowflakeCheckOperator SnowflakeCheckOperator connection id template issue Aug 23, 2023
@SamWheating
Copy link
Contributor

I have replicated this issue on main, will try to put up a fix shortly.

@Taragolis Taragolis added area:providers provider:snowflake Issues related to Snowflake provider and removed area:core needs-triage label for new issues that we didn't triage yet labels Aug 23, 2023
@joeknize-bc
Copy link
Contributor Author

Thank you for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers kind:bug This is a clearly a bug provider:snowflake Issues related to Snowflake provider
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants