Skip to content

Commit

Permalink
Merge pull request #287 from dbt-msft/v1.3.0
Browse files Browse the repository at this point in the history
release prep for dbt 1.3.0
  • Loading branch information
sdebruyn authored Oct 6, 2022
2 parents f0294e7 + d8798ce commit 1de0d7c
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 25 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ target/
# Pycharm
.idea

# VS Code
.vscode/

# Spyder
.spyproject/

Expand Down
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

### v1.3.0

#### Features

* Support for [dbt-core 1.3](https://github.com/dbt-labs/dbt-core/releases/tag/v1.3.0)
* Python models are currently not supported in this adapter
* The following cross-db macros are not supported in this adapter: `bool_or`, `array_construct`, `array_concat`, `array_append`

#### Fixes

* The macro `type_boolean` now returns the correct data type (`bit`)

#### Chores

* Update adapter testing framework
* Update dependencies and pre-commit hooks

### v1.2.0

#### Possibly breaking change: connection encryption
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/sqlserver/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.2.0"
version = "1.3.0rc1"
6 changes: 6 additions & 0 deletions dbt/adapters/sqlserver/sql_server_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ def get_rows_different_sql(

return sql

def valid_incremental_strategies(self):
"""The set of standard builtin strategies which this adapter supports out-of-the-box.
Not used to validate custom strategies defined by end users.
"""
return ["append", "delete+insert", "merge", "insert_overwrite"]

# This is for use in the test suite
def run_sql_for_tests(self, sql, fetch, conn):
cursor = conn.handle.cursor()
Expand Down
1 change: 1 addition & 0 deletions dbt/adapters/sqlserver/sql_server_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ class SQLServerColumn(Column):
"TIMESTAMP": "DATETIMEOFFSET",
"FLOAT": "FLOAT",
"INTEGER": "INT",
"BOOLEAN": "BIT",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% macro sqlserver__get_incremental_default_sql(arg_dict) %}

{% if arg_dict["unique_key"] %}
{% do return(get_incremental_delete_insert_sql(arg_dict)) %}
{% else %}
{% do return(get_incremental_append_sql(arg_dict)) %}
{% endif %}

{% endmacro %}
3 changes: 3 additions & 0 deletions dbt/include/sqlserver/macros/utils/array_construct.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% macro sqlserver__array_construct(inputs, data_type) -%}
JSON_ARRAY({{ inputs|join(' , ') }})
{%- endmacro %}
2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ twine==4.0.1
wheel==0.37.1
pre-commit==2.20.0
pytest-dotenv==0.5.2
dbt-tests-adapter==1.2.2
dbt-tests-adapter==1.3.0rc2
-e .
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

package_name = "dbt-sqlserver"
authors_list = ["Mikael Ene", "Anders Swanson", "Sam Debruyn", "Cor Zuurmond"]
dbt_version = "1.2"
description = """A Microsoft SQL Server adapter plugin for dbt"""
dbt_version = "1.3"
description = """A Microsoft SQL Server adapter plugin for dbt (data build tool)"""

this_directory = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(this_directory, "README.md")) as f:
Expand Down Expand Up @@ -66,7 +66,7 @@ def run(self):
packages=find_namespace_packages(include=["dbt", "dbt.*"]),
include_package_data=True,
install_requires=[
f"dbt-core~={dbt_version}.0",
"dbt-core==1.3.0rc2",
"pyodbc==4.0.32",
"azure-identity>=1.10.0",
],
Expand Down
24 changes: 23 additions & 1 deletion tests/functional/adapter/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
from dbt.tests.adapter.basic.test_empty import BaseEmpty
from dbt.tests.adapter.basic.test_ephemeral import BaseEphemeral
from dbt.tests.adapter.basic.test_generic_tests import BaseGenericTests
from dbt.tests.adapter.basic.test_incremental import BaseIncremental
from dbt.tests.adapter.basic.test_incremental import (
BaseIncremental,
BaseIncrementalNotSchemaChange,
)
from dbt.tests.adapter.basic.test_singular_tests import BaseSingularTests
from dbt.tests.adapter.basic.test_singular_tests_ephemeral import BaseSingularTestsEphemeral
from dbt.tests.adapter.basic.test_snapshot_check_cols import BaseSnapshotCheckCols
Expand Down Expand Up @@ -37,6 +40,25 @@ class TestIncrementalSQLServer(BaseIncremental):
pass


