Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.19.0 #81

Merged
merged 19 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
MSSQL_IP_ADDRESS: 0.0.0.0
executor: python/default
steps:
- run: &install-git
name: "TEMP: install Git"
command: |
apt-get install -y git
- checkout
- run:
name: wait for SQL Server container to set up
Expand All @@ -30,6 +34,7 @@ jobs:
connection-sqlserver:
<<: *sqlserver
steps:
- run: *install-git
- checkout
- python/install-packages:
pkg-manager: pip
Expand Down Expand Up @@ -71,6 +76,7 @@ jobs:
- image: dataders/pyodbc:1.4
executor: python/default
steps:
- run: *install-git
- checkout
- python/install-packages:
pkg-manager: pip
Expand All @@ -87,6 +93,7 @@ jobs:
- image: dataders/pyodbc:1.4
executor: python/default
steps:
- run: *install-git
- checkout
- python/install-packages:
pkg-manager: pip
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 = '0.18.1'
version = '0.19.0rc2'
30 changes: 22 additions & 8 deletions dbt/adapters/sqlserver/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import dbt.exceptions
from dbt.adapters.base import Credentials
from dbt.adapters.sql import SQLConnectionManager
from dbt.contracts.connection import AdapterResponse
from azure.core.credentials import AccessToken
from azure.identity import AzureCliCredential, DefaultAzureCredential

Expand Down Expand Up @@ -258,6 +259,9 @@ def open(cls, connection):
if getattr(credentials, "trust_cert", False) is True:
con_str.append(f"TrustServerCertificate=Yes")

application_name = f"dbt-{credentials.type}"
con_str.append(f"APP={application_name}")

con_str_concat = ';'.join(con_str)

index = []
Expand Down Expand Up @@ -347,7 +351,7 @@ def add_query(self, sql, auto_begin=True, bindings=None, abridge_sql_log=False):

logger.debug(
"SQL status: {} in {:0.2f} seconds".format(
self.get_status(cursor), (time.time() - pre)
self.get_response(cursor), (time.time() - pre)
)
)

Expand All @@ -358,16 +362,26 @@ def get_credentials(cls, credentials):
return credentials

@classmethod
def get_status(cls, cursor):
if cursor.rowcount == -1:
status = "OK"
else:
status = str(cursor.rowcount)
return status
def get_response(cls, cursor) -> AdapterResponse:
#message = str(cursor.statusmessage)
message = 'OK'
rows = cursor.rowcount
#status_message_parts = message.split() if message is not None else []
#status_messsage_strings = [
# part
# for part in status_message_parts
# if not part.isdigit()
#]
#code = ' '.join(status_messsage_strings)
return AdapterResponse(
_message=message,
#code=code,
rows_affected=rows
)

def execute(self, sql, auto_begin=True, fetch=False):
_, cursor = self.add_query(sql, auto_begin)
status = self.get_status(cursor)
status = self.get_response(cursor)
if fetch:
table = self.get_result_from_cursor(cursor)
else:
dataders marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,3 @@
{% endfor %}), 2)
{% endmacro %}

{% macro snapshot_check_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}
{% set check_cols_config = config['check_cols'] %}
{% set primary_key = config['unique_key'] %}
{% set updated_at = snapshot_get_time() %}

{% if check_cols_config == 'all' %}
{% set check_cols = get_columns_in_query(node['injected_sql']) %}
{% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}
{% set check_cols = check_cols_config %}
{% else %}
{% do exceptions.raise_compiler_error("Invalid value for 'check_cols': " ~ check_cols_config) %}
{% endif %}

{% set row_changed_expr -%}
(
{% for col in check_cols %}
{{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}
or
(
(({{ snapshotted_rel }}.{{ col }} is null) and not ({{ current_rel }}.{{ col }} is null))
or
((not {{ snapshotted_rel }}.{{ col }} is null) and ({{ current_rel }}.{{ col }} is null))
)
{%- if not loop.last %} or {% endif %}

{% endfor %}
)
{%- endset %}

{% set scd_id_expr = sqlserver__snapshot_hash_arguments([primary_key, updated_at]) %}

{% do return({
"unique_key": primary_key,
"updated_at": updated_at,
"row_changed": row_changed_expr,
"scd_id": scd_id_expr
}) %}
{% endmacro %}
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dbt-core~=0.18.0
dbt-core==0.19.0rc2
pyodbc>=4.0.27
azure-identity>=1.4.0
black~=20.8b1
pytest-dbt-adapter~=0.3.0
pytest-dbt-adapter~=0.4.0
dataders marked this conversation as resolved.
Show resolved Hide resolved
tox==3.2.0
flake8>=3.5.0
certifi==2020.6.20
Expand Down
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _dbt_sqlserver_version():
package_version = _dbt_sqlserver_version()
description = """A sqlserver adapter plugin for dbt (data build tool)"""

dbt_version = '0.18.1'
dbt_version = '0.19.0'
# the package version should be the dbt version, with maybe some things on the
# ends of it. (0.18.1 vs 0.18.1a1, 0.18.1.1, ...)
if not package_version.startswith(dbt_version):
Expand Down Expand Up @@ -56,5 +56,9 @@ def _dbt_sqlserver_version():
"include/sqlserver/macros/**/**/*.sql",
]
},
install_requires=["dbt-core~=0.18.0", "pyodbc>=4.0.27", "azure-identity>=1.4.0"],
install_requires=[
'dbt-core==0.19.0rc2',
dataders marked this conversation as resolved.
Show resolved Hide resolved
"pyodbc>=4.0.27",
"azure-identity>=1.4.0",
]
)