Skip to content

Commit

Permalink
fix 409 duplicate batch issue (#1020)
Browse files Browse the repository at this point in the history
* use dynamic schema in test_grant_access_to.py

* use dynamic schema in test_grant_access_to.py

* revert setup

* fix partitioninb

* skip TestPythonBatchIdModels

* add changie

* run python integration tests separately

* run python integration tests separately

* cleanup _get_batch_id

* add space to pipe

* fix integration.yml

* add extra changie

* use dynamic schema in test_grant_access_to.py

* use dynamic schema in test_grant_access_to.py

* revert setup

* replace deterministic default batch_id with uuid

* add changie

(cherry picked from commit 0c5422c)
  • Loading branch information
colin-rogers-dbt authored and github-actions[bot] committed Dec 12, 2023
1 parent ed574fd commit 2f5c4bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20231111-150959.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: replace deterministic batch_id with uuid
time: 2023-11-11T15:09:59.243797-08:00
custom:
Author: colin-rogers-dbt
Issue: "1006"
4 changes: 2 additions & 2 deletions dbt/adapters/bigquery/python_submissions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import uuid
from typing import Dict, Union

from dbt.events import AdapterLogger
Expand Down Expand Up @@ -126,8 +127,7 @@ def _get_job_client(self) -> dataproc_v1.BatchControllerClient:

def _get_batch_id(self) -> str:
model = self.parsed_model
default_batch_id = model["unique_id"].replace(".", "-").replace("_", "-")
default_batch_id += str(int(model["created_at"]))
default_batch_id = str(uuid.uuid4())
return model["config"].get("batch_id", default_batch_id)

def _submit_dataproc_job(self) -> Batch:
Expand Down
3 changes: 0 additions & 3 deletions tests/functional/adapter/test_python_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ def model(dbt, spark):
models:
- name: python_array_batch_id
description: A random table with a calculated column defined in python.
config:
batch_id: '{{ run_started_at.strftime("%Y-%m-%d-%H-%M-%S") }}-python-array'
columns:
- name: A
description: Column A
Expand Down Expand Up @@ -216,7 +214,6 @@ def model(dbt, spark):
"""


@pytest.mark.skip(reason="Currently failing as run_started_at is the same across dbt runs")
class TestPythonBatchIdModels:
@pytest.fixture(scope="class")
def models(self):
Expand Down

0 comments on commit 2f5c4bd

Please sign in to comment.