Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ vars:
intercom__contact_history_pass_through_columns: []
intercom__conversation_history_pass_through_columns: []
intercom__article_history_pass_through_columns: []
dispatch:
- macro_namespace: fivetran_utils
search_order: ['intercom', 'fivetran_utils']
clean-targets:
- target
- dbt_modules
Expand Down
1 change: 1 addition & 0 deletions integration_tests/ci/test_scenarios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ schema_variable_name: "intercom_schema"

include_databricks_sql: false
include_sqlserver: false
include_duckdb: true
include_dbt_compile: true

test_scenarios:
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ seeds:
dispatch:
- macro_namespace: dbt_utils
search_order: ['spark_utils', 'dbt_utils']
- macro_namespace: fivetran_utils
search_order: ['intercom', 'fivetran_utils']

flags:
send_anonymous_usage_stats: False
Expand Down
7 changes: 7 additions & 0 deletions macros/duckdb__percentile.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--percentile calculation specific to DuckDB
{% macro duckdb__percentile(percentile_field, partition_field, percent) %}

quantile_cont({{ percentile_field }}, {{ percent }})
/* have to group by partition field */

{% endmacro %}
4 changes: 2 additions & 2 deletions models/intercom__admin_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ median_metrics as (
round(cast({{ fivetran_utils.percentile("conversation_metrics.time_to_first_close_minutes", "last_close_by_admin_id", "0.5") }} as numeric), 2) as median_time_to_first_close_minutes,
round(cast({{ fivetran_utils.percentile("conversation_metrics.time_to_last_close_minutes", "last_close_by_admin_id", "0.5") }} as numeric), 2) as median_time_to_last_close_minutes
from conversation_metrics
--The Postgres warehouse does not allow for a group by argument within the `percentile` function. As such, we will apply the group by for all statements at the end of the query for Postgres only.
{% if target.type == 'postgres' %}
--The Postgres and DuckDB warehouses do not allow for a group by argument within the `percentile` function. As such, we will apply the group by for all statements at the end of the query for Postgres and DuckDB only.
{% if target.type in ('postgres', 'duckdb') %}
group by 1, 2
{% endif %}
),
Expand Down
4 changes: 2 additions & 2 deletions models/intercom__company_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ median_metrics as (
on company_enhanced.company_id = contact_company_history.company_id
and company_enhanced.source_relation = contact_company_history.source_relation

--The Postgres warehouse does not allow for a group by argument within the `percentile` function. As such, we will apply the group by for all statements at the end of the query for Postgres only.
{% if target.type == 'postgres' %}
--The Postgres and DuckDB warehouses do not allow for a group by argument within the `percentile` function. As such, we will apply the group by for all statements at the end of the query for Postgres and DuckDB only.
{% if target.type in ('postgres', 'duckdb') %}
group by 1, 2
{% endif %}
),
Expand Down