diff --git a/plugins/snowflake/dbt/adapters/snowflake/connections.py b/plugins/snowflake/dbt/adapters/snowflake/connections.py index f2005b50c47..2952d364a66 100644 --- a/plugins/snowflake/dbt/adapters/snowflake/connections.py +++ b/plugins/snowflake/dbt/adapters/snowflake/connections.py @@ -252,12 +252,18 @@ def add_query(self, sql, auto_begin=True, ) if cursor is None: + conn = self.get_thread_connection() + if conn is None or conn.name is None: + conn_name = '' + else: + conn_name = conn.name + raise dbt.exceptions.RuntimeException( "Tried to run an empty query on model '{}'. If you are " "conditionally running\nsql, eg. in a model hook, make " "sure your `else` clause contains valid sql!\n\n" "Provided SQL:\n{}" - .format(self.nice_connection_name(), sql) + .format(conn_name, sql) ) return connection, cursor