Adapter: dbt-sqlserver 1.10.0-rc1
dbt Core: 1.10.20
SQL Server: Microsoft ODBC Driver 18
Description
When a unit test given block specifies rows: [] for an input, dbt core generates an
empty-fixture CTE of the form:
__dbt__cte__some_ref as (
-- Fixture for some_ref
select try_cast(null as varchar(255)) as "col_a"
limit 0
)
The query fails immediately with:
('42000', "[42000] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]
Incorrect syntax near 'limit'. (102) (SQLMoreResults)")
Steps to reproduce
- Define a dbt unit test where at least one given input has rows: [].
- Run dbt test --resource-type unit_test.
Minimal YAML excerpt:
unit_tests:
- name: my_test
model: my_model
given:
- input: ref('some_ref')
rows: [] # <-- triggers the bug
- input: ref('other_ref')
rows:
- col_a: 'foo'
expect:
rows:
- col_a: 'foo'
Expected behaviour
An empty rows: [] block should produce a zero-row CTE using T-SQL-compatible
syntax
Adapter: dbt-sqlserver 1.10.0-rc1
dbt Core: 1.10.20
SQL Server: Microsoft ODBC Driver 18
Description
When a unit test given block specifies rows: [] for an input, dbt core generates an
empty-fixture CTE of the form:
The query fails immediately with:
('42000', "[42000] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]
Incorrect syntax near 'limit'. (102) (SQLMoreResults)")
Steps to reproduce
Minimal YAML excerpt:
Expected behaviour
An empty rows: [] block should produce a zero-row CTE using T-SQL-compatible
syntax