markporoshin / dbt-greenplum

Adaptation postgres adapter for Greenplum
32 stars 20 forks source link

Partition by clause support #3

Closed d1bevz closed 2 years ago

d1bevz commented 2 years ago

Does this adapter support for a partition clause? Like PARTITION BY RANGE (dt) (DEFAULT PARTITION other)

markporoshin commented 2 years ago

Hi! Yes, check the README.md on develop branch. There are few ways to specify partition using dbt-greenplum: https://github.com/markporoshin/dbt-greenplum/blob/develop/README.md

markporoshin commented 2 years ago

An example of partition usage

{% set fields_string %}
     user_id int4 null,
     incomingyear timestamp null
{% endset %}

{% set raw_partition %}
    PARTITION BY RANGE (incomingyear)
    (
        START ('2021-01-01'::timestamp) INCLUSIVE
        END ('2023-01-01'::timestamp) EXCLUSIVE
        EVERY (INTERVAL '1 year'),
        DEFAULT PARTITION extra
    );
{% endset %}

{{
    config(
        schema='marts',
        materialized='incremental',
        distributed_by='user_id',
        fields_string=fields_string,
        raw_partition=raw_partition
    )
}}

select
    user_id,
    incomingyear
from
    table
d1bevz commented 2 years ago

Very nice! Thank you for your adapter! Very quick response :)