Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/ddtrace-approx-eq-1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
McKnight-42 authored Oct 2, 2023
2 parents 7f9da50 + 658e16e commit bd2a5dc
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20230925-120144.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: allow for adding snowflake-python-collector logs to dbt output
time: 2023-09-25T12:01:44.778426-07:00
custom:
Author: colin-rogers-dbt
Issue: "768"
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20230925-144814.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Add tests for inlined limit + sql_header in dbt show query
time: 2023-09-25T14:48:14.663178+01:00
custom:
Author: michelleark
Issue: "786"
20 changes: 20 additions & 0 deletions .github/scripts/update_dbt_core_branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash -e
set -e

git_branch=$1
target_req_file="dev-requirements.txt"
core_req_sed_pattern="s|dbt-core.git.*#egg=dbt-core|dbt-core.git@${git_branch}#egg=dbt-core|g"
postgres_req_sed_pattern="s|dbt-core.git.*#egg=dbt-postgres|dbt-core.git@${git_branch}#egg=dbt-postgres|g"
tests_req_sed_pattern="s|dbt-core.git.*#egg=dbt-tests|dbt-core.git@${git_branch}#egg=dbt-tests|g"
if [[ "$OSTYPE" == darwin* ]]; then
# mac ships with a different version of sed that requires a delimiter arg
sed -i "" "$core_req_sed_pattern" $target_req_file
sed -i "" "$postgres_req_sed_pattern" $target_req_file
sed -i "" "$tests_req_sed_pattern" $target_req_file
else
sed -i "$core_req_sed_pattern" $target_req_file
sed -i "$postgres_req_sed_pattern" $target_req_file
sed -i "$tests_req_sed_pattern" $target_req_file
fi
core_version=$(curl "https://raw.githubusercontent.com/dbt-labs/dbt-core/${git_branch}/core/dbt/version.py" | grep "__version__ = *"|cut -d'=' -f2)
bumpversion --allow-dirty --new-version "$core_version" major
11 changes: 11 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ on:
pull_request_target:
# manual trigger
workflow_dispatch:
inputs:
dbt-core-branch:
description: "branch of dbt-core to use in dev-requirements.txt"
required: false
type: string

# explicitly turn off permissions for `GITHUB_TOKEN`
permissions: read-all
Expand Down Expand Up @@ -159,6 +164,12 @@ jobs:
python -m pip --version
tox --version
- name: Update dev_requirements.txt
if: inputs.dbt-core-branch != ''
run: |
pip install bumpversion
./.github/scripts/update_dbt_core_branch.sh ${{ inputs.dbt-core-branch }}
- name: Run tox (snowflake)
if: matrix.adapter == 'snowflake'
env:
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/repository-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# **what?**
# Cleanup branches left over from automation and testing. Also cleanup
# draft releases from release testing.

# **why?**
# The automations are leaving behind branches and releases that clutter
# the repository. Sometimes we need them to debug processes so we don't
# want them immediately deleted. Running on Saturday to avoid running
# at the same time as an actual release to prevent breaking a release
# mid-release.

# **when?**
# Mainly on a schedule of 12:00 Saturday.
# Manual trigger can also run on demand

name: Repository Cleanup

on:
schedule:
- cron: '0 12 * * SAT' # At 12:00 on Saturday - details in `why` above

workflow_dispatch: # for manual triggering

permissions:
contents: write

jobs:
cleanup-repo:
uses: dbt-labs/actions/.github/workflows/repository-cleanup.yml@main
secrets: inherit
8 changes: 8 additions & 0 deletions dbt/adapters/snowflake/connections.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import base64
import datetime
import os

import pytz
import re
from contextlib import contextmanager
Expand Down Expand Up @@ -47,6 +49,12 @@


logger = AdapterLogger("Snowflake")

if os.getenv("DBT_SNOWFLAKE_CONNECTOR_DEBUG_LOGGING"):
for logger_name in ["snowflake.connector", "botocore", "boto3"]:
logger.debug(f"Setting {logger_name} to DEBUG")
logger.set_adapter_dependency_log_level(logger_name, "DEBUG")

_TOKEN_REQUEST_URL = "https://{}.snowflakecomputing.com/oauth/token-request"

ERROR_REDACTION_PATTERNS = {
Expand Down
9 changes: 9 additions & 0 deletions tests/functional/adapter/dbt_show/test_dbt_show.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from dbt.tests.adapter.dbt_show.test_dbt_show import BaseShowSqlHeader, BaseShowLimit


class TestBigQueryShowLimit(BaseShowLimit):
pass


class TestBigQueryShowSqlHeader(BaseShowSqlHeader):
pass
25 changes: 25 additions & 0 deletions tests/unit/test_connections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
from importlib import reload
from unittest.mock import Mock
import dbt.adapters.snowflake.connections as connections
import dbt.events


def test_connections_sets_logs_in_response_to_env_var(monkeypatch):
"""Test that setting the DBT_SNOWFLAKE_CONNECTOR_DEBUG_LOGGING environment variable happens on import"""
log_mock = Mock()
monkeypatch.setattr(dbt.events, "AdapterLogger", Mock(return_value=log_mock))
monkeypatch.setattr(os, "environ", {"DBT_SNOWFLAKE_CONNECTOR_DEBUG_LOGGING": "true"})
reload(connections)

assert log_mock.debug.call_count == 3
assert log_mock.set_adapter_dependency_log_level.call_count == 3


def test_connections_does_not_set_logs_in_response_to_env_var(monkeypatch):
log_mock = Mock()
monkeypatch.setattr(dbt.events, "AdapterLogger", Mock(return_value=log_mock))
reload(connections)

assert log_mock.debug.call_count == 0
assert log_mock.set_adapter_dependency_log_level.call_count == 0

0 comments on commit bd2a5dc

Please sign in to comment.