-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
65 additions
and
251 deletions.
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 was deleted.
Oops, something went wrong.
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,37 @@ | ||
import pendulum | ||
from dagster import build_resources | ||
from dagster_gcp import BigQueryResource | ||
from google.cloud import bigquery | ||
|
||
from teamster.core.datagun.assets import construct_query | ||
from teamster.kipptaf import GCS_PROJECT_NAME | ||
|
||
|
||
def _test(query_type, query_value): | ||
with build_resources( | ||
resources={"db_bigquery": BigQueryResource(project=GCS_PROJECT_NAME)} | ||
) as resources: | ||
db_bigquery: bigquery.Client = next(resources.db_bigquery) | ||
|
||
query = construct_query( | ||
now=pendulum.now(), query_type=query_type, query_value=query_value | ||
) | ||
print(query) | ||
|
||
query_job = db_bigquery.query(query=str(query)) | ||
|
||
result = query_job.result() | ||
|
||
data = [dict(row) for row in result] | ||
|
||
print(data) | ||
|
||
|
||
def test_schema_query(): | ||
table_schema = "kipptaf_extracts" | ||
table_name = "rpt_deanslist__mod_assessment" | ||
|
||
_test( | ||
query_type="schema", | ||
query_value={"table": {"name": table_name, "schema": table_schema}}, | ||
) |