dbt-labs / dbt-snowflake

dbt-snowflake contains all of the code enabling dbt to work with Snowflake
https://getdbt.com
Apache License 2.0
296 stars 176 forks source link

[Feature] Support ordering on Incremental Materializations #1208

Open danielefrigo opened 1 month ago

danielefrigo commented 1 month ago

Is this your first time submitting a feature request?

Describe the feature

I know that dbt adds an order by at the end of models materialized as table having a clustering key, in order to reduce (potentially to zero) the auto-clustering costs. Couldn't the same logic be applied also to append and delete+insert materializations? I often apply them to models with time-aggregated data (e.g. monthly summaries), and they could surely benefit for such a feature (and I don't see any drawback: in the worst case, the auto-clustering would re-cluster the new data with the old one as it would have done anyway). I did some testing on my own project, and found that overriding get_insert_into_sql macro should do the trick.

Describe alternatives you've considered

No response

Who will this benefit?

No response

Are you interested in contributing this feature?

No response

Anything else?

No response