Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 1.7.latest] fix 409 duplicate batch issue #1054

Merged
merged 1 commit into from
Dec 13, 2023
Merged
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/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