class TestIncrementalNotSchemaChangeSQLServer(BaseIncrementalNotSchemaChange):
@pytest.fixture(scope="class")
def models(self):
incremental_not_schema_change_sql = """
{{ config(
materialized="incremental",
unique_key="user_id_current_time",
on_schema_change="sync_all_columns") }}
select
1 + '-' + current_timestamp as user_id_current_time,
{% if is_incremental() %}
'thisis18characters' as platform
{% else %}
'okthisis20characters' as platform
{% endif %}
"""
return {"incremental_not_schema_change.sql": incremental_not_schema_change_sql}


class TestGenericTestsSQLServer(BaseGenericTests):
pass

Expand Down
5 changes: 5 additions & 0 deletions tests/functional/adapter/test_data_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from dbt.tests.adapter.utils.data_types.test_type_bigint import BaseTypeBigInt
from dbt.tests.adapter.utils.data_types.test_type_boolean import BaseTypeBoolean
from dbt.tests.adapter.utils.data_types.test_type_float import BaseTypeFloat
from dbt.tests.adapter.utils.data_types.test_type_int import BaseTypeInt
from dbt.tests.adapter.utils.data_types.test_type_numeric import BaseTypeNumeric
Expand Down Expand Up @@ -52,3 +53,7 @@ def seeds(self):
"expected.csv": seeds__expected_csv,
"expected.yml": seeds__expected_yml,
}


class TestTypeBooleanSQLServer(BaseTypeBoolean):
pass
17 changes: 1 addition & 16 deletions tests/functional/adapter/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
ref_models__docs_md,
ref_models__ephemeral_copy_sql,
ref_models__schema_yml,
ref_sources__schema_yml,
)


Expand Down Expand Up @@ -66,22 +67,6 @@ def models(self):
select first_name, ct from {{ref('ephemeral_summary')}}
"""

ref_sources__schema_yml = """
version: 2
sources:
- name: my_source
description: "{{ doc('source_info') }}"
loader: a_loader
schema: "{{ var('test_schema') }}"
tables:
- name: my_table
description: "{{ doc('table_info') }}"
identifier: seed
columns:
- name: id
description: "{{ doc('column_info') }}"
"""

return {
"schema.yml": ref_models__schema_yml,
"sources.yml": ref_sources__schema_yml,
Expand Down
23 changes: 23 additions & 0 deletions tests/functional/adapter/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
seeds__data_listagg_csv,
)
from dbt.tests.adapter.utils.test_any_value import BaseAnyValue
from dbt.tests.adapter.utils.test_array_append import BaseArrayAppend
from dbt.tests.adapter.utils.test_array_concat import BaseArrayConcat
from dbt.tests.adapter.utils.test_array_construct import BaseArrayConstruct
from dbt.tests.adapter.utils.test_bool_or import BaseBoolOr
from dbt.tests.adapter.utils.test_cast_bool_to_text import BaseCastBoolToText
from dbt.tests.adapter.utils.test_concat import BaseConcat
from dbt.tests.adapter.utils.test_current_timestamp import BaseCurrentTimestampNaive
from dbt.tests.adapter.utils.test_date_trunc import BaseDateTrunc
from dbt.tests.adapter.utils.test_dateadd import BaseDateAdd
from dbt.tests.adapter.utils.test_datediff import BaseDateDiff
Expand Down Expand Up @@ -222,3 +226,22 @@ class TestPositionSQLServer(BasePosition):

class TestReplaceSQLServer(BaseReplace):
pass


class TestCurrentTimestampSQLServer(BaseCurrentTimestampNaive):
pass


@pytest.mark.skip(reason="arrays not supported")
class TestArrayAppendSQLServer(BaseArrayAppend):
pass


@pytest.mark.skip(reason="arrays not supported")
class TestArrayConcatSQLServer(BaseArrayConcat):
pass


@pytest.mark.skip(reason="arrays not supported")
class TestArrayConstructSQLServer(BaseArrayConstruct):
pass

0 comments on commit 1de0d7c

Please sign in to comment.