-
Notifications
You must be signed in to change notification settings - Fork 9
Description
dbt recently added unit testing support to dbt 1.8:
I tried using it with dbt 1.9 and the latest dbt RisingWave adapter:
utest.sql:
{{ config(materialized='view', enabled=true) }}
select 1 as col
utest.yml:
version: 2
models:
- name: utest
unit_tests:
- name: test_utest
model: utest
given: []
expect:
rows:
- {col: 5}
But it doesn't work:
dbt test --select utest
18:57:50 Running with dbt=1.9.3
18:57:50 Registered adapter: risingwave=1.9.1
18:57:53 Found 8 models, 19 data tests, 613 macros, 2 groups, 1 unit test
18:57:53
18:57:53 Concurrency: 1 threads (target='dev')
18:57:53
18:57:57 1 of 1 START unit_test utest::test_utest ....................................... [RUN]
18:57:57 1 of 1 ERROR utest::test_utest ................................................. [ERROR in 0.04s]
18:57:57
18:57:57 Finished running 1 unit test in 0 hours 0 minutes and 3.44 seconds (3.44s).
18:57:58
18:57:58 Completed with 1 error, 0 partial successes, and 0 warnings:
18:57:58
18:57:58 Runtime Error in unit_test test_utest (models/utest.yml)
An error occurred during execution of unit test 'test_utest'. There may be an error in the unit test definition: check the data types.
Compilation Error
macro 'dbt_macro__risingwave__create_table_as' takes not more than 2 argument(s)
> in macro create_table_as (macros/relations/table/create.sql)
> called by macro default__get_create_table_as_sql (macros/relations/table/create.sql)
> called by macro get_create_table_as_sql (macros/relations/table/create.sql)
> called by macro materialization_unit_default (macros/materializations/tests/unit.sql)
> called by <Unknown>
18:57:58
18:57:58 Done. PASS=0 WARN=0 ERROR=1 SKIP=0 TOTAL=1
It looks like there is a new materialization type defined in unit.sql for unit tests. That has a function call get_create_table_as_sql(True, temp_relation, get_empty_subquery_sql(sql)) with a first parameter True indicating a temporary table.
That macro is defined in https://github.com/dbt-labs/dbt-adapters/blob/main/dbt-adapters/src/dbt/include/global_project/macros/relations/table/create.sql which calls {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code)}}
.... but the RisingWave create_table_as macro does not have a temporary parameter, thus the error:
| {% macro risingwave__create_table_as(relation, sql) -%} |
For comparison, it looks like Materialize supports unit tests in some capacity: https://github.com/MaterializeInc/materialize/blob/main/misc/dbt-materialize/dbt/include/materialize/macros/materializations/unit.sql