dbt-labs / dbt-labs/dbt-adapters
[Bug] tmp_relation_type View not respecting cluster_by config
- Dominant language
- Python
- Stars
- 233
- Forks
- 362
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 9
Description
### Is this a new bug?
- [x] I believe this is a new bug
- [x] I have searched the existing issues, and I could not find an existing issue for this bug
### Which packages are affected?
- [ ] dbt-adapters
- [ ] dbt-tests-adapter
- [ ] dbt-athena
- [ ] dbt-athena-community
- [ ] dbt-bigquery
- [ ] dbt-postgres
- [ ] dbt-redshift
- [x] dbt-snowflake
- [ ] dbt-spark
### Current Behavior
When the `tmp_relation_type` is set to `view` the resulting query is not ordered by the fields identified in by the `cluster_by` config.
https://github.com/dbt-labs/dbt-adapters/blob/main/dbt-snowflake/src/dbt/include/snowflake/macros/relations/view/create.sql#L27-L29
### Expected Behavior
I would expect the view to follow the same behavior as the table and include an `ORDER BY` within the query.
https://github.com/dbt-labs/dbt-adapters/blob/main/dbt-snowflake/src/dbt/include/snowflake/macros/relations/table/create.sql#L103-L114
### Steps To Reproduce
1. Create an incremental model with a `cluster_by` config
2. set `tmp_relation_type` to view or leave as default
3. perform an incremental run of the model
4. review the query produced to create the temp view.
### Relevant log output
```shell
```
### Environment
```markdown
- OS: Intel Mac
- Python: 3.10
- dbt-adapters:
- dbt-snowflake: 1.9.1
```
### Additional Context
This may have an impact on clustering costs when the records are not ordered before loading in the target table.
Contributor guide
Assessment
This issue has not been assessed yet.