dbt-labs / dbt-postgres

Apache License 2.0
31 stars 12 forks source link

[WIP] - Partitioning support #78

Open ggam opened 6 months ago

ggam commented 6 months ago

resolves https://github.com/dbt-labs/dbt-postgres/issues/168

Problem

This is a draft PR adding partitioning support for Postgres as stated on https://github.com/dbt-labs/dbt-postgres/issues/168. It doesn't use dbt coding best practices and lacks, but it works. I'm opening it to gather feedback on how to proceed.

Syntax is copied from on dbt-bigquery partitioning:

{{ config(
    materialized = 'table',
    partition_by = {
      "field": "created_at",
      "granularity": "month"
    }
) }}

select generate_series(current_date - interval '1000 day', current_date, '1 month'::interval)::date as created_at,
        'hello' as dummy_text

Benefits this brings:

Moreover, creating a custom incremental strategy replacing partitions is then relatively easy as shown in https://github.com/dbt-labs/dbt-postgres/issues/168. That incremental strategy is out of scope for this PR as there are a lot of possible variations.

IMO this patch is already in a stage that can be reviewed. I would help on some best practices and adding tests though.

Solution

To Do:

Checklist

AniPatel commented 1 month ago

Do you have any plans for when these changes will be available in the master branch?