-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compatibility with dbt 1.2.0rc1 (#24)
* reorganize Dockerfile and use docker in github CI * in dbt-core 1.2.x, commit is now being done in SQLAdapter.drop_schema(), so there's no need for it here anymore. see this PR: dbt-labs/dbt-core#5198 * rm file on disk on DROP SCHEMA * load text.so sqlean extension to get split_parts fn * add math.so for functions needed by datediff
- Loading branch information
1 parent
815af9e
commit ef6c1db
Showing
22 changed files
with
609 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,5 @@ env/ | |
*.sublime-* | ||
|
||
.idea/ | ||
|
||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,33 @@ | ||
|
||
FROM ubuntu:20.04 | ||
ARG PYTHON_VERSION=3.9 | ||
|
||
RUN apt-get update && apt-get -y install git make python3 python3-pip python3-venv sqlite3 vim virtualenvwrapper wget | ||
FROM python:${PYTHON_VERSION}-bullseye | ||
|
||
RUN mkdir /root/dbt-sqlite | ||
RUN apt-get update && apt-get -y install git python3 python3-pip python3-venv sqlite3 vim virtualenvwrapper wget | ||
|
||
WORKDIR /root/dbt-sqlite | ||
WORKDIR /opt/dbt-sqlite | ||
|
||
RUN mkdir -p /tmp/dbt-sqlite-tests | ||
RUN python3 -m pip install --upgrade pip \ | ||
&& python3 -m pip install pytest pytest-dotenv dbt-core~=1.2.0 dbt-tests-adapter~=1.2.0 | ||
|
||
RUN cd /tmp/dbt-sqlite-tests && wget https://github.com/nalgeon/sqlean/releases/download/0.12.2/crypto.so | ||
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 | ||
RUN wget -q https://github.com/nalgeon/sqlean/releases/download/0.15.2/text.so | ||
|
||
RUN pip install dbt-core~=1.1.0 | ||
WORKDIR /opt/dbt-sqlite/src | ||
|
||
RUN pip install pytest pytest-dotenv dbt-tests-adapter==1.1.0 | ||
COPY . . | ||
|
||
ENTRYPOINT ["./run_tests.sh"] | ||
RUN pip install . | ||
|
||
ENV TESTDATA=/opt/dbt-sqlite/testdata | ||
|
||
RUN mkdir $TESTDATA | ||
|
||
VOLUME /opt/dbt-sqlite/testdata | ||
|
||
WORKDIR /opt/dbt-sqlite/project | ||
|
||
ENV PATH=$PATH:/opt/dbt-sqlite/src | ||
|
||
VOLUME /opt/dbt-sqlite/project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% macro sqlite__get_binding_char() %} | ||
{{ return('?') }} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% macro sqlite__any_value(expression) -%} | ||
|
||
min({{ expression }}) | ||
|
||
{%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% macro sqlite__bool_or(expression) -%} | ||
|
||
max({{ expression }}) | ||
|
||
{%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% macro sqlite__cast_bool_to_text(field) %} | ||
case | ||
when {{ field }} = 0 then 'false' | ||
when {{ field }} = 1 then 'true' | ||
end | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{% macro sqlite__dateadd(datepart, interval, from_date_or_timestamp) %} | ||
|
||
date( | ||
{{ from_date_or_timestamp }}, | ||
"{{ datepart }} {{ datepart }}" | ||
) | ||
|
||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
{# TODO: fully implement this and rename #} | ||
{# adapted from postgresql #} | ||
{% macro sqlite__datediff_broken(first_date, second_date, datepart) -%} | ||
|
||
{% if datepart == 'year' %} | ||
(strftime('%Y', {{second_date}}) - strftime('%Y', {{first_date}})) | ||
{# | ||
{% elif datepart == 'quarter' %} | ||
({{ datediff(first_date, second_date, 'year') }} * 4 + date_part('quarter', ({{second_date}})::date) - date_part('quarter', ({{first_date}})::date)) | ||
#} | ||
{% elif datepart == 'month' %} | ||
(({{ datediff(first_date, second_date, 'year') }} * 12 + strftime('%m', {{second_date}})) - strftime('%m', {{first_date}})) | ||
{% elif datepart == 'day' %} | ||
(floor(cast(strftime('%s', {{second_date}}) - strftime('%s', {{first_date}}) as real) / 86400) + | ||
case when {{second_date}} <= strftime('%Y-%m-%d 23:59:59.999999', {{first_date}}) then -1 else 0 end) | ||
{% elif datepart == 'week' %} | ||
({{ datediff(first_date, second_date, 'day') }} / 7 + case | ||
when strftime('%w', {{first_date}}) <= strftime('%w', {{second_date}}) then | ||
case when {{first_date}} <= {{second_date}} then 0 else -1 end | ||
else | ||
case when {{first_date}} <= {{second_date}} then 1 else 0 end | ||
end) | ||
{% elif datepart == 'hour' %} | ||
{# ({{ datediff(first_date, second_date, 'day') }} * 24 + strftime("%H", {{second_date}}) - strftime("%H", {{first_date}})) #} | ||
(ceil(cast(strftime('%s', {{second_date}}) - strftime('%s', {{first_date}}) as real) / 3600)) | ||
{% elif datepart == 'minute' %} | ||
{# ({{ datediff(first_date, second_date, 'hour') }} * 60 + strftime("%M", {{second_date}}) - strftime("%M", {{first_date}})) #} | ||
(ceil(cast(strftime('%s', {{second_date}}) - strftime('%s', {{first_date}}) as real) / 60)) | ||
{% elif datepart == 'second' %} | ||
(strftime('%s', {{second_date}}) - strftime('%s', {{first_date}})) | ||
{# | ||
{% elif datepart == 'millisecond' %} | ||
({{ datediff(first_date, second_date, 'minute') }} * 60000 + floor(date_part('millisecond', ({{second_date}})::timestamp)) - floor(date_part('millisecond', ({{first_date}})::timestamp))) | ||
{% elif datepart == 'microsecond' %} | ||
({{ datediff(first_date, second_date, 'minute') }} * 60000000 + floor(date_part('microsecond', ({{second_date}})::timestamp)) - floor(date_part('microsecond', ({{first_date}})::timestamp))) | ||
#} | ||
{% else %} | ||
{{ exceptions.raise_compiler_error("Unsupported datepart for macro datediff in sqlite: {!r}".format(datepart)) }} | ||
{% endif %} | ||
|
||
{%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% macro sqlite__hash(field) -%} | ||
case | ||
when {{ field }} is not null | ||
then lower(hex(md5(cast({{ field }} as {{ api.Column.translate_type('string') }})))) | ||
end | ||
{%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% macro sqlite__position(substring_text, string_text) %} | ||
|
||
instr({{ string_text }}, {{ substring_text }}) | ||
|
||
{%- endmacro -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% macro sqlite__right(string_text, length_expression) %} | ||
case | ||
when {{ length_expression }} <> 0 then | ||
substr( | ||
{{ string_text }}, | ||
-1 * {{ length_expression }} | ||
) | ||
else '' | ||
end | ||
{%- endmacro -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
#!/bin/bash | ||
|
||
docker build . -t dbt-sqlite-test | ||
docker build . -t dbt-sqlite | ||
|
||
docker run \ | ||
--rm \ | ||
--name dbt-sqlite-test-container \ | ||
-v "$(pwd)":"/root/dbt-sqlite" \ | ||
dbt-sqlite-test | ||
dbt-sqlite run_tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.