Skip to content

Commit 7596682

Browse files
committed
Merge branch 'main' of https://github.com/dbt-labs/dbt-snowflake into iceberg_poc
2 parents deb0946 + 3b014a8 commit 7596682

31 files changed

+473
-194
lines changed

.bumpversion.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.8.0b1
2+
current_version = 1.8.0b2
33
parse = (?P<major>[\d]+) # major version number
44
\.(?P<minor>[\d]+) # minor version number
55
\.(?P<patch>[\d]+) # patch version number

.changes/1.8.0-b2.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## dbt-snowflake 1.8.0-b2 - April 03, 2024
2+
3+
### Features
4+
5+
- Add new workflow for internal patch releases ([#38](https://github.com/dbt-labs/dbt-snowflake/issues/38))
6+
7+
### Fixes
8+
9+
- Acknowledge `send_anonymous_usage_stats` setting for python models ([#830](https://github.com/dbt-labs/dbt-snowflake/issues/830))
10+
- modify metadata queries to take into account object type of BASE TABLE being assigned to dynamic tables when was null previously ([#934](https://github.com/dbt-labs/dbt-snowflake/issues/934))
11+
- remove `private_key_path` from connection keys ([#949](https://github.com/dbt-labs/dbt-snowflake/issues/949))
12+
13+
### Under the Hood
14+
15+
- Add unit test for transaction semantics. ([#912](https://github.com/dbt-labs/dbt-snowflake/issues/912))
16+
17+
### Dependencies
18+
19+
- hard pin ddtrace to 2.3.0 ([#932](https://github.com/dbt-labs/dbt-snowflake/pull/932))
20+
- bump cryptography to 42.0.4 or higher for security callouts ([#938](https://github.com/dbt-labs/dbt-snowflake/pull/938))
21+
- Add `dbt-core` as a dependency to preserve backwards compatibility for installation ([#964](https://github.com/dbt-labs/dbt-snowflake/pull/964))
22+
23+
### Security
24+
25+
- Pin `black>=24.3` in `dev-requirements.txt` ([#959](https://github.com/dbt-labs/dbt-snowflake/pull/959))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Dependencies
2+
body: Add `dbt-core` as a dependency to preserve backwards compatibility for installation
3+
time: 2024-04-03T13:39:36.783478-04:00
4+
custom:
5+
Author: mikealfare
6+
PR: "964"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Features
2+
body: Add external_access_integration and secret to python models
3+
time: 2024-04-02T13:13:30.952425+01:00
4+
custom:
5+
Author: Lindblomsebastian
6+
Issue: "955"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Features
2+
body: Support TableLastModifiedMetadataBatch capability
3+
time: 2024-04-04T17:17:04.853047-07:00
4+
custom:
5+
Author: michelleark
6+
Issue: "965"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Under the Hood
2+
body: Update dependabot to cover GHA
3+
time: 2024-04-10T18:16:35.621793-04:00
4+
custom:
5+
Author: mikealfare
6+
Issue: "967"

.github/dependabot.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
version: 2
22
updates:
3-
# python dependencies
43
- package-ecosystem: "pip"
54
directory: "/"
65
schedule:
76
interval: "daily"
87
rebase-strategy: "disabled"
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
rebase-strategy: "disabled"
13+
- package-ecosystem: "docker"
14+
directory: "/docker"
15+
schedule:
16+
interval: "weekly"
17+
rebase-strategy: "disabled"

.github/workflows/release.yml

+16-23
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
#
1414
# **when?**
1515
# This workflow can be run manually on demand or can be called by other workflows
16-
name: Release to GitHub and PyPI
16+
name: "Release to GitHub, PyPI, and Docker"
17+
run-name: "Release ${{ inputs.version_number }} to GitHub, PyPI, and Docker"
1718

1819
on:
1920
workflow_dispatch:
@@ -131,27 +132,21 @@ jobs:
131132
132133
bump-version-generate-changelog:
133134
name: Bump package version, Generate changelog
134-
135135
uses: dbt-labs/dbt-release/.github/workflows/release-prep.yml@main
136-
137136
with:
138137
sha: ${{ inputs.sha }}
139138
version_number: ${{ inputs.version_number }}
140139
target_branch: ${{ inputs.target_branch }}
141140
env_setup_script_path: ${{ inputs.env_setup_script_path }}
142141
test_run: ${{ inputs.test_run }}
143142
nightly_release: ${{ inputs.nightly_release }}
144-
145143
secrets: inherit
146144

147145
log-outputs-bump-version-generate-changelog:
148146
name: "[Log output] Bump package version, Generate changelog"
149147
if: ${{ !failure() && !cancelled() }}
150-
151148
needs: [bump-version-generate-changelog]
152-
153149
runs-on: ubuntu-latest
154-
155150
steps:
156151
- name: Print variables
157152
run: |
@@ -162,9 +157,7 @@ jobs:
162157
name: Build, Test, Package
163158
if: ${{ !failure() && !cancelled() }}
164159
needs: [bump-version-generate-changelog]
165-
166160
uses: dbt-labs/dbt-release/.github/workflows/build.yml@main
167-
168161
with:
169162
sha: ${{ needs.bump-version-generate-changelog.outputs.final_sha }}
170163
version_number: ${{ inputs.version_number }}
@@ -174,19 +167,15 @@ jobs:
174167
package_test_command: ${{ inputs.package_test_command }}
175168
test_run: ${{ inputs.test_run }}
176169
nightly_release: ${{ inputs.nightly_release }}
177-
178170
secrets:
179171
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
180172
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
181173

182174
github-release:
183175
name: GitHub Release
184176
if: ${{ !failure() && !cancelled() }}
185-
186177
needs: [bump-version-generate-changelog, build-test-package]
187-
188178
uses: dbt-labs/dbt-release/.github/workflows/github-release.yml@main
189-
190179
with:
191180
sha: ${{ needs.bump-version-generate-changelog.outputs.final_sha }}
192181
version_number: ${{ inputs.version_number }}
@@ -195,34 +184,38 @@ jobs:
195184

196185
pypi-release:
197186
name: PyPI Release
198-
199-
needs: [github-release]
200-
187+
if: ${{ !failure() && !cancelled() }}
188+
needs: [bump-version-generate-changelog, build-test-package]
201189
uses: dbt-labs/dbt-release/.github/workflows/pypi-release.yml@main
202-
203190
with:
204191
version_number: ${{ inputs.version_number }}
205192
test_run: ${{ inputs.test_run }}
206-
207193
secrets:
208194
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
209195
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
210196

197+
docker-release:
198+
name: "Docker Release"
199+
if: ${{ !failure() && !cancelled() }}
200+
needs: [bump-version-generate-changelog, build-test-package, github-release]
201+
permissions:
202+
packages: write
203+
uses: dbt-labs/dbt-release/.github/workflows/release-docker.yml@main
204+
with:
205+
version_number: ${{ inputs.version_number }}
206+
test_run: ${{ inputs.test_run }}
207+
211208
slack-notification:
212209
name: Slack Notification
213210
if: ${{ failure() && (!inputs.test_run || inputs.nightly_release) }}
214-
215211
needs:
216212
[
217-
bump-version-generate-changelog,
218-
build-test-package,
219213
github-release,
220214
pypi-release,
215+
docker-release,
221216
]
222-
223217
uses: dbt-labs/dbt-release/.github/workflows/slack-post-notification.yml@main
224218
with:
225219
status: "failure"
226-
227220
secrets:
228221
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEV_ADAPTER_ALERTS }}

CHANGELOG.md

+28-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@
55
- "Breaking changes" listed under a version may require action from end users or external maintainers when upgrading to that version.
66
- Do not edit this file directly. This file is auto-generated using [changie](https://github.com/miniscruff/changie). For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-snowflake/blob/main/CONTRIBUTING.md#adding-changelog-entry)
77

8+
## dbt-snowflake 1.8.0-b2 - April 03, 2024
9+
10+
### Features
11+
12+
- Add new workflow for internal patch releases ([#38](https://github.com/dbt-labs/dbt-snowflake/issues/38))
13+
14+
### Fixes
15+
16+
- Acknowledge `send_anonymous_usage_stats` setting for python models ([#830](https://github.com/dbt-labs/dbt-snowflake/issues/830))
17+
- modify metadata queries to take into account object type of BASE TABLE being assigned to dynamic tables when was null previously ([#934](https://github.com/dbt-labs/dbt-snowflake/issues/934))
18+
- remove `private_key_path` from connection keys ([#949](https://github.com/dbt-labs/dbt-snowflake/issues/949))
19+
20+
### Under the Hood
21+
22+
- Add unit test for transaction semantics. ([#912](https://github.com/dbt-labs/dbt-snowflake/issues/912))
23+
24+
### Dependencies
25+
26+
- hard pin ddtrace to 2.3.0 ([#932](https://github.com/dbt-labs/dbt-snowflake/pull/932))
27+
- bump cryptography to 42.0.4 or higher for security callouts ([#938](https://github.com/dbt-labs/dbt-snowflake/pull/938))
28+
- Add `dbt-core` as a dependency to preserve backwards compatibility for installation ([#964](https://github.com/dbt-labs/dbt-snowflake/pull/964))
29+
30+
### Security
31+
32+
- Pin `black>=24.3` in `dev-requirements.txt` ([#959](https://github.com/dbt-labs/dbt-snowflake/pull/959))
33+
34+
35+
836
## dbt-snowflake 1.8.0-b1 - March 02, 2024
937

1038
### Features
@@ -46,8 +74,6 @@
4674

4775
- DDOS vulnerability in 41.0.5. Uptick to avoid ([#852](https://github.com/dbt-labs/dbt-snowflake/pull/852))
4876

49-
50-
5177
## Previous Releases
5278
For information on prior major and minor releases, see their changelogs:
5379
- [1.6](https://github.com/dbt-labs/dbt-snowflake/blob/1.6.latest/CHANGELOG.md)

Makefile

+8-29
Original file line numberDiff line numberDiff line change
@@ -66,32 +66,11 @@ help: ## Show this help message.
6666
@echo 'targets:'
6767
@grep -E '^[7+a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
6868

69-
.PHONY: ubuntu-py38
70-
ubuntu-py38:
71-
docker build -f docker_dev/ubuntu.Dockerfile -t dbt-snowflake-ubuntu-py38 . --build-arg version=3.8
72-
docker run --rm -it --name dbt-snowflake-ubuntu-py38 -v $(shell pwd):/opt/code dbt-snowflake-ubuntu-py38
73-
74-
.PHONY: ubuntu-py39
75-
ubuntu-py39:
76-
docker build -f docker_dev/ubuntu.Dockerfile -t dbt-snowflake-ubuntu-py39 . --build-arg version=3.9
77-
docker run --rm -it --name dbt-snowflake-ubuntu-py39 -v $(shell pwd):/opt/code dbt-snowflake-ubuntu-py39
78-
79-
.PHONY: ubuntu-py310
80-
ubuntu-py310:
81-
docker build -f docker_dev/ubuntu.Dockerfile -t dbt-snowflake-ubuntu-py310 . --build-arg version=3.10
82-
docker run --rm -it --name dbt-snowflake-ubuntu-py310 -v $(shell pwd):/opt/code dbt-snowflake-ubuntu-py310
83-
84-
.PHONY: ubuntu-py311
85-
ubuntu-py311:
86-
docker build -f docker_dev/ubuntu.Dockerfile -t dbt-snowflake-ubuntu-py311 . --build-arg version=3.11
87-
docker run --rm -it --name dbt-snowflake-ubuntu-py311 -v $(shell pwd):/opt/code dbt-snowflake-ubuntu-py311
88-
89-
.PHONY: debian-py38
90-
debian-py38:
91-
docker build -f docker/debian-py38.Dockerfile -t dbt-snowflake-debian-py38 . --build-arg version=3.8.15
92-
docker run --rm -it --name dbt-snowflake-debian-py38 -v $(shell pwd):/opt/code dbt-snowflake-debian-py38
93-
94-
.PHONY: dev-env-default
95-
dev-env-default:
96-
docker build -f docker/dev-env-default.Dockerfile -t dbt-snowflake-dev-env-default .
97-
docker run --rm -it --name dbt-snowflake-dev-env-default -v $(shell pwd):/opt/code dbt-snowflake-dev-env-default
69+
.PHONY: docker-dev
70+
docker-dev:
71+
docker build -f docker/dev.Dockerfile -t dbt-snowflake-dev .
72+
docker run --rm -it --name dbt-snowflake-dev -v $(shell pwd):/opt/code dbt-snowflake-dev
73+
74+
.PHONY: docker-prod
75+
docker-prod:
76+
docker build -f docker/Dockerfile -t dbt-snowflake .

dbt/adapters/snowflake/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "1.8.0b1"
1+
version = "1.8.0b2"

dbt/adapters/snowflake/impl.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class SnowflakeAdapter(SQLAdapter):
5353
{
5454
Capability.SchemaMetadataByRelations: CapabilitySupport(support=Support.Full),
5555
Capability.TableLastModifiedMetadata: CapabilitySupport(support=Support.Full),
56+
Capability.TableLastModifiedMetadataBatch: CapabilitySupport(support=Support.Full),
5657
}
5758
)
5859

@@ -205,6 +206,10 @@ def submit_python_job(self, parsed_model: dict, compiled_code: str):
205206

206207
packages = parsed_model["config"].get("packages", [])
207208
imports = parsed_model["config"].get("imports", [])
209+
external_access_integrations = parsed_model["config"].get(
210+
"external_access_integrations", []
211+
)
212+
secrets = parsed_model["config"].get("secrets", {})
208213
# adding default packages we need to make python model work
209214
default_packages = ["snowflake-snowpark-python"]
210215
package_names = [package.split("==")[0] for package in packages]
@@ -213,9 +218,18 @@ def submit_python_job(self, parsed_model: dict, compiled_code: str):
213218
packages.append(default_package)
214219
packages = "', '".join(packages)
215220
imports = "', '".join(imports)
216-
# we can't pass empty imports clause to snowflake
221+
external_access_integrations = ", ".join(external_access_integrations)
222+
secrets = ", ".join(f"'{key}' = {value}" for key, value in secrets.items())
223+
224+
# we can't pass empty imports, external_access_integrations or secrets clause to snowflake
217225
if imports:
218226
imports = f"IMPORTS = ('{imports}')"
227+
if external_access_integrations:
228+
# Black is trying to make this a tuple.
229+
# fmt: off
230+
external_access_integrations = f"EXTERNAL_ACCESS_INTEGRATIONS = ({external_access_integrations})"
231+
if secrets:
232+
secrets = f"SECRETS = ({secrets})"
219233

220234
if self.config.args.SEND_ANONYMOUS_USAGE_STATS:
221235
snowpark_telemetry_string = "dbtLabs_dbtPython"
@@ -230,6 +244,8 @@ def submit_python_job(self, parsed_model: dict, compiled_code: str):
230244
LANGUAGE PYTHON
231245
RUNTIME_VERSION = '{python_version}'
232246
PACKAGES = ('{packages}')
247+
{external_access_integrations}
248+
{secrets}
233249
{imports}
234250
HANDLER = 'main'
235251
EXECUTE AS CALLER

docker/Dockerfile

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# this image gets published to GHCR for production use
2+
ARG py_version=3.10.7
3+
4+
FROM python:$py_version-slim-bullseye as base
5+
6+
RUN apt-get update \
7+
&& apt-get dist-upgrade -y \
8+
&& apt-get install -y --no-install-recommends \
9+
build-essential=12.9 \
10+
ca-certificates=20210119 \
11+
git=1:2.30.2-1+deb11u2 \
12+
libpq-dev=13.14-0+deb11u1 \
13+
make=4.3-4.1 \
14+
openssh-client=1:8.4p1-5+deb11u3 \
15+
software-properties-common=0.96.20.2-2.1 \
16+
&& apt-get clean \
17+
&& rm -rf \
18+
/var/lib/apt/lists/* \
19+
/tmp/* \
20+
/var/tmp/*
21+
22+
ENV PYTHONIOENCODING=utf-8
23+
ENV LANG=C.UTF-8
24+
25+
RUN python -m pip install --upgrade "pip==24.0" "setuptools==69.2.0" "wheel==0.43.0" --no-cache-dir
26+
27+
28+
FROM base as dbt-snowflake
29+
30+
ARG commit_ref=main
31+
32+
HEALTHCHECK CMD dbt --version || exit 1
33+
34+
WORKDIR /usr/app/dbt/
35+
ENTRYPOINT ["dbt"]
36+
37+
RUN python -m pip install --no-cache-dir "dbt-snowflake @ git+https://github.com/dbt-labs/dbt-snowflake@${commit_ref}"

0 commit comments

Comments
 (0)