[v2 Bug] Preview CTE failure on CTE containing Jinja whitespace control
- 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 v2.x compared to the latest version of dbt 1.x?
- [x] I believe this is a new bug in dbt v2.x
- [x] I have searched the existing issues and could not find a duplicate
### Current Behavior
"Preview CTE" fails when attempting to preview CTE containing Jinja whitespace control. `dbt show` / `dbt show --inline` on the full model SQL succeeds.
### Expected Behavior
Preview CTE works on CTEs containing Jinja whitespace control.
### Steps To Reproduce
1. Create a model:
```sql
-- model.sql
WITH cte AS (
SELECT
{{- " 1 " -}} AS foo
)
SELECT *
FROM cte
```
2. Click "Preview CTE" and observe error:
```
Internal: [Snowflake] 001003 (42000): SQL compilation error:
syntax error line 6 at position 0 unexpected 'SE'. (sqlstate: [52, 50, 48, 48, 48], vendor_code: 1003)
```
### Relevant log output
```shell
```
### Environment
```markdown
- OS: Windows
- CPU: (x86 or ARM) x86
- dbt distribution and version: (`dbt --version`) preview.218
```
### Which database adapter are you using?
_No response_
### Is this a discrepancy vs. dbt 1.x?
- [ ] Yes — this works in dbt 1.x but not in dbt v2.x
### Additional Context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.