diff --git a/.changes/unreleased/Under the Hood-20240215-151417.yaml b/.changes/unreleased/Under the Hood-20240215-151417.yaml new file mode 100644 index 000000000..608e10d05 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20240215-151417.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Add `session_id` to `SnowflakeAdapterResponse` +time: 2024-02-15T15:14:17.873819247+01:00 +custom: + Author: jeppe742 + Issue: "881" diff --git a/dbt/adapters/snowflake/connections.py b/dbt/adapters/snowflake/connections.py index 6b325ab9c..2eef68131 100644 --- a/dbt/adapters/snowflake/connections.py +++ b/dbt/adapters/snowflake/connections.py @@ -85,6 +85,7 @@ def snowflake_private_key(private_key: RSAPrivateKey) -> bytes: @dataclass class SnowflakeAdapterResponse(AdapterResponse): query_id: str = "" + session_id: str = "" @dataclass @@ -444,7 +445,8 @@ def get_response(cls, cursor) -> SnowflakeAdapterResponse: rows_affected=cursor.rowcount, code=code, query_id=cursor.sfqid, - ) + session_id=str(cursor.connection.session_id) + ) # type: ignore # disable transactional logic by default on Snowflake # except for DML statements where explicitly defined diff --git a/tests/functional/artifacts/test_run_results.py b/tests/functional/artifacts/test_run_results.py new file mode 100644 index 000000000..345d06d8a --- /dev/null +++ b/tests/functional/artifacts/test_run_results.py @@ -0,0 +1,18 @@ +import pytest +from dbt.tests.util import run_dbt + +good_model_sql = """ +select 1 as id +""" + + +class TestRunResultsSuccess: + @pytest.fixture(scope="class") + def models(self): + return {"model.sql": good_model_sql} + + def test_adapter_response_exists(self, project): + results = run_dbt(["run"]) + assert len(results.results) == 1 + assert results.results[0].adapter_response["query_id"].strip() != "" + assert results.results[0].adapter_response["session_id"].strip() != ""