/dbt-postgres-utils

PostgreSQL-specific utility macros for dbt projects.

Apache License 2.0Apache-2.0

Postgres Utils

This dbt package contains Postgres-specific macros that can be (re)used across dbt projects.

Project Plan

Available in detail on Trello dbt-postgres-utils - voting enabled!

Installation Instructions

Check dbt Hub for the latest installation instructions, or read the docs for more information on installing packages.

Prerequisites

Postgres Utils is compatible with dbt 0.17.0 and later.


Optimizers

index (source)

This macro creates an index on a given column.

PostgreSQL Docs: Index

Usage (at end of model definition .sql file):

{{
config({
    "post-hook": [
      "{{ postgres_utils.index(this, 'id')}}",
    ],
    })
}}

uindex (source)

This macro creates an index on a given column which contains unique values (required to be fully distinct).

PostgreSQL Docs: Unique Index

Usage (at end of model definition .sql file):

{{
config({
    "post-hook": [
      "{{ postgres_utils.uindex(this, 'id')}}",
    ],
    })
}}

Acknowlegements

This project extends fishtown-analytics's own postgres project available here:

https://github.com/fishtown-analytics/postgres (source of index macro)