Skip to content

Commit

Permalink
Merge pull request #217 from DevDataPlatform/216-pass-the-bigquery-lo…
Browse files Browse the repository at this point in the history
…cation-to-prefect-proxy-for-dbt-core-blocks

pass bigquery dataset location to prefec-proxy for dbt block creation
  • Loading branch information
Ishankoradia authored Jul 6, 2023
2 parents ccc9f2a + ef5450e commit e3e0577
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ddpui/api/client/prefect_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,15 @@ def post_prefect_dbt_core_block(request, payload: PrefectDbtRun):
else orguser.org.dbt.default_schema
)

# get the bigquery location if warehouse is bq
bqlocation = None
if warehouse.wtype == "bigquery":
destination = airbyte_service.get_destination(
orguser.org.airbyte_workspace_id, warehouse.airbyte_destination_id
)
if destination.get("connectionConfiguration"):
bqlocation = destination["connectionConfiguration"]["dataset_location"]

block_names = []
for sequence_number, command in enumerate(
["clean", "deps", "run", "test", "docs generate"]
Expand All @@ -381,6 +390,7 @@ def post_prefect_dbt_core_block(request, payload: PrefectDbtRun):
target,
warehouse.wtype,
credentials,
bqlocation,
)
except Exception as error:
logger.exception(error)
Expand Down
2 changes: 2 additions & 0 deletions ddpui/ddpprefect/prefect_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def create_dbt_core_block(
target: str,
wtype: str,
credentials: dict,
bqlocation: str,
) -> dict:
"""Create a dbt core block in prefect"""
response = prefect_post(
Expand All @@ -214,6 +215,7 @@ def create_dbt_core_block(
},
"wtype": wtype,
"credentials": credentials,
"bqlocation": bqlocation,
"commands": dbtcore.commands,
"env": dbtcore.env,
"working_dir": dbtcore.working_dir,
Expand Down

0 comments on commit e3e0577

Please sign in to comment.