-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlog_transform.sql
More file actions
26 lines (19 loc) · 1.01 KB
/
Copy pathlog_transform.sql
File metadata and controls
26 lines (19 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{% macro log_transform(column, base=10, offset=0) %}
{# Validate inputs #}
{% if column is none or column == '' %}
{{ exceptions.raise_compiler_error("log_transform: 'column' parameter is required and cannot be empty.") }}
{% endif %}
{% if base is none %}
{{ exceptions.raise_compiler_error("log_transform: 'base' parameter cannot be None.") }}
{% endif %}
{% if base <= 0 or base == 1 %}
{{ exceptions.raise_compiler_error("log_transform: 'base' parameter must be positive and not equal to 1. Got: " ~ base ~ ".") }}
{% endif %}
{% if offset is none %}
{{ exceptions.raise_compiler_error("log_transform: 'offset' parameter cannot be None.") }}
{% endif %}
{{ return(adapter.dispatch('log_transform', 'dbt_ml_inline_preprocessing')(column, base, offset)) }}
{% endmacro %}
{% macro default__log_transform(column, base, offset) %}
({{ dbt_ml_inline_preprocessing.power_transform(column, lambda=0, offset=offset) }}) / ln({{ base }})
{% endmacro %}