Skip to content

Commit

Permalink
Merge branch 'main' into incremental-ingestion-time
Browse files Browse the repository at this point in the history
  • Loading branch information
McKnight-42 authored Aug 25, 2022
2 parents 67420bd + ad885cd commit 59a5354
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 88 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Under the Hood-20220817-154151.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Under the Hood
body: Adding `slot_ms` go `BigQueryAdapterResponse`
time: 2022-08-17T15:41:51.080936-05:00
custom:
Author: yu-iskw
Issue: "194"
PR: "195"
7 changes: 7 additions & 0 deletions .changes/unreleased/Under the Hood-20220825-073235.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Under the Hood
body: specify supported_languages for materialization that support python models
time: 2022-08-25T07:32:35.820396-07:00
custom:
Author: ChenyuLInx
Issue: "288"
PR: "290"
40 changes: 40 additions & 0 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# **what?**
# When a PR is merged, if it has the backport label, it will create
# a new PR to backport those changes to the given branch. If it can't
# cleanly do a backport, it will comment on the merged PR of the failure.
#
# Label naming convention: "backport <branch name to backport to>"
# Example: backport 1.0.latest
#
# You MUST "Squash and merge" the original PR or this won't work.

# **why?**
# Changes sometimes need to be backported to release branches.
# This automates the backporting process

# **when?**
# Once a PR is "Squash and merge"'d, by adding a backport label, this is triggered

name: Backport
on:
pull_request:
types:
- labeled

permissions:
contents: write
pull-requests: write

jobs:
backport:
name: Backport
runs-on: ubuntu-latest
# Only react to merged PRs for security reasons.
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
if: >
github.event.pull_request.merged
&& contains(github.event.label.name, 'backport')
steps:
- uses: tibdex/backport@v2.0.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/changelog-existence.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ jobs:
changelog:
uses: dbt-labs/actions/.github/workflows/changelog-existence.yml@main
with:
changelog_comment: 'Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the [dbt-bigquery contributing guide](https://github.com/dbt-labs/dbt-bigquery/blob/main/CONTRIBUTING.MD).'
changelog_comment: 'Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the [dbt-bigquery contributing guide](https://github.com/dbt-labs/dbt-bigquery/blob/main/CONTRIBUTING.md).'
skip_label: 'Skip Changelog'
secrets: inherit # this is only acceptable because we own the action we're calling
96 changes: 11 additions & 85 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
@@ -1,102 +1,28 @@
# **what?**
# This workflow will take a version number and a dry run flag. With that
# This workflow will take the new version number to bump to. With that
# it will run versionbump to update the version number everywhere in the
# code base and then generate an update Docker requirements file. If this
# is a dry run, a draft PR will open with the changes. If this isn't a dry
# run, the changes will be committed to the branch this is run on.
# code base and then run changie to create the corresponding changelog.
# A PR will be created with the changes that can be reviewed before committing.

# **why?**
# This is to aid in releasing dbt and making sure we have updated
# the versions and Docker requirements in all places.
# the version in all places and generated the changelog.

# **when?**
# This is triggered either manually OR
# from the repository_dispatch event "version-bump" which is sent from
# the dbt-release repo Action
# This is triggered manually

name: Version Bump

on:
workflow_dispatch:
inputs:
version_number:
description: 'The version number to bump to'
description: 'The version number to bump to (ex. 1.2.0, 1.3.0b1)'
required: true
is_dry_run:
description: 'Creates a draft PR to allow testing instead of committing to a branch'
required: true
default: 'true'
repository_dispatch:
types: [version-bump]

jobs:
bump:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2

- name: Set version and dry run values
id: variables
env:
VERSION_NUMBER: "${{ github.event.client_payload.version_number == '' && github.event.inputs.version_number || github.event.client_payload.version_number }}"
IS_DRY_RUN: "${{ github.event.client_payload.is_dry_run == '' && github.event.inputs.is_dry_run || github.event.client_payload.is_dry_run }}"
run: |
echo Repository dispatch event version: ${{ github.event.client_payload.version_number }}
echo Repository dispatch event dry run: ${{ github.event.client_payload.is_dry_run }}
echo Workflow dispatch event version: ${{ github.event.inputs.version_number }}
echo Workflow dispatch event dry run: ${{ github.event.inputs.is_dry_run }}
echo ::set-output name=VERSION_NUMBER::$VERSION_NUMBER
echo ::set-output name=IS_DRY_RUN::$IS_DRY_RUN
- uses: actions/setup-python@v2
with:
python-version: "3.8"

