codeforkjeff/dbt-sqlite

Fix errors in sqlite__dateadd in dbt-core v1.6.0

Closed this issue · 1 comments

Here is the error I received during my test:

00:49:42  Completed with 1 error and 0 warnings:
00:49:42
00:49:42  Failure in test assert_equal_test_dateadd_actual__expected (models/test_dateadd.yml)
00:49:42    Got 4 results, configured to fail if != 0
00:49:42
00:49:42    compiled Code at target/compiled/test/models/test_dateadd.yml/assert_equal_test_dateadd_actual__expected.sql
00:49:42
00:49:42  Done. PASS=2 WARN=0 ERROR=1 SKIP=0 TOTAL=3

Here is the sample seed used for the test:

seeds__data_dateadd_csv = """from_time,interval_length,datepart,result
2018-01-01 01:00:00,1,day,2018-01-02 01:00:00
2018-01-01 01:00:00,1,month,2018-02-01 01:00:00
2018-01-01 01:00:00,1,year,2019-01-01 01:00:00
2018-01-01 01:00:00,1,hour,2018-01-01 02:00:00
,1,day,
"""

Since our existing dateadd macro only uses date we are not able to pass this test which has datetime in it.

{% macro sqlite__dateadd(datepart, interval, from_date_or_timestamp) %}

    date(
        {{ from_date_or_timestamp }},
        "{{ datepart }} {{ datepart }}"
        )

{% endmacro %}

I have resolved this issue in an updated dateadd.sql macro in our adapter files, which passes the assert_equal_test_dateadd_actual__expected test.

I have committed this change to a new compatibility branch for v1.6.0 here.