dbt-labs / dbt-labs/dbt-adapters
ADAP-1260: [Bug] [dbt-redshift] merge macro aliases cause Redshift materializations to fail
- 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
- [x] dbt-redshift
- [ ] dbt-snowflake
- [ ] dbt-spark
### Current Behavior
After #910 our incremental Redshift loads started failing due to an alias syntax error (Redshift doesnt allow aliases in some DELETE/INSERT jobs)
[DBT slack thread](https://getdbt.slack.com/archives/CJARVS0RY/p1743469802292739)
### Expected Behavior
Incremental models should execute their delete/insert steps without issue
### Steps To Reproduce
On `dbt-adapters==1.14.4` , try a Redshift incremental delete/insert model and see if you get this error
When you change to an easier version of the repo it should work fine:
`dbt-adapters==1.14.3`
### Relevant log output
```shell
Example Airflow error
Database Error in model
[2025-04-01, 00:55:29 UTC] {subprocess.py:93} INFO - syntax error at or near "as" in context "from "analytics"."schema_name"."example_redshift_table_name" as", at line 6, column 80
Where we think the "Redshift doesnt like aliases in Delete From" issue is arising
delete from "analytics"."schema_name"."example_redshift_table_name" as DBT_INTERNAL_DEST
where (composite_key) in (
select distinct composite_key
from "table_name__dbt_tmp235413576120" as DBT_INTERNAL_SOURCE
);
```
### Environment
```markdown
- dbt-adapters==1.14.4
```
### Additional Context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.