Skip to content

Instantly share code, notes, and snippets.

View jthandy's full-sized avatar

Tristan Handy jthandy

View GitHub Profile
@tconbeer
tconbeer / describe_table.sql
Created February 8, 2019 23:15
dbt macro for descriptive statistics of a model
{% macro can_sum(field) %}
{{return(field.dtype.lower() in ('integer', 'bigint', 'double precision', 'float', 'real', 'numeric', 'decimal'))}}
{% endmacro %}
{% macro can_percentile(field) %}
{{return(field.dtype.lower() in ('integer', 'bigint', 'double precision', 'float', 'real', 'numeric', 'decimal', 'date', 'timestamp', 'timestamptz'))}}
{% endmacro %}
{% macro describe_model(model) %}
{# Calculates descriptive statistics for each field in model. Model should be a