Skip to content

compatiblity for 1.5.0 #51

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

Merged
merged 3 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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'
5 changes: 3 additions & 2 deletions 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 Expand Up @@ -73,7 +74,7 @@ def open(cls, connection: Connection):

for ext_path in credentials.extensions:
handle.load_extension(ext_path)

cursor = handle.cursor()

for schema in set(schemas_and_paths.keys()) - set(['main']):
Expand Down
27 changes: 11 additions & 16 deletions dbt/include/sqlite/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,22 @@
{% 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) -%}
{% 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 +104,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 +115,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