Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit 8a51d37

Browse files
author
Claire Carroll
authored
Merge pull request #25 from fishtown-analytics/pr/22
Allow customisation of audit schema in base project
2 parents 00091d1 + b716447 commit 8a51d37

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

README.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
> this package, especially as a post-hook. Please consider if this package is
66
> appropriate for your use case before using it.
77
8-
Requires dbt >= 0.14.0
8+
Requires dbt >= 0.16.0
99

1010
This package provides out-of-the-box functionality to log events for all dbt
1111
invocations, including run start, run end, model start, and model end. It
@@ -32,6 +32,21 @@ models:
3232
That's it! You'll now have a stream of events for all dbt invocations in your
3333
warehouse.
3434
35+
#### Customising audit schema
36+
37+
It's possible to customise the audit schema for any project by adding a macro named: `get_audit_schema` into your DBT project.
38+
39+
For example to always log into a specific schema, say `analytics_meta`, regardless of DBT schema, you can include the following in your project:
40+
41+
```sql
42+
-- your_dbt_project/macros/get_audit_schema.sql
43+
{% macro get_audit_schema() %}
44+
45+
{{ return('analytics_meta') }}
46+
47+
{% endmacro %}
48+
```
49+
3550
### Adapter support
3651

3752
This package is currently compatible with dbt's Snowflake, Redshift, and

dbt_project.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test-paths: ["tests"]
77
data-paths: ["data"]
88
macro-paths: ["macros"]
99

10-
require-dbt-version: ">=0.14.0"
10+
require-dbt-version: ">=0.16.0"
1111

1212
target-path: "target"
1313
clean-targets:

macros/audit.sql

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{% macro get_audit_schema() %}
22

3-
{{ return(target.schema~'_meta') }}
3+
{# if the get_audit_schema macro exists in the base project use that #}
4+
{% if context.get(project_name, {}).get('get_audit_schema') %}
5+
{{ return(context[project_name].get_audit_schema()) }}
6+
{% else %}
7+
{{ return(target.schema~'_meta') }}
8+
{% endif %}
49

510
{% endmacro %}
611

0 commit comments

Comments
 (0)