Skip to content

Commit

Permalink
Merge branch 'main' into add_session_id
Browse files Browse the repository at this point in the history
  • Loading branch information
jeppe742 authored Mar 22, 2024
2 parents 61e24cf + ad7ea4d commit e8b732b
Show file tree
Hide file tree
Showing 47 changed files with 289 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.8.0a1
current_version = 1.8.0b1
parse = (?P<major>[\d]+) # major version number
\.(?P<minor>[\d]+) # minor version number
\.(?P<patch>[\d]+) # patch version number
Expand Down
40 changes: 40 additions & 0 deletions .changes/1.8.0-b1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## dbt-snowflake 1.8.0-b1 - March 02, 2024

### Features

- Update base adapter references as part of decoupling migration ([#882](https://github.com/dbt-labs/dbt-snowflake/issues/882))
- Support primative types + object, variant, array in snowflake for unit testing" ([#898](https://github.com/dbt-labs/dbt-snowflake/issues/898))

### Fixes

- Dynamic tables now show the proper type in catalog queries ([#817](https://github.com/dbt-labs/dbt-snowflake/issues/817))
- remove `token` field from connection keys ([#906](https://github.com/dbt-labs/dbt-snowflake/issues/906))

### Under the Hood

- Add tests for --empty flag ([#837](https://github.com/dbt-labs/dbt-snowflake/issues/837))
- Migrate to dbt-common and dbt-adapters package ([#890](https://github.com/dbt-labs/dbt-snowflake/issues/890))

### Dependencies

- Update ddtrace requirement from ~=1.18 to ~=1.19 ([#780](https://github.com/dbt-labs/dbt-snowflake/pull/780))
- Update pre-commit-hooks requirement from ~=4.4 to ~=4.5 ([#795](https://github.com/dbt-labs/dbt-snowflake/pull/795))
- Bump mypy from 1.5.1 to 1.6.0 ([#799](https://github.com/dbt-labs/dbt-snowflake/pull/799))
- Update pre-commit requirement from ~=3.4 to ~=3.5 ([#807](https://github.com/dbt-labs/dbt-snowflake/pull/807))
- Update black requirement from ~=23.9 to ~=23.10 ([#809](https://github.com/dbt-labs/dbt-snowflake/pull/809))
- Bump mypy from 1.6.0 to 1.6.1 ([#821](https://github.com/dbt-labs/dbt-snowflake/pull/821))
- Update ddtrace requirement from ~=1.19 to ~=2.1 ([#822](https://github.com/dbt-labs/dbt-snowflake/pull/822))
- Update black requirement from ~=23.10 to ~=23.11 ([#826](https://github.com/dbt-labs/dbt-snowflake/pull/826))
- Bump mypy from 1.6.1 to 1.7.0 ([#828](https://github.com/dbt-labs/dbt-snowflake/pull/828))
- Update pytest-xdist requirement from ~=3.3 to ~=3.4 ([#829](https://github.com/dbt-labs/dbt-snowflake/pull/829))
- Update ddtrace requirement from ~=2.1 to ~=2.2 ([#832](https://github.com/dbt-labs/dbt-snowflake/pull/832))
- Update wheel requirement from ~=0.41 to ~=0.42 ([#844](https://github.com/dbt-labs/dbt-snowflake/pull/844))
- Update ddtrace requirement from ~=2.2 to ~=2.3 ([#848](https://github.com/dbt-labs/dbt-snowflake/pull/848))
- Update pytest-xdist requirement from ~=3.4 to ~=3.5 ([#849](https://github.com/dbt-labs/dbt-snowflake/pull/849))
- Bump mypy from 1.7.0 to 1.7.1 ([#850](https://github.com/dbt-labs/dbt-snowflake/pull/850))
- Update freezegun requirement from ~=1.2 to ~=1.3 ([#860](https://github.com/dbt-labs/dbt-snowflake/pull/860))
- Update black requirement from ~=23.11 to ~=23.12 ([#864](https://github.com/dbt-labs/dbt-snowflake/pull/864))

### Security

- DDOS vulnerability in 41.0.5. Uptick to avoid ([#852](https://github.com/dbt-labs/dbt-snowflake/pull/852))
File renamed without changes.
6 changes: 6 additions & 0 deletions .changes/1.8.0/Fixes-20240216-125014.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: remove `token` field from connection keys
time: 2024-02-16T12:50:14.459161-08:00
custom:
Author: colin-rogers-dbt
Issue: "906"
6 changes: 6 additions & 0 deletions .changes/unreleased/Dependencies-20240319-102636.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Dependencies
body: hard pin ddtrace to 2.3.0
time: 2024-03-19T10:26:36.090014-05:00
custom:
Author: McKnight-42
PR: "932"
6 changes: 6 additions & 0 deletions .changes/unreleased/Dependencies-20240320-111128.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Dependencies
body: bump cryptography to 42.0.4 or higher for security callouts
time: 2024-03-20T11:11:28.5121-05:00
custom:
Author: McKnight-42
PR: "938"
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20240318-033136.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: ' Add new workflow for internal patch releases'
time: 2024-03-18T03:31:36.425644-07:00
custom:
Author: versusfacit
Issue: "38"
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240318-203635.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Acknowledge `send_anonymous_usage_stats` setting for python models
time: 2024-03-18T20:36:35.396323-04:00
custom:
Author: mikealfare
Issue: "830"
7 changes: 7 additions & 0 deletions .changes/unreleased/Fixes-20240320-154054.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Fixes
body: modify metadata queries to take into account object type of BASE TABLE being
assigned to dynamic tables when was null previously
time: 2024-03-20T15:40:54.074292-05:00
custom:
Author: McKnight-42
Issue: "934"
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240227-010428.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Add unit test for transaction semantics.
time: 2024-02-27T01:04:28.713433-08:00
custom:
Author: versusfacit
Issue: "912"
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ jobs:
- name: Check wheel distributions
run: |
dbt --version
python -c "import dbt.adapters.snowflake"
- name: Install source distributions
run: |
find ./dist/*.gz -maxdepth 1 -type f | xargs python -m pip install --force-reinstall --find-links=dist/
- name: Check source distributions
run: |
dbt --version
python -c "import dbt.adapters.snowflake"
64 changes: 64 additions & 0 deletions .github/workflows/release-internal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Release internal patch

on:
workflow_dispatch:
inputs:
version_number:
description: "The release version number (i.e. 1.0.0b1)"
type: string
required: true
sha:
description: "The sha to use (leave empty to use latest on main)"
type: string
required: false
package_test_command:
description: "Package test command"
type: string
default: "python -c \"import dbt.adapters.snowflake\""
required: true
dbms_name:
description: "The name of the warehouse the adapter connects to."
type: string
default: "snowflake"
required: true
workflow_call:
inputs:
version_number:
description: "The release version number (i.e. 1.0.0b1)"
type: string
required: true
sha:
description: "The sha to use (leave empty to use latest on main)"
type: string
required: false
package_test_command:
description: "Package test command"
type: string
default: "python -c \"import dbt.adapters.snowflake\""
required: true
dbms_name:
description: "The name of the warehouse the adapter connects to."
type: string
default: "snowflake"
required: true

defaults:
run:
shell: bash

env:
PYTHON_TARGET_VERSION: 3.11

jobs:
invoke-reusable-workflow:
name: Build and Release Internally

uses: VersusFacit/dbt-release/.github/workflows/internal-archive-release.yml@main

with:
version_number: ${{ inputs.version_number }}
package_test_command: ${{ inputs.package_test_command }}
dbms_name: ${{ inputs.dbms_name }}
sha: ${{ inputs.sha }}

secrets: inherit
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,49 @@
- "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.8.0-b1 - March 02, 2024

### Features

- Update base adapter references as part of decoupling migration ([#882](https://github.com/dbt-labs/dbt-snowflake/issues/882))
- Support primative types + object, variant, array in snowflake for unit testing" ([#898](https://github.com/dbt-labs/dbt-snowflake/issues/898))

### Fixes

- Dynamic tables now show the proper type in catalog queries ([#817](https://github.com/dbt-labs/dbt-snowflake/issues/817))
- remove `token` field from connection keys ([#906](https://github.com/dbt-labs/dbt-snowflake/issues/906))

### Under the Hood

- Add tests for --empty flag ([#837](https://github.com/dbt-labs/dbt-snowflake/issues/837))
- Migrate to dbt-common and dbt-adapters package ([#890](https://github.com/dbt-labs/dbt-snowflake/issues/890))

### Dependencies

- Update ddtrace requirement from ~=1.18 to ~=1.19 ([#780](https://github.com/dbt-labs/dbt-snowflake/pull/780))
- Update pre-commit-hooks requirement from ~=4.4 to ~=4.5 ([#795](https://github.com/dbt-labs/dbt-snowflake/pull/795))
- Bump mypy from 1.5.1 to 1.6.0 ([#799](https://github.com/dbt-labs/dbt-snowflake/pull/799))
- Update pre-commit requirement from ~=3.4 to ~=3.5 ([#807](https://github.com/dbt-labs/dbt-snowflake/pull/807))
- Update black requirement from ~=23.9 to ~=23.10 ([#809](https://github.com/dbt-labs/dbt-snowflake/pull/809))
- Bump mypy from 1.6.0 to 1.6.1 ([#821](https://github.com/dbt-labs/dbt-snowflake/pull/821))
- Update ddtrace requirement from ~=1.19 to ~=2.1 ([#822](https://github.com/dbt-labs/dbt-snowflake/pull/822))
- Update black requirement from ~=23.10 to ~=23.11 ([#826](https://github.com/dbt-labs/dbt-snowflake/pull/826))
- Bump mypy from 1.6.1 to 1.7.0 ([#828](https://github.com/dbt-labs/dbt-snowflake/pull/828))
- Update pytest-xdist requirement from ~=3.3 to ~=3.4 ([#829](https://github.com/dbt-labs/dbt-snowflake/pull/829))
- Update ddtrace requirement from ~=2.1 to ~=2.2 ([#832](https://github.com/dbt-labs/dbt-snowflake/pull/832))
- Update wheel requirement from ~=0.41 to ~=0.42 ([#844](https://github.com/dbt-labs/dbt-snowflake/pull/844))
- Update ddtrace requirement from ~=2.2 to ~=2.3 ([#848](https://github.com/dbt-labs/dbt-snowflake/pull/848))
- Update pytest-xdist requirement from ~=3.4 to ~=3.5 ([#849](https://github.com/dbt-labs/dbt-snowflake/pull/849))
- Bump mypy from 1.7.0 to 1.7.1 ([#850](https://github.com/dbt-labs/dbt-snowflake/pull/850))
- Update freezegun requirement from ~=1.2 to ~=1.3 ([#860](https://github.com/dbt-labs/dbt-snowflake/pull/860))
- Update black requirement from ~=23.11 to ~=23.12 ([#864](https://github.com/dbt-labs/dbt-snowflake/pull/864))

### Security

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



## 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)
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/snowflake/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.8.0a1"
version = "1.8.0b1"
1 change: 0 additions & 1 deletion dbt/adapters/snowflake/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ def _connection_keys(self):
"schema",
"authenticator",
"private_key_path",
"token",
"oauth_client_id",
"query_tag",
"client_session_keep_alive",
Expand Down
7 changes: 5 additions & 2 deletions dbt/adapters/snowflake/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,13 @@ def submit_python_job(self, parsed_model: dict, compiled_code: str):
if imports:
imports = f"IMPORTS = ('{imports}')"

snowpark_telemetry_string = "dbtLabs_dbtPython"
snowpark_telemetry_snippet = f"""
if self.config.args.SEND_ANONYMOUS_USAGE_STATS:
snowpark_telemetry_string = "dbtLabs_dbtPython"
snowpark_telemetry_snippet = f"""
import sys
sys._xoptions['snowflake_partner_attribution'].append("{snowpark_telemetry_string}")"""
else:
snowpark_telemetry_snippet = ""

common_procedure_code = f"""
RETURNS STRING
Expand Down
27 changes: 19 additions & 8 deletions dbt/adapters/snowflake/relation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
from typing import Optional, Type
from typing import FrozenSet, Optional, Type

from dbt.adapters.base.relation import BaseRelation
from dbt.adapters.relation_configs import RelationConfigChangeAction, RelationResults
Expand All @@ -20,13 +20,24 @@
class SnowflakeRelation(BaseRelation):
type: Optional[SnowflakeRelationType] = None # type: ignore
quote_policy: SnowflakeQuotePolicy = field(default_factory=lambda: SnowflakeQuotePolicy())
renameable_relations = frozenset({SnowflakeRelationType.Table, SnowflakeRelationType.View})
replaceable_relations = frozenset(
{
SnowflakeRelationType.DynamicTable,
SnowflakeRelationType.Table,
SnowflakeRelationType.View,
}

renameable_relations: FrozenSet[SnowflakeRelationType] = field(
default_factory=lambda: frozenset(
{
SnowflakeRelationType.Table,
SnowflakeRelationType.View,
}
)
)

replaceable_relations: FrozenSet[SnowflakeRelationType] = field(
default_factory=lambda: frozenset(
{
SnowflakeRelationType.DynamicTable,
SnowflakeRelationType.Table,
SnowflakeRelationType.View,
}
)
)

@property
Expand Down
5 changes: 4 additions & 1 deletion dbt/include/snowflake/macros/catalog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
table_catalog as "table_database",
table_schema as "table_schema",
table_name as "table_name",
coalesce(table_type, 'DYNAMIC TABLE') as "table_type",
case
when is_dynamic = 'YES' and table_type = 'BASE TABLE' THEN 'DYNAMIC TABLE'
else table_type
end as "table_type",
comment as "table_comment",

-- note: this is the _role_ that owns the table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
as (
{{ sql }}
)
;

{%- endmacro %}
4 changes: 2 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ git+https://github.com/dbt-labs/dbt-adapters.git#subdirectory=dbt-tests-adapter
black~=23.12
bumpversion~=0.6.0
click~=8.1
cryptography~=41.0.7
ddtrace~=2.3
cryptography~=42.0.4
ddtrace==2.3.0
flake8~=6.1
flaky~=3.7
freezegun~=1.3
Expand Down
16 changes: 3 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,8 @@ def _get_plugin_version_dict():
return match.groupdict()


# require a compatible minor version (~=), prerelease if this is a prerelease
def _get_dbt_core_version():
parts = _get_plugin_version_dict()
minor = "{major}.{minor}.0".format(**parts)
pre = parts["prekind"] + "1" if parts["prekind"] else ""
return f"{minor}{pre}"


package_name = "dbt-snowflake"
package_version = "1.8.0a1"
dbt_core_version = _get_dbt_core_version()
package_version = "1.8.0b1"
description = """The Snowflake adapter plugin for dbt"""

setup(
Expand All @@ -67,9 +58,8 @@ def _get_dbt_core_version():
packages=find_namespace_packages(include=["dbt", "dbt.*"]),
include_package_data=True,
install_requires=[
"dbt-core~={}".format(dbt_core_version),
"dbt-common~=0.1.0",
"dbt-adapters~=0.1.0a2",
"dbt-common>=0.1.0a1,<2.0",
"dbt-adapters>=0.1.0a1,<2.0",
"snowflake-connector-python[secure-local-storage]~=3.0",
# installed via dbt-core but referenced directly; don't pin to avoid version conflicts with dbt-core
"agate",
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/adapter/dynamic_table_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ def query_relation_type(project, relation: SnowflakeRelation) -> Optional[str]:
sql = f"""
select
case
when table_type = 'BASE TABLE' and is_dynamic = 'YES' then 'dynamic_table'
when table_type = 'BASE TABLE' then 'table'
when table_type = 'VIEW' then 'view'
when table_type = 'EXTERNAL TABLE' then 'external_table'
when table_type is null then 'dynamic_table'
end as relation_type
from information_schema.tables
where table_name like '{relation.identifier.upper()}'
Expand Down
Loading

0 comments on commit e8b732b

Please sign in to comment.