- name: Install python dependencies
run: |
python3 -m venv env
source env/bin/activate
python -m pip install --upgrade pip
- name: Create PR branch
if: ${{ steps.variables.outputs.IS_DRY_RUN == 'true' }}
run: |
git checkout -b bumping-version/${{steps.variables.outputs.VERSION_NUMBER}}_$GITHUB_RUN_ID
git push origin bumping-version/${{steps.variables.outputs.VERSION_NUMBER}}_$GITHUB_RUN_ID
git branch --set-upstream-to=origin/bumping-version/${{steps.variables.outputs.VERSION_NUMBER}}_$GITHUB_RUN_ID bumping-version/${{steps.variables.outputs.VERSION_NUMBER}}_$GITHUB_RUN_ID
- name: Bumping version
run: |
source env/bin/activate
python -m pip install -r dev-requirements.txt
env/bin/bumpversion --allow-dirty --new-version ${{steps.variables.outputs.VERSION_NUMBER}} major
git status
- name: Commit version bump directly
uses: EndBug/add-and-commit@v7
if: ${{ steps.variables.outputs.IS_DRY_RUN == 'false' }}
with:
author_name: 'Github Build Bot'
author_email: 'buildbot@fishtownanalytics.com'
message: 'Bumping version to ${{steps.variables.outputs.VERSION_NUMBER}}'

- name: Commit version bump to branch
uses: EndBug/add-and-commit@v7
if: ${{ steps.variables.outputs.IS_DRY_RUN == 'true' }}
with:
author_name: 'Github Build Bot'
author_email: 'buildbot@fishtownanalytics.com'
message: 'Bumping version to ${{steps.variables.outputs.VERSION_NUMBER}}'
branch: 'bumping-version/${{steps.variables.outputs.VERSION_NUMBER}}_${{GITHUB.RUN_ID}}'
push: 'origin origin/bumping-version/${{steps.variables.outputs.VERSION_NUMBER}}_${{GITHUB.RUN_ID}}'

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
if: ${{ steps.variables.outputs.IS_DRY_RUN == 'true' }}
with:
author: 'Github Build Bot <buildbot@fishtownanalytics.com>'
draft: true
base: ${{github.ref}}
title: 'Bumping version to ${{steps.variables.outputs.VERSION_NUMBER}}'
branch: 'bumping-version/${{steps.variables.outputs.VERSION_NUMBER}}_${{GITHUB.RUN_ID}}'
version_bump_and_changie:
uses: dbt-labs/actions/.github/workflows/version-bump.yml@main
with:
version_number: ${{ inputs.version_number }}
secrets: inherit # ok since what we are calling is internally maintained
4 changes: 4 additions & 0 deletions dbt/adapters/bigquery/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class BigQueryAdapterResponse(AdapterResponse):
location: Optional[str] = None
project_id: Optional[str] = None
job_id: Optional[str] = None
slot_ms: Optional[int] = None


@dataclass
Expand Down Expand Up @@ -460,6 +461,7 @@ def execute(
project_id = None
num_rows_formatted = None
processed_bytes = None
slot_ms = None

if query_job.statement_type == "CREATE_VIEW":
code = "CREATE VIEW"
Expand Down Expand Up @@ -488,6 +490,7 @@ def execute(

# set common attributes
bytes_processed = query_job.total_bytes_processed
slot_ms = query_job.slot_millis
processed_bytes = self.format_bytes(bytes_processed)
location = query_job.location
job_id = query_job.job_id
Expand All @@ -511,6 +514,7 @@ def execute(
location=location,
project_id=project_id,
job_id=job_id,
slot_ms=slot_ms,
)

return response, table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

{% endmacro %}

{% materialization incremental, adapter='bigquery' -%}
{% materialization incremental, adapter='bigquery', supported_languages=['sql', 'python'] -%}

{%- set unique_key = config.get('unique_key') -%}
{%- set full_refresh_mode = (should_full_refresh()) -%}
Expand Down
2 changes: 1 addition & 1 deletion dbt/include/bigquery/macros/materializations/table.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% materialization table, adapter='bigquery' -%}
{% materialization table, adapter='bigquery', supported_languages=['sql', 'python']-%}

{%- set language = model['language'] -%}
{%- set identifier = model['alias'] -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def test__bigquery_adapter_functions(self):
assert result.adapter_response["location"] is not None
assert result.adapter_response["project_id"] is not None
assert result.adapter_response["job_id"] is not None
assert result.adapter_response["slot_ms"] is not None

test_results = self.run_dbt(['test'])

Expand Down

0 comments on commit 59a5354

Please sign in to comment.