Created
January 14, 2023 20:01
-
-
Save drewbanin/a830a4694c9141adc7e6bfafe7818e63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ | |
config( | |
materialized='incremental', | |
unique_key='id', | |
indexes=[ | |
{'columns': ['id', 'name']}, | |
] | |
) | |
}} | |
select | |
1 as id, | |
'drew' as name, | |
getdate() as dt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- macros/index.sql | |
{% macro default__get_create_index_sql(relation, index_dict) -%} | |
{%- set index_config = adapter.parse_index(index_dict) -%} | |
{%- set comma_separated_columns = ", ".join(index_config.columns) -%} | |
{%- set index_name = index_config.render(relation) -%} | |
{%- do log('Creating an index on ' ~ relation ~ ' [' ~ comma_separated_columns ~ ']!', info=true) -%} | |
ALTER TABLE {{ relation }} | |
ADD CONSTRAINT "unique_{{ index_name }}" | |
UNIQUE ({{ comma_separated_columns }}); | |
{%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ | |
config( | |
materialized='table', | |
indexes=[ | |
{'columns': ['id', 'name']}, | |
] | |
) | |
}} | |
select | |
1 as id, | |
'drew' as name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment