diff --git a/.bumpversion.cfg b/.bumpversion.cfg index ae6fd86e8..43e4f539b 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = v1.7.0b2 +current_version = 1.8.0a1 parse = (?P[\d]+) # major version number \.(?P[\d]+) # minor version number \.(?P[\d]+) # patch version number diff --git a/.changes/1.7.0-b1.md b/.changes/1.7.0-b1.md deleted file mode 100644 index 51907be49..000000000 --- a/.changes/1.7.0-b1.md +++ /dev/null @@ -1,35 +0,0 @@ -## dbt-snowflake 1.7.0-b1 - August 17, 2023 - -### Fixes - -- Incremental materialization with "append" strategy does not wrap dml with explicit transaction ([#656](https://github.com/dbt-labs/dbt-snowflake/issues/656)) -- Fix `on_configuration_change` setting to properly recognize `continue` and `fail` ([#708](https://github.com/dbt-labs/dbt-snowflake/issues/708)) -- Cancel all queries when terminating dbt ([#711](https://github.com/dbt-labs/dbt-snowflake/issues/711)) -- change target_lag type to allow for downstream as a option ([#734](https://github.com/dbt-labs/dbt-snowflake/issues/734)) -- update snowflake_warehouse field for dynamic tables to be more accounted for ([#735](https://github.com/dbt-labs/dbt-snowflake/issues/735)) - -### Under the Hood - -- add pem private key option ([#619](https://github.com/dbt-labs/dbt-snowflake/issues/619)) -- Update stale workflow to use the centralized version ([#707](https://github.com/dbt-labs/dbt-snowflake/issues/707)) - -### Dependencies - -- Update black requirement from ~=23.3 to ~=23.7 ([#688](https://github.com/dbt-labs/dbt-snowflake/pull/688)) -- Update pip-tools requirement from ~=6.14 to ~=7.0 ([#692](https://github.com/dbt-labs/dbt-snowflake/pull/692)) -- Update ddtrace requirement from ~=1.16 to ~=1.17 ([#704](https://github.com/dbt-labs/dbt-snowflake/pull/704)) -- Update wheel requirement from ~=0.40 to ~=0.41 ([#706](https://github.com/dbt-labs/dbt-snowflake/pull/706)) -- Update flake8 requirement from ~=6.0 to ~=6.1 ([#714](https://github.com/dbt-labs/dbt-snowflake/pull/714)) -- Update pip-tools requirement from ~=7.0 to ~=7.1 ([#722](https://github.com/dbt-labs/dbt-snowflake/pull/722)) -- Update pip-tools requirement from ~=7.1 to ~=7.2 ([#723](https://github.com/dbt-labs/dbt-snowflake/pull/723)) -- Update tox requirement from ~=4.6 to ~=4.7 ([#730](https://github.com/dbt-labs/dbt-snowflake/pull/730)) -- Update pip-tools requirement from ~=7.2 to ~=7.3 ([#731](https://github.com/dbt-labs/dbt-snowflake/pull/731)) -- Bump mypy from 1.4.1 to 1.5.0 ([#733](https://github.com/dbt-labs/dbt-snowflake/pull/733)) -- Update tox requirement from ~=4.7 to ~=4.8 ([#744](https://github.com/dbt-labs/dbt-snowflake/pull/744)) -- Update ddtrace requirement from ~=1.17 to ~=1.18 ([#745](https://github.com/dbt-labs/dbt-snowflake/pull/745)) -- Update tox requirement from ~=4.8 to ~=4.9 ([#748](https://github.com/dbt-labs/dbt-snowflake/pull/748)) - -### Contributors -- [@danielefrigo](https://github.com/danielefrigo) ([#656](https://github.com/dbt-labs/dbt-snowflake/issues/656)) -- [@gabeschenz](https://github.com/gabeschenz) ([#619](https://github.com/dbt-labs/dbt-snowflake/issues/619)) -- [@julio-romero](https://github.com/julio-romero) ([#711](https://github.com/dbt-labs/dbt-snowflake/issues/711)) diff --git a/.changes/1.7.0-b2.md b/.changes/1.7.0-b2.md deleted file mode 100644 index f8f84cde1..000000000 --- a/.changes/1.7.0-b2.md +++ /dev/null @@ -1,22 +0,0 @@ -## dbt-snowflake 1.7.0-b2 - September 15, 2023 - -### Fixes - -- remove senesitive creds from dbt debug stdout ([#754](https://github.com/dbt-labs/dbt-snowflake/issues/754)) -- changes expected value types to AnyInteger to take into account changes in core ([#762](https://github.com/dbt-labs/dbt-snowflake/issues/762)) -- Fixing comment on syntax for dynamic tables ([#769](https://github.com/dbt-labs/dbt-snowflake/issues/769)) - -### Under the Hood - -- Restructure macros files - move relation ddl statements into separate files and directories ([#750](https://github.com/dbt-labs/dbt-snowflake/issues/750)) - -### Dependencies - -- Bump mypy from 1.5.0 to 1.5.1 ([#749](https://github.com/dbt-labs/dbt-snowflake/pull/749)) -- Update tox requirement from ~=4.9 to ~=4.10 ([#752](https://github.com/dbt-labs/dbt-snowflake/pull/752)) -- Update tox requirement from ~=4.10 to ~=4.11 ([#759](https://github.com/dbt-labs/dbt-snowflake/pull/759)) -- Update pre-commit requirement from ~=3.3 to ~=3.4 ([#760](https://github.com/dbt-labs/dbt-snowflake/pull/760)) -- Update black requirement from ~=23.7 to ~=23.9 ([#765](https://github.com/dbt-labs/dbt-snowflake/pull/765)) - -### Contributors -- [@kaarthik108](https://github.com/kaarthik108) ([#769](https://github.com/dbt-labs/dbt-snowflake/issues/769)) diff --git a/.changes/1.7.0/Dependencies-20230711-123517.yaml b/.changes/1.7.0/Dependencies-20230711-123517.yaml deleted file mode 100644 index a7d964540..000000000 --- a/.changes/1.7.0/Dependencies-20230711-123517.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update black requirement from ~=23.3 to ~=23.7" -time: 2023-07-11T12:35:17.00000Z -custom: - Author: dependabot[bot] - PR: 688 diff --git a/.changes/1.7.0/Dependencies-20230717-121543.yaml b/.changes/1.7.0/Dependencies-20230717-121543.yaml deleted file mode 100644 index 9ef607863..000000000 --- a/.changes/1.7.0/Dependencies-20230717-121543.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update pip-tools requirement from ~=6.14 to ~=7.0" -time: 2023-07-17T12:15:43.00000Z -custom: - Author: dependabot[bot] - PR: 692 diff --git a/.changes/1.7.0/Dependencies-20230721-130136.yaml b/.changes/1.7.0/Dependencies-20230721-130136.yaml deleted file mode 100644 index 666fc3bfb..000000000 --- a/.changes/1.7.0/Dependencies-20230721-130136.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update ddtrace requirement from ~=1.16 to ~=1.17" -time: 2023-07-21T13:01:36.00000Z -custom: - Author: dependabot[bot] - PR: 704 diff --git a/.changes/1.7.0/Dependencies-20230724-123845.yaml b/.changes/1.7.0/Dependencies-20230724-123845.yaml deleted file mode 100644 index 9166c85fb..000000000 --- a/.changes/1.7.0/Dependencies-20230724-123845.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update wheel requirement from ~=0.40 to ~=0.41" -time: 2023-07-24T12:38:45.00000Z -custom: - Author: dependabot[bot] - PR: 706 diff --git a/.changes/1.7.0/Dependencies-20230731-121631.yaml b/.changes/1.7.0/Dependencies-20230731-121631.yaml deleted file mode 100644 index b154c26cd..000000000 --- a/.changes/1.7.0/Dependencies-20230731-121631.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update flake8 requirement from ~=6.0 to ~=6.1" -time: 2023-07-31T12:16:31.00000Z -custom: - Author: dependabot[bot] - PR: 714 diff --git a/.changes/1.7.0/Dependencies-20230802-221810.yaml b/.changes/1.7.0/Dependencies-20230802-221810.yaml deleted file mode 100644 index fe9c7917b..000000000 --- a/.changes/1.7.0/Dependencies-20230802-221810.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update pip-tools requirement from ~=7.0 to ~=7.1" -time: 2023-08-02T22:18:10.00000Z -custom: - Author: dependabot[bot] - PR: 722 diff --git a/.changes/1.7.0/Dependencies-20230803-131336.yaml b/.changes/1.7.0/Dependencies-20230803-131336.yaml deleted file mode 100644 index 708a050f1..000000000 --- a/.changes/1.7.0/Dependencies-20230803-131336.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update pip-tools requirement from ~=7.1 to ~=7.2" -time: 2023-08-03T13:13:36.00000Z -custom: - Author: dependabot[bot] - PR: 723 diff --git a/.changes/1.7.0/Dependencies-20230809-130151.yaml b/.changes/1.7.0/Dependencies-20230809-130151.yaml deleted file mode 100644 index 8227f2647..000000000 --- a/.changes/1.7.0/Dependencies-20230809-130151.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update tox requirement from ~=4.6 to ~=4.7" -time: 2023-08-09T13:01:51.00000Z -custom: - Author: dependabot[bot] - PR: 730 diff --git a/.changes/1.7.0/Dependencies-20230809-130216.yaml b/.changes/1.7.0/Dependencies-20230809-130216.yaml deleted file mode 100644 index 494a50a26..000000000 --- a/.changes/1.7.0/Dependencies-20230809-130216.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update pip-tools requirement from ~=7.2 to ~=7.3" -time: 2023-08-09T13:02:16.00000Z -custom: - Author: dependabot[bot] - PR: 731 diff --git a/.changes/1.7.0/Dependencies-20230810-124706.yaml b/.changes/1.7.0/Dependencies-20230810-124706.yaml deleted file mode 100644 index e54416457..000000000 --- a/.changes/1.7.0/Dependencies-20230810-124706.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Bump mypy from 1.4.1 to 1.5.0" -time: 2023-08-10T12:47:06.00000Z -custom: - Author: dependabot[bot] - PR: 733 diff --git a/.changes/1.7.0/Dependencies-20230814-125402.yaml b/.changes/1.7.0/Dependencies-20230814-125402.yaml deleted file mode 100644 index e7b5f931b..000000000 --- a/.changes/1.7.0/Dependencies-20230814-125402.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update tox requirement from ~=4.7 to ~=4.8" -time: 2023-08-14T12:54:02.00000Z -custom: - Author: dependabot[bot] - PR: 744 diff --git a/.changes/1.7.0/Dependencies-20230814-125450.yaml b/.changes/1.7.0/Dependencies-20230814-125450.yaml deleted file mode 100644 index d510da321..000000000 --- a/.changes/1.7.0/Dependencies-20230814-125450.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update ddtrace requirement from ~=1.17 to ~=1.18" -time: 2023-08-14T12:54:50.00000Z -custom: - Author: dependabot[bot] - PR: 745 diff --git a/.changes/1.7.0/Dependencies-20230817-121646.yaml b/.changes/1.7.0/Dependencies-20230817-121646.yaml deleted file mode 100644 index f65ba7790..000000000 --- a/.changes/1.7.0/Dependencies-20230817-121646.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update tox requirement from ~=4.8 to ~=4.9" -time: 2023-08-17T12:16:46.00000Z -custom: - Author: dependabot[bot] - PR: 748 diff --git a/.changes/1.7.0/Dependencies-20230817-121652.yaml b/.changes/1.7.0/Dependencies-20230817-121652.yaml deleted file mode 100644 index 9f7440852..000000000 --- a/.changes/1.7.0/Dependencies-20230817-121652.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Bump mypy from 1.5.0 to 1.5.1" -time: 2023-08-17T12:16:52.00000Z -custom: - Author: dependabot[bot] - PR: 749 diff --git a/.changes/1.7.0/Dependencies-20230822-120421.yaml b/.changes/1.7.0/Dependencies-20230822-120421.yaml deleted file mode 100644 index 30cdfa38c..000000000 --- a/.changes/1.7.0/Dependencies-20230822-120421.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update tox requirement from ~=4.9 to ~=4.10" -time: 2023-08-22T12:04:21.00000Z -custom: - Author: dependabot[bot] - PR: 752 diff --git a/.changes/1.7.0/Dependencies-20230830-125448.yaml b/.changes/1.7.0/Dependencies-20230830-125448.yaml deleted file mode 100644 index a0ca197ba..000000000 --- a/.changes/1.7.0/Dependencies-20230830-125448.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update tox requirement from ~=4.10 to ~=4.11" -time: 2023-08-30T12:54:48.00000Z -custom: - Author: dependabot[bot] - PR: 759 diff --git a/.changes/1.7.0/Dependencies-20230904-121823.yaml b/.changes/1.7.0/Dependencies-20230904-121823.yaml deleted file mode 100644 index 14ef931b4..000000000 --- a/.changes/1.7.0/Dependencies-20230904-121823.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update pre-commit requirement from ~=3.3 to ~=3.4" -time: 2023-09-04T12:18:23.00000Z -custom: - Author: dependabot[bot] - PR: 760 diff --git a/.changes/1.7.0/Dependencies-20230911-122237.yaml b/.changes/1.7.0/Dependencies-20230911-122237.yaml deleted file mode 100644 index 2c593b139..000000000 --- a/.changes/1.7.0/Dependencies-20230911-122237.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: "Dependencies" -body: "Update black requirement from ~=23.7 to ~=23.9" -time: 2023-09-11T12:22:37.00000Z -custom: - Author: dependabot[bot] - PR: 765 diff --git a/.changes/1.7.0/Fixes-20230626-132631.yaml b/.changes/1.7.0/Fixes-20230626-132631.yaml deleted file mode 100644 index c0594e5a2..000000000 --- a/.changes/1.7.0/Fixes-20230626-132631.yaml +++ /dev/null @@ -1,7 +0,0 @@ -kind: Fixes -body: Incremental materialization with "append" strategy does not wrap dml with explicit - transaction -time: 2023-06-26T13:26:31.575359809Z -custom: - Author: danielefrigo - Issue: "656" diff --git a/.changes/1.7.0/Fixes-20230726-164729.yaml b/.changes/1.7.0/Fixes-20230726-164729.yaml deleted file mode 100644 index 031e5dfde..000000000 --- a/.changes/1.7.0/Fixes-20230726-164729.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixes -body: Fix `on_configuration_change` setting to properly recognize `continue` and `fail` -time: 2023-07-26T16:47:29.471437-04:00 -custom: - Author: mikealfare - Issue: "708" diff --git a/.changes/1.7.0/Fixes-20230804-175222.yaml b/.changes/1.7.0/Fixes-20230804-175222.yaml deleted file mode 100644 index b222b21ac..000000000 --- a/.changes/1.7.0/Fixes-20230804-175222.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixes -body: Cancel all queries when terminating dbt -time: 2023-08-04T17:52:22.956964-06:00 -custom: - Author: julio-romero - Issue: "711" diff --git a/.changes/1.7.0/Fixes-20230810-154613.yaml b/.changes/1.7.0/Fixes-20230810-154613.yaml deleted file mode 100644 index e1794e899..000000000 --- a/.changes/1.7.0/Fixes-20230810-154613.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixes -body: change target_lag type to allow for downstream as a option -time: 2023-08-10T15:46:13.896057-05:00 -custom: - Author: McKnight-42 - Issue: "734" diff --git a/.changes/1.7.0/Fixes-20230810-163232.yaml b/.changes/1.7.0/Fixes-20230810-163232.yaml deleted file mode 100644 index 80643d93f..000000000 --- a/.changes/1.7.0/Fixes-20230810-163232.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixes -body: update snowflake_warehouse field for dynamic tables to be more accounted for -time: 2023-08-10T16:32:32.417917-05:00 -custom: - Author: McKnight-42 - Issue: "735" diff --git a/.changes/1.7.0/Fixes-20230828-143834.yaml b/.changes/1.7.0/Fixes-20230828-143834.yaml deleted file mode 100644 index 793b2b65c..000000000 --- a/.changes/1.7.0/Fixes-20230828-143834.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixes -body: remove senesitive creds from dbt debug stdout -time: 2023-08-28T14:38:34.380646-05:00 -custom: - Author: McKnight-42 - Issue: "754" diff --git a/.changes/1.7.0/Fixes-20230907-153305.yaml b/.changes/1.7.0/Fixes-20230907-153305.yaml deleted file mode 100644 index 23b10daf7..000000000 --- a/.changes/1.7.0/Fixes-20230907-153305.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixes -body: changes expected value types to AnyInteger to take into account changes in core -time: 2023-09-07T15:33:05.133868-05:00 -custom: - Author: McKnight-42 - Issue: "762" diff --git a/.changes/1.7.0/Fixes-20230914-110800.yaml b/.changes/1.7.0/Fixes-20230914-110800.yaml deleted file mode 100644 index 3aa206a73..000000000 --- a/.changes/1.7.0/Fixes-20230914-110800.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Fixes -body: Fixing comment on syntax for dynamic tables -time: 2023-09-14T11:08:00.250684+12:00 -custom: - Author: kaarthik108 - Issue: '769' diff --git a/.changes/1.7.0/Under the Hood-20230621-144450.yaml b/.changes/1.7.0/Under the Hood-20230621-144450.yaml deleted file mode 100644 index 61538538c..000000000 --- a/.changes/1.7.0/Under the Hood-20230621-144450.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Under the Hood -body: add pem private key option -time: 2023-06-21T14:44:50.559665-05:00 -custom: - Author: gabeschenz - Issue: "619" diff --git a/.changes/1.7.0/Under the Hood-20230724-162947.yaml b/.changes/1.7.0/Under the Hood-20230724-162947.yaml deleted file mode 100644 index 59c0af110..000000000 --- a/.changes/1.7.0/Under the Hood-20230724-162947.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Under the Hood -body: Update stale workflow to use the centralized version -time: 2023-07-24T16:29:47.135179-04:00 -custom: - Author: mikealfare - Issue: "707" diff --git a/.changes/1.7.0/Under the Hood-20230821-230921.yaml b/.changes/1.7.0/Under the Hood-20230821-230921.yaml deleted file mode 100644 index b19517caf..000000000 --- a/.changes/1.7.0/Under the Hood-20230821-230921.yaml +++ /dev/null @@ -1,7 +0,0 @@ -kind: Under the Hood -body: Restructure macros files - move relation ddl statements into separate files - and directories -time: 2023-08-21T23:09:21.317975-04:00 -custom: - Author: mikealfare - Issue: "750" diff --git a/.changes/unreleased/Dependencies-20231009-122807.yaml b/.changes/unreleased/Dependencies-20231009-122807.yaml new file mode 100644 index 000000000..c133a1d4e --- /dev/null +++ b/.changes/unreleased/Dependencies-20231009-122807.yaml @@ -0,0 +1,6 @@ +kind: "Dependencies" +body: "Update pre-commit-hooks requirement from ~=4.4 to ~=4.5" +time: 2023-10-09T12:28:07.00000Z +custom: + Author: dependabot[bot] + PR: 795 diff --git a/.changes/unreleased/Dependencies-20231011-124519.yaml b/.changes/unreleased/Dependencies-20231011-124519.yaml new file mode 100644 index 000000000..4c3df6550 --- /dev/null +++ b/.changes/unreleased/Dependencies-20231011-124519.yaml @@ -0,0 +1,6 @@ +kind: "Dependencies" +body: "Bump mypy from 1.5.1 to 1.6.0" +time: 2023-10-11T12:45:19.00000Z +custom: + Author: dependabot[bot] + PR: 799 diff --git a/.changes/unreleased/Dependencies-20231016-121821.yaml b/.changes/unreleased/Dependencies-20231016-121821.yaml new file mode 100644 index 000000000..80028d3f2 --- /dev/null +++ b/.changes/unreleased/Dependencies-20231016-121821.yaml @@ -0,0 +1,6 @@ +kind: "Dependencies" +body: "Update pre-commit requirement from ~=3.4 to ~=3.5" +time: 2023-10-16T12:18:21.00000Z +custom: + Author: dependabot[bot] + PR: 807 diff --git a/.changes/unreleased/Dependencies-20231018-123921.yaml b/.changes/unreleased/Dependencies-20231018-123921.yaml new file mode 100644 index 000000000..03cbb3faa --- /dev/null +++ b/.changes/unreleased/Dependencies-20231018-123921.yaml @@ -0,0 +1,6 @@ +kind: "Dependencies" +body: "Update black requirement from ~=23.9 to ~=23.10" +time: 2023-10-18T12:39:21.00000Z +custom: + Author: dependabot[bot] + PR: 809 diff --git a/.changes/unreleased/Features-20230822-234732.yaml b/.changes/unreleased/Features-20230822-234732.yaml deleted file mode 100644 index 297630745..000000000 --- a/.changes/unreleased/Features-20230822-234732.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Features -body: Support replacing tables/views with dynamic tables and vice versa -time: 2023-08-22T23:47:32.27784-04:00 -custom: - Author: mikealfare - Issue: "753" diff --git a/.changes/unreleased/Features-20230915-091507.yaml b/.changes/unreleased/Features-20230915-091507.yaml deleted file mode 100644 index 7a5fc3a54..000000000 --- a/.changes/unreleased/Features-20230915-091507.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Features -body: Redact cases where raw data can be leaked logs -time: 2023-09-15T09:15:07.430443+10:00 -custom: - Author: jaypeedevlin - Issue: "772" diff --git a/.changes/unreleased/Under the Hood-20230925-120144.yaml b/.changes/unreleased/Under the Hood-20230925-120144.yaml deleted file mode 100644 index 717f415f2..000000000 --- a/.changes/unreleased/Under the Hood-20230925-120144.yaml +++ /dev/null @@ -1,6 +0,0 @@ -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" diff --git a/.changes/unreleased/Under the Hood-20230925-144814.yaml b/.changes/unreleased/Under the Hood-20230925-144814.yaml deleted file mode 100644 index df7e17255..000000000 --- a/.changes/unreleased/Under the Hood-20230925-144814.yaml +++ /dev/null @@ -1,6 +0,0 @@ -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" diff --git a/.github/workflows/docs-issues.yml b/.github/workflows/docs-issues.yml new file mode 100644 index 000000000..00a098df8 --- /dev/null +++ b/.github/workflows/docs-issues.yml @@ -0,0 +1,43 @@ +# **what?** +# Open an issue in docs.getdbt.com when a PR is labeled `user docs` + +# **why?** +# To reduce barriers for keeping docs up to date + +# **when?** +# When a PR is labeled `user docs` and is merged. Runs on pull_request_target to run off the workflow already merged, +# not the workflow that existed on the PR branch. This allows old PRs to get comments. + + +name: Open issues in docs.getdbt.com repo when a PR is labeled +run-name: "Open an issue in docs.getdbt.com for PR #${{ github.event.pull_request.number }}" + +on: + pull_request_target: + types: [labeled, closed] + +defaults: + run: + shell: bash + +permissions: + issues: write # opens new issues + pull-requests: write # comments on PRs + + +jobs: + open_issues: + # we only want to run this when the PR has been merged or the label in the labeled event is `user docs`. Otherwise it runs the + # risk of duplicaton of issues being created due to merge and label both triggering this workflow to run and neither having + # generating the comment before the other runs. This lives here instead of the shared workflow because this is where we + # decide if it should run or not. + if: | + (github.event.pull_request.merged == true) && + ((github.event.action == 'closed' && contains( github.event.pull_request.labels.*.name, 'user docs')) || + (github.event.action == 'labeled' && github.event.label.name == 'user docs')) + uses: dbt-labs/actions/.github/workflows/open-issue-in-repo.yml@main + with: + issue_repository: "dbt-labs/docs.getdbt.com" + issue_title: "Docs Changes Needed from ${{ github.event.repository.name }} PR #${{ github.event.pull_request.number }}" + issue_body: "At a minimum, update body to include a link to the page on docs.getdbt.com requiring updates and what part(s) of the page you would like to see updated." + secrets: inherit diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 4762d1218..fddec31c7 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -26,7 +26,7 @@ defaults: shell: bash env: - RELEASE_BRANCH: "1.5.latest" + RELEASE_BRANCH: "1.6.latest" jobs: aggregate-release-data: @@ -75,7 +75,7 @@ jobs: - name: "Generate Nightly Release Version Number" id: nightly-release-version run: | - number="${{ steps.semver.outputs.major }}.${{ steps.semver.outputs.minor }}.${{ steps.bump_patch.outputs.patch }}.dev${{ steps.current-date.outputs.date }}" + number="${{ steps.semver.outputs.major }}.${{ steps.semver.outputs.minor }}.${{ steps.bump_patch.outputs.patch }}+dev${{ steps.current-date.outputs.date }}" echo "number=$number" >> $GITHUB_OUTPUT - name: "Audit Nightly Release Version And Parse Into Parts" diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c0b8dcd1..8b6702b8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,66 +5,6 @@ - "Breaking changes" listed under a version may require action from end users or external maintainers when upgrading to that version. - 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) -## dbt-snowflake 1.7.0-b2 - September 15, 2023 - -### Fixes - -- remove senesitive creds from dbt debug stdout ([#754](https://github.com/dbt-labs/dbt-snowflake/issues/754)) -- changes expected value types to AnyInteger to take into account changes in core ([#762](https://github.com/dbt-labs/dbt-snowflake/issues/762)) -- Fixing comment on syntax for dynamic tables ([#769](https://github.com/dbt-labs/dbt-snowflake/issues/769)) - -### Under the Hood - -- Restructure macros files - move relation ddl statements into separate files and directories ([#750](https://github.com/dbt-labs/dbt-snowflake/issues/750)) - -### Dependencies - -- Bump mypy from 1.5.0 to 1.5.1 ([#749](https://github.com/dbt-labs/dbt-snowflake/pull/749)) -- Update tox requirement from ~=4.9 to ~=4.10 ([#752](https://github.com/dbt-labs/dbt-snowflake/pull/752)) -- Update tox requirement from ~=4.10 to ~=4.11 ([#759](https://github.com/dbt-labs/dbt-snowflake/pull/759)) -- Update pre-commit requirement from ~=3.3 to ~=3.4 ([#760](https://github.com/dbt-labs/dbt-snowflake/pull/760)) -- Update black requirement from ~=23.7 to ~=23.9 ([#765](https://github.com/dbt-labs/dbt-snowflake/pull/765)) - -### Contributors -- [@kaarthik108](https://github.com/kaarthik108) ([#769](https://github.com/dbt-labs/dbt-snowflake/issues/769)) - - -## dbt-snowflake 1.7.0-b1 - August 17, 2023 - -### Fixes - -- Incremental materialization with "append" strategy does not wrap dml with explicit transaction ([#656](https://github.com/dbt-labs/dbt-snowflake/issues/656)) -- Fix `on_configuration_change` setting to properly recognize `continue` and `fail` ([#708](https://github.com/dbt-labs/dbt-snowflake/issues/708)) -- Cancel all queries when terminating dbt ([#711](https://github.com/dbt-labs/dbt-snowflake/issues/711)) -- change target_lag type to allow for downstream as a option ([#734](https://github.com/dbt-labs/dbt-snowflake/issues/734)) -- update snowflake_warehouse field for dynamic tables to be more accounted for ([#735](https://github.com/dbt-labs/dbt-snowflake/issues/735)) - -### Under the Hood - -- add pem private key option ([#619](https://github.com/dbt-labs/dbt-snowflake/issues/619)) -- Update stale workflow to use the centralized version ([#707](https://github.com/dbt-labs/dbt-snowflake/issues/707)) - -### Dependencies - -- Update black requirement from ~=23.3 to ~=23.7 ([#688](https://github.com/dbt-labs/dbt-snowflake/pull/688)) -- Update pip-tools requirement from ~=6.14 to ~=7.0 ([#692](https://github.com/dbt-labs/dbt-snowflake/pull/692)) -- Update ddtrace requirement from ~=1.16 to ~=1.17 ([#704](https://github.com/dbt-labs/dbt-snowflake/pull/704)) -- Update wheel requirement from ~=0.40 to ~=0.41 ([#706](https://github.com/dbt-labs/dbt-snowflake/pull/706)) -- Update flake8 requirement from ~=6.0 to ~=6.1 ([#714](https://github.com/dbt-labs/dbt-snowflake/pull/714)) -- Update pip-tools requirement from ~=7.0 to ~=7.1 ([#722](https://github.com/dbt-labs/dbt-snowflake/pull/722)) -- Update pip-tools requirement from ~=7.1 to ~=7.2 ([#723](https://github.com/dbt-labs/dbt-snowflake/pull/723)) -- Update tox requirement from ~=4.6 to ~=4.7 ([#730](https://github.com/dbt-labs/dbt-snowflake/pull/730)) -- Update pip-tools requirement from ~=7.2 to ~=7.3 ([#731](https://github.com/dbt-labs/dbt-snowflake/pull/731)) -- Bump mypy from 1.4.1 to 1.5.0 ([#733](https://github.com/dbt-labs/dbt-snowflake/pull/733)) -- Update tox requirement from ~=4.7 to ~=4.8 ([#744](https://github.com/dbt-labs/dbt-snowflake/pull/744)) -- Update ddtrace requirement from ~=1.17 to ~=1.18 ([#745](https://github.com/dbt-labs/dbt-snowflake/pull/745)) -- Update tox requirement from ~=4.8 to ~=4.9 ([#748](https://github.com/dbt-labs/dbt-snowflake/pull/748)) - -### Contributors -- [@danielefrigo](https://github.com/danielefrigo) ([#656](https://github.com/dbt-labs/dbt-snowflake/issues/656)) -- [@gabeschenz](https://github.com/gabeschenz) ([#619](https://github.com/dbt-labs/dbt-snowflake/issues/619)) -- [@julio-romero](https://github.com/julio-romero) ([#711](https://github.com/dbt-labs/dbt-snowflake/issues/711)) - ## Previous Releases For information on prior major and minor releases, see their changelogs: - [1.6](https://github.com/dbt-labs/dbt-snowflake/blob/1.6.latest/CHANGELOG.md) diff --git a/dbt/adapters/snowflake/__version__.py b/dbt/adapters/snowflake/__version__.py index 3f5d3c0b7..f15b401d1 100644 --- a/dbt/adapters/snowflake/__version__.py +++ b/dbt/adapters/snowflake/__version__.py @@ -1 +1 @@ -version = "1.7.0b2" +version = "1.8.0a1" diff --git a/dbt/adapters/snowflake/impl.py b/dbt/adapters/snowflake/impl.py index 671906242..6f71fec1a 100644 --- a/dbt/adapters/snowflake/impl.py +++ b/dbt/adapters/snowflake/impl.py @@ -5,6 +5,7 @@ from dbt.adapters.base.impl import AdapterConfig, ConstraintSupport # type: ignore from dbt.adapters.base.meta import available +from dbt.adapters.capability import CapabilityDict, CapabilitySupport, Support, Capability from dbt.adapters.sql import SQLAdapter # type: ignore from dbt.adapters.sql.impl import ( LIST_SCHEMAS_MACRO_NAME, @@ -49,6 +50,13 @@ class SnowflakeAdapter(SQLAdapter): ConstraintType.foreign_key: ConstraintSupport.NOT_ENFORCED, } + _capabilities: CapabilityDict = CapabilityDict( + { + Capability.SchemaMetadataByRelations: CapabilitySupport(support=Support.Full), + Capability.TableLastModifiedMetadata: CapabilitySupport(support=Support.Full), + } + ) + @classmethod def date_function(cls): return "CURRENT_TIMESTAMP()" diff --git a/dbt/include/snowflake/macros/adapters.sql b/dbt/include/snowflake/macros/adapters.sql index 024c05274..b2b496356 100644 --- a/dbt/include/snowflake/macros/adapters.sql +++ b/dbt/include/snowflake/macros/adapters.sql @@ -183,7 +183,7 @@ {% macro snowflake__alter_column_comment(relation, column_dict) -%} {% set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute="name") | list %} {% if relation.is_dynamic_table -%} - {% set relation_type = "dynamic table" %} + {% set relation_type = "table" %} {% else -%} {% set relation_type = relation.type %} {% endif %} diff --git a/dbt/include/snowflake/macros/catalog.sql b/dbt/include/snowflake/macros/catalog.sql index cf96df25d..eaa7582e9 100644 --- a/dbt/include/snowflake/macros/catalog.sql +++ b/dbt/include/snowflake/macros/catalog.sql @@ -1,72 +1,123 @@ {% macro snowflake__get_catalog(information_schema, schemas) -%} - {% set query %} - with tables as ( - - select - table_catalog as "table_database", - table_schema as "table_schema", - table_name as "table_name", - table_type as "table_type", - comment as "table_comment", - - -- note: this is the _role_ that owns the table - table_owner as "table_owner", - - 'Clustering Key' as "stats:clustering_key:label", - clustering_key as "stats:clustering_key:value", - 'The key used to cluster this table' as "stats:clustering_key:description", - (clustering_key is not null) as "stats:clustering_key:include", - - 'Row Count' as "stats:row_count:label", - row_count as "stats:row_count:value", - 'An approximate count of rows in this table' as "stats:row_count:description", - (row_count is not null) as "stats:row_count:include", - - 'Approximate Size' as "stats:bytes:label", - bytes as "stats:bytes:value", - 'Approximate size of the table as reported by Snowflake' as "stats:bytes:description", - (bytes is not null) as "stats:bytes:include", - - 'Last Modified' as "stats:last_modified:label", - to_varchar(convert_timezone('UTC', last_altered), 'yyyy-mm-dd HH24:MI'||'UTC') as "stats:last_modified:value", - 'The timestamp for last update/change' as "stats:last_modified:description", - (last_altered is not null and table_type='BASE TABLE') as "stats:last_modified:include" - - from {{ information_schema }}.tables - where ( - {%- for schema in schemas -%} - upper("table_schema") = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%} - {%- endfor -%} - ) - - ), - - columns as ( - - select - table_catalog as "table_database", - table_schema as "table_schema", - table_name as "table_name", - - column_name as "column_name", - ordinal_position as "column_index", - data_type as "column_type", - comment as "column_comment" - - from {{ information_schema }}.columns - where ( - {%- for schema in schemas -%} - upper("table_schema") = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%} - {%- endfor -%} - ) - ) - - select * - from tables - join columns using ("table_database", "table_schema", "table_name") - order by "column_index" + + {% set query %} + with tables as ( + {{ snowflake__get_catalog_tables_sql(information_schema) }} + {{ snowflake__get_catalog_schemas_where_clause_sql(schemas) }} + ), + columns as ( + {{ snowflake__get_catalog_columns_sql(information_schema) }} + {{ snowflake__get_catalog_schemas_where_clause_sql(schemas) }} + ) + {{ snowflake__get_catalog_results_sql() }} + {%- endset -%} + + {{ return(run_query(query)) }} + +{%- endmacro %} + + +{% macro snowflake__get_catalog_relations(information_schema, relations) -%} + + {% set query %} + with tables as ( + {{ snowflake__get_catalog_tables_sql(information_schema) }} + {{ snowflake__get_catalog_relations_where_clause_sql(relations) }} + ), + columns as ( + {{ snowflake__get_catalog_columns_sql(information_schema) }} + {{ snowflake__get_catalog_relations_where_clause_sql(relations) }} + ) + {{ snowflake__get_catalog_results_sql() }} {%- endset -%} - {{ return(run_query(query)) }} + {{ return(run_query(query)) }} + +{%- endmacro %} + + +{% macro snowflake__get_catalog_tables_sql(information_schema) -%} + select + table_catalog as "table_database", + table_schema as "table_schema", + table_name as "table_name", + table_type as "table_type", + comment as "table_comment", + + -- note: this is the _role_ that owns the table + table_owner as "table_owner", + + 'Clustering Key' as "stats:clustering_key:label", + clustering_key as "stats:clustering_key:value", + 'The key used to cluster this table' as "stats:clustering_key:description", + (clustering_key is not null) as "stats:clustering_key:include", + + 'Row Count' as "stats:row_count:label", + row_count as "stats:row_count:value", + 'An approximate count of rows in this table' as "stats:row_count:description", + (row_count is not null) as "stats:row_count:include", + + 'Approximate Size' as "stats:bytes:label", + bytes as "stats:bytes:value", + 'Approximate size of the table as reported by Snowflake' as "stats:bytes:description", + (bytes is not null) as "stats:bytes:include", + + 'Last Modified' as "stats:last_modified:label", + to_varchar(convert_timezone('UTC', last_altered), 'yyyy-mm-dd HH24:MI'||'UTC') as "stats:last_modified:value", + 'The timestamp for last update/change' as "stats:last_modified:description", + (last_altered is not null and table_type='BASE TABLE') as "stats:last_modified:include" + from {{ information_schema }}.tables +{%- endmacro %} + + +{% macro snowflake__get_catalog_columns_sql(information_schema) -%} + select + table_catalog as "table_database", + table_schema as "table_schema", + table_name as "table_name", + + column_name as "column_name", + ordinal_position as "column_index", + data_type as "column_type", + comment as "column_comment" + from {{ information_schema }}.columns +{%- endmacro %} + + +{% macro snowflake__get_catalog_results_sql() -%} + select * + from tables + join columns using ("table_database", "table_schema", "table_name") + order by "column_index" +{%- endmacro %} + + +{% macro snowflake__get_catalog_schemas_where_clause_sql(schemas) -%} + where ({%- for schema in schemas -%} + upper("table_schema") = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%} + {%- endfor -%}) +{%- endmacro %} + + +{% macro snowflake__get_catalog_relations_where_clause_sql(relations) -%} + where ( + {%- for relation in relations -%} + {% if relation.schema and relation.identifier %} + ( + upper("table_schema") = upper('{{ relation.schema }}') + and upper("table_name") = upper('{{ relation.identifier }}') + ) + {% elif relation.schema %} + ( + upper("table_schema") = upper('{{ relation.schema }}') + ) + {% else %} + {% do exceptions.raise_compiler_error( + '`get_catalog_relations` requires a list of relations, each with a schema' + ) %} + {% endif %} + {%- if not loop.last %} or {% endif -%} + {%- endfor -%} + ) {%- endmacro %} diff --git a/dbt/include/snowflake/macros/materializations/table.sql b/dbt/include/snowflake/macros/materializations/table.sql index 628474caa..ef201c705 100644 --- a/dbt/include/snowflake/macros/materializations/table.sql +++ b/dbt/include/snowflake/macros/materializations/table.sql @@ -38,7 +38,18 @@ {% endmaterialization %} -{% macro py_write_table(compiled_code, target_relation, temporary=False) %} +{% macro py_write_table(compiled_code, target_relation, temporary=False, table_type=none) %} +{#- The following logic is only for backwards-compatiblity with deprecated `temporary` parameter -#} +{% if table_type is not none %} + {#- Just use the table_type as-is -#} +{% elif temporary -%} + {#- Case 1 when the deprecated `temporary` parameter is used without the replacement `table_type` parameter -#} + {%- set table_type = "temporary" -%} +{% else %} + {#- Case 2 when the deprecated `temporary` parameter is used without the replacement `table_type` parameter -#} + {#- Snowflake treats "" as meaning "permanent" -#} + {%- set table_type = "" -%} +{%- endif %} {{ compiled_code }} def materialize(session, df, target_relation): # make sure pandas exists @@ -52,7 +63,7 @@ def materialize(session, df, target_relation): # session.write_pandas does not have overwrite function df = session.createDataFrame(df) {% set target_relation_name = resolve_model_name(target_relation) %} - df.write.mode("overwrite").save_as_table('{{ target_relation_name }}', create_temp_table={{temporary}}) + df.write.mode("overwrite").save_as_table('{{ target_relation_name }}', table_type='{{table_type}}') def main(session): dbt = dbtObj(session.table) diff --git a/dbt/include/snowflake/macros/metadata.sql b/dbt/include/snowflake/macros/metadata.sql new file mode 100644 index 000000000..667082fe2 --- /dev/null +++ b/dbt/include/snowflake/macros/metadata.sql @@ -0,0 +1,19 @@ +{% macro snowflake__get_relation_last_modified(information_schema, relations) -%} + + {%- call statement('last_modified', fetch_result=True) -%} + select table_schema as schema, + table_name as identifier, + last_altered as last_modified, + {{ current_timestamp() }} as snapshotted_at + from {{ information_schema }}.tables + where ( + {%- for relation in relations -%} + (upper(table_schema) = upper('{{ relation.schema }}') and + upper(table_name) = upper('{{ relation.identifier }}')){%- if not loop.last %} or {% endif -%} + {%- endfor -%} + ) + {%- endcall -%} + + {{ return(load_result('last_modified')) }} + +{% endmacro %} diff --git a/dbt/include/snowflake/macros/relations/dynamic_table/create.sql b/dbt/include/snowflake/macros/relations/dynamic_table/create.sql index bf84c58cb..8e8f3287f 100644 --- a/dbt/include/snowflake/macros/relations/dynamic_table/create.sql +++ b/dbt/include/snowflake/macros/relations/dynamic_table/create.sql @@ -7,6 +7,5 @@ {{ sql }} ) ; - {{ snowflake__refresh_dynamic_table(relation) }} {%- endmacro %} diff --git a/dbt/include/snowflake/macros/relations/table/create.sql b/dbt/include/snowflake/macros/relations/table/create.sql index 8924af00a..c6bc8f775 100644 --- a/dbt/include/snowflake/macros/relations/table/create.sql +++ b/dbt/include/snowflake/macros/relations/table/create.sql @@ -1,6 +1,15 @@ {% macro snowflake__create_table_as(temporary, relation, compiled_code, language='sql') -%} + {%- set transient = config.get('transient', default=true) -%} + + {% if temporary -%} + {%- set table_type = "temporary" -%} + {%- elif transient -%} + {%- set table_type = "transient" -%} + {%- else -%} + {%- set table_type = "" -%} + {%- endif %} + {%- if language == 'sql' -%} - {%- set transient = config.get('transient', default=true) -%} {%- set cluster_by_keys = config.get('cluster_by', default=none) -%} {%- set enable_automatic_clustering = config.get('automatic_clustering', default=false) -%} {%- set copy_grants = config.get('copy_grants', default=false) -%} @@ -17,11 +26,7 @@ {{ sql_header if sql_header is not none }} - create or replace {% if temporary -%} - temporary - {%- elif transient -%} - transient - {%- endif %} table {{ relation }} + create or replace {{ table_type }} table {{ relation }} {%- set contract_config = config.get('contract') -%} {%- if contract_config.enforced -%} {{ get_assert_columns_equivalent(sql) }} @@ -46,7 +51,7 @@ {%- endif -%} {%- elif language == 'python' -%} - {{ py_write_table(compiled_code=compiled_code, target_relation=relation, temporary=temporary) }} + {{ py_write_table(compiled_code=compiled_code, target_relation=relation, table_type=table_type) }} {%- else -%} {% do exceptions.raise_compiler_error("snowflake__create_table_as macro didn't get supported language, it got %s" % language) %} {%- endif -%} diff --git a/dev-requirements.txt b/dev-requirements.txt index 61af91605..c7a189c49 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -5,7 +5,7 @@ git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory= # if version 1.x or greater -> pin to major version # if version 0.x -> pin to minor -black~=23.9 +black~=23.10 bumpversion~=0.6.0 click~=8.1 ddtrace~=1.19 @@ -13,10 +13,10 @@ flake8~=6.1 flaky~=3.7 freezegun~=1.2 ipdb~=0.13.13 -mypy==1.5.1 # patch updates have historically introduced breaking changes +mypy==1.6.0 # patch updates have historically introduced breaking changes pip-tools~=7.3 -pre-commit~=3.4 -pre-commit-hooks~=4.4 +pre-commit~=3.5 +pre-commit-hooks~=4.5 pytest~=7.4 pytest-csv~=3.0 pytest-dotenv~=0.5.2 diff --git a/setup.py b/setup.py index c11ef3654..0eaf4fb9a 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ def _get_dbt_core_version(): package_name = "dbt-snowflake" -package_version = "1.7.0b2" +package_version = "1.8.0a1" dbt_core_version = _get_dbt_core_version() description = """The Snowflake adapter plugin for dbt""" diff --git a/tests/functional/adapter/python_model_tests/_files.py b/tests/functional/adapter/python_model_tests/_files.py new file mode 100644 index 000000000..dd69f37fa --- /dev/null +++ b/tests/functional/adapter/python_model_tests/_files.py @@ -0,0 +1,48 @@ +# __table +TRANSIENT_TRUE_TABLE = """ +import pandas + +def model(dbt, session): + dbt.config(transient=True) + return pandas.DataFrame([[1,2]] * 10, columns=['test', 'test2']) +""" + + +TRANSIENT_FALSE_TABLE = """ +import pandas + +def model(dbt, session): + dbt.config(transient=False) + return pandas.DataFrame([[1,2]] * 10, columns=['test', 'test2']) +""" + + +TRANSIENT_NONE_TABLE = """ +import pandas + +def model(dbt, session): + dbt.config(transient=None) + return pandas.DataFrame([[1,2]] * 10, columns=['test', 'test2']) +""" + + +TRANSIENT_UNSET_TABLE = """ +import pandas + +def model(dbt, session): + return pandas.DataFrame([[1,2]] * 10, columns=['test', 'test2']) +""" + + +MACRO__DESCRIBE_TABLES = """ +{% macro snowflake__test__describe_tables() %} + {%- set _sql -%} + show tables; + select "name", "kind" + from table(result_scan(last_query_id())) + {%- endset %} + {% set _table = run_query(_sql) %} + + {% do return(_table) %} +{% endmacro %} +""" diff --git a/tests/functional/adapter/python_model_tests/test_table_type.py b/tests/functional/adapter/python_model_tests/test_table_type.py new file mode 100644 index 000000000..df1f34ac4 --- /dev/null +++ b/tests/functional/adapter/python_model_tests/test_table_type.py @@ -0,0 +1,35 @@ +import pytest + +from dbt.tests.util import run_dbt + +from tests.functional.adapter.python_model_tests import _files + + +class TestTableType: + @pytest.fixture(scope="class") + def macros(self): + return {"snowflake__test__describe_tables.sql": _files.MACRO__DESCRIBE_TABLES} + + @pytest.fixture(scope="class") + def models(self): + return { + # __table + "TRANSIENT_TRUE_TABLE.py": _files.TRANSIENT_TRUE_TABLE, + "TRANSIENT_FALSE_TABLE.py": _files.TRANSIENT_FALSE_TABLE, + "TRANSIENT_NONE_TABLE.py": _files.TRANSIENT_NONE_TABLE, + "TRANSIENT_UNSET_TABLE.py": _files.TRANSIENT_UNSET_TABLE, + } + + def test_expected_table_types_are_created(self, project): + run_dbt(["run"]) + expected_table_types = { + # (name, kind) - TABLE == permanent + ("TRANSIENT_TRUE_TABLE", "TRANSIENT"), + ("TRANSIENT_FALSE_TABLE", "TABLE"), + ("TRANSIENT_NONE_TABLE", "TABLE"), + ("TRANSIENT_UNSET_TABLE", "TRANSIENT"), + } + with project.adapter.connection_named("__test"): + agate_table = project.adapter.execute_macro("snowflake__test__describe_tables") + actual_table_types = {(row.get("name"), row.get("kind")) for row in agate_table.rows} + assert actual_table_types == expected_table_types diff --git a/tests/functional/adapter/store_test_failures_tests/test_store_test_failures.py b/tests/functional/adapter/store_test_failures_tests/test_store_test_failures.py index 2a7e0158e..b3bce12c3 100644 --- a/tests/functional/adapter/store_test_failures_tests/test_store_test_failures.py +++ b/tests/functional/adapter/store_test_failures_tests/test_store_test_failures.py @@ -1,7 +1,32 @@ +from dbt.tests.adapter.store_test_failures_tests import basic from dbt.tests.adapter.store_test_failures_tests.test_store_test_failures import ( TestStoreTestFailures, ) -class SnowflakeTestStoreTestFailures(TestStoreTestFailures): +class TestSnowflakeStoreTestFailures(TestStoreTestFailures): + pass + + +class TestStoreTestFailuresAsInteractions(basic.StoreTestFailuresAsInteractions): + pass + + +class TestStoreTestFailuresAsProjectLevelOff(basic.StoreTestFailuresAsProjectLevelOff): + pass + + +class TestStoreTestFailuresAsProjectLevelView(basic.StoreTestFailuresAsProjectLevelView): + pass + + +class TestStoreTestFailuresAsGeneric(basic.StoreTestFailuresAsGeneric): + pass + + +class TestStoreTestFailuresAsProjectLevelEphemeral(basic.StoreTestFailuresAsProjectLevelEphemeral): + pass + + +class TestStoreTestFailuresAsExceptions(basic.StoreTestFailuresAsExceptions): pass diff --git a/tests/functional/adapter/test_get_last_relation_modified.py b/tests/functional/adapter/test_get_last_relation_modified.py new file mode 100644 index 000000000..870488499 --- /dev/null +++ b/tests/functional/adapter/test_get_last_relation_modified.py @@ -0,0 +1,60 @@ +import os +import pytest + +from dbt.cli.main import dbtRunner + + +freshness_via_metadata_schema_yml = """version: 2 +sources: + - name: test_source + freshness: + warn_after: {count: 10, period: hour} + error_after: {count: 1, period: day} + schema: "{{ env_var('DBT_GET_LAST_RELATION_TEST_SCHEMA') }}" + tables: + - name: test_table +""" + + +class TestGetLastRelationModified: + @pytest.fixture(scope="class", autouse=True) + def set_env_vars(self, project): + os.environ["DBT_GET_LAST_RELATION_TEST_SCHEMA"] = project.test_schema + yield + del os.environ["DBT_GET_LAST_RELATION_TEST_SCHEMA"] + + @pytest.fixture(scope="class") + def models(self): + return {"schema.yml": freshness_via_metadata_schema_yml} + + @pytest.fixture(scope="class") + def custom_schema(self, project, set_env_vars): + with project.adapter.connection_named("__test"): + relation = project.adapter.Relation.create( + database=project.database, schema=os.environ["DBT_GET_LAST_RELATION_TEST_SCHEMA"] + ) + project.adapter.drop_schema(relation) + project.adapter.create_schema(relation) + + yield relation.schema + + with project.adapter.connection_named("__test"): + project.adapter.drop_schema(relation) + + def test_get_last_relation_modified(self, project, set_env_vars, custom_schema): + project.run_sql( + f"create table {custom_schema}.test_table (id integer autoincrement, name varchar(100) not null);" + ) + + warning_or_error = False + + def probe(e): + nonlocal warning_or_error + if e.info.level in ["warning", "error"]: + warning_or_error = True + + runner = dbtRunner(callbacks=[probe]) + runner.invoke(["source", "freshness"]) + + # The 'source freshness' command should succeed without warnings or errors. + assert not warning_or_error diff --git a/tests/functional/adapter/test_list_relations_without_caching.py b/tests/functional/adapter/test_list_relations_without_caching.py index dd1d03b78..f6dfc2144 100644 --- a/tests/functional/adapter/test_list_relations_without_caching.py +++ b/tests/functional/adapter/test_list_relations_without_caching.py @@ -75,7 +75,7 @@ def find_exc_info_in_parsed_logs(parsed_logs, exc_info_name): ) -class TestListRelationsWithoutCaching: +class TestListRelationsWithoutCachingSingle: @pytest.fixture(scope="class") def models(self): my_models = {"my_model_base.sql": TABLE_BASE_SQL} @@ -88,7 +88,6 @@ def models(self): def macros(self): return { "validate_list_relations_without_caching.sql": MACROS__VALIDATE__SNOWFLAKE__LIST_RELATIONS_WITHOUT_CACHING, - "validate_list_relations_without_caching_raise_error.sql": MACROS__VALIDATE__SNOWFLAKE__LIST_RELATIONS_WITHOUT_CACHING_RAISE_ERROR, } def test__snowflake__list_relations_without_caching_termination(self, project): @@ -96,8 +95,7 @@ def test__snowflake__list_relations_without_caching_termination(self, project): validates that we do NOT trigger pagination logic snowflake__list_relations_without_caching macro when there are fewer than max_results_per_iter relations in the target schema """ - - _ = run_dbt(["run", "-s", "my_model_base"]) + run_dbt(["run", "-s", "my_model_base"]) database = project.database schemas = project.created_schemas @@ -121,6 +119,23 @@ def test__snowflake__list_relations_without_caching_termination(self, project): assert n_relations == "n_relations: 1" + +class TestListRelationsWithoutCachingFull: + @pytest.fixture(scope="class") + def models(self): + my_models = {"my_model_base.sql": TABLE_BASE_SQL} + for view in range(0, NUM_VIEWS): + my_models.update({f"my_model_{view}.sql": VIEW_X_SQL}) + + return my_models + + @pytest.fixture(scope="class") + def macros(self): + return { + "validate_list_relations_without_caching.sql": MACROS__VALIDATE__SNOWFLAKE__LIST_RELATIONS_WITHOUT_CACHING, + "validate_list_relations_without_caching_raise_error.sql": MACROS__VALIDATE__SNOWFLAKE__LIST_RELATIONS_WITHOUT_CACHING_RAISE_ERROR, + } + def test__snowflake__list_relations_without_caching(self, project): """ validates pagination logic in snowflake__list_relations_without_caching macro counts @@ -128,7 +143,7 @@ def test__snowflake__list_relations_without_caching(self, project): calls of SHOW TERSE OBJECTS. """ # purpose of the first run is to create the replicated views in the target schema - _ = run_dbt(["run", "--exclude", "my_model_base"]) + run_dbt(["run"]) database = project.database schemas = project.created_schemas @@ -157,6 +172,8 @@ def test__snowflake__list_relations_without_caching_raise_error(self, project): validates pagination logic terminates and raises a compilation error when exceeding the limit of how many results to return. """ + run_dbt(["run"]) + database = project.database schemas = project.created_schemas diff --git a/tests/functional/adapter/utils/test_utils.py b/tests/functional/adapter/utils/test_utils.py index 49e3628cf..bea418998 100644 --- a/tests/functional/adapter/utils/test_utils.py +++ b/tests/functional/adapter/utils/test_utils.py @@ -8,10 +8,14 @@ from dbt.tests.adapter.utils.test_current_timestamp import BaseCurrentTimestampAware from dbt.tests.adapter.utils.test_dateadd import BaseDateAdd from dbt.tests.adapter.utils.test_datediff import BaseDateDiff +from dbt.tests.adapter.utils.test_date_spine import BaseDateSpine from dbt.tests.adapter.utils.test_date_trunc import BaseDateTrunc from dbt.tests.adapter.utils.test_escape_single_quotes import BaseEscapeSingleQuotesQuote from dbt.tests.adapter.utils.test_escape_single_quotes import BaseEscapeSingleQuotesBackslash from dbt.tests.adapter.utils.test_except import BaseExcept +from dbt.tests.adapter.utils.test_generate_series import BaseGenerateSeries +from dbt.tests.adapter.utils.test_get_intervals_between import BaseGetIntervalsBetween +from dbt.tests.adapter.utils.test_get_powers_of_two import BaseGetPowersOfTwo from dbt.tests.adapter.utils.test_hash import BaseHash from dbt.tests.adapter.utils.test_intersect import BaseIntersect from dbt.tests.adapter.utils.test_last_day import BaseLastDay @@ -66,6 +70,10 @@ class TestDateDiff(BaseDateDiff): pass +class TestDateSpine(BaseDateSpine): + pass + + class TestDateTrunc(BaseDateTrunc): pass @@ -82,6 +90,18 @@ class TestExcept(BaseExcept): pass +class TestGenerateSeries(BaseGenerateSeries): + pass + + +class TestGetIntervalsBeteween(BaseGetIntervalsBetween): + pass + + +class TestGetPowersOfTwo(BaseGetPowersOfTwo): + pass + + class TestHash(BaseHash): pass