dbt-labs / dbt-labs/dbt

[CT-3372] [Bug] Syntax error in `is_type` macro within test suite (only when test fails)

Open
#9,055 5 comments 0 reactions 0 assignees View on GitHub
engine:v1 type:bug
Dominant language
Rust
Stars
13.8k
Forks
2.6k
Avg merge
21h 31m
Merged PRs (30d)
56

Description

### Is this a new bug in dbt-core?

- [X] I believe this is a new bug in dbt-core
- [X] I have searched the existing issues, and I could not find an existing issue for this bug

### Current Behavior

So I'm trying to adopt missing functional adapter tests. When I got to column_types, once I used model_sql that was compatible with my adapter (Databricks), I failed the test due to a syntax error in the macro:

```
select 'int_col' as bad_column
union all

select 'numeric_col' as bad_column
union all

select 'string_col' as bad_column


select * from (select 1 limit 0) as nothing
------^^^
```

Looking at the macro definition, I think this hasn't been an issue because there is no syntax error if there are no failures. Here's the offending code:

```
...
{% do log('bad columns: ' ~ bad_columns, info=True) %}
{% for bad_column in bad_columns %}
select '{{ bad_column }}' as bad_column
{{ 'union all' if not loop.last }}
{% endfor %}
select * from (select 1 limit 0) as nothing
```

### Expected Behavior

Failure of the test due to the dbt tests failing (as opposed to syntax failure). In my project, I have replaced the code above with:
```
{% if bad_columns %}
{% do log('bad columns: ' ~ bad_columns, info=True) %}
{% for bad_column in bad_columns %}
select '{{ bad_column }}' as bad_column
{{ 'union all' if not loop.last }}
{% endfor %}
{% else %}
select * from (select 1 limit 0) as nothing
{% endif %}
```

### Steps To Reproduce

Tweak the definition of model_sql so that the test would fail. See that the failure in the logs is due to syntax error.

### Relevant log output

_No response_

### Environment

```markdown
- OS:
- Python:
- dbt:
```

### Which database adapter are you using with dbt?

other (mention it in "Additional Context")

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.