-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return Databricks Query History API id as part of AdapterResponse (#376)
query_id is now written to run_results.json Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
- Loading branch information
Jesse
authored
Jun 29, 2023
1 parent
e3bc534
commit af2435d
Showing
5 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 2 | ||
models: | ||
- name: view_model | ||
columns: | ||
- name: id | ||
tests: | ||
- unique | ||
- not_null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
select 1 as id | ||
union all | ||
select 1 as id | ||
union all | ||
select null as id |
49 changes: 49 additions & 0 deletions
49
tests/integration/run_results_json/test_run_results_json.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from tests.integration.base import DBTIntegrationTest, use_profile | ||
import os | ||
import json | ||
import tempfile | ||
|
||
|
||
class TestRunResultsJson(DBTIntegrationTest): | ||
def setUp(self): | ||
self.tempdir: tempfile.TemporaryDirectory = tempfile.TemporaryDirectory() | ||
return super().setUp() | ||
|
||
def tearDown(self): | ||
self.tempdir.cleanup() | ||
return super().tearDown() | ||
|
||
@property | ||
def project_config(self): | ||
return { | ||
"config-version": 2, | ||
"models": {"materialized": "table"}, | ||
"target-path": self.tempdir.name, | ||
} | ||
|
||
@property | ||
def models(self): | ||
return "models" | ||
|
||
@property | ||
def schema(self): | ||
return "test_results_json" | ||
|
||
def run_and_check_for_query_id(self): | ||
self.run_dbt(["run"]) | ||
|
||
_fhpath = os.path.join(self.tempdir.name, "run_results.json") | ||
with open(_fhpath, "r") as results_json_raw: | ||
results_json = json.load(results_json_raw) | ||
self.assertIsNotNone( | ||
results_json["results"][0]["adapter_response"].get("query_id"), | ||
"Query ID column was not written to run_results.json", | ||
) | ||
|
||
@use_profile("databricks_sql_endpoint") | ||
def test_run_results_json_databricks_sql_endpoint(self): | ||
self.run_and_check_for_query_id() | ||
|
||
@use_profile("databricks_uc_sql_endpoint") | ||
def test_run_results_json_databricks_uc_sql_endpoint(self): | ||
self.run_and_check_for_query_id() |