Repository: dbt-labs/dbt-core

Issue:
Specify the `application` field in Snowflake connections
## Feature

### Feature description
dbt should specify the `application` field in Snowflake connections. This field isn't exposed externally, but can be used by the Snowflake team to trace queries back to the applications which generate them.


Discussion:

Resolving patch:
diff --git a/plugins/snowflake/dbt/adapters/snowflake/connections.py b/plugins/snowflake/dbt/adapters/snowflake/connections.py
--- a/plugins/snowflake/dbt/adapters/snowflake/connections.py
+++ b/plugins/snowflake/dbt/adapters/snowflake/connections.py
@@ -131,6 +131,7 @@ def open(cls, connection):
                 autocommit=False,
                 client_session_keep_alive=credentials.get(
                     'client_session_keep_alive', False),
+                application='dbt',
                 **auth_args
             )
 


Test patch:
diff --git a/test/unit/test_snowflake_adapter.py b/test/unit/test_snowflake_adapter.py
--- a/test/unit/test_snowflake_adapter.py
+++ b/test/unit/test_snowflake_adapter.py
@@ -164,7 +164,7 @@ def test_client_session_keep_alive_false_by_default(self):
                 account='test_account', autocommit=False,
                 client_session_keep_alive=False, database='test_database',
                 role=None, schema='public', user='test_user',
-                warehouse='test_warehouse', private_key=None)
+                warehouse='test_warehouse', private_key=None, application='dbt')
         ])
 
     def test_client_session_keep_alive_true(self):
@@ -178,7 +178,7 @@ def test_client_session_keep_alive_true(self):
                 account='test_account', autocommit=False,
                 client_session_keep_alive=True, database='test_database',
                 role=None, schema='public', user='test_user',
-                warehouse='test_warehouse', private_key=None)
+                warehouse='test_warehouse', private_key=None, application='dbt')
         ])
 
     def test_user_pass_authentication(self):
@@ -192,7 +192,8 @@ def test_user_pass_authentication(self):
                 account='test_account', autocommit=False,
                 client_session_keep_alive=False, database='test_database',
                 password='test_password', role=None, schema='public',
-                user='test_user', warehouse='test_warehouse', private_key=None)
+                user='test_user', warehouse='test_warehouse', private_key=None,
+                application='dbt')
         ])
 
     def test_authenticator_user_pass_authentication(self):
@@ -207,7 +208,8 @@ def test_authenticator_user_pass_authentication(self):
                 client_session_keep_alive=False, database='test_database',
                 password='test_password', role=None, schema='public',
                 user='test_user', warehouse='test_warehouse',
-                authenticator='test_sso_url', private_key=None)
+                authenticator='test_sso_url', private_key=None,
+                application='dbt')
         ])
 
     def test_authenticator_externalbrowser_authentication(self):
@@ -222,7 +224,7 @@ def test_authenticator_externalbrowser_authentication(self):
                 client_session_keep_alive=False, database='test_database',
                 role=None, schema='public', user='test_user',
                 warehouse='test_warehouse', authenticator='externalbrowser',
-                private_key=None)
+                private_key=None, application='dbt')
         ])
 
     @patch('dbt.adapters.snowflake.SnowflakeConnectionManager._get_private_key', return_value='test_key')
@@ -239,5 +241,6 @@ def test_authenticator_private_key_authentication(self, mock_get_private_key):
                 account='test_account', autocommit=False,
                 client_session_keep_alive=False, database='test_database',
                 role=None, schema='public', user='test_user',
-                warehouse='test_warehouse', private_key='test_key')
+                warehouse='test_warehouse', private_key='test_key',
+                application='dbt')
         ])