Skip to content

Commit

Permalink
add compatiblity for 1.5.0
Browse files Browse the repository at this point in the history
- sourced from MatthewPocock with a minor adjustment made to the anonymous telemetry `unique_key` to use socket.gethostname()
  • Loading branch information
tom-juntunen committed Apr 20, 2024
1 parent af6dd91 commit 2a5f0f0
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
strategy:
matrix:
python_version: ["3.8", "3.9", "3.10"]
python_version: ["3.8", "3.9", "3.10", "3.11"]

runs-on: ubuntu-latest

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apt-get update && apt-get -y install git python3 python3-pip python3-venv sq
WORKDIR /opt/dbt-sqlite

RUN python3 -m pip install --upgrade pip \
&& python3 -m pip install pytest pytest-dotenv dbt-core~=1.4.0 dbt-tests-adapter~=1.4.0
&& python3 -m pip install pytest pytest-dotenv dbt-core~=1.5.0 dbt-tests-adapter~=1.5.0

RUN wget -q https://github.com/nalgeon/sqlean/releases/download/0.15.2/crypto.so
RUN wget -q https://github.com/nalgeon/sqlean/releases/download/0.15.2/math.so
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Use the right version. Starting with the release of dbt-core 1.0.0,
versions of dbt-sqlite are aligned to the same major+minor
[version](https://semver.org/) of dbt-core.

- versions 1.5.x of this adapter work with dbt-core 1.5.x
- versions 1.4.x of this adapter work with dbt-core 1.4.x
- versions 1.3.x of this adapter work with dbt-core 1.3.x
- versions 1.2.x of this adapter work with dbt-core 1.2.x
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/sqlite/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '1.4.0'
version = '1.5.0'
3 changes: 2 additions & 1 deletion dbt/adapters/sqlite/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import glob
import os.path
import sqlite3
from socket import gethostname
from typing import Optional, Tuple, Any, Dict, List


Expand Down Expand Up @@ -37,7 +38,7 @@ def unique_field(self):
Hashed and included in anonymous telemetry to track adapter adoption.
Pick a field that can uniquely identify one team/organization building with this adapter
"""
return self.host
return gethostname()

def _connection_keys(self):
""" Keys to show when debugging """
Expand Down
30 changes: 13 additions & 17 deletions dbt/include/sqlite/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,24 @@
{% endmacro %}

{% macro sqlite__create_table_as(temporary, relation, sql) -%}
create {% if temporary -%}
{% set contract_config = config.get('contract') %}
{% if contract_config.enforced %}
{{exceptions.warn("Model contracts cannot be enforced by sqlite!")}}
{% endif %}
create {% if temporary -%}
temporary
{%- endif %} table {{ relation }}
as
{%- endif %} table {{ relation }}
as
{{ sql }}
{% endmacro %}

{% macro sqlite__create_view_as(relation, sql, auto_begin=False) -%}
create view {{ relation }} as
{% set contract_config = config.get('contract') %}
{% if contract_config.enforced %}
{{exceptions.warn("Model contracts cannot be enforced by sqlite!")}}
{% endif %}
create view {{ relation }}
as
{{ sql }};
{%- endmacro %}

Expand All @@ -96,15 +105,6 @@
{# see SQLiteAdapter.rename_relation() #}
{% endmacro %}

{% macro sqlite__snapshot_get_time() -%}
datetime()
{%- endmacro %}

{% macro sqlite__snapshot_string_as_time(timestamp) -%}
{# just return the string; SQLite doesn't have a timestamp data type per se #}
{{ return("'" + timestamp|string + "'") }}
{%- endmacro %}

{#
the only allowable schema for temporary tables in SQLite is 'temp', so set
that here when making the relation and everything else should Just Work
Expand All @@ -116,7 +116,3 @@ that here when making the relation and everything else should Just Work

{% do return(tmp_relation) %}
{% endmacro %}

{% macro sqlite__current_timestamp() -%}
datetime()
{%- endmacro %}
12 changes: 12 additions & 0 deletions dbt/include/sqlite/macros/utils/timestamps.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% macro sqlite__current_timestamp() -%}
datetime()
{%- endmacro %}

{% macro sqlite__snapshot_string_as_time(timestamp) -%}
{# just return the string; SQLite doesn''t have a timestamp data type per se #}
{{ return("'" + timestamp|string + "'") }}
{%- endmacro %}

{% macro sqlite__snapshot_get_time() -%}
datetime()
{%- endmacro %}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _get_plugin_version():
]
},
install_requires=[
"dbt-core>=1.4.0"
"dbt-core~=1.5.0"
],
classifiers=[
'Development Status :: 4 - Beta',
Expand Down

0 comments on commit 2a5f0f0

Please sign in to comment.