Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240215-151417.yaml
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 3 additions & 1 deletion dbt/adapters/snowflake/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def snowflake_private_key(private_key: RSAPrivateKey) -> bytes:
@dataclass
class SnowflakeAdapterResponse(AdapterResponse):
query_id: str = ""
session_id: str = ""


@dataclass
Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions tests/functional/artifacts/test_run_results.py
Original file line number Diff line number Diff line change
@@ -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() != ""