From 7cae473c131907a1d52c623c73c592d88d5d6a2a Mon Sep 17 00:00:00 2001 From: Dan Flippo Date: Mon, 19 Aug 2024 16:20:01 -0400 Subject: [PATCH 1/5] Update to use attached_node for selected FK --- macros/create_constraints.sql | 40 +++++++---------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/macros/create_constraints.sql b/macros/create_constraints.sql index 2b029ce..3992840 100644 --- a/macros/create_constraints.sql +++ b/macros/create_constraints.sql @@ -174,10 +174,10 @@ {#- This macro checks if a test or its model is selected -#} {%- macro test_selected(test_model) -%} - {%- if test_model.unique_id in selected_resources -%} + {%- if test_model.unique_id and test_model.unique_id in selected_resources -%} {{ return("TEST_SELECTED") }} {%- endif -%} - {%- if lists_intersect(test_model.depends_on.nodes, selected_resources) -%} + {%- if test_model.attached_node and test_model.attached_node in selected_resources -%} -%} {{ return("MODEL_SELECTED") }} {%- endif -%} @@ -196,9 +196,9 @@ {%- for fk_model in graph.nodes.values() | selectattr("resource_type", "equalto", "test") if fk_model.test_metadata and fk_model.test_metadata.name in ("foreign_key", "relationships") - and lists_intersect(test_model.depends_on.nodes, fk_model.depends_on.nodes) - and ( fk_model.unique_id in selected_resources - or lists_intersect(fk_model.depends_on.nodes, selected_resources) ) -%} + and test_model.attached_node in fk_model.depends_on.nodes + and ( (fk_model.unique_id and fk_model.unique_id in selected_resources) + or (fk_model.attached_node and fk_model.attached_node in selected_resources) ) -%} {%- set fk_test_args = fk_model.test_metadata.kwargs -%} {%- set fk_test_columns = [] -%} {%- if fk_test_args.pk_column_names -%} @@ -362,24 +362,8 @@ {%- elif 2 == table_models|count and test_name in( "foreign_key", "relationships") -%} - {%- set fk_model = none -%} - {%- set pk_model = none -%} - {%- set fk_model_names = modules.re.findall( "(models|snapshots|seeds)\W+(\w+)" , test_model.file_key_name) -%} - {%- set fk_source_names = modules.re.findall( "source\W+(\w+)\W+(\w+)" , test_parameters.model) -%} - - {%- if 1 == fk_model_names | count -%} - {%- set fk_model = table_models | selectattr("name", "equalto", fk_model_names[0][1]) | first -%} - {%- set pk_model = table_models | rejectattr("name", "equalto", fk_model_names[0][1]) | first -%} - {%- elif 1 == fk_source_names | count -%} - {%- if table_models[0].source_name == fk_source_names[0][0] and table_models[0].name == fk_source_names[0][1] -%} - {%- set fk_model = table_models[0] -%} - {%- set pk_model = table_models[1] -%} - {%- else -%} - {%- set fk_model = table_models[1] -%} - {%- set pk_model = table_models[0] -%} - {%- endif -%} - {%- endif -%} - {# {%- set fk_model_name = test_model.file_key_name |replace("models.", "") -%} #} + {%- set fk_model = table_models | selectattr("unique_id", "equalto", test_model.attached_node) | first -%} + {%- set pk_model = table_models | rejectattr("unique_id", "equalto", test_model.attached_node) | first -%} {%- if fk_model and pk_model -%} @@ -428,7 +412,7 @@ {%- do dbt_constraints.create_foreign_key(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, ns.verify_permissions, quote_columns, test_parameters.constraint_name, lookup_cache, rely_clause) -%} {%- endif -%} {%- else -%} - {%- do log("Skipping foreign key because a we couldn't find the child table: model=" ~ fk_model_names ~ " or source=" ~ fk_source_names, info=true) -%} + {%- do log("Skipping foreign key because a we couldn't find the child table: model=" ~ test_model.attached_node ~ " or source", info=true) -%} {%- endif -%} {#- We only create NN if there is one model referenced by the test @@ -518,11 +502,3 @@ {{ return(false) }} {%- endif -%} {%- endmacro -%} - -{# This macro allows us to compare two lists to see if they intersect #} -{%- macro lists_intersect(listA, listB) -%} - {%- for valueFromA in listA if valueFromA in listB -%} - {{ return(true) }} - {% endfor %} - {{ return(false) }} -{%- endmacro -%} From 5b10fd00bfbf8075a1d94ffad24e33c0738867ce Mon Sep 17 00:00:00 2001 From: Dan Flippo Date: Mon, 19 Aug 2024 16:22:43 -0400 Subject: [PATCH 2/5] Increase minimum version of dbt. --- dbt_project.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dbt_project.yml b/dbt_project.yml index a32fb9f..9aff302 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -1,11 +1,12 @@ name: 'dbt_constraints' -version: '1.0.0' +version: '1.0.3' config-version: 2 # These macros depend on the results and graph objects in dbt >=0.19.0 # and has been tested with dbt >=1.0.0 -require-dbt-version: ">=1.0.0" +# v1.0.3 adds usage of the attached_node attribute added in dbt 1.5.x +require-dbt-version: ">=1.5.0" profile: 'dbt_constraints' From 4ab98210d4e4c41cbafc69d19c433ee59375eba7 Mon Sep 17 00:00:00 2001 From: Dan Flippo Date: Mon, 19 Aug 2024 16:27:20 -0400 Subject: [PATCH 3/5] Update documentation --- docs/catalog.json | 2 +- docs/graph_summary.json | 1 + docs/index.html | 55 ++++++++++--------------------------- docs/manifest.json | 2 +- docs/run_results.json | 2 +- docs/semantic_manifest.json | 1 + 6 files changed, 19 insertions(+), 44 deletions(-) create mode 100644 docs/graph_summary.json create mode 100644 docs/semantic_manifest.json diff --git a/docs/catalog.json b/docs/catalog.json index 369aeb3..b53b5f9 100644 --- a/docs/catalog.json +++ b/docs/catalog.json @@ -1 +1 @@ -{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/catalog/v1.json", "dbt_version": "1.3.2", "generated_at": "2023-01-20T04:30:03.174118Z", "invocation_id": "134cbac7-4598-4147-95e0-4a1ee1fd6018", "env": {}}, "nodes": {}, "sources": {}, "errors": null} \ No newline at end of file +{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/catalog/v1.json", "dbt_version": "1.8.5", "generated_at": "2024-08-19T18:34:12.783856Z", "invocation_id": "6248ccf8-48d0-470c-b010-2db8eb51c482", "env": {}}, "nodes": {}, "sources": {}, "errors": null} \ No newline at end of file diff --git a/docs/graph_summary.json b/docs/graph_summary.json new file mode 100644 index 0000000..426db29 --- /dev/null +++ b/docs/graph_summary.json @@ -0,0 +1 @@ +{"_invocation_id": "6248ccf8-48d0-470c-b010-2db8eb51c482", "linked": {"0": {"name": "operation.dbt_constraints.dbt_constraints-on-run-end-0", "type": "operation"}}} \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 65749e4..c580ce9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,30 +1,4 @@ - - - - - - - dbt Docs - - - - - - - - - - - - - - - - - -
icons
-
- - +e.exports=function(e){return null!=e&&(n(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}(e)||!!e._isBuffer)}},function(e,t,n){n(8).module("dbt").factory("locationService",["$state",function(e){var t={};return t.parseState=function(e){return function(e){return{selected:{include:e.g_i||"",exclude:e.g_e||""},show_graph:!!e.g_v}}(e)},t.setState=function(t){var n=function(e){var t={g_v:1};return t.g_i=e.include,t.g_e=e.exclude,t}(t),r=e.current.name;e.go(r,n)},t.clearState=function(){var t=e.current.name;e.go(t,{g_i:null,g_e:null,g_v:null})},t}])},function(e,t,n){"use strict";const r=n(8),i=n(202);r.module("dbt").controller("OverviewCtrl",["$scope","$state","project",function(e,t,n){e.overview_md="(loading)",n.ready((function(n){let r=t.params.project_name?t.params.project_name:null;var o=n.docs["doc.dbt.__overview__"],a=i.filter(n.docs,{name:"__overview__"});if(i.each(a,(function(e){"dbt"!=e.package_name&&(o=e)})),null!==r){o=n.docs[`doc.${r}.__${r}__`]||o;let e=i.filter(n.docs,{name:`__${r}__`});i.each(e,e=>{e.package_name!==r&&(o=e)})}e.overview_md=o.block_contents}))}])},function(e,t,n){"use strict";n(8).module("dbt").controller("SourceListCtrl",["$scope","$state","project",function(e,t,n){e.source=t.params.source,e.model={},e.extra_table_fields=[],e.has_more_info=function(e){return(e.description||"").length},e.toggle_source_expanded=function(t){e.has_more_info(t)&&(t.expanded=!t.expanded)},n.ready((function(t){var n=_.filter(t.nodes,(function(t){return t.source_name==e.source}));if(0!=n.length){n.sort((e,t)=>e.name.localeCompare(t.name));var r=n[0];e.model={name:e.source,source_description:r.source_description,sources:n};var i=_.uniq(_.map(n,"metadata.owner")),o=_.uniq(_.map(n,"database")),a=_.uniq(_.map(n,"schema"));e.extra_table_fields=[{name:"Loader",value:r.loader},{name:1==i.length?"Owner":"Owners",value:i.join(", ")},{name:1==o.length?"Database":"Databases",value:o.join(", ")},{name:1==a.length?"Schema":"Schemas",value:a.join(", ")},{name:"Tables",value:n.length}]}}))}])},function(e,t,n){const r=n(8),i={main:n(483),overview:n(484),graph:n(485),source:n(205),source_list:n(486),model:n(487),source:n(205),snapshot:n(488),seed:n(489),unit_test:n(490),test:n(491),analysis:n(492),macro:n(493),exposure:n(494),metric:n(495),semantic_model:n(496),saved_query:n(497),operation:n(498)};r.module("dbt").config(["$stateProvider","$urlRouterProvider",function(e,t){var n="g_v&g_i&g_e&g_p&g_n";t.otherwise("/overview"),e.state("dbt",{url:"/",abstract:!0,controller:"MainController",templateUrl:i.main}).state("dbt.overview",{url:"overview?"+n,controller:"OverviewCtrl",templateUrl:i.overview}).state("dbt.project_overview",{url:"overview/:project_name?"+n,controller:"OverviewCtrl",templateUrl:i.overview,params:{project_name:{type:"string"}}}).state("dbt.graph",{url:"graph",controller:"GraphCtrl",templateUrl:i.graph}).state("dbt.model",{url:"model/:unique_id?section&"+n,controller:"ModelCtrl",templateUrl:i.model,params:{unique_id:{type:"string"}}}).state("dbt.seed",{url:"seed/:unique_id?section&"+n,controller:"SeedCtrl",templateUrl:i.seed,params:{unique_id:{type:"string"}}}).state("dbt.snapshot",{url:"snapshot/:unique_id?section&"+n,controller:"SnapshotCtrl",templateUrl:i.snapshot,params:{unique_id:{type:"string"}}}).state("dbt.unit_test",{url:"unit_test/:unique_id?section&"+n,controller:"TestCtrl",templateUrl:i.unit_test,params:{unique_id:{type:"string"}}}).state("dbt.test",{url:"test/:unique_id?section&"+n,controller:"TestCtrl",templateUrl:i.test,params:{unique_id:{type:"string"}}}).state("dbt.analysis",{url:"analysis/:unique_id?section&"+n,controller:"AnalysisCtrl",templateUrl:i.analysis,params:{unique_id:{type:"string"}}}).state("dbt.source",{url:"source/:unique_id?section&"+n,controller:"SourceCtrl",templateUrl:i.source,params:{unique_id:{type:"string"}}}).state("dbt.source_list",{url:"source_list/:source?section&"+n,controller:"SourceListCtrl",templateUrl:i.source_list,params:{source:{type:"string"}}}).state("dbt.macro",{url:"macro/:unique_id?section",controller:"MacroCtrl",templateUrl:i.macro,params:{unique_id:{type:"string"}}}).state("dbt.exposure",{url:"exposure/:unique_id?section&"+n,controller:"ExposureCtrl",templateUrl:i.exposure,params:{unique_id:{type:"string"}}}).state("dbt.metric",{url:"metric/:unique_id?section&"+n,controller:"MetricCtrl",templateUrl:i.metric,params:{unique_id:{type:"string"}}}).state("dbt.semantic_model",{url:"semantic_model/:unique_id?section&"+n,controller:"SemanticModelCtrl",templateUrl:i.semantic_model,params:{unique_id:{type:"string"}}}).state("dbt.saved_query",{url:"saved_query/:unique_id?section&"+n,controller:"SavedQueryCtrl",templateUrl:i.saved_query,params:{unique_id:{type:"string"}}}).state("dbt.operation",{url:"operation/:unique_id?section&"+n,controller:"OperationCtrl",templateUrl:i.operation,params:{unique_id:{type:"string"}}})}])},function(e,t){var n="/main/main.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'\n\n
\n \n\n
\n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n \n
\n
\n
\n
\n')}]),e.exports=n},function(e,t){var n="/overview/overview.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'
\n \n
\n
\n

\n
\n
\n
\n\n')}]),e.exports=n},function(e,t){var n="/graph/graph.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'
\n
\n
\n
\n
\n
\n
\n')}]),e.exports=n},function(e,t){var n="/sources/source_list.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'\n\n
\n \n
\n
\n
\n
\n \n
\n\n
\n
\n
\n
Description
\n
\n
\n
\n
This {{ model.resource_type }} is not currently documented
\n
\n
\n
\n
\n\n\n
\n
\n
\n
Source Tables
\n
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
SourceTableDescriptionLinkMore?
\n
\n {{ source.source_name }}\n
\n
\n {{ source.name }}

\n
\n {{ source.description }}\n \n View docs\n \n \n \n \n \n \n \n \n \n
\n
\n
\n
Description
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n')}]),e.exports=n},function(e,t){var n="/docs/model.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'\n\n
\n \n
\n
\n
\n
\n \n
\n\n
\n
\n
\n
Description
\n
\n
\n
\n
This {{ model.resource_type }} is not currently documented
\n
\n
\n
\n
\n\n
\n
\n
\n
Columns
\n \n
\n
\n\n
\n
\n
\n
Referenced By
\n \n
\n
\n\n
\n
\n
\n
Depends On
\n \n
\n
\n\n
\n
\n
\n \n
\n
\n
\n
\n
\n')}]),e.exports=n},function(e,t){var n="/docs/snapshot.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'\n\n
\n \n
\n
\n
\n
\n \n
\n\n
\n
\n
\n
Description
\n
\n
\n
\n
This {{ model.resource_type }} is not currently documented
\n
\n
\n
\n
\n\n
\n
\n
\n
Columns
\n \n
\n
\n\n
\n
\n
\n
Referenced By
\n \n
\n
\n\n
\n
\n
\n
Depends On
\n \n
\n
\n\n
\n
\n
\n \n
\n
\n
\n
\n
\n')}]),e.exports=n},function(e,t){var n="/docs/seed.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'\n\n
\n \n
\n
\n
\n
\n \n
\n\n
\n
\n
\n
Description
\n
\n
\n
\n
This {{ model.resource_type }} is not currently documented
\n
\n
\n
\n
\n
\n
\n
\n
Columns
\n \n
\n
\n\n
\n
\n
\n
Referenced By
\n \n
\n
\n\n
\n
\n
\n
Depends On
\n \n
\n
\n\n
\n
\n
\n \n
\n
\n
\n
\n
\n')}]),e.exports=n},function(e,t){var n="/docs/unit_test.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'\n\n
\n \n
\n
\n
\n
\n
\n
Description
\n
\n
\n
\n
This {{ model.resource_type }} is not currently documented
\n
\n
\n
\n
\n\n
\n
\n
\n
Depends On
\n \n
\n
\n\n
\n
\n
\n')}]),e.exports=n},function(e,t){var n="/docs/test.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'\n\n
\n \n
\n
\n
\n
\n
\n
Description
\n
\n
\n
\n
This {{ model.resource_type }} is not currently documented
\n
\n
\n
\n
\n\n
\n
\n
\n
Depends On
\n \n
\n
\n\n
\n
\n
\n \n
\n
\n
\n
\n
\n')}]),e.exports=n},function(e,t){var n="/docs/analysis.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'\n\n
\n \n
\n
\n\n
\n
\n
\n
Description
\n
\n
\n
\n
This {{ model.resource_type }} is not currently documented
\n
\n
\n
\n
\n\n
\n
\n
\n
Depends On
\n \n
\n
\n\n
\n
\n
\n \n
\n
\n
\n
\n
\n')}]),e.exports=n},function(e,t){var n="/docs/macro.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'\n\n
\n \n
\n
\n
\n
\n
\n
Description
\n
\n
\n
\n
This {{ macro.resource_type }} is not currently documented
\n
\n
\n
\n
\n\n
\n
\n
\n
Arguments
\n \n
\n
\n\n
\n
\n
\n
Referenced By
\n \n
\n
\n\n
\n
\n
\n
Depends On
\n \n
\n
\n\n
\n
\n
\n \n
\n
\n
\n
\n
\n')}]),e.exports=n},function(e,t){var n="/docs/exposure.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'\n\n
\n \n
\n
\n\n
\n
\n \n
\n\n
\n
\n
\n
Description
\n
\n
\n
\n
This {{ exposure.resource_type }} is not currently documented
\n
\n
\n
\n
\n\n
\n
\n
\n
Depends On
\n \n
\n
\n\n
\n
\n
\n')}]),e.exports=n},function(e,t){var n="/docs/metric.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'\n\n
\n \n
\n
\n\n
\n
\n \n
\n\n
\n
\n
\n
Description
\n
\n
\n
\n
This {{ metric.resource_type }} is not currently documented
\n
\n
\n
\n
\n\n
\n
\n
\n
Depends On
\n \n
\n
\n\n
\n
\n
\n')}]),e.exports=n},function(e,t){var n="/docs/semantic_model.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'\n\n
\n \n
\n
\n\n
\n
\n \n
\n\n
\n
\n
\n
Description
\n
\n
\n
\n
This {{ semantic_model.resource_type }} is not currently documented
\n
\n
\n
\n
\n\n
\n
\n
\n
Entities
\n\n
\n
\n
\n
\n
Name
\n
{{ entity.name }}
\n
None
\n
Type
\n
{{ entity.type }}
\n
None
\n
Expression
\n
{{ entity.expr }}
\n
None
\n
\n
\n
\n
\n
\n
\n\n
\n
\n
\n
Depends On
\n \n
\n
\n\n
\n
\n
\n')}]),e.exports=n},function(e,t){var n="/docs/saved_query.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'\n\n
\n \n
\n
\n\n
\n
\n \n
\n\n
\n
\n
\n
Description
\n
\n
\n
\n
This {{ saved_query.resource_type }} is not currently documented
\n
\n
\n
\n
\n\n
\n
\n
\n
Entities
\n\n
\n
\n
\n
\n
Name
\n
{{ entity.name }}
\n
None
\n
Type
\n
{{ entity.type }}
\n
None
\n
Expression
\n
{{ entity.expr }}
\n
None
\n
\n
\n
\n
\n
\n
\n\n
\n
\n
\n
Depends On
\n \n
\n
\n\n
\n
\n
')}]),e.exports=n},function(e,t){var n="/docs/operation.html";window.angular.module("ng").run(["$templateCache",function(e){e.put(n,'\n\n
\n \n
\n
\n
\n
\n
\n
Description
\n
\n
\n
\n
This {{ model.resource_type }} is not currently documented
\n
\n
\n
\n
\n\n
\n
\n
\n
Depends On
\n \n
\n
\n\n
\n
\n
\n \n
\n
\n
\n
\n
\n')}]),e.exports=n}]); +//# sourceMappingURL=main.js.map diff --git a/docs/manifest.json b/docs/manifest.json index 664a3f4..6ed685d 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -1 +1 @@ -{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/manifest/v7.json", "dbt_version": "1.3.2", "generated_at": "2023-01-20T04:30:03.084817Z", "invocation_id": "134cbac7-4598-4147-95e0-4a1ee1fd6018", "env": {}, "project_id": "6511921c8841bf2635d77c9c99850470", "user_id": "163b30ee-8119-4b7c-839b-96ee37254ff3", "send_anonymous_usage_stats": true, "adapter_type": "snowflake"}, "nodes": {"operation.dbt_constraints.dbt_constraints-on-run-end-0": {"compiled": true, "resource_type": "operation", "depends_on": {"macros": ["macro.dbt_constraints.create_constraints"], "nodes": []}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "post-hook": [], "pre-hook": []}, "database": "DFLIPPO_DEV", "schema": "DBT_DEMO", "fqn": ["dbt_constraints", "hooks", "dbt_constraints-on-run-end-0"], "unique_id": "operation.dbt_constraints.dbt_constraints-on-run-end-0", "raw_code": "{{ dbt_constraints.create_constraints() }}", "language": "sql", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "hooks/dbt_constraints-on-run-end-0.sql", "original_file_path": "./dbt_project.yml", "name": "dbt_constraints-on-run-end-0", "alias": "dbt_constraints-on-run-end-0", "checksum": {"name": "sha256", "checksum": "322fdaf41d183a13b7417bf8f47935d83bfdf07242073cf29b8c8789010746fb"}, "tags": ["on-run-end"], "refs": [], "sources": [], "metrics": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "compiled_path": null, "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1674188998.243506, "compiled_code": "", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "index": 0}}, "sources": {}, "macros": {"macro.dbt_constraints.postgres__create_primary_key": {"unique_id": "macro.dbt_constraints.postgres__create_primary_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "name": "postgres__create_primary_key", "macro_sql": "\n{%- macro postgres__create_primary_key(table_relation, column_names, verify_permissions, quote_columns=false, constraint_name=none, lookup_cache=none) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_PK\") | upper -%}\n\n {%- if constraint_name|length > 63 %}\n {%- set constraint_name_query %}\n select 'PK_' || md5( '{{ constraint_name }}' )::varchar as \"constraint_name\"\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- do log(\"Creating primary key: \" ~ constraint_name, info=true) -%}\n {%- call statement('add_pk', fetch_result=False, auto_begin=True) -%}\n ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} PRIMARY KEY ( {{columns_csv}} )\n {%- endcall -%}\n {{ adapter.commit() }}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=false) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.438806, "supported_languages": null}, "macro.dbt_constraints.postgres__create_unique_key": {"unique_id": "macro.dbt_constraints.postgres__create_unique_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "name": "postgres__create_unique_key", "macro_sql": "\n{%- macro postgres__create_unique_key(table_relation, column_names, verify_permissions, quote_columns=false, constraint_name=none, lookup_cache=none) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_UK\") | upper -%}\n\n {%- if constraint_name|length > 63 %}\n {%- set constraint_name_query %}\n select 'UK_' || md5( '{{ constraint_name }}' )::varchar as \"constraint_name\"\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- do log(\"Creating unique key: \" ~ constraint_name, info=true) -%}\n {%- call statement('add_uk', fetch_result=False, auto_begin=True) -%}\n ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} UNIQUE ( {{columns_csv}} )\n {%- endcall -%}\n {{ adapter.commit() }}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=false) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.441967, "supported_languages": null}, "macro.dbt_constraints.postgres__create_not_null": {"unique_id": "macro.dbt_constraints.postgres__create_not_null", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "name": "postgres__create_not_null", "macro_sql": "\n{%- macro postgres__create_not_null(table_relation, column_names, verify_permissions, quote_columns=false, lookup_cache=none) -%}\n {%- set columns_list = dbt_constraints.get_quoted_column_list(column_names, quote_columns) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set modify_statements= [] -%}\n {%- for column in columns_list -%}\n {%- set modify_statements = modify_statements.append( \"ALTER COLUMN \" ~ column ~ \" SET NOT NULL\" ) -%}\n {%- endfor -%}\n {%- set modify_statement_csv = modify_statements | join(\", \") -%}\n {%- do log(\"Creating not null constraint for: \" ~ columns_list | join(\", \") ~ \" in \" ~ table_relation, info=true) -%}\n {%- call statement('add_nn', fetch_result=False, auto_begin=True) -%}\n ALTER TABLE {{table_relation}} {{ modify_statement_csv }};\n {%- endcall -%}\n {{ adapter.commit() }}\n\n {%- else -%}\n {%- do log(\"Skipping not null constraint for \" ~ columns_list | join(\", \") ~ \" in \" ~ table_relation ~ \" because of insufficient privileges: \" ~ table_relation, info=true) -%}\n {%- endif -%}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_list", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.444303, "supported_languages": null}, "macro.dbt_constraints.postgres__create_foreign_key": {"unique_id": "macro.dbt_constraints.postgres__create_foreign_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "name": "postgres__create_foreign_key", "macro_sql": "\n{%- macro postgres__create_foreign_key(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, verify_permissions, quote_columns=true, constraint_name=none, lookup_cache=none) -%}\n {%- set constraint_name = (constraint_name or fk_table_relation.identifier ~ \"_\" ~ fk_column_names|join('_') ~ \"_FK\") | upper -%}\n\n {%- if constraint_name|length > 63 %}\n {%- set constraint_name_query %}\n select 'FK_' || md5( '{{ constraint_name }}' )::varchar as \"constraint_name\"\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set fk_columns_csv = dbt_constraints.get_quoted_column_csv(fk_column_names, quote_columns) -%}\n {%- set pk_columns_csv = dbt_constraints.get_quoted_column_csv(pk_column_names, quote_columns) -%}\n {#- Check that the PK table has a PK or UK -#}\n {%- if dbt_constraints.unique_constraint_exists(pk_table_relation, pk_column_names, lookup_cache) -%}\n {#- Check if the table already has this foreign key -#}\n {%- if not dbt_constraints.foreign_key_exists(fk_table_relation, fk_column_names) -%}\n\n {%- if dbt_constraints.have_ownership_priv(fk_table_relation, verify_permissions, lookup_cache) and dbt_constraints.have_references_priv(pk_table_relation, verify_permissions, lookup_cache) -%}\n\n {%- do log(\"Creating foreign key: \" ~ constraint_name ~ \" referencing \" ~ pk_table_relation.identifier ~ \" \" ~ pk_column_names, info=true) -%}\n {%- call statement('add_fk', fetch_result=False, auto_begin=True) -%}\n ALTER TABLE {{fk_table_relation}} ADD CONSTRAINT {{constraint_name}} FOREIGN KEY ( {{fk_columns_csv}} ) REFERENCES {{pk_table_relation}} ( {{pk_columns_csv}} ) ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED\n {%- endcall -%}\n {{ adapter.commit() }}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ fk_table_relation ~ \" referencing \" ~ pk_table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because FK already exists: \" ~ fk_table_relation ~ \" \" ~ fk_column_names, info=false) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because a PK/UK was not found on the PK table: \" ~ pk_table_relation ~ \" \" ~ pk_column_names, info=true) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.foreign_key_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt_constraints.have_references_priv", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.4483972, "supported_languages": null}, "macro.dbt_constraints.postgres__unique_constraint_exists": {"unique_id": "macro.dbt_constraints.postgres__unique_constraint_exists", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "name": "postgres__unique_constraint_exists", "macro_sql": "\n{%- macro postgres__unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n {%- set lookup_query -%}\n select c.oid as constraint_name\n , upper(col.attname) as column_name\n from pg_constraint c\n cross join lateral unnest(c.conkey) as con(conkey)\n join pg_class tbl on tbl.oid = c.conrelid\n join pg_namespace ns on ns.oid = tbl.relnamespace\n join pg_attribute col on (col.attrelid = tbl.oid\n and col.attnum = con.conkey)\n where c.contype in ('p', 'u')\n and ns.nspname ilike '{{table_relation.schema}}'\n and tbl.relname ilike '{{table_relation.identifier}}'\n order by constraint_name\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"column_name\"].values(), column_names ) -%}\n {%- do log(\"Found PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}#}\n\n {#- If we get this far then the table does not have either constraint -#}\n {%- do log(\"No PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.column_list_matches"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.4505038, "supported_languages": null}, "macro.dbt_constraints.postgres__foreign_key_exists": {"unique_id": "macro.dbt_constraints.postgres__foreign_key_exists", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "name": "postgres__foreign_key_exists", "macro_sql": "\n{%- macro postgres__foreign_key_exists(table_relation, column_names, lookup_cache) -%}\n {%- set lookup_query -%}\n select c.oid as fk_name\n , upper(col.attname) as fk_column_name\n from pg_constraint c\n cross join lateral unnest(c.conkey) as con(conkey)\n join pg_class tbl on tbl.oid = c.conrelid\n join pg_namespace ns on ns.oid = tbl.relnamespace\n join pg_attribute col on (col.attrelid = tbl.oid\n and col.attnum = con.conkey)\n where c.contype in ('f')\n and ns.nspname ilike '{{table_relation.schema}}'\n and tbl.relname ilike '{{table_relation.identifier}}'\n order by fk_name\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"fk_column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"fk_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"fk_column_name\"].values(), column_names ) -%}\n {%- do log(\"Found FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {#- If we get this far then the table does not have this constraint -#}\n {%- do log(\"No FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.column_list_matches"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.452539, "supported_languages": null}, "macro.dbt_constraints.postgres__have_references_priv": {"unique_id": "macro.dbt_constraints.postgres__have_references_priv", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "name": "postgres__have_references_priv", "macro_sql": "{%- macro postgres__have_references_priv(table_relation, verify_permissions, lookup_cache) -%}\n {%- if verify_permissions is sameas true -%}\n\n {%- set lookup_query -%}\n select case when count(*) > 0 then 'y' else 'n' end as \"have_references\"\n from information_schema.table_privileges t\n join information_schema.enabled_roles er on t.grantee = er.role_name\n where upper(t.table_schema) = upper('{{table_relation.schema}}')\n and upper(t.table_name) = upper('{{table_relation.identifier}}')\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set results = run_query(lookup_query) -%}\n {%- if \"y\" in( results.columns[\"have_references\"].values() ) -%}\n {{ return(true) }}\n {%- endif -%}\n\n {{ return(false) }}\n {%- else -%}\n {{ return(true) }}\n {%- endif -%}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.4539719, "supported_languages": null}, "macro.dbt_constraints.postgres__have_ownership_priv": {"unique_id": "macro.dbt_constraints.postgres__have_ownership_priv", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "name": "postgres__have_ownership_priv", "macro_sql": "{%- macro postgres__have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n {%- if verify_permissions is sameas true -%}\n\n {%- set lookup_query -%}\n select case when count(*) > 0 then 'y' else 'n' end as \"have_ownership\"\n from pg_catalog.pg_tables t\n join information_schema.enabled_roles er on t.tableowner = er.role_name\n where upper(t.schemaname) = upper('{{table_relation.schema}}')\n and upper(t.tablename) = upper('{{table_relation.identifier}}')\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set results = run_query(lookup_query) -%}\n {%- if \"y\" in( results.columns[\"have_ownership\"].values() ) -%}\n {{ return(true) }}\n {%- endif -%}\n\n {{ return(false) }}\n {%- else -%}\n {{ return(true) }}\n {%- endif -%}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.4553769, "supported_languages": null}, "macro.dbt_constraints.postgres__drop_referential_constraints": {"unique_id": "macro.dbt_constraints.postgres__drop_referential_constraints", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "name": "postgres__drop_referential_constraints", "macro_sql": "{% macro postgres__drop_referential_constraints(relation) -%}\n {%- set lookup_query -%}\n select constraint_name\n from information_schema.table_constraints\n where table_schema = '{{relation.schema}}'\n and table_name='{{relation.identifier}}'\n and constraint_type in ('FOREIGN KEY', 'PRIMARY KEY', 'UNIQUE')\n {%- endset -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n\n {%- for constraint_name in constraint_list.columns[\"constraint_name\"].values() -%}\n {%- do log(\"Dropping constraint: \" ~ constraint_name ~ \" from table \" ~ relation, info=false) -%}\n {%- call statement('drop_constraint_cascade', fetch_result=False, auto_begin=True) -%}\n ALTER TABLE {{relation}} DROP CONSTRAINT IF EXISTS \"{{constraint_name}}\" CASCADE\n {%- endcall -%}\n {{ adapter.commit() }}\n {% endfor %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.456746, "supported_languages": null}, "macro.dbt_constraints.postgres__truncate_relation": {"unique_id": "macro.dbt_constraints.postgres__truncate_relation", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "name": "postgres__truncate_relation", "macro_sql": "{% macro postgres__truncate_relation(relation) -%}\n {{ postgres__drop_referential_constraints(relation) }}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.postgres__drop_referential_constraints", "macro.dbt_constraints.truncate_relation", "macro.dbt_snowflake.snowflake__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.457279, "supported_languages": null}, "macro.dbt_constraints.postgres__drop_relation": {"unique_id": "macro.dbt_constraints.postgres__drop_relation", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "name": "postgres__drop_relation", "macro_sql": "{% macro postgres__drop_relation(relation) -%}\n {{ postgres__drop_referential_constraints(relation) }}\n {{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.postgres__drop_referential_constraints", "macro.dbt_constraints.drop_relation", "macro.dbt.default__drop_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.4577842, "supported_languages": null}, "macro.dbt_constraints.default__test_primary_key": {"unique_id": "macro.dbt_constraints.default__test_primary_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/default__test_constraints.sql", "original_file_path": "macros/default__test_constraints.sql", "name": "default__test_primary_key", "macro_sql": "\n{%- macro default__test_primary_key(model, column_names, quote_columns=false) -%}\n{#\nNOTE: This test is designed to implement the \"primary key\" as specified in ANSI SQL 92 which states the following:\n \"A unique constraint is satisfied if and only if no two rows in\n a table have the same non-null values in the unique columns. In\n addition, if the unique constraint was defined with PRIMARY KEY,\n then it requires that none of the values in the specified column or\n columns be the null value.\"\n#}\n\n{%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) %}\n\n{#- This test will return for any duplicates and if any of the key columns is null -#}\nwith validation_errors as (\n select\n {{columns_csv}}, count(*) as row_count\n from {{model}}\n group by {{columns_csv}}\n having count(*) > 1\n {% for column in column_names -%}\n or {{column}} is null\n {% endfor %}\n)\n\nselect *\nfrom validation_errors\n\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.460435, "supported_languages": null}, "macro.dbt_constraints.default__test_unique_key": {"unique_id": "macro.dbt_constraints.default__test_unique_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/default__test_constraints.sql", "original_file_path": "macros/default__test_constraints.sql", "name": "default__test_unique_key", "macro_sql": "\n{%- macro default__test_unique_key(model, column_names, quote_columns=false) -%}\n{#\nNOTE: This test is designed to implement the \"unique constraint\" as specified in ANSI SQL 92 which states the following:\n \"A unique constraint is satisfied if and only if no two rows in\n a table have the same non-null values in the unique columns.\"\n#}\n\n{%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) %}\n\n{#- This test will return any duplicates -#}\nwith validation_errors as (\n select\n {{columns_csv}}\n from {{model}}\n group by {{columns_csv}}\n having count(*) > 1\n)\n\nselect *\nfrom validation_errors\n\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.46104, "supported_languages": null}, "macro.dbt_constraints.default__test_foreign_key": {"unique_id": "macro.dbt_constraints.default__test_foreign_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/default__test_constraints.sql", "original_file_path": "macros/default__test_constraints.sql", "name": "default__test_foreign_key", "macro_sql": "\n{%- macro default__test_foreign_key(model, fk_column_names, pk_table_name, pk_column_names, quote_columns=false) -%}\n{#\nNOTE: This test is designed to implement the \"referential constraint\" as specified in ANSI SQL 92 which states the following:\n \"A referential constraint is satisfied if one of the following con-\n ditions is true, depending on the specified in the\n :\n\n - If no was specified then, for each row R1 of the\n referencing table, either at least one of the values of the\n referencing columns in R1 shall be a null value, or the value of\n each referencing column in R1 shall be equal to the value of the\n corresponding referenced column in some row of the referenced\n table.\"\n\nThe implications of this standard is that if one column is NULL in a compound foreign key, the other column\ndoes NOT need to match a row in a referenced unique key. This is implemented by first excluding any\nrows from the test that have a NULL value in any of the columns.\n#}\n\n{%- set fk_columns_list=dbt_constraints.get_quoted_column_list(fk_column_names, quote_columns) %}\n{%- set pk_columns_list=dbt_constraints.get_quoted_column_list(pk_column_names, quote_columns) %}\n{%- set fk_columns_csv=dbt_constraints.get_quoted_column_csv(fk_column_names, quote_columns) %}\n{%- set pk_columns_csv=dbt_constraints.get_quoted_column_csv(pk_column_names, quote_columns) %}\n{%- set join_conditions = [] -%}\n{%- for x in range(fk_columns_list|count) -%}\n {%- set join_conditions = join_conditions.append( 'parent.' ~ pk_columns_list[x] ~ ' = child.' ~ fk_columns_list[x] ) -%}\n{%- endfor -%}\n\n{#- This test will return if all the columns are not null\n and the values are not found in the referenced PK table #}\nwith child as (\n select\n {{fk_columns_csv}}\n from {{model}}\n where 1=1\n {% for column in fk_columns_list -%}\n and {{column}} is not null\n {% endfor %}\n),\n\nparent as (\n select\n {{pk_columns_csv}}\n from {{pk_table_name}}\n),\n\nvalidation_errors as (\n select\n child.*\n from child\n left join parent\n on {{join_conditions | join(' and ')}}\n\n where parent.{{pk_columns_list | first}} is null\n)\n\nselect *\nfrom validation_errors\n\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_list", "macro.dbt_constraints.get_quoted_column_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.4629729, "supported_languages": null}, "macro.dbt_constraints.get_quoted_column_list": {"unique_id": "macro.dbt_constraints.get_quoted_column_list", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/default__test_constraints.sql", "original_file_path": "macros/default__test_constraints.sql", "name": "get_quoted_column_list", "macro_sql": "{%- macro get_quoted_column_list(column_array, quote_columns=false) -%}\n\n {%- if not quote_columns -%}\n {%- set column_list=column_array -%}\n {%- elif quote_columns -%}\n {%- set column_list=[] -%}\n {%- for column in column_array -%}\n {%- set column_list = column_list.append( adapter.quote(column) ) -%}\n {%- endfor -%}\n {%- else -%}\n {{ exceptions.raise_compiler_error(\n \"`quote_columns` argument must be one of [True, False] Got: '\" ~ quote ~\"'.'\"\n ) }}\n {%- endif -%}\n\n {{ return(column_list) }}\n\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.463984, "supported_languages": null}, "macro.dbt_constraints.get_quoted_column_csv": {"unique_id": "macro.dbt_constraints.get_quoted_column_csv", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/default__test_constraints.sql", "original_file_path": "macros/default__test_constraints.sql", "name": "get_quoted_column_csv", "macro_sql": "{%- macro get_quoted_column_csv(column_array, quote_columns=false) -%}\n\n {%- set column_list = dbt_constraints.get_quoted_column_list(column_array, quote_columns) -%}\n {%- set columns_csv=column_list | join(', ') -%}\n {{ return(columns_csv) }}\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_list"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.4645498, "supported_languages": null}, "macro.dbt_constraints.test_primary_key": {"unique_id": "macro.dbt_constraints.test_primary_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "test_primary_key", "macro_sql": "\n\n{%- test primary_key(model,\n column_name=none, column_names=[],\n quote_columns=false, constraint_name=none) -%}\n\n {%- if column_names|count == 0 and column_name -%}\n {%- do column_names.append(column_name) -%}\n {%- endif -%}\n\n {{ return(adapter.dispatch('test_primary_key', 'dbt_constraints')(model, column_names, quote_columns)) }}\n\n{%- endtest -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.default__test_primary_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.4739041, "supported_languages": null}, "macro.dbt_constraints.test_unique_key": {"unique_id": "macro.dbt_constraints.test_unique_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "test_unique_key", "macro_sql": "{%- test unique_key(model,\n column_name=none, column_names=[],\n quote_columns=false, constraint_name=none) -%}\n\n {%- if column_names|count == 0 and column_name -%}\n {%- do column_names.append(column_name) -%}\n {%- endif -%}\n\n {{ return(adapter.dispatch('test_unique_key', 'dbt_constraints')(model, column_names, quote_columns)) }}\n\n{%- endtest -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.default__test_unique_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.4749691, "supported_languages": null}, "macro.dbt_constraints.test_foreign_key": {"unique_id": "macro.dbt_constraints.test_foreign_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "test_foreign_key", "macro_sql": "{%- test foreign_key(model,\n column_name=none, fk_column_name=none, fk_column_names=[],\n pk_table_name=none, to=none,\n pk_column_name=none, pk_column_names=[], field=none,\n quote_columns=false, constraint_name=none) -%}\n\n {%- if pk_column_names|count == 0 and (pk_column_name or field) -%}\n {%- do pk_column_names.append( (pk_column_name or field) ) -%}\n {%- endif -%}\n {%- if fk_column_names|count == 0 and (fk_column_name or column_name) -%}\n {%- do fk_column_names.append( (fk_column_name or column_name) ) -%}\n {%- endif -%}\n {%- set pk_table_name = pk_table_name or to -%}\n\n {{ return(adapter.dispatch('test_foreign_key', 'dbt_constraints')(model, fk_column_names, pk_table_name, pk_column_names, quote_columns)) }}\n\n{%- endtest -%}\n\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.default__test_foreign_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.4769511, "supported_languages": null}, "macro.dbt_constraints.create_primary_key": {"unique_id": "macro.dbt_constraints.create_primary_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "create_primary_key", "macro_sql": "\n\n{%- macro create_primary_key(table_model, column_names, verify_permissions, quote_columns=false, constraint_name=none, lookup_cache=none) -%}\n {{ return(adapter.dispatch('create_primary_key', 'dbt_constraints')(table_model, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache)) }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.snowflake__create_primary_key"]}, "description": "Calls the adapter-specific version of the macro to create a primary key", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": "dbt_constraints://macros/macros.yml", "arguments": [{"name": "table_model", "type": "graph node", "description": "Accepts the graph node of the table that will have the constraint"}, {"name": "column_names", "type": "array of column names", "description": "An array of text column names to include in the constraint"}, {"name": "quote_columns", "type": "boolean", "description": "Whether to wrap column names in double quotes. By default this is set to false."}, {"name": "constraint_name", "type": "string", "description": "Name of the constraint. If not specified, a constraint name will be generated."}], "created_at": 1674188998.3491251, "supported_languages": null}, "macro.dbt_constraints.create_unique_key": {"unique_id": "macro.dbt_constraints.create_unique_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "create_unique_key", "macro_sql": "{%- macro create_unique_key(table_model, column_names, verify_permissions, quote_columns=false, constraint_name=none, lookup_cache=none) -%}\n {{ return(adapter.dispatch('create_unique_key', 'dbt_constraints')(table_model, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache)) }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.snowflake__create_unique_key"]}, "description": "Calls the adapter-specific version of the macro to create a unique key", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": "dbt_constraints://macros/macros.yml", "arguments": [{"name": "table_model", "type": "graph node", "description": "Accepts the graph node of the table that will have the constraint"}, {"name": "column_names", "type": "array of column names", "description": "An array of text column names to include in the constraint"}, {"name": "quote_columns", "type": "boolean", "description": "Whether to wrap column names in double quotes. By default this is set to false."}, {"name": "constraint_name", "type": "string", "description": "Name of the constraint. If not specified, a constraint name will be generated."}], "created_at": 1674188998.352628, "supported_languages": null}, "macro.dbt_constraints.create_foreign_key": {"unique_id": "macro.dbt_constraints.create_foreign_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "create_foreign_key", "macro_sql": "{%- macro create_foreign_key(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, verify_permissions, quote_columns, constraint_name, lookup_cache) -%}\n {{ return(adapter.dispatch('create_foreign_key', 'dbt_constraints')(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, verify_permissions, quote_columns, constraint_name, lookup_cache)) }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.snowflake__create_foreign_key"]}, "description": "Calls the adapter-specific version of the macro to create a foreign key", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": "dbt_constraints://macros/macros.yml", "arguments": [{"name": "test_model", "type": "results node", "description": "Accepts the result node of the test related to this constraint"}, {"name": "pk_model", "type": "graph node", "description": "Accepts the graph node of the parent table that has a PK or UK"}, {"name": "column_names", "type": "array of column names", "description": "An array of text column names to include in the FK reference"}, {"name": "fk_model", "type": "graph node", "description": "Accepts the graph node of the table that will have the constraint"}, {"name": "fk_column_names", "type": "array of column names", "description": "An array of text column names to include in the constraint"}, {"name": "quote_columns", "type": "boolean", "description": "Whether to wrap column names in double quotes. By default this is set to false."}, {"name": "constraint_name", "type": "string", "description": "Name of the constraint. If not specified, a constraint name will be generated."}], "created_at": 1674188998.3584409, "supported_languages": null}, "macro.dbt_constraints.create_not_null": {"unique_id": "macro.dbt_constraints.create_not_null", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "create_not_null", "macro_sql": "{%- macro create_not_null(table_relation, column_names, verify_permissions, quote_columns, lookup_cache) -%}\n {{ return(adapter.dispatch('create_not_null', 'dbt_constraints')(table_relation, column_names, verify_permissions, quote_columns, lookup_cache)) }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.snowflake__create_not_null"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.4805892, "supported_languages": null}, "macro.dbt_constraints.unique_constraint_exists": {"unique_id": "macro.dbt_constraints.unique_constraint_exists", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "unique_constraint_exists", "macro_sql": "\n\n{%- macro unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n {{ return(adapter.dispatch('unique_constraint_exists', 'dbt_constraints')(table_relation, column_names, lookup_cache) ) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.snowflake__unique_constraint_exists"]}, "description": "Calls the adapter-specific version of the macro to check if a PK or UK already exists", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": "dbt_constraints://macros/macros.yml", "arguments": [{"name": "table_relation", "type": "relation", "description": "Accepts the relation of the table to check"}, {"name": "column_names", "type": "array of column names", "description": "An array of text column names the constraint must contain"}], "created_at": 1674188998.360521, "supported_languages": null}, "macro.dbt_constraints.foreign_key_exists": {"unique_id": "macro.dbt_constraints.foreign_key_exists", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "foreign_key_exists", "macro_sql": "{%- macro foreign_key_exists(table_relation, column_names, lookup_cache) -%}\n {{ return(adapter.dispatch('foreign_key_exists', 'dbt_constraints')(table_relation, column_names, lookup_cache)) }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.snowflake__foreign_key_exists"]}, "description": "Calls the adapter-specific version of the macro to check if a foreign key already exists", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": "dbt_constraints://macros/macros.yml", "arguments": [{"name": "table_relation", "type": "relation", "description": "Accepts the relation of the table to check"}, {"name": "column_names", "type": "array of column names", "description": "An array of text column names the constraint must contain"}], "created_at": 1674188998.362603, "supported_languages": null}, "macro.dbt_constraints.have_references_priv": {"unique_id": "macro.dbt_constraints.have_references_priv", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "have_references_priv", "macro_sql": "\n\n{%- macro have_references_priv(table_relation, verify_permissions, lookup_cache) -%}\n {{ return(adapter.dispatch('have_references_priv', 'dbt_constraints')(table_relation, verify_permissions, lookup_cache) ) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.snowflake__have_references_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.4828439, "supported_languages": null}, "macro.dbt_constraints.have_ownership_priv": {"unique_id": "macro.dbt_constraints.have_ownership_priv", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "have_ownership_priv", "macro_sql": "{%- macro have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n {{ return(adapter.dispatch('have_ownership_priv', 'dbt_constraints')(table_relation, verify_permissions, lookup_cache)) }}\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.snowflake__have_ownership_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.483766, "supported_languages": null}, "macro.dbt_constraints.truncate_relation": {"unique_id": "macro.dbt_constraints.truncate_relation", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "truncate_relation", "macro_sql": "{% macro truncate_relation(relation) -%}\n {{ return(adapter.dispatch('truncate_relation')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.484289, "supported_languages": null}, "macro.dbt_constraints.drop_relation": {"unique_id": "macro.dbt_constraints.drop_relation", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "drop_relation", "macro_sql": "{% macro drop_relation(relation) -%}\n {{ return(adapter.dispatch('drop_relation')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__drop_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.484761, "supported_languages": null}, "macro.dbt_constraints.create_constraints": {"unique_id": "macro.dbt_constraints.create_constraints", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "create_constraints", "macro_sql": "\n{%- macro create_constraints(\n constraint_types=[\n 'primary_key',\n 'unique_key',\n 'unique_combination_of_columns',\n 'unique',\n 'foreign_key',\n 'relationships',\n 'not_null'],\n quote_columns=false) -%}\n {%- if execute and var('dbt_constraints_enabled', false) and results -%}\n {%- do log(\"Running dbt Constraints\", info=true) -%}\n\n {%- set lookup_cache = {\n \"table_columns\": { },\n \"table_privileges\": { },\n \"table_details\": { },\n \"unique_keys\": { },\n \"not_null_col\": { },\n \"foreign_keys\": { } } -%}\n\n {%- if 'not_null' in constraint_types -%}\n {%- do dbt_constraints.create_constraints_by_type(['not_null'], quote_columns, lookup_cache) -%}\n {%- endif -%}\n {%- if 'primary_key' in constraint_types -%}\n {%- do dbt_constraints.create_constraints_by_type(['primary_key'], quote_columns, lookup_cache) -%}\n {%- endif -%}\n {%- if 'unique_key' in constraint_types -%}\n {%- do dbt_constraints.create_constraints_by_type(['unique_key'], quote_columns, lookup_cache) -%}\n {%- endif -%}\n {%- if 'unique_combination_of_columns' in constraint_types -%}\n {%- do dbt_constraints.create_constraints_by_type(['unique_combination_of_columns'], quote_columns, lookup_cache) -%}\n {%- endif -%}\n {%- if 'unique' in constraint_types -%}\n {%- do dbt_constraints.create_constraints_by_type(['unique'], quote_columns, lookup_cache) -%}\n {%- endif -%}\n {%- if 'foreign_key' in constraint_types -%}\n {%- do dbt_constraints.create_constraints_by_type(['foreign_key'], quote_columns, lookup_cache) -%}\n {%- endif -%}\n {%- if 'relationships' in constraint_types -%}\n {%- do dbt_constraints.create_constraints_by_type(['relationships'], quote_columns, lookup_cache) -%}\n {%- endif -%}\n\n {%- do log(\"Finished dbt Constraints\", info=true) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.create_constraints_by_type"]}, "description": "Primary macro automatically called `on-run-end` to generate primary keys, unique keys, and foreign keys. The `dbt_constraints_enabled` variable can be set to `false` in your project to disable this macro.", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": "dbt_constraints://macros/macros.yml", "arguments": [{"name": "constraint_types", "type": "array of constraint types", "description": "Accepts a list of tests to consider for constraint creation and whether columns should be quoted. By default it will create all the constraint types. Valid values are ['primary_key', 'unique_key', 'unique_combination_of_columns', 'unique', 'foreign_key', 'relationships']"}, {"name": "quote_columns", "type": "boolean", "description": "Whether to wrap column names in double quotes. By default this is set to false."}], "created_at": 1674188998.345383, "supported_languages": null}, "macro.dbt_constraints.create_constraints_by_type": {"unique_id": "macro.dbt_constraints.create_constraints_by_type", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "create_constraints_by_type", "macro_sql": "\n{%- macro create_constraints_by_type(constraint_types, quote_columns, lookup_cache) -%}\n\n {#- Loop through the results and find all tests that passed and match the constraint_types -#}\n {#- Issue #2: added condition that the where config must be empty -#}\n {%- for res in results\n if res.status == \"pass\"\n and res.node.config.materialized == \"test\"\n and res.node.test_metadata\n and res.node.test_metadata.name is in( constraint_types )\n and res.node.config.where is none -%}\n\n {%- set test_model = res.node -%}\n {%- set test_parameters = test_model.test_metadata.kwargs -%}\n {% set ns = namespace(verify_permissions=false) %}\n\n {#- Find the table models that are referenced by this test.\n These models must be physical tables and cannot be sources -#}\n {%- set table_models = [] -%}\n {%- for node in graph.nodes.values() | selectattr(\"unique_id\", \"in\", test_model.depends_on.nodes)\n if node.resource_type in ( ( \"model\", \"snapshot\", \"seed\") )\n if node.config.materialized in( (\"table\", \"incremental\", \"snapshot\", \"seed\") ) -%}\n\n {#- Append to our list of models &or snapshots for this test -#}\n {%- do table_models.append(node) -%}\n\n {% endfor %}\n\n {#- Check if we allow constraints on sources overall and for this specific type of constraint -#}\n {%- if var('dbt_constraints_sources_enabled', false) and (\n ( var('dbt_constraints_sources_pk_enabled', false) and test_model.test_metadata.name in(\"primary_key\") )\n or ( var('dbt_constraints_sources_uk_enabled', false) and test_model.test_metadata.name in(\"unique_key\", \"unique_combination_of_columns\", \"unique\") )\n or ( var('dbt_constraints_sources_fk_enabled', false) and test_model.test_metadata.name in(\"foreign_key\", \"relationships\") )\n or ( var('dbt_constraints_sources_nn_enabled', false) and test_model.test_metadata.name in(\"not_null\") )\n ) -%}\n {%- for node in graph.sources.values()\n | selectattr(\"resource_type\", \"equalto\", \"source\")\n | selectattr(\"unique_id\", \"in\", test_model.depends_on.nodes) -%}\n\n {%- do node.update({'alias': node.alias or node.name }) -%}\n {#- Append to our list of models for this test -#}\n {%- do table_models.append(node) -%}\n {#- If we are using a sources, we will need to verify permissions -#}\n {%- set ns.verify_permissions = true -%}\n\n {%- endfor -%}\n {%- endif -%}\n\n\n {#- We only create PK/UK if there is one model referenced by the test\n and if all the columns exist as physical columns on the table -#}\n {%- if 1 == table_models|count\n and test_model.test_metadata.name in(\"primary_key\", \"unique_key\", \"unique_combination_of_columns\", \"unique\") -%}\n\n {# Attempt to identify a parameter we can use for the column names #}\n {%- set column_names = [] -%}\n {%- if test_parameters.column_names -%}\n {%- set column_names = test_parameters.column_names -%}\n {%- elif test_parameters.combination_of_columns -%}\n {%- set column_names = test_parameters.combination_of_columns -%}\n {%- elif test_parameters.column_name -%}\n {%- set column_names = [test_parameters.column_name] -%}\n {%- else -%}\n {{ exceptions.raise_compiler_error(\n \"`column_names` or `column_name` parameter missing for primary/unique key constraint on table: '\" ~ table_models[0].name\n ) }}\n {%- endif -%}\n\n {%- set table_relation = api.Relation.create(\n database=table_models[0].database,\n schema=table_models[0].schema,\n identifier=table_models[0].alias ) -%}\n {%- if dbt_constraints.table_columns_all_exist(table_relation, column_names, lookup_cache) -%}\n {%- if test_model.test_metadata.name == \"primary_key\" -%}\n {%- do dbt_constraints.create_not_null(table_relation, column_names, ns.verify_permissions, quote_columns, lookup_cache) -%}\n {%- do dbt_constraints.create_primary_key(table_relation, column_names, ns.verify_permissions, quote_columns, test_parameters.constraint_name, lookup_cache) -%}\n {%- else -%}\n {%- do dbt_constraints.create_unique_key(table_relation, column_names, ns.verify_permissions, quote_columns, test_parameters.constraint_name, lookup_cache) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping primary/unique key because a physical column name was not found on the table: \" ~ table_models[0].name ~ \" \" ~ column_names, info=true) -%}\n {%- endif -%}\n\n {#- We only create FK if there are two models referenced by the test\n and if all the columns exist as physical columns on the tables -#}\n {%- elif 2 == table_models|count\n and test_model.test_metadata.name in( \"foreign_key\", \"relationships\") -%}\n\n {%- set fk_model = none -%}\n {%- set pk_model = none -%}\n {%- set fk_model_names = modules.re.findall( \"(models|snapshots|seeds)\\W+(\\w+)\" , test_model.file_key_name) -%}\n {%- set fk_source_names = modules.re.findall( \"source\\W+(\\w+)\\W+(\\w+)\" , test_parameters.model) -%}\n\n {%- if 1 == fk_model_names | count -%}\n {%- set fk_model = table_models | selectattr(\"name\", \"equalto\", fk_model_names[0][1]) | first -%}\n {%- set pk_model = table_models | rejectattr(\"name\", \"equalto\", fk_model_names[0][1]) | first -%}\n {%- elif 1 == fk_source_names | count -%}\n {%- if table_models[0].source_name == fk_source_names[0][0] and table_models[0].name == fk_source_names[0][1] -%}\n {%- set fk_model = table_models[0] -%}\n {%- set pk_model = table_models[1] -%}\n {%- else -%}\n {%- set fk_model = table_models[1] -%}\n {%- set pk_model = table_models[0] -%}\n {%- endif -%}\n {%- endif -%}\n {# {%- set fk_model_name = test_model.file_key_name |replace(\"models.\", \"\") -%} #}\n\n {%- if fk_model and pk_model -%}\n\n {%- set fk_table_relation = api.Relation.create(\n database=fk_model.database,\n schema=fk_model.schema,\n identifier=fk_model.alias) -%}\n\n {%- set pk_table_relation = api.Relation.create(\n database=pk_model.database,\n schema=pk_model.schema,\n identifier=pk_model.alias) -%}\n\n {# Attempt to identify parameters we can use for the column names #}\n {%- set pk_column_names = [] -%}\n {%- if test_parameters.pk_column_names -%}\n {%- set pk_column_names = test_parameters.pk_column_names -%}\n {%- elif test_parameters.field -%}\n {%- set pk_column_names = [test_parameters.field] -%}\n {%- elif test_parameters.pk_column_name -%}\n {%- set pk_column_names = [test_parameters.pk_column_name] -%}\n {%- else -%}\n {{ exceptions.raise_compiler_error(\n \"`pk_column_names`, `pk_column_name`, or `field` parameter missing for foreign key constraint on table: '\" ~ fk_model.name ~ \" \" ~ test_parameters\n ) }}\n {%- endif -%}\n\n {%- set fk_column_names = [] -%}\n {%- if test_parameters.fk_column_names -%}\n {%- set fk_column_names = test_parameters.fk_column_names -%}\n {%- elif test_parameters.column_name -%}\n {%- set fk_column_names = [test_parameters.column_name] -%}\n {%- elif test_parameters.fk_column_name -%}\n {%- set fk_column_names = [test_parameters.fk_column_name] -%}\n {%- else -%}\n {{ exceptions.raise_compiler_error(\n \"`fk_column_names`, `fk_column_name`, or `column_name` parameter missing for foreign key constraint on table: '\" ~ fk_model.name ~ \" \" ~ test_parameters\n ) }}\n {%- endif -%}\n\n {%- if not dbt_constraints.table_columns_all_exist(pk_table_relation, pk_column_names, lookup_cache) -%}\n {%- do log(\"Skipping foreign key because a physical column was not found on the pk table: \" ~ pk_model.name ~ \" \" ~ pk_column_names, info=true) -%}\n {%- elif not dbt_constraints.table_columns_all_exist(fk_table_relation, fk_column_names, lookup_cache) -%}\n {%- do log(\"Skipping foreign key because a physical column was not found on the fk table: \" ~ fk_model.name ~ \" \" ~ fk_column_names, info=true) -%}\n {%- else -%}\n {%- do dbt_constraints.create_foreign_key(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, ns.verify_permissions, quote_columns, test_parameters.constraint_name, lookup_cache) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping foreign key because a we couldn't find the child table: model=\" ~ fk_model_names ~ \" or source=\" ~ fk_source_names, info=true) -%}\n {%- endif -%}\n\n {#- We only create NN if there is one model referenced by the test\n and if all the columns exist as physical columns on the table -#}\n {%- elif 1 == table_models|count\n and test_model.test_metadata.name in(\"not_null\") -%}\n\n {# Attempt to identify a parameter we can use for the column names #}\n {%- set column_names = [] -%}\n {%- if test_parameters.column_names -%}\n {%- set column_names = test_parameters.column_names -%}\n {%- elif test_parameters.combination_of_columns -%}\n {%- set column_names = test_parameters.combination_of_columns -%}\n {%- elif test_parameters.column_name -%}\n {%- set column_names = [test_parameters.column_name] -%}\n {%- else -%}\n {{ exceptions.raise_compiler_error(\n \"`column_names` or `column_name` parameter missing for not null constraint on table: '\" ~ table_models[0].name\n ) }}\n {%- endif -%}\n\n {%- set table_relation = api.Relation.create(\n database=table_models[0].database,\n schema=table_models[0].schema,\n identifier=table_models[0].alias ) -%}\n\n {%- if dbt_constraints.table_columns_all_exist(table_relation, column_names, lookup_cache) -%}\n {%- do dbt_constraints.create_not_null(table_relation, column_names, ns.verify_permissions, quote_columns, lookup_cache) -%}\n {%- else -%}\n {%- do log(\"Skipping not null constraint because a physical column name was not found on the table: \" ~ table_models[0].name ~ \" \" ~ column_names, info=true) -%}\n {%- endif -%}\n\n {%- endif -%}\n\n {%- endfor -%}\n\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.table_columns_all_exist", "macro.dbt_constraints.create_not_null", "macro.dbt_constraints.create_primary_key", "macro.dbt_constraints.create_unique_key", "macro.dbt_constraints.create_foreign_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.504691, "supported_languages": null}, "macro.dbt_constraints.table_columns_all_exist": {"unique_id": "macro.dbt_constraints.table_columns_all_exist", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "table_columns_all_exist", "macro_sql": "\n{%- macro table_columns_all_exist(table_relation, column_list, lookup_cache) -%}\n {%- set tab_column_list = dbt_constraints.lookup_table_columns(table_relation, lookup_cache) -%}\n\n {%- for column in column_list|map('upper') if column not in tab_column_list -%}\n {{ return(false) }}\n {%- endfor -%}\n {{ return(true) }}\n\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.lookup_table_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.5055628, "supported_languages": null}, "macro.dbt_constraints.lookup_table_columns": {"unique_id": "macro.dbt_constraints.lookup_table_columns", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "lookup_table_columns", "macro_sql": "{%- macro lookup_table_columns(table_relation, lookup_cache) -%}\n {{ return(adapter.dispatch('lookup_table_columns', 'dbt_constraints')(table_relation, lookup_cache)) }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.snowflake__lookup_table_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.506025, "supported_languages": null}, "macro.dbt_constraints.default__lookup_table_columns": {"unique_id": "macro.dbt_constraints.default__lookup_table_columns", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "default__lookup_table_columns", "macro_sql": "{%- macro default__lookup_table_columns(table_relation, lookup_cache) -%}\n {%- if table_relation not in lookup_cache.table_columns -%}\n {%- set tab_Columns = adapter.get_columns_in_relation(table_relation) -%}\n\n {%- set tab_column_list = [] -%}\n {%- for column in tab_Columns -%}\n {{ tab_column_list.append(column.name|upper) }}\n {%- endfor -%}\n {%- do lookup_cache.table_columns.update({ table_relation: tab_column_list }) -%}\n {%- endif -%}\n {{ return(lookup_cache.table_columns[table_relation]) }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.507094, "supported_languages": null}, "macro.dbt_constraints.column_list_matches": {"unique_id": "macro.dbt_constraints.column_list_matches", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "name": "column_list_matches", "macro_sql": "\n{%- macro column_list_matches(listA, listB) -%}\n {# Test if A is empty or the lists are not the same size #}\n {%- if listA | count > 0 and listA | count == listB | count -%}\n {# Fail if there are any columns in A that are not in B #}\n {%- for valueFromA in listA|map('upper') -%}\n {%- if valueFromA|upper not in listB| map('upper') -%}\n {{ return(false) }}\n {%- endif -%}\n {% endfor %}\n {# Since we know the count is the same, A must equal B #}\n {{ return(true) }}\n {%- else -%}\n {{ return(false) }}\n {%- endif -%}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.5081549, "supported_languages": null}, "macro.dbt_constraints.snowflake__create_primary_key": {"unique_id": "macro.dbt_constraints.snowflake__create_primary_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "name": "snowflake__create_primary_key", "macro_sql": "\n{%- macro snowflake__create_primary_key(table_relation, column_names, verify_permissions, quote_columns=false, constraint_name=none, lookup_cache=none) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_PK\") | upper -%}\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set query -%}\n ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} PRIMARY KEY ( {{columns_csv}} ) RELY\n {%- endset -%}\n {%- do log(\"Creating primary key: \" ~ constraint_name, info=true) -%}\n {%- do run_query(query) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.unique_keys.update({table_relation: {constraint_name: column_names} }) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.518537, "supported_languages": null}, "macro.dbt_constraints.snowflake__create_unique_key": {"unique_id": "macro.dbt_constraints.snowflake__create_unique_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "name": "snowflake__create_unique_key", "macro_sql": "\n{%- macro snowflake__create_unique_key(table_relation, column_names, verify_permissions, quote_columns=false, constraint_name=none, lookup_cache=none) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_UK\") | upper -%}\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set query -%}\n ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} UNIQUE ( {{columns_csv}} ) RELY\n {%- endset -%}\n {%- do log(\"Creating unique key: \" ~ constraint_name, info=true) -%}\n {%- do run_query(query) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.unique_keys.update({table_relation: {constraint_name: column_names} }) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.520669, "supported_languages": null}, "macro.dbt_constraints.snowflake__create_foreign_key": {"unique_id": "macro.dbt_constraints.snowflake__create_foreign_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "name": "snowflake__create_foreign_key", "macro_sql": "\n{%- macro snowflake__create_foreign_key(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, verify_permissions, quote_columns, constraint_name, lookup_cache) -%}\n {%- set constraint_name = (constraint_name or fk_table_relation.identifier ~ \"_\" ~ fk_column_names|join('_') ~ \"_FK\") | upper -%}\n {%- set fk_columns_csv = dbt_constraints.get_quoted_column_csv(fk_column_names, quote_columns) -%}\n {%- set pk_columns_csv = dbt_constraints.get_quoted_column_csv(pk_column_names, quote_columns) -%}\n {#- Check that the PK table has a PK or UK -#}\n {%- if dbt_constraints.unique_constraint_exists(pk_table_relation, pk_column_names, lookup_cache) -%}\n {#- Check if the table already has this foreign key -#}\n {%- if not dbt_constraints.foreign_key_exists(fk_table_relation, fk_column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(fk_table_relation, verify_permissions, lookup_cache) and dbt_constraints.have_references_priv(pk_table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set query -%}\n ALTER TABLE {{fk_table_relation}} ADD CONSTRAINT {{constraint_name}} FOREIGN KEY ( {{fk_columns_csv}} ) REFERENCES {{pk_table_relation}} ( {{pk_columns_csv}} ) RELY\n {%- endset -%}\n {%- do log(\"Creating foreign key: \" ~ constraint_name ~ \" referencing \" ~ pk_table_relation.identifier ~ \" \" ~ pk_column_names, info=true) -%}\n {%- do run_query(query) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.foreign_keys.update({fk_table_relation: {constraint_name: fk_column_names} }) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ fk_table_relation ~ \" referencing \" ~ pk_table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because FK already exists: \" ~ fk_table_relation ~ \" \" ~ fk_column_names, info=false) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because a PK/UK was not found on the PK table: \" ~ pk_table_relation ~ \" \" ~ pk_column_names, info=true) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.foreign_key_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt_constraints.have_references_priv", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.523746, "supported_languages": null}, "macro.dbt_constraints.snowflake__create_not_null": {"unique_id": "macro.dbt_constraints.snowflake__create_not_null", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "name": "snowflake__create_not_null", "macro_sql": "\n{%- macro snowflake__create_not_null(table_relation, column_names, verify_permissions, quote_columns, lookup_cache) -%}\n\n {%- set existing_not_null_col = lookup_cache.not_null_col[table_relation] -%}\n\n {%- set columns_to_change = [] -%}\n {%- for column_name in column_names if column_name not in existing_not_null_col -%}\n {%- do columns_to_change.append(column_name) -%}\n {%- do existing_not_null_col.append(column_name) -%}\n {%- endfor -%}\n {%- if columns_to_change|count > 0 -%}\n {%- set columns_list = dbt_constraints.get_quoted_column_list(columns_to_change, quote_columns) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set modify_statements= [] -%}\n {%- for column in columns_list -%}\n {%- set modify_statements = modify_statements.append( \"COLUMN \" ~ column ~ \" SET NOT NULL\" ) -%}\n {%- endfor -%}\n {%- set modify_statement_csv = modify_statements | join(\", \") -%}\n {%- set query -%}\n ALTER TABLE {{table_relation}} MODIFY {{ modify_statement_csv }};\n {%- endset -%}\n {%- do log(\"Creating not null constraint for: \" ~ columns_to_change | join(\", \") ~ \" in \" ~ table_relation, info=true) -%}\n {%- do run_query(query) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- set constraint_key = table_relation.identifier ~ \"_\" ~ columns_to_change|join('_') ~ \"_NN\" -%}\n {%- do lookup_cache.not_null_col.update({table_relation: existing_not_null_col }) -%}\n\n {%- else -%}\n {%- do log(\"Skipping not null constraint for \" ~ columns_to_change | join(\", \") ~ \" in \" ~ table_relation ~ \" because of insufficient privileges: \" ~ table_relation, info=true) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping not null constraint for \" ~ column_names | join(\", \") ~ \" in \" ~ table_relation ~ \" because all columns are already not null\", info=false) -%}\n {%- endif -%}\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_list", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.5268748, "supported_languages": null}, "macro.dbt_constraints.snowflake__unique_constraint_exists": {"unique_id": "macro.dbt_constraints.snowflake__unique_constraint_exists", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "name": "snowflake__unique_constraint_exists", "macro_sql": "\n{%- macro snowflake__unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {#- Check if we can find this constraint in the lookup cache -#}\n {%- if table_relation in lookup_cache.unique_keys -%}\n {%- set cached_unique_keys = lookup_cache.unique_keys[table_relation] -%}\n {%- for cached_columns in cached_unique_keys.values() -%}\n {%- if dbt_constraints.column_list_matches(cached_columns, column_names ) -%}\n {%- do log(\"Found UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {%- set lookup_query -%}\n SHOW UNIQUE KEYS IN TABLE {{table_relation}}\n {%- endset -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.unique_keys.update({table_relation: {constraint.key_name: constraint.columns[\"column_name\"].values()} }) -%}\n {% endfor %}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"column_name\"].values(), column_names ) -%}\n {%- do log(\"Found UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {%- set lookup_query -%}\n SHOW PRIMARY KEYS IN TABLE {{table_relation}}\n {%- endset -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.unique_keys.update({table_relation: {constraint.key_name: constraint.columns[\"column_name\"].values()} }) -%}\n {% endfor %}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"column_name\"].values(), column_names ) -%}\n {%- do log(\"Found PK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {#- If we get this far then the table does not have either constraint -#}\n {%- do log(\"No PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.column_list_matches", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.53125, "supported_languages": null}, "macro.dbt_constraints.snowflake__foreign_key_exists": {"unique_id": "macro.dbt_constraints.snowflake__foreign_key_exists", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "name": "snowflake__foreign_key_exists", "macro_sql": "\n{%- macro snowflake__foreign_key_exists(table_relation, column_names, lookup_cache) -%}\n\n {#- Check if we can find this constraint in the lookup cache -#}\n {%- if table_relation in lookup_cache.foreign_keys -%}\n {%- set cached_foreign_keys = lookup_cache.foreign_keys[table_relation] -%}\n {%- for cached_columns in cached_foreign_keys.values() -%}\n {%- if dbt_constraints.column_list_matches(cached_columns, column_names ) -%}\n {%- do log(\"Found FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {%- set lookup_query -%}\n SHOW IMPORTED KEYS IN TABLE {{table_relation}}\n {%- endset -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"fk_column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"fk_name\") -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.foreign_keys.update({table_relation: {constraint.key_name: constraint.columns[\"fk_column_name\"].values()} }) -%}\n {% endfor %}\n {%- for constraint in constraint_list.group_by(\"fk_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"fk_column_name\"].values(), column_names ) -%}\n {%- do log(\"Found FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {#- If we get this far then the table does not have this constraint -#}\n {%- do log(\"No FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.column_list_matches", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.5339541, "supported_languages": null}, "macro.dbt_constraints.snowflake__have_references_priv": {"unique_id": "macro.dbt_constraints.snowflake__have_references_priv", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "name": "snowflake__have_references_priv", "macro_sql": "{%- macro snowflake__have_references_priv(table_relation, verify_permissions, lookup_cache) -%}\n {%- if verify_permissions is sameas true -%}\n\n {%- set table_privileges = snowflake__lookup_table_privileges(table_relation, lookup_cache) -%}\n {%- if \"REFERENCES\" in table_privileges or \"OWNERSHIP\" in table_privileges -%}\n {{ return(true) }}\n {%- else -%}\n {{ return(false) }}\n {%- endif -%}\n\n {%- else -%}\n {{ return(true) }}\n {%- endif -%}\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.snowflake__lookup_table_privileges"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.5348082, "supported_languages": null}, "macro.dbt_constraints.snowflake__have_ownership_priv": {"unique_id": "macro.dbt_constraints.snowflake__have_ownership_priv", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "name": "snowflake__have_ownership_priv", "macro_sql": "{%- macro snowflake__have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n {%- if verify_permissions is sameas true -%}\n\n {%- set table_privileges = snowflake__lookup_table_privileges(table_relation, lookup_cache) -%}\n {%- if \"OWNERSHIP\" in table_privileges -%}\n {{ return(true) }}\n {%- else -%}\n {{ return(false) }}\n {%- endif -%}\n\n {%- else -%}\n {{ return(true) }}\n {%- endif -%}\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.snowflake__lookup_table_privileges"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.535591, "supported_languages": null}, "macro.dbt_constraints.snowflake__lookup_table_privileges": {"unique_id": "macro.dbt_constraints.snowflake__lookup_table_privileges", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "name": "snowflake__lookup_table_privileges", "macro_sql": "{%- macro snowflake__lookup_table_privileges(table_relation, lookup_cache) -%}\n\n {%- if table_relation.database not in lookup_cache.table_privileges -%}\n {%- set lookup_query -%}\n select distinct\n upper(tp.table_schema) as \"table_schema\",\n upper(tp.table_name) as \"table_name\",\n tp.privilege_type as \"privilege_type\"\n from {{table_relation.database}}.information_schema.table_privileges tp\n where is_role_in_session(tp.grantee)\n and tp.privilege_type in ('OWNERSHIP', 'REFERENCES')\n {%- endset -%}\n {%- do log(\"Caching privileges for database: \" ~ table_relation.database, info=false) -%}\n {%- set privilege_list = run_query(lookup_query) -%}\n {%- do lookup_cache.table_privileges.update({ table_relation.database: privilege_list }) -%}\n {%- endif -%}\n\n {%- set tab_priv_list = [] -%}\n {%- set schema_name = table_relation.schema|upper -%}\n {%- set table_name = table_relation.identifier|upper -%}\n {%- for row in lookup_cache.table_privileges[table_relation.database].rows -%}\n {%- if row[\"table_schema\"] == schema_name and row[\"table_name\"] == table_name -%}\n {%- do tab_priv_list.append(row[\"privilege_type\"]) -%}\n {%- endif -%}\n {%- endfor -%}\n {{ return(tab_priv_list) }}\n\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.5373042, "supported_languages": null}, "macro.dbt_constraints.snowflake__lookup_table_columns": {"unique_id": "macro.dbt_constraints.snowflake__lookup_table_columns", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "name": "snowflake__lookup_table_columns", "macro_sql": "{%- macro snowflake__lookup_table_columns(table_relation, lookup_cache) -%}\n\n {%- if table_relation not in lookup_cache.table_columns -%}\n {%- set lookup_query -%}\n SHOW COLUMNS IN TABLE {{table_relation}}\n {%- endset -%}\n {%- set results = run_query(lookup_query) -%}\n\n {%- set not_null_col = [] -%}\n {%- set upper_column_list = [] -%}\n {%- for row in results.rows -%}\n {%- do upper_column_list.append(row[\"column_name\"]|upper) -%}\n {%- if row['null?'] == 'false' -%}\n {%- do not_null_col.append(row[\"column_name\"]|upper) -%}\n {%- endif -%}\n {%- endfor -%}\n {%- do lookup_cache.table_columns.update({ table_relation: upper_column_list }) -%}\n {%- do lookup_cache.not_null_col.update({ table_relation: not_null_col }) -%}\n {%- endif -%}\n {{ return(lookup_cache.table_columns[table_relation]) }}\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.539105, "supported_languages": null}, "macro.dbt_constraints.redshift__create_primary_key": {"unique_id": "macro.dbt_constraints.redshift__create_primary_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "name": "redshift__create_primary_key", "macro_sql": "\n{%- macro redshift__create_primary_key(table_relation, column_names, verify_permissions, quote_columns=false, constraint_name=none, lookup_cache=none) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_PK\") | upper -%}\n\n {%- if constraint_name|length > 127 %}\n {%- set constraint_name_query %}\n select 'PK_' || md5( '{{ constraint_name }}' )::varchar as \"constraint_name\"\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- do log(\"Creating primary key: \" ~ constraint_name, info=true) -%}\n {%- set query -%}\n ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} PRIMARY KEY ( {{columns_csv}} )\n {%- endset -%}\n {%- do run_query(query) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=false) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.5471208, "supported_languages": null}, "macro.dbt_constraints.redshift__create_unique_key": {"unique_id": "macro.dbt_constraints.redshift__create_unique_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "name": "redshift__create_unique_key", "macro_sql": "\n{%- macro redshift__create_unique_key(table_relation, column_names, verify_permissions, quote_columns=false, constraint_name=none, lookup_cache=none) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_UK\") | upper -%}\n\n {%- if constraint_name|length > 127 %}\n {%- set constraint_name_query %}\n select 'UK_' || md5( '{{ constraint_name }}' )::varchar as \"constraint_name\"\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- do log(\"Creating unique key: \" ~ constraint_name, info=true) -%}\n {%- set query -%}\n ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} UNIQUE ( {{columns_csv}} )\n {%- endset -%}\n {%- do run_query(query) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=false) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.5497642, "supported_languages": null}, "macro.dbt_constraints.redshift__create_not_null": {"unique_id": "macro.dbt_constraints.redshift__create_not_null", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "name": "redshift__create_not_null", "macro_sql": "\n{%- macro redshift__create_not_null(table_relation, column_names, verify_permissions, quote_columns=false, lookup_cache=none) -%}\n {%- set columns_list = dbt_constraints.get_quoted_column_list(column_names, quote_columns) -%}\n\n {%- do log(\"Skipping not null constraint for \" ~ columns_list | join(\", \") ~ \" in \" ~ table_relation ~ \" because ALTER COLUMN SET NOT NULL is not supported\", info=true) -%}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_list"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.5508869, "supported_languages": null}, "macro.dbt_constraints.redshift__create_foreign_key": {"unique_id": "macro.dbt_constraints.redshift__create_foreign_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "name": "redshift__create_foreign_key", "macro_sql": "\n{%- macro redshift__create_foreign_key(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, verify_permissions, quote_columns=true, constraint_name=none, lookup_cache=none) -%}\n {%- set constraint_name = (constraint_name or fk_table_relation.identifier ~ \"_\" ~ fk_column_names|join('_') ~ \"_FK\") | upper -%}\n\n {%- if constraint_name|length > 127 %}\n {%- set constraint_name_query %}\n select 'FK_' || md5( '{{ constraint_name }}' )::varchar as \"constraint_name\"\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set fk_columns_csv = dbt_constraints.get_quoted_column_csv(fk_column_names, quote_columns) -%}\n {%- set pk_columns_csv = dbt_constraints.get_quoted_column_csv(pk_column_names, quote_columns) -%}\n {#- Check that the PK table has a PK or UK -#}\n {%- if dbt_constraints.unique_constraint_exists(pk_table_relation, pk_column_names, lookup_cache) -%}\n {#- Check if the table already has this foreign key -#}\n {%- if not dbt_constraints.foreign_key_exists(fk_table_relation, fk_column_names) -%}\n\n {%- if dbt_constraints.have_ownership_priv(fk_table_relation, verify_permissions, lookup_cache) and dbt_constraints.have_references_priv(pk_table_relation, verify_permissions, lookup_cache) -%}\n\n {%- do log(\"Creating foreign key: \" ~ constraint_name ~ \" referencing \" ~ pk_table_relation.identifier ~ \" \" ~ pk_column_names, info=true) -%}\n {%- set query -%}\n --Note: ON DELETE not supported in Redshift\n ALTER TABLE {{fk_table_relation}} ADD CONSTRAINT {{constraint_name}} FOREIGN KEY ( {{fk_columns_csv}} ) REFERENCES {{pk_table_relation}} ( {{pk_columns_csv}} ) --ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED\n {%- endset -%}\n {%- do run_query(query) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ fk_table_relation ~ \" referencing \" ~ pk_table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because FK already exists: \" ~ fk_table_relation ~ \" \" ~ fk_column_names, info=false) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because a PK/UK was not found on the PK table: \" ~ pk_table_relation ~ \" \" ~ pk_column_names, info=true) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.foreign_key_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt_constraints.have_references_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.554035, "supported_languages": null}, "macro.dbt_constraints.redshift__unique_constraint_exists": {"unique_id": "macro.dbt_constraints.redshift__unique_constraint_exists", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "name": "redshift__unique_constraint_exists", "macro_sql": "\n{%- macro redshift__unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n {%- set lookup_query -%}\n SELECT\n kc.constraint_name\n , lower(kc.column_name) as column_name\n FROM information_schema.key_column_usage kc\n JOIN information_schema.table_constraints tc\n ON kc.table_name = tc.table_name\n AND kc.table_schema = tc.table_schema\n AND kc.constraint_name = tc.constraint_name\n WHERE tc.constraint_type in ('PRIMARY KEY', 'UNIQUE')\n AND kc.table_schema ilike '{{table_relation.schema}}'\n AND kc.table_name ilike '{{table_relation.identifier}}'\n order by kc.constraint_name\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"column_name\"].values(), column_names ) -%}\n {%- do log(\"Found PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}#}\n\n {#- If we get this far then the table does not have either constraint -#}\n {%- do log(\"No PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.column_list_matches"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.555763, "supported_languages": null}, "macro.dbt_constraints.redshift__foreign_key_exists": {"unique_id": "macro.dbt_constraints.redshift__foreign_key_exists", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "name": "redshift__foreign_key_exists", "macro_sql": "\n{%- macro redshift__foreign_key_exists(table_relation, column_names, lookup_cache) -%}\n {%- set lookup_query -%}\n SELECT\n kc.constraint_name fk_name\n , lower(kc.column_name) as fk_column_name\n FROM information_schema.key_column_usage kc\n JOIN information_schema.table_constraints tc\n ON kc.table_name = tc.table_name\n AND kc.table_schema = tc.table_schema\n AND kc.constraint_name = tc.constraint_name\n WHERE tc.constraint_type='FOREIGN KEY'\n AND kc.table_schema ilike '{{table_relation.schema}}'\n AND kc.table_name ilike '{{table_relation.identifier}}'\n order by kc.constraint_name\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"fk_column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"fk_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"fk_column_name\"].values(), column_names ) -%}\n {%- do log(\"Found FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {#- If we get this far then the table does not have this constraint -#}\n {%- do log(\"No FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.column_list_matches"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.557601, "supported_languages": null}, "macro.dbt_constraints.redshift__have_references_priv": {"unique_id": "macro.dbt_constraints.redshift__have_references_priv", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "name": "redshift__have_references_priv", "macro_sql": "{%- macro redshift__have_references_priv(table_relation, verify_permissions, lookup_cache) -%}\n {%- if verify_permissions is sameas true -%}\n\n {%- set lookup_query -%}\n select case when count(*) > 0 then 'y' else 'n' end as \"have_references\"\n from information_schema.table_privileges t\n join information_schema.enabled_roles er on t.grantee = er.role_name\n where upper(t.table_schema) = upper('{{table_relation.schema}}')\n and upper(t.table_name) = upper('{{table_relation.identifier}}')\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set results = run_query(lookup_query) -%}\n {%- if \"y\" in( results.columns[\"have_references\"].values() ) -%}\n {{ return(true) }}\n {%- endif -%}\n\n {{ return(false) }}\n {%- else -%}\n {{ return(true) }}\n {%- endif -%}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.5587788, "supported_languages": null}, "macro.dbt_constraints.redshift__have_ownership_priv": {"unique_id": "macro.dbt_constraints.redshift__have_ownership_priv", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "name": "redshift__have_ownership_priv", "macro_sql": "{%- macro redshift__have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n {%- if verify_permissions is sameas true -%}\n\n {%- set lookup_query -%}\n select case when count(*) > 0 then 'y' else 'n' end as \"have_ownership\"\n from pg_catalog.pg_tables t\n join information_schema.enabled_roles er on t.tableowner = er.role_name\n where upper(t.schemaname) = upper('{{table_relation.schema}}')\n and upper(t.tablename) = upper('{{table_relation.identifier}}')\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set results = run_query(lookup_query) -%}\n {%- if \"y\" in( results.columns[\"have_ownership\"].values() ) -%}\n {{ return(true) }}\n {%- endif -%}\n\n {{ return(false) }}\n {%- else -%}\n {{ return(true) }}\n {%- endif -%}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.5599868, "supported_languages": null}, "macro.dbt_constraints.redshift__drop_referential_constraints": {"unique_id": "macro.dbt_constraints.redshift__drop_referential_constraints", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "name": "redshift__drop_referential_constraints", "macro_sql": "{% macro redshift__drop_referential_constraints(relation) -%}\n {%- set lookup_query -%}\n select constraint_name\n from information_schema.table_constraints\n where table_schema = '{{relation.schema}}'\n and table_name='{{relation.identifier}}'\n and constraint_type in ('FOREIGN KEY', 'PRIMARY KEY', 'UNIQUE')\n {%- endset -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n\n {%- for constraint_name in constraint_list.columns[\"constraint_name\"].values() -%}\n {%- do log(\"Dropping constraint: \" ~ constraint_name ~ \" from table \" ~ relation, info=false) -%}\n {%- set query -%}\n ALTER TABLE {{relation}} DROP CONSTRAINT \"{{constraint_name}}\" CASCADE\n {%- endset -%}\n {%- do run_query(query) -%}\n {% endfor %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.5611, "supported_languages": null}, "macro.dbt_constraints.redshift__truncate_relation": {"unique_id": "macro.dbt_constraints.redshift__truncate_relation", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "name": "redshift__truncate_relation", "macro_sql": "{% macro redshift__truncate_relation(relation) -%}\n {{ redshift__drop_referential_constraints(relation) }}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.redshift__drop_referential_constraints", "macro.dbt_constraints.truncate_relation", "macro.dbt_snowflake.snowflake__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.561596, "supported_languages": null}, "macro.dbt_constraints.redshift__drop_relation": {"unique_id": "macro.dbt_constraints.redshift__drop_relation", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "name": "redshift__drop_relation", "macro_sql": "{% macro redshift__drop_relation(relation) -%}\n {{ redshift__drop_referential_constraints(relation) }}\n {{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.redshift__drop_referential_constraints", "macro.dbt_constraints.drop_relation", "macro.dbt.default__drop_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.562021, "supported_languages": null}, "macro.dbt_constraints.oracle__create_primary_key": {"unique_id": "macro.dbt_constraints.oracle__create_primary_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "name": "oracle__create_primary_key", "macro_sql": "\n{%- macro oracle__create_primary_key(table_relation, column_names, verify_permissions, quote_columns=false, constraint_name=none, lookup_cache=none) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_PK\") | upper -%}\n\n {%- if constraint_name|length > 30 %}\n {%- set constraint_name_query %}\n select 'PK_' || ora_hash( '{{ constraint_name }}' ) as \"constraint_name\" from dual\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set query -%}\nBEGIN\n EXECUTE IMMEDIATE 'ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} PRIMARY KEY ( {{columns_csv}} )';\nEXCEPTION\n WHEN OTHERS THEN\n DBMS_OUTPUT.ENABLE(BUFFER_SIZE => NULL);\n DBMS_OUTPUT.PUT_LINE('Unable to create constraint: ' || SQLERRM);\nEND;\n {%- endset -%}\n {%- do log(\"Creating primary key: \" ~ constraint_name, info=true) -%}\n {%- do run_query(query) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=false) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.569061, "supported_languages": null}, "macro.dbt_constraints.oracle__create_unique_key": {"unique_id": "macro.dbt_constraints.oracle__create_unique_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "name": "oracle__create_unique_key", "macro_sql": "\n{%- macro oracle__create_unique_key(table_relation, column_names, verify_permissions, quote_columns=false, constraint_name=none, lookup_cache=none) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_UK\") | upper -%}\n\n {%- if constraint_name|length > 30 %}\n {%- set constraint_name_query %}\n select 'UK_' || ora_hash( '{{ constraint_name }}' ) as \"constraint_name\" from dual\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set query -%}\nBEGIN\n EXECUTE IMMEDIATE 'ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} UNIQUE ( {{columns_csv}} )';\nEXCEPTION\n WHEN OTHERS THEN\n DBMS_OUTPUT.ENABLE(BUFFER_SIZE => NULL);\n DBMS_OUTPUT.PUT_LINE('Unable to create constraint: ' || SQLERRM);\nEND;\n {%- endset -%}\n {%- do log(\"Creating unique key: \" ~ constraint_name, info=true) -%}\n {%- do run_query(query) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=false) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.571758, "supported_languages": null}, "macro.dbt_constraints.oracle__create_foreign_key": {"unique_id": "macro.dbt_constraints.oracle__create_foreign_key", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "name": "oracle__create_foreign_key", "macro_sql": "\n{%- macro oracle__create_foreign_key(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, verify_permissions, quote_columns=true, constraint_name=none, lookup_cache=none) -%}\n {%- set constraint_name = (constraint_name or fk_table_relation.identifier ~ \"_\" ~ fk_column_names|join('_') ~ \"_FK\") | upper -%}\n\n {%- if constraint_name|length > 30 %}\n {%- set constraint_name_query %}\n select 'FK_' || ora_hash( '{{ constraint_name }}' ) as \"constraint_name\" from dual\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set fk_columns_csv = dbt_constraints.get_quoted_column_csv(fk_column_names, quote_columns) -%}\n {%- set pk_columns_csv = dbt_constraints.get_quoted_column_csv(pk_column_names, quote_columns) -%}\n {#- Check that the PK table has a PK or UK -#}\n {%- if dbt_constraints.unique_constraint_exists(pk_table_relation, pk_column_names, lookup_cache) -%}\n {#- Check if the table already has this foreign key -#}\n {%- if not dbt_constraints.foreign_key_exists(fk_table_relation, fk_column_names) -%}\n\n {%- if dbt_constraints.have_ownership_priv(fk_table_relation, verify_permissions, lookup_cache) and dbt_constraints.have_references_priv(pk_table_relation, verify_permissions) -%}\n\n {%- set query -%}\nBEGIN\n EXECUTE IMMEDIATE 'ALTER TABLE {{fk_table_relation}} ADD CONSTRAINT {{constraint_name}} FOREIGN KEY ( {{fk_columns_csv}} ) REFERENCES {{pk_table_relation}} ( {{pk_columns_csv}} )';\nEXCEPTION\n WHEN OTHERS THEN\n DBMS_OUTPUT.ENABLE(BUFFER_SIZE => NULL);\n DBMS_OUTPUT.PUT_LINE('Unable to create constraint: ' || SQLERRM);\nEND;\n {%- endset -%}\n {%- do log(\"Creating foreign key: \" ~ constraint_name ~ \" referencing \" ~ pk_table_relation.identifier ~ \" \" ~ pk_column_names, info=true) -%}\n {%- do run_query(query) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ fk_table_relation ~ \" referencing \" ~ pk_table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because FK already exists: \" ~ fk_table_relation ~ \" \" ~ fk_column_names, info=false) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because a PK/UK was not found on the PK table: \" ~ pk_table_relation ~ \" \" ~ pk_column_names, info=true) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.foreign_key_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt_constraints.have_references_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.574917, "supported_languages": null}, "macro.dbt_constraints.oracle__create_not_null": {"unique_id": "macro.dbt_constraints.oracle__create_not_null", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "name": "oracle__create_not_null", "macro_sql": "\n{%- macro oracle__create_not_null(table_relation, column_names, verify_permissions, quote_columns=false) -%}\n {%- set columns_list = dbt_constraints.get_quoted_column_list(column_names, quote_columns) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions) -%}\n\n {%- set modify_statements= [] -%}\n {%- for column in columns_list -%}\n {%- set modify_statements = modify_statements.append( column ~ \" NOT NULL\" ) -%}\n {%- endfor -%}\n {%- set modify_statement_csv = modify_statements | join(\", \") -%}\n {%- set query -%}\nBEGIN\n EXECUTE IMMEDIATE 'ALTER TABLE {{table_relation}} MODIFY ( {{ modify_statement_csv }} )';\nEXCEPTION\n WHEN OTHERS THEN\n DBMS_OUTPUT.ENABLE(BUFFER_SIZE => NULL);\n DBMS_OUTPUT.PUT_LINE('Unable to create constraint: ' || SQLERRM);\nEND;\n {%- endset -%}\n {%- do log(\"Creating not null constraint for: \" ~ columns_list | join(\", \") ~ \" in \" ~ table_relation, info=true) -%}\n {%- do run_query(query) -%}\n\n {%- else -%}\n {%- do log(\"Skipping not null constraint for \" ~ columns_list | join(\", \") ~ \" in \" ~ table_relation ~ \" because of insufficient privileges: \" ~ table_relation, info=true) -%}\n {%- endif -%}\n{%- endmacro -%}\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_list", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.576927, "supported_languages": null}, "macro.dbt_constraints.oracle__unique_constraint_exists": {"unique_id": "macro.dbt_constraints.oracle__unique_constraint_exists", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "name": "oracle__unique_constraint_exists", "macro_sql": "\n{%- macro oracle__unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n {%- set lookup_query -%}\nselect\n cols.constraint_name as \"constraint_name\",\n upper(cols.column_name) as \"column_name\"\nfrom\n all_constraints cons\n join all_cons_columns cols on cons.constraint_name = cols.constraint_name\n and cons.owner = cols.owner\nwhere\n cons.constraint_type in ( 'P', 'U' )\n and upper(cons.owner) = upper('{{table_relation.schema}}')\n and upper(cons.table_name) = upper('{{table_relation.identifier}}')\norder by 1, 2\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"column_name\"].values(), column_names ) -%}\n {%- do log(\"Found PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}#}\n\n {#- If we get this far then the table does not have either constraint -#}\n {%- do log(\"No PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.column_list_matches"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.578881, "supported_languages": null}, "macro.dbt_constraints.oracle__foreign_key_exists": {"unique_id": "macro.dbt_constraints.oracle__foreign_key_exists", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "name": "oracle__foreign_key_exists", "macro_sql": "\n{%- macro oracle__foreign_key_exists(table_relation, column_names, lookup_cache) -%}\n {%- set lookup_query -%}\nselect\n cols.constraint_name as \"fk_name\",\n upper(cols.column_name) as \"fk_column_name\"\nfrom\n all_constraints cons\n join all_cons_columns cols on cons.constraint_name = cols.constraint_name\n and cons.owner = cols.owner\nwhere\n cons.constraint_type in ( 'R' )\n and upper(cons.owner) = upper('{{table_relation.schema}}')\n and upper(cons.table_name) = upper('{{table_relation.identifier}}')\norder by 1, 2\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"fk_column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"fk_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"fk_column_name\"].values(), column_names ) -%}\n {%- do log(\"Found FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {#- If we get this far then the table does not have this constraint -#}\n {%- do log(\"No FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.column_list_matches"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.581182, "supported_languages": null}, "macro.dbt_constraints.oracle__have_references_priv": {"unique_id": "macro.dbt_constraints.oracle__have_references_priv", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "name": "oracle__have_references_priv", "macro_sql": "\n{%- macro oracle__have_references_priv(table_relation, verify_permissions) -%}\n {{ return(true) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.581456, "supported_languages": null}, "macro.dbt_constraints.oracle__have_ownership_priv": {"unique_id": "macro.dbt_constraints.oracle__have_ownership_priv", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "name": "oracle__have_ownership_priv", "macro_sql": "\n{%- macro oracle__have_ownership_priv(table_relation, verify_permissions) -%}\n {{ return(true) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.581713, "supported_languages": null}, "macro.dbt_constraints.oracle__drop_referential_constraints": {"unique_id": "macro.dbt_constraints.oracle__drop_referential_constraints", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "name": "oracle__drop_referential_constraints", "macro_sql": "{% macro oracle__drop_referential_constraints(relation) -%}\n {%- call statement('drop_constraint_cascade') -%}\nBEGIN\n FOR REC IN (\n SELECT constraint_name\n FROM all_constraints cons\n WHERE cons.constraint_type IN ('P', 'U', 'R')\n AND upper(cons.owner) = upper('{{relation.schema}}')\n AND upper(cons.table_name) = upper('{{relation.identifier}}')\n ORDER BY 1\n ) LOOP\n BEGIN\n EXECUTE IMMEDIATE 'ALTER TABLE {{relation}} DROP CONSTRAINT \"'||REC.CONSTRAINT_NAME||'\" CASCADE';\n EXCEPTION\n WHEN OTHERS THEN\n DBMS_OUTPUT.ENABLE(BUFFER_SIZE => NULL);\n DBMS_OUTPUT.PUT_LINE('Unable to drop constraint: ' || SQLERRM);\n END;\n END LOOP;\nEND;\n {%- endcall -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.582169, "supported_languages": null}, "macro.dbt_constraints.oracle__truncate_relation": {"unique_id": "macro.dbt_constraints.oracle__truncate_relation", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "name": "oracle__truncate_relation", "macro_sql": "{% macro oracle__truncate_relation(relation) -%}\n {{ oracle__drop_referential_constraints(relation) }}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.oracle__drop_referential_constraints", "macro.dbt_constraints.truncate_relation", "macro.dbt_snowflake.snowflake__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.5825868, "supported_languages": null}, "macro.dbt_constraints.oracle__drop_relation": {"unique_id": "macro.dbt_constraints.oracle__drop_relation", "package_name": "dbt_constraints", "root_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "name": "oracle__drop_relation", "macro_sql": "{% macro oracle__drop_relation(relation) -%}\n {{ oracle__drop_referential_constraints(relation) }}\n {{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_constraints.oracle__drop_referential_constraints", "macro.dbt_constraints.drop_relation", "macro.dbt.default__drop_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.583008, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog": {"unique_id": "macro.dbt_snowflake.snowflake__get_catalog", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "name": "snowflake__get_catalog", "macro_sql": "{% macro snowflake__get_catalog(information_schema, schemas) -%}\n {% set query %}\n with tables as (\n\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n table_type as \"table_type\",\n comment as \"table_comment\",\n\n -- note: this is the _role_ that owns the table\n table_owner as \"table_owner\",\n\n 'Clustering Key' as \"stats:clustering_key:label\",\n clustering_key as \"stats:clustering_key:value\",\n 'The key used to cluster this table' as \"stats:clustering_key:description\",\n (clustering_key is not null) as \"stats:clustering_key:include\",\n\n 'Row Count' as \"stats:row_count:label\",\n row_count as \"stats:row_count:value\",\n 'An approximate count of rows in this table' as \"stats:row_count:description\",\n (row_count is not null) as \"stats:row_count:include\",\n\n 'Approximate Size' as \"stats:bytes:label\",\n bytes as \"stats:bytes:value\",\n 'Approximate size of the table as reported by Snowflake' as \"stats:bytes:description\",\n (bytes is not null) as \"stats:bytes:include\",\n\n 'Last Modified' as \"stats:last_modified:label\",\n to_varchar(convert_timezone('UTC', last_altered), 'yyyy-mm-dd HH24:MI'||'UTC') as \"stats:last_modified:value\",\n 'The timestamp for last update/change' as \"stats:last_modified:description\",\n (last_altered is not null and table_type='BASE TABLE') as \"stats:last_modified:include\"\n\n from {{ information_schema }}.tables\n\n ),\n\n columns as (\n\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n\n column_name as \"column_name\",\n ordinal_position as \"column_index\",\n data_type as \"column_type\",\n comment as \"column_comment\"\n\n from {{ information_schema }}.columns\n )\n\n select *\n from tables\n join columns using (\"table_database\", \"table_schema\", \"table_name\")\n where (\n {%- for schema in schemas -%}\n upper(\"table_schema\") = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n order by \"column_index\"\n {%- endset -%}\n\n {{ return(run_query(query)) }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.584629, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_table_as": {"unique_id": "macro.dbt_snowflake.snowflake__create_table_as", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__create_table_as", "macro_sql": "{% macro snowflake__create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {%- if language == 'sql' -%}\n {%- set transient = config.get('transient', default=true) -%}\n {%- set cluster_by_keys = config.get('cluster_by', default=none) -%}\n {%- set enable_automatic_clustering = config.get('automatic_clustering', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n\n {%- if cluster_by_keys is not none and cluster_by_keys is string -%}\n {%- set cluster_by_keys = [cluster_by_keys] -%}\n {%- endif -%}\n {%- if cluster_by_keys is not none -%}\n {%- set cluster_by_string = cluster_by_keys|join(\", \")-%}\n {% else %}\n {%- set cluster_by_string = none -%}\n {%- endif -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create or replace {% if temporary -%}\n temporary\n {%- elif transient -%}\n transient\n {%- endif %} table {{ relation }} {% if copy_grants and not temporary -%} copy grants {%- endif %} as\n (\n {%- if cluster_by_string is not none -%}\n select * from(\n {{ compiled_code }}\n ) order by ({{ cluster_by_string }})\n {%- else -%}\n {{ compiled_code }}\n {%- endif %}\n );\n {% if cluster_by_string is not none and not temporary -%}\n alter table {{relation}} cluster by ({{cluster_by_string}});\n {%- endif -%}\n {% if enable_automatic_clustering and cluster_by_string is not none and not temporary -%}\n alter table {{relation}} resume recluster;\n {%- endif -%}\n\n {%- elif language == 'python' -%}\n {{ py_write_table(compiled_code=compiled_code, target_relation=relation, temporary=temporary) }}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"snowflake__create_table_as macro didn't get supported language, it got %s\" % language) %}\n {%- endif -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.py_write_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.605288, "supported_languages": null}, "macro.dbt_snowflake.get_column_comment_sql": {"unique_id": "macro.dbt_snowflake.get_column_comment_sql", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "get_column_comment_sql", "macro_sql": "{% macro get_column_comment_sql(column_name, column_dict) -%}\n {% if (column_name|upper in column_dict) -%}\n {% set matched_column = column_name|upper -%}\n {% elif (column_name|lower in column_dict) -%}\n {% set matched_column = column_name|lower -%}\n {% elif (column_name in column_dict) -%}\n {% set matched_column = column_name -%}\n {% else -%}\n {% set matched_column = None -%}\n {% endif -%}\n {% if matched_column -%}\n {{ adapter.quote(column_name) }} COMMENT $${{ column_dict[matched_column]['description'] | replace('$', '[$]') }}$$\n {%- else -%}\n {{ adapter.quote(column_name) }} COMMENT $$$$\n {%- endif -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.606559, "supported_languages": null}, "macro.dbt_snowflake.get_persist_docs_column_list": {"unique_id": "macro.dbt_snowflake.get_persist_docs_column_list", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "get_persist_docs_column_list", "macro_sql": "{% macro get_persist_docs_column_list(model_columns, query_columns) %}\n(\n {% for column_name in query_columns %}\n {{ get_column_comment_sql(column_name, model_columns) }}\n {{- \", \" if not loop.last else \"\" }}\n {% endfor %}\n)\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.get_column_comment_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6070771, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_view_as": {"unique_id": "macro.dbt_snowflake.snowflake__create_view_as", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__create_view_as", "macro_sql": "{% macro snowflake__create_view_as(relation, sql) -%}\n {%- set secure = config.get('secure', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create or replace {% if secure -%}\n secure\n {%- endif %} view {{ relation }}\n {% if config.persist_column_docs() -%}\n {% set model_columns = model.columns %}\n {% set query_columns = get_columns_in_query(sql) %}\n {{ get_persist_docs_column_list(model_columns, query_columns) }}\n\n {%- endif %}\n {% if copy_grants -%} copy grants {%- endif %} as (\n {{ sql }}\n );\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_columns_in_query", "macro.dbt_snowflake.get_persist_docs_column_list"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.608441, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_columns_in_relation": {"unique_id": "macro.dbt_snowflake.snowflake__get_columns_in_relation", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__get_columns_in_relation", "macro_sql": "{% macro snowflake__get_columns_in_relation(relation) -%}\n {%- set sql -%}\n describe table {{ relation }}\n {%- endset -%}\n {%- set result = run_query(sql) -%}\n\n {% set maximum = 10000 %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many columns in relation {{ relation }}! dbt can only get\n information about relations with fewer than {{ maximum }} columns.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n\n {% set columns = [] %}\n {% for row in result %}\n {% do columns.append(api.Column.from_description(row['name'], row['type'])) %}\n {% endfor %}\n {% do return(columns) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6099808, "supported_languages": null}, "macro.dbt_snowflake.snowflake__list_schemas": {"unique_id": "macro.dbt_snowflake.snowflake__list_schemas", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__list_schemas", "macro_sql": "{% macro snowflake__list_schemas(database) -%}\n {# 10k limit from here: https://docs.snowflake.net/manuals/sql-reference/sql/show-schemas.html#usage-notes #}\n {% set maximum = 10000 %}\n {% set sql -%}\n show terse schemas in database {{ database }}\n limit {{ maximum }}\n {%- endset %}\n {% set result = run_query(sql) %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many schemas in database {{ database }}! dbt can only get\n information about databases with fewer than {{ maximum }} schemas.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n {{ return(result) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6110709, "supported_languages": null}, "macro.dbt_snowflake.snowflake__list_relations_without_caching": {"unique_id": "macro.dbt_snowflake.snowflake__list_relations_without_caching", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__list_relations_without_caching", "macro_sql": "{% macro snowflake__list_relations_without_caching(schema_relation) %}\n {%- set sql -%}\n show terse objects in {{ schema_relation }}\n {%- endset -%}\n\n {%- set result = run_query(sql) -%}\n {% set maximum = 10000 %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many schemas in schema {{ schema_relation }}! dbt can only get\n information about schemas with fewer than {{ maximum }} objects.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n {%- do return(result) -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6120808, "supported_languages": null}, "macro.dbt_snowflake.snowflake__check_schema_exists": {"unique_id": "macro.dbt_snowflake.snowflake__check_schema_exists", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__check_schema_exists", "macro_sql": "{% macro snowflake__check_schema_exists(information_schema, schema) -%}\n {% call statement('check_schema_exists', fetch_result=True) -%}\n select count(*)\n from {{ information_schema }}.schemata\n where upper(schema_name) = upper('{{ schema }}')\n and upper(catalog_name) = upper('{{ information_schema.database }}')\n {%- endcall %}\n {{ return(load_result('check_schema_exists').table) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6128268, "supported_languages": null}, "macro.dbt_snowflake.snowflake__rename_relation": {"unique_id": "macro.dbt_snowflake.snowflake__rename_relation", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__rename_relation", "macro_sql": "{% macro snowflake__rename_relation(from_relation, to_relation) -%}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ to_relation }}\n {%- endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.613406, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_column_type": {"unique_id": "macro.dbt_snowflake.snowflake__alter_column_type", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__alter_column_type", "macro_sql": "{% macro snowflake__alter_column_type(relation, column_name, new_column_type) -%}\n {% call statement('alter_column_type') %}\n alter table {{ relation }} alter {{ adapter.quote(column_name) }} set data type {{ new_column_type }};\n {% endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.614269, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_relation_comment": {"unique_id": "macro.dbt_snowflake.snowflake__alter_relation_comment", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__alter_relation_comment", "macro_sql": "{% macro snowflake__alter_relation_comment(relation, relation_comment) -%}\n comment on {{ relation.type }} {{ relation }} IS $${{ relation_comment | replace('$', '[$]') }}$$;\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.614708, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_column_comment": {"unique_id": "macro.dbt_snowflake.snowflake__alter_column_comment", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__alter_column_comment", "macro_sql": "{% macro snowflake__alter_column_comment(relation, column_dict) -%}\n {% set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute=\"name\") | list %}\n alter {{ relation.type }} {{ relation }} alter\n {% for column_name in existing_columns if (column_name in existing_columns) or (column_name|lower in existing_columns) %}\n {{ get_column_comment_sql(column_name, column_dict) }} {{- ',' if not loop.last else ';' }}\n {% endfor %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.get_column_comment_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.61616, "supported_languages": null}, "macro.dbt_snowflake.get_current_query_tag": {"unique_id": "macro.dbt_snowflake.get_current_query_tag", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "get_current_query_tag", "macro_sql": "{% macro get_current_query_tag() -%}\n {{ return(run_query(\"show parameters like 'query_tag' in session\").rows[0]['value']) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.616524, "supported_languages": null}, "macro.dbt_snowflake.set_query_tag": {"unique_id": "macro.dbt_snowflake.set_query_tag", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "set_query_tag", "macro_sql": "{% macro set_query_tag() -%}\n {{ return(adapter.dispatch('set_query_tag', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__set_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.616849, "supported_languages": null}, "macro.dbt_snowflake.snowflake__set_query_tag": {"unique_id": "macro.dbt_snowflake.snowflake__set_query_tag", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__set_query_tag", "macro_sql": "{% macro snowflake__set_query_tag() -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% set original_query_tag = get_current_query_tag() %}\n {{ log(\"Setting query_tag to '\" ~ new_query_tag ~ \"'. Will reset to '\" ~ original_query_tag ~ \"' after materialization.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(new_query_tag)) %}\n {{ return(original_query_tag)}}\n {% endif %}\n {{ return(none)}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.get_current_query_tag", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.618006, "supported_languages": null}, "macro.dbt_snowflake.unset_query_tag": {"unique_id": "macro.dbt_snowflake.unset_query_tag", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "unset_query_tag", "macro_sql": "{% macro unset_query_tag(original_query_tag) -%}\n {{ return(adapter.dispatch('unset_query_tag', 'dbt')(original_query_tag)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6183639, "supported_languages": null}, "macro.dbt_snowflake.snowflake__unset_query_tag": {"unique_id": "macro.dbt_snowflake.snowflake__unset_query_tag", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__unset_query_tag", "macro_sql": "{% macro snowflake__unset_query_tag(original_query_tag) -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% if original_query_tag %}\n {{ log(\"Resetting query_tag to '\" ~ original_query_tag ~ \"'.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(original_query_tag)) %}\n {% else %}\n {{ log(\"No original query_tag, unsetting parameter.\") }}\n {% do run_query(\"alter session unset query_tag\") %}\n {% endif %}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.619274, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns": {"unique_id": "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__alter_relation_add_remove_columns", "macro_sql": "{% macro snowflake__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if add_columns %}\n\n {% set sql -%}\n alter {{ relation.type }} {{ relation }} add column\n {% for column in add_columns %}\n {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n {% endif %}\n\n {% if remove_columns %}\n\n {% set sql -%}\n alter {{ relation.type }} {{ relation }} drop column\n {% for column in remove_columns %}\n {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n {% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.621048, "supported_languages": null}, "macro.dbt_snowflake.snowflake_dml_explicit_transaction": {"unique_id": "macro.dbt_snowflake.snowflake_dml_explicit_transaction", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake_dml_explicit_transaction", "macro_sql": "{% macro snowflake_dml_explicit_transaction(dml) %}\n {#\n Use this macro to wrap all INSERT, MERGE, UPDATE, DELETE, and TRUNCATE\n statements before passing them into run_query(), or calling in the 'main' statement\n of a materialization\n #}\n {% set dml_transaction -%}\n begin;\n {{ dml }};\n commit;\n {%- endset %}\n\n {% do return(dml_transaction) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.621494, "supported_languages": null}, "macro.dbt_snowflake.snowflake__truncate_relation": {"unique_id": "macro.dbt_snowflake.snowflake__truncate_relation", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__truncate_relation", "macro_sql": "{% macro snowflake__truncate_relation(relation) -%}\n {% set truncate_dml %}\n truncate table {{ relation }}\n {% endset %}\n {% call statement('truncate_relation') -%}\n {{ snowflake_dml_explicit_transaction(truncate_dml) }}\n {%- endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.621997, "supported_languages": null}, "macro.dbt_snowflake.snowflake__copy_grants": {"unique_id": "macro.dbt_snowflake.snowflake__copy_grants", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/apply_grants.sql", "original_file_path": "macros/apply_grants.sql", "name": "snowflake__copy_grants", "macro_sql": "{% macro snowflake__copy_grants() %}\n {% set copy_grants = config.get('copy_grants', False) %}\n {{ return(copy_grants) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.622752, "supported_languages": null}, "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement": {"unique_id": "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/apply_grants.sql", "original_file_path": "macros/apply_grants.sql", "name": "snowflake__support_multiple_grantees_per_dcl_statement", "macro_sql": "\n\n{%- macro snowflake__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(False) }}\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.622993, "supported_languages": null}, "macro.dbt_snowflake.materialization_test_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_test_snowflake", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/test.sql", "original_file_path": "macros/materializations/test.sql", "name": "materialization_test_snowflake", "macro_sql": "{%- materialization test, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set relations = materialization_test_default() %}\n {% do unset_query_tag(original_query_tag) %}\n {{ return(relations) }}\n\n{%- endmaterialization -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_test_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.623832, "supported_languages": ["sql"]}, "macro.dbt_snowflake.snowflake__get_merge_sql": {"unique_id": "macro.dbt_snowflake.snowflake__get_merge_sql", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "name": "snowflake__get_merge_sql", "macro_sql": "{% macro snowflake__get_merge_sql(target, source_sql, unique_key, dest_columns, predicates) -%}\n\n {#\n Workaround for Snowflake not being happy with a merge on a constant-false predicate.\n When no unique_key is provided, this macro will do a regular insert. If a unique_key\n is provided, then this macro will do a proper merge instead.\n #}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute='name')) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {%- set dml -%}\n {%- if unique_key is none -%}\n\n {{ sql_header if sql_header is not none }}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source_sql }}\n )\n\n {%- else -%}\n\n {{ default__get_merge_sql(target, source_sql, unique_key, dest_columns, predicates) }}\n\n {%- endif -%}\n {%- endset -%}\n\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_quoted_csv", "macro.dbt.default__get_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.625925, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql": {"unique_id": "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "name": "snowflake__get_delete_insert_merge_sql", "macro_sql": "{% macro snowflake__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) %}\n {% set dml = default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_delete_insert_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.626452, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_merge_sql": {"unique_id": "macro.dbt_snowflake.snowflake__snapshot_merge_sql", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "name": "snowflake__snapshot_merge_sql", "macro_sql": "{% macro snowflake__snapshot_merge_sql(target, source, insert_cols) %}\n {% set dml = default__snapshot_merge_sql(target, source, insert_cols) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__snapshot_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.627031, "supported_languages": null}, "macro.dbt_snowflake.snowflake__load_csv_rows": {"unique_id": "macro.dbt_snowflake.snowflake__load_csv_rows", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/seed.sql", "original_file_path": "macros/materializations/seed.sql", "name": "snowflake__load_csv_rows", "macro_sql": "{% macro snowflake__load_csv_rows(model, agate_table) %}\n {% set batch_size = get_batch_size() %}\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n %s\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query('BEGIN', auto_begin=False) %}\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n {% do adapter.add_query('COMMIT', auto_begin=False) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_batch_size", "macro.dbt.get_seed_column_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6309109, "supported_languages": null}, "macro.dbt_snowflake.materialization_seed_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_seed_snowflake", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/seed.sql", "original_file_path": "macros/materializations/seed.sql", "name": "materialization_seed_snowflake", "macro_sql": "{% materialization seed, adapter='snowflake' %}\n {% set original_query_tag = set_query_tag() %}\n\n {% set relations = materialization_seed_default() %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return(relations) }}\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_seed_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.631773, "supported_languages": ["sql"]}, "macro.dbt_snowflake.materialization_view_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_view_snowflake", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/view.sql", "original_file_path": "macros/materializations/view.sql", "name": "materialization_view_snowflake", "macro_sql": "{% materialization view, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set to_return = create_or_replace_view() %}\n\n {% set target_relation = this.incorporate(type='view') %}\n\n {% do persist_docs(target_relation, model, for_columns=false) %}\n\n {% do return(to_return) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n{%- endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.create_or_replace_view", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6330292, "supported_languages": ["sql"]}, "macro.dbt_snowflake.materialization_table_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_table_snowflake", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "name": "materialization_table_snowflake", "macro_sql": "{% materialization table, adapter='snowflake', supported_languages=['sql', 'python']%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {%- set identifier = model['alias'] -%}\n {%- set language = model['language'] -%}\n\n {% set grant_config = config.get('grants') %}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set target_relation = api.Relation.create(identifier=identifier,\n schema=schema,\n database=database, type='table') -%}\n\n {{ run_hooks(pre_hooks) }}\n\n {#-- Drop the relation if it was a view to \"convert\" it in a table. This may lead to\n -- downtime, but it should be a relatively infrequent occurrence #}\n {% if old_relation is not none and not old_relation.is_table %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ drop_relation_if_exists(old_relation) }}\n {% endif %}\n\n {% call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall %}\n\n {{ run_hooks(post_hooks) }}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.create_table_as", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.637227, "supported_languages": ["sql", "python"]}, "macro.dbt_snowflake.py_write_table": {"unique_id": "macro.dbt_snowflake.py_write_table", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "name": "py_write_table", "macro_sql": "{% macro py_write_table(compiled_code, target_relation, temporary=False) %}\n{{ compiled_code }}\ndef materialize(session, df, target_relation):\n # make sure pandas exists\n import importlib.util\n package_name = 'pandas'\n if importlib.util.find_spec(package_name):\n import pandas\n if isinstance(df, pandas.core.frame.DataFrame):\n # session.write_pandas does not have overwrite function\n df = session.createDataFrame(df)\n df.write.mode(\"overwrite\").save_as_table(\"{{ target_relation }}\", create_temp_table={{temporary}})\n\ndef main(session):\n dbt = dbtObj(session.table)\n df = model(dbt, session)\n materialize(session, df, dbt.this)\n return \"OK\"\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6376371, "supported_languages": null}, "macro.dbt_snowflake.py_script_comment": {"unique_id": "macro.dbt_snowflake.py_script_comment", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "name": "py_script_comment", "macro_sql": "{%macro py_script_comment()%}\n# To run this in snowsight, you need to select entry point to be main\n# And you may have to modify the return type to text to get the result back\n# def main(session):\n# dbt = dbtObj(session.table)\n# df = model(dbt, session)\n# return df.collect()\n\n# to run this in local notebook, you need to create a session following examples https://github.com/Snowflake-Labs/sfguide-getting-started-snowpark-python\n# then you can do the following to run model\n# dbt = dbtObj(session.table)\n# df = model(dbt, session)\n{%endmacro%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.637831, "supported_languages": null}, "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type": {"unique_id": "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "name": "dbt_snowflake_get_tmp_relation_type", "macro_sql": "{% macro dbt_snowflake_get_tmp_relation_type(strategy, unique_key, language) %}\n\n /* {#\n If we are running multiple statements (DELETE + INSERT),\n we must first save the model query results as a temporary table\n in order to guarantee consistent inputs to both statements.\n\n If we are running a single statement (MERGE or INSERT alone),\n we can save the model query definition as a view instead,\n for faster overall incremental processing.\n #} */\n\n {% if language == 'sql' and (strategy in ('default', 'append', 'merge') or (unique_key is none)) %}\n {{ return('view') }}\n {% else %} {#-- play it safe -- #}\n {{ return('table') }}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.640065, "supported_languages": null}, "macro.dbt_snowflake.materialization_incremental_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_incremental_snowflake", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "name": "materialization_incremental_snowflake", "macro_sql": "{% materialization incremental, adapter='snowflake', supported_languages=['sql', 'python'] -%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {#-- Set vars --#}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n {%- set language = model['language'] -%}\n {% set target_relation = this %}\n {% set existing_relation = load_relation(this) %}\n\n {#-- The temp relation will be a view (faster) or temp table, depending on upsert/merge strategy --#}\n {%- set unique_key = config.get('unique_key') -%}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set tmp_relation_type = dbt_snowflake_get_tmp_relation_type(incremental_strategy, unique_key, language) %}\n {% set tmp_relation = make_temp_relation(this).incorporate(type=tmp_relation_type) %}\n\n {% set grant_config = config.get('grants') %}\n\n {% set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') %}\n\n {{ run_hooks(pre_hooks) }}\n\n {% if existing_relation is none %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n\n {% elif existing_relation.is_view %}\n {#-- Can't overwrite a view with a table - we must drop --#}\n {{ log(\"Dropping relation \" ~ target_relation ~ \" because it is a view and this model is a table.\") }}\n {% do adapter.drop_relation(existing_relation) %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n {% elif full_refresh_mode %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n\n {% else %}\n {#-- Create the temp relation, either as a view or as a temp table --#}\n {% if tmp_relation_type == 'view' %}\n {%- call statement('create_tmp_relation') -%}\n {{ create_view_as(tmp_relation, compiled_code) }}\n {%- endcall -%}\n {% else %}\n {%- call statement('create_tmp_relation', language=language) -%}\n {{ create_table_as(True, tmp_relation, compiled_code, language) }}\n {%- endcall -%}\n {% endif %}\n\n {% do adapter.expand_target_column_types(\n from_relation=tmp_relation,\n to_relation=target_relation) %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, tmp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_predicates = config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': tmp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'predicates': incremental_predicates }) %}\n\n {%- call statement('main') -%}\n {{ strategy_sql_macro_func(strategy_arg_dict) }}\n {%- endcall -%}\n {% endif %}\n\n {% do drop_relation_if_exists(tmp_relation) %}\n\n {{ run_hooks(post_hooks) }}\n\n {% set target_relation = target_relation.incorporate(type='table') %}\n\n {% set should_revoke =\n should_revoke(existing_relation.is_table, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.should_full_refresh", "macro.dbt.load_relation", "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type", "macro.dbt.make_temp_relation", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.create_table_as", "macro.dbt.create_view_as", "macro.dbt.process_schema_changes", "macro.dbt.drop_relation_if_exists", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.646296, "supported_languages": ["sql", "python"]}, "macro.dbt_snowflake.snowflake__get_incremental_default_sql": {"unique_id": "macro.dbt_snowflake.snowflake__get_incremental_default_sql", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "name": "snowflake__get_incremental_default_sql", "macro_sql": "{% macro snowflake__get_incremental_default_sql(arg_dict) %}\n {{ return(get_incremental_merge_sql(arg_dict)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_incremental_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.646614, "supported_languages": null}, "macro.dbt_snowflake.materialization_snapshot_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_snapshot_snowflake", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/snapshot.sql", "original_file_path": "macros/materializations/snapshot.sql", "name": "materialization_snapshot_snowflake", "macro_sql": "{% materialization snapshot, adapter='snowflake' %}\n {% set original_query_tag = set_query_tag() %}\n {% set relations = materialization_snapshot_default() %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return(relations) }}\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_snapshot_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6474218, "supported_languages": ["sql"]}, "macro.dbt_snowflake.snowflake__current_timestamp": {"unique_id": "macro.dbt_snowflake.snowflake__current_timestamp", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "name": "snowflake__current_timestamp", "macro_sql": "{% macro snowflake__current_timestamp() -%}\n convert_timezone('UTC', current_timestamp())\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.648055, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_string_as_time": {"unique_id": "macro.dbt_snowflake.snowflake__snapshot_string_as_time", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "name": "snowflake__snapshot_string_as_time", "macro_sql": "{% macro snowflake__snapshot_string_as_time(timestamp) -%}\n {%- set result = \"to_timestamp_ntz('\" ~ timestamp ~ \"')\" -%}\n {{ return(result) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.648465, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_get_time": {"unique_id": "macro.dbt_snowflake.snowflake__snapshot_get_time", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "name": "snowflake__snapshot_get_time", "macro_sql": "{% macro snowflake__snapshot_get_time() -%}\n to_timestamp_ntz({{ current_timestamp() }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.648683, "supported_languages": null}, "macro.dbt_snowflake.snowflake__current_timestamp_backcompat": {"unique_id": "macro.dbt_snowflake.snowflake__current_timestamp_backcompat", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "name": "snowflake__current_timestamp_backcompat", "macro_sql": "{% macro snowflake__current_timestamp_backcompat() %}\n current_timestamp::{{ type_timestamp() }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.648899, "supported_languages": null}, "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat": {"unique_id": "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "name": "snowflake__current_timestamp_in_utc_backcompat", "macro_sql": "{% macro snowflake__current_timestamp_in_utc_backcompat() %}\n convert_timezone('UTC', {{ snowflake__current_timestamp_backcompat() }})::{{ type_timestamp() }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_backcompat", "macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.649163, "supported_languages": null}, "macro.dbt_snowflake.snowflake__escape_single_quotes": {"unique_id": "macro.dbt_snowflake.snowflake__escape_single_quotes", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "name": "snowflake__escape_single_quotes", "macro_sql": "{% macro snowflake__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\", \"\\\\'\") }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.649709, "supported_languages": null}, "macro.dbt_snowflake.snowflake__right": {"unique_id": "macro.dbt_snowflake.snowflake__right", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "name": "snowflake__right", "macro_sql": "{% macro snowflake__right(string_text, length_expression) %}\n\n case when {{ length_expression }} = 0\n then ''\n else\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n end\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.650261, "supported_languages": null}, "macro.dbt_snowflake.snowflake__safe_cast": {"unique_id": "macro.dbt_snowflake.snowflake__safe_cast", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "name": "snowflake__safe_cast", "macro_sql": "{% macro snowflake__safe_cast(field, type) %}\n try_cast({{field}} as {{type}})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.650787, "supported_languages": null}, "macro.dbt_snowflake.snowflake__bool_or": {"unique_id": "macro.dbt_snowflake.snowflake__bool_or", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "name": "snowflake__bool_or", "macro_sql": "{% macro snowflake__bool_or(expression) -%}\n\n boolor_agg({{ expression }})\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6512, "supported_languages": null}, "macro.dbt_snowflake.snowflake__array_construct": {"unique_id": "macro.dbt_snowflake.snowflake__array_construct", "package_name": "dbt_snowflake", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "name": "snowflake__array_construct", "macro_sql": "{% macro snowflake__array_construct(inputs, data_type) -%}\n array_construct( {{ inputs|join(' , ') }} )\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.651686, "supported_languages": null}, "macro.dbt.run_hooks": {"unique_id": "macro.dbt.run_hooks", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "name": "run_hooks", "macro_sql": "{% macro run_hooks(hooks, inside_transaction=True) %}\n {% for hook in hooks | selectattr('transaction', 'equalto', inside_transaction) %}\n {% if not inside_transaction and loop.first %}\n {% call statement(auto_begin=inside_transaction) %}\n commit;\n {% endcall %}\n {% endif %}\n {% set rendered = render(hook.get('sql')) | trim %}\n {% if (rendered | length) > 0 %}\n {% call statement(auto_begin=inside_transaction) %}\n {{ rendered }}\n {% endcall %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.653774, "supported_languages": null}, "macro.dbt.make_hook_config": {"unique_id": "macro.dbt.make_hook_config", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "name": "make_hook_config", "macro_sql": "{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({\"sql\": sql, \"transaction\": inside_transaction}) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.654172, "supported_languages": null}, "macro.dbt.before_begin": {"unique_id": "macro.dbt.before_begin", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "name": "before_begin", "macro_sql": "{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6544662, "supported_languages": null}, "macro.dbt.in_transaction": {"unique_id": "macro.dbt.in_transaction", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "name": "in_transaction", "macro_sql": "{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6547499, "supported_languages": null}, "macro.dbt.after_commit": {"unique_id": "macro.dbt.after_commit", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "name": "after_commit", "macro_sql": "{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6550348, "supported_languages": null}, "macro.dbt.set_sql_header": {"unique_id": "macro.dbt.set_sql_header", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "name": "set_sql_header", "macro_sql": "{% macro set_sql_header(config) -%}\n {{ config.set('sql_header', caller()) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.655841, "supported_languages": null}, "macro.dbt.should_full_refresh": {"unique_id": "macro.dbt.should_full_refresh", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "name": "should_full_refresh", "macro_sql": "{% macro should_full_refresh() %}\n {% set config_full_refresh = config.get('full_refresh') %}\n {% if config_full_refresh is none %}\n {% set config_full_refresh = flags.FULL_REFRESH %}\n {% endif %}\n {% do return(config_full_refresh) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.656419, "supported_languages": null}, "macro.dbt.should_store_failures": {"unique_id": "macro.dbt.should_store_failures", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "name": "should_store_failures", "macro_sql": "{% macro should_store_failures() %}\n {% set config_store_failures = config.get('store_failures') %}\n {% if config_store_failures is none %}\n {% set config_store_failures = flags.STORE_FAILURES %}\n {% endif %}\n {% do return(config_store_failures) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.656993, "supported_languages": null}, "macro.dbt.snapshot_merge_sql": {"unique_id": "macro.dbt.snapshot_merge_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/snapshot_merge.sql", "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", "name": "snapshot_merge_sql", "macro_sql": "{% macro snapshot_merge_sql(target, source, insert_cols) -%}\n {{ adapter.dispatch('snapshot_merge_sql', 'dbt')(target, source, insert_cols) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.657896, "supported_languages": null}, "macro.dbt.default__snapshot_merge_sql": {"unique_id": "macro.dbt.default__snapshot_merge_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/snapshot_merge.sql", "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", "name": "default__snapshot_merge_sql", "macro_sql": "{% macro default__snapshot_merge_sql(target, source, insert_cols) -%}\n {%- set insert_cols_csv = insert_cols | join(', ') -%}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id\n\n when matched\n and DBT_INTERNAL_DEST.dbt_valid_to is null\n and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')\n then update\n set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to\n\n when not matched\n and DBT_INTERNAL_SOURCE.dbt_change_type = 'insert'\n then insert ({{ insert_cols_csv }})\n values ({{ insert_cols_csv }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.658412, "supported_languages": null}, "macro.dbt.strategy_dispatch": {"unique_id": "macro.dbt.strategy_dispatch", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "strategy_dispatch", "macro_sql": "{% macro strategy_dispatch(name) -%}\n{% set original_name = name %}\n {% if '.' in name %}\n {% set package_name, name = name.split(\".\", 1) %}\n {% else %}\n {% set package_name = none %}\n {% endif %}\n\n {% if package_name is none %}\n {% set package_context = context %}\n {% elif package_name in context %}\n {% set package_context = context[package_name] %}\n {% else %}\n {% set error_msg %}\n Could not find package '{{package_name}}', called with '{{original_name}}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n\n {%- set search_name = 'snapshot_' ~ name ~ '_strategy' -%}\n\n {% if search_name not in package_context %}\n {% set error_msg %}\n The specified strategy macro '{{name}}' was not found in package '{{ package_name }}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n {{ return(package_context[search_name]) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.664305, "supported_languages": null}, "macro.dbt.snapshot_hash_arguments": {"unique_id": "macro.dbt.snapshot_hash_arguments", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "snapshot_hash_arguments", "macro_sql": "{% macro snapshot_hash_arguments(args) -%}\n {{ adapter.dispatch('snapshot_hash_arguments', 'dbt')(args) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.66463, "supported_languages": null}, "macro.dbt.default__snapshot_hash_arguments": {"unique_id": "macro.dbt.default__snapshot_hash_arguments", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "default__snapshot_hash_arguments", "macro_sql": "{% macro default__snapshot_hash_arguments(args) -%}\n md5({%- for arg in args -%}\n coalesce(cast({{ arg }} as varchar ), '')\n {% if not loop.last %} || '|' || {% endif %}\n {%- endfor -%})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.665151, "supported_languages": null}, "macro.dbt.snapshot_timestamp_strategy": {"unique_id": "macro.dbt.snapshot_timestamp_strategy", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "snapshot_timestamp_strategy", "macro_sql": "{% macro snapshot_timestamp_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set primary_key = config['unique_key'] %}\n {% set updated_at = config['updated_at'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n\n {#/*\n The snapshot relation might not have an {{ updated_at }} value if the\n snapshot strategy is changed from `check` to `timestamp`. We\n should use a dbt-created column for the comparison in the snapshot\n table instead of assuming that the user-supplied {{ updated_at }}\n will be present in the historical data.\n\n See https://github.com/dbt-labs/dbt-core/issues/2350\n */ #}\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.dbt_valid_from < {{ current_rel }}.{{ updated_at }})\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6664488, "supported_languages": null}, "macro.dbt.snapshot_string_as_time": {"unique_id": "macro.dbt.snapshot_string_as_time", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "snapshot_string_as_time", "macro_sql": "{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter.dispatch('snapshot_string_as_time', 'dbt')(timestamp) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_string_as_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.66677, "supported_languages": null}, "macro.dbt.default__snapshot_string_as_time": {"unique_id": "macro.dbt.default__snapshot_string_as_time", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "default__snapshot_string_as_time", "macro_sql": "{% macro default__snapshot_string_as_time(timestamp) %}\n {% do exceptions.raise_not_implemented(\n 'snapshot_string_as_time macro not implemented for adapter '+adapter.type()\n ) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.667161, "supported_languages": null}, "macro.dbt.snapshot_check_all_get_existing_columns": {"unique_id": "macro.dbt.snapshot_check_all_get_existing_columns", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "snapshot_check_all_get_existing_columns", "macro_sql": "{% macro snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) -%}\n {%- if not target_exists -%}\n {#-- no table yet -> return whatever the query does --#}\n {{ return((false, query_columns)) }}\n {%- endif -%}\n\n {#-- handle any schema changes --#}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=node.alias) -%}\n\n {% if check_cols_config == 'all' %}\n {%- set query_columns = get_columns_in_query(node['compiled_code']) -%}\n\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {#-- query for proper casing/quoting, to support comparison below --#}\n {%- set select_check_cols_from_target -%}\n select {{ check_cols_config | join(', ') }} from ({{ node['compiled_code'] }}) subq\n {%- endset -%}\n {% set query_columns = get_columns_in_query(select_check_cols_from_target) %}\n\n {% else %}\n {% do exceptions.raise_compiler_error(\"Invalid value for 'check_cols': \" ~ check_cols_config) %}\n {% endif %}\n\n {%- set existing_cols = adapter.get_columns_in_relation(target_relation) | map(attribute = 'name') | list -%}\n {%- set ns = namespace() -%} {#-- handle for-loop scoping with a namespace --#}\n {%- set ns.column_added = false -%}\n\n {%- set intersection = [] -%}\n {%- for col in query_columns -%}\n {%- if col in existing_cols -%}\n {%- do intersection.append(adapter.quote(col)) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return((ns.column_added, intersection)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_columns_in_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.669649, "supported_languages": null}, "macro.dbt.snapshot_check_strategy": {"unique_id": "macro.dbt.snapshot_check_strategy", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "name": "snapshot_check_strategy", "macro_sql": "{% macro snapshot_check_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set check_cols_config = config['check_cols'] %}\n {% set primary_key = config['unique_key'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n {% set updated_at = config.get('updated_at', snapshot_get_time()) %}\n\n {% set column_added = false %}\n\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n {{ get_true_sql() }}\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n (\n (({{ snapshotted_rel }}.{{ col }} is null) and not ({{ current_rel }}.{{ col }} is null))\n or\n ((not {{ snapshotted_rel }}.{{ col }} is null) and ({{ current_rel }}.{{ col }} is null))\n )\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n {%- endif -%}\n )\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.snapshot_get_time", "macro.dbt.snapshot_check_all_get_existing_columns", "macro.dbt.get_true_sql", "macro.dbt.snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6721, "supported_languages": null}, "macro.dbt.create_columns": {"unique_id": "macro.dbt.create_columns", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "create_columns", "macro_sql": "{% macro create_columns(relation, columns) %}\n {{ adapter.dispatch('create_columns', 'dbt')(relation, columns) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__create_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.677804, "supported_languages": null}, "macro.dbt.default__create_columns": {"unique_id": "macro.dbt.default__create_columns", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "default__create_columns", "macro_sql": "{% macro default__create_columns(relation, columns) %}\n {% for column in columns %}\n {% call statement() %}\n alter table {{ relation }} add column \"{{ column.name }}\" {{ column.data_type }};\n {% endcall %}\n {% endfor %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.678359, "supported_languages": null}, "macro.dbt.post_snapshot": {"unique_id": "macro.dbt.post_snapshot", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "post_snapshot", "macro_sql": "{% macro post_snapshot(staging_relation) %}\n {{ adapter.dispatch('post_snapshot', 'dbt')(staging_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__post_snapshot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.67869, "supported_languages": null}, "macro.dbt.default__post_snapshot": {"unique_id": "macro.dbt.default__post_snapshot", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "default__post_snapshot", "macro_sql": "{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.678878, "supported_languages": null}, "macro.dbt.get_true_sql": {"unique_id": "macro.dbt.get_true_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "get_true_sql", "macro_sql": "{% macro get_true_sql() %}\n {{ adapter.dispatch('get_true_sql', 'dbt')() }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_true_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.679169, "supported_languages": null}, "macro.dbt.default__get_true_sql": {"unique_id": "macro.dbt.default__get_true_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "default__get_true_sql", "macro_sql": "{% macro default__get_true_sql() %}\n {{ return('TRUE') }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.679443, "supported_languages": null}, "macro.dbt.snapshot_staging_table": {"unique_id": "macro.dbt.snapshot_staging_table", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "snapshot_staging_table", "macro_sql": "{% macro snapshot_staging_table(strategy, source_sql, target_relation) -%}\n {{ adapter.dispatch('snapshot_staging_table', 'dbt')(strategy, source_sql, target_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__snapshot_staging_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.679884, "supported_languages": null}, "macro.dbt.default__snapshot_staging_table": {"unique_id": "macro.dbt.default__snapshot_staging_table", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "default__snapshot_staging_table", "macro_sql": "{% macro default__snapshot_staging_table(strategy, source_sql, target_relation) -%}\n\n with snapshot_query as (\n\n {{ source_sql }}\n\n ),\n\n snapshotted_data as (\n\n select *,\n {{ strategy.unique_key }} as dbt_unique_key\n\n from {{ target_relation }}\n where dbt_valid_to is null\n\n ),\n\n insertions_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to,\n {{ strategy.scd_id }} as dbt_scd_id\n\n from snapshot_query\n ),\n\n updates_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n {{ strategy.updated_at }} as dbt_valid_to\n\n from snapshot_query\n ),\n\n {%- if strategy.invalidate_hard_deletes %}\n\n deletes_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key\n from snapshot_query\n ),\n {% endif %}\n\n insertions as (\n\n select\n 'insert' as dbt_change_type,\n source_data.*\n\n from insertions_source_data as source_data\n left outer join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_unique_key is null\n or (\n snapshotted_data.dbt_unique_key is not null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n ),\n\n updates as (\n\n select\n 'update' as dbt_change_type,\n source_data.*,\n snapshotted_data.dbt_scd_id\n\n from updates_source_data as source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where (\n {{ strategy.row_changed }}\n )\n )\n\n {%- if strategy.invalidate_hard_deletes -%}\n ,\n\n deletes as (\n\n select\n 'delete' as dbt_change_type,\n source_data.*,\n {{ snapshot_get_time() }} as dbt_valid_from,\n {{ snapshot_get_time() }} as dbt_updated_at,\n {{ snapshot_get_time() }} as dbt_valid_to,\n snapshotted_data.dbt_scd_id\n\n from snapshotted_data\n left join deletes_source_data as source_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where source_data.dbt_unique_key is null\n )\n {%- endif %}\n\n select * from insertions\n union all\n select * from updates\n {%- if strategy.invalidate_hard_deletes %}\n union all\n select * from deletes\n {%- endif %}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.snapshot_get_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6815581, "supported_languages": null}, "macro.dbt.build_snapshot_table": {"unique_id": "macro.dbt.build_snapshot_table", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "build_snapshot_table", "macro_sql": "{% macro build_snapshot_table(strategy, sql) -%}\n {{ adapter.dispatch('build_snapshot_table', 'dbt')(strategy, sql) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__build_snapshot_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.681931, "supported_languages": null}, "macro.dbt.default__build_snapshot_table": {"unique_id": "macro.dbt.default__build_snapshot_table", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "default__build_snapshot_table", "macro_sql": "{% macro default__build_snapshot_table(strategy, sql) %}\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to\n from (\n {{ sql }}\n ) sbq\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.682414, "supported_languages": null}, "macro.dbt.build_snapshot_staging_table": {"unique_id": "macro.dbt.build_snapshot_staging_table", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "name": "build_snapshot_staging_table", "macro_sql": "{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set temp_relation = make_temp_relation(target_relation) %}\n\n {% set select = snapshot_staging_table(strategy, sql, target_relation) %}\n\n {% call statement('build_snapshot_staging_relation') %}\n {{ create_table_as(True, temp_relation, select) }}\n {% endcall %}\n\n {% do return(temp_relation) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.make_temp_relation", "macro.dbt.snapshot_staging_table", "macro.dbt.statement", "macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6832619, "supported_languages": null}, "macro.dbt.materialization_snapshot_default": {"unique_id": "macro.dbt.materialization_snapshot_default", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshots/snapshot.sql", "original_file_path": "macros/materializations/snapshots/snapshot.sql", "name": "materialization_snapshot_default", "macro_sql": "{% materialization snapshot, default %}\n {%- set config = model['config'] -%}\n\n {%- set target_table = model.get('alias', model.get('name')) -%}\n\n {%- set strategy_name = config.get('strategy') -%}\n {%- set unique_key = config.get('unique_key') %}\n -- grab current tables grants config for comparision later on\n {%- set grant_config = config.get('grants') -%}\n\n {% set target_relation_exists, target_relation = get_or_create_relation(\n database=model.database,\n schema=model.schema,\n identifier=target_table,\n type='table') -%}\n\n {%- if not target_relation.is_table -%}\n {% do exceptions.relation_wrong_type(target_relation, 'table') %}\n {%- endif -%}\n\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set strategy_macro = strategy_dispatch(strategy_name) %}\n {% set strategy = strategy_macro(model, \"snapshotted_data\", \"source_data\", config, target_relation_exists) %}\n\n {% if not target_relation_exists %}\n\n {% set build_sql = build_snapshot_table(strategy, model['compiled_code']) %}\n {% set final_sql = create_table_as(False, target_relation, build_sql) %}\n\n {% else %}\n\n {{ adapter.valid_snapshot_target(target_relation) }}\n\n {% set staging_table = build_snapshot_staging_table(strategy, sql, target_relation) %}\n\n -- this may no-op if the database does not require column expansion\n {% do adapter.expand_target_column_types(from_relation=staging_table,\n to_relation=target_relation) %}\n\n {% set missing_columns = adapter.get_missing_columns(staging_table, target_relation)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% do create_columns(target_relation, missing_columns) %}\n\n {% set source_columns = adapter.get_columns_in_relation(staging_table)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% set quoted_source_columns = [] %}\n {% for column in source_columns %}\n {% do quoted_source_columns.append(adapter.quote(column.name)) %}\n {% endfor %}\n\n {% set final_sql = snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n %}\n\n {% endif %}\n\n {% call statement('main') %}\n {{ final_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(target_relation_exists, full_refresh_mode=False) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if not target_relation_exists %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if staging_table is defined %}\n {% do post_snapshot(staging_table) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_or_create_relation", "macro.dbt.run_hooks", "macro.dbt.strategy_dispatch", "macro.dbt.build_snapshot_table", "macro.dbt.create_table_as", "macro.dbt.build_snapshot_staging_table", "macro.dbt.create_columns", "macro.dbt.snapshot_merge_sql", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes", "macro.dbt.post_snapshot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6927412, "supported_languages": ["sql"]}, "macro.dbt.materialization_test_default": {"unique_id": "macro.dbt.materialization_test_default", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/tests/test.sql", "original_file_path": "macros/materializations/tests/test.sql", "name": "materialization_test_default", "macro_sql": "{%- materialization test, default -%}\n\n {% set relations = [] %}\n\n {% if should_store_failures() %}\n\n {% set identifier = model['alias'] %}\n {% set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n {% set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database, type='table') -%} %}\n\n {% if old_relation %}\n {% do adapter.drop_relation(old_relation) %}\n {% endif %}\n\n {% call statement(auto_begin=True) %}\n {{ create_table_as(False, target_relation, sql) }}\n {% endcall %}\n\n {% do relations.append(target_relation) %}\n\n {% set main_sql %}\n select *\n from {{ target_relation }}\n {% endset %}\n\n {{ adapter.commit() }}\n\n {% else %}\n\n {% set main_sql = sql %}\n\n {% endif %}\n\n {% set limit = config.get('limit') %}\n {% set fail_calc = config.get('fail_calc') %}\n {% set warn_if = config.get('warn_if') %}\n {% set error_if = config.get('error_if') %}\n\n {% call statement('main', fetch_result=True) -%}\n\n {{ get_test_sql(main_sql, fail_calc, warn_if, error_if, limit)}}\n\n {%- endcall %}\n\n {{ return({'relations': relations}) }}\n\n{%- endmaterialization -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.should_store_failures", "macro.dbt.statement", "macro.dbt.create_table_as", "macro.dbt.get_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6964061, "supported_languages": ["sql"]}, "macro.dbt.get_test_sql": {"unique_id": "macro.dbt.get_test_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "name": "get_test_sql", "macro_sql": "{% macro get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n {{ adapter.dispatch('get_test_sql', 'dbt')(main_sql, fail_calc, warn_if, error_if, limit) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.6973388, "supported_languages": null}, "macro.dbt.default__get_test_sql": {"unique_id": "macro.dbt.default__get_test_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "name": "default__get_test_sql", "macro_sql": "{% macro default__get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n select\n {{ fail_calc }} as failures,\n {{ fail_calc }} {{ warn_if }} as should_warn,\n {{ fail_calc }} {{ error_if }} as should_error\n from (\n {{ main_sql }}\n {{ \"limit \" ~ limit if limit != none }}\n ) dbt_internal_test\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.697999, "supported_languages": null}, "macro.dbt.get_where_subquery": {"unique_id": "macro.dbt.get_where_subquery", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/tests/where_subquery.sql", "original_file_path": "macros/materializations/tests/where_subquery.sql", "name": "get_where_subquery", "macro_sql": "{% macro get_where_subquery(relation) -%}\n {% do return(adapter.dispatch('get_where_subquery', 'dbt')(relation)) %}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_where_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.698826, "supported_languages": null}, "macro.dbt.default__get_where_subquery": {"unique_id": "macro.dbt.default__get_where_subquery", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/tests/where_subquery.sql", "original_file_path": "macros/materializations/tests/where_subquery.sql", "name": "default__get_where_subquery", "macro_sql": "{% macro default__get_where_subquery(relation) -%}\n {% set where = config.get('where', '') %}\n {% if where %}\n {%- set filtered -%}\n (select * from {{ relation }} where {{ where }}) dbt_subquery\n {%- endset -%}\n {% do return(filtered) %}\n {%- else -%}\n {% do return(relation) %}\n {%- endif -%}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.699789, "supported_languages": null}, "macro.dbt.get_quoted_csv": {"unique_id": "macro.dbt.get_quoted_csv", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "name": "get_quoted_csv", "macro_sql": "{% macro get_quoted_csv(column_names) %}\n\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote(col)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.702353, "supported_languages": null}, "macro.dbt.diff_columns": {"unique_id": "macro.dbt.diff_columns", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "name": "diff_columns", "macro_sql": "{% macro diff_columns(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% set source_names = source_columns | map(attribute = 'column') | list %}\n {% set target_names = target_columns | map(attribute = 'column') | list %}\n\n {# --check whether the name attribute exists in the target - this does not perform a data type check #}\n {% for sc in source_columns %}\n {% if sc.name not in target_names %}\n {{ result.append(sc) }}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.703428, "supported_languages": null}, "macro.dbt.diff_column_data_types": {"unique_id": "macro.dbt.diff_column_data_types", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "name": "diff_column_data_types", "macro_sql": "{% macro diff_column_data_types(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% for sc in source_columns %}\n {% set tc = target_columns | selectattr(\"name\", \"equalto\", sc.name) | list | first %}\n {% if tc %}\n {% if sc.data_type != tc.data_type and not sc.can_expand_to(other_column=tc) %}\n {{ result.append( { 'column_name': tc.name, 'new_type': sc.data_type } ) }}\n {% endif %}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.704635, "supported_languages": null}, "macro.dbt.get_merge_update_columns": {"unique_id": "macro.dbt.get_merge_update_columns", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "name": "get_merge_update_columns", "macro_sql": "{% macro get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {{ return(adapter.dispatch('get_merge_update_columns', 'dbt')(merge_update_columns, merge_exclude_columns, dest_columns)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_merge_update_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.705076, "supported_languages": null}, "macro.dbt.default__get_merge_update_columns": {"unique_id": "macro.dbt.default__get_merge_update_columns", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "name": "default__get_merge_update_columns", "macro_sql": "{% macro default__get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {%- set default_cols = dest_columns | map(attribute=\"quoted\") | list -%}\n\n {%- if merge_update_columns and merge_exclude_columns -%}\n {{ exceptions.raise_compiler_error(\n 'Model cannot specify merge_update_columns and merge_exclude_columns. Please update model to use only one config'\n )}}\n {%- elif merge_update_columns -%}\n {%- set update_columns = merge_update_columns -%}\n {%- elif merge_exclude_columns -%}\n {%- set update_columns = [] -%}\n {%- for column in dest_columns -%}\n {% if column.column | lower not in merge_exclude_columns | map(\"lower\") | list %}\n {%- do update_columns.append(column.quoted) -%}\n {% endif %}\n {%- endfor -%}\n {%- else -%}\n {%- set update_columns = default_cols -%}\n {%- endif -%}\n\n {{ return(update_columns) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.706414, "supported_languages": null}, "macro.dbt.get_merge_sql": {"unique_id": "macro.dbt.get_merge_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "name": "get_merge_sql", "macro_sql": "{% macro get_merge_sql(target, source, unique_key, dest_columns, predicates=none) -%}\n {{ adapter.dispatch('get_merge_sql', 'dbt')(target, source, unique_key, dest_columns, predicates) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7122, "supported_languages": null}, "macro.dbt.default__get_merge_sql": {"unique_id": "macro.dbt.default__get_merge_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "name": "default__get_merge_sql", "macro_sql": "{% macro default__get_merge_sql(target, source, unique_key, dest_columns, predicates) -%}\n {%- set predicates = [] if predicates is none else [] + predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set merge_update_columns = config.get('merge_update_columns') -%}\n {%- set merge_exclude_columns = config.get('merge_exclude_columns') -%}\n {%- set update_columns = get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not mapping and unique_key is not string %}\n {% for key in unique_key %}\n {% set this_key_match %}\n DBT_INTERNAL_SOURCE.{{ key }} = DBT_INTERNAL_DEST.{{ key }}\n {% endset %}\n {% do predicates.append(this_key_match) %}\n {% endfor %}\n {% else %}\n {% set unique_key_match %}\n DBT_INTERNAL_SOURCE.{{ unique_key }} = DBT_INTERNAL_DEST.{{ unique_key }}\n {% endset %}\n {% do predicates.append(unique_key_match) %}\n {% endif %}\n {% else %}\n {% do predicates.append('FALSE') %}\n {% endif %}\n\n {{ sql_header if sql_header is not none }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on {{ predicates | join(' and ') }}\n\n {% if unique_key %}\n when matched then update set\n {% for column_name in update_columns -%}\n {{ column_name }} = DBT_INTERNAL_SOURCE.{{ column_name }}\n {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n {% endif %}\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_quoted_csv", "macro.dbt.get_merge_update_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.715334, "supported_languages": null}, "macro.dbt.get_delete_insert_merge_sql": {"unique_id": "macro.dbt.get_delete_insert_merge_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "name": "get_delete_insert_merge_sql", "macro_sql": "{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ adapter.dispatch('get_delete_insert_merge_sql', 'dbt')(target, source, unique_key, dest_columns) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.715778, "supported_languages": null}, "macro.dbt.default__get_delete_insert_merge_sql": {"unique_id": "macro.dbt.default__get_delete_insert_merge_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "name": "default__get_delete_insert_merge_sql", "macro_sql": "{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not string %}\n delete from {{target }}\n using {{ source }}\n where (\n {% for key in unique_key %}\n {{ source }}.{{ key }} = {{ target }}.{{ key }}\n {{ \"and \" if not loop.last }}\n {% endfor %}\n );\n {% else %}\n delete from {{ target }}\n where (\n {{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n );\n\n {% endif %}\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n )\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.717212, "supported_languages": null}, "macro.dbt.get_insert_overwrite_merge_sql": {"unique_id": "macro.dbt.get_insert_overwrite_merge_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "name": "get_insert_overwrite_merge_sql", "macro_sql": "{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header=false) -%}\n {{ adapter.dispatch('get_insert_overwrite_merge_sql', 'dbt')(target, source, dest_columns, predicates, include_sql_header) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_insert_overwrite_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7177112, "supported_languages": null}, "macro.dbt.default__get_insert_overwrite_merge_sql": {"unique_id": "macro.dbt.default__get_insert_overwrite_merge_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "name": "default__get_insert_overwrite_merge_sql", "macro_sql": "{% macro default__get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header) -%}\n {#-- The only time include_sql_header is True: --#}\n {#-- BigQuery + insert_overwrite strategy + \"static\" partitions config --#}\n {#-- We should consider including the sql header at the materialization level instead --#}\n\n {%- set predicates = [] if predicates is none else [] + predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none and include_sql_header }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on FALSE\n\n when not matched by source\n {% if predicates %} and {{ predicates | join(' and ') }} {% endif %}\n then delete\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7188969, "supported_languages": null}, "macro.dbt.is_incremental": {"unique_id": "macro.dbt.is_incremental", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/is_incremental.sql", "original_file_path": "macros/materializations/models/incremental/is_incremental.sql", "name": "is_incremental", "macro_sql": "{% macro is_incremental() %}\n {#-- do not run introspective queries in parsing #}\n {% if not execute %}\n {{ return(False) }}\n {% else %}\n {% set relation = adapter.get_relation(this.database, this.schema, this.table) %}\n {{ return(relation is not none\n and relation.type == 'table'\n and model.config.materialized == 'incremental'\n and not should_full_refresh()) }}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.should_full_refresh"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7201338, "supported_languages": null}, "macro.dbt.get_incremental_append_sql": {"unique_id": "macro.dbt.get_incremental_append_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "get_incremental_append_sql", "macro_sql": "{% macro get_incremental_append_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_append_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_incremental_append_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.721643, "supported_languages": null}, "macro.dbt.default__get_incremental_append_sql": {"unique_id": "macro.dbt.default__get_incremental_append_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "default__get_incremental_append_sql", "macro_sql": "{% macro default__get_incremental_append_sql(arg_dict) %}\n\n {% do return(get_insert_into_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_insert_into_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7220962, "supported_languages": null}, "macro.dbt.get_incremental_delete_insert_sql": {"unique_id": "macro.dbt.get_incremental_delete_insert_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "get_incremental_delete_insert_sql", "macro_sql": "{% macro get_incremental_delete_insert_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_delete_insert_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_incremental_delete_insert_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7224581, "supported_languages": null}, "macro.dbt.default__get_incremental_delete_insert_sql": {"unique_id": "macro.dbt.default__get_incremental_delete_insert_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "default__get_incremental_delete_insert_sql", "macro_sql": "{% macro default__get_incremental_delete_insert_sql(arg_dict) %}\n\n {% do return(get_delete_insert_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_delete_insert_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7229528, "supported_languages": null}, "macro.dbt.get_incremental_merge_sql": {"unique_id": "macro.dbt.get_incremental_merge_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "get_incremental_merge_sql", "macro_sql": "{% macro get_incremental_merge_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_merge_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_incremental_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7233129, "supported_languages": null}, "macro.dbt.default__get_incremental_merge_sql": {"unique_id": "macro.dbt.default__get_incremental_merge_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "default__get_incremental_merge_sql", "macro_sql": "{% macro default__get_incremental_merge_sql(arg_dict) %}\n\n {% do return(get_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.723837, "supported_languages": null}, "macro.dbt.get_incremental_insert_overwrite_sql": {"unique_id": "macro.dbt.get_incremental_insert_overwrite_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "get_incremental_insert_overwrite_sql", "macro_sql": "{% macro get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_insert_overwrite_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_incremental_insert_overwrite_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.724239, "supported_languages": null}, "macro.dbt.default__get_incremental_insert_overwrite_sql": {"unique_id": "macro.dbt.default__get_incremental_insert_overwrite_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "default__get_incremental_insert_overwrite_sql", "macro_sql": "{% macro default__get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {% do return(get_insert_overwrite_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"], arg_dict[\"predicates\"])) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_insert_overwrite_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.724734, "supported_languages": null}, "macro.dbt.get_incremental_default_sql": {"unique_id": "macro.dbt.get_incremental_default_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "get_incremental_default_sql", "macro_sql": "{% macro get_incremental_default_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_default_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_incremental_default_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7251992, "supported_languages": null}, "macro.dbt.default__get_incremental_default_sql": {"unique_id": "macro.dbt.default__get_incremental_default_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "default__get_incremental_default_sql", "macro_sql": "{% macro default__get_incremental_default_sql(arg_dict) %}\n\n {% do return(get_incremental_append_sql(arg_dict)) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_incremental_append_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.725497, "supported_languages": null}, "macro.dbt.get_insert_into_sql": {"unique_id": "macro.dbt.get_insert_into_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "name": "get_insert_into_sql", "macro_sql": "{% macro get_insert_into_sql(target_relation, temp_relation, dest_columns) %}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n insert into {{ target_relation }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ temp_relation }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.726212, "supported_languages": null}, "macro.dbt.materialization_incremental_default": {"unique_id": "macro.dbt.materialization_incremental_default", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/incremental.sql", "original_file_path": "macros/materializations/models/incremental/incremental.sql", "name": "materialization_incremental_default", "macro_sql": "{% materialization incremental, default -%}\n\n -- relations\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set temp_relation = make_temp_relation(target_relation)-%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation)-%}\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n\n -- configs\n {%- set unique_key = config.get('unique_key') -%}\n {%- set full_refresh_mode = (should_full_refresh() or existing_relation.is_view) -%}\n {%- set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') -%}\n\n -- the temp_ and backup_ relations should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation. This has to happen before\n -- BEGIN, in a separate transaction\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation)-%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set to_drop = [] %}\n\n {% if existing_relation is none %}\n {% set build_sql = get_create_table_as_sql(False, target_relation, sql) %}\n {% elif full_refresh_mode %}\n {% set build_sql = get_create_table_as_sql(False, intermediate_relation, sql) %}\n {% set need_swap = true %}\n {% else %}\n {% do run_query(get_create_table_as_sql(True, temp_relation, sql)) %}\n {% do adapter.expand_target_column_types(\n from_relation=temp_relation,\n to_relation=target_relation) %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, temp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set incremental_predicates = config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': temp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'predicates': incremental_predicates }) %}\n {% set build_sql = strategy_sql_macro_func(strategy_arg_dict) %}\n\n {% endif %}\n\n {% call statement(\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% if need_swap %}\n {% do adapter.rename_relation(target_relation, backup_relation) %}\n {% do adapter.rename_relation(intermediate_relation, target_relation) %}\n {% do to_drop.append(backup_relation) %}\n {% endif %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if existing_relation is none or existing_relation.is_view or should_full_refresh() %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {% do adapter.commit() %}\n\n {% for rel in to_drop %}\n {% do adapter.drop_relation(rel) %}\n {% endfor %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_temp_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.should_full_refresh", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.get_create_table_as_sql", "macro.dbt.run_query", "macro.dbt.process_schema_changes", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7356522, "supported_languages": ["sql"]}, "macro.dbt.incremental_validate_on_schema_change": {"unique_id": "macro.dbt.incremental_validate_on_schema_change", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "name": "incremental_validate_on_schema_change", "macro_sql": "{% macro incremental_validate_on_schema_change(on_schema_change, default='ignore') %}\n\n {% if on_schema_change not in ['sync_all_columns', 'append_new_columns', 'fail', 'ignore'] %}\n\n {% set log_message = 'Invalid value for on_schema_change (%s) specified. Setting default value of %s.' % (on_schema_change, default) %}\n {% do log(log_message) %}\n\n {{ return(default) }}\n\n {% else %}\n\n {{ return(on_schema_change) }}\n\n {% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.742762, "supported_languages": null}, "macro.dbt.check_for_schema_changes": {"unique_id": "macro.dbt.check_for_schema_changes", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "name": "check_for_schema_changes", "macro_sql": "{% macro check_for_schema_changes(source_relation, target_relation) %}\n\n {% set schema_changed = False %}\n\n {%- set source_columns = adapter.get_columns_in_relation(source_relation) -%}\n {%- set target_columns = adapter.get_columns_in_relation(target_relation) -%}\n {%- set source_not_in_target = diff_columns(source_columns, target_columns) -%}\n {%- set target_not_in_source = diff_columns(target_columns, source_columns) -%}\n\n {% set new_target_types = diff_column_data_types(source_columns, target_columns) %}\n\n {% if source_not_in_target != [] %}\n {% set schema_changed = True %}\n {% elif target_not_in_source != [] or new_target_types != [] %}\n {% set schema_changed = True %}\n {% elif new_target_types != [] %}\n {% set schema_changed = True %}\n {% endif %}\n\n {% set changes_dict = {\n 'schema_changed': schema_changed,\n 'source_not_in_target': source_not_in_target,\n 'target_not_in_source': target_not_in_source,\n 'source_columns': source_columns,\n 'target_columns': target_columns,\n 'new_target_types': new_target_types\n } %}\n\n {% set msg %}\n In {{ target_relation }}:\n Schema changed: {{ schema_changed }}\n Source columns not in target: {{ source_not_in_target }}\n Target columns not in source: {{ target_not_in_source }}\n New column types: {{ new_target_types }}\n {% endset %}\n\n {% do log(msg) %}\n\n {{ return(changes_dict) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.diff_columns", "macro.dbt.diff_column_data_types"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7449028, "supported_languages": null}, "macro.dbt.sync_column_schemas": {"unique_id": "macro.dbt.sync_column_schemas", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "name": "sync_column_schemas", "macro_sql": "{% macro sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {%- set add_to_target_arr = schema_changes_dict['source_not_in_target'] -%}\n\n {%- if on_schema_change == 'append_new_columns'-%}\n {%- if add_to_target_arr | length > 0 -%}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, none) -%}\n {%- endif -%}\n\n {% elif on_schema_change == 'sync_all_columns' %}\n {%- set remove_from_target_arr = schema_changes_dict['target_not_in_source'] -%}\n {%- set new_target_types = schema_changes_dict['new_target_types'] -%}\n\n {% if add_to_target_arr | length > 0 or remove_from_target_arr | length > 0 %}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, remove_from_target_arr) -%}\n {% endif %}\n\n {% if new_target_types != [] %}\n {% for ntt in new_target_types %}\n {% set column_name = ntt['column_name'] %}\n {% set new_type = ntt['new_type'] %}\n {% do alter_column_type(target_relation, column_name, new_type) %}\n {% endfor %}\n {% endif %}\n\n {% endif %}\n\n {% set schema_change_message %}\n In {{ target_relation }}:\n Schema change approach: {{ on_schema_change }}\n Columns added: {{ add_to_target_arr }}\n Columns removed: {{ remove_from_target_arr }}\n Data types changed: {{ new_target_types }}\n {% endset %}\n\n {% do log(schema_change_message) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.alter_relation_add_remove_columns", "macro.dbt.alter_column_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.747118, "supported_languages": null}, "macro.dbt.process_schema_changes": {"unique_id": "macro.dbt.process_schema_changes", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "name": "process_schema_changes", "macro_sql": "{% macro process_schema_changes(on_schema_change, source_relation, target_relation) %}\n\n {% if on_schema_change == 'ignore' %}\n\n {{ return({}) }}\n\n {% else %}\n\n {% set schema_changes_dict = check_for_schema_changes(source_relation, target_relation) %}\n\n {% if schema_changes_dict['schema_changed'] %}\n\n {% if on_schema_change == 'fail' %}\n\n {% set fail_msg %}\n The source and target schemas on this incremental model are out of sync!\n They can be reconciled in several ways:\n - set the `on_schema_change` config to either append_new_columns or sync_all_columns, depending on your situation.\n - Re-run the incremental model with `full_refresh: True` to update the target schema.\n - update the schema manually and re-run the process.\n\n Additional troubleshooting context:\n Source columns not in target: {{ schema_changes_dict['source_not_in_target'] }}\n Target columns not in source: {{ schema_changes_dict['target_not_in_source'] }}\n New column types: {{ schema_changes_dict['new_target_types'] }}\n {% endset %}\n\n {% do exceptions.raise_compiler_error(fail_msg) %}\n\n {# -- unless we ignore, run the sync operation per the config #}\n {% else %}\n\n {% do sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {% endif %}\n\n {% endif %}\n\n {{ return(schema_changes_dict['source_columns']) }}\n\n {% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.check_for_schema_changes", "macro.dbt.sync_column_schemas"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.748754, "supported_languages": null}, "macro.dbt.materialization_table_default": {"unique_id": "macro.dbt.materialization_table_default", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/table/table.sql", "original_file_path": "macros/materializations/models/table/table.sql", "name": "materialization_table_default", "macro_sql": "{% materialization table, default %}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n See ../view/view.sql for more information about this relation.\n */\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% do create_indexes(target_relation) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n -- finally, drop the existing/backup relation after the commit\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt.create_indexes", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.753025, "supported_languages": ["sql"]}, "macro.dbt.get_create_table_as_sql": {"unique_id": "macro.dbt.get_create_table_as_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/table/create_table_as.sql", "original_file_path": "macros/materializations/models/table/create_table_as.sql", "name": "get_create_table_as_sql", "macro_sql": "{% macro get_create_table_as_sql(temporary, relation, sql) -%}\n {{ adapter.dispatch('get_create_table_as_sql', 'dbt')(temporary, relation, sql) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_create_table_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.75397, "supported_languages": null}, "macro.dbt.default__get_create_table_as_sql": {"unique_id": "macro.dbt.default__get_create_table_as_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/table/create_table_as.sql", "original_file_path": "macros/materializations/models/table/create_table_as.sql", "name": "default__get_create_table_as_sql", "macro_sql": "{% macro default__get_create_table_as_sql(temporary, relation, sql) -%}\n {{ return(create_table_as(temporary, relation, sql)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7543108, "supported_languages": null}, "macro.dbt.create_table_as": {"unique_id": "macro.dbt.create_table_as", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/table/create_table_as.sql", "original_file_path": "macros/materializations/models/table/create_table_as.sql", "name": "create_table_as", "macro_sql": "{% macro create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {# backward compatibility for create_table_as that does not support language #}\n {% if language == \"sql\" %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code)}}\n {% else %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code, language) }}\n {% endif %}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7551968, "supported_languages": null}, "macro.dbt.default__create_table_as": {"unique_id": "macro.dbt.default__create_table_as", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/table/create_table_as.sql", "original_file_path": "macros/materializations/models/table/create_table_as.sql", "name": "default__create_table_as", "macro_sql": "{% macro default__create_table_as(temporary, relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary: -%}temporary{%- endif %} table\n {{ relation.include(database=(not temporary), schema=(not temporary)) }}\n as (\n {{ sql }}\n );\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7559402, "supported_languages": null}, "macro.dbt.materialization_view_default": {"unique_id": "macro.dbt.materialization_view_default", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/view.sql", "original_file_path": "macros/materializations/models/view/view.sql", "name": "materialization_view_default", "macro_sql": "{%- materialization view, default -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='view') -%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n This relation (probably) doesn't exist yet. If it does exist, it's a leftover from\n a previous run, and we're going to try to drop it immediately. At the end of this\n materialization, we're going to rename the \"existing_relation\" to this identifier,\n and then we're going to drop it. In order to make sure we run the correct one of:\n - drop view ...\n - drop table ...\n\n We need to set the type of this relation to be the type of the existing_relation, if it exists,\n or else \"view\" as a sane default if it does not. Note that if the existing_relation does not\n exist, then there is nothing to move out of the way and subsequentally drop. In that case,\n this relation will be effectively unused.\n */\n {%- set backup_relation_type = 'view' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n -- move the existing view out of the way\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.760211, "supported_languages": ["sql"]}, "macro.dbt.handle_existing_table": {"unique_id": "macro.dbt.handle_existing_table", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/helpers.sql", "original_file_path": "macros/materializations/models/view/helpers.sql", "name": "handle_existing_table", "macro_sql": "{% macro handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.dispatch('handle_existing_table', 'dbt')(full_refresh, old_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__handle_existing_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7608662, "supported_languages": null}, "macro.dbt.default__handle_existing_table": {"unique_id": "macro.dbt.default__handle_existing_table", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/helpers.sql", "original_file_path": "macros/materializations/models/view/helpers.sql", "name": "default__handle_existing_table", "macro_sql": "{% macro default__handle_existing_table(full_refresh, old_relation) %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ adapter.drop_relation(old_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7613199, "supported_languages": null}, "macro.dbt.create_or_replace_view": {"unique_id": "macro.dbt.create_or_replace_view", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/create_or_replace_view.sql", "original_file_path": "macros/materializations/models/view/create_or_replace_view.sql", "name": "create_or_replace_view", "macro_sql": "{% macro create_or_replace_view() %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database,\n type='view') -%}\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks) }}\n\n -- If there's a table with the same name and we weren't told to full refresh,\n -- that's an error. If we were told to full refresh, drop it. This behavior differs\n -- for Snowflake and BigQuery, so multiple dispatch is used.\n {%- if old_relation is not none and old_relation.is_table -%}\n {{ handle_existing_table(should_full_refresh(), old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n\n {% set should_revoke = should_revoke(exists_as_view, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=True) %}\n\n {{ run_hooks(post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.handle_existing_table", "macro.dbt.should_full_refresh", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.764139, "supported_languages": null}, "macro.dbt.get_create_view_as_sql": {"unique_id": "macro.dbt.get_create_view_as_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/create_view_as.sql", "original_file_path": "macros/materializations/models/view/create_view_as.sql", "name": "get_create_view_as_sql", "macro_sql": "{% macro get_create_view_as_sql(relation, sql) -%}\n {{ adapter.dispatch('get_create_view_as_sql', 'dbt')(relation, sql) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_create_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.765134, "supported_languages": null}, "macro.dbt.default__get_create_view_as_sql": {"unique_id": "macro.dbt.default__get_create_view_as_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/create_view_as.sql", "original_file_path": "macros/materializations/models/view/create_view_as.sql", "name": "default__get_create_view_as_sql", "macro_sql": "{% macro default__get_create_view_as_sql(relation, sql) -%}\n {{ return(create_view_as(relation, sql)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.76544, "supported_languages": null}, "macro.dbt.create_view_as": {"unique_id": "macro.dbt.create_view_as", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/create_view_as.sql", "original_file_path": "macros/materializations/models/view/create_view_as.sql", "name": "create_view_as", "macro_sql": "{% macro create_view_as(relation, sql) -%}\n {{ adapter.dispatch('create_view_as', 'dbt')(relation, sql) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.765784, "supported_languages": null}, "macro.dbt.default__create_view_as": {"unique_id": "macro.dbt.default__create_view_as", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/models/view/create_view_as.sql", "original_file_path": "macros/materializations/models/view/create_view_as.sql", "name": "default__create_view_as", "macro_sql": "{% macro default__create_view_as(relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create view {{ relation }} as (\n {{ sql }}\n );\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7662652, "supported_languages": null}, "macro.dbt.materialization_seed_default": {"unique_id": "macro.dbt.materialization_seed_default", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/seed.sql", "original_file_path": "macros/materializations/seeds/seed.sql", "name": "materialization_seed_default", "macro_sql": "{% materialization seed, default %}\n\n {%- set identifier = model['alias'] -%}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\n {%- set exists_as_table = (old_relation is not none and old_relation.is_table) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set grant_config = config.get('grants') -%}\n {%- set agate_table = load_agate_table() -%}\n -- grab current tables grants config for comparision later on\n\n {%- do store_result('agate_table', response='OK', agate_table=agate_table) -%}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% set create_table_sql = \"\" %}\n {% if exists_as_view %}\n {{ exceptions.raise_compiler_error(\"Cannot seed to '{}', it is a view\".format(old_relation)) }}\n {% elif exists_as_table %}\n {% set create_table_sql = reset_csv_table(model, full_refresh_mode, old_relation, agate_table) %}\n {% else %}\n {% set create_table_sql = create_csv_table(model, agate_table) %}\n {% endif %}\n\n {% set code = 'CREATE' if full_refresh_mode else 'INSERT' %}\n {% set rows_affected = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement('main', code ~ ' ' ~ rows_affected, code, rows_affected) %}\n {{ get_csv_sql(create_table_sql, sql) }};\n {% endcall %}\n\n {% set target_relation = this.incorporate(type='table') %}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if full_refresh_mode or not exists_as_table %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.run_hooks", "macro.dbt.reset_csv_table", "macro.dbt.create_csv_table", "macro.dbt.load_csv_rows", "macro.dbt.noop_statement", "macro.dbt.get_csv_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.771811, "supported_languages": ["sql"]}, "macro.dbt.create_csv_table": {"unique_id": "macro.dbt.create_csv_table", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "create_csv_table", "macro_sql": "{% macro create_csv_table(model, agate_table) -%}\n {{ adapter.dispatch('create_csv_table', 'dbt')(model, agate_table) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__create_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.778583, "supported_languages": null}, "macro.dbt.default__create_csv_table": {"unique_id": "macro.dbt.default__create_csv_table", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "default__create_csv_table", "macro_sql": "{% macro default__create_csv_table(model, agate_table) %}\n {%- set column_override = model['config'].get('column_types', {}) -%}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n\n {% set sql %}\n create table {{ this.render() }} (\n {%- for col_name in agate_table.column_names -%}\n {%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}\n {%- set type = column_override.get(col_name, inferred_type) -%}\n {%- set column_name = (col_name | string) -%}\n {{ adapter.quote_seed_column(column_name, quote_seed_column) }} {{ type }} {%- if not loop.last -%}, {%- endif -%}\n {%- endfor -%}\n )\n {% endset %}\n\n {% call statement('_') -%}\n {{ sql }}\n {%- endcall %}\n\n {{ return(sql) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7803679, "supported_languages": null}, "macro.dbt.reset_csv_table": {"unique_id": "macro.dbt.reset_csv_table", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "reset_csv_table", "macro_sql": "{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter.dispatch('reset_csv_table', 'dbt')(model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__reset_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7807932, "supported_languages": null}, "macro.dbt.default__reset_csv_table": {"unique_id": "macro.dbt.default__reset_csv_table", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "default__reset_csv_table", "macro_sql": "{% macro default__reset_csv_table(model, full_refresh, old_relation, agate_table) %}\n {% set sql = \"\" %}\n {% if full_refresh %}\n {{ adapter.drop_relation(old_relation) }}\n {% set sql = create_csv_table(model, agate_table) %}\n {% else %}\n {{ adapter.truncate_relation(old_relation) }}\n {% set sql = \"truncate table \" ~ old_relation %}\n {% endif %}\n\n {{ return(sql) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.create_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7820008, "supported_languages": null}, "macro.dbt.get_csv_sql": {"unique_id": "macro.dbt.get_csv_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "get_csv_sql", "macro_sql": "{% macro get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ adapter.dispatch('get_csv_sql', 'dbt')(create_or_truncate_sql, insert_sql) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_csv_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7823622, "supported_languages": null}, "macro.dbt.default__get_csv_sql": {"unique_id": "macro.dbt.default__get_csv_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "default__get_csv_sql", "macro_sql": "{% macro default__get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ create_or_truncate_sql }};\n -- dbt seed --\n {{ insert_sql }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.78262, "supported_languages": null}, "macro.dbt.get_binding_char": {"unique_id": "macro.dbt.get_binding_char", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "get_binding_char", "macro_sql": "{% macro get_binding_char() -%}\n {{ adapter.dispatch('get_binding_char', 'dbt')() }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_binding_char"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.782889, "supported_languages": null}, "macro.dbt.default__get_binding_char": {"unique_id": "macro.dbt.default__get_binding_char", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "default__get_binding_char", "macro_sql": "{% macro default__get_binding_char() %}\n {{ return('%s') }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7831192, "supported_languages": null}, "macro.dbt.get_batch_size": {"unique_id": "macro.dbt.get_batch_size", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "get_batch_size", "macro_sql": "{% macro get_batch_size() -%}\n {{ return(adapter.dispatch('get_batch_size', 'dbt')()) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_batch_size"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7834198, "supported_languages": null}, "macro.dbt.default__get_batch_size": {"unique_id": "macro.dbt.default__get_batch_size", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "default__get_batch_size", "macro_sql": "{% macro default__get_batch_size() %}\n {{ return(10000) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7836502, "supported_languages": null}, "macro.dbt.get_seed_column_quoted_csv": {"unique_id": "macro.dbt.get_seed_column_quoted_csv", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "get_seed_column_quoted_csv", "macro_sql": "{% macro get_seed_column_quoted_csv(model, column_names) %}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote_seed_column(col, quote_seed_column)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.784548, "supported_languages": null}, "macro.dbt.load_csv_rows": {"unique_id": "macro.dbt.load_csv_rows", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "load_csv_rows", "macro_sql": "{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter.dispatch('load_csv_rows', 'dbt')(model, agate_table) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__load_csv_rows"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.784894, "supported_languages": null}, "macro.dbt.default__load_csv_rows": {"unique_id": "macro.dbt.default__load_csv_rows", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "name": "default__load_csv_rows", "macro_sql": "{% macro default__load_csv_rows(model, agate_table) %}\n\n {% set batch_size = get_batch_size() %}\n\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n {{ get_binding_char() }}\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_batch_size", "macro.dbt.get_seed_column_quoted_csv", "macro.dbt.get_binding_char"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.787135, "supported_languages": null}, "macro.dbt.generate_alias_name": {"unique_id": "macro.dbt.generate_alias_name", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/get_custom_name/get_custom_alias.sql", "original_file_path": "macros/get_custom_name/get_custom_alias.sql", "name": "generate_alias_name", "macro_sql": "{% macro generate_alias_name(custom_alias_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_alias_name', 'dbt')(custom_alias_name, node)) %}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__generate_alias_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.78793, "supported_languages": null}, "macro.dbt.default__generate_alias_name": {"unique_id": "macro.dbt.default__generate_alias_name", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/get_custom_name/get_custom_alias.sql", "original_file_path": "macros/get_custom_name/get_custom_alias.sql", "name": "default__generate_alias_name", "macro_sql": "{% macro default__generate_alias_name(custom_alias_name=none, node=none) -%}\n\n {%- if custom_alias_name is none -%}\n\n {{ node.name }}\n\n {%- else -%}\n\n {{ custom_alias_name | trim }}\n\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.788358, "supported_languages": null}, "macro.dbt.generate_schema_name": {"unique_id": "macro.dbt.generate_schema_name", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "name": "generate_schema_name", "macro_sql": "{% macro generate_schema_name(custom_schema_name=none, node=none) -%}\n {{ return(adapter.dispatch('generate_schema_name', 'dbt')(custom_schema_name, node)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__generate_schema_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.789727, "supported_languages": null}, "macro.dbt.default__generate_schema_name": {"unique_id": "macro.dbt.default__generate_schema_name", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "name": "default__generate_schema_name", "macro_sql": "{% macro default__generate_schema_name(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if custom_schema_name is none -%}\n\n {{ default_schema }}\n\n {%- else -%}\n\n {{ default_schema }}_{{ custom_schema_name | trim }}\n\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7907572, "supported_languages": null}, "macro.dbt.generate_schema_name_for_env": {"unique_id": "macro.dbt.generate_schema_name_for_env", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "name": "generate_schema_name_for_env", "macro_sql": "{% macro generate_schema_name_for_env(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if target.name == 'prod' and custom_schema_name is not none -%}\n\n {{ custom_schema_name | trim }}\n\n {%- else -%}\n\n {{ default_schema }}\n\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7913542, "supported_languages": null}, "macro.dbt.generate_database_name": {"unique_id": "macro.dbt.generate_database_name", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/get_custom_name/get_custom_database.sql", "original_file_path": "macros/get_custom_name/get_custom_database.sql", "name": "generate_database_name", "macro_sql": "{% macro generate_database_name(custom_database_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_database_name', 'dbt')(custom_database_name, node)) %}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__generate_database_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.792145, "supported_languages": null}, "macro.dbt.default__generate_database_name": {"unique_id": "macro.dbt.default__generate_database_name", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/get_custom_name/get_custom_database.sql", "original_file_path": "macros/get_custom_name/get_custom_database.sql", "name": "default__generate_database_name", "macro_sql": "{% macro default__generate_database_name(custom_database_name=none, node=none) -%}\n {%- set default_database = target.database -%}\n {%- if custom_database_name is none -%}\n\n {{ default_database }}\n\n {%- else -%}\n\n {{ custom_database_name }}\n\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.792693, "supported_languages": null}, "macro.dbt.default__test_relationships": {"unique_id": "macro.dbt.default__test_relationships", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/generic_test_sql/relationships.sql", "original_file_path": "macros/generic_test_sql/relationships.sql", "name": "default__test_relationships", "macro_sql": "{% macro default__test_relationships(model, column_name, to, field) %}\n\nwith child as (\n select {{ column_name }} as from_field\n from {{ model }}\n where {{ column_name }} is not null\n),\n\nparent as (\n select {{ field }} as to_field\n from {{ to }}\n)\n\nselect\n from_field\n\nfrom child\nleft join parent\n on child.from_field = parent.to_field\n\nwhere parent.to_field is null\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.793406, "supported_languages": null}, "macro.dbt.default__test_not_null": {"unique_id": "macro.dbt.default__test_not_null", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/generic_test_sql/not_null.sql", "original_file_path": "macros/generic_test_sql/not_null.sql", "name": "default__test_not_null", "macro_sql": "{% macro default__test_not_null(model, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else column_name %}\n\nselect {{ column_list }}\nfrom {{ model }}\nwhere {{ column_name }} is null\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.should_store_failures"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7941172, "supported_languages": null}, "macro.dbt.default__test_unique": {"unique_id": "macro.dbt.default__test_unique", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/generic_test_sql/unique.sql", "original_file_path": "macros/generic_test_sql/unique.sql", "name": "default__test_unique", "macro_sql": "{% macro default__test_unique(model, column_name) %}\n\nselect\n {{ column_name }} as unique_field,\n count(*) as n_records\n\nfrom {{ model }}\nwhere {{ column_name }} is not null\ngroup by {{ column_name }}\nhaving count(*) > 1\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7948081, "supported_languages": null}, "macro.dbt.default__test_accepted_values": {"unique_id": "macro.dbt.default__test_accepted_values", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/generic_test_sql/accepted_values.sql", "original_file_path": "macros/generic_test_sql/accepted_values.sql", "name": "default__test_accepted_values", "macro_sql": "{% macro default__test_accepted_values(model, column_name, values, quote=True) %}\n\nwith all_values as (\n\n select\n {{ column_name }} as value_field,\n count(*) as n_records\n\n from {{ model }}\n group by {{ column_name }}\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n)\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.7958999, "supported_languages": null}, "macro.dbt.statement": {"unique_id": "macro.dbt.statement", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "name": "statement", "macro_sql": "\n{%- macro statement(name=None, fetch_result=False, auto_begin=True, language='sql') -%}\n {%- if execute: -%}\n {%- set compiled_code = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime {} for node \"{}\"'.format(language, model['unique_id'])) }}\n {{ write(compiled_code) }}\n {%- endif -%}\n {%- if language == 'sql'-%}\n {%- set res, table = adapter.execute(compiled_code, auto_begin=auto_begin, fetch=fetch_result) -%}\n {%- elif language == 'python' -%}\n {%- set res = submit_python_job(model, compiled_code) -%}\n {#-- TODO: What should table be for python models? --#}\n {%- set table = None -%}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"statement macro didn't get supported language\") %}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_result(name, response=res, agate_table=table) }}\n {%- endif -%}\n\n {%- endif -%}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.798889, "supported_languages": null}, "macro.dbt.noop_statement": {"unique_id": "macro.dbt.noop_statement", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "name": "noop_statement", "macro_sql": "{% macro noop_statement(name=None, message=None, code=None, rows_affected=None, res=None) -%}\n {%- set sql = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime SQL for node \"{}\"'.format(model['unique_id'])) }}\n {{ write(sql) }}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_raw_result(name, message=message, code=code, rows_affected=rows_affected, agate_table=res) }}\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.800437, "supported_languages": null}, "macro.dbt.run_query": {"unique_id": "macro.dbt.run_query", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "name": "run_query", "macro_sql": "{% macro run_query(sql) %}\n {% call statement(\"run_query_statement\", fetch_result=true, auto_begin=false) %}\n {{ sql }}\n {% endcall %}\n\n {% do return(load_result(\"run_query_statement\").table) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.801034, "supported_languages": null}, "macro.dbt.convert_datetime": {"unique_id": "macro.dbt.convert_datetime", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "name": "convert_datetime", "macro_sql": "{% macro convert_datetime(date_str, date_fmt) %}\n\n {% set error_msg -%}\n The provided partition date '{{ date_str }}' does not match the expected format '{{ date_fmt }}'\n {%- endset %}\n\n {% set res = try_or_compiler_error(error_msg, modules.datetime.datetime.strptime, date_str.strip(), date_fmt) %}\n {{ return(res) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.803998, "supported_languages": null}, "macro.dbt.dates_in_range": {"unique_id": "macro.dbt.dates_in_range", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "name": "dates_in_range", "macro_sql": "{% macro dates_in_range(start_date_str, end_date_str=none, in_fmt=\"%Y%m%d\", out_fmt=\"%Y%m%d\") %}\n {% set end_date_str = start_date_str if end_date_str is none else end_date_str %}\n\n {% set start_date = convert_datetime(start_date_str, in_fmt) %}\n {% set end_date = convert_datetime(end_date_str, in_fmt) %}\n\n {% set day_count = (end_date - start_date).days %}\n {% if day_count < 0 %}\n {% set msg -%}\n Partiton start date is after the end date ({{ start_date }}, {{ end_date }})\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg, model) }}\n {% endif %}\n\n {% set date_list = [] %}\n {% for i in range(0, day_count + 1) %}\n {% set the_date = (modules.datetime.timedelta(days=i) + start_date) %}\n {% if not out_fmt %}\n {% set _ = date_list.append(the_date) %}\n {% else %}\n {% set _ = date_list.append(the_date.strftime(out_fmt)) %}\n {% endif %}\n {% endfor %}\n\n {{ return(date_list) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.convert_datetime"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.806257, "supported_languages": null}, "macro.dbt.partition_range": {"unique_id": "macro.dbt.partition_range", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "name": "partition_range", "macro_sql": "{% macro partition_range(raw_partition_date, date_fmt='%Y%m%d') %}\n {% set partition_range = (raw_partition_date | string).split(\",\") %}\n\n {% if (partition_range | length) == 1 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = none %}\n {% elif (partition_range | length) == 2 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = partition_range[1] %}\n {% else %}\n {{ exceptions.raise_compiler_error(\"Invalid partition time. Expected format: {Start Date}[,{End Date}]. Got: \" ~ raw_partition_date) }}\n {% endif %}\n\n {{ return(dates_in_range(start_date, end_date, in_fmt=date_fmt)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.dates_in_range"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.807599, "supported_languages": null}, "macro.dbt.py_current_timestring": {"unique_id": "macro.dbt.py_current_timestring", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "name": "py_current_timestring", "macro_sql": "{% macro py_current_timestring() %}\n {% set dt = modules.datetime.datetime.now() %}\n {% do return(dt.strftime(\"%Y%m%d%H%M%S%f\")) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.808031, "supported_languages": null}, "macro.dbt.except": {"unique_id": "macro.dbt.except", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/except.sql", "original_file_path": "macros/utils/except.sql", "name": "except", "macro_sql": "{% macro except() %}\n {{ return(adapter.dispatch('except', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.808588, "supported_languages": null}, "macro.dbt.default__except": {"unique_id": "macro.dbt.default__except", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/except.sql", "original_file_path": "macros/utils/except.sql", "name": "default__except", "macro_sql": "{% macro default__except() %}\n\n except\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.808745, "supported_languages": null}, "macro.dbt.replace": {"unique_id": "macro.dbt.replace", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/replace.sql", "original_file_path": "macros/utils/replace.sql", "name": "replace", "macro_sql": "{% macro replace(field, old_chars, new_chars) -%}\n {{ return(adapter.dispatch('replace', 'dbt') (field, old_chars, new_chars)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__replace"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.809441, "supported_languages": null}, "macro.dbt.default__replace": {"unique_id": "macro.dbt.default__replace", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/replace.sql", "original_file_path": "macros/utils/replace.sql", "name": "default__replace", "macro_sql": "{% macro default__replace(field, old_chars, new_chars) %}\n\n replace(\n {{ field }},\n {{ old_chars }},\n {{ new_chars }}\n )\n\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.80976, "supported_languages": null}, "macro.dbt.concat": {"unique_id": "macro.dbt.concat", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/concat.sql", "original_file_path": "macros/utils/concat.sql", "name": "concat", "macro_sql": "{% macro concat(fields) -%}\n {{ return(adapter.dispatch('concat', 'dbt')(fields)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.810412, "supported_languages": null}, "macro.dbt.default__concat": {"unique_id": "macro.dbt.default__concat", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/concat.sql", "original_file_path": "macros/utils/concat.sql", "name": "default__concat", "macro_sql": "{% macro default__concat(fields) -%}\n {{ fields|join(' || ') }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8106592, "supported_languages": null}, "macro.dbt.length": {"unique_id": "macro.dbt.length", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/length.sql", "original_file_path": "macros/utils/length.sql", "name": "length", "macro_sql": "{% macro length(expression) -%}\n {{ return(adapter.dispatch('length', 'dbt') (expression)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__length"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.811254, "supported_languages": null}, "macro.dbt.default__length": {"unique_id": "macro.dbt.default__length", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/length.sql", "original_file_path": "macros/utils/length.sql", "name": "default__length", "macro_sql": "{% macro default__length(expression) %}\n\n length(\n {{ expression }}\n )\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.811467, "supported_languages": null}, "macro.dbt.dateadd": {"unique_id": "macro.dbt.dateadd", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/dateadd.sql", "original_file_path": "macros/utils/dateadd.sql", "name": "dateadd", "macro_sql": "{% macro dateadd(datepart, interval, from_date_or_timestamp) %}\n {{ return(adapter.dispatch('dateadd', 'dbt')(datepart, interval, from_date_or_timestamp)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.81218, "supported_languages": null}, "macro.dbt.default__dateadd": {"unique_id": "macro.dbt.default__dateadd", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/dateadd.sql", "original_file_path": "macros/utils/dateadd.sql", "name": "default__dateadd", "macro_sql": "{% macro default__dateadd(datepart, interval, from_date_or_timestamp) %}\n\n dateadd(\n {{ datepart }},\n {{ interval }},\n {{ from_date_or_timestamp }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.812546, "supported_languages": null}, "macro.dbt.intersect": {"unique_id": "macro.dbt.intersect", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/intersect.sql", "original_file_path": "macros/utils/intersect.sql", "name": "intersect", "macro_sql": "{% macro intersect() %}\n {{ return(adapter.dispatch('intersect', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__intersect"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8131561, "supported_languages": null}, "macro.dbt.default__intersect": {"unique_id": "macro.dbt.default__intersect", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/intersect.sql", "original_file_path": "macros/utils/intersect.sql", "name": "default__intersect", "macro_sql": "{% macro default__intersect() %}\n\n intersect\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.813314, "supported_languages": null}, "macro.dbt.escape_single_quotes": {"unique_id": "macro.dbt.escape_single_quotes", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "name": "escape_single_quotes", "macro_sql": "{% macro escape_single_quotes(expression) %}\n {{ return(adapter.dispatch('escape_single_quotes', 'dbt') (expression)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__escape_single_quotes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.813998, "supported_languages": null}, "macro.dbt.default__escape_single_quotes": {"unique_id": "macro.dbt.default__escape_single_quotes", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "name": "default__escape_single_quotes", "macro_sql": "{% macro default__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\",\"''\") }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8144372, "supported_languages": null}, "macro.dbt.right": {"unique_id": "macro.dbt.right", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "name": "right", "macro_sql": "{% macro right(string_text, length_expression) -%}\n {{ return(adapter.dispatch('right', 'dbt') (string_text, length_expression)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__right"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8150988, "supported_languages": null}, "macro.dbt.default__right": {"unique_id": "macro.dbt.default__right", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "name": "default__right", "macro_sql": "{% macro default__right(string_text, length_expression) %}\n\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.815368, "supported_languages": null}, "macro.dbt.listagg": {"unique_id": "macro.dbt.listagg", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/listagg.sql", "original_file_path": "macros/utils/listagg.sql", "name": "listagg", "macro_sql": "{% macro listagg(measure, delimiter_text=\"','\", order_by_clause=none, limit_num=none) -%}\n {{ return(adapter.dispatch('listagg', 'dbt') (measure, delimiter_text, order_by_clause, limit_num)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__listagg"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.816566, "supported_languages": null}, "macro.dbt.default__listagg": {"unique_id": "macro.dbt.default__listagg", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/listagg.sql", "original_file_path": "macros/utils/listagg.sql", "name": "default__listagg", "macro_sql": "{% macro default__listagg(measure, delimiter_text, order_by_clause, limit_num) -%}\n\n {% if limit_num -%}\n array_to_string(\n array_slice(\n array_agg(\n {{ measure }}\n ){% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n ,0\n ,{{ limit_num }}\n ),\n {{ delimiter_text }}\n )\n {%- else %}\n listagg(\n {{ measure }},\n {{ delimiter_text }}\n )\n {% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n {%- endif %}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.817317, "supported_languages": null}, "macro.dbt.datediff": {"unique_id": "macro.dbt.datediff", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/datediff.sql", "original_file_path": "macros/utils/datediff.sql", "name": "datediff", "macro_sql": "{% macro datediff(first_date, second_date, datepart) %}\n {{ return(adapter.dispatch('datediff', 'dbt')(first_date, second_date, datepart)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.818054, "supported_languages": null}, "macro.dbt.default__datediff": {"unique_id": "macro.dbt.default__datediff", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/datediff.sql", "original_file_path": "macros/utils/datediff.sql", "name": "default__datediff", "macro_sql": "{% macro default__datediff(first_date, second_date, datepart) -%}\n\n datediff(\n {{ datepart }},\n {{ first_date }},\n {{ second_date }}\n )\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.818366, "supported_languages": null}, "macro.dbt.safe_cast": {"unique_id": "macro.dbt.safe_cast", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "name": "safe_cast", "macro_sql": "{% macro safe_cast(field, type) %}\n {{ return(adapter.dispatch('safe_cast', 'dbt') (field, type)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__safe_cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.819027, "supported_languages": null}, "macro.dbt.default__safe_cast": {"unique_id": "macro.dbt.default__safe_cast", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "name": "default__safe_cast", "macro_sql": "{% macro default__safe_cast(field, type) %}\n {# most databases don't support this function yet\n so we just need to use cast #}\n cast({{field}} as {{type}})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.819419, "supported_languages": null}, "macro.dbt.hash": {"unique_id": "macro.dbt.hash", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/hash.sql", "original_file_path": "macros/utils/hash.sql", "name": "hash", "macro_sql": "{% macro hash(field) -%}\n {{ return(adapter.dispatch('hash', 'dbt') (field)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__hash"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.820014, "supported_languages": null}, "macro.dbt.default__hash": {"unique_id": "macro.dbt.default__hash", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/hash.sql", "original_file_path": "macros/utils/hash.sql", "name": "default__hash", "macro_sql": "{% macro default__hash(field) -%}\n md5(cast({{ field }} as {{ api.Column.translate_type('string') }}))\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.820322, "supported_languages": null}, "macro.dbt.cast_bool_to_text": {"unique_id": "macro.dbt.cast_bool_to_text", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/cast_bool_to_text.sql", "original_file_path": "macros/utils/cast_bool_to_text.sql", "name": "cast_bool_to_text", "macro_sql": "{% macro cast_bool_to_text(field) %}\n {{ adapter.dispatch('cast_bool_to_text', 'dbt') (field) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__cast_bool_to_text"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.820897, "supported_languages": null}, "macro.dbt.default__cast_bool_to_text": {"unique_id": "macro.dbt.default__cast_bool_to_text", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/cast_bool_to_text.sql", "original_file_path": "macros/utils/cast_bool_to_text.sql", "name": "default__cast_bool_to_text", "macro_sql": "{% macro default__cast_bool_to_text(field) %}\n cast({{ field }} as {{ api.Column.translate_type('string') }})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8214662, "supported_languages": null}, "macro.dbt.any_value": {"unique_id": "macro.dbt.any_value", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/any_value.sql", "original_file_path": "macros/utils/any_value.sql", "name": "any_value", "macro_sql": "{% macro any_value(expression) -%}\n {{ return(adapter.dispatch('any_value', 'dbt') (expression)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__any_value"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.822405, "supported_languages": null}, "macro.dbt.default__any_value": {"unique_id": "macro.dbt.default__any_value", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/any_value.sql", "original_file_path": "macros/utils/any_value.sql", "name": "default__any_value", "macro_sql": "{% macro default__any_value(expression) -%}\n\n any_value({{ expression }})\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.822617, "supported_languages": null}, "macro.dbt.position": {"unique_id": "macro.dbt.position", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/position.sql", "original_file_path": "macros/utils/position.sql", "name": "position", "macro_sql": "{% macro position(substring_text, string_text) -%}\n {{ return(adapter.dispatch('position', 'dbt') (substring_text, string_text)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__position"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.823263, "supported_languages": null}, "macro.dbt.default__position": {"unique_id": "macro.dbt.default__position", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/position.sql", "original_file_path": "macros/utils/position.sql", "name": "default__position", "macro_sql": "{% macro default__position(substring_text, string_text) %}\n\n position(\n {{ substring_text }} in {{ string_text }}\n )\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.82353, "supported_languages": null}, "macro.dbt.string_literal": {"unique_id": "macro.dbt.string_literal", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/literal.sql", "original_file_path": "macros/utils/literal.sql", "name": "string_literal", "macro_sql": "{%- macro string_literal(value) -%}\n {{ return(adapter.dispatch('string_literal', 'dbt') (value)) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__string_literal"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.824129, "supported_languages": null}, "macro.dbt.default__string_literal": {"unique_id": "macro.dbt.default__string_literal", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/literal.sql", "original_file_path": "macros/utils/literal.sql", "name": "default__string_literal", "macro_sql": "{% macro default__string_literal(value) -%}\n '{{ value }}'\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.824346, "supported_languages": null}, "macro.dbt.type_string": {"unique_id": "macro.dbt.type_string", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "type_string", "macro_sql": "\n\n{%- macro type_string() -%}\n {{ return(adapter.dispatch('type_string', 'dbt')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.826014, "supported_languages": null}, "macro.dbt.default__type_string": {"unique_id": "macro.dbt.default__type_string", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "default__type_string", "macro_sql": "{% macro default__type_string() %}\n {{ return(api.Column.translate_type(\"string\")) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8263118, "supported_languages": null}, "macro.dbt.type_timestamp": {"unique_id": "macro.dbt.type_timestamp", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "type_timestamp", "macro_sql": "\n\n{%- macro type_timestamp() -%}\n {{ return(adapter.dispatch('type_timestamp', 'dbt')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.826742, "supported_languages": null}, "macro.dbt.default__type_timestamp": {"unique_id": "macro.dbt.default__type_timestamp", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "default__type_timestamp", "macro_sql": "{% macro default__type_timestamp() %}\n {{ return(api.Column.translate_type(\"timestamp\")) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.827038, "supported_languages": null}, "macro.dbt.type_float": {"unique_id": "macro.dbt.type_float", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "type_float", "macro_sql": "\n\n{%- macro type_float() -%}\n {{ return(adapter.dispatch('type_float', 'dbt')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__type_float"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8273542, "supported_languages": null}, "macro.dbt.default__type_float": {"unique_id": "macro.dbt.default__type_float", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "default__type_float", "macro_sql": "{% macro default__type_float() %}\n {{ return(api.Column.translate_type(\"float\")) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.827656, "supported_languages": null}, "macro.dbt.type_numeric": {"unique_id": "macro.dbt.type_numeric", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "type_numeric", "macro_sql": "\n\n{%- macro type_numeric() -%}\n {{ return(adapter.dispatch('type_numeric', 'dbt')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__type_numeric"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.828058, "supported_languages": null}, "macro.dbt.default__type_numeric": {"unique_id": "macro.dbt.default__type_numeric", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "default__type_numeric", "macro_sql": "{% macro default__type_numeric() %}\n {{ return(api.Column.numeric_type(\"numeric\", 28, 6)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.828393, "supported_languages": null}, "macro.dbt.type_bigint": {"unique_id": "macro.dbt.type_bigint", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "type_bigint", "macro_sql": "\n\n{%- macro type_bigint() -%}\n {{ return(adapter.dispatch('type_bigint', 'dbt')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__type_bigint"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8287082, "supported_languages": null}, "macro.dbt.default__type_bigint": {"unique_id": "macro.dbt.default__type_bigint", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "default__type_bigint", "macro_sql": "{% macro default__type_bigint() %}\n {{ return(api.Column.translate_type(\"bigint\")) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8290062, "supported_languages": null}, "macro.dbt.type_int": {"unique_id": "macro.dbt.type_int", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "type_int", "macro_sql": "\n\n{%- macro type_int() -%}\n {{ return(adapter.dispatch('type_int', 'dbt')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__type_int"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.829538, "supported_languages": null}, "macro.dbt.default__type_int": {"unique_id": "macro.dbt.default__type_int", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "default__type_int", "macro_sql": "{%- macro default__type_int() -%}\n {{ return(api.Column.translate_type(\"integer\")) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8299131, "supported_languages": null}, "macro.dbt.type_boolean": {"unique_id": "macro.dbt.type_boolean", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "type_boolean", "macro_sql": "\n\n{%- macro type_boolean() -%}\n {{ return(adapter.dispatch('type_boolean', 'dbt')()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__type_boolean"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.830221, "supported_languages": null}, "macro.dbt.default__type_boolean": {"unique_id": "macro.dbt.default__type_boolean", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "name": "default__type_boolean", "macro_sql": "{%- macro default__type_boolean() -%}\n {{ return(api.Column.translate_type(\"boolean\")) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.830503, "supported_languages": null}, "macro.dbt.array_concat": {"unique_id": "macro.dbt.array_concat", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/array_concat.sql", "original_file_path": "macros/utils/array_concat.sql", "name": "array_concat", "macro_sql": "{% macro array_concat(array_1, array_2) -%}\n {{ return(adapter.dispatch('array_concat', 'dbt')(array_1, array_2)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__array_concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.831218, "supported_languages": null}, "macro.dbt.default__array_concat": {"unique_id": "macro.dbt.default__array_concat", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/array_concat.sql", "original_file_path": "macros/utils/array_concat.sql", "name": "default__array_concat", "macro_sql": "{% macro default__array_concat(array_1, array_2) -%}\n array_cat({{ array_1 }}, {{ array_2 }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8316438, "supported_languages": null}, "macro.dbt.bool_or": {"unique_id": "macro.dbt.bool_or", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "name": "bool_or", "macro_sql": "{% macro bool_or(expression) -%}\n {{ return(adapter.dispatch('bool_or', 'dbt') (expression)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__bool_or"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.832247, "supported_languages": null}, "macro.dbt.default__bool_or": {"unique_id": "macro.dbt.default__bool_or", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "name": "default__bool_or", "macro_sql": "{% macro default__bool_or(expression) -%}\n\n bool_or({{ expression }})\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.832463, "supported_languages": null}, "macro.dbt.last_day": {"unique_id": "macro.dbt.last_day", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "name": "last_day", "macro_sql": "{% macro last_day(date, datepart) %}\n {{ return(adapter.dispatch('last_day', 'dbt') (date, datepart)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.833194, "supported_languages": null}, "macro.dbt.default_last_day": {"unique_id": "macro.dbt.default_last_day", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "name": "default_last_day", "macro_sql": "\n\n{%- macro default_last_day(date, datepart) -%}\n cast(\n {{dbt.dateadd('day', '-1',\n dbt.dateadd(datepart, '1', dbt.date_trunc(datepart, date))\n )}}\n as date)\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.833685, "supported_languages": null}, "macro.dbt.default__last_day": {"unique_id": "macro.dbt.default__last_day", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "name": "default__last_day", "macro_sql": "{% macro default__last_day(date, datepart) -%}\n {{dbt.default_last_day(date, datepart)}}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default_last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8339741, "supported_languages": null}, "macro.dbt.split_part": {"unique_id": "macro.dbt.split_part", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "name": "split_part", "macro_sql": "{% macro split_part(string_text, delimiter_text, part_number) %}\n {{ return(adapter.dispatch('split_part', 'dbt') (string_text, delimiter_text, part_number)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__split_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.834921, "supported_languages": null}, "macro.dbt.default__split_part": {"unique_id": "macro.dbt.default__split_part", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "name": "default__split_part", "macro_sql": "{% macro default__split_part(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n {{ part_number }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.835242, "supported_languages": null}, "macro.dbt._split_part_negative": {"unique_id": "macro.dbt._split_part_negative", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "name": "_split_part_negative", "macro_sql": "{% macro _split_part_negative(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n length({{ string_text }})\n - length(\n replace({{ string_text }}, {{ delimiter_text }}, '')\n ) + 2 {{ part_number }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.835663, "supported_languages": null}, "macro.dbt.date_trunc": {"unique_id": "macro.dbt.date_trunc", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/date_trunc.sql", "original_file_path": "macros/utils/date_trunc.sql", "name": "date_trunc", "macro_sql": "{% macro date_trunc(datepart, date) -%}\n {{ return(adapter.dispatch('date_trunc', 'dbt') (datepart, date)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.836308, "supported_languages": null}, "macro.dbt.default__date_trunc": {"unique_id": "macro.dbt.default__date_trunc", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/date_trunc.sql", "original_file_path": "macros/utils/date_trunc.sql", "name": "default__date_trunc", "macro_sql": "{% macro default__date_trunc(datepart, date) -%}\n date_trunc('{{datepart}}', {{date}})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.836571, "supported_languages": null}, "macro.dbt.array_construct": {"unique_id": "macro.dbt.array_construct", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "name": "array_construct", "macro_sql": "{% macro array_construct(inputs=[], data_type=api.Column.translate_type('integer')) -%}\n {{ return(adapter.dispatch('array_construct', 'dbt')(inputs, data_type)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__array_construct"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.83743, "supported_languages": null}, "macro.dbt.default__array_construct": {"unique_id": "macro.dbt.default__array_construct", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "name": "default__array_construct", "macro_sql": "{% macro default__array_construct(inputs, data_type) -%}\n {% if inputs|length > 0 %}\n array[ {{ inputs|join(' , ') }} ]\n {% else %}\n array[]::{{data_type}}[]\n {% endif %}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8379068, "supported_languages": null}, "macro.dbt.array_append": {"unique_id": "macro.dbt.array_append", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/array_append.sql", "original_file_path": "macros/utils/array_append.sql", "name": "array_append", "macro_sql": "{% macro array_append(array, new_element) -%}\n {{ return(adapter.dispatch('array_append', 'dbt')(array, new_element)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__array_append"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8385558, "supported_languages": null}, "macro.dbt.default__array_append": {"unique_id": "macro.dbt.default__array_append", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/utils/array_append.sql", "original_file_path": "macros/utils/array_append.sql", "name": "default__array_append", "macro_sql": "{% macro default__array_append(array, new_element) -%}\n array_append({{ array }}, {{ new_element }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8388228, "supported_languages": null}, "macro.dbt.create_schema": {"unique_id": "macro.dbt.create_schema", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "name": "create_schema", "macro_sql": "{% macro create_schema(relation) -%}\n {{ adapter.dispatch('create_schema', 'dbt')(relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__create_schema"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8396502, "supported_languages": null}, "macro.dbt.default__create_schema": {"unique_id": "macro.dbt.default__create_schema", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "name": "default__create_schema", "macro_sql": "{% macro default__create_schema(relation) -%}\n {%- call statement('create_schema') -%}\n create schema if not exists {{ relation.without_identifier() }}\n {% endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.840016, "supported_languages": null}, "macro.dbt.drop_schema": {"unique_id": "macro.dbt.drop_schema", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "name": "drop_schema", "macro_sql": "{% macro drop_schema(relation) -%}\n {{ adapter.dispatch('drop_schema', 'dbt')(relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__drop_schema"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.840331, "supported_languages": null}, "macro.dbt.default__drop_schema": {"unique_id": "macro.dbt.default__drop_schema", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "name": "default__drop_schema", "macro_sql": "{% macro default__drop_schema(relation) -%}\n {%- call statement('drop_schema') -%}\n drop schema if exists {{ relation.without_identifier() }} cascade\n {% endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.840706, "supported_languages": null}, "macro.dbt.current_timestamp": {"unique_id": "macro.dbt.current_timestamp", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "current_timestamp", "macro_sql": "{%- macro current_timestamp() -%}\n {{ adapter.dispatch('current_timestamp', 'dbt')() }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.841656, "supported_languages": null}, "macro.dbt.default__current_timestamp": {"unique_id": "macro.dbt.default__current_timestamp", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "default__current_timestamp", "macro_sql": "{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n 'current_timestamp macro not implemented for adapter ' + adapter.type()) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8420632, "supported_languages": null}, "macro.dbt.snapshot_get_time": {"unique_id": "macro.dbt.snapshot_get_time", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "snapshot_get_time", "macro_sql": "\n\n{%- macro snapshot_get_time() -%}\n {{ adapter.dispatch('snapshot_get_time', 'dbt')() }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_get_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8423822, "supported_languages": null}, "macro.dbt.default__snapshot_get_time": {"unique_id": "macro.dbt.default__snapshot_get_time", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "default__snapshot_get_time", "macro_sql": "{% macro default__snapshot_get_time() %}\n {{ current_timestamp() }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.842613, "supported_languages": null}, "macro.dbt.current_timestamp_backcompat": {"unique_id": "macro.dbt.current_timestamp_backcompat", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "current_timestamp_backcompat", "macro_sql": "{% macro current_timestamp_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.842931, "supported_languages": null}, "macro.dbt.default__current_timestamp_backcompat": {"unique_id": "macro.dbt.default__current_timestamp_backcompat", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "default__current_timestamp_backcompat", "macro_sql": "{% macro default__current_timestamp_backcompat() %}\n current_timestamp::timestamp\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8430889, "supported_languages": null}, "macro.dbt.current_timestamp_in_utc_backcompat": {"unique_id": "macro.dbt.current_timestamp_in_utc_backcompat", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "current_timestamp_in_utc_backcompat", "macro_sql": "{% macro current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_in_utc_backcompat', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.843406, "supported_languages": null}, "macro.dbt.default__current_timestamp_in_utc_backcompat": {"unique_id": "macro.dbt.default__current_timestamp_in_utc_backcompat", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "name": "default__current_timestamp_in_utc_backcompat", "macro_sql": "{% macro default__current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.current_timestamp_backcompat", "macro.dbt_snowflake.snowflake__current_timestamp_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.84373, "supported_languages": null}, "macro.dbt.get_create_index_sql": {"unique_id": "macro.dbt.get_create_index_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "name": "get_create_index_sql", "macro_sql": "{% macro get_create_index_sql(relation, index_dict) -%}\n {{ return(adapter.dispatch('get_create_index_sql', 'dbt')(relation, index_dict)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_create_index_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.844619, "supported_languages": null}, "macro.dbt.default__get_create_index_sql": {"unique_id": "macro.dbt.default__get_create_index_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "name": "default__get_create_index_sql", "macro_sql": "{% macro default__get_create_index_sql(relation, index_dict) -%}\n {% do return(None) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.844893, "supported_languages": null}, "macro.dbt.create_indexes": {"unique_id": "macro.dbt.create_indexes", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "name": "create_indexes", "macro_sql": "{% macro create_indexes(relation) -%}\n {{ adapter.dispatch('create_indexes', 'dbt')(relation) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8452039, "supported_languages": null}, "macro.dbt.default__create_indexes": {"unique_id": "macro.dbt.default__create_indexes", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "name": "default__create_indexes", "macro_sql": "{% macro default__create_indexes(relation) -%}\n {%- set _indexes = config.get('indexes', default=[]) -%}\n\n {% for _index_dict in _indexes %}\n {% set create_index_sql = get_create_index_sql(relation, _index_dict) %}\n {% if create_index_sql %}\n {% do run_query(create_index_sql) %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.get_create_index_sql", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.84595, "supported_languages": null}, "macro.dbt.make_intermediate_relation": {"unique_id": "macro.dbt.make_intermediate_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "make_intermediate_relation", "macro_sql": "{% macro make_intermediate_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_intermediate_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__make_intermediate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.85072, "supported_languages": null}, "macro.dbt.default__make_intermediate_relation": {"unique_id": "macro.dbt.default__make_intermediate_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "default__make_intermediate_relation", "macro_sql": "{% macro default__make_intermediate_relation(base_relation, suffix) %}\n {{ return(default__make_temp_relation(base_relation, suffix)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__make_temp_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8510468, "supported_languages": null}, "macro.dbt.make_temp_relation": {"unique_id": "macro.dbt.make_temp_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "make_temp_relation", "macro_sql": "{% macro make_temp_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_temp_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__make_temp_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.851465, "supported_languages": null}, "macro.dbt.default__make_temp_relation": {"unique_id": "macro.dbt.default__make_temp_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "default__make_temp_relation", "macro_sql": "{% macro default__make_temp_relation(base_relation, suffix) %}\n {%- set temp_identifier = base_relation.identifier ~ suffix -%}\n {%- set temp_relation = base_relation.incorporate(\n path={\"identifier\": temp_identifier}) -%}\n\n {{ return(temp_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.85201, "supported_languages": null}, "macro.dbt.make_backup_relation": {"unique_id": "macro.dbt.make_backup_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "make_backup_relation", "macro_sql": "{% macro make_backup_relation(base_relation, backup_relation_type, suffix='__dbt_backup') %}\n {{ return(adapter.dispatch('make_backup_relation', 'dbt')(base_relation, backup_relation_type, suffix)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__make_backup_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.852479, "supported_languages": null}, "macro.dbt.default__make_backup_relation": {"unique_id": "macro.dbt.default__make_backup_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "default__make_backup_relation", "macro_sql": "{% macro default__make_backup_relation(base_relation, backup_relation_type, suffix) %}\n {%- set backup_identifier = base_relation.identifier ~ suffix -%}\n {%- set backup_relation = base_relation.incorporate(\n path={\"identifier\": backup_identifier},\n type=backup_relation_type\n ) -%}\n {{ return(backup_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.853073, "supported_languages": null}, "macro.dbt.drop_relation": {"unique_id": "macro.dbt.drop_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "drop_relation", "macro_sql": "{% macro drop_relation(relation) -%}\n {{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__drop_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.85343, "supported_languages": null}, "macro.dbt.default__drop_relation": {"unique_id": "macro.dbt.default__drop_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "default__drop_relation", "macro_sql": "{% macro default__drop_relation(relation) -%}\n {% call statement('drop_relation', auto_begin=False) -%}\n drop {{ relation.type }} if exists {{ relation }} cascade\n {%- endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.853844, "supported_languages": null}, "macro.dbt.truncate_relation": {"unique_id": "macro.dbt.truncate_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "truncate_relation", "macro_sql": "{% macro truncate_relation(relation) -%}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.854191, "supported_languages": null}, "macro.dbt.default__truncate_relation": {"unique_id": "macro.dbt.default__truncate_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "default__truncate_relation", "macro_sql": "{% macro default__truncate_relation(relation) -%}\n {% call statement('truncate_relation') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.85451, "supported_languages": null}, "macro.dbt.rename_relation": {"unique_id": "macro.dbt.rename_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "rename_relation", "macro_sql": "{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter.dispatch('rename_relation', 'dbt')(from_relation, to_relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__rename_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.854899, "supported_languages": null}, "macro.dbt.default__rename_relation": {"unique_id": "macro.dbt.default__rename_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "default__rename_relation", "macro_sql": "{% macro default__rename_relation(from_relation, to_relation) -%}\n {% set target_name = adapter.quote_as_configured(to_relation.identifier, 'identifier') %}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ target_name }}\n {%- endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.85554, "supported_languages": null}, "macro.dbt.get_or_create_relation": {"unique_id": "macro.dbt.get_or_create_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "get_or_create_relation", "macro_sql": "{% macro get_or_create_relation(database, schema, identifier, type) -%}\n {{ return(adapter.dispatch('get_or_create_relation', 'dbt')(database, schema, identifier, type)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_or_create_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.856002, "supported_languages": null}, "macro.dbt.default__get_or_create_relation": {"unique_id": "macro.dbt.default__get_or_create_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "default__get_or_create_relation", "macro_sql": "{% macro default__get_or_create_relation(database, schema, identifier, type) %}\n {%- set target_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% if target_relation %}\n {% do return([true, target_relation]) %}\n {% endif %}\n\n {%- set new_relation = api.Relation.create(\n database=database,\n schema=schema,\n identifier=identifier,\n type=type\n ) -%}\n {% do return([false, new_relation]) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.857103, "supported_languages": null}, "macro.dbt.load_cached_relation": {"unique_id": "macro.dbt.load_cached_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "load_cached_relation", "macro_sql": "{% macro load_cached_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.857534, "supported_languages": null}, "macro.dbt.load_relation": {"unique_id": "macro.dbt.load_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "load_relation", "macro_sql": "{% macro load_relation(relation) %}\n {{ return(load_cached_relation(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.load_cached_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8578181, "supported_languages": null}, "macro.dbt.drop_relation_if_exists": {"unique_id": "macro.dbt.drop_relation_if_exists", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "name": "drop_relation_if_exists", "macro_sql": "{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.858192, "supported_languages": null}, "macro.dbt.collect_freshness": {"unique_id": "macro.dbt.collect_freshness", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/freshness.sql", "original_file_path": "macros/adapters/freshness.sql", "name": "collect_freshness", "macro_sql": "{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter.dispatch('collect_freshness', 'dbt')(source, loaded_at_field, filter))}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__collect_freshness"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.859082, "supported_languages": null}, "macro.dbt.default__collect_freshness": {"unique_id": "macro.dbt.default__collect_freshness", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/freshness.sql", "original_file_path": "macros/adapters/freshness.sql", "name": "default__collect_freshness", "macro_sql": "{% macro default__collect_freshness(source, loaded_at_field, filter) %}\n {% call statement('collect_freshness', fetch_result=True, auto_begin=False) -%}\n select\n max({{ loaded_at_field }}) as max_loaded_at,\n {{ current_timestamp() }} as snapshotted_at\n from {{ source }}\n {% if filter %}\n where {{ filter }}\n {% endif %}\n {% endcall %}\n {{ return(load_result('collect_freshness').table) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.859864, "supported_languages": null}, "macro.dbt.copy_grants": {"unique_id": "macro.dbt.copy_grants", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "copy_grants", "macro_sql": "{% macro copy_grants() %}\n {{ return(adapter.dispatch('copy_grants', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__copy_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.862369, "supported_languages": null}, "macro.dbt.default__copy_grants": {"unique_id": "macro.dbt.default__copy_grants", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__copy_grants", "macro_sql": "{% macro default__copy_grants() %}\n {{ return(True) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8626041, "supported_languages": null}, "macro.dbt.support_multiple_grantees_per_dcl_statement": {"unique_id": "macro.dbt.support_multiple_grantees_per_dcl_statement", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "support_multiple_grantees_per_dcl_statement", "macro_sql": "{% macro support_multiple_grantees_per_dcl_statement() %}\n {{ return(adapter.dispatch('support_multiple_grantees_per_dcl_statement', 'dbt')()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.862968, "supported_languages": null}, "macro.dbt.default__support_multiple_grantees_per_dcl_statement": {"unique_id": "macro.dbt.default__support_multiple_grantees_per_dcl_statement", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__support_multiple_grantees_per_dcl_statement", "macro_sql": "\n\n{%- macro default__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(True) }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.863192, "supported_languages": null}, "macro.dbt.should_revoke": {"unique_id": "macro.dbt.should_revoke", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "should_revoke", "macro_sql": "{% macro should_revoke(existing_relation, full_refresh_mode=True) %}\n\n {% if not existing_relation %}\n {#-- The table doesn't already exist, so no grants to copy over --#}\n {{ return(False) }}\n {% elif full_refresh_mode %}\n {#-- The object is being REPLACED -- whether grants are copied over depends on the value of user config --#}\n {{ return(copy_grants()) }}\n {% else %}\n {#-- The table is being merged/upserted/inserted -- grants will be carried over --#}\n {{ return(True) }}\n {% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.copy_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.864002, "supported_languages": null}, "macro.dbt.get_show_grant_sql": {"unique_id": "macro.dbt.get_show_grant_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "get_show_grant_sql", "macro_sql": "{% macro get_show_grant_sql(relation) %}\n {{ return(adapter.dispatch(\"get_show_grant_sql\", \"dbt\")(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_show_grant_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.864413, "supported_languages": null}, "macro.dbt.default__get_show_grant_sql": {"unique_id": "macro.dbt.default__get_show_grant_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__get_show_grant_sql", "macro_sql": "{% macro default__get_show_grant_sql(relation) %}\n show grants on {{ relation }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.864625, "supported_languages": null}, "macro.dbt.get_grant_sql": {"unique_id": "macro.dbt.get_grant_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "get_grant_sql", "macro_sql": "{% macro get_grant_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_grant_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_grant_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.865045, "supported_languages": null}, "macro.dbt.default__get_grant_sql": {"unique_id": "macro.dbt.default__get_grant_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__get_grant_sql", "macro_sql": "\n\n{%- macro default__get_grant_sql(relation, privilege, grantees) -%}\n grant {{ privilege }} on {{ relation }} to {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8654048, "supported_languages": null}, "macro.dbt.get_revoke_sql": {"unique_id": "macro.dbt.get_revoke_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "get_revoke_sql", "macro_sql": "{% macro get_revoke_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_revoke_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_revoke_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.865831, "supported_languages": null}, "macro.dbt.default__get_revoke_sql": {"unique_id": "macro.dbt.default__get_revoke_sql", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__get_revoke_sql", "macro_sql": "\n\n{%- macro default__get_revoke_sql(relation, privilege, grantees) -%}\n revoke {{ privilege }} on {{ relation }} from {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.866202, "supported_languages": null}, "macro.dbt.get_dcl_statement_list": {"unique_id": "macro.dbt.get_dcl_statement_list", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "get_dcl_statement_list", "macro_sql": "{% macro get_dcl_statement_list(relation, grant_config, get_dcl_macro) %}\n {{ return(adapter.dispatch('get_dcl_statement_list', 'dbt')(relation, grant_config, get_dcl_macro)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_dcl_statement_list"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8666291, "supported_languages": null}, "macro.dbt.default__get_dcl_statement_list": {"unique_id": "macro.dbt.default__get_dcl_statement_list", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__get_dcl_statement_list", "macro_sql": "\n\n{%- macro default__get_dcl_statement_list(relation, grant_config, get_dcl_macro) -%}\n {#\n -- Unpack grant_config into specific privileges and the set of users who need them granted/revoked.\n -- Depending on whether this database supports multiple grantees per statement, pass in the list of\n -- all grantees per privilege, or (if not) template one statement per privilege-grantee pair.\n -- `get_dcl_macro` will be either `get_grant_sql` or `get_revoke_sql`\n #}\n {%- set dcl_statements = [] -%}\n {%- for privilege, grantees in grant_config.items() %}\n {%- if support_multiple_grantees_per_dcl_statement() and grantees -%}\n {%- set dcl = get_dcl_macro(relation, privilege, grantees) -%}\n {%- do dcl_statements.append(dcl) -%}\n {%- else -%}\n {%- for grantee in grantees -%}\n {% set dcl = get_dcl_macro(relation, privilege, [grantee]) %}\n {%- do dcl_statements.append(dcl) -%}\n {% endfor -%}\n {%- endif -%}\n {%- endfor -%}\n {{ return(dcl_statements) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.support_multiple_grantees_per_dcl_statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.867871, "supported_languages": null}, "macro.dbt.call_dcl_statements": {"unique_id": "macro.dbt.call_dcl_statements", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "call_dcl_statements", "macro_sql": "{% macro call_dcl_statements(dcl_statement_list) %}\n {{ return(adapter.dispatch(\"call_dcl_statements\", \"dbt\")(dcl_statement_list)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__call_dcl_statements"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.868393, "supported_languages": null}, "macro.dbt.default__call_dcl_statements": {"unique_id": "macro.dbt.default__call_dcl_statements", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__call_dcl_statements", "macro_sql": "{% macro default__call_dcl_statements(dcl_statement_list) %}\n {#\n -- By default, supply all grant + revoke statements in a single semicolon-separated block,\n -- so that they're all processed together.\n\n -- Some databases do not support this. Those adapters will need to override this macro\n -- to run each statement individually.\n #}\n {% call statement('grants') %}\n {% for dcl_statement in dcl_statement_list %}\n {{ dcl_statement }};\n {% endfor %}\n {% endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.868866, "supported_languages": null}, "macro.dbt.apply_grants": {"unique_id": "macro.dbt.apply_grants", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "apply_grants", "macro_sql": "{% macro apply_grants(relation, grant_config, should_revoke) %}\n {{ return(adapter.dispatch(\"apply_grants\", \"dbt\")(relation, grant_config, should_revoke)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.869296, "supported_languages": null}, "macro.dbt.default__apply_grants": {"unique_id": "macro.dbt.default__apply_grants", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "name": "default__apply_grants", "macro_sql": "{% macro default__apply_grants(relation, grant_config, should_revoke=True) %}\n {#-- If grant_config is {} or None, this is a no-op --#}\n {% if grant_config %}\n {% if should_revoke %}\n {#-- We think previous grants may have carried over --#}\n {#-- Show current grants and calculate diffs --#}\n {% set current_grants_table = run_query(get_show_grant_sql(relation)) %}\n {% set current_grants_dict = adapter.standardize_grants_dict(current_grants_table) %}\n {% set needs_granting = diff_of_two_dicts(grant_config, current_grants_dict) %}\n {% set needs_revoking = diff_of_two_dicts(current_grants_dict, grant_config) %}\n {% if not (needs_granting or needs_revoking) %}\n {{ log('On ' ~ relation ~': All grants are in place, no revocation or granting needed.')}}\n {% endif %}\n {% else %}\n {#-- We don't think there's any chance of previous grants having carried over. --#}\n {#-- Jump straight to granting what the user has configured. --#}\n {% set needs_revoking = {} %}\n {% set needs_granting = grant_config %}\n {% endif %}\n {% if needs_granting or needs_revoking %}\n {% set revoke_statement_list = get_dcl_statement_list(relation, needs_revoking, get_revoke_sql) %}\n {% set grant_statement_list = get_dcl_statement_list(relation, needs_granting, get_grant_sql) %}\n {% set dcl_statement_list = revoke_statement_list + grant_statement_list %}\n {% if dcl_statement_list %}\n {{ call_dcl_statements(dcl_statement_list) }}\n {% endif %}\n {% endif %}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.get_show_grant_sql", "macro.dbt.get_dcl_statement_list", "macro.dbt.call_dcl_statements"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.871358, "supported_languages": null}, "macro.dbt.alter_column_comment": {"unique_id": "macro.dbt.alter_column_comment", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "name": "alter_column_comment", "macro_sql": "{% macro alter_column_comment(relation, column_dict) -%}\n {{ return(adapter.dispatch('alter_column_comment', 'dbt')(relation, column_dict)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_column_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.872542, "supported_languages": null}, "macro.dbt.default__alter_column_comment": {"unique_id": "macro.dbt.default__alter_column_comment", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "name": "default__alter_column_comment", "macro_sql": "{% macro default__alter_column_comment(relation, column_dict) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_column_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.872867, "supported_languages": null}, "macro.dbt.alter_relation_comment": {"unique_id": "macro.dbt.alter_relation_comment", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "name": "alter_relation_comment", "macro_sql": "{% macro alter_relation_comment(relation, relation_comment) -%}\n {{ return(adapter.dispatch('alter_relation_comment', 'dbt')(relation, relation_comment)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_relation_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8732958, "supported_languages": null}, "macro.dbt.default__alter_relation_comment": {"unique_id": "macro.dbt.default__alter_relation_comment", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "name": "default__alter_relation_comment", "macro_sql": "{% macro default__alter_relation_comment(relation, relation_comment) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_relation_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.873622, "supported_languages": null}, "macro.dbt.persist_docs": {"unique_id": "macro.dbt.persist_docs", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "name": "persist_docs", "macro_sql": "{% macro persist_docs(relation, model, for_relation=true, for_columns=true) -%}\n {{ return(adapter.dispatch('persist_docs', 'dbt')(relation, model, for_relation, for_columns)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.87412, "supported_languages": null}, "macro.dbt.default__persist_docs": {"unique_id": "macro.dbt.default__persist_docs", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "name": "default__persist_docs", "macro_sql": "{% macro default__persist_docs(relation, model, for_relation, for_columns) -%}\n {% if for_relation and config.persist_relation_docs() and model.description %}\n {% do run_query(alter_relation_comment(relation, model.description)) %}\n {% endif %}\n\n {% if for_columns and config.persist_column_docs() and model.columns %}\n {% do run_query(alter_column_comment(relation, model.columns)) %}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.alter_relation_comment", "macro.dbt.alter_column_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8749912, "supported_languages": null}, "macro.dbt.get_catalog": {"unique_id": "macro.dbt.get_catalog", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "get_catalog", "macro_sql": "{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter.dispatch('get_catalog', 'dbt')(information_schema, schemas)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8775492, "supported_languages": null}, "macro.dbt.default__get_catalog": {"unique_id": "macro.dbt.default__get_catalog", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "default__get_catalog", "macro_sql": "{% macro default__get_catalog(information_schema, schemas) -%}\n\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.878046, "supported_languages": null}, "macro.dbt.information_schema_name": {"unique_id": "macro.dbt.information_schema_name", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "information_schema_name", "macro_sql": "{% macro information_schema_name(database) %}\n {{ return(adapter.dispatch('information_schema_name', 'dbt')(database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__information_schema_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8784032, "supported_languages": null}, "macro.dbt.default__information_schema_name": {"unique_id": "macro.dbt.default__information_schema_name", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "default__information_schema_name", "macro_sql": "{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ database }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.878756, "supported_languages": null}, "macro.dbt.list_schemas": {"unique_id": "macro.dbt.list_schemas", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "list_schemas", "macro_sql": "{% macro list_schemas(database) -%}\n {{ return(adapter.dispatch('list_schemas', 'dbt')(database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__list_schemas"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.879099, "supported_languages": null}, "macro.dbt.default__list_schemas": {"unique_id": "macro.dbt.default__list_schemas", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "default__list_schemas", "macro_sql": "{% macro default__list_schemas(database) -%}\n {% set sql %}\n select distinct schema_name\n from {{ information_schema_name(database) }}.SCHEMATA\n where catalog_name ilike '{{ database }}'\n {% endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.information_schema_name", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8798752, "supported_languages": null}, "macro.dbt.check_schema_exists": {"unique_id": "macro.dbt.check_schema_exists", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "check_schema_exists", "macro_sql": "{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter.dispatch('check_schema_exists', 'dbt')(information_schema, schema)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__check_schema_exists"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.880267, "supported_languages": null}, "macro.dbt.default__check_schema_exists": {"unique_id": "macro.dbt.default__check_schema_exists", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "default__check_schema_exists", "macro_sql": "{% macro default__check_schema_exists(information_schema, schema) -%}\n {% set sql -%}\n select count(*)\n from {{ information_schema.replace(information_schema_view='SCHEMATA') }}\n where catalog_name='{{ information_schema.database }}'\n and schema_name='{{ schema }}'\n {%- endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.replace", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8808372, "supported_languages": null}, "macro.dbt.list_relations_without_caching": {"unique_id": "macro.dbt.list_relations_without_caching", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "list_relations_without_caching", "macro_sql": "{% macro list_relations_without_caching(schema_relation) %}\n {{ return(adapter.dispatch('list_relations_without_caching', 'dbt')(schema_relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__list_relations_without_caching"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.881195, "supported_languages": null}, "macro.dbt.default__list_relations_without_caching": {"unique_id": "macro.dbt.default__list_relations_without_caching", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "name": "default__list_relations_without_caching", "macro_sql": "{% macro default__list_relations_without_caching(schema_relation) %}\n {{ exceptions.raise_not_implemented(\n 'list_relations_without_caching macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8815958, "supported_languages": null}, "macro.dbt.get_columns_in_relation": {"unique_id": "macro.dbt.get_columns_in_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "get_columns_in_relation", "macro_sql": "{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter.dispatch('get_columns_in_relation', 'dbt')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.884368, "supported_languages": null}, "macro.dbt.default__get_columns_in_relation": {"unique_id": "macro.dbt.default__get_columns_in_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "default__get_columns_in_relation", "macro_sql": "{% macro default__get_columns_in_relation(relation) -%}\n {{ exceptions.raise_not_implemented(\n 'get_columns_in_relation macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.884682, "supported_languages": null}, "macro.dbt.sql_convert_columns_in_relation": {"unique_id": "macro.dbt.sql_convert_columns_in_relation", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "sql_convert_columns_in_relation", "macro_sql": "{% macro sql_convert_columns_in_relation(table) -%}\n {% set columns = [] %}\n {% for row in table %}\n {% do columns.append(api.Column(*row)) %}\n {% endfor %}\n {{ return(columns) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.885314, "supported_languages": null}, "macro.dbt.get_columns_in_query": {"unique_id": "macro.dbt.get_columns_in_query", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "get_columns_in_query", "macro_sql": "{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter.dispatch('get_columns_in_query', 'dbt')(select_sql)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__get_columns_in_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.885792, "supported_languages": null}, "macro.dbt.default__get_columns_in_query": {"unique_id": "macro.dbt.default__get_columns_in_query", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "default__get_columns_in_query", "macro_sql": "{% macro default__get_columns_in_query(select_sql) %}\n {% call statement('get_columns_in_query', fetch_result=True, auto_begin=False) -%}\n select * from (\n {{ select_sql }}\n ) as __dbt_sbq\n where false\n limit 0\n {% endcall %}\n\n {{ return(load_result('get_columns_in_query').table.columns | map(attribute='name') | list) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8864179, "supported_languages": null}, "macro.dbt.alter_column_type": {"unique_id": "macro.dbt.alter_column_type", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "alter_column_type", "macro_sql": "{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter.dispatch('alter_column_type', 'dbt')(relation, column_name, new_column_type)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_column_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.88685, "supported_languages": null}, "macro.dbt.default__alter_column_type": {"unique_id": "macro.dbt.default__alter_column_type", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "default__alter_column_type", "macro_sql": "{% macro default__alter_column_type(relation, column_name, new_column_type) -%}\n {#\n 1. Create a new column (w/ temp name and correct type)\n 2. Copy data over to it\n 3. Drop the existing column (cascade!)\n 4. Rename the new column to existing column\n #}\n {%- set tmp_column = column_name + \"__dbt_alter\" -%}\n\n {% call statement('alter_column_type') %}\n alter table {{ relation }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};\n update {{ relation }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};\n alter table {{ relation }} drop column {{ adapter.quote(column_name) }} cascade;\n alter table {{ relation }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}\n {% endcall %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.887943, "supported_languages": null}, "macro.dbt.alter_relation_add_remove_columns": {"unique_id": "macro.dbt.alter_relation_add_remove_columns", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "alter_relation_add_remove_columns", "macro_sql": "{% macro alter_relation_add_remove_columns(relation, add_columns = none, remove_columns = none) -%}\n {{ return(adapter.dispatch('alter_relation_add_remove_columns', 'dbt')(relation, add_columns, remove_columns)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8884192, "supported_languages": null}, "macro.dbt.default__alter_relation_add_remove_columns": {"unique_id": "macro.dbt.default__alter_relation_add_remove_columns", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "name": "default__alter_relation_add_remove_columns", "macro_sql": "{% macro default__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if add_columns is none %}\n {% set add_columns = [] %}\n {% endif %}\n {% if remove_columns is none %}\n {% set remove_columns = [] %}\n {% endif %}\n\n {% set sql -%}\n\n alter {{ relation.type }} {{ relation }}\n\n {% for column in add_columns %}\n add column {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}{{ ',' if add_columns and remove_columns }}\n\n {% for column in remove_columns %}\n drop column {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.889853, "supported_languages": null}, "macro.dbt.build_ref_function": {"unique_id": "macro.dbt.build_ref_function", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "name": "build_ref_function", "macro_sql": "{% macro build_ref_function(model) %}\n\n {%- set ref_dict = {} -%}\n {%- for _ref in model.refs -%}\n {%- set resolved = ref(*_ref) -%}\n {%- do ref_dict.update({_ref | join(\".\"): resolved.quote(database=False, schema=False, identifier=False) | string}) -%}\n {%- endfor -%}\n\ndef ref(*args,dbt_load_df_function):\n refs = {{ ref_dict | tojson }}\n key = \".\".join(args)\n return dbt_load_df_function(refs[key])\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.892125, "supported_languages": null}, "macro.dbt.build_source_function": {"unique_id": "macro.dbt.build_source_function", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "name": "build_source_function", "macro_sql": "{% macro build_source_function(model) %}\n\n {%- set source_dict = {} -%}\n {%- for _source in model.sources -%}\n {%- set resolved = source(*_source) -%}\n {%- do source_dict.update({_source | join(\".\"): resolved.quote(database=False, schema=False, identifier=False) | string}) -%}\n {%- endfor -%}\n\ndef source(*args, dbt_load_df_function):\n sources = {{ source_dict | tojson }}\n key = \".\".join(args)\n return dbt_load_df_function(sources[key])\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8929842, "supported_languages": null}, "macro.dbt.build_config_dict": {"unique_id": "macro.dbt.build_config_dict", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "name": "build_config_dict", "macro_sql": "{% macro build_config_dict(model) %}\n {%- set config_dict = {} -%}\n {%- for key in model.config.config_keys_used -%}\n {# weird type testing with enum, would be much easier to write this logic in Python! #}\n {%- if key == 'language' -%}\n {%- set value = 'python' -%}\n {%- endif -%}\n {%- set value = model.config[key] -%}\n {%- do config_dict.update({key: value}) -%}\n {%- endfor -%}\nconfig_dict = {{ config_dict }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.893821, "supported_languages": null}, "macro.dbt.py_script_postfix": {"unique_id": "macro.dbt.py_script_postfix", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "name": "py_script_postfix", "macro_sql": "{% macro py_script_postfix(model) %}\n# This part is user provided model code\n# you will need to copy the next section to run the code\n# COMMAND ----------\n# this part is dbt logic for get ref work, do not modify\n\n{{ build_ref_function(model ) }}\n{{ build_source_function(model ) }}\n{{ build_config_dict(model) }}\n\nclass config:\n def __init__(self, *args, **kwargs):\n pass\n\n @staticmethod\n def get(key, default=None):\n return config_dict.get(key, default)\n\nclass this:\n \"\"\"dbt.this() or dbt.this.identifier\"\"\"\n database = '{{ this.database }}'\n schema = '{{ this.schema }}'\n identifier = '{{ this.identifier }}'\n def __repr__(self):\n return '{{ this }}'\n\n\nclass dbtObj:\n def __init__(self, load_df_function) -> None:\n self.source = lambda *args: source(*args, dbt_load_df_function=load_df_function)\n self.ref = lambda *args: ref(*args, dbt_load_df_function=load_df_function)\n self.config = config\n self.this = this()\n self.is_incremental = {{ is_incremental() }}\n\n# COMMAND ----------\n{{py_script_comment()}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.build_ref_function", "macro.dbt.build_source_function", "macro.dbt.build_config_dict", "macro.dbt.is_incremental", "macro.dbt.py_script_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.894569, "supported_languages": null}, "macro.dbt.py_script_comment": {"unique_id": "macro.dbt.py_script_comment", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "name": "py_script_comment", "macro_sql": "{%macro py_script_comment()%}\n{%endmacro%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.894725, "supported_languages": null}, "macro.dbt.test_unique": {"unique_id": "macro.dbt.test_unique", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "name": "test_unique", "macro_sql": "{% test unique(model, column_name) %}\n {% set macro = adapter.dispatch('test_unique', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__test_unique"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.895741, "supported_languages": null}, "macro.dbt.test_not_null": {"unique_id": "macro.dbt.test_not_null", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "name": "test_not_null", "macro_sql": "{% test not_null(model, column_name) %}\n {% set macro = adapter.dispatch('test_not_null', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__test_not_null"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.896229, "supported_languages": null}, "macro.dbt.test_accepted_values": {"unique_id": "macro.dbt.test_accepted_values", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "name": "test_accepted_values", "macro_sql": "{% test accepted_values(model, column_name, values, quote=True) %}\n {% set macro = adapter.dispatch('test_accepted_values', 'dbt') %}\n {{ macro(model, column_name, values, quote) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__test_accepted_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.8967612, "supported_languages": null}, "macro.dbt.test_relationships": {"unique_id": "macro.dbt.test_relationships", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "name": "test_relationships", "macro_sql": "{% test relationships(model, column_name, to, field) %}\n {% set macro = adapter.dispatch('test_relationships', 'dbt') %}\n {{ macro(model, column_name, to, field) }}\n{% endtest %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__test_relationships"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1674188997.897274, "supported_languages": null}}, "docs": {"dbt.__overview__": {"unique_id": "dbt.__overview__", "package_name": "dbt", "root_path": "/Users/dflippo/opt/anaconda3/envs/dbt/lib/python3.8/site-packages/dbt/include/global_project", "path": "overview.md", "original_file_path": "docs/overview.md", "name": "__overview__", "block_contents": "### Welcome!\n\nWelcome to the auto-generated documentation for your dbt project!\n\n### Navigation\n\nYou can use the `Project` and `Database` navigation tabs on the left side of the window to explore the models\nin your project.\n\n#### Project Tab\nThe `Project` tab mirrors the directory structure of your dbt project. In this tab, you can see all of the\nmodels defined in your dbt project, as well as models imported from dbt packages.\n\n#### Database Tab\nThe `Database` tab also exposes your models, but in a format that looks more like a database explorer. This view\nshows relations (tables and views) grouped into database schemas. Note that ephemeral models are _not_ shown\nin this interface, as they do not exist in the database.\n\n### Graph Exploration\nYou can click the blue icon on the bottom-right corner of the page to view the lineage graph of your models.\n\nOn model pages, you'll see the immediate parents and children of the model you're exploring. By clicking the `Expand`\nbutton at the top-right of this lineage pane, you'll be able to see all of the models that are used to build,\nor are built from, the model you're exploring.\n\nOnce expanded, you'll be able to use the `--select` and `--exclude` model selection syntax to filter the\nmodels in the graph. For more information on model selection, check out the [dbt docs](https://docs.getdbt.com/docs/model-selection-syntax).\n\nNote that you can also right-click on models to interactively filter and explore the graph.\n\n---\n\n### More information\n\n- [What is dbt](https://docs.getdbt.com/docs/introduction)?\n- Read the [dbt viewpoint](https://docs.getdbt.com/docs/viewpoint)\n- [Installation](https://docs.getdbt.com/docs/installation)\n- Join the [dbt Community](https://www.getdbt.com/community/) for questions and discussion"}}, "exposures": {}, "metrics": {}, "selectors": {}, "disabled": {}, "parent_map": {"operation.dbt_constraints.dbt_constraints-on-run-end-0": []}, "child_map": {"operation.dbt_constraints.dbt_constraints-on-run-end-0": []}} \ No newline at end of file +{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/manifest/v12.json", "dbt_version": "1.8.5", "generated_at": "2024-08-19T18:34:12.708644Z", "invocation_id": "6248ccf8-48d0-470c-b010-2db8eb51c482", "env": {}, "project_name": "dbt_constraints", "project_id": "6511921c8841bf2635d77c9c99850470", "user_id": "163b30ee-8119-4b7c-839b-96ee37254ff3", "send_anonymous_usage_stats": true, "adapter_type": "snowflake"}, "nodes": {"operation.dbt_constraints.dbt_constraints-on-run-end-0": {"database": "DFLIPPO_DEV", "schema": "DBT_DEMO", "name": "dbt_constraints-on-run-end-0", "resource_type": "operation", "package_name": "dbt_constraints", "path": "hooks/dbt_constraints-on-run-end-0.sql", "original_file_path": "./dbt_project.yml", "unique_id": "operation.dbt_constraints.dbt_constraints-on-run-end-0", "fqn": ["dbt_constraints", "hooks", "dbt_constraints-on-run-end-0"], "alias": "dbt_constraints-on-run-end-0", "checksum": {"name": "sha256", "checksum": "bc240eb08389c27f05d8e74e436f128ee745454b0056546db5af72de5624bb6e"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}}, "tags": ["on-run-end"], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "unrendered_config": {}, "created_at": 1724092450.348017, "relation_name": null, "raw_code": "{{ dbt_constraints.create_constraints() }}", "language": "sql", "refs": [], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt_constraints.create_constraints"], "nodes": []}, "compiled_path": null, "compiled": true, "compiled_code": "", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "index": 0}}, "sources": {}, "macros": {"macro.dbt_constraints.postgres__create_primary_key": {"name": "postgres__create_primary_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "unique_id": "macro.dbt_constraints.postgres__create_primary_key", "macro_sql": "\n{%- macro postgres__create_primary_key(table_relation, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_PK\") | upper -%}\n\n {%- if constraint_name|length > 63 %}\n {%- set constraint_name_query %}\n select 'PK_' || md5( '{{ constraint_name }}' )::varchar as \"constraint_name\"\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- do log(\"Creating primary key: \" ~ constraint_name, info=true) -%}\n {%- call statement('add_pk', fetch_result=False, auto_begin=True) -%}\n ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} PRIMARY KEY ( {{columns_csv}} )\n {%- endcall -%}\n {{ adapter.commit() }}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=false) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.970808, "supported_languages": null}, "macro.dbt_constraints.postgres__create_unique_key": {"name": "postgres__create_unique_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "unique_id": "macro.dbt_constraints.postgres__create_unique_key", "macro_sql": "\n{%- macro postgres__create_unique_key(table_relation, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_UK\") | upper -%}\n\n {%- if constraint_name|length > 63 %}\n {%- set constraint_name_query %}\n select 'UK_' || md5( '{{ constraint_name }}' )::varchar as \"constraint_name\"\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- do log(\"Creating unique key: \" ~ constraint_name, info=true) -%}\n {%- call statement('add_uk', fetch_result=False, auto_begin=True) -%}\n ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} UNIQUE ( {{columns_csv}} )\n {%- endcall -%}\n {{ adapter.commit() }}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=false) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.97157, "supported_languages": null}, "macro.dbt_constraints.postgres__create_not_null": {"name": "postgres__create_not_null", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "unique_id": "macro.dbt_constraints.postgres__create_not_null", "macro_sql": "\n{%- macro postgres__create_not_null(table_relation, column_names, verify_permissions, quote_columns, lookup_cache, rely_clause) -%}\n {%- set columns_list = dbt_constraints.get_quoted_column_list(column_names, quote_columns) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set modify_statements= [] -%}\n {%- for column in columns_list -%}\n {%- set modify_statements = modify_statements.append( \"ALTER COLUMN \" ~ column ~ \" SET NOT NULL\" ) -%}\n {%- endfor -%}\n {%- set modify_statement_csv = modify_statements | join(\", \") -%}\n {%- do log(\"Creating not null constraint for: \" ~ columns_list | join(\", \") ~ \" in \" ~ table_relation, info=true) -%}\n {%- call statement('add_nn', fetch_result=False, auto_begin=True) -%}\n ALTER TABLE {{table_relation}} {{ modify_statement_csv }};\n {%- endcall -%}\n {{ adapter.commit() }}\n\n {%- else -%}\n {%- do log(\"Skipping not null constraint for \" ~ columns_list | join(\", \") ~ \" in \" ~ table_relation ~ \" because of insufficient privileges: \" ~ table_relation, info=true) -%}\n {%- endif -%}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_list", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.972136, "supported_languages": null}, "macro.dbt_constraints.postgres__create_foreign_key": {"name": "postgres__create_foreign_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "unique_id": "macro.dbt_constraints.postgres__create_foreign_key", "macro_sql": "\n{%- macro postgres__create_foreign_key(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {%- set constraint_name = (constraint_name or fk_table_relation.identifier ~ \"_\" ~ fk_column_names|join('_') ~ \"_FK\") | upper -%}\n\n {%- if constraint_name|length > 63 %}\n {%- set constraint_name_query %}\n select 'FK_' || md5( '{{ constraint_name }}' )::varchar as \"constraint_name\"\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set fk_columns_csv = dbt_constraints.get_quoted_column_csv(fk_column_names, quote_columns) -%}\n {%- set pk_columns_csv = dbt_constraints.get_quoted_column_csv(pk_column_names, quote_columns) -%}\n {#- Check that the PK table has a PK or UK -#}\n {%- if dbt_constraints.unique_constraint_exists(pk_table_relation, pk_column_names, lookup_cache) -%}\n {#- Check if the table already has this foreign key -#}\n {%- if not dbt_constraints.foreign_key_exists(fk_table_relation, fk_column_names) -%}\n\n {%- if dbt_constraints.have_ownership_priv(fk_table_relation, verify_permissions, lookup_cache) and dbt_constraints.have_references_priv(pk_table_relation, verify_permissions, lookup_cache) -%}\n\n {%- do log(\"Creating foreign key: \" ~ constraint_name ~ \" referencing \" ~ pk_table_relation.identifier ~ \" \" ~ pk_column_names, info=true) -%}\n {%- call statement('add_fk', fetch_result=False, auto_begin=True) -%}\n ALTER TABLE {{fk_table_relation}} ADD CONSTRAINT {{constraint_name}} FOREIGN KEY ( {{fk_columns_csv}} ) REFERENCES {{pk_table_relation}} ( {{pk_columns_csv}} ) ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED\n {%- endcall -%}\n {{ adapter.commit() }}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ fk_table_relation ~ \" referencing \" ~ pk_table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because FK already exists: \" ~ fk_table_relation ~ \" \" ~ fk_column_names, info=false) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because a PK/UK was not found on the PK table: \" ~ pk_table_relation ~ \" \" ~ pk_column_names, info=true) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.foreign_key_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt_constraints.have_references_priv", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.97314, "supported_languages": null}, "macro.dbt_constraints.postgres__unique_constraint_exists": {"name": "postgres__unique_constraint_exists", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "unique_id": "macro.dbt_constraints.postgres__unique_constraint_exists", "macro_sql": "\n{%- macro postgres__unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n {%- set lookup_query -%}\n select c.oid as constraint_name\n , upper(col.attname) as column_name\n from pg_constraint c\n cross join lateral unnest(c.conkey) as con(conkey)\n join pg_class tbl on tbl.oid = c.conrelid\n join pg_namespace ns on ns.oid = tbl.relnamespace\n join pg_attribute col on (col.attrelid = tbl.oid\n and col.attnum = con.conkey)\n where c.contype in ('p', 'u')\n and ns.nspname ilike '{{table_relation.schema}}'\n and tbl.relname ilike '{{table_relation.identifier}}'\n order by constraint_name\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"column_name\"].values(), column_names ) -%}\n {%- do log(\"Found PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}#}\n\n {#- If we get this far then the table does not have either constraint -#}\n {%- do log(\"No PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.column_list_matches"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.973666, "supported_languages": null}, "macro.dbt_constraints.postgres__foreign_key_exists": {"name": "postgres__foreign_key_exists", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "unique_id": "macro.dbt_constraints.postgres__foreign_key_exists", "macro_sql": "\n{%- macro postgres__foreign_key_exists(table_relation, column_names, lookup_cache) -%}\n {%- set lookup_query -%}\n select c.oid as fk_name\n , upper(col.attname) as fk_column_name\n from pg_constraint c\n cross join lateral unnest(c.conkey) as con(conkey)\n join pg_class tbl on tbl.oid = c.conrelid\n join pg_namespace ns on ns.oid = tbl.relnamespace\n join pg_attribute col on (col.attrelid = tbl.oid\n and col.attnum = con.conkey)\n where c.contype in ('f')\n and ns.nspname ilike '{{table_relation.schema}}'\n and tbl.relname ilike '{{table_relation.identifier}}'\n order by fk_name\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"fk_column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"fk_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"fk_column_name\"].values(), column_names ) -%}\n {%- do log(\"Found FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {#- If we get this far then the table does not have this constraint -#}\n {%- do log(\"No FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.column_list_matches"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.974195, "supported_languages": null}, "macro.dbt_constraints.postgres__have_references_priv": {"name": "postgres__have_references_priv", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "unique_id": "macro.dbt_constraints.postgres__have_references_priv", "macro_sql": "{%- macro postgres__have_references_priv(table_relation, verify_permissions, lookup_cache) -%}\n {%- if verify_permissions is sameas true -%}\n\n {%- set lookup_query -%}\n select case when count(*) > 0 then 'y' else 'n' end as \"have_references\"\n from information_schema.table_privileges t\n join information_schema.enabled_roles er on t.grantee = er.role_name\n where upper(t.table_schema) = upper('{{table_relation.schema}}')\n and upper(t.table_name) = upper('{{table_relation.identifier}}')\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set results = run_query(lookup_query) -%}\n {%- if \"y\" in( results.columns[\"have_references\"].values() ) -%}\n {{ return(true) }}\n {%- endif -%}\n\n {{ return(false) }}\n {%- else -%}\n {{ return(true) }}\n {%- endif -%}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.974546, "supported_languages": null}, "macro.dbt_constraints.postgres__have_ownership_priv": {"name": "postgres__have_ownership_priv", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "unique_id": "macro.dbt_constraints.postgres__have_ownership_priv", "macro_sql": "{%- macro postgres__have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n {%- if verify_permissions is sameas true -%}\n\n {%- set lookup_query -%}\n select case when count(*) > 0 then 'y' else 'n' end as \"have_ownership\"\n from pg_catalog.pg_tables t\n join information_schema.enabled_roles er on t.tableowner = er.role_name\n where upper(t.schemaname) = upper('{{table_relation.schema}}')\n and upper(t.tablename) = upper('{{table_relation.identifier}}')\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set results = run_query(lookup_query) -%}\n {%- if \"y\" in( results.columns[\"have_ownership\"].values() ) -%}\n {{ return(true) }}\n {%- endif -%}\n\n {{ return(false) }}\n {%- else -%}\n {{ return(true) }}\n {%- endif -%}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.974899, "supported_languages": null}, "macro.dbt_constraints.postgres__drop_referential_constraints": {"name": "postgres__drop_referential_constraints", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "unique_id": "macro.dbt_constraints.postgres__drop_referential_constraints", "macro_sql": "{% macro postgres__drop_referential_constraints(relation) -%}\n {%- set lookup_query -%}\n select constraint_name\n from information_schema.table_constraints\n where table_schema = '{{relation.schema}}'\n and table_name='{{relation.identifier}}'\n and constraint_type in ('FOREIGN KEY', 'PRIMARY KEY', 'UNIQUE')\n {%- endset -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n\n {%- for constraint_name in constraint_list.columns[\"constraint_name\"].values() -%}\n {%- do log(\"Dropping constraint: \" ~ constraint_name ~ \" from table \" ~ relation, info=false) -%}\n {%- call statement('drop_constraint_cascade', fetch_result=False, auto_begin=True) -%}\n ALTER TABLE {{relation}} DROP CONSTRAINT IF EXISTS \"{{constraint_name}}\" CASCADE\n {%- endcall -%}\n {{ adapter.commit() }}\n {% endfor %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.975243, "supported_languages": null}, "macro.dbt_constraints.postgres__truncate_relation": {"name": "postgres__truncate_relation", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "unique_id": "macro.dbt_constraints.postgres__truncate_relation", "macro_sql": "{% macro postgres__truncate_relation(relation) -%}\n {{ postgres__drop_referential_constraints(relation) }}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_constraints.postgres__drop_referential_constraints", "macro.dbt_constraints.truncate_relation", "macro.dbt_snowflake.snowflake__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.975369, "supported_languages": null}, "macro.dbt_constraints.postgres__drop_relation": {"name": "postgres__drop_relation", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/postgres__create_constraints.sql", "original_file_path": "macros/postgres__create_constraints.sql", "unique_id": "macro.dbt_constraints.postgres__drop_relation", "macro_sql": "{% macro postgres__drop_relation(relation) -%}\n {{ postgres__drop_referential_constraints(relation) }}\n {{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_constraints.postgres__drop_referential_constraints", "macro.dbt_constraints.drop_relation", "macro.dbt.default__drop_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.975502, "supported_languages": null}, "macro.dbt_constraints.default__test_primary_key": {"name": "default__test_primary_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/default__test_constraints.sql", "original_file_path": "macros/default__test_constraints.sql", "unique_id": "macro.dbt_constraints.default__test_primary_key", "macro_sql": "\n{%- macro default__test_primary_key(model, column_names, quote_columns=false) -%}\n{#\nNOTE: This test is designed to implement the \"primary key\" as specified in ANSI SQL 92 which states the following:\n \"A unique constraint is satisfied if and only if no two rows in\n a table have the same non-null values in the unique columns. In\n addition, if the unique constraint was defined with PRIMARY KEY,\n then it requires that none of the values in the specified column or\n columns be the null value.\"\n#}\n\n{%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) %}\n\n{#- This test will return for any duplicates and if any of the key columns is null -#}\nwith validation_errors as (\n select\n {{columns_csv}}, count(*) as row_count\n from {{model}}\n group by {{columns_csv}}\n having count(*) > 1\n {% for column in column_names -%}\n or {{column}} is null\n {% endfor %}\n)\n\nselect *\nfrom validation_errors\n\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.976375, "supported_languages": null}, "macro.dbt_constraints.default__test_unique_key": {"name": "default__test_unique_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/default__test_constraints.sql", "original_file_path": "macros/default__test_constraints.sql", "unique_id": "macro.dbt_constraints.default__test_unique_key", "macro_sql": "\n{%- macro default__test_unique_key(model, column_names, quote_columns=false) -%}\n{#\nNOTE: This test is designed to implement the \"unique constraint\" as specified in ANSI SQL 92 which states the following:\n \"A unique constraint is satisfied if and only if no two rows in\n a table have the same non-null values in the unique columns.\"\n#}\n\n{%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) %}\n\n{#- This test will return any duplicates -#}\nwith validation_errors as (\n select\n {{columns_csv}}\n from {{model}}\n group by {{columns_csv}}\n having count(*) > 1\n)\n\nselect *\nfrom validation_errors\n\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.976532, "supported_languages": null}, "macro.dbt_constraints.default__test_foreign_key": {"name": "default__test_foreign_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/default__test_constraints.sql", "original_file_path": "macros/default__test_constraints.sql", "unique_id": "macro.dbt_constraints.default__test_foreign_key", "macro_sql": "\n{%- macro default__test_foreign_key(model, fk_column_names, pk_table_name, pk_column_names, quote_columns=false) -%}\n{#\nNOTE: This test is designed to implement the \"referential constraint\" as specified in ANSI SQL 92 which states the following:\n \"A referential constraint is satisfied if one of the following con-\n ditions is true, depending on the specified in the\n :\n\n - If no was specified then, for each row R1 of the\n referencing table, either at least one of the values of the\n referencing columns in R1 shall be a null value, or the value of\n each referencing column in R1 shall be equal to the value of the\n corresponding referenced column in some row of the referenced\n table.\"\n\nThe implications of this standard is that if one column is NULL in a compound foreign key, the other column\ndoes NOT need to match a row in a referenced unique key. This is implemented by first excluding any\nrows from the test that have a NULL value in any of the columns.\n#}\n\n{%- set fk_columns_list=dbt_constraints.get_quoted_column_list(fk_column_names, quote_columns) %}\n{%- set pk_columns_list=dbt_constraints.get_quoted_column_list(pk_column_names, quote_columns) %}\n{%- set fk_columns_csv=dbt_constraints.get_quoted_column_csv(fk_column_names, quote_columns) %}\n{%- set pk_columns_csv=dbt_constraints.get_quoted_column_csv(pk_column_names, quote_columns) %}\n{%- set join_conditions = [] -%}\n{%- for x in range(fk_columns_list|count) -%}\n {%- set join_conditions = join_conditions.append( 'parent.' ~ pk_columns_list[x] ~ ' = child.' ~ fk_columns_list[x] ) -%}\n{%- endfor -%}\n\n{#- This test will return if all the columns are not null\n and the values are not found in the referenced PK table #}\nwith child as (\n select\n {{fk_columns_csv}}\n from {{model}}\n where 1=1\n {% for column in fk_columns_list -%}\n and {{column}} is not null\n {% endfor %}\n),\n\nparent as (\n select\n {{pk_columns_csv}}\n from {{pk_table_name}}\n),\n\nvalidation_errors as (\n select\n child.*\n from child\n left join parent\n on {{join_conditions | join(' and ')}}\n\n where parent.{{pk_columns_list | first}} is null\n)\n\nselect *\nfrom validation_errors\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_list", "macro.dbt_constraints.get_quoted_column_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.977041, "supported_languages": null}, "macro.dbt_constraints.get_quoted_column_list": {"name": "get_quoted_column_list", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/default__test_constraints.sql", "original_file_path": "macros/default__test_constraints.sql", "unique_id": "macro.dbt_constraints.get_quoted_column_list", "macro_sql": "{%- macro get_quoted_column_list(column_array, quote_columns=false) -%}\n\n {%- if not quote_columns -%}\n {%- set column_list=column_array -%}\n {%- elif quote_columns -%}\n {%- set column_list=[] -%}\n {%- for column in column_array -%}\n {%- set column_list = column_list.append( adapter.quote(column) ) -%}\n {%- endfor -%}\n {%- else -%}\n {{ exceptions.raise_compiler_error(\n \"`quote_columns` argument must be one of [True, False] Got: '\" ~ quote ~\"'.'\"\n ) }}\n {%- endif -%}\n\n {{ return(column_list) }}\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.9773262, "supported_languages": null}, "macro.dbt_constraints.get_quoted_column_csv": {"name": "get_quoted_column_csv", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/default__test_constraints.sql", "original_file_path": "macros/default__test_constraints.sql", "unique_id": "macro.dbt_constraints.get_quoted_column_csv", "macro_sql": "{%- macro get_quoted_column_csv(column_array, quote_columns=false) -%}\n\n {%- set column_list = dbt_constraints.get_quoted_column_list(column_array, quote_columns) -%}\n {%- set columns_csv=column_list | join(', ') -%}\n {{ return(columns_csv) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_list"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.977487, "supported_languages": null}, "macro.dbt_constraints.test_primary_key": {"name": "test_primary_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.test_primary_key", "macro_sql": "\n\n{%- test primary_key(model,\n column_name=none, column_names=[],\n quote_columns=false, constraint_name=none) -%}\n\n {%- if column_names|count == 0 and column_name -%}\n {%- do column_names.append(column_name) -%}\n {%- endif -%}\n\n {{ return(adapter.dispatch('test_primary_key', 'dbt_constraints')(model, column_names, quote_columns)) }}\n\n{%- endtest -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.default__test_primary_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.98208, "supported_languages": null}, "macro.dbt_constraints.test_unique_key": {"name": "test_unique_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.test_unique_key", "macro_sql": "{%- test unique_key(model,\n column_name=none, column_names=[],\n quote_columns=false, constraint_name=none) -%}\n\n {%- if column_names|count == 0 and column_name -%}\n {%- do column_names.append(column_name) -%}\n {%- endif -%}\n\n {{ return(adapter.dispatch('test_unique_key', 'dbt_constraints')(model, column_names, quote_columns)) }}\n\n{%- endtest -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.default__test_unique_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.9823081, "supported_languages": null}, "macro.dbt_constraints.test_foreign_key": {"name": "test_foreign_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.test_foreign_key", "macro_sql": "{%- test foreign_key(model,\n column_name=none, fk_column_name=none, fk_column_names=[],\n pk_table_name=none, to=none,\n pk_column_name=none, pk_column_names=[], field=none,\n quote_columns=false, constraint_name=none) -%}\n\n {%- if pk_column_names|count == 0 and (pk_column_name or field) -%}\n {%- do pk_column_names.append( (pk_column_name or field) ) -%}\n {%- endif -%}\n {%- if fk_column_names|count == 0 and (fk_column_name or column_name) -%}\n {%- do fk_column_names.append( (fk_column_name or column_name) ) -%}\n {%- endif -%}\n {%- set pk_table_name = pk_table_name or to -%}\n\n {{ return(adapter.dispatch('test_foreign_key', 'dbt_constraints')(model, fk_column_names, pk_table_name, pk_column_names, quote_columns)) }}\n\n{%- endtest -%}\n\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.default__test_foreign_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.9827468, "supported_languages": null}, "macro.dbt_constraints.create_primary_key": {"name": "create_primary_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.create_primary_key", "macro_sql": "\n\n{%- macro create_primary_key(table_model, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {{ return(adapter.dispatch('create_primary_key', 'dbt_constraints')(table_model, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause)) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.snowflake__create_primary_key"]}, "description": "Calls the adapter-specific version of the macro to create a primary key", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": "dbt_constraints://macros/macros.yml", "arguments": [{"name": "table_model", "type": "graph node", "description": "Accepts the graph node of the table that will have the constraint"}, {"name": "column_names", "type": "array of column names", "description": "An array of text column names to include in the constraint"}, {"name": "quote_columns", "type": "boolean", "description": "Whether to wrap column names in double quotes. By default this is set to false."}, {"name": "constraint_name", "type": "string", "description": "Name of the constraint. If not specified, a constraint name will be generated."}], "created_at": 1724092450.4029288, "supported_languages": null}, "macro.dbt_constraints.create_unique_key": {"name": "create_unique_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.create_unique_key", "macro_sql": "{%- macro create_unique_key(table_model, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {{ return(adapter.dispatch('create_unique_key', 'dbt_constraints')(table_model, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause)) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.snowflake__create_unique_key"]}, "description": "Calls the adapter-specific version of the macro to create a unique key", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": "dbt_constraints://macros/macros.yml", "arguments": [{"name": "table_model", "type": "graph node", "description": "Accepts the graph node of the table that will have the constraint"}, {"name": "column_names", "type": "array of column names", "description": "An array of text column names to include in the constraint"}, {"name": "quote_columns", "type": "boolean", "description": "Whether to wrap column names in double quotes. By default this is set to false."}, {"name": "constraint_name", "type": "string", "description": "Name of the constraint. If not specified, a constraint name will be generated."}], "created_at": 1724092450.403154, "supported_languages": null}, "macro.dbt_constraints.create_foreign_key": {"name": "create_foreign_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.create_foreign_key", "macro_sql": "{%- macro create_foreign_key(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {{ return(adapter.dispatch('create_foreign_key', 'dbt_constraints')(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause)) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.snowflake__create_foreign_key"]}, "description": "Calls the adapter-specific version of the macro to create a foreign key", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": "dbt_constraints://macros/macros.yml", "arguments": [{"name": "test_model", "type": "results node", "description": "Accepts the result node of the test related to this constraint"}, {"name": "pk_model", "type": "graph node", "description": "Accepts the graph node of the parent table that has a PK or UK"}, {"name": "column_names", "type": "array of column names", "description": "An array of text column names to include in the FK reference"}, {"name": "fk_model", "type": "graph node", "description": "Accepts the graph node of the table that will have the constraint"}, {"name": "fk_column_names", "type": "array of column names", "description": "An array of text column names to include in the constraint"}, {"name": "quote_columns", "type": "boolean", "description": "Whether to wrap column names in double quotes. By default this is set to false."}, {"name": "constraint_name", "type": "string", "description": "Name of the constraint. If not specified, a constraint name will be generated."}], "created_at": 1724092450.403939, "supported_languages": null}, "macro.dbt_constraints.create_not_null": {"name": "create_not_null", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.create_not_null", "macro_sql": "{%- macro create_not_null(table_relation, column_names, verify_permissions, quote_columns, lookup_cache, rely_clause) -%}\n {{ return(adapter.dispatch('create_not_null', 'dbt_constraints')(table_relation, column_names, verify_permissions, quote_columns, lookup_cache, rely_clause)) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.snowflake__create_not_null"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.9834409, "supported_languages": null}, "macro.dbt_constraints.unique_constraint_exists": {"name": "unique_constraint_exists", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.unique_constraint_exists", "macro_sql": "\n\n{%- macro unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n {{ return(adapter.dispatch('unique_constraint_exists', 'dbt_constraints')(table_relation, column_names, lookup_cache) ) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_constraints.snowflake__unique_constraint_exists"]}, "description": "Calls the adapter-specific version of the macro to check if a PK or UK already exists", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": "dbt_constraints://macros/macros.yml", "arguments": [{"name": "table_relation", "type": "relation", "description": "Accepts the relation of the table to check"}, {"name": "column_names", "type": "array of column names", "description": "An array of text column names the constraint must contain"}], "created_at": 1724092450.4042969, "supported_languages": null}, "macro.dbt_constraints.foreign_key_exists": {"name": "foreign_key_exists", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.foreign_key_exists", "macro_sql": "{%- macro foreign_key_exists(table_relation, column_names, lookup_cache) -%}\n {{ return(adapter.dispatch('foreign_key_exists', 'dbt_constraints')(table_relation, column_names, lookup_cache)) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.snowflake__foreign_key_exists"]}, "description": "Calls the adapter-specific version of the macro to check if a foreign key already exists", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": "dbt_constraints://macros/macros.yml", "arguments": [{"name": "table_relation", "type": "relation", "description": "Accepts the relation of the table to check"}, {"name": "column_names", "type": "array of column names", "description": "An array of text column names the constraint must contain"}], "created_at": 1724092450.404477, "supported_languages": null}, "macro.dbt_constraints.have_references_priv": {"name": "have_references_priv", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.have_references_priv", "macro_sql": "\n\n{%- macro have_references_priv(table_relation, verify_permissions, lookup_cache) -%}\n {{ return(adapter.dispatch('have_references_priv', 'dbt_constraints')(table_relation, verify_permissions, lookup_cache) ) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_constraints.snowflake__have_references_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.983806, "supported_languages": null}, "macro.dbt_constraints.have_ownership_priv": {"name": "have_ownership_priv", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.have_ownership_priv", "macro_sql": "{%- macro have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n {{ return(adapter.dispatch('have_ownership_priv', 'dbt_constraints')(table_relation, verify_permissions, lookup_cache)) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.snowflake__have_ownership_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.983924, "supported_languages": null}, "macro.dbt_constraints.adapter_supports_rely_norely": {"name": "adapter_supports_rely_norely", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.adapter_supports_rely_norely", "macro_sql": "\n\n{%- macro adapter_supports_rely_norely(test_name) -%}\n {{ return(adapter.dispatch('adapter_supports_rely_norely', 'dbt_constraints')(test_name)) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_constraints.snowflake__adapter_supports_rely_norely"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.984023, "supported_languages": null}, "macro.dbt_constraints.default__adapter_supports_rely_norely": {"name": "default__adapter_supports_rely_norely", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.default__adapter_supports_rely_norely", "macro_sql": "\n{%- macro default__adapter_supports_rely_norely(test_name) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.9840908, "supported_languages": null}, "macro.dbt_constraints.truncate_relation": {"name": "truncate_relation", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.truncate_relation", "macro_sql": "{% macro truncate_relation(relation) -%}\n {{ return(adapter.dispatch('truncate_relation')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.98418, "supported_languages": null}, "macro.dbt_constraints.drop_relation": {"name": "drop_relation", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.drop_relation", "macro_sql": "{% macro drop_relation(relation) -%}\n {{ return(adapter.dispatch('drop_relation')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.9842718, "supported_languages": null}, "macro.dbt_constraints.create_constraints": {"name": "create_constraints", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.create_constraints", "macro_sql": "\n{%- macro create_constraints(\n constraint_types=[\n 'primary_key',\n 'unique_key',\n 'unique_combination_of_columns',\n 'unique',\n 'foreign_key',\n 'relationships',\n 'not_null'],\n quote_columns=false) -%}\n {%- if execute and var('dbt_constraints_enabled', false) and results -%}\n {%- do log(\"Running dbt Constraints\", info=true) -%}\n\n {%- set lookup_cache = {\n \"table_columns\": { },\n \"table_privileges\": { },\n \"unique_keys\": { },\n \"not_null_col\": { },\n \"foreign_keys\": { } } -%}\n\n {%- if 'not_null' in constraint_types -%}\n {%- do dbt_constraints.create_constraints_by_type(['not_null'], quote_columns, lookup_cache) -%}\n {%- endif -%}\n {%- if 'primary_key' in constraint_types -%}\n {%- do dbt_constraints.create_constraints_by_type(['primary_key'], quote_columns, lookup_cache) -%}\n {%- endif -%}\n {%- if 'unique_key' in constraint_types -%}\n {%- do dbt_constraints.create_constraints_by_type(['unique_key'], quote_columns, lookup_cache) -%}\n {%- endif -%}\n {%- if 'unique_combination_of_columns' in constraint_types -%}\n {%- do dbt_constraints.create_constraints_by_type(['unique_combination_of_columns'], quote_columns, lookup_cache) -%}\n {%- endif -%}\n {%- if 'unique' in constraint_types -%}\n {%- do dbt_constraints.create_constraints_by_type(['unique'], quote_columns, lookup_cache) -%}\n {%- endif -%}\n {%- if 'foreign_key' in constraint_types -%}\n {%- do dbt_constraints.create_constraints_by_type(['foreign_key'], quote_columns, lookup_cache) -%}\n {%- endif -%}\n {%- if 'relationships' in constraint_types -%}\n {%- do dbt_constraints.create_constraints_by_type(['relationships'], quote_columns, lookup_cache) -%}\n {%- endif -%}\n\n {%- do log(\"Finished dbt Constraints\", info=true) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.create_constraints_by_type"]}, "description": "Primary macro automatically called `on-run-end` to generate primary keys, unique keys, and foreign keys. The `dbt_constraints_enabled` variable can be set to `false` in your project to disable this macro.", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": "dbt_constraints://macros/macros.yml", "arguments": [{"name": "constraint_types", "type": "array of constraint types", "description": "Accepts a list of tests to consider for constraint creation and whether columns should be quoted. By default it will create all the constraint types. Valid values are ['primary_key', 'unique_key', 'unique_combination_of_columns', 'unique', 'foreign_key', 'relationships']"}, {"name": "quote_columns", "type": "boolean", "description": "Whether to wrap column names in double quotes. By default this is set to false."}], "created_at": 1724092450.402108, "supported_languages": null}, "macro.dbt_constraints.test_selected": {"name": "test_selected", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.test_selected", "macro_sql": "\n{%- macro test_selected(test_model) -%}\n\n {%- if test_model.unique_id and test_model.unique_id in selected_resources -%}\n {{ return(\"TEST_SELECTED\") }}\n {%- endif -%}\n {%- if test_model.attached_node and test_model.attached_node in selected_resources -%} -%}\n {{ return(\"MODEL_SELECTED\") }}\n {%- endif -%}\n\n {#- Check if a PK/UK should be created because it is referenced by a selected FK -#}\n {%- if test_model.test_metadata\n and test_model.test_metadata.name in (\"primary_key\", \"unique_key\", \"unique_combination_of_columns\", \"unique\") -%}\n {%- set pk_test_args = test_model.test_metadata.kwargs -%}\n {%- set pk_test_columns = [] -%}\n {%- if pk_test_args.column_names -%}\n {%- set pk_test_columns = pk_test_args.column_names -%}\n {%- elif pk_test_args.combination_of_columns -%}\n {%- set pk_test_columns = pk_test_args.combination_of_columns -%}\n {%- elif pk_test_args.column_name -%}\n {%- set pk_test_columns = [pk_test_args.column_name] -%}\n {%- endif -%}\n {%- for fk_model in graph.nodes.values() | selectattr(\"resource_type\", \"equalto\", \"test\")\n if fk_model.test_metadata\n and fk_model.test_metadata.name in (\"foreign_key\", \"relationships\")\n and test_model.attached_node in fk_model.depends_on.nodes\n and ( (fk_model.unique_id and fk_model.unique_id in selected_resources)\n or (fk_model.attached_node and fk_model.attached_node in selected_resources) ) -%}\n {%- set fk_test_args = fk_model.test_metadata.kwargs -%}\n {%- set fk_test_columns = [] -%}\n {%- if fk_test_args.pk_column_names -%}\n {%- set fk_test_columns = fk_test_args.pk_column_names -%}\n {%- elif fk_test_args.pk_column_name -%}\n {%- set fk_test_columns = [fk_test_args.pk_column_name] -%}\n {%- elif fk_test_args.field -%}\n {%- set fk_test_columns = [fk_test_args.field] -%}\n {%- endif -%}\n {%- if column_list_matches(pk_test_columns, fk_test_columns) -%}\n {{ return(\"PK_UK_FOR_SELECTED_FK\") }}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n\n {{ return(none) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.column_list_matches"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.986103, "supported_languages": null}, "macro.dbt_constraints.lookup_should_rely": {"name": "lookup_should_rely", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.lookup_should_rely", "macro_sql": "\n{%- macro lookup_should_rely(test_model) -%}\n {%- if test_model.config.where\n or test_model.config.warn_if != \"!= 0\"\n or test_model.config.fail_calc != \"count(*)\" -%}\n {#- Set NORELY if there is a condition on the test -#}\n {{ return('NORELY') }}\n {%- endif -%}\n\n {%- for res in results\n if res.node.config.materialized == \"test\"\n and res.node.unique_id == test_model.unique_id -%}\n {%- if res.failures > 0 -%}\n {#- Set NORELY if there is a test failure -#}\n {{ return('NORELY') }}\n {%- elif res.failures == 0 -%}\n {#- Set RELY if there are 0 failures -#}\n {{ return('RELY') }}\n {%- endif -%}\n {%- endfor -%}\n {{ return('') }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.986455, "supported_languages": null}, "macro.dbt_constraints.should_always_create_constraint": {"name": "should_always_create_constraint", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.should_always_create_constraint", "macro_sql": "\n{%- macro should_always_create_constraint(test_model) -%}\n {%- if test_model.config.get(\"always_create_constraint\", false) == true -%}\n {{ return(true) }}\n {%- endif -%}\n {%- for table_node in test_model.depends_on.nodes -%}\n {%- for node in graph.nodes.values() | selectattr(\"unique_id\", \"equalto\", table_node)\n if node.config.get(\"always_create_constraint\", false) == true -%}\n {{ return(true) }}\n {%- endfor -%}\n {%- endfor -%}\n\n {{ return(false) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.98676, "supported_languages": null}, "macro.dbt_constraints.create_constraints_by_type": {"name": "create_constraints_by_type", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.create_constraints_by_type", "macro_sql": "\n{%- macro create_constraints_by_type(constraint_types, quote_columns, lookup_cache) -%}\n\n {#- Loop through the metadata and find all tests that match the constraint_types -#}\n {%- for test_model in graph.nodes.values() | selectattr(\"resource_type\", \"equalto\", \"test\")\n if test_model.test_metadata\n and test_model.test_metadata.name is in( constraint_types )\n and test_model.config.enabled\n and test_model.config.get(\"dbt_constraints_enabled\", true) -%}\n\n {%- set test_parameters = test_model.test_metadata.kwargs -%}\n {%- set test_name = test_model.test_metadata.name -%}\n {%- set selected = dbt_constraints.test_selected(test_model) -%}\n\n {#- We can shortcut additional tests if the constraint was not selected -#}\n {%- if selected is not none -%}\n {#- rely_clause clause will be RELY if a test passed, NORELY if it failed, and '' if it was skipped -#}\n {%- set rely_clause = dbt_constraints.lookup_should_rely(test_model) -%}\n {%- set always_create_constraint = dbt_constraints.should_always_create_constraint(test_model) -%}\n {%- else -%}\n {%- set rely_clause = '' -%}\n {%- set always_create_constraint = false -%}\n {%- endif -%}\n\n {#- Create constraints that:\n - Either the test or its model was selected to run, including PK/UK for FK\n - Passed the test (RELY) or the database supports NORELY constraints\n - We ran the test (RELY/NORELY) or we need the constraint for a FK\n or we have the always_create_constraint parameter turned on -#}\n {%- if selected is not none\n and ( rely_clause == 'RELY'\n or dbt_constraints.adapter_supports_rely_norely(test_name) == true )\n and ( rely_clause in('RELY', 'NORELY')\n or selected == \"PK_UK_FOR_SELECTED_FK\"\n or always_create_constraint == true ) -%}\n\n {% set ns = namespace(verify_permissions=false) %}\n {%- set table_models = [] -%}\n\n {#- Find the table models that are referenced by this test. -#}\n {%- for table_node in test_model.depends_on.nodes -%}\n {%- for node in graph.nodes.values() | selectattr(\"unique_id\", \"equalto\", table_node)\n if node.config.get(\"materialized\", \"other\") not in (\"view\", \"ephemeral\", \"dynamic_table\")\n and ( node.resource_type in (\"model\", \"snapshot\", \"seed\")\n or ( node.resource_type == \"source\" and var('dbt_constraints_sources_enabled', false)\n and ( ( var('dbt_constraints_sources_pk_enabled', false) and test_name in(\"primary_key\") )\n or ( var('dbt_constraints_sources_uk_enabled', false) and test_name in(\"unique_key\", \"unique_combination_of_columns\", \"unique\") )\n or ( var('dbt_constraints_sources_fk_enabled', false) and test_name in(\"foreign_key\", \"relationships\") )\n or ( var('dbt_constraints_sources_nn_enabled', false) and test_name in(\"not_null\") ) )\n ) ) -%}\n\n {%- do node.update({'alias': node.alias or node.name }) -%}\n {#- Append to our list of models for this test -#}\n {%- do table_models.append(node) -%}\n {%- if node.resource_type == \"source\"\n or node.config.get(\"materialized\", \"other\") not in (\"table\", \"incremental\", \"snapshot\", \"seed\") -%}\n {#- If we are using a sources or custom materializations, we will need to verify permissions -#}\n {%- set ns.verify_permissions = true -%}\n {%- endif -%}\n\n {% endfor %}\n {% endfor %}\n\n {#- We only create PK/UK if there is one model referenced by the test\n and if all the columns exist as physical columns on the table -#}\n {%- if 1 == table_models|count\n and test_name in(\"primary_key\", \"unique_key\", \"unique_combination_of_columns\", \"unique\") -%}\n\n {# Attempt to identify a parameter we can use for the column names #}\n {%- set column_names = [] -%}\n {%- if test_parameters.column_names -%}\n {%- set column_names = test_parameters.column_names -%}\n {%- elif test_parameters.combination_of_columns -%}\n {%- set column_names = test_parameters.combination_of_columns -%}\n {%- elif test_parameters.column_name -%}\n {%- set column_names = [test_parameters.column_name] -%}\n {%- else -%}\n {{ exceptions.raise_compiler_error(\n \"`column_names` or `column_name` parameter missing for primary/unique key constraint on table: '\" ~ table_models[0].name\n ) }}\n {%- endif -%}\n\n {%- set table_relation = api.Relation.create(\n database=table_models[0].database,\n schema=table_models[0].schema,\n identifier=table_models[0].alias ) -%}\n {%- if dbt_constraints.table_columns_all_exist(table_relation, column_names, lookup_cache) -%}\n {%- if test_name == \"primary_key\" -%}\n {%- if dbt_constraints.adapter_supports_rely_norely(\"not_null\") == true -%}\n {%- do dbt_constraints.create_not_null(table_relation, column_names, ns.verify_permissions, quote_columns, lookup_cache, rely_clause) -%}\n {%- endif -%}\n {%- do dbt_constraints.create_primary_key(table_relation, column_names, ns.verify_permissions, quote_columns, test_parameters.constraint_name, lookup_cache, rely_clause) -%}\n {%- else -%}\n {%- do dbt_constraints.create_unique_key(table_relation, column_names, ns.verify_permissions, quote_columns, test_parameters.constraint_name, lookup_cache, rely_clause) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping primary/unique key because a physical column name was not found on the table: \" ~ table_models[0].name ~ \" \" ~ column_names, info=true) -%}\n {%- endif -%}\n\n {#- We only create FK if there are two models referenced by the test\n and if all the columns exist as physical columns on the tables -#}\n {%- elif 2 == table_models|count\n and test_name in( \"foreign_key\", \"relationships\") -%}\n\n {%- set fk_model = table_models | selectattr(\"unique_id\", \"equalto\", test_model.attached_node) | first -%}\n {%- set pk_model = table_models | rejectattr(\"unique_id\", \"equalto\", test_model.attached_node) | first -%}\n\n {%- if fk_model and pk_model -%}\n\n {%- set fk_table_relation = api.Relation.create(\n database=fk_model.database,\n schema=fk_model.schema,\n identifier=fk_model.alias) -%}\n\n {%- set pk_table_relation = api.Relation.create(\n database=pk_model.database,\n schema=pk_model.schema,\n identifier=pk_model.alias) -%}\n\n {# Attempt to identify parameters we can use for the column names #}\n {%- set pk_column_names = [] -%}\n {%- if test_parameters.pk_column_names -%}\n {%- set pk_column_names = test_parameters.pk_column_names -%}\n {%- elif test_parameters.field -%}\n {%- set pk_column_names = [test_parameters.field] -%}\n {%- elif test_parameters.pk_column_name -%}\n {%- set pk_column_names = [test_parameters.pk_column_name] -%}\n {%- else -%}\n {{ exceptions.raise_compiler_error(\n \"`pk_column_names`, `pk_column_name`, or `field` parameter missing for foreign key constraint on table: '\" ~ fk_model.name ~ \" \" ~ test_parameters\n ) }}\n {%- endif -%}\n\n {%- set fk_column_names = [] -%}\n {%- if test_parameters.fk_column_names -%}\n {%- set fk_column_names = test_parameters.fk_column_names -%}\n {%- elif test_parameters.column_name -%}\n {%- set fk_column_names = [test_parameters.column_name] -%}\n {%- elif test_parameters.fk_column_name -%}\n {%- set fk_column_names = [test_parameters.fk_column_name] -%}\n {%- else -%}\n {{ exceptions.raise_compiler_error(\n \"`fk_column_names`, `fk_column_name`, or `column_name` parameter missing for foreign key constraint on table: '\" ~ fk_model.name ~ \" \" ~ test_parameters\n ) }}\n {%- endif -%}\n\n {%- if not dbt_constraints.table_columns_all_exist(pk_table_relation, pk_column_names, lookup_cache) -%}\n {%- do log(\"Skipping foreign key because a physical column was not found on the pk table: \" ~ pk_model.name ~ \" \" ~ pk_column_names, info=true) -%}\n {%- elif not dbt_constraints.table_columns_all_exist(fk_table_relation, fk_column_names, lookup_cache) -%}\n {%- do log(\"Skipping foreign key because a physical column was not found on the fk table: \" ~ fk_model.name ~ \" \" ~ fk_column_names, info=true) -%}\n {%- else -%}\n {%- do dbt_constraints.create_foreign_key(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, ns.verify_permissions, quote_columns, test_parameters.constraint_name, lookup_cache, rely_clause) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping foreign key because a we couldn't find the child table: model=\" ~ test_model.attached_node ~ \" or source\", info=true) -%}\n {%- endif -%}\n\n {#- We only create NN if there is one model referenced by the test\n and if all the columns exist as physical columns on the table -#}\n {%- elif 1 == table_models|count\n and test_name in(\"not_null\") -%}\n\n {# Attempt to identify a parameter we can use for the column names #}\n {%- set column_names = [] -%}\n {%- if test_parameters.column_names -%}\n {%- set column_names = test_parameters.column_names -%}\n {%- elif test_parameters.combination_of_columns -%}\n {%- set column_names = test_parameters.combination_of_columns -%}\n {%- elif test_parameters.column_name -%}\n {%- set column_names = [test_parameters.column_name] -%}\n {%- else -%}\n {{ exceptions.raise_compiler_error(\n \"`column_names` or `column_name` parameter missing for not null constraint on table: '\" ~ table_models[0].name\n ) }}\n {%- endif -%}\n\n {%- set table_relation = api.Relation.create(\n database=table_models[0].database,\n schema=table_models[0].schema,\n identifier=table_models[0].alias ) -%}\n\n {%- if dbt_constraints.table_columns_all_exist(table_relation, column_names, lookup_cache) -%}\n {%- do dbt_constraints.create_not_null(table_relation, column_names, ns.verify_permissions, quote_columns, lookup_cache, rely_clause) -%}\n {%- else -%}\n {%- do log(\"Skipping not null constraint because a physical column name was not found on the table: \" ~ table_models[0].name ~ \" \" ~ column_names, info=true) -%}\n {%- endif -%}\n\n {%- endif -%}\n {%- endif -%}\n\n\n {%- endfor -%}\n\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.test_selected", "macro.dbt_constraints.lookup_should_rely", "macro.dbt_constraints.should_always_create_constraint", "macro.dbt_constraints.adapter_supports_rely_norely", "macro.dbt_constraints.table_columns_all_exist", "macro.dbt_constraints.create_not_null", "macro.dbt_constraints.create_primary_key", "macro.dbt_constraints.create_unique_key", "macro.dbt_constraints.create_foreign_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.9906602, "supported_languages": null}, "macro.dbt_constraints.table_columns_all_exist": {"name": "table_columns_all_exist", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.table_columns_all_exist", "macro_sql": "\n{%- macro table_columns_all_exist(table_relation, column_list, lookup_cache) -%}\n {%- set tab_column_list = dbt_constraints.lookup_table_columns(table_relation, lookup_cache) -%}\n\n {%- for column in column_list|map('upper') if column not in tab_column_list -%}\n {{ return(false) }}\n {%- endfor -%}\n {{ return(true) }}\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.lookup_table_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.9908748, "supported_languages": null}, "macro.dbt_constraints.lookup_table_columns": {"name": "lookup_table_columns", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.lookup_table_columns", "macro_sql": "{%- macro lookup_table_columns(table_relation, lookup_cache) -%}\n {{ return(adapter.dispatch('lookup_table_columns', 'dbt_constraints')(table_relation, lookup_cache)) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.snowflake__lookup_table_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.9909902, "supported_languages": null}, "macro.dbt_constraints.default__lookup_table_columns": {"name": "default__lookup_table_columns", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.default__lookup_table_columns", "macro_sql": "{%- macro default__lookup_table_columns(table_relation, lookup_cache) -%}\n {%- if table_relation not in lookup_cache.table_columns -%}\n {%- set tab_Columns = adapter.get_columns_in_relation(table_relation) -%}\n\n {%- set tab_column_list = [] -%}\n {%- for column in tab_Columns -%}\n {{ tab_column_list.append(column.name|upper) }}\n {%- endfor -%}\n {%- do lookup_cache.table_columns.update({ table_relation: tab_column_list }) -%}\n {%- endif -%}\n {{ return(lookup_cache.table_columns[table_relation]) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.991261, "supported_languages": null}, "macro.dbt_constraints.column_list_matches": {"name": "column_list_matches", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/create_constraints.sql", "original_file_path": "macros/create_constraints.sql", "unique_id": "macro.dbt_constraints.column_list_matches", "macro_sql": "\n{%- macro column_list_matches(listA, listB) -%}\n {# Test if A is empty or the lists are not the same size #}\n {%- if listA | count > 0 and listA | count == listB | count -%}\n {# Fail if there are any columns in A that are not in B #}\n {%- for valueFromA in listA|map('upper') -%}\n {%- if valueFromA|upper not in listB| map('upper') -%}\n {{ return(false) }}\n {%- endif -%}\n {% endfor %}\n {# Since we know the count is the same, A must equal B #}\n {{ return(true) }}\n {%- else -%}\n {{ return(false) }}\n {%- endif -%}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.991543, "supported_languages": null}, "macro.dbt_constraints.snowflake__adapter_supports_rely_norely": {"name": "snowflake__adapter_supports_rely_norely", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "unique_id": "macro.dbt_constraints.snowflake__adapter_supports_rely_norely", "macro_sql": "\n{%- macro snowflake__adapter_supports_rely_norely(test_name) -%}\n {%- if test_name in (\n 'primary_key',\n 'unique_key',\n 'unique_combination_of_columns',\n 'unique',\n 'foreign_key',\n 'relationships') -%}\n {{ return(true) }}\n {%- else -%}\n {{ return(false) }}\n {%- endif -%}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.9956548, "supported_languages": null}, "macro.dbt_constraints.snowflake__create_primary_key": {"name": "snowflake__create_primary_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "unique_id": "macro.dbt_constraints.snowflake__create_primary_key", "macro_sql": "\n{%- macro snowflake__create_primary_key(table_relation, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n{%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_PK\") | upper -%}\n{%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n{#- Check that the table does not already have this PK/UK -#}\n{%- set existing_constraint = dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n{%- if constraint_name == existing_constraint -%}\n {%- do dbt_constraints.set_rely_norely(table_relation, constraint_name, lookup_cache.unique_keys[table_relation][constraint_name].rely, rely_clause) -%}\n {%- do lookup_cache.unique_keys.update({table_relation: {constraint_name:\n { \"constraint_name\": constraint_name,\n \"columns\": column_names,\n \"rely\": \"true\" if rely_clause == \"RELY\" else \"false\" } } }) -%}\n{%- elif none == existing_constraint -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set rely_clause = 'NORELY' if rely_clause == '' else rely_clause -%}\n {%- set query -%}\n ALTER TABLE {{ table_relation }} ADD CONSTRAINT {{ constraint_name }} PRIMARY KEY ( {{ columns_csv }} ) {{ rely_clause }}\n {%- endset -%}\n {%- do log(\"Creating primary key: \" ~ constraint_name ~ \" \" ~ rely_clause, info=true) -%}\n {%- do run_query(query) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.unique_keys.update({table_relation: {constraint_name:\n { \"constraint_name\": constraint_name,\n \"columns\": column_names,\n \"rely\": \"true\" if rely_clause == \"RELY\" else \"false\" } } }) -%}\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.set_rely_norely", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.996651, "supported_languages": null}, "macro.dbt_constraints.snowflake__create_unique_key": {"name": "snowflake__create_unique_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "unique_id": "macro.dbt_constraints.snowflake__create_unique_key", "macro_sql": "\n{%- macro snowflake__create_unique_key(table_relation, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n{%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_UK\") | upper -%}\n{%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n{#- Check that the table does not already have this PK/UK -#}\n{%- set existing_constraint = dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n{%- if constraint_name == existing_constraint -%}\n {%- do dbt_constraints.set_rely_norely(table_relation, constraint_name, lookup_cache.unique_keys[table_relation][constraint_name].rely, rely_clause) -%}\n {%- do lookup_cache.unique_keys.update({table_relation: {constraint_name:\n { \"constraint_name\": constraint_name,\n \"columns\": column_names,\n \"rely\": \"true\" if rely_clause == \"RELY\" else \"false\" } } }) -%}\n{%- elif none == existing_constraint -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set rely_clause = 'NORELY' if rely_clause == '' else rely_clause -%}\n {%- set query -%}\n ALTER TABLE {{ table_relation }} ADD CONSTRAINT {{ constraint_name }} UNIQUE ( {{ columns_csv }} ) {{ rely_clause }}\n {%- endset -%}\n {%- do log(\"Creating unique key: \" ~ constraint_name ~ \" \" ~ rely_clause, info=true) -%}\n {%- do run_query(query) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.unique_keys.update({table_relation: {constraint_name:\n { \"constraint_name\": constraint_name,\n \"columns\": column_names,\n \"rely\": \"true\" if rely_clause == \"RELY\" else \"false\" } } }) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.set_rely_norely", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.997633, "supported_languages": null}, "macro.dbt_constraints.snowflake__create_foreign_key": {"name": "snowflake__create_foreign_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "unique_id": "macro.dbt_constraints.snowflake__create_foreign_key", "macro_sql": "\n{%- macro snowflake__create_foreign_key(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n{%- set constraint_name = (constraint_name or fk_table_relation.identifier ~ \"_\" ~ fk_column_names|join('_') ~ \"_FK\") | upper -%}\n{%- set fk_columns_csv = dbt_constraints.get_quoted_column_csv(fk_column_names, quote_columns) -%}\n{%- set pk_columns_csv = dbt_constraints.get_quoted_column_csv(pk_column_names, quote_columns) -%}\n\n{#- Check that the PK table has a PK or UK -#}\n{%- if none != dbt_constraints.unique_constraint_exists(pk_table_relation, pk_column_names, lookup_cache) -%}\n {#- Check if the table already has this foreign key -#}\n {%- set existing_constraint = dbt_constraints.foreign_key_exists(fk_table_relation, fk_column_names, lookup_cache) -%}\n {%- if constraint_name == existing_constraint -%}\n {%- do dbt_constraints.set_rely_norely(fk_table_relation, constraint_name, lookup_cache.foreign_keys[fk_table_relation][constraint_name].rely, rely_clause) -%}\n {%- do lookup_cache.foreign_keys.update({fk_table_relation: {constraint_name:\n {\"constraint_name\": constraint_name,\n \"columns\": fk_column_names,\n \"rely\": \"true\" if rely_clause == \"RELY\" else \"false\" } } }) -%}\n {%- elif none == existing_constraint -%}\n\n {%- if dbt_constraints.have_ownership_priv(fk_table_relation, verify_permissions, lookup_cache) and dbt_constraints.have_references_priv(pk_table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set rely_clause = 'NORELY' if rely_clause == '' else rely_clause -%}\n {%- set query -%}\n ALTER TABLE {{ fk_table_relation }} ADD CONSTRAINT {{ constraint_name }} FOREIGN KEY ( {{ fk_columns_csv }} ) REFERENCES {{ pk_table_relation }} ( {{ pk_columns_csv }} ) {{ rely_clause }}\n {%- endset -%}\n {%- do log(\"Creating foreign key: \" ~ constraint_name ~ \" referencing \" ~ pk_table_relation.identifier ~ \" \" ~ pk_column_names ~ \" \" ~ rely_clause, info=true) -%}\n {%- do run_query(query) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.foreign_keys.update({fk_table_relation: {constraint_name:\n {\"constraint_name\": constraint_name,\n \"columns\": fk_column_names,\n \"rely\": \"true\" if rely_clause == \"RELY\" else \"false\" } } }) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ fk_table_relation ~ \" referencing \" ~ pk_table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because FK already exists: \" ~ fk_table_relation ~ \" \" ~ fk_column_names, info=false) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because a PK/UK was not found on the PK table: \" ~ pk_table_relation ~ \" \" ~ pk_column_names, info=true) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.foreign_key_exists", "macro.dbt_constraints.set_rely_norely", "macro.dbt_constraints.have_ownership_priv", "macro.dbt_constraints.have_references_priv", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.998901, "supported_languages": null}, "macro.dbt_constraints.snowflake__create_not_null": {"name": "snowflake__create_not_null", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "unique_id": "macro.dbt_constraints.snowflake__create_not_null", "macro_sql": "\n{%- macro snowflake__create_not_null(table_relation, column_names, verify_permissions, quote_columns, lookup_cache, rely_clause) -%}\n{%- if not rely_clause == 'RELY' -%}\n {%- do log(\"Skipping not null constraint for \" ~ column_names | join(\", \") ~ \" in \" ~ table_relation ~ \" because Snowflake does not support NORELY for not null constraints.\", info=true) -%}\n {{ return(false) }}\n{%- endif -%}\n\n{%- set existing_not_null_col = lookup_cache.not_null_col[table_relation] -%}\n\n{%- set columns_to_change = [] -%}\n{%- for column_name in column_names if column_name not in existing_not_null_col -%}\n {%- do columns_to_change.append(column_name) -%}\n {%- do existing_not_null_col.append(column_name) -%}\n{%- endfor -%}\n{%- if columns_to_change|count > 0 -%}\n {%- set columns_list = dbt_constraints.get_quoted_column_list(columns_to_change, quote_columns) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set modify_statements= [] -%}\n {%- for column in columns_list -%}\n {%- set modify_statements = modify_statements.append( \"COLUMN \" ~ column ~ \" SET NOT NULL\" ) -%}\n {%- endfor -%}\n {%- set modify_statement_csv = modify_statements | join(\", \") -%}\n {%- set query -%}\n ALTER TABLE {{ table_relation }} MODIFY {{ modify_statement_csv }};\n {%- endset -%}\n {%- do log(\"Creating not null constraint for: \" ~ columns_to_change | join(\", \") ~ \" in \" ~ table_relation ~ \" \" ~ rely_clause, info=true) -%}\n {%- do run_query(query) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- set constraint_key = table_relation.identifier ~ \"_\" ~ columns_to_change|join('_') ~ \"_NN\" -%}\n {%- do lookup_cache.not_null_col.update({table_relation: existing_not_null_col }) -%}\n\n {%- else -%}\n {%- do log(\"Skipping not null constraint for \" ~ columns_to_change | join(\", \") ~ \" in \" ~ table_relation ~ \" because of insufficient privileges: \" ~ table_relation, info=true) -%}\n {%- endif -%}\n{%- else -%}\n {%- do log(\"Skipping not null constraint for \" ~ column_names | join(\", \") ~ \" in \" ~ table_relation ~ \" because all columns are already not null\", info=false) -%}\n{%- endif -%}\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_list", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092449.999893, "supported_languages": null}, "macro.dbt_constraints.set_rely_norely": {"name": "set_rely_norely", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "unique_id": "macro.dbt_constraints.set_rely_norely", "macro_sql": "\n{%- macro set_rely_norely(table_relation, constraint_name, constraint_rely, rely_clause) -%}\n {%- if ( rely_clause == 'NORELY' and constraint_rely == 'true' )\n or ( rely_clause == 'RELY' and constraint_rely == 'false' ) -%}\n {%- set query -%}\n ALTER TABLE {{ table_relation }} MODIFY CONSTRAINT {{ constraint_name }} {{ rely_clause }}\n {%- endset -%}\n {%- do log(\"Updating constraint: \" ~ constraint_name ~ \" \" ~ rely_clause, info=true) -%}\n {%- do run_query(query) -%}\n {%- endif -%}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.000175, "supported_languages": null}, "macro.dbt_constraints.snowflake__unique_constraint_exists": {"name": "snowflake__unique_constraint_exists", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "unique_id": "macro.dbt_constraints.snowflake__unique_constraint_exists", "macro_sql": "\n{%- macro snowflake__unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n{#- Check if we can find this constraint in the lookup cache -#}\n{%- if table_relation in lookup_cache.unique_keys -%}\n {%- set cached_unique_keys = lookup_cache.unique_keys[table_relation] -%}\n {%- for cached_val in cached_unique_keys.values() -%}\n {%- if dbt_constraints.column_list_matches(cached_val.columns, column_names ) -%}\n {%- do log(\"Found UK key: \" ~ table_relation ~ \" \" ~ cached_val.columns ~ \" \" ~ cached_val.rely, info=false) -%}\n {{ return(cached_val.constraint_name) }}\n {%- endif -%}\n {% endfor %}\n{%- endif -%}\n\n{%- set lookup_query -%}\nSHOW UNIQUE KEYS IN TABLE {{ table_relation }}\n{%- endset -%}\n{%- set constraint_list = run_query(lookup_query) -%}\n{%- if constraint_list.columns[\"column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {%- set existing_constraint_name = (constraint.columns[\"constraint_name\"].values() | first) -%}\n {%- set existing_columns = constraint.columns[\"column_name\"].values() -%}\n {%- set existing_rely = (constraint.columns[\"rely\"].values() | first) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.unique_keys.update({table_relation: {existing_constraint_name:\n { \"constraint_name\": existing_constraint_name,\n \"columns\": existing_columns,\n \"rely\": existing_rely } } }) -%}\n {%- if dbt_constraints.column_list_matches(existing_columns, column_names ) -%}\n {%- do log(\"Found UK key: \" ~ existing_constraint_name ~ \" \" ~ table_relation ~ \" \" ~ column_names ~ \" \" ~ existing_rely, info=false) -%}\n {{ return(existing_constraint_name) }}\n {%- endif -%}\n {% endfor %}\n{%- endif -%}\n\n{%- set lookup_query -%}\nSHOW PRIMARY KEYS IN TABLE {{ table_relation }}\n{%- endset -%}\n{%- set constraint_list = run_query(lookup_query) -%}\n{%- if constraint_list.columns[\"column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {%- set existing_constraint_name = (constraint.columns[\"constraint_name\"].values() | first) -%}\n {%- set existing_columns = constraint.columns[\"column_name\"].values() -%}\n {%- set existing_rely = (constraint.columns[\"rely\"].values() | first) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.unique_keys.update({table_relation: {existing_constraint_name:\n { \"constraint_name\": existing_constraint_name,\n \"columns\": existing_columns,\n \"rely\": existing_rely } } }) -%}\n {%- if dbt_constraints.column_list_matches(existing_columns, column_names ) -%}\n {%- do log(\"Found PK key: \" ~ existing_constraint_name ~ \" \" ~ table_relation ~ \" \" ~ column_names ~ \" \" ~ existing_rely, info=false) -%}\n {{ return(existing_constraint_name) }}\n {%- endif -%}\n {% endfor %}\n{%- endif -%}\n\n{#- If we get this far then the table does not have either constraint -#}\n{%- do log(\"No PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n{{ return(none) }}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.column_list_matches", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.001631, "supported_languages": null}, "macro.dbt_constraints.snowflake__foreign_key_exists": {"name": "snowflake__foreign_key_exists", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "unique_id": "macro.dbt_constraints.snowflake__foreign_key_exists", "macro_sql": "\n{%- macro snowflake__foreign_key_exists(table_relation, column_names, lookup_cache) -%}\n\n{#- Check if we can find this constraint in the lookup cache -#}\n{%- if table_relation in lookup_cache.foreign_keys -%}\n {%- set cached_foreign_keys = lookup_cache.foreign_keys[table_relation] -%}\n {%- for cached_val in cached_foreign_keys.values() -%}\n {%- if dbt_constraints.column_list_matches(cached_val.columns, column_names ) -%}\n {%- do log(\"Found FK key: \" ~ table_relation ~ \" \" ~ cached_val.constraint_name ~ \" \" ~ column_names ~ \" \" ~ cached_val.rely, info=false) -%}\n {{ return(cached_val.constraint_name) }}\n {%- endif -%}\n {% endfor %}\n{%- endif -%}\n\n{%- set lookup_query -%}\nSHOW IMPORTED KEYS IN TABLE {{ table_relation }}\n{%- endset -%}\n{%- set constraint_list = run_query(lookup_query) -%}\n{%- if constraint_list.columns[\"fk_column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"fk_name\") -%}\n {%- set existing_constraint_name = (constraint.columns[\"fk_name\"].values() | first) -%}\n {%- set existing_columns = constraint.columns[\"fk_column_name\"].values() -%}\n {%- set existing_rely = (constraint.columns[\"rely\"].values() | first) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.foreign_keys.update({table_relation: {existing_constraint_name:\n { \"constraint_name\": existing_constraint_name,\n \"columns\": existing_columns,\n \"rely\": existing_rely } } }) -%}\n {%- if dbt_constraints.column_list_matches(existing_columns, column_names ) -%}\n {%- do log(\"Found FK key: \" ~ table_relation ~ \" \" ~ existing_constraint_name ~ \" \" ~ column_names ~ \" \" ~ existing_rely, info=false) -%}\n {{ return(existing_constraint_name) }}\n {%- endif -%}\n {% endfor %}\n{%- endif -%}\n\n{#- If we get this far then the table does not have this constraint -#}\n{%- do log(\"No FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n{{ return(none) }}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.column_list_matches", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.002631, "supported_languages": null}, "macro.dbt_constraints.snowflake__have_references_priv": {"name": "snowflake__have_references_priv", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "unique_id": "macro.dbt_constraints.snowflake__have_references_priv", "macro_sql": "{%- macro snowflake__have_references_priv(table_relation, verify_permissions, lookup_cache) -%}\n{%- if verify_permissions is sameas true -%}\n\n{%- set table_privileges = snowflake__lookup_table_privileges(table_relation, lookup_cache) -%}\n{%- if \"REFERENCES\" in table_privileges or \"OWNERSHIP\" in table_privileges -%}\n {{ return(true) }}\n {%- else -%}\n {{ return(false) }}\n {%- endif -%}\n\n {%- else -%}\n{{ return(true) }}\n{%- endif -%}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.snowflake__lookup_table_privileges"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0028758, "supported_languages": null}, "macro.dbt_constraints.snowflake__have_ownership_priv": {"name": "snowflake__have_ownership_priv", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "unique_id": "macro.dbt_constraints.snowflake__have_ownership_priv", "macro_sql": "{%- macro snowflake__have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n{%- if verify_permissions is sameas true -%}\n\n{%- set table_privileges = snowflake__lookup_table_privileges(table_relation, lookup_cache) -%}\n{%- if \"OWNERSHIP\" in table_privileges -%}\n {{ return(true) }}\n {%- else -%}\n {{ return(false) }}\n {%- endif -%}\n\n {%- else -%}\n{{ return(true) }}\n{%- endif -%}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.snowflake__lookup_table_privileges"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0031, "supported_languages": null}, "macro.dbt_constraints.snowflake__lookup_table_privileges": {"name": "snowflake__lookup_table_privileges", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "unique_id": "macro.dbt_constraints.snowflake__lookup_table_privileges", "macro_sql": "{%- macro snowflake__lookup_table_privileges(table_relation, lookup_cache) -%}\n\n{%- if table_relation.database not in lookup_cache.table_privileges -%}\n {%- do log(\"Caching privileges for database: \" ~ table_relation.database, info=false) -%}\n\n {%- set lookup_query -%}\n select distinct\n upper(tp.table_schema) as \"table_schema\",\n upper(tp.table_name) as \"table_name\",\n tp.privilege_type as \"privilege_type\"\n from {{ table_relation.database }}.information_schema.table_privileges tp\n where (is_role_in_session(tp.grantee) or is_database_role_in_session(tp.grantee))\n and tp.privilege_type in ('OWNERSHIP', 'REFERENCES')\n {%- endset -%}\n {%- set privilege_list = run_query(lookup_query) -%}\n {%- do lookup_cache.table_privileges.update({ table_relation.database: privilege_list }) -%}\n {%- endif -%}\n\n{%- set tab_priv_list = [] -%}\n{%- set schema_name = table_relation.schema|upper -%}\n{%- set table_name = table_relation.identifier|upper -%}\n{%- for row in lookup_cache.table_privileges[table_relation.database].rows -%}\n {%- if row[\"table_schema\"] == schema_name and row[\"table_name\"] == table_name -%}\n {%- do tab_priv_list.append(row[\"privilege_type\"]) -%}\n {%- endif -%}\n {%- endfor -%}\n{{ return(tab_priv_list) }}\n\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0035882, "supported_languages": null}, "macro.dbt_constraints.snowflake__lookup_table_columns": {"name": "snowflake__lookup_table_columns", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/snowflake__create_constraints.sql", "original_file_path": "macros/snowflake__create_constraints.sql", "unique_id": "macro.dbt_constraints.snowflake__lookup_table_columns", "macro_sql": "{%- macro snowflake__lookup_table_columns(table_relation, lookup_cache) -%}\n\n{%- if table_relation not in lookup_cache.table_columns -%}\n {%- set lookup_query -%}\n SHOW COLUMNS IN TABLE {{ table_relation }}\n {%- endset -%}\n {%- set results = run_query(lookup_query) -%}\n\n {%- set not_null_col = [] -%}\n {%- set upper_column_list = [] -%}\n {%- for row in results.rows -%}\n {%- do upper_column_list.append(row[\"column_name\"]|upper) -%}\n {%- if row['null?'] == 'false' -%}\n {%- do not_null_col.append(row[\"column_name\"]|upper) -%}\n {%- endif -%}\n {%- endfor -%}\n {%- do lookup_cache.table_columns.update({ table_relation: upper_column_list }) -%}\n {%- do lookup_cache.not_null_col.update({ table_relation: not_null_col }) -%}\n {%- endif -%}\n{{ return(lookup_cache.table_columns[table_relation]) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.004042, "supported_languages": null}, "macro.dbt_constraints.redshift__create_primary_key": {"name": "redshift__create_primary_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "unique_id": "macro.dbt_constraints.redshift__create_primary_key", "macro_sql": "\n{%- macro redshift__create_primary_key(table_relation, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_PK\") | upper -%}\n\n {%- if constraint_name|length > 127 %}\n {%- set constraint_name_query %}\n select 'PK_' || md5( '{{ constraint_name }}' )::varchar as \"constraint_name\"\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- do log(\"Creating primary key: \" ~ constraint_name, info=true) -%}\n {%- set query -%}\n ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} PRIMARY KEY ( {{columns_csv}} )\n {%- endset -%}\n {%- do run_query(query) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=false) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0070632, "supported_languages": null}, "macro.dbt_constraints.redshift__create_unique_key": {"name": "redshift__create_unique_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "unique_id": "macro.dbt_constraints.redshift__create_unique_key", "macro_sql": "\n{%- macro redshift__create_unique_key(table_relation, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_UK\") | upper -%}\n\n {%- if constraint_name|length > 127 %}\n {%- set constraint_name_query %}\n select 'UK_' || md5( '{{ constraint_name }}' )::varchar as \"constraint_name\"\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- do log(\"Creating unique key: \" ~ constraint_name, info=true) -%}\n {%- set query -%}\n ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} UNIQUE ( {{columns_csv}} )\n {%- endset -%}\n {%- do run_query(query) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=false) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.007741, "supported_languages": null}, "macro.dbt_constraints.redshift__create_not_null": {"name": "redshift__create_not_null", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "unique_id": "macro.dbt_constraints.redshift__create_not_null", "macro_sql": "\n{%- macro redshift__create_not_null(table_relation, column_names, verify_permissions, quote_columns, lookup_cache, rely_clause) -%}\n {%- set columns_list = dbt_constraints.get_quoted_column_list(column_names, quote_columns) -%}\n\n {%- do log(\"Skipping not null constraint for \" ~ columns_list | join(\", \") ~ \" in \" ~ table_relation ~ \" because ALTER COLUMN SET NOT NULL is not supported\", info=true) -%}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_list"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0079339, "supported_languages": null}, "macro.dbt_constraints.redshift__create_foreign_key": {"name": "redshift__create_foreign_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "unique_id": "macro.dbt_constraints.redshift__create_foreign_key", "macro_sql": "\n{%- macro redshift__create_foreign_key(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {%- set constraint_name = (constraint_name or fk_table_relation.identifier ~ \"_\" ~ fk_column_names|join('_') ~ \"_FK\") | upper -%}\n\n {%- if constraint_name|length > 127 %}\n {%- set constraint_name_query %}\n select 'FK_' || md5( '{{ constraint_name }}' )::varchar as \"constraint_name\"\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set fk_columns_csv = dbt_constraints.get_quoted_column_csv(fk_column_names, quote_columns) -%}\n {%- set pk_columns_csv = dbt_constraints.get_quoted_column_csv(pk_column_names, quote_columns) -%}\n {#- Check that the PK table has a PK or UK -#}\n {%- if dbt_constraints.unique_constraint_exists(pk_table_relation, pk_column_names, lookup_cache) -%}\n {#- Check if the table already has this foreign key -#}\n {%- if not dbt_constraints.foreign_key_exists(fk_table_relation, fk_column_names) -%}\n\n {%- if dbt_constraints.have_ownership_priv(fk_table_relation, verify_permissions, lookup_cache) and dbt_constraints.have_references_priv(pk_table_relation, verify_permissions, lookup_cache) -%}\n\n {%- do log(\"Creating foreign key: \" ~ constraint_name ~ \" referencing \" ~ pk_table_relation.identifier ~ \" \" ~ pk_column_names, info=true) -%}\n {%- set query -%}\n --Note: ON DELETE not supported in Redshift\n ALTER TABLE {{fk_table_relation}} ADD CONSTRAINT {{constraint_name}} FOREIGN KEY ( {{fk_columns_csv}} ) REFERENCES {{pk_table_relation}} ( {{pk_columns_csv}} ) --ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED\n {%- endset -%}\n {%- do run_query(query) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ fk_table_relation ~ \" referencing \" ~ pk_table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because FK already exists: \" ~ fk_table_relation ~ \" \" ~ fk_column_names, info=false) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because a PK/UK was not found on the PK table: \" ~ pk_table_relation ~ \" \" ~ pk_column_names, info=true) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.foreign_key_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt_constraints.have_references_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.008848, "supported_languages": null}, "macro.dbt_constraints.redshift__unique_constraint_exists": {"name": "redshift__unique_constraint_exists", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "unique_id": "macro.dbt_constraints.redshift__unique_constraint_exists", "macro_sql": "\n{%- macro redshift__unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n {%- set lookup_query -%}\n SELECT\n kc.constraint_name\n , lower(kc.column_name) as column_name\n FROM information_schema.key_column_usage kc\n JOIN information_schema.table_constraints tc\n ON kc.table_name = tc.table_name\n AND kc.table_schema = tc.table_schema\n AND kc.constraint_name = tc.constraint_name\n WHERE tc.constraint_type in ('PRIMARY KEY', 'UNIQUE')\n AND kc.table_schema ilike '{{table_relation.schema}}'\n AND kc.table_name ilike '{{table_relation.identifier}}'\n order by kc.constraint_name\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"column_name\"].values(), column_names ) -%}\n {%- do log(\"Found PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}#}\n\n {#- If we get this far then the table does not have either constraint -#}\n {%- do log(\"No PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.column_list_matches"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.009367, "supported_languages": null}, "macro.dbt_constraints.redshift__foreign_key_exists": {"name": "redshift__foreign_key_exists", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "unique_id": "macro.dbt_constraints.redshift__foreign_key_exists", "macro_sql": "\n{%- macro redshift__foreign_key_exists(table_relation, column_names, lookup_cache) -%}\n {%- set lookup_query -%}\n SELECT\n kc.constraint_name fk_name\n , lower(kc.column_name) as fk_column_name\n FROM information_schema.key_column_usage kc\n JOIN information_schema.table_constraints tc\n ON kc.table_name = tc.table_name\n AND kc.table_schema = tc.table_schema\n AND kc.constraint_name = tc.constraint_name\n WHERE tc.constraint_type='FOREIGN KEY'\n AND kc.table_schema ilike '{{table_relation.schema}}'\n AND kc.table_name ilike '{{table_relation.identifier}}'\n order by kc.constraint_name\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"fk_column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"fk_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"fk_column_name\"].values(), column_names ) -%}\n {%- do log(\"Found FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {#- If we get this far then the table does not have this constraint -#}\n {%- do log(\"No FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.column_list_matches"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0098639, "supported_languages": null}, "macro.dbt_constraints.redshift__have_references_priv": {"name": "redshift__have_references_priv", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "unique_id": "macro.dbt_constraints.redshift__have_references_priv", "macro_sql": "{%- macro redshift__have_references_priv(table_relation, verify_permissions, lookup_cache) -%}\n {%- if verify_permissions is sameas true -%}\n\n {%- set lookup_query -%}\n select case when count(*) > 0 then 'y' else 'n' end as \"have_references\"\n from information_schema.table_privileges t\n join information_schema.enabled_roles er on t.grantee = er.role_name\n where upper(t.table_schema) = upper('{{table_relation.schema}}')\n and upper(t.table_name) = upper('{{table_relation.identifier}}')\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set results = run_query(lookup_query) -%}\n {%- if \"y\" in( results.columns[\"have_references\"].values() ) -%}\n {{ return(true) }}\n {%- endif -%}\n\n {{ return(false) }}\n {%- else -%}\n {{ return(true) }}\n {%- endif -%}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.010206, "supported_languages": null}, "macro.dbt_constraints.redshift__have_ownership_priv": {"name": "redshift__have_ownership_priv", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "unique_id": "macro.dbt_constraints.redshift__have_ownership_priv", "macro_sql": "{%- macro redshift__have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n {%- if verify_permissions is sameas true -%}\n\n {%- set lookup_query -%}\n select case when count(*) > 0 then 'y' else 'n' end as \"have_ownership\"\n from pg_catalog.pg_tables t\n join information_schema.enabled_roles er on t.tableowner = er.role_name\n where upper(t.schemaname) = upper('{{table_relation.schema}}')\n and upper(t.tablename) = upper('{{table_relation.identifier}}')\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set results = run_query(lookup_query) -%}\n {%- if \"y\" in( results.columns[\"have_ownership\"].values() ) -%}\n {{ return(true) }}\n {%- endif -%}\n\n {{ return(false) }}\n {%- else -%}\n {{ return(true) }}\n {%- endif -%}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.010538, "supported_languages": null}, "macro.dbt_constraints.redshift__drop_referential_constraints": {"name": "redshift__drop_referential_constraints", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "unique_id": "macro.dbt_constraints.redshift__drop_referential_constraints", "macro_sql": "{% macro redshift__drop_referential_constraints(relation) -%}\n {%- set lookup_query -%}\n select constraint_name\n from information_schema.table_constraints\n where table_schema = '{{relation.schema}}'\n and table_name='{{relation.identifier}}'\n and constraint_type in ('FOREIGN KEY', 'PRIMARY KEY', 'UNIQUE')\n {%- endset -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n\n {%- for constraint_name in constraint_list.columns[\"constraint_name\"].values() -%}\n {%- do log(\"Dropping constraint: \" ~ constraint_name ~ \" from table \" ~ relation, info=false) -%}\n {%- set query -%}\n ALTER TABLE {{relation}} DROP CONSTRAINT \"{{constraint_name}}\" CASCADE\n {%- endset -%}\n {%- do run_query(query) -%}\n {% endfor %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.010844, "supported_languages": null}, "macro.dbt_constraints.redshift__truncate_relation": {"name": "redshift__truncate_relation", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "unique_id": "macro.dbt_constraints.redshift__truncate_relation", "macro_sql": "{% macro redshift__truncate_relation(relation) -%}\n {{ redshift__drop_referential_constraints(relation) }}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_constraints.redshift__drop_referential_constraints", "macro.dbt_constraints.truncate_relation", "macro.dbt_snowflake.snowflake__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0109708, "supported_languages": null}, "macro.dbt_constraints.redshift__drop_relation": {"name": "redshift__drop_relation", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/redshift__create_constraints.sql", "original_file_path": "macros/redshift__create_constraints.sql", "unique_id": "macro.dbt_constraints.redshift__drop_relation", "macro_sql": "{% macro redshift__drop_relation(relation) -%}\n {{ redshift__drop_referential_constraints(relation) }}\n {{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_constraints.redshift__drop_referential_constraints", "macro.dbt_constraints.drop_relation", "macro.dbt.default__drop_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.011091, "supported_languages": null}, "macro.dbt_constraints.vertica__create_primary_key": {"name": "vertica__create_primary_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/vertica__create_constraints.sql", "original_file_path": "macros/vertica__create_constraints.sql", "unique_id": "macro.dbt_constraints.vertica__create_primary_key", "macro_sql": "\n{%- macro vertica__create_primary_key(table_relation, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_PK\") | upper -%}\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set query -%}\n ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} PRIMARY KEY ( {{columns_csv}} )\n {%- endset -%}\n {%- do log(\"Creating primary key: \" ~ constraint_name, info=true) -%}\n {%- do run_query(query) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.unique_keys.update({table_relation: {constraint_name: column_names} }) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.015341, "supported_languages": null}, "macro.dbt_constraints.vertica__create_unique_key": {"name": "vertica__create_unique_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/vertica__create_constraints.sql", "original_file_path": "macros/vertica__create_constraints.sql", "unique_id": "macro.dbt_constraints.vertica__create_unique_key", "macro_sql": "\n{%- macro vertica__create_unique_key(table_relation, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_UK\") | upper -%}\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set query -%}\n ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} UNIQUE ( {{columns_csv}} )\n {%- endset -%}\n {%- do log(\"Creating unique key: \" ~ constraint_name, info=true) -%}\n {%- do run_query(query) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.unique_keys.update({table_relation: {constraint_name: column_names} }) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.01595, "supported_languages": null}, "macro.dbt_constraints.vertica__create_foreign_key": {"name": "vertica__create_foreign_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/vertica__create_constraints.sql", "original_file_path": "macros/vertica__create_constraints.sql", "unique_id": "macro.dbt_constraints.vertica__create_foreign_key", "macro_sql": "\n{%- macro vertica__create_foreign_key(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {%- set constraint_name = (constraint_name or fk_table_relation.identifier ~ \"_\" ~ fk_column_names|join('_') ~ \"_FK\") | upper -%}\n {%- set fk_columns_csv = dbt_constraints.get_quoted_column_csv(fk_column_names, quote_columns) -%}\n {%- set pk_columns_csv = dbt_constraints.get_quoted_column_csv(pk_column_names, quote_columns) -%}\n {#- Check that the PK table has a PK or UK -#}\n {%- if dbt_constraints.unique_constraint_exists(pk_table_relation, pk_column_names, lookup_cache) -%}\n {#- Check if the table already has this foreign key -#}\n {%- if not dbt_constraints.foreign_key_exists(fk_table_relation, fk_column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(fk_table_relation, verify_permissions, lookup_cache) and dbt_constraints.have_references_priv(pk_table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set query -%}\n ALTER TABLE {{fk_table_relation}} ADD CONSTRAINT {{constraint_name}} FOREIGN KEY ( {{fk_columns_csv}} ) REFERENCES {{pk_table_relation}} ( {{pk_columns_csv}} )\n {%- endset -%}\n {%- do log(\"Creating foreign key: \" ~ constraint_name ~ \" referencing \" ~ pk_table_relation.identifier ~ \" \" ~ pk_column_names, info=true) -%}\n {%- do run_query(query) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.foreign_keys.update({fk_table_relation: {constraint_name: fk_column_names} }) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ fk_table_relation ~ \" referencing \" ~ pk_table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because FK already exists: \" ~ fk_table_relation ~ \" \" ~ fk_column_names, info=false) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because a PK/UK was not found on the PK table: \" ~ pk_table_relation ~ \" \" ~ pk_column_names, info=true) -%}\n {%- endif -%}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.foreign_key_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt_constraints.have_references_priv", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0167758, "supported_languages": null}, "macro.dbt_constraints.vertica__create_not_null": {"name": "vertica__create_not_null", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/vertica__create_constraints.sql", "original_file_path": "macros/vertica__create_constraints.sql", "unique_id": "macro.dbt_constraints.vertica__create_not_null", "macro_sql": "\n{%- macro vertica__create_not_null(table_relation, column_names, verify_permissions, quote_columns, lookup_cache, rely_clause) -%}\n\n {%- set existing_not_null_col = lookup_cache.not_null_col[table_relation] -%}\n\n {%- set columns_to_change = [] -%}\n {%- for column_name in column_names if column_name|upper not in existing_not_null_col -%}\n {%- do columns_to_change.append(column_name) -%}\n {%- do existing_not_null_col.append(column_name) -%}\n {%- endfor -%}\n {%- if columns_to_change|count > 0 -%}\n {%- set columns_list = dbt_constraints.get_quoted_column_list(columns_to_change, quote_columns) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n {%- set modify_statements= [] -%}\n {%- for column in columns_list -%}\n {%- set modify_statements = modify_statements.append( \"COLUMN \" ~ column ~ \" SET NOT NULL\" ) -%}\n {%- endfor -%}\n {%- set modify_statement_csv = modify_statements | join(\", \") -%}\n {%- set query -%}\n ALTER TABLE {{table_relation}} ALTER {{ modify_statement_csv }};\n {%- endset -%}\n {%- do log(\"Creating not null constraint for: \" ~ columns_to_change | join(\", \") ~ \" in \" ~ table_relation, info=true) -%}\n {%- do run_query(query) -%}\n {#- Add this constraint to the lookup cache -#}\n {%- set constraint_key = table_relation.identifier ~ \"_\" ~ columns_to_change|join('_') ~ \"_NN\" -%}\n {%- do lookup_cache.not_null_col.update({table_relation: existing_not_null_col }) -%}\n {%- else -%}\n {%- do log(\"Skipping not null constraint for \" ~ columns_to_change | join(\", \") ~ \" in \" ~ table_relation ~ \" because of insufficient privileges: \" ~ table_relation, info=true) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping not null constraint for \" ~ column_names | join(\", \") ~ \" in \" ~ table_relation ~ \" because all columns are already not null\", info=false) -%}\n {%- endif -%}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_list", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.017707, "supported_languages": null}, "macro.dbt_constraints.vertica__unique_constraint_exists": {"name": "vertica__unique_constraint_exists", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/vertica__create_constraints.sql", "original_file_path": "macros/vertica__create_constraints.sql", "unique_id": "macro.dbt_constraints.vertica__unique_constraint_exists", "macro_sql": "\n{%- macro vertica__unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {#- Check if we can find this constraint in the lookup cache -#}\n {%- if table_relation in lookup_cache.unique_keys -%}\n {%- set cached_unique_keys = lookup_cache.unique_keys[table_relation] -%}\n {%- for cached_columns in cached_unique_keys.values() -%}\n {%- if dbt_constraints.column_list_matches(cached_columns, column_names ) -%}\n {%- do log(\"Found UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {%- set lookup_query -%}\n select constraint_name, column_name\n from constraint_columns\n where\n table_schema ilike '{{table_relation.schema}}'\n and table_name ilike '{{table_relation.identifier}}'\n and constraint_type in ('u')\n order by constraint_name\n {%- endset -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.unique_keys.update({table_relation: {constraint.key_name: constraint.columns[\"column_name\"].values()} }) -%}\n {% endfor %}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"column_name\"].values(), column_names ) -%}\n {%- do log(\"Found UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {%- set lookup_query -%}\n select constraint_name, column_name\n from constraint_columns\n where\n table_schema ilike '{{table_relation.schema}}'\n and table_name ilike '{{table_relation.identifier}}'\n and constraint_type in ('p')\n order by constraint_name\n {%- endset -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.unique_keys.update({table_relation: {constraint.key_name: constraint.columns[\"column_name\"].values()} }) -%}\n {% endfor %}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"column_name\"].values(), column_names ) -%}\n {%- do log(\"Found PK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {#- If we get this far then the table does not have either constraint -#}\n {%- do log(\"No PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.column_list_matches", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.018924, "supported_languages": null}, "macro.dbt_constraints.vertica__foreign_key_exists": {"name": "vertica__foreign_key_exists", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/vertica__create_constraints.sql", "original_file_path": "macros/vertica__create_constraints.sql", "unique_id": "macro.dbt_constraints.vertica__foreign_key_exists", "macro_sql": "\n{%- macro vertica__foreign_key_exists(table_relation, column_names, lookup_cache) -%}\n\n {#- Check if we can find this constraint in the lookup cache -#}\n {%- if table_relation in lookup_cache.foreign_keys -%}\n {%- set cached_foreign_keys = lookup_cache.foreign_keys[table_relation] -%}\n {%- for cached_columns in cached_foreign_keys.values() -%}\n {%- if dbt_constraints.column_list_matches(cached_columns, column_names ) -%}\n {%- do log(\"Found FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {%- set lookup_query -%}\n select constraint_name as fk_name, column_name as fk_column_name\n from constraint_columns\n where\n table_schema ilike '{{table_relation.schema}}'\n and table_name ilike '{{table_relation.identifier}}'\n and constraint_type in ('f')\n order by constraint_name\n {%- endset -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"fk_column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"fk_name\") -%}\n {#- Add this constraint to the lookup cache -#}\n {%- do lookup_cache.foreign_keys.update({table_relation: {constraint.key_name: constraint.columns[\"fk_column_name\"].values()} }) -%}\n {% endfor %}\n {%- for constraint in constraint_list.group_by(\"fk_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"fk_column_name\"].values(), column_names ) -%}\n {%- do log(\"Found FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {#- If we get this far then the table does not have this constraint -#}\n {%- do log(\"No FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.column_list_matches", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.019726, "supported_languages": null}, "macro.dbt_constraints.vertica__have_references_priv": {"name": "vertica__have_references_priv", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/vertica__create_constraints.sql", "original_file_path": "macros/vertica__create_constraints.sql", "unique_id": "macro.dbt_constraints.vertica__have_references_priv", "macro_sql": "{%- macro vertica__have_references_priv(table_relation, verify_permissions, lookup_cache) -%}\n {%- if verify_permissions is sameas true -%}\n\n {%- set table_privileges = vertica__lookup_table_privileges(table_relation, lookup_cache) -%}\n {%- if \"REFERENCES\" in table_privileges or \"OWNERSHIP\" in table_privileges -%}\n {{ return(true) }}\n {%- else -%}\n {{ return(false) }}\n {%- endif -%}\n\n {%- else -%}\n {{ return(true) }}\n {%- endif -%}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.vertica__lookup_table_privileges"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0199811, "supported_languages": null}, "macro.dbt_constraints.vertica__have_ownership_priv": {"name": "vertica__have_ownership_priv", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/vertica__create_constraints.sql", "original_file_path": "macros/vertica__create_constraints.sql", "unique_id": "macro.dbt_constraints.vertica__have_ownership_priv", "macro_sql": "{%- macro vertica__have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n {%- if verify_permissions is sameas true -%}\n\n {%- set table_privileges = vertica__lookup_table_privileges(table_relation, lookup_cache) -%}\n {%- if \"OWNERSHIP\" in table_privileges -%}\n {{ return(true) }}\n {%- else -%}\n {{ return(false) }}\n {%- endif -%}\n\n {%- else -%}\n {{ return(true) }}\n {%- endif -%}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt_constraints.vertica__lookup_table_privileges"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.020212, "supported_languages": null}, "macro.dbt_constraints.vertica__lookup_table_privileges": {"name": "vertica__lookup_table_privileges", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/vertica__create_constraints.sql", "original_file_path": "macros/vertica__create_constraints.sql", "unique_id": "macro.dbt_constraints.vertica__lookup_table_privileges", "macro_sql": "{%- macro vertica__lookup_table_privileges(table_relation, lookup_cache) -%}\n\n {%- if table_relation.database not in lookup_cache.table_privileges -%}\n {%- set lookup_query -%}\n select distinct\n upper(tp.table_schema) as \"table_schema\",\n upper(tp.table_name) as \"table_name\",\n tp.privilege_type as \"privilege_type\"\n from {{table_relation.database}}.information_schema.table_privileges tp\n where is_role_in_session(tp.grantee)\n and tp.privilege_type in ('OWNERSHIP', 'REFERENCES')\n {%- endset -%}\n {%- do log(\"Caching privileges for database: \" ~ table_relation.database, info=false) -%}\n {%- set privilege_list = run_query(lookup_query) -%}\n {%- do lookup_cache.table_privileges.update({ table_relation.database: privilege_list }) -%}\n {%- endif -%}\n\n {%- set tab_priv_list = [] -%}\n {%- set schema_name = table_relation.schema|upper -%}\n {%- set table_name = table_relation.identifier|upper -%}\n {%- for row in lookup_cache.table_privileges[table_relation.database].rows -%}\n {%- if row[\"table_schema\"] == schema_name and row[\"table_name\"] == table_name -%}\n {%- do tab_priv_list.append(row[\"privilege_type\"]) -%}\n {%- endif -%}\n {%- endfor -%}\n {{ return(tab_priv_list) }}\n\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.020721, "supported_languages": null}, "macro.dbt_constraints.vertica__lookup_table_columns": {"name": "vertica__lookup_table_columns", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/vertica__create_constraints.sql", "original_file_path": "macros/vertica__create_constraints.sql", "unique_id": "macro.dbt_constraints.vertica__lookup_table_columns", "macro_sql": "{%- macro vertica__lookup_table_columns(table_relation, lookup_cache) -%}\n\n {%- if table_relation not in lookup_cache.table_columns -%}\n {%- set lookup_query -%}\n select column_name, is_nullable\n from columns\n where table_schema ilike '{{table_relation.schema}}'\n and table_name ilike '{{table_relation.identifier}}'\n {%- endset -%}\n {%- set results = run_query(lookup_query) -%}\n {%- set not_null_col = [] -%}\n {%- set upper_column_list = [] -%}\n {%- for row in results.rows -%}\n {%- do upper_column_list.append(row[\"column_name\"]|upper) -%}\n {%- if row['is_nullable'] == False -%}\n {%- do not_null_col.append(row[\"column_name\"]|upper) -%}\n {%- endif -%}\n {%- endfor -%}\n {%- do lookup_cache.table_columns.update({ table_relation: upper_column_list }) -%}\n\n {%- do lookup_cache.not_null_col.update({ table_relation: not_null_col }) -%}\n {%- endif -%}\n {{ return(lookup_cache.table_columns[table_relation]) }}\n\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.021205, "supported_languages": null}, "macro.dbt_constraints.vertica__get_create_index_sql": {"name": "vertica__get_create_index_sql", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/vertica__create_constraints.sql", "original_file_path": "macros/vertica__create_constraints.sql", "unique_id": "macro.dbt_constraints.vertica__get_create_index_sql", "macro_sql": "{%- macro vertica__get_create_index_sql(table_relation, lookup_cache) -%}\n\n {%- do log(\"Skipping creation of indexes, they are not supported by Vertica\", info=true) -%}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.021301, "supported_languages": null}, "macro.dbt_constraints.oracle__create_primary_key": {"name": "oracle__create_primary_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "unique_id": "macro.dbt_constraints.oracle__create_primary_key", "macro_sql": "\n{%- macro oracle__create_primary_key(table_relation, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_PK\") | upper -%}\n\n {%- if constraint_name|length > 30 %}\n {%- set constraint_name_query %}\n select 'PK_' || ora_hash( '{{ constraint_name }}' ) as \"constraint_name\" from dual\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set query -%}\nBEGIN\n EXECUTE IMMEDIATE 'ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} PRIMARY KEY ( {{columns_csv}} )';\nEXCEPTION\n WHEN OTHERS THEN\n DBMS_OUTPUT.ENABLE(BUFFER_SIZE => NULL);\n DBMS_OUTPUT.PUT_LINE('Unable to create constraint: ' || SQLERRM);\nEND;\n {%- endset -%}\n {%- do log(\"Creating primary key: \" ~ constraint_name, info=true) -%}\n {%- do run_query(query) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=false) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.024201, "supported_languages": null}, "macro.dbt_constraints.oracle__create_unique_key": {"name": "oracle__create_unique_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "unique_id": "macro.dbt_constraints.oracle__create_unique_key", "macro_sql": "\n{%- macro oracle__create_unique_key(table_relation, column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {%- set constraint_name = (constraint_name or table_relation.identifier ~ \"_\" ~ column_names|join('_') ~ \"_UK\") | upper -%}\n\n {%- if constraint_name|length > 30 %}\n {%- set constraint_name_query %}\n select 'UK_' || ora_hash( '{{ constraint_name }}' ) as \"constraint_name\" from dual\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set columns_csv = dbt_constraints.get_quoted_column_csv(column_names, quote_columns) -%}\n\n {#- Check that the table does not already have this PK/UK -#}\n {%- if not dbt_constraints.unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n\n {%- set query -%}\nBEGIN\n EXECUTE IMMEDIATE 'ALTER TABLE {{table_relation}} ADD CONSTRAINT {{constraint_name}} UNIQUE ( {{columns_csv}} )';\nEXCEPTION\n WHEN OTHERS THEN\n DBMS_OUTPUT.ENABLE(BUFFER_SIZE => NULL);\n DBMS_OUTPUT.PUT_LINE('Unable to create constraint: ' || SQLERRM);\nEND;\n {%- endset -%}\n {%- do log(\"Creating unique key: \" ~ constraint_name, info=true) -%}\n {%- do run_query(query) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ table_relation, info=false) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because PK/UK already exists: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.have_ownership_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.024931, "supported_languages": null}, "macro.dbt_constraints.oracle__create_foreign_key": {"name": "oracle__create_foreign_key", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "unique_id": "macro.dbt_constraints.oracle__create_foreign_key", "macro_sql": "\n{%- macro oracle__create_foreign_key(pk_table_relation, pk_column_names, fk_table_relation, fk_column_names, verify_permissions, quote_columns, constraint_name, lookup_cache, rely_clause) -%}\n {%- set constraint_name = (constraint_name or fk_table_relation.identifier ~ \"_\" ~ fk_column_names|join('_') ~ \"_FK\") | upper -%}\n\n {%- if constraint_name|length > 30 %}\n {%- set constraint_name_query %}\n select 'FK_' || ora_hash( '{{ constraint_name }}' ) as \"constraint_name\" from dual\n {%- endset -%}\n {%- set results = run_query(constraint_name_query) -%}\n {%- set constraint_name = results.columns[0].values()[0] -%}\n {% endif %}\n\n {%- set fk_columns_csv = dbt_constraints.get_quoted_column_csv(fk_column_names, quote_columns) -%}\n {%- set pk_columns_csv = dbt_constraints.get_quoted_column_csv(pk_column_names, quote_columns) -%}\n {#- Check that the PK table has a PK or UK -#}\n {%- if dbt_constraints.unique_constraint_exists(pk_table_relation, pk_column_names, lookup_cache) -%}\n {#- Check if the table already has this foreign key -#}\n {%- if not dbt_constraints.foreign_key_exists(fk_table_relation, fk_column_names) -%}\n\n {%- if dbt_constraints.have_ownership_priv(fk_table_relation, verify_permissions, lookup_cache) and dbt_constraints.have_references_priv(pk_table_relation, verify_permissions) -%}\n\n {%- set query -%}\nBEGIN\n EXECUTE IMMEDIATE 'ALTER TABLE {{fk_table_relation}} ADD CONSTRAINT {{constraint_name}} FOREIGN KEY ( {{fk_columns_csv}} ) REFERENCES {{pk_table_relation}} ( {{pk_columns_csv}} )';\nEXCEPTION\n WHEN OTHERS THEN\n DBMS_OUTPUT.ENABLE(BUFFER_SIZE => NULL);\n DBMS_OUTPUT.PUT_LINE('Unable to create constraint: ' || SQLERRM);\nEND;\n {%- endset -%}\n {%- do log(\"Creating foreign key: \" ~ constraint_name ~ \" referencing \" ~ pk_table_relation.identifier ~ \" \" ~ pk_column_names, info=true) -%}\n {%- do run_query(query) -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because of insufficient privileges: \" ~ fk_table_relation ~ \" referencing \" ~ pk_table_relation, info=true) -%}\n {%- endif -%}\n\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because FK already exists: \" ~ fk_table_relation ~ \" \" ~ fk_column_names, info=false) -%}\n {%- endif -%}\n {%- else -%}\n {%- do log(\"Skipping \" ~ constraint_name ~ \" because a PK/UK was not found on the PK table: \" ~ pk_table_relation ~ \" \" ~ pk_column_names, info=true) -%}\n {%- endif -%}\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.get_quoted_column_csv", "macro.dbt_constraints.unique_constraint_exists", "macro.dbt_constraints.foreign_key_exists", "macro.dbt_constraints.have_ownership_priv", "macro.dbt_constraints.have_references_priv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.025859, "supported_languages": null}, "macro.dbt_constraints.oracle__create_not_null": {"name": "oracle__create_not_null", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "unique_id": "macro.dbt_constraints.oracle__create_not_null", "macro_sql": "\n{%- macro oracle__create_not_null(table_relation, column_names, verify_permissions, quote_columns, lookup_cache, rely_clause) -%}\n {%- set columns_list = dbt_constraints.get_quoted_column_list(column_names, quote_columns) -%}\n\n {%- if dbt_constraints.have_ownership_priv(table_relation, verify_permissions) -%}\n\n {%- set modify_statements= [] -%}\n {%- for column in columns_list -%}\n {%- set modify_statements = modify_statements.append( column ~ \" NOT NULL\" ) -%}\n {%- endfor -%}\n {%- set modify_statement_csv = modify_statements | join(\", \") -%}\n {%- set query -%}\nBEGIN\n EXECUTE IMMEDIATE 'ALTER TABLE {{table_relation}} MODIFY ( {{ modify_statement_csv }} )';\nEXCEPTION\n WHEN OTHERS THEN\n DBMS_OUTPUT.ENABLE(BUFFER_SIZE => NULL);\n DBMS_OUTPUT.PUT_LINE('Unable to create constraint: ' || SQLERRM);\nEND;\n {%- endset -%}\n {%- do log(\"Creating not null constraint for: \" ~ columns_list | join(\", \") ~ \" in \" ~ table_relation, info=true) -%}\n {%- do run_query(query) -%}\n\n {%- else -%}\n {%- do log(\"Skipping not null constraint for \" ~ columns_list | join(\", \") ~ \" in \" ~ table_relation ~ \" because of insufficient privileges: \" ~ table_relation, info=true) -%}\n {%- endif -%}\n{%- endmacro -%}\n", "depends_on": {"macros": ["macro.dbt_constraints.get_quoted_column_list", "macro.dbt_constraints.have_ownership_priv", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.026357, "supported_languages": null}, "macro.dbt_constraints.oracle__unique_constraint_exists": {"name": "oracle__unique_constraint_exists", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "unique_id": "macro.dbt_constraints.oracle__unique_constraint_exists", "macro_sql": "\n{%- macro oracle__unique_constraint_exists(table_relation, column_names, lookup_cache) -%}\n {%- set lookup_query -%}\nselect\n cols.constraint_name as \"constraint_name\",\n upper(cols.column_name) as \"column_name\"\nfrom\n all_constraints cons\n join all_cons_columns cols on cons.constraint_name = cols.constraint_name\n and cons.owner = cols.owner\nwhere\n cons.constraint_type in ( 'P', 'U' )\n and upper(cons.owner) = upper('{{table_relation.schema}}')\n and upper(cons.table_name) = upper('{{table_relation.identifier}}')\norder by 1, 2\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"constraint_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"column_name\"].values(), column_names ) -%}\n {%- do log(\"Found PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}#}\n\n {#- If we get this far then the table does not have either constraint -#}\n {%- do log(\"No PK/UK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.column_list_matches"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0268621, "supported_languages": null}, "macro.dbt_constraints.oracle__foreign_key_exists": {"name": "oracle__foreign_key_exists", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "unique_id": "macro.dbt_constraints.oracle__foreign_key_exists", "macro_sql": "\n{%- macro oracle__foreign_key_exists(table_relation, column_names, lookup_cache) -%}\n {%- set lookup_query -%}\nselect\n cols.constraint_name as \"fk_name\",\n upper(cols.column_name) as \"fk_column_name\"\nfrom\n all_constraints cons\n join all_cons_columns cols on cons.constraint_name = cols.constraint_name\n and cons.owner = cols.owner\nwhere\n cons.constraint_type in ( 'R' )\n and upper(cons.owner) = upper('{{table_relation.schema}}')\n and upper(cons.table_name) = upper('{{table_relation.identifier}}')\norder by 1, 2\n {%- endset -%}\n {%- do log(\"Lookup: \" ~ lookup_query, info=false) -%}\n {%- set constraint_list = run_query(lookup_query) -%}\n {%- if constraint_list.columns[\"fk_column_name\"].values() | count > 0 -%}\n {%- for constraint in constraint_list.group_by(\"fk_name\") -%}\n {%- if dbt_constraints.column_list_matches(constraint.columns[\"fk_column_name\"].values(), column_names ) -%}\n {%- do log(\"Found FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(true) }}\n {%- endif -%}\n {% endfor %}\n {%- endif -%}\n\n {#- If we get this far then the table does not have this constraint -#}\n {%- do log(\"No FK key: \" ~ table_relation ~ \" \" ~ column_names, info=false) -%}\n {{ return(false) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_constraints.column_list_matches"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.027366, "supported_languages": null}, "macro.dbt_constraints.oracle__have_references_priv": {"name": "oracle__have_references_priv", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "unique_id": "macro.dbt_constraints.oracle__have_references_priv", "macro_sql": "\n{%- macro oracle__have_references_priv(table_relation, verify_permissions, lookup_cache) -%}\n {{ return(true) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.027453, "supported_languages": null}, "macro.dbt_constraints.oracle__have_ownership_priv": {"name": "oracle__have_ownership_priv", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "unique_id": "macro.dbt_constraints.oracle__have_ownership_priv", "macro_sql": "\n{%- macro oracle__have_ownership_priv(table_relation, verify_permissions, lookup_cache) -%}\n {{ return(true) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.027533, "supported_languages": null}, "macro.dbt_constraints.oracle__drop_referential_constraints": {"name": "oracle__drop_referential_constraints", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "unique_id": "macro.dbt_constraints.oracle__drop_referential_constraints", "macro_sql": "{% macro oracle__drop_referential_constraints(relation) -%}\n {%- call statement('drop_constraint_cascade') -%}\nBEGIN\n FOR REC IN (\n SELECT owner, table_name, constraint_name\n FROM all_constraints cons\n WHERE cons.constraint_type IN ('P', 'U', 'R')\n AND upper(cons.owner) = '{{relation.schema|upper}}'\n AND upper(cons.table_name) = '{{relation.identifier|upper}}'\n ORDER BY 1\n ) LOOP\n BEGIN\n EXECUTE IMMEDIATE 'ALTER TABLE \"'||REC.OWNER||'\".\"'||REC.TABLE_NAME||'\" DROP CONSTRAINT \"'||REC.CONSTRAINT_NAME||'\" CASCADE';\n EXCEPTION\n WHEN OTHERS THEN\n DBMS_OUTPUT.ENABLE(BUFFER_SIZE => NULL);\n DBMS_OUTPUT.PUT_LINE('Unable to drop constraint: ' || SQLERRM);\n END;\n END LOOP;\nEND;\n {%- endcall -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.02768, "supported_languages": null}, "macro.dbt_constraints.oracle__truncate_relation": {"name": "oracle__truncate_relation", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "unique_id": "macro.dbt_constraints.oracle__truncate_relation", "macro_sql": "{% macro oracle__truncate_relation(relation) -%}\n {%- do log(\"Truncating table \" ~ relation, info=true) -%}\n {{ oracle__drop_referential_constraints(relation) }}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_constraints.oracle__drop_referential_constraints", "macro.dbt_constraints.truncate_relation", "macro.dbt_snowflake.snowflake__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0278358, "supported_languages": null}, "macro.dbt_constraints.oracle__drop_relation": {"name": "oracle__drop_relation", "resource_type": "macro", "package_name": "dbt_constraints", "path": "macros/oracle__create_constraints.sql", "original_file_path": "macros/oracle__create_constraints.sql", "unique_id": "macro.dbt_constraints.oracle__drop_relation", "macro_sql": "{% macro oracle__drop_relation(relation) -%}\n {%- do log(\"Dropping table \" ~ relation, info=true) -%}\n {%- call statement('drop_constraint_cascade') -%}\nBEGIN\n FOR REC IN (\n SELECT owner, table_name, constraint_name\n FROM all_constraints cons\n WHERE cons.constraint_type IN ('P', 'U', 'R')\n AND upper(cons.owner) = '{{relation.schema|upper}}'\n AND upper(cons.table_name) = '{{relation.identifier|upper}}'\n ORDER BY 1\n ) LOOP\n BEGIN\n EXECUTE IMMEDIATE 'ALTER TABLE \"'||REC.OWNER||'\".\"'||REC.TABLE_NAME||'\" DROP CONSTRAINT \"'||REC.CONSTRAINT_NAME||'\" CASCADE';\n EXCEPTION\n WHEN OTHERS THEN\n DBMS_OUTPUT.ENABLE(BUFFER_SIZE => NULL);\n DBMS_OUTPUT.PUT_LINE('Unable to drop constraint: ' || SQLERRM);\n END;\n END LOOP;\n FOR REC IN (\n SELECT owner, table_name\n FROM all_tables\n WHERE upper(owner) = '{{relation.schema|upper}}'\n AND upper(table_name) = '{{relation.identifier|upper}}'\n ORDER BY 1\n ) LOOP\n BEGIN\n EXECUTE IMMEDIATE 'DROP TABLE \"'||REC.OWNER||'\".\"'||REC.TABLE_NAME||'\" CASCADE CONSTRAINTS';\n EXCEPTION\n WHEN OTHERS THEN\n DBMS_OUTPUT.ENABLE(BUFFER_SIZE => NULL);\n DBMS_OUTPUT.PUT_LINE('Unable to drop table: ' || SQLERRM);\n END;\n END LOOP;\nEND;\n {%- endcall -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.028081, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog": {"name": "snowflake__get_catalog", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog", "macro_sql": "{% macro snowflake__get_catalog(information_schema, schemas) -%}\n\n {% set query %}\n with tables as (\n {{ snowflake__get_catalog_tables_sql(information_schema) }}\n {{ snowflake__get_catalog_schemas_where_clause_sql(schemas) }}\n ),\n columns as (\n {{ snowflake__get_catalog_columns_sql(information_schema) }}\n {{ snowflake__get_catalog_schemas_where_clause_sql(schemas) }}\n )\n {{ snowflake__get_catalog_results_sql() }}\n {%- endset -%}\n\n {{ return(run_query(query)) }}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog_tables_sql", "macro.dbt_snowflake.snowflake__get_catalog_schemas_where_clause_sql", "macro.dbt_snowflake.snowflake__get_catalog_columns_sql", "macro.dbt_snowflake.snowflake__get_catalog_results_sql", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0301929, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_relations": {"name": "snowflake__get_catalog_relations", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_relations", "macro_sql": "{% macro snowflake__get_catalog_relations(information_schema, relations) -%}\n\n {% set query %}\n with tables as (\n {{ snowflake__get_catalog_tables_sql(information_schema) }}\n {{ snowflake__get_catalog_relations_where_clause_sql(relations) }}\n ),\n columns as (\n {{ snowflake__get_catalog_columns_sql(information_schema) }}\n {{ snowflake__get_catalog_relations_where_clause_sql(relations) }}\n )\n {{ snowflake__get_catalog_results_sql() }}\n {%- endset -%}\n\n {{ return(run_query(query)) }}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog_tables_sql", "macro.dbt_snowflake.snowflake__get_catalog_relations_where_clause_sql", "macro.dbt_snowflake.snowflake__get_catalog_columns_sql", "macro.dbt_snowflake.snowflake__get_catalog_results_sql", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.030389, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_tables_sql": {"name": "snowflake__get_catalog_tables_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_tables_sql", "macro_sql": "{% macro snowflake__get_catalog_tables_sql(information_schema) -%}\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n case\n when is_dynamic = 'YES' and table_type = 'BASE TABLE' THEN 'DYNAMIC TABLE'\n else table_type\n end as \"table_type\",\n comment as \"table_comment\",\n\n -- note: this is the _role_ that owns the table\n table_owner as \"table_owner\",\n\n 'Clustering Key' as \"stats:clustering_key:label\",\n clustering_key as \"stats:clustering_key:value\",\n 'The key used to cluster this table' as \"stats:clustering_key:description\",\n (clustering_key is not null) as \"stats:clustering_key:include\",\n\n 'Row Count' as \"stats:row_count:label\",\n row_count as \"stats:row_count:value\",\n 'An approximate count of rows in this table' as \"stats:row_count:description\",\n (row_count is not null) as \"stats:row_count:include\",\n\n 'Approximate Size' as \"stats:bytes:label\",\n bytes as \"stats:bytes:value\",\n 'Approximate size of the table as reported by Snowflake' as \"stats:bytes:description\",\n (bytes is not null) as \"stats:bytes:include\",\n\n 'Last Modified' as \"stats:last_modified:label\",\n to_varchar(convert_timezone('UTC', last_altered), 'yyyy-mm-dd HH24:MI'||'UTC') as \"stats:last_modified:value\",\n 'The timestamp for last update/change' as \"stats:last_modified:description\",\n (last_altered is not null and table_type='BASE TABLE') as \"stats:last_modified:include\"\n from {{ information_schema }}.tables\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.030525, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_columns_sql": {"name": "snowflake__get_catalog_columns_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_columns_sql", "macro_sql": "{% macro snowflake__get_catalog_columns_sql(information_schema) -%}\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n\n column_name as \"column_name\",\n ordinal_position as \"column_index\",\n data_type as \"column_type\",\n comment as \"column_comment\"\n from {{ information_schema }}.columns\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.030596, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_results_sql": {"name": "snowflake__get_catalog_results_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_results_sql", "macro_sql": "{% macro snowflake__get_catalog_results_sql() -%}\n select *\n from tables\n join columns using (\"table_database\", \"table_schema\", \"table_name\")\n order by \"column_index\"\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.030643, "supported_languages": null}, "macro.dbt_snowflake.snowflake__catalog_equals": {"name": "snowflake__catalog_equals", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__catalog_equals", "macro_sql": "{% macro snowflake__catalog_equals(field, value) %}\n \"{{ field }}\" ilike '{{ value }}' and upper(\"{{ field }}\") = upper('{{ value }}')\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.030734, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_schemas_where_clause_sql": {"name": "snowflake__get_catalog_schemas_where_clause_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_schemas_where_clause_sql", "macro_sql": "{% macro snowflake__get_catalog_schemas_where_clause_sql(schemas) -%}\n where ({%- for schema in schemas -%}\n ({{ snowflake__catalog_equals('table_schema', schema) }}){%- if not loop.last %} or {% endif -%}\n {%- endfor -%})\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__catalog_equals"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.030873, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_catalog_relations_where_clause_sql": {"name": "snowflake__get_catalog_relations_where_clause_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_relations_where_clause_sql", "macro_sql": "{% macro snowflake__get_catalog_relations_where_clause_sql(relations) -%}\n where (\n {%- for relation in relations -%}\n {% if relation.schema and relation.identifier %}\n (\n {{ snowflake__catalog_equals('table_schema', relation.schema) }}\n and {{ snowflake__catalog_equals('table_name', relation.identifier) }}\n )\n {% elif relation.schema %}\n (\n {{ snowflake__catalog_equals('table_schema', relation.schema) }}\n )\n {% else %}\n {% do exceptions.raise_compiler_error(\n '`get_catalog_relations` requires a list of relations, each with a schema'\n ) %}\n {% endif %}\n\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__catalog_equals"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0311942, "supported_languages": null}, "macro.dbt_snowflake.get_column_comment_sql": {"name": "get_column_comment_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.get_column_comment_sql", "macro_sql": "{% macro get_column_comment_sql(column_name, column_dict) -%}\n {% if (column_name|upper in column_dict) -%}\n {% set matched_column = column_name|upper -%}\n {% elif (column_name|lower in column_dict) -%}\n {% set matched_column = column_name|lower -%}\n {% elif (column_name in column_dict) -%}\n {% set matched_column = column_name -%}\n {% else -%}\n {% set matched_column = None -%}\n {% endif -%}\n {% if matched_column -%}\n {{ adapter.quote(column_name) }} COMMENT $${{ column_dict[matched_column]['description'] | replace('$', '[$]') }}$$\n {%- else -%}\n {{ adapter.quote(column_name) }} COMMENT $$$$\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0377212, "supported_languages": null}, "macro.dbt_snowflake.get_persist_docs_column_list": {"name": "get_persist_docs_column_list", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.get_persist_docs_column_list", "macro_sql": "{% macro get_persist_docs_column_list(model_columns, query_columns) %}\n(\n {% for column_name in query_columns %}\n {{ get_column_comment_sql(column_name, model_columns) }}\n {{- \", \" if not loop.last else \"\" }}\n {% endfor %}\n)\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.get_column_comment_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.037958, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_columns_in_relation": {"name": "snowflake__get_columns_in_relation", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_columns_in_relation", "macro_sql": "{% macro snowflake__get_columns_in_relation(relation) -%}\n {%- set sql -%}\n describe table {{ relation }}\n {%- endset -%}\n {%- set result = run_query(sql) -%}\n\n {% set maximum = 10000 %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many columns in relation {{ relation }}! dbt can only get\n information about relations with fewer than {{ maximum }} columns.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n\n {% set columns = [] %}\n {% for row in result %}\n {% do columns.append(api.Column.from_description(row['name'], row['type'])) %}\n {% endfor %}\n {% do return(columns) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.038353, "supported_languages": null}, "macro.dbt_snowflake.snowflake__list_schemas": {"name": "snowflake__list_schemas", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__list_schemas", "macro_sql": "{% macro snowflake__list_schemas(database) -%}\n {# 10k limit from here: https://docs.snowflake.net/manuals/sql-reference/sql/show-schemas.html#usage-notes #}\n {% set maximum = 10000 %}\n {% set sql -%}\n show terse schemas in database {{ database }}\n limit {{ maximum }}\n {%- endset %}\n {% set result = run_query(sql) %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many schemas in database {{ database }}! dbt can only get\n information about databases with fewer than {{ maximum }} schemas.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n {{ return(result) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.038649, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_paginated_relations_array": {"name": "snowflake__get_paginated_relations_array", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_paginated_relations_array", "macro_sql": "{% macro snowflake__get_paginated_relations_array(max_iter, max_results_per_iter, max_total_results, schema_relation, watermark) %}\n\n {% set paginated_relations = [] %}\n\n {% for _ in range(0, max_iter) %}\n\n {% if schema_relation is string %}\n {%- set paginated_sql -%}\n show objects in {{ schema_relation }} limit {{ max_results_per_iter }} from '{{ watermark.table_name }}'\n {%- endset -%}\n {% else %}\n {%- set paginated_sql -%}\n show objects in {{ schema_relation.include(identifier=False) }} limit {{ max_results_per_iter }} from '{{ watermark.table_name }}'\n {%- endset -%}\n {% endif -%}\n\n {%- set paginated_result = run_query(paginated_sql) %}\n {%- set paginated_n = (paginated_result | length) -%}\n\n {#\n terminating condition: if there are 0 records in the result we reached\n the end exactly on the previous iteration\n #}\n {%- if paginated_n == 0 -%}\n {%- break -%}\n {%- endif -%}\n\n {#\n terminating condition: At some point the user needs to be reasonable with how\n many objects are contained in their schemas. Since there was already\n one iteration before attempting pagination, loop.index == max_iter means\n the limit has been surpassed.\n #}\n\n {%- if loop.index == max_iter -%}\n {%- set msg -%}\n dbt will list a maximum of {{ max_total_results }} objects in schema {{ schema_relation }}.\n Your schema exceeds this limit. Please contact support@getdbt.com for troubleshooting tips,\n or review and reduce the number of objects contained.\n {%- endset -%}\n\n {% do exceptions.raise_compiler_error(msg) %}\n {%- endif -%}\n\n {%- do paginated_relations.append(paginated_result) -%}\n {% set watermark.table_name = paginated_result.columns[1].values()[-1] %}\n\n {#\n terminating condition: paginated_n < max_results_per_iter means we reached the end\n #}\n {%- if paginated_n < max_results_per_iter -%}\n {%- break -%}\n {%- endif -%}\n {%- endfor -%}\n\n {{ return(paginated_relations) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.03931, "supported_languages": null}, "macro.dbt_snowflake.snowflake__list_relations_without_caching": {"name": "snowflake__list_relations_without_caching", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__list_relations_without_caching", "macro_sql": "{% macro snowflake__list_relations_without_caching(schema_relation, max_iter=10, max_results_per_iter=10000) %}\n\n {%- set max_total_results = max_results_per_iter * max_iter -%}\n {% if schema_relation is string %}\n {%- set sql -%}\n show objects in {{ schema_relation }} limit {{ max_results_per_iter }}\n {%- endset -%}\n {% else %}\n {%- set sql -%}\n show objects in {{ schema_relation.include(identifier=False) }} limit {{ max_results_per_iter }}\n {%- endset -%}\n {% endif -%}\n\n {%- set result = run_query(sql) -%}\n\n {%- set n = (result | length) -%}\n {%- set watermark = namespace(table_name=result.columns[1].values()[-1]) -%}\n {%- set paginated = namespace(result=[]) -%}\n\n {% if n >= max_results_per_iter %}\n\n {% set paginated.result = snowflake__get_paginated_relations_array(\n max_iter,\n max_results_per_iter,\n max_total_results,\n schema_relation,\n watermark\n )\n %}\n\n {% endif %}\n\n {%- set all_results_array = [result] + paginated.result -%}\n {%- set result = result.merge(all_results_array) -%}\n {%- do return(result) -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt_snowflake.snowflake__get_paginated_relations_array"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.039885, "supported_languages": null}, "macro.dbt_snowflake.snowflake__check_schema_exists": {"name": "snowflake__check_schema_exists", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__check_schema_exists", "macro_sql": "{% macro snowflake__check_schema_exists(information_schema, schema) -%}\n {% call statement('check_schema_exists', fetch_result=True) -%}\n select count(*)\n from {{ information_schema }}.schemata\n where upper(schema_name) = upper('{{ schema }}')\n and upper(catalog_name) = upper('{{ information_schema.database }}')\n {%- endcall %}\n {{ return(load_result('check_schema_exists').table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.040064, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_column_type": {"name": "snowflake__alter_column_type", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__alter_column_type", "macro_sql": "{% macro snowflake__alter_column_type(relation, column_name, new_column_type) -%}\n {% call statement('alter_column_type') %}\n alter table {{ relation }} alter {{ adapter.quote(column_name) }} set data type {{ new_column_type }};\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0401978, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_relation_comment": {"name": "snowflake__alter_relation_comment", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__alter_relation_comment", "macro_sql": "{% macro snowflake__alter_relation_comment(relation, relation_comment) -%}\n {%- if relation.is_dynamic_table -%}\n {%- set relation_type = 'dynamic table' -%}\n {%- else -%}\n {%- set relation_type = relation.type -%}\n {%- endif -%}\n comment on {{ relation_type }} {{ relation }} IS $${{ relation_comment | replace('$', '[$]') }}$$;\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.040388, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_column_comment": {"name": "snowflake__alter_column_comment", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__alter_column_comment", "macro_sql": "{% macro snowflake__alter_column_comment(relation, column_dict) -%}\n {% set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute=\"name\") | list %}\n {% if relation.is_dynamic_table -%}\n {% set relation_type = \"table\" %}\n {% else -%}\n {% set relation_type = relation.type %}\n {% endif %}\n alter {{ relation_type }} {{ relation }} alter\n {% for column_name in existing_columns if (column_name in existing_columns) or (column_name|lower in existing_columns) %}\n {{ get_column_comment_sql(column_name, column_dict) }} {{- ',' if not loop.last else ';' }}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.get_column_comment_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.040735, "supported_languages": null}, "macro.dbt_snowflake.get_current_query_tag": {"name": "get_current_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.get_current_query_tag", "macro_sql": "{% macro get_current_query_tag() -%}\n {{ return(run_query(\"show parameters like 'query_tag' in session\").rows[0]['value']) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.040837, "supported_languages": null}, "macro.dbt_snowflake.set_query_tag": {"name": "set_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.set_query_tag", "macro_sql": "{% macro set_query_tag() -%}\n {{ return(adapter.dispatch('set_query_tag', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__set_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.040929, "supported_languages": null}, "macro.dbt_snowflake.snowflake__set_query_tag": {"name": "snowflake__set_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__set_query_tag", "macro_sql": "{% macro snowflake__set_query_tag() -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% set original_query_tag = get_current_query_tag() %}\n {{ log(\"Setting query_tag to '\" ~ new_query_tag ~ \"'. Will reset to '\" ~ original_query_tag ~ \"' after materialization.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(new_query_tag)) %}\n {{ return(original_query_tag)}}\n {% endif %}\n {{ return(none)}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.get_current_query_tag", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.04118, "supported_languages": null}, "macro.dbt_snowflake.unset_query_tag": {"name": "unset_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.unset_query_tag", "macro_sql": "{% macro unset_query_tag(original_query_tag) -%}\n {{ return(adapter.dispatch('unset_query_tag', 'dbt')(original_query_tag)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.041285, "supported_languages": null}, "macro.dbt_snowflake.snowflake__unset_query_tag": {"name": "snowflake__unset_query_tag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__unset_query_tag", "macro_sql": "{% macro snowflake__unset_query_tag(original_query_tag) -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% if original_query_tag %}\n {{ log(\"Resetting query_tag to '\" ~ original_query_tag ~ \"'.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(original_query_tag)) %}\n {% else %}\n {{ log(\"No original query_tag, unsetting parameter.\") }}\n {% do run_query(\"alter session unset query_tag\") %}\n {% endif %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0415528, "supported_languages": null}, "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns": {"name": "snowflake__alter_relation_add_remove_columns", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns", "macro_sql": "{% macro snowflake__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if relation.is_dynamic_table -%}\n {% set relation_type = \"dynamic table\" %}\n {% else -%}\n {% set relation_type = relation.type %}\n {% endif %}\n\n {% if add_columns %}\n\n {% set sql -%}\n alter {{ relation_type }} {{ relation }} add column\n {% for column in add_columns %}\n {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n {% endif %}\n\n {% if remove_columns %}\n\n {% set sql -%}\n alter {{ relation_type }} {{ relation }} drop column\n {% for column in remove_columns %}\n {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0420108, "supported_languages": null}, "macro.dbt_snowflake.snowflake_dml_explicit_transaction": {"name": "snowflake_dml_explicit_transaction", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake_dml_explicit_transaction", "macro_sql": "{% macro snowflake_dml_explicit_transaction(dml) %}\n {#\n Use this macro to wrap all INSERT, MERGE, UPDATE, DELETE, and TRUNCATE\n statements before passing them into run_query(), or calling in the 'main' statement\n of a materialization\n #}\n {% set dml_transaction -%}\n begin;\n {{ dml }};\n commit;\n {%- endset %}\n\n {% do return(dml_transaction) %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0421371, "supported_languages": null}, "macro.dbt_snowflake.snowflake__truncate_relation": {"name": "snowflake__truncate_relation", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_snowflake.snowflake__truncate_relation", "macro_sql": "{% macro snowflake__truncate_relation(relation) -%}\n {% set truncate_dml %}\n truncate table {{ relation }}\n {% endset %}\n {% call statement('truncate_relation') -%}\n {{ snowflake_dml_explicit_transaction(truncate_dml) }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0422678, "supported_languages": null}, "macro.dbt_snowflake.snowflake__copy_grants": {"name": "snowflake__copy_grants", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/apply_grants.sql", "original_file_path": "macros/apply_grants.sql", "unique_id": "macro.dbt_snowflake.snowflake__copy_grants", "macro_sql": "{% macro snowflake__copy_grants() %}\n {% set copy_grants = config.get('copy_grants', False) %}\n {{ return(copy_grants) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.042429, "supported_languages": null}, "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement": {"name": "snowflake__support_multiple_grantees_per_dcl_statement", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/apply_grants.sql", "original_file_path": "macros/apply_grants.sql", "unique_id": "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement", "macro_sql": "\n\n{%- macro snowflake__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(False) }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.042492, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_relation_last_modified": {"name": "snowflake__get_relation_last_modified", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/metadata.sql", "original_file_path": "macros/metadata.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_relation_last_modified", "macro_sql": "{% macro snowflake__get_relation_last_modified(information_schema, relations) -%}\n\n {%- call statement('last_modified', fetch_result=True) -%}\n select table_schema as schema,\n table_name as identifier,\n last_altered as last_modified,\n {{ current_timestamp() }} as snapshotted_at\n from {{ information_schema }}.tables\n where (\n {%- for relation in relations -%}\n (upper(table_schema) = upper('{{ relation.schema }}') and\n upper(table_name) = upper('{{ relation.identifier }}')){%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n {%- endcall -%}\n\n {{ return(load_result('last_modified')) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.042861, "supported_languages": null}, "macro.dbt_snowflake.materialization_test_snowflake": {"name": "materialization_test_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/test.sql", "original_file_path": "macros/materializations/test.sql", "unique_id": "macro.dbt_snowflake.materialization_test_snowflake", "macro_sql": "{%- materialization test, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set relations = materialization_test_default() %}\n {% do unset_query_tag(original_query_tag) %}\n {{ return(relations) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_test_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.043061, "supported_languages": ["sql"]}, "macro.dbt_snowflake.snowflake__get_merge_sql": {"name": "snowflake__get_merge_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_merge_sql", "macro_sql": "{% macro snowflake__get_merge_sql(target, source_sql, unique_key, dest_columns, incremental_predicates) -%}\n\n {#\n Workaround for Snowflake not being happy with a merge on a constant-false predicate.\n When no unique_key is provided, this macro will do a regular insert. If a unique_key\n is provided, then this macro will do a proper merge instead.\n #}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute='name')) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {%- set dml -%}\n {%- if unique_key is none -%}\n\n {{ sql_header if sql_header is not none }}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source_sql }}\n )\n\n {%- else -%}\n\n {{ default__get_merge_sql(target, source_sql, unique_key, dest_columns, incremental_predicates) }}\n\n {%- endif -%}\n {%- endset -%}\n\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv", "macro.dbt.default__get_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0438762, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql": {"name": "snowflake__get_delete_insert_merge_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql", "macro_sql": "{% macro snowflake__get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) %}\n {% set dml = default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_delete_insert_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0440378, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_merge_sql": {"name": "snowflake__snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "unique_id": "macro.dbt_snowflake.snowflake__snapshot_merge_sql", "macro_sql": "{% macro snowflake__snapshot_merge_sql(target, source, insert_cols) %}\n {% set dml = default__snapshot_merge_sql(target, source, insert_cols) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__snapshot_merge_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.044172, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_incremental_append_sql": {"name": "snowflake__get_incremental_append_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_incremental_append_sql", "macro_sql": "{% macro snowflake__get_incremental_append_sql(get_incremental_append_sql) %}\n {% set dml = default__get_incremental_append_sql(get_incremental_append_sql) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_append_sql", "macro.dbt_snowflake.snowflake_dml_explicit_transaction"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.044288, "supported_languages": null}, "macro.dbt_snowflake.snowflake__load_csv_rows": {"name": "snowflake__load_csv_rows", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/seed.sql", "original_file_path": "macros/materializations/seed.sql", "unique_id": "macro.dbt_snowflake.snowflake__load_csv_rows", "macro_sql": "{% macro snowflake__load_csv_rows(model, agate_table) %}\n {% set batch_size = get_batch_size() %}\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n %s\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query('BEGIN', auto_begin=False) %}\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n {% do adapter.add_query('COMMIT', auto_begin=False) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_batch_size", "macro.dbt.get_seed_column_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0455139, "supported_languages": null}, "macro.dbt_snowflake.materialization_seed_snowflake": {"name": "materialization_seed_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/seed.sql", "original_file_path": "macros/materializations/seed.sql", "unique_id": "macro.dbt_snowflake.materialization_seed_snowflake", "macro_sql": "{% materialization seed, adapter='snowflake' %}\n {% set original_query_tag = set_query_tag() %}\n\n {% set relations = materialization_seed_default() %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return(relations) }}\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_seed_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.045687, "supported_languages": ["sql"]}, "macro.dbt_snowflake.materialization_view_snowflake": {"name": "materialization_view_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/view.sql", "original_file_path": "macros/materializations/view.sql", "unique_id": "macro.dbt_snowflake.materialization_view_snowflake", "macro_sql": "{% materialization view, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set to_return = snowflake__create_or_replace_view() %}\n\n {% set target_relation = this.incorporate(type='view') %}\n\n {% do persist_docs(target_relation, model, for_columns=false) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {% do return(to_return) %}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt_snowflake.snowflake__create_or_replace_view", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.045982, "supported_languages": ["sql"]}, "macro.dbt_snowflake.materialization_table_snowflake": {"name": "materialization_table_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_snowflake.materialization_table_snowflake", "macro_sql": "{% materialization table, adapter='snowflake', supported_languages=['sql', 'python']%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {%- set identifier = model['alias'] -%}\n {%- set language = model['language'] -%}\n\n {% set grant_config = config.get('grants') %}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set target_relation = api.Relation.create(identifier=identifier,\n schema=schema,\n database=database, type='table') -%}\n\n {{ run_hooks(pre_hooks) }}\n\n {#-- Drop the relation if it was a view to \"convert\" it in a table. This may lead to\n -- downtime, but it should be a relatively infrequent occurrence #}\n {% if old_relation is not none and not old_relation.is_table %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ drop_relation_if_exists(old_relation) }}\n {% endif %}\n\n {% call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall %}\n\n {{ run_hooks(post_hooks) }}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.create_table_as", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.047171, "supported_languages": ["sql", "python"]}, "macro.dbt_snowflake.py_write_table": {"name": "py_write_table", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_snowflake.py_write_table", "macro_sql": "{% macro py_write_table(compiled_code, target_relation, temporary=False, table_type=none) %}\n{#- The following logic is only for backwards-compatiblity with deprecated `temporary` parameter -#}\n{% if table_type is not none %}\n {#- Just use the table_type as-is -#}\n{% elif temporary -%}\n {#- Case 1 when the deprecated `temporary` parameter is used without the replacement `table_type` parameter -#}\n {%- set table_type = \"temporary\" -%}\n{% else %}\n {#- Case 2 when the deprecated `temporary` parameter is used without the replacement `table_type` parameter -#}\n {#- Snowflake treats \"\" as meaning \"permanent\" -#}\n {%- set table_type = \"\" -%}\n{%- endif %}\n{{ compiled_code }}\ndef materialize(session, df, target_relation):\n # make sure pandas exists\n import importlib.util\n package_name = 'pandas'\n if importlib.util.find_spec(package_name):\n import pandas\n if isinstance(df, pandas.core.frame.DataFrame):\n session.use_database(target_relation.database)\n session.use_schema(target_relation.schema)\n # session.write_pandas does not have overwrite function\n df = session.createDataFrame(df)\n {% set target_relation_name = resolve_model_name(target_relation) %}\n df.write.mode(\"overwrite\").save_as_table('{{ target_relation_name }}', table_type='{{table_type}}')\n\ndef main(session):\n dbt = dbtObj(session.table)\n df = model(dbt, session)\n materialize(session, df, dbt.this)\n return \"OK\"\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.047456, "supported_languages": null}, "macro.dbt_snowflake.py_script_comment": {"name": "py_script_comment", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_snowflake.py_script_comment", "macro_sql": "{% macro py_script_comment()%}\n# To run this in snowsight, you need to select entry point to be main\n# And you may have to modify the return type to text to get the result back\n# def main(session):\n# dbt = dbtObj(session.table)\n# df = model(dbt, session)\n# return df.collect()\n\n# to run this in local notebook, you need to create a session following examples https://github.com/Snowflake-Labs/sfguide-getting-started-snowpark-python\n# then you can do the following to run model\n# dbt = dbtObj(session.table)\n# df = model(dbt, session)\n{%endmacro%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0475268, "supported_languages": null}, "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type": {"name": "dbt_snowflake_get_tmp_relation_type", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "unique_id": "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type", "macro_sql": "{% macro dbt_snowflake_get_tmp_relation_type(strategy, unique_key, language) %}\n{%- set tmp_relation_type = config.get('tmp_relation_type') -%}\n /* {#\n High-level principles:\n If we are running multiple statements (DELETE + INSERT),\n and we want to guarantee identical inputs to both statements,\n then we must first save the model query results as a temporary table\n (which presumably comes with a performance cost).\n If we are running a single statement (MERGE or INSERT alone),\n we _may_ save the model query definition as a view instead,\n for (presumably) faster overall incremental processing.\n\n Low-level specifics:\n If an invalid option is specified, then we will raise an\n excpetion with corresponding message.\n\n Languages other than SQL (like Python) will use a temporary table.\n With the default strategy of merge, the user may choose between a temporary\n table and view (defaulting to view).\n\n The append strategy can use a view because it will run a single INSERT statement.\n\n When unique_key is none, the delete+insert strategy can use a view beacuse a\n single INSERT statement is run with no DELETES as part of the statement.\n Otherwise, play it safe by using a temporary table.\n #} */\n\n {% if language == \"python\" and tmp_relation_type is not none %}\n {% do exceptions.raise_compiler_error(\n \"Python models currently only support 'table' for tmp_relation_type but \"\n ~ tmp_relation_type ~ \" was specified.\"\n ) %}\n {% endif %}\n\n {% if strategy == \"delete+insert\" and tmp_relation_type is not none and tmp_relation_type != \"table\" and unique_key is not none %}\n {% do exceptions.raise_compiler_error(\n \"In order to maintain consistent results when `unique_key` is not none,\n the `delete+insert` strategy only supports `table` for `tmp_relation_type` but \"\n ~ tmp_relation_type ~ \" was specified.\"\n )\n %}\n {% endif %}\n\n {% if language != \"sql\" %}\n {{ return(\"table\") }}\n {% elif tmp_relation_type == \"table\" %}\n {{ return(\"table\") }}\n {% elif tmp_relation_type == \"view\" %}\n {{ return(\"view\") }}\n {% elif strategy in (\"default\", \"merge\", \"append\") %}\n {{ return(\"view\") }}\n {% elif strategy == \"delete+insert\" and unique_key is none %}\n {{ return(\"view\") }}\n {% else %}\n {{ return(\"table\") }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0489442, "supported_languages": null}, "macro.dbt_snowflake.materialization_incremental_snowflake": {"name": "materialization_incremental_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "unique_id": "macro.dbt_snowflake.materialization_incremental_snowflake", "macro_sql": "{% materialization incremental, adapter='snowflake', supported_languages=['sql', 'python'] -%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {#-- Set vars --#}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n {%- set language = model['language'] -%}\n {% set target_relation = this %}\n {% set existing_relation = load_relation(this) %}\n\n {#-- The temp relation will be a view (faster) or temp table, depending on upsert/merge strategy --#}\n {%- set unique_key = config.get('unique_key') -%}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set tmp_relation_type = dbt_snowflake_get_tmp_relation_type(incremental_strategy, unique_key, language) %}\n {% set tmp_relation = make_temp_relation(this).incorporate(type=tmp_relation_type) %}\n\n {% set grant_config = config.get('grants') %}\n\n {% set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') %}\n\n {{ run_hooks(pre_hooks) }}\n\n {% if existing_relation is none %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n\n {% elif existing_relation.is_view %}\n {#-- Can't overwrite a view with a table - we must drop --#}\n {{ log(\"Dropping relation \" ~ target_relation ~ \" because it is a view and this model is a table.\") }}\n {% do adapter.drop_relation(existing_relation) %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n {% elif full_refresh_mode %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n\n {% else %}\n {#-- Create the temp relation, either as a view or as a temp table --#}\n {% if tmp_relation_type == 'view' %}\n {%- call statement('create_tmp_relation') -%}\n {{ snowflake__create_view_as_with_temp_flag(tmp_relation, compiled_code, True) }}\n {%- endcall -%}\n {% else %}\n {%- call statement('create_tmp_relation', language=language) -%}\n {{ create_table_as(True, tmp_relation, compiled_code, language) }}\n {%- endcall -%}\n {% endif %}\n\n {% do adapter.expand_target_column_types(\n from_relation=tmp_relation,\n to_relation=target_relation) %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, tmp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': tmp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'incremental_predicates': incremental_predicates }) %}\n\n {%- call statement('main') -%}\n {{ strategy_sql_macro_func(strategy_arg_dict) }}\n {%- endcall -%}\n {% endif %}\n\n {% do drop_relation_if_exists(tmp_relation) %}\n\n {{ run_hooks(post_hooks) }}\n\n {% set target_relation = target_relation.incorporate(type='table') %}\n\n {% set should_revoke =\n should_revoke(existing_relation.is_table, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.should_full_refresh", "macro.dbt.load_relation", "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type", "macro.dbt.make_temp_relation", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.create_table_as", "macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag", "macro.dbt.process_schema_changes", "macro.dbt.drop_relation_if_exists", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.050684, "supported_languages": ["sql", "python"]}, "macro.dbt_snowflake.snowflake__get_incremental_default_sql": {"name": "snowflake__get_incremental_default_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_incremental_default_sql", "macro_sql": "{% macro snowflake__get_incremental_default_sql(arg_dict) %}\n {{ return(get_incremental_merge_sql(arg_dict)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_incremental_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0507798, "supported_languages": null}, "macro.dbt_snowflake.materialization_snapshot_snowflake": {"name": "materialization_snapshot_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/snapshot.sql", "original_file_path": "macros/materializations/snapshot.sql", "unique_id": "macro.dbt_snowflake.materialization_snapshot_snowflake", "macro_sql": "{% materialization snapshot, adapter='snowflake' %}\n {% set original_query_tag = set_query_tag() %}\n {% set relations = materialization_snapshot_default() %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return(relations) }}\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.materialization_snapshot_default", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.05098, "supported_languages": ["sql"]}, "macro.dbt_snowflake.materialization_dynamic_table_snowflake": {"name": "materialization_dynamic_table_snowflake", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/dynamic_table.sql", "original_file_path": "macros/materializations/dynamic_table.sql", "unique_id": "macro.dbt_snowflake.materialization_dynamic_table_snowflake", "macro_sql": "{% materialization dynamic_table, adapter='snowflake' %}\n\n {% set query_tag = set_query_tag() %}\n\n {% set existing_relation = load_cached_relation(this) %}\n {% set target_relation = this.incorporate(type=this.DynamicTable) %}\n\n {{ run_hooks(pre_hooks) }}\n\n {% set build_sql = dynamic_table_get_build_sql(existing_relation, target_relation) %}\n\n {% if build_sql == '' %}\n {{ dynamic_table_execute_no_op(target_relation) }}\n {% else %}\n {{ dynamic_table_execute_build_sql(build_sql, existing_relation, target_relation) }}\n {% endif %}\n\n {{ run_hooks(post_hooks) }}\n\n {% do unset_query_tag(query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt_snowflake.set_query_tag", "macro.dbt.load_cached_relation", "macro.dbt.run_hooks", "macro.dbt_snowflake.dynamic_table_get_build_sql", "macro.dbt_snowflake.dynamic_table_execute_no_op", "macro.dbt_snowflake.dynamic_table_execute_build_sql", "macro.dbt_snowflake.unset_query_tag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0529459, "supported_languages": ["sql"]}, "macro.dbt_snowflake.dynamic_table_get_build_sql": {"name": "dynamic_table_get_build_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/dynamic_table.sql", "original_file_path": "macros/materializations/dynamic_table.sql", "unique_id": "macro.dbt_snowflake.dynamic_table_get_build_sql", "macro_sql": "{% macro dynamic_table_get_build_sql(existing_relation, target_relation) %}\n\n {% set full_refresh_mode = should_full_refresh() %}\n\n -- determine the scenario we're in: create, full_refresh, alter, refresh data\n {% if existing_relation is none %}\n {% set build_sql = get_create_sql(target_relation, sql) %}\n {% elif full_refresh_mode or not existing_relation.is_dynamic_table %}\n {% set build_sql = get_replace_sql(existing_relation, target_relation, sql) %}\n {% else %}\n\n -- get config options\n {% set on_configuration_change = config.get('on_configuration_change') %}\n {% set configuration_changes = snowflake__get_dynamic_table_configuration_changes(existing_relation, config) %}\n\n {% if configuration_changes is none %}\n {% set build_sql = '' %}\n {{ exceptions.warn(\"No configuration changes were identified on: `\" ~ target_relation ~ \"`. Continuing.\") }}\n\n {% elif on_configuration_change == 'apply' %}\n {% set build_sql = snowflake__get_alter_dynamic_table_as_sql(existing_relation, configuration_changes, target_relation, sql) %}\n {% elif on_configuration_change == 'continue' %}\n {% set build_sql = '' %}\n {{ exceptions.warn(\"Configuration changes were identified and `on_configuration_change` was set to `continue` for `\" ~ target_relation ~ \"`\") }}\n {% elif on_configuration_change == 'fail' %}\n {{ exceptions.raise_fail_fast_error(\"Configuration changes were identified and `on_configuration_change` was set to `fail` for `\" ~ target_relation ~ \"`\") }}\n\n {% else %}\n -- this only happens if the user provides a value other than `apply`, 'continue', 'fail'\n {{ exceptions.raise_compiler_error(\"Unexpected configuration scenario: `\" ~ on_configuration_change ~ \"`\") }}\n\n {% endif %}\n\n {% endif %}\n\n {% do return(build_sql) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.get_create_sql", "macro.dbt.get_replace_sql", "macro.dbt_snowflake.snowflake__get_dynamic_table_configuration_changes", "macro.dbt_snowflake.snowflake__get_alter_dynamic_table_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.053632, "supported_languages": null}, "macro.dbt_snowflake.dynamic_table_execute_no_op": {"name": "dynamic_table_execute_no_op", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/dynamic_table.sql", "original_file_path": "macros/materializations/dynamic_table.sql", "unique_id": "macro.dbt_snowflake.dynamic_table_execute_no_op", "macro_sql": "{% macro dynamic_table_execute_no_op(relation) %}\n {% do store_raw_result(\n name=\"main\",\n message=\"skip \" ~ relation,\n code=\"skip\",\n rows_affected=\"-1\"\n ) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.053761, "supported_languages": null}, "macro.dbt_snowflake.dynamic_table_execute_build_sql": {"name": "dynamic_table_execute_build_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/dynamic_table.sql", "original_file_path": "macros/materializations/dynamic_table.sql", "unique_id": "macro.dbt_snowflake.dynamic_table_execute_build_sql", "macro_sql": "{% macro dynamic_table_execute_build_sql(build_sql, existing_relation, target_relation) %}\n\n {% set grant_config = config.get('grants') %}\n\n {% call statement(name=\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.054017, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_dynamic_table_configuration_changes": {"name": "snowflake__get_dynamic_table_configuration_changes", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/dynamic_table.sql", "original_file_path": "macros/materializations/dynamic_table.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_dynamic_table_configuration_changes", "macro_sql": "{% macro snowflake__get_dynamic_table_configuration_changes(existing_relation, new_config) -%}\n {% set _existing_dynamic_table = snowflake__describe_dynamic_table(existing_relation) %}\n {% set _configuration_changes = existing_relation.dynamic_table_config_changeset(_existing_dynamic_table, new_config.model) %}\n {% do return(_configuration_changes) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__describe_dynamic_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.054165, "supported_languages": null}, "macro.dbt_snowflake.snowflake__can_clone_table": {"name": "snowflake__can_clone_table", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/clone.sql", "original_file_path": "macros/materializations/clone.sql", "unique_id": "macro.dbt_snowflake.snowflake__can_clone_table", "macro_sql": "{% macro snowflake__can_clone_table() %}\n {{ return(True) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.054306, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_or_replace_clone": {"name": "snowflake__create_or_replace_clone", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/materializations/clone.sql", "original_file_path": "macros/materializations/clone.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_or_replace_clone", "macro_sql": "{% macro snowflake__create_or_replace_clone(this_relation, defer_relation) %}\n create or replace\n {{ \"transient\" if config.get(\"transient\", true) }}\n table {{ this_relation }}\n clone {{ defer_relation }}\n {{ \"copy grants\" if config.get(\"copy_grants\", false) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.054461, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_drop_sql": {"name": "snowflake__get_drop_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_drop_sql", "macro_sql": "{% macro snowflake__get_drop_sql(relation) %}\n\n {% if relation.is_dynamic_table %}\n {{ snowflake__get_drop_dynamic_table_sql(relation) }}\n\n {% else %}\n {{ default__get_drop_sql(relation) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_drop_dynamic_table_sql", "macro.dbt.default__get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.054635, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_replace_sql": {"name": "snowflake__get_replace_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/replace.sql", "original_file_path": "macros/relations/replace.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_replace_sql", "macro_sql": "{% macro snowflake__get_replace_sql(existing_relation, target_relation, sql) %}\n\n {% if existing_relation.is_dynamic_table and target_relation.is_dynamic_table %}\n {{ snowflake__get_replace_dynamic_table_sql(target_relation, sql) }}\n\n {% else %}\n {{ default__get_replace_sql(existing_relation, target_relation, sql) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_replace_dynamic_table_sql", "macro.dbt.default__get_replace_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0548549, "supported_languages": null}, "macro.dbt_snowflake.snowflake__rename_relation": {"name": "snowflake__rename_relation", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt_snowflake.snowflake__rename_relation", "macro_sql": "{% macro snowflake__rename_relation(from_relation, to_relation) -%}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ to_relation }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.054998, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_create_sql": {"name": "snowflake__get_create_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/create.sql", "original_file_path": "macros/relations/create.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_create_sql", "macro_sql": "{% macro snowflake__get_create_sql(relation, sql) %}\n\n {% if relation.is_dynamic_table %}\n {{ snowflake__get_create_dynamic_table_as_sql(relation, sql) }}\n\n {% else %}\n {{ default__get_create_sql(relation, sql) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_create_dynamic_table_as_sql", "macro.dbt.default__get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.055198, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_drop_table_sql": {"name": "snowflake__get_drop_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/table/drop.sql", "original_file_path": "macros/relations/table/drop.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_drop_table_sql", "macro_sql": "{% macro snowflake__get_drop_table_sql(relation) %}\n drop table if exists {{ relation }} cascade\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.055286, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_replace_table_sql": {"name": "snowflake__get_replace_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/table/replace.sql", "original_file_path": "macros/relations/table/replace.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_replace_table_sql", "macro_sql": "{% macro snowflake__get_replace_table_sql(relation, sql) %}\n {{ snowflake__create_table_as(False, relation, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.055391, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_rename_table_sql": {"name": "snowflake__get_rename_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/table/rename.sql", "original_file_path": "macros/relations/table/rename.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_rename_table_sql", "macro_sql": "{%- macro snowflake__get_rename_table_sql(relation, new_name) -%}\n alter table {{ relation }} rename to {{ new_name }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0554838, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_table_as": {"name": "snowflake__create_table_as", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_table_as", "macro_sql": "{% macro snowflake__create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {%- set transient = config.get('transient', default=true) -%}\n\n {% if temporary -%}\n {%- set table_type = \"temporary\" -%}\n {%- elif transient -%}\n {%- set table_type = \"transient\" -%}\n {%- else -%}\n {%- set table_type = \"\" -%}\n {%- endif %}\n\n {%- if language == 'sql' -%}\n {%- set cluster_by_keys = config.get('cluster_by', default=none) -%}\n {%- set enable_automatic_clustering = config.get('automatic_clustering', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n\n {%- if cluster_by_keys is not none and cluster_by_keys is string -%}\n {%- set cluster_by_keys = [cluster_by_keys] -%}\n {%- endif -%}\n {%- if cluster_by_keys is not none -%}\n {%- set cluster_by_string = cluster_by_keys|join(\", \")-%}\n {% else %}\n {%- set cluster_by_string = none -%}\n {%- endif -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create or replace {{ table_type }} table {{ relation }}\n {%- set contract_config = config.get('contract') -%}\n {%- if contract_config.enforced -%}\n {{ get_assert_columns_equivalent(sql) }}\n {{ get_table_columns_and_constraints() }}\n {% set compiled_code = get_select_subquery(compiled_code) %}\n {% endif %}\n {% if copy_grants and not temporary -%} copy grants {%- endif %} as\n (\n {%- if cluster_by_string is not none -%}\n select * from (\n {{ compiled_code }}\n ) order by ({{ cluster_by_string }})\n {%- else -%}\n {{ compiled_code }}\n {%- endif %}\n );\n {% if cluster_by_string is not none and not temporary -%}\n alter table {{relation}} cluster by ({{cluster_by_string}});\n {%- endif -%}\n {% if enable_automatic_clustering and cluster_by_string is not none and not temporary -%}\n alter table {{relation}} resume recluster;\n {%- endif -%}\n\n {%- elif language == 'python' -%}\n {{ py_write_table(compiled_code=compiled_code, target_relation=relation, table_type=table_type) }}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"snowflake__create_table_as macro didn't get supported language, it got %s\" % language) %}\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_assert_columns_equivalent", "macro.dbt.get_table_columns_and_constraints", "macro.dbt.get_select_subquery", "macro.dbt_snowflake.py_write_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0575979, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_drop_view_sql": {"name": "snowflake__get_drop_view_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/view/drop.sql", "original_file_path": "macros/relations/view/drop.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_drop_view_sql", "macro_sql": "{% macro snowflake__get_drop_view_sql(relation) %}\n drop view if exists {{ relation }} cascade\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.057687, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_replace_view_sql": {"name": "snowflake__get_replace_view_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_replace_view_sql", "macro_sql": "{% macro snowflake__get_replace_view_sql(relation, sql) %}\n {{ snowflake__create_view_as(relation, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.057784, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_rename_view_sql": {"name": "snowflake__get_rename_view_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/view/rename.sql", "original_file_path": "macros/relations/view/rename.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_rename_view_sql", "macro_sql": "{%- macro snowflake__get_rename_view_sql(relation, new_name) -%}\n alter view {{ relation }} rename to {{ new_name }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.057878, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag": {"name": "snowflake__create_view_as_with_temp_flag", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag", "macro_sql": "{% macro snowflake__create_view_as_with_temp_flag(relation, sql, is_temporary=False) -%}\n {%- set secure = config.get('secure', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create or replace {% if secure -%}\n secure\n {%- endif %} {% if is_temporary -%}\n temporary\n {%- endif %} view {{ relation }}\n {% if config.persist_column_docs() -%}\n {% set model_columns = model.columns %}\n {% set query_columns = get_columns_in_query(sql) %}\n {{ get_persist_docs_column_list(model_columns, query_columns) }}\n\n {%- endif %}\n {%- set contract_config = config.get('contract') -%}\n {%- if contract_config.enforced -%}\n {{ get_assert_columns_equivalent(sql) }}\n {%- endif %}\n {% if copy_grants -%} copy grants {%- endif %} as (\n {{ sql }}\n );\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_columns_in_query", "macro.dbt_snowflake.get_persist_docs_column_list", "macro.dbt.get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.058857, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_view_as": {"name": "snowflake__create_view_as", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_view_as", "macro_sql": "{% macro snowflake__create_view_as(relation, sql) -%}\n {{ snowflake__create_view_as_with_temp_flag(relation, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.058944, "supported_languages": null}, "macro.dbt_snowflake.snowflake__create_or_replace_view": {"name": "snowflake__create_or_replace_view", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt_snowflake.snowflake__create_or_replace_view", "macro_sql": "{% macro snowflake__create_or_replace_view() %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database,\n type='view') -%}\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks) }}\n\n -- If there's a table with the same name and we weren't told to full refresh,\n -- that's an error. If we were told to full refresh, drop it. This behavior differs\n -- for Snowflake and BigQuery, so multiple dispatch is used.\n {%- if old_relation is not none and not old_relation.is_view -%}\n {{ handle_existing_table(should_full_refresh(), old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n\n {% set should_revoke = should_revoke(exists_as_view, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {{ run_hooks(post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.handle_existing_table", "macro.dbt.should_full_refresh", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0595891, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_drop_dynamic_table_sql": {"name": "snowflake__get_drop_dynamic_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/dynamic_table/drop.sql", "original_file_path": "macros/relations/dynamic_table/drop.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_drop_dynamic_table_sql", "macro_sql": "{% macro snowflake__get_drop_dynamic_table_sql(relation) %}\n drop dynamic table if exists {{ relation }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.05968, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_replace_dynamic_table_sql": {"name": "snowflake__get_replace_dynamic_table_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/dynamic_table/replace.sql", "original_file_path": "macros/relations/dynamic_table/replace.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_replace_dynamic_table_sql", "macro_sql": "{% macro snowflake__get_replace_dynamic_table_sql(relation, sql) %}\n\n create or replace dynamic table {{ relation }}\n target_lag = '{{ config.get(\"target_lag\") }}'\n warehouse = {{ config.get(\"snowflake_warehouse\") }}\n as (\n {{ sql }}\n )\n ;\n {{ snowflake__refresh_dynamic_table(relation) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__refresh_dynamic_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0598888, "supported_languages": null}, "macro.dbt_snowflake.snowflake__describe_dynamic_table": {"name": "snowflake__describe_dynamic_table", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/dynamic_table/describe.sql", "original_file_path": "macros/relations/dynamic_table/describe.sql", "unique_id": "macro.dbt_snowflake.snowflake__describe_dynamic_table", "macro_sql": "{% macro snowflake__describe_dynamic_table(relation) %}\n {%- set _dynamic_table_sql -%}\n show dynamic tables\n like '{{ relation.identifier }}'\n in schema {{ relation.database }}.{{ relation.schema }}\n ;\n select\n \"name\",\n \"schema_name\",\n \"database_name\",\n \"text\",\n \"target_lag\",\n \"warehouse\"\n from table(result_scan(last_query_id()))\n {%- endset %}\n {% set _dynamic_table = run_query(_dynamic_table_sql) %}\n\n {% do return({'dynamic_table': _dynamic_table}) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.060197, "supported_languages": null}, "macro.dbt_snowflake.snowflake__refresh_dynamic_table": {"name": "snowflake__refresh_dynamic_table", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/dynamic_table/refresh.sql", "original_file_path": "macros/relations/dynamic_table/refresh.sql", "unique_id": "macro.dbt_snowflake.snowflake__refresh_dynamic_table", "macro_sql": "{% macro snowflake__refresh_dynamic_table(relation) -%}\n {{- log('Applying REFRESH to: ' ~ relation) -}}\n\n alter dynamic table {{ relation }} refresh\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.060315, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_alter_dynamic_table_as_sql": {"name": "snowflake__get_alter_dynamic_table_as_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/dynamic_table/alter.sql", "original_file_path": "macros/relations/dynamic_table/alter.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_alter_dynamic_table_as_sql", "macro_sql": "{% macro snowflake__get_alter_dynamic_table_as_sql(\n existing_relation,\n configuration_changes,\n target_relation,\n sql\n) -%}\n {{- log('Applying ALTER to: ' ~ existing_relation) -}}\n\n {% if configuration_changes.requires_full_refresh %}\n {{- get_replace_sql(existing_relation, target_relation, sql) -}}\n\n {% else %}\n\n {%- set target_lag = configuration_changes.target_lag -%}\n {%- if target_lag -%}{{- log('Applying UPDATE TARGET_LAG to: ' ~ existing_relation) -}}{%- endif -%}\n {%- set snowflake_warehouse = configuration_changes.snowflake_warehouse -%}\n {%- if snowflake_warehouse -%}{{- log('Applying UPDATE WAREHOUSE to: ' ~ existing_relation) -}}{%- endif -%}\n\n alter dynamic table {{ existing_relation }} set\n {% if target_lag %}target_lag = '{{ target_lag.context }}'{% endif %}\n {% if snowflake_warehouse %}warehouse = {{ snowflake_warehouse.context }}{% endif %}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_replace_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.060889, "supported_languages": null}, "macro.dbt_snowflake.snowflake__get_create_dynamic_table_as_sql": {"name": "snowflake__get_create_dynamic_table_as_sql", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/relations/dynamic_table/create.sql", "original_file_path": "macros/relations/dynamic_table/create.sql", "unique_id": "macro.dbt_snowflake.snowflake__get_create_dynamic_table_as_sql", "macro_sql": "{% macro snowflake__get_create_dynamic_table_as_sql(relation, sql) -%}\n\n create dynamic table {{ relation }}\n target_lag = '{{ config.get(\"target_lag\") }}'\n warehouse = {{ config.get(\"snowflake_warehouse\") }}\n as (\n {{ sql }}\n )\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.06107, "supported_languages": null}, "macro.dbt_snowflake.snowflake__current_timestamp": {"name": "snowflake__current_timestamp", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp", "macro_sql": "{% macro snowflake__current_timestamp() -%}\n convert_timezone('UTC', current_timestamp())\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0612428, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_string_as_time": {"name": "snowflake__snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__snapshot_string_as_time", "macro_sql": "{% macro snowflake__snapshot_string_as_time(timestamp) -%}\n {%- set result = \"to_timestamp_ntz('\" ~ timestamp ~ \"')\" -%}\n {{ return(result) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.061343, "supported_languages": null}, "macro.dbt_snowflake.snowflake__snapshot_get_time": {"name": "snowflake__snapshot_get_time", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__snapshot_get_time", "macro_sql": "{% macro snowflake__snapshot_get_time() -%}\n to_timestamp_ntz({{ current_timestamp() }})\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0614028, "supported_languages": null}, "macro.dbt_snowflake.snowflake__current_timestamp_backcompat": {"name": "snowflake__current_timestamp_backcompat", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp_backcompat", "macro_sql": "{% macro snowflake__current_timestamp_backcompat() %}\n current_timestamp::{{ type_timestamp() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.061464, "supported_languages": null}, "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat": {"name": "snowflake__current_timestamp_in_utc_backcompat", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat", "macro_sql": "{% macro snowflake__current_timestamp_in_utc_backcompat() %}\n convert_timezone('UTC', {{ snowflake__current_timestamp_backcompat() }})::{{ type_timestamp() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_backcompat", "macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.061536, "supported_languages": null}, "macro.dbt_snowflake.snowflake__escape_single_quotes": {"name": "snowflake__escape_single_quotes", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "unique_id": "macro.dbt_snowflake.snowflake__escape_single_quotes", "macro_sql": "{% macro snowflake__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\", \"\\\\'\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0616431, "supported_languages": null}, "macro.dbt_snowflake.snowflake__right": {"name": "snowflake__right", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "unique_id": "macro.dbt_snowflake.snowflake__right", "macro_sql": "{% macro snowflake__right(string_text, length_expression) %}\n\n case when {{ length_expression }} = 0\n then ''\n else\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n end\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.06177, "supported_languages": null}, "macro.dbt_snowflake.snowflake__safe_cast": {"name": "snowflake__safe_cast", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "unique_id": "macro.dbt_snowflake.snowflake__safe_cast", "macro_sql": "{% macro snowflake__safe_cast(field, type) %}\n {% if type|upper == \"GEOMETRY\" -%}\n try_to_geometry({{field}})\n {% elif type|upper == \"GEOGRAPHY\" -%}\n try_to_geography({{field}})\n {% elif type|upper != \"VARIANT\" -%}\n {#-- Snowflake try_cast does not support casting to variant, and expects the field as a string --#}\n {% set field_as_string = dbt.string_literal(field) if field is number else field %}\n try_cast({{field_as_string}} as {{type}})\n {% else -%}\n {{ adapter.dispatch('cast', 'dbt')(field, type) }}\n {% endif -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.string_literal", "macro.dbt.cast", "macro.dbt_snowflake.snowflake__cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.062149, "supported_languages": null}, "macro.dbt_snowflake.snowflake__cast": {"name": "snowflake__cast", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/cast.sql", "original_file_path": "macros/utils/cast.sql", "unique_id": "macro.dbt_snowflake.snowflake__cast", "macro_sql": "{% macro snowflake__cast(field, type) %}\n {% if (type|upper == \"GEOGRAPHY\") -%}\n to_geography({{field}})\n {% elif (type|upper == \"GEOMETRY\") -%}\n to_geometry({{field}})\n {% else -%}\n cast({{field}} as {{type}})\n {% endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.062376, "supported_languages": null}, "macro.dbt_snowflake.snowflake__bool_or": {"name": "snowflake__bool_or", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "unique_id": "macro.dbt_snowflake.snowflake__bool_or", "macro_sql": "{% macro snowflake__bool_or(expression) -%}\n\n boolor_agg({{ expression }})\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.062454, "supported_languages": null}, "macro.dbt_snowflake.snowflake__array_construct": {"name": "snowflake__array_construct", "resource_type": "macro", "package_name": "dbt_snowflake", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "unique_id": "macro.dbt_snowflake.snowflake__array_construct", "macro_sql": "{% macro snowflake__array_construct(inputs, data_type) -%}\n array_construct( {{ inputs|join(' , ') }} )\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.062552, "supported_languages": null}, "macro.dbt.run_hooks": {"name": "run_hooks", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.run_hooks", "macro_sql": "{% macro run_hooks(hooks, inside_transaction=True) %}\n {% for hook in hooks | selectattr('transaction', 'equalto', inside_transaction) %}\n {% if not inside_transaction and loop.first %}\n {% call statement(auto_begin=inside_transaction) %}\n commit;\n {% endcall %}\n {% endif %}\n {% set rendered = render(hook.get('sql')) | trim %}\n {% if (rendered | length) > 0 %}\n {% call statement(auto_begin=inside_transaction) %}\n {{ rendered }}\n {% endcall %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.063147, "supported_languages": null}, "macro.dbt.make_hook_config": {"name": "make_hook_config", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.make_hook_config", "macro_sql": "{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({\"sql\": sql, \"transaction\": inside_transaction}) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.063255, "supported_languages": null}, "macro.dbt.before_begin": {"name": "before_begin", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.before_begin", "macro_sql": "{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.063334, "supported_languages": null}, "macro.dbt.in_transaction": {"name": "in_transaction", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.in_transaction", "macro_sql": "{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.063421, "supported_languages": null}, "macro.dbt.after_commit": {"name": "after_commit", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.after_commit", "macro_sql": "{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0635111, "supported_languages": null}, "macro.dbt.set_sql_header": {"name": "set_sql_header", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "unique_id": "macro.dbt.set_sql_header", "macro_sql": "{% macro set_sql_header(config) -%}\n {{ config.set('sql_header', caller()) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0637262, "supported_languages": null}, "macro.dbt.should_full_refresh": {"name": "should_full_refresh", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "unique_id": "macro.dbt.should_full_refresh", "macro_sql": "{% macro should_full_refresh() %}\n {% set config_full_refresh = config.get('full_refresh') %}\n {% if config_full_refresh is none %}\n {% set config_full_refresh = flags.FULL_REFRESH %}\n {% endif %}\n {% do return(config_full_refresh) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.063893, "supported_languages": null}, "macro.dbt.should_store_failures": {"name": "should_store_failures", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "unique_id": "macro.dbt.should_store_failures", "macro_sql": "{% macro should_store_failures() %}\n {% set config_store_failures = config.get('store_failures') %}\n {% if config_store_failures is none %}\n {% set config_store_failures = flags.STORE_FAILURES %}\n {% endif %}\n {% do return(config_store_failures) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.064266, "supported_languages": null}, "macro.dbt.snapshot_merge_sql": {"name": "snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/snapshot_merge.sql", "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", "unique_id": "macro.dbt.snapshot_merge_sql", "macro_sql": "{% macro snapshot_merge_sql(target, source, insert_cols) -%}\n {{ adapter.dispatch('snapshot_merge_sql', 'dbt')(target, source, insert_cols) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.064518, "supported_languages": null}, "macro.dbt.default__snapshot_merge_sql": {"name": "default__snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/snapshot_merge.sql", "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", "unique_id": "macro.dbt.default__snapshot_merge_sql", "macro_sql": "{% macro default__snapshot_merge_sql(target, source, insert_cols) -%}\n {%- set insert_cols_csv = insert_cols | join(', ') -%}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id\n\n when matched\n and DBT_INTERNAL_DEST.dbt_valid_to is null\n and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')\n then update\n set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to\n\n when not matched\n and DBT_INTERNAL_SOURCE.dbt_change_type = 'insert'\n then insert ({{ insert_cols_csv }})\n values ({{ insert_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.064676, "supported_languages": null}, "macro.dbt.strategy_dispatch": {"name": "strategy_dispatch", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.strategy_dispatch", "macro_sql": "{% macro strategy_dispatch(name) -%}\n{% set original_name = name %}\n {% if '.' in name %}\n {% set package_name, name = name.split(\".\", 1) %}\n {% else %}\n {% set package_name = none %}\n {% endif %}\n\n {% if package_name is none %}\n {% set package_context = context %}\n {% elif package_name in context %}\n {% set package_context = context[package_name] %}\n {% else %}\n {% set error_msg %}\n Could not find package '{{package_name}}', called with '{{original_name}}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n\n {%- set search_name = 'snapshot_' ~ name ~ '_strategy' -%}\n\n {% if search_name not in package_context %}\n {% set error_msg %}\n The specified strategy macro '{{name}}' was not found in package '{{ package_name }}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n {{ return(package_context[search_name]) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0666418, "supported_languages": null}, "macro.dbt.snapshot_hash_arguments": {"name": "snapshot_hash_arguments", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_hash_arguments", "macro_sql": "{% macro snapshot_hash_arguments(args) -%}\n {{ adapter.dispatch('snapshot_hash_arguments', 'dbt')(args) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.066738, "supported_languages": null}, "macro.dbt.default__snapshot_hash_arguments": {"name": "default__snapshot_hash_arguments", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.default__snapshot_hash_arguments", "macro_sql": "{% macro default__snapshot_hash_arguments(args) -%}\n md5({%- for arg in args -%}\n coalesce(cast({{ arg }} as varchar ), '')\n {% if not loop.last %} || '|' || {% endif %}\n {%- endfor -%})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.066862, "supported_languages": null}, "macro.dbt.snapshot_timestamp_strategy": {"name": "snapshot_timestamp_strategy", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_timestamp_strategy", "macro_sql": "{% macro snapshot_timestamp_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set primary_key = config['unique_key'] %}\n {% set updated_at = config['updated_at'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n\n {#/*\n The snapshot relation might not have an {{ updated_at }} value if the\n snapshot strategy is changed from `check` to `timestamp`. We\n should use a dbt-created column for the comparison in the snapshot\n table instead of assuming that the user-supplied {{ updated_at }}\n will be present in the historical data.\n\n See https://github.com/dbt-labs/dbt-core/issues/2350\n */ #}\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.dbt_valid_from < {{ current_rel }}.{{ updated_at }})\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.067242, "supported_languages": null}, "macro.dbt.snapshot_string_as_time": {"name": "snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_string_as_time", "macro_sql": "{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter.dispatch('snapshot_string_as_time', 'dbt')(timestamp) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_string_as_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.067332, "supported_languages": null}, "macro.dbt.default__snapshot_string_as_time": {"name": "default__snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.default__snapshot_string_as_time", "macro_sql": "{% macro default__snapshot_string_as_time(timestamp) %}\n {% do exceptions.raise_not_implemented(\n 'snapshot_string_as_time macro not implemented for adapter '+adapter.type()\n ) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.067426, "supported_languages": null}, "macro.dbt.snapshot_check_all_get_existing_columns": {"name": "snapshot_check_all_get_existing_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_check_all_get_existing_columns", "macro_sql": "{% macro snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) -%}\n {%- if not target_exists -%}\n {#-- no table yet -> return whatever the query does --#}\n {{ return((false, query_columns)) }}\n {%- endif -%}\n\n {#-- handle any schema changes --#}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=node.alias) -%}\n\n {% if check_cols_config == 'all' %}\n {%- set query_columns = get_columns_in_query(node['compiled_code']) -%}\n\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {#-- query for proper casing/quoting, to support comparison below --#}\n {%- set select_check_cols_from_target -%}\n {#-- N.B. The whitespace below is necessary to avoid edge case issue with comments --#}\n {#-- See: https://github.com/dbt-labs/dbt-core/issues/6781 --#}\n select {{ check_cols_config | join(', ') }} from (\n {{ node['compiled_code'] }}\n ) subq\n {%- endset -%}\n {% set query_columns = get_columns_in_query(select_check_cols_from_target) %}\n\n {% else %}\n {% do exceptions.raise_compiler_error(\"Invalid value for 'check_cols': \" ~ check_cols_config) %}\n {% endif %}\n\n {%- set existing_cols = adapter.get_columns_in_relation(target_relation) | map(attribute = 'name') | list -%}\n {%- set ns = namespace() -%} {#-- handle for-loop scoping with a namespace --#}\n {%- set ns.column_added = false -%}\n\n {%- set intersection = [] -%}\n {%- for col in query_columns -%}\n {%- if col in existing_cols -%}\n {%- do intersection.append(adapter.quote(col)) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return((ns.column_added, intersection)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_columns_in_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.06816, "supported_languages": null}, "macro.dbt.snapshot_check_strategy": {"name": "snapshot_check_strategy", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_check_strategy", "macro_sql": "{% macro snapshot_check_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set check_cols_config = config['check_cols'] %}\n {% set primary_key = config['unique_key'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n {% set updated_at = config.get('updated_at', snapshot_get_time()) %}\n\n {% set column_added = false %}\n\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n {{ get_true_sql() }}\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n (\n (({{ snapshotted_rel }}.{{ col }} is null) and not ({{ current_rel }}.{{ col }} is null))\n or\n ((not {{ snapshotted_rel }}.{{ col }} is null) and ({{ current_rel }}.{{ col }} is null))\n )\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n {%- endif -%}\n )\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_get_time", "macro.dbt.snapshot_check_all_get_existing_columns", "macro.dbt.get_true_sql", "macro.dbt.snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0688288, "supported_languages": null}, "macro.dbt.create_columns": {"name": "create_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.create_columns", "macro_sql": "{% macro create_columns(relation, columns) %}\n {{ adapter.dispatch('create_columns', 'dbt')(relation, columns) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.071084, "supported_languages": null}, "macro.dbt.default__create_columns": {"name": "default__create_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__create_columns", "macro_sql": "{% macro default__create_columns(relation, columns) %}\n {% for column in columns %}\n {% call statement() %}\n alter table {{ relation }} add column \"{{ column.name }}\" {{ column.data_type }};\n {% endcall %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.071237, "supported_languages": null}, "macro.dbt.post_snapshot": {"name": "post_snapshot", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.post_snapshot", "macro_sql": "{% macro post_snapshot(staging_relation) %}\n {{ adapter.dispatch('post_snapshot', 'dbt')(staging_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__post_snapshot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.071327, "supported_languages": null}, "macro.dbt.default__post_snapshot": {"name": "default__post_snapshot", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__post_snapshot", "macro_sql": "{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.071378, "supported_languages": null}, "macro.dbt.get_true_sql": {"name": "get_true_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.get_true_sql", "macro_sql": "{% macro get_true_sql() %}\n {{ adapter.dispatch('get_true_sql', 'dbt')() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_true_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0714612, "supported_languages": null}, "macro.dbt.default__get_true_sql": {"name": "default__get_true_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__get_true_sql", "macro_sql": "{% macro default__get_true_sql() %}\n {{ return('TRUE') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0715241, "supported_languages": null}, "macro.dbt.snapshot_staging_table": {"name": "snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.snapshot_staging_table", "macro_sql": "{% macro snapshot_staging_table(strategy, source_sql, target_relation) -%}\n {{ adapter.dispatch('snapshot_staging_table', 'dbt')(strategy, source_sql, target_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__snapshot_staging_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0716338, "supported_languages": null}, "macro.dbt.default__snapshot_staging_table": {"name": "default__snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__snapshot_staging_table", "macro_sql": "{% macro default__snapshot_staging_table(strategy, source_sql, target_relation) -%}\n\n with snapshot_query as (\n\n {{ source_sql }}\n\n ),\n\n snapshotted_data as (\n\n select *,\n {{ strategy.unique_key }} as dbt_unique_key\n\n from {{ target_relation }}\n where dbt_valid_to is null\n\n ),\n\n insertions_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to,\n {{ strategy.scd_id }} as dbt_scd_id\n\n from snapshot_query\n ),\n\n updates_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n {{ strategy.updated_at }} as dbt_valid_to\n\n from snapshot_query\n ),\n\n {%- if strategy.invalidate_hard_deletes %}\n\n deletes_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key\n from snapshot_query\n ),\n {% endif %}\n\n insertions as (\n\n select\n 'insert' as dbt_change_type,\n source_data.*\n\n from insertions_source_data as source_data\n left outer join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_unique_key is null\n or (\n snapshotted_data.dbt_unique_key is not null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n ),\n\n updates as (\n\n select\n 'update' as dbt_change_type,\n source_data.*,\n snapshotted_data.dbt_scd_id\n\n from updates_source_data as source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where (\n {{ strategy.row_changed }}\n )\n )\n\n {%- if strategy.invalidate_hard_deletes -%}\n ,\n\n deletes as (\n\n select\n 'delete' as dbt_change_type,\n source_data.*,\n {{ snapshot_get_time() }} as dbt_valid_from,\n {{ snapshot_get_time() }} as dbt_updated_at,\n {{ snapshot_get_time() }} as dbt_valid_to,\n snapshotted_data.dbt_scd_id\n\n from snapshotted_data\n left join deletes_source_data as source_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where source_data.dbt_unique_key is null\n )\n {%- endif %}\n\n select * from insertions\n union all\n select * from updates\n {%- if strategy.invalidate_hard_deletes %}\n union all\n select * from deletes\n {%- endif %}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_get_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.072139, "supported_languages": null}, "macro.dbt.build_snapshot_table": {"name": "build_snapshot_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.build_snapshot_table", "macro_sql": "{% macro build_snapshot_table(strategy, sql) -%}\n {{ adapter.dispatch('build_snapshot_table', 'dbt')(strategy, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__build_snapshot_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.072248, "supported_languages": null}, "macro.dbt.default__build_snapshot_table": {"name": "default__build_snapshot_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__build_snapshot_table", "macro_sql": "{% macro default__build_snapshot_table(strategy, sql) %}\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to\n from (\n {{ sql }}\n ) sbq\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.072386, "supported_languages": null}, "macro.dbt.build_snapshot_staging_table": {"name": "build_snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.build_snapshot_staging_table", "macro_sql": "{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set temp_relation = make_temp_relation(target_relation) %}\n\n {% set select = snapshot_staging_table(strategy, sql, target_relation) %}\n\n {% call statement('build_snapshot_staging_relation') %}\n {{ create_table_as(True, temp_relation, select) }}\n {% endcall %}\n\n {% do return(temp_relation) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_temp_relation", "macro.dbt.snapshot_staging_table", "macro.dbt.statement", "macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0726058, "supported_languages": null}, "macro.dbt.materialization_snapshot_default": {"name": "materialization_snapshot_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/snapshot.sql", "original_file_path": "macros/materializations/snapshots/snapshot.sql", "unique_id": "macro.dbt.materialization_snapshot_default", "macro_sql": "{% materialization snapshot, default %}\n {%- set config = model['config'] -%}\n\n {%- set target_table = model.get('alias', model.get('name')) -%}\n\n {%- set strategy_name = config.get('strategy') -%}\n {%- set unique_key = config.get('unique_key') %}\n -- grab current tables grants config for comparision later on\n {%- set grant_config = config.get('grants') -%}\n\n {% set target_relation_exists, target_relation = get_or_create_relation(\n database=model.database,\n schema=model.schema,\n identifier=target_table,\n type='table') -%}\n\n {%- if not target_relation.is_table -%}\n {% do exceptions.relation_wrong_type(target_relation, 'table') %}\n {%- endif -%}\n\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set strategy_macro = strategy_dispatch(strategy_name) %}\n {% set strategy = strategy_macro(model, \"snapshotted_data\", \"source_data\", config, target_relation_exists) %}\n\n {% if not target_relation_exists %}\n\n {% set build_sql = build_snapshot_table(strategy, model['compiled_code']) %}\n {% set final_sql = create_table_as(False, target_relation, build_sql) %}\n\n {% else %}\n\n {{ adapter.valid_snapshot_target(target_relation) }}\n\n {% set staging_table = build_snapshot_staging_table(strategy, sql, target_relation) %}\n\n -- this may no-op if the database does not require column expansion\n {% do adapter.expand_target_column_types(from_relation=staging_table,\n to_relation=target_relation) %}\n\n {% set missing_columns = adapter.get_missing_columns(staging_table, target_relation)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% do create_columns(target_relation, missing_columns) %}\n\n {% set source_columns = adapter.get_columns_in_relation(staging_table)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% set quoted_source_columns = [] %}\n {% for column in source_columns %}\n {% do quoted_source_columns.append(adapter.quote(column.name)) %}\n {% endfor %}\n\n {% set final_sql = snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n %}\n\n {% endif %}\n\n {% call statement('main') %}\n {{ final_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(target_relation_exists, full_refresh_mode=False) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if not target_relation_exists %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if staging_table is defined %}\n {% do post_snapshot(staging_table) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.get_or_create_relation", "macro.dbt.run_hooks", "macro.dbt.strategy_dispatch", "macro.dbt.build_snapshot_table", "macro.dbt.create_table_as", "macro.dbt.build_snapshot_staging_table", "macro.dbt.create_columns", "macro.dbt.snapshot_merge_sql", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes", "macro.dbt.post_snapshot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0757709, "supported_languages": ["sql"]}, "macro.dbt.materialization_test_default": {"name": "materialization_test_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/test.sql", "original_file_path": "macros/materializations/tests/test.sql", "unique_id": "macro.dbt.materialization_test_default", "macro_sql": "{%- materialization test, default -%}\n\n {% set relations = [] %}\n\n {% if should_store_failures() %}\n\n {% set identifier = model['alias'] %}\n {% set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% set store_failures_as = config.get('store_failures_as') %}\n -- if `--store-failures` is invoked via command line and `store_failures_as` is not set,\n -- config.get('store_failures_as', 'table') returns None, not 'table'\n {% if store_failures_as == none %}{% set store_failures_as = 'table' %}{% endif %}\n {% if store_failures_as not in ['table', 'view'] %}\n {{ exceptions.raise_compiler_error(\n \"'\" ~ store_failures_as ~ \"' is not a valid value for `store_failures_as`. \"\n \"Accepted values are: ['ephemeral', 'table', 'view']\"\n ) }}\n {% endif %}\n\n {% set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database, type=store_failures_as) -%} %}\n\n {% if old_relation %}\n {% do adapter.drop_relation(old_relation) %}\n {% endif %}\n\n {% call statement(auto_begin=True) %}\n {{ get_create_sql(target_relation, sql) }}\n {% endcall %}\n\n {% do relations.append(target_relation) %}\n\n {% set main_sql %}\n select *\n from {{ target_relation }}\n {% endset %}\n\n {{ adapter.commit() }}\n\n {% else %}\n\n {% set main_sql = sql %}\n\n {% endif %}\n\n {% set limit = config.get('limit') %}\n {% set fail_calc = config.get('fail_calc') %}\n {% set warn_if = config.get('warn_if') %}\n {% set error_if = config.get('error_if') %}\n\n {% call statement('main', fetch_result=True) -%}\n\n {{ get_test_sql(main_sql, fail_calc, warn_if, error_if, limit)}}\n\n {%- endcall %}\n\n {{ return({'relations': relations}) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.should_store_failures", "macro.dbt.statement", "macro.dbt.get_create_sql", "macro.dbt.get_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.077235, "supported_languages": ["sql"]}, "macro.dbt.get_test_sql": {"name": "get_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "unique_id": "macro.dbt.get_test_sql", "macro_sql": "{% macro get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n {{ adapter.dispatch('get_test_sql', 'dbt')(main_sql, fail_calc, warn_if, error_if, limit) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.077898, "supported_languages": null}, "macro.dbt.default__get_test_sql": {"name": "default__get_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "unique_id": "macro.dbt.default__get_test_sql", "macro_sql": "{% macro default__get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n select\n {{ fail_calc }} as failures,\n {{ fail_calc }} {{ warn_if }} as should_warn,\n {{ fail_calc }} {{ error_if }} as should_error\n from (\n {{ main_sql }}\n {{ \"limit \" ~ limit if limit != none }}\n ) dbt_internal_test\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0780602, "supported_languages": null}, "macro.dbt.get_unit_test_sql": {"name": "get_unit_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "unique_id": "macro.dbt.get_unit_test_sql", "macro_sql": "{% macro get_unit_test_sql(main_sql, expected_fixture_sql, expected_column_names) -%}\n {{ adapter.dispatch('get_unit_test_sql', 'dbt')(main_sql, expected_fixture_sql, expected_column_names) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_unit_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.078175, "supported_languages": null}, "macro.dbt.default__get_unit_test_sql": {"name": "default__get_unit_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "unique_id": "macro.dbt.default__get_unit_test_sql", "macro_sql": "{% macro default__get_unit_test_sql(main_sql, expected_fixture_sql, expected_column_names) -%}\n-- Build actual result given inputs\nwith dbt_internal_unit_test_actual as (\n select\n {% for expected_column_name in expected_column_names %}{{expected_column_name}}{% if not loop.last -%},{% endif %}{%- endfor -%}, {{ dbt.string_literal(\"actual\") }} as {{ adapter.quote(\"actual_or_expected\") }}\n from (\n {{ main_sql }}\n ) _dbt_internal_unit_test_actual\n),\n-- Build expected result\ndbt_internal_unit_test_expected as (\n select\n {% for expected_column_name in expected_column_names %}{{expected_column_name}}{% if not loop.last -%}, {% endif %}{%- endfor -%}, {{ dbt.string_literal(\"expected\") }} as {{ adapter.quote(\"actual_or_expected\") }}\n from (\n {{ expected_fixture_sql }}\n ) _dbt_internal_unit_test_expected\n)\n-- Union actual and expected results\nselect * from dbt_internal_unit_test_actual\nunion all\nselect * from dbt_internal_unit_test_expected\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.string_literal"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.078499, "supported_languages": null}, "macro.dbt.get_where_subquery": {"name": "get_where_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/where_subquery.sql", "original_file_path": "macros/materializations/tests/where_subquery.sql", "unique_id": "macro.dbt.get_where_subquery", "macro_sql": "{% macro get_where_subquery(relation) -%}\n {% do return(adapter.dispatch('get_where_subquery', 'dbt')(relation)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_where_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.078711, "supported_languages": null}, "macro.dbt.default__get_where_subquery": {"name": "default__get_where_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/where_subquery.sql", "original_file_path": "macros/materializations/tests/where_subquery.sql", "unique_id": "macro.dbt.default__get_where_subquery", "macro_sql": "{% macro default__get_where_subquery(relation) -%}\n {% set where = config.get('where', '') %}\n {% if where %}\n {%- set filtered -%}\n (select * from {{ relation }} where {{ where }}) dbt_subquery\n {%- endset -%}\n {% do return(filtered) %}\n {%- else -%}\n {% do return(relation) %}\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.078915, "supported_languages": null}, "macro.dbt.materialization_unit_default": {"name": "materialization_unit_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/unit.sql", "original_file_path": "macros/materializations/tests/unit.sql", "unique_id": "macro.dbt.materialization_unit_default", "macro_sql": "{%- materialization unit, default -%}\n\n {% set relations = [] %}\n\n {% set expected_rows = config.get('expected_rows') %}\n {% set expected_sql = config.get('expected_sql') %}\n {% set tested_expected_column_names = expected_rows[0].keys() if (expected_rows | length ) > 0 else get_columns_in_query(sql) %} %}\n\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set temp_relation = make_temp_relation(target_relation)-%}\n {% do run_query(get_create_table_as_sql(True, temp_relation, get_empty_subquery_sql(sql))) %}\n {%- set columns_in_relation = adapter.get_columns_in_relation(temp_relation) -%}\n {%- set column_name_to_data_types = {} -%}\n {%- for column in columns_in_relation -%}\n {%- do column_name_to_data_types.update({column.name|lower: column.data_type}) -%}\n {%- endfor -%}\n\n {% if not expected_sql %}\n {% set expected_sql = get_expected_sql(expected_rows, column_name_to_data_types) %}\n {% endif %}\n {% set unit_test_sql = get_unit_test_sql(sql, expected_sql, tested_expected_column_names) %}\n\n {% call statement('main', fetch_result=True) -%}\n\n {{ unit_test_sql }}\n\n {%- endcall %}\n\n {% do adapter.drop_relation(temp_relation) %}\n\n {{ return({'relations': relations}) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.get_columns_in_query", "macro.dbt.make_temp_relation", "macro.dbt.run_query", "macro.dbt.get_create_table_as_sql", "macro.dbt.get_empty_subquery_sql", "macro.dbt.get_expected_sql", "macro.dbt.get_unit_test_sql", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.079862, "supported_languages": ["sql"]}, "macro.dbt.materialization_materialized_view_default": {"name": "materialization_materialized_view_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialization_materialized_view_default", "macro_sql": "{% materialization materialized_view, default %}\n {% set existing_relation = load_cached_relation(this) %}\n {% set target_relation = this.incorporate(type=this.MaterializedView) %}\n {% set intermediate_relation = make_intermediate_relation(target_relation) %}\n {% set backup_relation_type = target_relation.MaterializedView if existing_relation is none else existing_relation.type %}\n {% set backup_relation = make_backup_relation(target_relation, backup_relation_type) %}\n\n {{ materialized_view_setup(backup_relation, intermediate_relation, pre_hooks) }}\n\n {% set build_sql = materialized_view_get_build_sql(existing_relation, target_relation, backup_relation, intermediate_relation) %}\n\n {% if build_sql == '' %}\n {{ materialized_view_execute_no_op(target_relation) }}\n {% else %}\n {{ materialized_view_execute_build_sql(build_sql, existing_relation, target_relation, post_hooks) }}\n {% endif %}\n\n {{ materialized_view_teardown(backup_relation, intermediate_relation, post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.materialized_view_setup", "macro.dbt.materialized_view_get_build_sql", "macro.dbt.materialized_view_execute_no_op", "macro.dbt.materialized_view_execute_build_sql", "macro.dbt.materialized_view_teardown"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.082628, "supported_languages": ["sql"]}, "macro.dbt.materialized_view_setup": {"name": "materialized_view_setup", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_setup", "macro_sql": "{% macro materialized_view_setup(backup_relation, intermediate_relation, pre_hooks) %}\n\n -- backup_relation and intermediate_relation should not already exist in the database\n -- it's possible these exist because of a previous run that exited unexpectedly\n {% set preexisting_backup_relation = load_cached_relation(backup_relation) %}\n {% set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.082839, "supported_languages": null}, "macro.dbt.materialized_view_teardown": {"name": "materialized_view_teardown", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_teardown", "macro_sql": "{% macro materialized_view_teardown(backup_relation, intermediate_relation, post_hooks) %}\n\n -- drop the temp relations if they exist to leave the database clean for the next run\n {{ drop_relation_if_exists(backup_relation) }}\n {{ drop_relation_if_exists(intermediate_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.082973, "supported_languages": null}, "macro.dbt.materialized_view_get_build_sql": {"name": "materialized_view_get_build_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_get_build_sql", "macro_sql": "{% macro materialized_view_get_build_sql(existing_relation, target_relation, backup_relation, intermediate_relation) %}\n\n {% set full_refresh_mode = should_full_refresh() %}\n\n -- determine the scenario we're in: create, full_refresh, alter, refresh data\n {% if existing_relation is none %}\n {% set build_sql = get_create_materialized_view_as_sql(target_relation, sql) %}\n {% elif full_refresh_mode or not existing_relation.is_materialized_view %}\n {% set build_sql = get_replace_sql(existing_relation, target_relation, sql) %}\n {% else %}\n\n -- get config options\n {% set on_configuration_change = config.get('on_configuration_change') %}\n {% set configuration_changes = get_materialized_view_configuration_changes(existing_relation, config) %}\n\n {% if configuration_changes is none %}\n {% set build_sql = refresh_materialized_view(target_relation) %}\n\n {% elif on_configuration_change == 'apply' %}\n {% set build_sql = get_alter_materialized_view_as_sql(target_relation, configuration_changes, sql, existing_relation, backup_relation, intermediate_relation) %}\n {% elif on_configuration_change == 'continue' %}\n {% set build_sql = '' %}\n {{ exceptions.warn(\"Configuration changes were identified and `on_configuration_change` was set to `continue` for `\" ~ target_relation ~ \"`\") }}\n {% elif on_configuration_change == 'fail' %}\n {{ exceptions.raise_fail_fast_error(\"Configuration changes were identified and `on_configuration_change` was set to `fail` for `\" ~ target_relation ~ \"`\") }}\n\n {% else %}\n -- this only happens if the user provides a value other than `apply`, 'skip', 'fail'\n {{ exceptions.raise_compiler_error(\"Unexpected configuration scenario\") }}\n\n {% endif %}\n\n {% endif %}\n\n {% do return(build_sql) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.get_create_materialized_view_as_sql", "macro.dbt.get_replace_sql", "macro.dbt.get_materialized_view_configuration_changes", "macro.dbt.refresh_materialized_view", "macro.dbt.get_alter_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.083641, "supported_languages": null}, "macro.dbt.materialized_view_execute_no_op": {"name": "materialized_view_execute_no_op", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_execute_no_op", "macro_sql": "{% macro materialized_view_execute_no_op(target_relation) %}\n {% do store_raw_result(\n name=\"main\",\n message=\"skip \" ~ target_relation,\n code=\"skip\",\n rows_affected=\"-1\"\n ) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0837681, "supported_languages": null}, "macro.dbt.materialized_view_execute_build_sql": {"name": "materialized_view_execute_build_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_execute_build_sql", "macro_sql": "{% macro materialized_view_execute_build_sql(build_sql, existing_relation, target_relation, post_hooks) %}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set grant_config = config.get('grants') %}\n\n {% call statement(name=\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.084115, "supported_languages": null}, "macro.dbt.materialization_view_default": {"name": "materialization_view_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/view.sql", "original_file_path": "macros/materializations/models/view.sql", "unique_id": "macro.dbt.materialization_view_default", "macro_sql": "{%- materialization view, default -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='view') -%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n This relation (probably) doesn't exist yet. If it does exist, it's a leftover from\n a previous run, and we're going to try to drop it immediately. At the end of this\n materialization, we're going to rename the \"existing_relation\" to this identifier,\n and then we're going to drop it. In order to make sure we run the correct one of:\n - drop view ...\n - drop table ...\n\n We need to set the type of this relation to be the type of the existing_relation, if it exists,\n or else \"view\" as a sane default if it does not. Note that if the existing_relation does not\n exist, then there is nothing to move out of the way and subsequentally drop. In that case,\n this relation will be effectively unused.\n */\n {%- set backup_relation_type = 'view' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n -- move the existing view out of the way\n {% if existing_relation is not none %}\n /* Do the equivalent of rename_if_exists. 'existing_relation' could have been dropped\n since the variable was first set. */\n {% set existing_relation = load_cached_relation(existing_relation) %}\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {% endif %}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.085681, "supported_languages": ["sql"]}, "macro.dbt.materialization_table_default": {"name": "materialization_table_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/table.sql", "original_file_path": "macros/materializations/models/table.sql", "unique_id": "macro.dbt.materialization_table_default", "macro_sql": "{% materialization table, default %}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n See ../view/view.sql for more information about this relation.\n */\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n {% if existing_relation is not none %}\n /* Do the equivalent of rename_if_exists. 'existing_relation' could have been dropped\n since the variable was first set. */\n {% set existing_relation = load_cached_relation(existing_relation) %}\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {% endif %}\n\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% do create_indexes(target_relation) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n -- finally, drop the existing/backup relation after the commit\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt.create_indexes", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.08724, "supported_languages": ["sql"]}, "macro.dbt.get_quoted_csv": {"name": "get_quoted_csv", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.get_quoted_csv", "macro_sql": "{% macro get_quoted_csv(column_names) %}\n\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote(col)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0881631, "supported_languages": null}, "macro.dbt.diff_columns": {"name": "diff_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.diff_columns", "macro_sql": "{% macro diff_columns(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% set source_names = source_columns | map(attribute = 'column') | list %}\n {% set target_names = target_columns | map(attribute = 'column') | list %}\n\n {# --check whether the name attribute exists in the target - this does not perform a data type check #}\n {% for sc in source_columns %}\n {% if sc.name not in target_names %}\n {{ result.append(sc) }}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.088471, "supported_languages": null}, "macro.dbt.diff_column_data_types": {"name": "diff_column_data_types", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.diff_column_data_types", "macro_sql": "{% macro diff_column_data_types(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% for sc in source_columns %}\n {% set tc = target_columns | selectattr(\"name\", \"equalto\", sc.name) | list | first %}\n {% if tc %}\n {% if sc.data_type != tc.data_type and not sc.can_expand_to(other_column=tc) %}\n {{ result.append( { 'column_name': tc.name, 'new_type': sc.data_type } ) }}\n {% endif %}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.088814, "supported_languages": null}, "macro.dbt.get_merge_update_columns": {"name": "get_merge_update_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.get_merge_update_columns", "macro_sql": "{% macro get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {{ return(adapter.dispatch('get_merge_update_columns', 'dbt')(merge_update_columns, merge_exclude_columns, dest_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_merge_update_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0889459, "supported_languages": null}, "macro.dbt.default__get_merge_update_columns": {"name": "default__get_merge_update_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.default__get_merge_update_columns", "macro_sql": "{% macro default__get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {%- set default_cols = dest_columns | map(attribute=\"quoted\") | list -%}\n\n {%- if merge_update_columns and merge_exclude_columns -%}\n {{ exceptions.raise_compiler_error(\n 'Model cannot specify merge_update_columns and merge_exclude_columns. Please update model to use only one config'\n )}}\n {%- elif merge_update_columns -%}\n {%- set update_columns = merge_update_columns -%}\n {%- elif merge_exclude_columns -%}\n {%- set update_columns = [] -%}\n {%- for column in dest_columns -%}\n {% if column.column | lower not in merge_exclude_columns | map(\"lower\") | list %}\n {%- do update_columns.append(column.quoted) -%}\n {% endif %}\n {%- endfor -%}\n {%- else -%}\n {%- set update_columns = default_cols -%}\n {%- endif -%}\n\n {{ return(update_columns) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0893261, "supported_languages": null}, "macro.dbt.get_merge_sql": {"name": "get_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.get_merge_sql", "macro_sql": "{% macro get_merge_sql(target, source, unique_key, dest_columns, incremental_predicates=none) -%}\n -- back compat for old kwarg name\n {% set incremental_predicates = kwargs.get('predicates', incremental_predicates) %}\n {{ adapter.dispatch('get_merge_sql', 'dbt')(target, source, unique_key, dest_columns, incremental_predicates) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0926, "supported_languages": null}, "macro.dbt.default__get_merge_sql": {"name": "default__get_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.default__get_merge_sql", "macro_sql": "{% macro default__get_merge_sql(target, source, unique_key, dest_columns, incremental_predicates=none) -%}\n {%- set predicates = [] if incremental_predicates is none else [] + incremental_predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set merge_update_columns = config.get('merge_update_columns') -%}\n {%- set merge_exclude_columns = config.get('merge_exclude_columns') -%}\n {%- set update_columns = get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not mapping and unique_key is not string %}\n {% for key in unique_key %}\n {% set this_key_match %}\n DBT_INTERNAL_SOURCE.{{ key }} = DBT_INTERNAL_DEST.{{ key }}\n {% endset %}\n {% do predicates.append(this_key_match) %}\n {% endfor %}\n {% else %}\n {% set unique_key_match %}\n DBT_INTERNAL_SOURCE.{{ unique_key }} = DBT_INTERNAL_DEST.{{ unique_key }}\n {% endset %}\n {% do predicates.append(unique_key_match) %}\n {% endif %}\n {% else %}\n {% do predicates.append('FALSE') %}\n {% endif %}\n\n {{ sql_header if sql_header is not none }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on {{\"(\" ~ predicates | join(\") and (\") ~ \")\"}}\n\n {% if unique_key %}\n when matched then update set\n {% for column_name in update_columns -%}\n {{ column_name }} = DBT_INTERNAL_SOURCE.{{ column_name }}\n {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n {% endif %}\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv", "macro.dbt.get_merge_update_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0934882, "supported_languages": null}, "macro.dbt.get_delete_insert_merge_sql": {"name": "get_delete_insert_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.get_delete_insert_merge_sql", "macro_sql": "{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) -%}\n {{ adapter.dispatch('get_delete_insert_merge_sql', 'dbt')(target, source, unique_key, dest_columns, incremental_predicates) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.093633, "supported_languages": null}, "macro.dbt.default__get_delete_insert_merge_sql": {"name": "default__get_delete_insert_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.default__get_delete_insert_merge_sql", "macro_sql": "{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) -%}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not string %}\n delete from {{target }}\n using {{ source }}\n where (\n {% for key in unique_key %}\n {{ source }}.{{ key }} = {{ target }}.{{ key }}\n {{ \"and \" if not loop.last}}\n {% endfor %}\n {% if incremental_predicates %}\n {% for predicate in incremental_predicates %}\n and {{ predicate }}\n {% endfor %}\n {% endif %}\n );\n {% else %}\n delete from {{ target }}\n where (\n {{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n )\n {%- if incremental_predicates %}\n {% for predicate in incremental_predicates %}\n and {{ predicate }}\n {% endfor %}\n {%- endif -%};\n\n {% endif %}\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n )\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.094162, "supported_languages": null}, "macro.dbt.get_insert_overwrite_merge_sql": {"name": "get_insert_overwrite_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.get_insert_overwrite_merge_sql", "macro_sql": "{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header=false) -%}\n {{ adapter.dispatch('get_insert_overwrite_merge_sql', 'dbt')(target, source, dest_columns, predicates, include_sql_header) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_insert_overwrite_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0943098, "supported_languages": null}, "macro.dbt.default__get_insert_overwrite_merge_sql": {"name": "default__get_insert_overwrite_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.default__get_insert_overwrite_merge_sql", "macro_sql": "{% macro default__get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header) -%}\n {#-- The only time include_sql_header is True: --#}\n {#-- BigQuery + insert_overwrite strategy + \"static\" partitions config --#}\n {#-- We should consider including the sql header at the materialization level instead --#}\n\n {%- set predicates = [] if predicates is none else [] + predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none and include_sql_header }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on FALSE\n\n when not matched by source\n {% if predicates %} and {{ predicates | join(' and ') }} {% endif %}\n then delete\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.094653, "supported_languages": null}, "macro.dbt.is_incremental": {"name": "is_incremental", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/is_incremental.sql", "original_file_path": "macros/materializations/models/incremental/is_incremental.sql", "unique_id": "macro.dbt.is_incremental", "macro_sql": "{% macro is_incremental() %}\n {#-- do not run introspective queries in parsing #}\n {% if not execute %}\n {{ return(False) }}\n {% else %}\n {% set relation = adapter.get_relation(this.database, this.schema, this.table) %}\n {{ return(relation is not none\n and relation.type == 'table'\n and model.config.materialized == 'incremental'\n and not should_full_refresh()) }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.094984, "supported_languages": null}, "macro.dbt.get_incremental_append_sql": {"name": "get_incremental_append_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_append_sql", "macro_sql": "{% macro get_incremental_append_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_append_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_incremental_append_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.095503, "supported_languages": null}, "macro.dbt.default__get_incremental_append_sql": {"name": "default__get_incremental_append_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_append_sql", "macro_sql": "{% macro default__get_incremental_append_sql(arg_dict) %}\n\n {% do return(get_insert_into_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_insert_into_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.095629, "supported_languages": null}, "macro.dbt.get_incremental_delete_insert_sql": {"name": "get_incremental_delete_insert_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_delete_insert_sql", "macro_sql": "{% macro get_incremental_delete_insert_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_delete_insert_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_delete_insert_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0957282, "supported_languages": null}, "macro.dbt.default__get_incremental_delete_insert_sql": {"name": "default__get_incremental_delete_insert_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_delete_insert_sql", "macro_sql": "{% macro default__get_incremental_delete_insert_sql(arg_dict) %}\n\n {% do return(get_delete_insert_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_delete_insert_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.095882, "supported_languages": null}, "macro.dbt.get_incremental_merge_sql": {"name": "get_incremental_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_merge_sql", "macro_sql": "{% macro get_incremental_merge_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_merge_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.095985, "supported_languages": null}, "macro.dbt.default__get_incremental_merge_sql": {"name": "default__get_incremental_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_merge_sql", "macro_sql": "{% macro default__get_incremental_merge_sql(arg_dict) %}\n\n {% do return(get_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.096145, "supported_languages": null}, "macro.dbt.get_incremental_insert_overwrite_sql": {"name": "get_incremental_insert_overwrite_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_insert_overwrite_sql", "macro_sql": "{% macro get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_insert_overwrite_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_insert_overwrite_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0962439, "supported_languages": null}, "macro.dbt.default__get_incremental_insert_overwrite_sql": {"name": "default__get_incremental_insert_overwrite_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_insert_overwrite_sql", "macro_sql": "{% macro default__get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {% do return(get_insert_overwrite_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_insert_overwrite_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.096381, "supported_languages": null}, "macro.dbt.get_incremental_default_sql": {"name": "get_incremental_default_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_default_sql", "macro_sql": "{% macro get_incremental_default_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_default_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_incremental_default_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0964842, "supported_languages": null}, "macro.dbt.default__get_incremental_default_sql": {"name": "default__get_incremental_default_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_default_sql", "macro_sql": "{% macro default__get_incremental_default_sql(arg_dict) %}\n\n {% do return(get_incremental_append_sql(arg_dict)) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_incremental_append_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0965672, "supported_languages": null}, "macro.dbt.get_insert_into_sql": {"name": "get_insert_into_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_insert_into_sql", "macro_sql": "{% macro get_insert_into_sql(target_relation, temp_relation, dest_columns) %}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n insert into {{ target_relation }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ temp_relation }}\n )\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.096718, "supported_languages": null}, "macro.dbt.materialization_incremental_default": {"name": "materialization_incremental_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/incremental.sql", "original_file_path": "macros/materializations/models/incremental/incremental.sql", "unique_id": "macro.dbt.materialization_incremental_default", "macro_sql": "{% materialization incremental, default -%}\n\n -- relations\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set temp_relation = make_temp_relation(target_relation)-%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation)-%}\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n\n -- configs\n {%- set unique_key = config.get('unique_key') -%}\n {%- set full_refresh_mode = (should_full_refresh() or existing_relation.is_view) -%}\n {%- set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') -%}\n\n -- the temp_ and backup_ relations should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation. This has to happen before\n -- BEGIN, in a separate transaction\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation)-%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set to_drop = [] %}\n\n {% if existing_relation is none %}\n {% set build_sql = get_create_table_as_sql(False, target_relation, sql) %}\n {% elif full_refresh_mode %}\n {% set build_sql = get_create_table_as_sql(False, intermediate_relation, sql) %}\n {% set need_swap = true %}\n {% else %}\n {% do run_query(get_create_table_as_sql(True, temp_relation, sql)) %}\n {% do adapter.expand_target_column_types(\n from_relation=temp_relation,\n to_relation=target_relation) %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, temp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': temp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'incremental_predicates': incremental_predicates }) %}\n {% set build_sql = strategy_sql_macro_func(strategy_arg_dict) %}\n\n {% endif %}\n\n {% call statement(\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% if need_swap %}\n {% do adapter.rename_relation(target_relation, backup_relation) %}\n {% do adapter.rename_relation(intermediate_relation, target_relation) %}\n {% do to_drop.append(backup_relation) %}\n {% endif %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if existing_relation is none or existing_relation.is_view or should_full_refresh() %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {% do adapter.commit() %}\n\n {% for rel in to_drop %}\n {% do adapter.drop_relation(rel) %}\n {% endfor %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_temp_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.should_full_refresh", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.get_create_table_as_sql", "macro.dbt.run_query", "macro.dbt.process_schema_changes", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.0994549, "supported_languages": ["sql"]}, "macro.dbt.incremental_validate_on_schema_change": {"name": "incremental_validate_on_schema_change", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.incremental_validate_on_schema_change", "macro_sql": "{% macro incremental_validate_on_schema_change(on_schema_change, default='ignore') %}\n\n {% if on_schema_change not in ['sync_all_columns', 'append_new_columns', 'fail', 'ignore'] %}\n\n {% set log_message = 'Invalid value for on_schema_change (%s) specified. Setting default value of %s.' % (on_schema_change, default) %}\n {% do log(log_message) %}\n\n {{ return(default) }}\n\n {% else %}\n\n {{ return(on_schema_change) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.102517, "supported_languages": null}, "macro.dbt.check_for_schema_changes": {"name": "check_for_schema_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.check_for_schema_changes", "macro_sql": "{% macro check_for_schema_changes(source_relation, target_relation) %}\n\n {% set schema_changed = False %}\n\n {%- set source_columns = adapter.get_columns_in_relation(source_relation) -%}\n {%- set target_columns = adapter.get_columns_in_relation(target_relation) -%}\n {%- set source_not_in_target = diff_columns(source_columns, target_columns) -%}\n {%- set target_not_in_source = diff_columns(target_columns, source_columns) -%}\n\n {% set new_target_types = diff_column_data_types(source_columns, target_columns) %}\n\n {% if source_not_in_target != [] %}\n {% set schema_changed = True %}\n {% elif target_not_in_source != [] or new_target_types != [] %}\n {% set schema_changed = True %}\n {% elif new_target_types != [] %}\n {% set schema_changed = True %}\n {% endif %}\n\n {% set changes_dict = {\n 'schema_changed': schema_changed,\n 'source_not_in_target': source_not_in_target,\n 'target_not_in_source': target_not_in_source,\n 'source_columns': source_columns,\n 'target_columns': target_columns,\n 'new_target_types': new_target_types\n } %}\n\n {% set msg %}\n In {{ target_relation }}:\n Schema changed: {{ schema_changed }}\n Source columns not in target: {{ source_not_in_target }}\n Target columns not in source: {{ target_not_in_source }}\n New column types: {{ new_target_types }}\n {% endset %}\n\n {% do log(msg) %}\n\n {{ return(changes_dict) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.diff_columns", "macro.dbt.diff_column_data_types"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1031418, "supported_languages": null}, "macro.dbt.sync_column_schemas": {"name": "sync_column_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.sync_column_schemas", "macro_sql": "{% macro sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {%- set add_to_target_arr = schema_changes_dict['source_not_in_target'] -%}\n\n {%- if on_schema_change == 'append_new_columns'-%}\n {%- if add_to_target_arr | length > 0 -%}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, none) -%}\n {%- endif -%}\n\n {% elif on_schema_change == 'sync_all_columns' %}\n {%- set remove_from_target_arr = schema_changes_dict['target_not_in_source'] -%}\n {%- set new_target_types = schema_changes_dict['new_target_types'] -%}\n\n {% if add_to_target_arr | length > 0 or remove_from_target_arr | length > 0 %}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, remove_from_target_arr) -%}\n {% endif %}\n\n {% if new_target_types != [] %}\n {% for ntt in new_target_types %}\n {% set column_name = ntt['column_name'] %}\n {% set new_type = ntt['new_type'] %}\n {% do alter_column_type(target_relation, column_name, new_type) %}\n {% endfor %}\n {% endif %}\n\n {% endif %}\n\n {% set schema_change_message %}\n In {{ target_relation }}:\n Schema change approach: {{ on_schema_change }}\n Columns added: {{ add_to_target_arr }}\n Columns removed: {{ remove_from_target_arr }}\n Data types changed: {{ new_target_types }}\n {% endset %}\n\n {% do log(schema_change_message) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.alter_relation_add_remove_columns", "macro.dbt.alter_column_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.103772, "supported_languages": null}, "macro.dbt.process_schema_changes": {"name": "process_schema_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.process_schema_changes", "macro_sql": "{% macro process_schema_changes(on_schema_change, source_relation, target_relation) %}\n\n {% if on_schema_change == 'ignore' %}\n\n {{ return({}) }}\n\n {% else %}\n\n {% set schema_changes_dict = check_for_schema_changes(source_relation, target_relation) %}\n\n {% if schema_changes_dict['schema_changed'] %}\n\n {% if on_schema_change == 'fail' %}\n\n {% set fail_msg %}\n The source and target schemas on this incremental model are out of sync!\n They can be reconciled in several ways:\n - set the `on_schema_change` config to either append_new_columns or sync_all_columns, depending on your situation.\n - Re-run the incremental model with `full_refresh: True` to update the target schema.\n - update the schema manually and re-run the process.\n\n Additional troubleshooting context:\n Source columns not in target: {{ schema_changes_dict['source_not_in_target'] }}\n Target columns not in source: {{ schema_changes_dict['target_not_in_source'] }}\n New column types: {{ schema_changes_dict['new_target_types'] }}\n {% endset %}\n\n {% do exceptions.raise_compiler_error(fail_msg) %}\n\n {# -- unless we ignore, run the sync operation per the config #}\n {% else %}\n\n {% do sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {% endif %}\n\n {% endif %}\n\n {{ return(schema_changes_dict['source_columns']) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.check_for_schema_changes", "macro.dbt.sync_column_schemas"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.104223, "supported_languages": null}, "macro.dbt.can_clone_table": {"name": "can_clone_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/can_clone_table.sql", "original_file_path": "macros/materializations/models/clone/can_clone_table.sql", "unique_id": "macro.dbt.can_clone_table", "macro_sql": "{% macro can_clone_table() %}\n {{ return(adapter.dispatch('can_clone_table', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__can_clone_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.104355, "supported_languages": null}, "macro.dbt.default__can_clone_table": {"name": "default__can_clone_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/can_clone_table.sql", "original_file_path": "macros/materializations/models/clone/can_clone_table.sql", "unique_id": "macro.dbt.default__can_clone_table", "macro_sql": "{% macro default__can_clone_table() %}\n {{ return(False) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.104419, "supported_languages": null}, "macro.dbt.create_or_replace_clone": {"name": "create_or_replace_clone", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/create_or_replace_clone.sql", "original_file_path": "macros/materializations/models/clone/create_or_replace_clone.sql", "unique_id": "macro.dbt.create_or_replace_clone", "macro_sql": "{% macro create_or_replace_clone(this_relation, defer_relation) %}\n {{ return(adapter.dispatch('create_or_replace_clone', 'dbt')(this_relation, defer_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_or_replace_clone"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.104585, "supported_languages": null}, "macro.dbt.default__create_or_replace_clone": {"name": "default__create_or_replace_clone", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/create_or_replace_clone.sql", "original_file_path": "macros/materializations/models/clone/create_or_replace_clone.sql", "unique_id": "macro.dbt.default__create_or_replace_clone", "macro_sql": "{% macro default__create_or_replace_clone(this_relation, defer_relation) %}\n create or replace table {{ this_relation }} clone {{ defer_relation }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.10466, "supported_languages": null}, "macro.dbt.materialization_clone_default": {"name": "materialization_clone_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/clone.sql", "original_file_path": "macros/materializations/models/clone/clone.sql", "unique_id": "macro.dbt.materialization_clone_default", "macro_sql": "{%- materialization clone, default -%}\n\n {%- set relations = {'relations': []} -%}\n\n {%- if not defer_relation -%}\n -- nothing to do\n {{ log(\"No relation found in state manifest for \" ~ model.unique_id, info=True) }}\n {{ return(relations) }}\n {%- endif -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n\n {%- if existing_relation and not flags.FULL_REFRESH -%}\n -- noop!\n {{ log(\"Relation \" ~ existing_relation ~ \" already exists\", info=True) }}\n {{ return(relations) }}\n {%- endif -%}\n\n {%- set other_existing_relation = load_cached_relation(defer_relation) -%}\n\n -- If this is a database that can do zero-copy cloning of tables, and the other relation is a table, then this will be a table\n -- Otherwise, this will be a view\n\n {% set can_clone_table = can_clone_table() %}\n\n {%- if other_existing_relation and other_existing_relation.type == 'table' and can_clone_table -%}\n\n {%- set target_relation = this.incorporate(type='table') -%}\n {% if existing_relation is not none and not existing_relation.is_table %}\n {{ log(\"Dropping relation \" ~ existing_relation ~ \" because it is of type \" ~ existing_relation.type) }}\n {{ drop_relation_if_exists(existing_relation) }}\n {% endif %}\n\n -- as a general rule, data platforms that can clone tables can also do atomic 'create or replace'\n {% call statement('main') %}\n {% if target_relation and defer_relation and target_relation == defer_relation %}\n {{ log(\"Target relation and defer relation are the same, skipping clone for relation: \" ~ target_relation) }}\n {% else %}\n {{ create_or_replace_clone(target_relation, defer_relation) }}\n {% endif %}\n\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n {% do persist_docs(target_relation, model) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n {%- else -%}\n\n {%- set target_relation = this.incorporate(type='view') -%}\n\n -- reuse the view materialization\n -- TODO: support actual dispatch for materialization macros\n -- Tracking ticket: https://github.com/dbt-labs/dbt-core/issues/7799\n {% set search_name = \"materialization_view_\" ~ adapter.type() %}\n {% if not search_name in context %}\n {% set search_name = \"materialization_view_default\" %}\n {% endif %}\n {% set materialization_macro = context[search_name] %}\n {% set relations = materialization_macro() %}\n {{ return(relations) }}\n\n {%- endif -%}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.can_clone_table", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.create_or_replace_clone", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.106588, "supported_languages": ["sql"]}, "macro.dbt.materialization_seed_default": {"name": "materialization_seed_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/seed.sql", "original_file_path": "macros/materializations/seeds/seed.sql", "unique_id": "macro.dbt.materialization_seed_default", "macro_sql": "{% materialization seed, default %}\n\n {%- set identifier = model['alias'] -%}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\n {%- set exists_as_table = (old_relation is not none and old_relation.is_table) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set grant_config = config.get('grants') -%}\n {%- set agate_table = load_agate_table() -%}\n -- grab current tables grants config for comparison later on\n\n {%- do store_result('agate_table', response='OK', agate_table=agate_table) -%}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% set create_table_sql = \"\" %}\n {% if exists_as_view %}\n {{ exceptions.raise_compiler_error(\"Cannot seed to '{}', it is a view\".format(old_relation)) }}\n {% elif exists_as_table %}\n {% set create_table_sql = reset_csv_table(model, full_refresh_mode, old_relation, agate_table) %}\n {% else %}\n {% set create_table_sql = create_csv_table(model, agate_table) %}\n {% endif %}\n\n {% set code = 'CREATE' if full_refresh_mode else 'INSERT' %}\n {% set rows_affected = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement('main', code ~ ' ' ~ rows_affected, code, rows_affected) %}\n {{ get_csv_sql(create_table_sql, sql) }};\n {% endcall %}\n\n {% set target_relation = this.incorporate(type='table') %}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if full_refresh_mode or not exists_as_table %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.run_hooks", "macro.dbt.reset_csv_table", "macro.dbt.create_csv_table", "macro.dbt.load_csv_rows", "macro.dbt.noop_statement", "macro.dbt.get_csv_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1083221, "supported_languages": ["sql"]}, "macro.dbt.create_csv_table": {"name": "create_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.create_csv_table", "macro_sql": "{% macro create_csv_table(model, agate_table) -%}\n {{ adapter.dispatch('create_csv_table', 'dbt')(model, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.111134, "supported_languages": null}, "macro.dbt.default__create_csv_table": {"name": "default__create_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__create_csv_table", "macro_sql": "{% macro default__create_csv_table(model, agate_table) %}\n {%- set column_override = model['config'].get('column_types', {}) -%}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n\n {% set sql %}\n create table {{ this.render() }} (\n {%- for col_name in agate_table.column_names -%}\n {%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}\n {%- set type = column_override.get(col_name, inferred_type) -%}\n {%- set column_name = (col_name | string) -%}\n {{ adapter.quote_seed_column(column_name, quote_seed_column) }} {{ type }} {%- if not loop.last -%}, {%- endif -%}\n {%- endfor -%}\n )\n {% endset %}\n\n {% call statement('_') -%}\n {{ sql }}\n {%- endcall %}\n\n {{ return(sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.111596, "supported_languages": null}, "macro.dbt.reset_csv_table": {"name": "reset_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.reset_csv_table", "macro_sql": "{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter.dispatch('reset_csv_table', 'dbt')(model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__reset_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1117241, "supported_languages": null}, "macro.dbt.default__reset_csv_table": {"name": "default__reset_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__reset_csv_table", "macro_sql": "{% macro default__reset_csv_table(model, full_refresh, old_relation, agate_table) %}\n {% set sql = \"\" %}\n {% if full_refresh %}\n {{ adapter.drop_relation(old_relation) }}\n {% set sql = create_csv_table(model, agate_table) %}\n {% else %}\n {{ adapter.truncate_relation(old_relation) }}\n {% set sql = \"truncate table \" ~ old_relation %}\n {% endif %}\n\n {{ return(sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.111976, "supported_languages": null}, "macro.dbt.get_csv_sql": {"name": "get_csv_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_csv_sql", "macro_sql": "{% macro get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ adapter.dispatch('get_csv_sql', 'dbt')(create_or_truncate_sql, insert_sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_csv_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1120808, "supported_languages": null}, "macro.dbt.default__get_csv_sql": {"name": "default__get_csv_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__get_csv_sql", "macro_sql": "{% macro default__get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ create_or_truncate_sql }};\n -- dbt seed --\n {{ insert_sql }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.112154, "supported_languages": null}, "macro.dbt.get_binding_char": {"name": "get_binding_char", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_binding_char", "macro_sql": "{% macro get_binding_char() -%}\n {{ adapter.dispatch('get_binding_char', 'dbt')() }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_binding_char"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.112231, "supported_languages": null}, "macro.dbt.default__get_binding_char": {"name": "default__get_binding_char", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__get_binding_char", "macro_sql": "{% macro default__get_binding_char() %}\n {{ return('%s') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.112302, "supported_languages": null}, "macro.dbt.get_batch_size": {"name": "get_batch_size", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_batch_size", "macro_sql": "{% macro get_batch_size() -%}\n {{ return(adapter.dispatch('get_batch_size', 'dbt')()) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_batch_size"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1123898, "supported_languages": null}, "macro.dbt.default__get_batch_size": {"name": "default__get_batch_size", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__get_batch_size", "macro_sql": "{% macro default__get_batch_size() %}\n {{ return(10000) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.112455, "supported_languages": null}, "macro.dbt.get_seed_column_quoted_csv": {"name": "get_seed_column_quoted_csv", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_seed_column_quoted_csv", "macro_sql": "{% macro get_seed_column_quoted_csv(model, column_names) %}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote_seed_column(col, quote_seed_column)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.112705, "supported_languages": null}, "macro.dbt.load_csv_rows": {"name": "load_csv_rows", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.load_csv_rows", "macro_sql": "{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter.dispatch('load_csv_rows', 'dbt')(model, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__load_csv_rows"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1128051, "supported_languages": null}, "macro.dbt.default__load_csv_rows": {"name": "default__load_csv_rows", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__load_csv_rows", "macro_sql": "{% macro default__load_csv_rows(model, agate_table) %}\n\n {% set batch_size = get_batch_size() %}\n\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n {{ get_binding_char() }}\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_batch_size", "macro.dbt.get_seed_column_quoted_csv", "macro.dbt.get_binding_char"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.113493, "supported_languages": null}, "macro.dbt.generate_alias_name": {"name": "generate_alias_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_alias.sql", "original_file_path": "macros/get_custom_name/get_custom_alias.sql", "unique_id": "macro.dbt.generate_alias_name", "macro_sql": "{% macro generate_alias_name(custom_alias_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_alias_name', 'dbt')(custom_alias_name, node)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_alias_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1137311, "supported_languages": null}, "macro.dbt.default__generate_alias_name": {"name": "default__generate_alias_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_alias.sql", "original_file_path": "macros/get_custom_name/get_custom_alias.sql", "unique_id": "macro.dbt.default__generate_alias_name", "macro_sql": "{% macro default__generate_alias_name(custom_alias_name=none, node=none) -%}\n\n {%- if custom_alias_name -%}\n\n {{ custom_alias_name | trim }}\n\n {%- elif node.version -%}\n\n {{ return(node.name ~ \"_v\" ~ (node.version | replace(\".\", \"_\"))) }}\n\n {%- else -%}\n\n {{ node.name }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1139321, "supported_languages": null}, "macro.dbt.generate_schema_name": {"name": "generate_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "unique_id": "macro.dbt.generate_schema_name", "macro_sql": "{% macro generate_schema_name(custom_schema_name=none, node=none) -%}\n {{ return(adapter.dispatch('generate_schema_name', 'dbt')(custom_schema_name, node)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_schema_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.114238, "supported_languages": null}, "macro.dbt.default__generate_schema_name": {"name": "default__generate_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "unique_id": "macro.dbt.default__generate_schema_name", "macro_sql": "{% macro default__generate_schema_name(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if custom_schema_name is none -%}\n\n {{ default_schema }}\n\n {%- else -%}\n\n {{ default_schema }}_{{ custom_schema_name | trim }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.114381, "supported_languages": null}, "macro.dbt.generate_schema_name_for_env": {"name": "generate_schema_name_for_env", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "unique_id": "macro.dbt.generate_schema_name_for_env", "macro_sql": "{% macro generate_schema_name_for_env(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if target.name == 'prod' and custom_schema_name is not none -%}\n\n {{ custom_schema_name | trim }}\n\n {%- else -%}\n\n {{ default_schema }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.114534, "supported_languages": null}, "macro.dbt.generate_database_name": {"name": "generate_database_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_database.sql", "original_file_path": "macros/get_custom_name/get_custom_database.sql", "unique_id": "macro.dbt.generate_database_name", "macro_sql": "{% macro generate_database_name(custom_database_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_database_name', 'dbt')(custom_database_name, node)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_database_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1147578, "supported_languages": null}, "macro.dbt.default__generate_database_name": {"name": "default__generate_database_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_database.sql", "original_file_path": "macros/get_custom_name/get_custom_database.sql", "unique_id": "macro.dbt.default__generate_database_name", "macro_sql": "{% macro default__generate_database_name(custom_database_name=none, node=none) -%}\n {%- set default_database = target.database -%}\n {%- if custom_database_name is none -%}\n\n {{ default_database }}\n\n {%- else -%}\n\n {{ custom_database_name }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.114895, "supported_languages": null}, "macro.dbt.get_drop_sql": {"name": "get_drop_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.get_drop_sql", "macro_sql": "{%- macro get_drop_sql(relation) -%}\n {{- log('Applying DROP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_drop_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.115318, "supported_languages": null}, "macro.dbt.default__get_drop_sql": {"name": "default__get_drop_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.default__get_drop_sql", "macro_sql": "{%- macro default__get_drop_sql(relation) -%}\n\n {%- if relation.is_view -%}\n {{ drop_view(relation) }}\n\n {%- elif relation.is_table -%}\n {{ drop_table(relation) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ drop_materialized_view(relation) }}\n\n {%- else -%}\n drop {{ relation.type }} if exists {{ relation }} cascade\n\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.drop_view", "macro.dbt.drop_table", "macro.dbt.drop_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.115523, "supported_languages": null}, "macro.dbt.drop_relation": {"name": "drop_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.drop_relation", "macro_sql": "{% macro drop_relation(relation) -%}\n {{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.115621, "supported_languages": null}, "macro.dbt.default__drop_relation": {"name": "default__drop_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.default__drop_relation", "macro_sql": "{% macro default__drop_relation(relation) -%}\n {% call statement('drop_relation', auto_begin=False) -%}\n {{ get_drop_sql(relation) }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.115731, "supported_languages": null}, "macro.dbt.drop_relation_if_exists": {"name": "drop_relation_if_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.drop_relation_if_exists", "macro_sql": "{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.11584, "supported_languages": null}, "macro.dbt.get_replace_sql": {"name": "get_replace_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/replace.sql", "original_file_path": "macros/relations/replace.sql", "unique_id": "macro.dbt.get_replace_sql", "macro_sql": "{% macro get_replace_sql(existing_relation, target_relation, sql) %}\n {{- log('Applying REPLACE to: ' ~ existing_relation) -}}\n {{- adapter.dispatch('get_replace_sql', 'dbt')(existing_relation, target_relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_replace_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.116339, "supported_languages": null}, "macro.dbt.default__get_replace_sql": {"name": "default__get_replace_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/replace.sql", "original_file_path": "macros/relations/replace.sql", "unique_id": "macro.dbt.default__get_replace_sql", "macro_sql": "{% macro default__get_replace_sql(existing_relation, target_relation, sql) %}\n\n {# /* use a create or replace statement if possible */ #}\n\n {% set is_replaceable = existing_relation.type == target_relation_type and existing_relation.can_be_replaced %}\n\n {% if is_replaceable and existing_relation.is_view %}\n {{ get_replace_view_sql(target_relation, sql) }}\n\n {% elif is_replaceable and existing_relation.is_table %}\n {{ get_replace_table_sql(target_relation, sql) }}\n\n {% elif is_replaceable and existing_relation.is_materialized_view %}\n {{ get_replace_materialized_view_sql(target_relation, sql) }}\n\n {# /* a create or replace statement is not possible, so try to stage and/or backup to be safe */ #}\n\n {# /* create target_relation as an intermediate relation, then swap it out with the existing one using a backup */ #}\n {%- elif target_relation.can_be_renamed and existing_relation.can_be_renamed -%}\n {{ get_create_intermediate_sql(target_relation, sql) }};\n {{ get_create_backup_sql(existing_relation) }};\n {{ get_rename_intermediate_sql(target_relation) }};\n {{ get_drop_backup_sql(existing_relation) }}\n\n {# /* create target_relation as an intermediate relation, then swap it out with the existing one without using a backup */ #}\n {%- elif target_relation.can_be_renamed -%}\n {{ get_create_intermediate_sql(target_relation, sql) }};\n {{ get_drop_sql(existing_relation) }};\n {{ get_rename_intermediate_sql(target_relation) }}\n\n {# /* create target_relation in place by first backing up the existing relation */ #}\n {%- elif existing_relation.can_be_renamed -%}\n {{ get_create_backup_sql(existing_relation) }};\n {{ get_create_sql(target_relation, sql) }};\n {{ get_drop_backup_sql(existing_relation) }}\n\n {# /* no renaming is allowed, so just drop and create */ #}\n {%- else -%}\n {{ get_drop_sql(existing_relation) }};\n {{ get_create_sql(target_relation, sql) }}\n\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_replace_view_sql", "macro.dbt.get_replace_table_sql", "macro.dbt.get_replace_materialized_view_sql", "macro.dbt.get_create_intermediate_sql", "macro.dbt.get_create_backup_sql", "macro.dbt.get_rename_intermediate_sql", "macro.dbt.get_drop_backup_sql", "macro.dbt.get_drop_sql", "macro.dbt.get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.116951, "supported_languages": null}, "macro.dbt.get_create_intermediate_sql": {"name": "get_create_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_intermediate.sql", "original_file_path": "macros/relations/create_intermediate.sql", "unique_id": "macro.dbt.get_create_intermediate_sql", "macro_sql": "{%- macro get_create_intermediate_sql(relation, sql) -%}\n {{- log('Applying CREATE INTERMEDIATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_intermediate_sql', 'dbt')(relation, sql) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_create_intermediate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.117173, "supported_languages": null}, "macro.dbt.default__get_create_intermediate_sql": {"name": "default__get_create_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_intermediate.sql", "original_file_path": "macros/relations/create_intermediate.sql", "unique_id": "macro.dbt.default__get_create_intermediate_sql", "macro_sql": "{%- macro default__get_create_intermediate_sql(relation, sql) -%}\n\n -- get the standard intermediate name\n {% set intermediate_relation = make_intermediate_relation(relation) %}\n\n -- drop any pre-existing intermediate\n {{ get_drop_sql(intermediate_relation) }};\n\n {{ get_create_sql(intermediate_relation, sql) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_intermediate_relation", "macro.dbt.get_drop_sql", "macro.dbt.get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.117315, "supported_languages": null}, "macro.dbt.drop_schema_named": {"name": "drop_schema_named", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/schema.sql", "original_file_path": "macros/relations/schema.sql", "unique_id": "macro.dbt.drop_schema_named", "macro_sql": "{% macro drop_schema_named(schema_name) %}\n {{ return(adapter.dispatch('drop_schema_named', 'dbt') (schema_name)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_schema_named"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1174688, "supported_languages": null}, "macro.dbt.default__drop_schema_named": {"name": "default__drop_schema_named", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/schema.sql", "original_file_path": "macros/relations/schema.sql", "unique_id": "macro.dbt.default__drop_schema_named", "macro_sql": "{% macro default__drop_schema_named(schema_name) %}\n {% set schema_relation = api.Relation.create(schema=schema_name) %}\n {{ adapter.drop_schema(schema_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.117584, "supported_languages": null}, "macro.dbt.get_drop_backup_sql": {"name": "get_drop_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop_backup.sql", "original_file_path": "macros/relations/drop_backup.sql", "unique_id": "macro.dbt.get_drop_backup_sql", "macro_sql": "{%- macro get_drop_backup_sql(relation) -%}\n {{- log('Applying DROP BACKUP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_drop_backup_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_drop_backup_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1177652, "supported_languages": null}, "macro.dbt.default__get_drop_backup_sql": {"name": "default__get_drop_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop_backup.sql", "original_file_path": "macros/relations/drop_backup.sql", "unique_id": "macro.dbt.default__get_drop_backup_sql", "macro_sql": "{%- macro default__get_drop_backup_sql(relation) -%}\n\n -- get the standard backup name\n {% set backup_relation = make_backup_relation(relation, relation.type) %}\n\n {{ get_drop_sql(backup_relation) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_backup_relation", "macro.dbt.get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.117878, "supported_languages": null}, "macro.dbt.get_rename_sql": {"name": "get_rename_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.get_rename_sql", "macro_sql": "{%- macro get_rename_sql(relation, new_name) -%}\n {{- log('Applying RENAME to: ' ~ relation) -}}\n {{- adapter.dispatch('get_rename_sql', 'dbt')(relation, new_name) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.118291, "supported_languages": null}, "macro.dbt.default__get_rename_sql": {"name": "default__get_rename_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.default__get_rename_sql", "macro_sql": "{%- macro default__get_rename_sql(relation, new_name) -%}\n\n {%- if relation.is_view -%}\n {{ get_rename_view_sql(relation, new_name) }}\n\n {%- elif relation.is_table -%}\n {{ get_rename_table_sql(relation, new_name) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ get_rename_materialized_view_sql(relation, new_name) }}\n\n {%- else -%}\n {{- exceptions.raise_compiler_error(\"`get_rename_sql` has not been implemented for: \" ~ relation.type ) -}}\n\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.get_rename_view_sql", "macro.dbt.get_rename_table_sql", "macro.dbt.get_rename_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.118515, "supported_languages": null}, "macro.dbt.rename_relation": {"name": "rename_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.rename_relation", "macro_sql": "{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter.dispatch('rename_relation', 'dbt')(from_relation, to_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__rename_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.118628, "supported_languages": null}, "macro.dbt.default__rename_relation": {"name": "default__rename_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.default__rename_relation", "macro_sql": "{% macro default__rename_relation(from_relation, to_relation) -%}\n {% set target_name = adapter.quote_as_configured(to_relation.identifier, 'identifier') %}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ target_name }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1187782, "supported_languages": null}, "macro.dbt.get_create_backup_sql": {"name": "get_create_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_backup.sql", "original_file_path": "macros/relations/create_backup.sql", "unique_id": "macro.dbt.get_create_backup_sql", "macro_sql": "{%- macro get_create_backup_sql(relation) -%}\n {{- log('Applying CREATE BACKUP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_backup_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_create_backup_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.118976, "supported_languages": null}, "macro.dbt.default__get_create_backup_sql": {"name": "default__get_create_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_backup.sql", "original_file_path": "macros/relations/create_backup.sql", "unique_id": "macro.dbt.default__get_create_backup_sql", "macro_sql": "{%- macro default__get_create_backup_sql(relation) -%}\n\n -- get the standard backup name\n {% set backup_relation = make_backup_relation(relation, relation.type) %}\n\n -- drop any pre-existing backup\n {{ get_drop_sql(backup_relation) }};\n\n {{ get_rename_sql(relation, backup_relation.identifier) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_backup_relation", "macro.dbt.get_drop_sql", "macro.dbt.get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.119186, "supported_languages": null}, "macro.dbt.get_create_sql": {"name": "get_create_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create.sql", "original_file_path": "macros/relations/create.sql", "unique_id": "macro.dbt.get_create_sql", "macro_sql": "{%- macro get_create_sql(relation, sql) -%}\n {{- log('Applying CREATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_sql', 'dbt')(relation, sql) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1194549, "supported_languages": null}, "macro.dbt.default__get_create_sql": {"name": "default__get_create_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create.sql", "original_file_path": "macros/relations/create.sql", "unique_id": "macro.dbt.default__get_create_sql", "macro_sql": "{%- macro default__get_create_sql(relation, sql) -%}\n\n {%- if relation.is_view -%}\n {{ get_create_view_as_sql(relation, sql) }}\n\n {%- elif relation.is_table -%}\n {{ get_create_table_as_sql(False, relation, sql) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ get_create_materialized_view_as_sql(relation, sql) }}\n\n {%- else -%}\n {{- exceptions.raise_compiler_error(\"`get_create_sql` has not been implemented for: \" ~ relation.type ) -}}\n\n {%- endif -%}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.get_create_view_as_sql", "macro.dbt.get_create_table_as_sql", "macro.dbt.get_create_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1196868, "supported_languages": null}, "macro.dbt.get_rename_intermediate_sql": {"name": "get_rename_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename_intermediate.sql", "original_file_path": "macros/relations/rename_intermediate.sql", "unique_id": "macro.dbt.get_rename_intermediate_sql", "macro_sql": "{%- macro get_rename_intermediate_sql(relation) -%}\n {{- log('Applying RENAME INTERMEDIATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_rename_intermediate_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_rename_intermediate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.119872, "supported_languages": null}, "macro.dbt.default__get_rename_intermediate_sql": {"name": "default__get_rename_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename_intermediate.sql", "original_file_path": "macros/relations/rename_intermediate.sql", "unique_id": "macro.dbt.default__get_rename_intermediate_sql", "macro_sql": "{%- macro default__get_rename_intermediate_sql(relation) -%}\n\n -- get the standard intermediate name\n {% set intermediate_relation = make_intermediate_relation(relation) %}\n\n {{ get_rename_sql(intermediate_relation, relation.identifier) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_intermediate_relation", "macro.dbt.get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1199841, "supported_languages": null}, "macro.dbt.drop_materialized_view": {"name": "drop_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/drop.sql", "original_file_path": "macros/relations/materialized_view/drop.sql", "unique_id": "macro.dbt.drop_materialized_view", "macro_sql": "{% macro drop_materialized_view(relation) -%}\n {{- adapter.dispatch('drop_materialized_view', 'dbt')(relation) -}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.120127, "supported_languages": null}, "macro.dbt.default__drop_materialized_view": {"name": "default__drop_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/drop.sql", "original_file_path": "macros/relations/materialized_view/drop.sql", "unique_id": "macro.dbt.default__drop_materialized_view", "macro_sql": "{% macro default__drop_materialized_view(relation) -%}\n drop materialized view if exists {{ relation }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.120188, "supported_languages": null}, "macro.dbt.get_replace_materialized_view_sql": {"name": "get_replace_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/replace.sql", "original_file_path": "macros/relations/materialized_view/replace.sql", "unique_id": "macro.dbt.get_replace_materialized_view_sql", "macro_sql": "{% macro get_replace_materialized_view_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_materialized_view_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_replace_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1203442, "supported_languages": null}, "macro.dbt.default__get_replace_materialized_view_sql": {"name": "default__get_replace_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/replace.sql", "original_file_path": "macros/relations/materialized_view/replace.sql", "unique_id": "macro.dbt.default__get_replace_materialized_view_sql", "macro_sql": "{% macro default__get_replace_materialized_view_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_materialized_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.120426, "supported_languages": null}, "macro.dbt.refresh_materialized_view": {"name": "refresh_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/refresh.sql", "original_file_path": "macros/relations/materialized_view/refresh.sql", "unique_id": "macro.dbt.refresh_materialized_view", "macro_sql": "{% macro refresh_materialized_view(relation) %}\n {{- log('Applying REFRESH to: ' ~ relation) -}}\n {{- adapter.dispatch('refresh_materialized_view', 'dbt')(relation) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__refresh_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1206, "supported_languages": null}, "macro.dbt.default__refresh_materialized_view": {"name": "default__refresh_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/refresh.sql", "original_file_path": "macros/relations/materialized_view/refresh.sql", "unique_id": "macro.dbt.default__refresh_materialized_view", "macro_sql": "{% macro default__refresh_materialized_view(relation) %}\n {{ exceptions.raise_compiler_error(\"`refresh_materialized_view` has not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.120675, "supported_languages": null}, "macro.dbt.get_rename_materialized_view_sql": {"name": "get_rename_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/rename.sql", "original_file_path": "macros/relations/materialized_view/rename.sql", "unique_id": "macro.dbt.get_rename_materialized_view_sql", "macro_sql": "{% macro get_rename_materialized_view_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_materialized_view_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_rename_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.12083, "supported_languages": null}, "macro.dbt.default__get_rename_materialized_view_sql": {"name": "default__get_rename_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/rename.sql", "original_file_path": "macros/relations/materialized_view/rename.sql", "unique_id": "macro.dbt.default__get_rename_materialized_view_sql", "macro_sql": "{% macro default__get_rename_materialized_view_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_materialized_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1209128, "supported_languages": null}, "macro.dbt.get_alter_materialized_view_as_sql": {"name": "get_alter_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.get_alter_materialized_view_as_sql", "macro_sql": "{% macro get_alter_materialized_view_as_sql(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n) %}\n {{- log('Applying ALTER to: ' ~ relation) -}}\n {{- adapter.dispatch('get_alter_materialized_view_as_sql', 'dbt')(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n ) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_alter_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.121268, "supported_languages": null}, "macro.dbt.default__get_alter_materialized_view_as_sql": {"name": "default__get_alter_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.default__get_alter_materialized_view_as_sql", "macro_sql": "{% macro default__get_alter_materialized_view_as_sql(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n) %}\n {{ exceptions.raise_compiler_error(\"Materialized views have not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.121377, "supported_languages": null}, "macro.dbt.get_materialized_view_configuration_changes": {"name": "get_materialized_view_configuration_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.get_materialized_view_configuration_changes", "macro_sql": "{% macro get_materialized_view_configuration_changes(existing_relation, new_config) %}\n /* {#\n It's recommended that configuration changes be formatted as follows:\n {\"\": [{\"action\": \"\", \"context\": ...}]}\n\n For example:\n {\n \"indexes\": [\n {\"action\": \"drop\", \"context\": \"index_abc\"},\n {\"action\": \"create\", \"context\": {\"columns\": [\"column_1\", \"column_2\"], \"type\": \"hash\", \"unique\": True}},\n ],\n }\n\n Either way, `get_materialized_view_configuration_changes` needs to align with `get_alter_materialized_view_as_sql`.\n #} */\n {{- log('Determining configuration changes on: ' ~ existing_relation) -}}\n {%- do return(adapter.dispatch('get_materialized_view_configuration_changes', 'dbt')(existing_relation, new_config)) -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_materialized_view_configuration_changes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.12153, "supported_languages": null}, "macro.dbt.default__get_materialized_view_configuration_changes": {"name": "default__get_materialized_view_configuration_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.default__get_materialized_view_configuration_changes", "macro_sql": "{% macro default__get_materialized_view_configuration_changes(existing_relation, new_config) %}\n {{ exceptions.raise_compiler_error(\"Materialized views have not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.121619, "supported_languages": null}, "macro.dbt.get_create_materialized_view_as_sql": {"name": "get_create_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/create.sql", "original_file_path": "macros/relations/materialized_view/create.sql", "unique_id": "macro.dbt.get_create_materialized_view_as_sql", "macro_sql": "{% macro get_create_materialized_view_as_sql(relation, sql) -%}\n {{- adapter.dispatch('get_create_materialized_view_as_sql', 'dbt')(relation, sql) -}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1217752, "supported_languages": null}, "macro.dbt.default__get_create_materialized_view_as_sql": {"name": "default__get_create_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/create.sql", "original_file_path": "macros/relations/materialized_view/create.sql", "unique_id": "macro.dbt.default__get_create_materialized_view_as_sql", "macro_sql": "{% macro default__get_create_materialized_view_as_sql(relation, sql) -%}\n {{ exceptions.raise_compiler_error(\n \"`get_create_materialized_view_as_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.121855, "supported_languages": null}, "macro.dbt.get_table_columns_and_constraints": {"name": "get_table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.get_table_columns_and_constraints", "macro_sql": "{%- macro get_table_columns_and_constraints() -%}\n {{ adapter.dispatch('get_table_columns_and_constraints', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__get_table_columns_and_constraints"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.122464, "supported_languages": null}, "macro.dbt.default__get_table_columns_and_constraints": {"name": "default__get_table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.default__get_table_columns_and_constraints", "macro_sql": "{% macro default__get_table_columns_and_constraints() -%}\n {{ return(table_columns_and_constraints()) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.table_columns_and_constraints"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1225338, "supported_languages": null}, "macro.dbt.table_columns_and_constraints": {"name": "table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.table_columns_and_constraints", "macro_sql": "{% macro table_columns_and_constraints() %}\n {# loop through user_provided_columns to create DDL with data types and constraints #}\n {%- set raw_column_constraints = adapter.render_raw_columns_constraints(raw_columns=model['columns']) -%}\n {%- set raw_model_constraints = adapter.render_raw_model_constraints(raw_constraints=model['constraints']) -%}\n (\n {% for c in raw_column_constraints -%}\n {{ c }}{{ \",\" if not loop.last or raw_model_constraints }}\n {% endfor %}\n {% for c in raw_model_constraints -%}\n {{ c }}{{ \",\" if not loop.last }}\n {% endfor -%}\n )\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.122824, "supported_languages": null}, "macro.dbt.get_assert_columns_equivalent": {"name": "get_assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.get_assert_columns_equivalent", "macro_sql": "\n\n{%- macro get_assert_columns_equivalent(sql) -%}\n {{ adapter.dispatch('get_assert_columns_equivalent', 'dbt')(sql) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.122915, "supported_languages": null}, "macro.dbt.default__get_assert_columns_equivalent": {"name": "default__get_assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.default__get_assert_columns_equivalent", "macro_sql": "{% macro default__get_assert_columns_equivalent(sql) -%}\n {{ return(assert_columns_equivalent(sql)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.122989, "supported_languages": null}, "macro.dbt.assert_columns_equivalent": {"name": "assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.assert_columns_equivalent", "macro_sql": "{% macro assert_columns_equivalent(sql) %}\n\n {#-- First ensure the user has defined 'columns' in yaml specification --#}\n {%- set user_defined_columns = model['columns'] -%}\n {%- if not user_defined_columns -%}\n {{ exceptions.raise_contract_error([], []) }}\n {%- endif -%}\n\n {#-- Obtain the column schema provided by sql file. #}\n {%- set sql_file_provided_columns = get_column_schema_from_query(sql, config.get('sql_header', none)) -%}\n {#--Obtain the column schema provided by the schema file by generating an 'empty schema' query from the model's columns. #}\n {%- set schema_file_provided_columns = get_column_schema_from_query(get_empty_schema_sql(user_defined_columns)) -%}\n\n {#-- create dictionaries with name and formatted data type and strings for exception #}\n {%- set sql_columns = format_columns(sql_file_provided_columns) -%}\n {%- set yaml_columns = format_columns(schema_file_provided_columns) -%}\n\n {%- if sql_columns|length != yaml_columns|length -%}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n\n {%- for sql_col in sql_columns -%}\n {%- set yaml_col = [] -%}\n {%- for this_col in yaml_columns -%}\n {%- if this_col['name'] == sql_col['name'] -%}\n {%- do yaml_col.append(this_col) -%}\n {%- break -%}\n {%- endif -%}\n {%- endfor -%}\n {%- if not yaml_col -%}\n {#-- Column with name not found in yaml #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- if sql_col['formatted'] != yaml_col[0]['formatted'] -%}\n {#-- Column data types don't match #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- endfor -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_column_schema_from_query", "macro.dbt.get_empty_schema_sql", "macro.dbt.format_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.12371, "supported_languages": null}, "macro.dbt.format_columns": {"name": "format_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.format_columns", "macro_sql": "{% macro format_columns(columns) %}\n {% set formatted_columns = [] %}\n {% for column in columns %}\n {%- set formatted_column = adapter.dispatch('format_column', 'dbt')(column) -%}\n {%- do formatted_columns.append(formatted_column) -%}\n {% endfor %}\n {{ return(formatted_columns) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__format_column"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1239219, "supported_languages": null}, "macro.dbt.default__format_column": {"name": "default__format_column", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.default__format_column", "macro_sql": "{% macro default__format_column(column) -%}\n {% set data_type = column.dtype %}\n {% set formatted = column.column.lower() ~ \" \" ~ data_type %}\n {{ return({'name': column.name, 'data_type': data_type, 'formatted': formatted}) }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1241028, "supported_languages": null}, "macro.dbt.drop_table": {"name": "drop_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/drop.sql", "original_file_path": "macros/relations/table/drop.sql", "unique_id": "macro.dbt.drop_table", "macro_sql": "{% macro drop_table(relation) -%}\n {{- adapter.dispatch('drop_table', 'dbt')(relation) -}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1242461, "supported_languages": null}, "macro.dbt.default__drop_table": {"name": "default__drop_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/drop.sql", "original_file_path": "macros/relations/table/drop.sql", "unique_id": "macro.dbt.default__drop_table", "macro_sql": "{% macro default__drop_table(relation) -%}\n drop table if exists {{ relation }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.124305, "supported_languages": null}, "macro.dbt.get_replace_table_sql": {"name": "get_replace_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/replace.sql", "original_file_path": "macros/relations/table/replace.sql", "unique_id": "macro.dbt.get_replace_table_sql", "macro_sql": "{% macro get_replace_table_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_table_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_replace_table_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.124459, "supported_languages": null}, "macro.dbt.default__get_replace_table_sql": {"name": "default__get_replace_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/replace.sql", "original_file_path": "macros/relations/table/replace.sql", "unique_id": "macro.dbt.default__get_replace_table_sql", "macro_sql": "{% macro default__get_replace_table_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_table_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.124539, "supported_languages": null}, "macro.dbt.get_rename_table_sql": {"name": "get_rename_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/rename.sql", "original_file_path": "macros/relations/table/rename.sql", "unique_id": "macro.dbt.get_rename_table_sql", "macro_sql": "{% macro get_rename_table_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_table_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_rename_table_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.124693, "supported_languages": null}, "macro.dbt.default__get_rename_table_sql": {"name": "default__get_rename_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/rename.sql", "original_file_path": "macros/relations/table/rename.sql", "unique_id": "macro.dbt.default__get_rename_table_sql", "macro_sql": "{% macro default__get_rename_table_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_table_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.124775, "supported_languages": null}, "macro.dbt.get_create_table_as_sql": {"name": "get_create_table_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.get_create_table_as_sql", "macro_sql": "{% macro get_create_table_as_sql(temporary, relation, sql) -%}\n {{ adapter.dispatch('get_create_table_as_sql', 'dbt')(temporary, relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_table_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.125271, "supported_languages": null}, "macro.dbt.default__get_create_table_as_sql": {"name": "default__get_create_table_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__get_create_table_as_sql", "macro_sql": "{% macro default__get_create_table_as_sql(temporary, relation, sql) -%}\n {{ return(create_table_as(temporary, relation, sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.125371, "supported_languages": null}, "macro.dbt.create_table_as": {"name": "create_table_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.create_table_as", "macro_sql": "{% macro create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {# backward compatibility for create_table_as that does not support language #}\n {% if language == \"sql\" %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code)}}\n {% else %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code, language) }}\n {% endif %}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.125603, "supported_languages": null}, "macro.dbt.default__create_table_as": {"name": "default__create_table_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__create_table_as", "macro_sql": "{% macro default__create_table_as(temporary, relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary: -%}temporary{%- endif %} table\n {{ relation.include(database=(not temporary), schema=(not temporary)) }}\n {% set contract_config = config.get('contract') %}\n {% if contract_config.enforced and (not temporary) %}\n {{ get_assert_columns_equivalent(sql) }}\n {{ get_table_columns_and_constraints() }}\n {%- set sql = get_select_subquery(sql) %}\n {% endif %}\n as (\n {{ sql }}\n );\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_assert_columns_equivalent", "macro.dbt.get_table_columns_and_constraints", "macro.dbt.get_select_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.125969, "supported_languages": null}, "macro.dbt.default__get_column_names": {"name": "default__get_column_names", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__get_column_names", "macro_sql": "{% macro default__get_column_names() %}\n {#- loop through user_provided_columns to get column names -#}\n {%- set user_provided_columns = model['columns'] -%}\n {%- for i in user_provided_columns %}\n {%- set col = user_provided_columns[i] -%}\n {%- set col_name = adapter.quote(col['name']) if col.get('quote') else col['name'] -%}\n {{ col_name }}{{ \", \" if not loop.last }}\n {%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.126218, "supported_languages": null}, "macro.dbt.get_select_subquery": {"name": "get_select_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.get_select_subquery", "macro_sql": "{% macro get_select_subquery(sql) %}\n {{ return(adapter.dispatch('get_select_subquery', 'dbt')(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_select_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.126322, "supported_languages": null}, "macro.dbt.default__get_select_subquery": {"name": "default__get_select_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__get_select_subquery", "macro_sql": "{% macro default__get_select_subquery(sql) %}\n select {{ adapter.dispatch('get_column_names', 'dbt')() }}\n from (\n {{ sql }}\n ) as model_subq\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_column_names"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.126422, "supported_languages": null}, "macro.dbt.drop_view": {"name": "drop_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/drop.sql", "original_file_path": "macros/relations/view/drop.sql", "unique_id": "macro.dbt.drop_view", "macro_sql": "{% macro drop_view(relation) -%}\n {{- adapter.dispatch('drop_view', 'dbt')(relation) -}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.126562, "supported_languages": null}, "macro.dbt.default__drop_view": {"name": "default__drop_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/drop.sql", "original_file_path": "macros/relations/view/drop.sql", "unique_id": "macro.dbt.default__drop_view", "macro_sql": "{% macro default__drop_view(relation) -%}\n drop view if exists {{ relation }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.126625, "supported_languages": null}, "macro.dbt.get_replace_view_sql": {"name": "get_replace_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.get_replace_view_sql", "macro_sql": "{% macro get_replace_view_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_view_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_replace_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1271439, "supported_languages": null}, "macro.dbt.default__get_replace_view_sql": {"name": "default__get_replace_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.default__get_replace_view_sql", "macro_sql": "{% macro default__get_replace_view_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.127226, "supported_languages": null}, "macro.dbt.create_or_replace_view": {"name": "create_or_replace_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.create_or_replace_view", "macro_sql": "{% macro create_or_replace_view() %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database,\n type='view') -%}\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks) }}\n\n -- If there's a table with the same name and we weren't told to full refresh,\n -- that's an error. If we were told to full refresh, drop it. This behavior differs\n -- for Snowflake and BigQuery, so multiple dispatch is used.\n {%- if old_relation is not none and old_relation.is_table -%}\n {{ handle_existing_table(should_full_refresh(), old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n\n {% set should_revoke = should_revoke(exists_as_view, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {{ run_hooks(post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.handle_existing_table", "macro.dbt.should_full_refresh", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.127809, "supported_languages": null}, "macro.dbt.handle_existing_table": {"name": "handle_existing_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.handle_existing_table", "macro_sql": "{% macro handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.dispatch('handle_existing_table', 'dbt')(full_refresh, old_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__handle_existing_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.127915, "supported_languages": null}, "macro.dbt.default__handle_existing_table": {"name": "default__handle_existing_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.default__handle_existing_table", "macro_sql": "{% macro default__handle_existing_table(full_refresh, old_relation) %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ adapter.drop_relation(old_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.128034, "supported_languages": null}, "macro.dbt.get_rename_view_sql": {"name": "get_rename_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/rename.sql", "original_file_path": "macros/relations/view/rename.sql", "unique_id": "macro.dbt.get_rename_view_sql", "macro_sql": "{% macro get_rename_view_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_view_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_rename_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1281888, "supported_languages": null}, "macro.dbt.default__get_rename_view_sql": {"name": "default__get_rename_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/rename.sql", "original_file_path": "macros/relations/view/rename.sql", "unique_id": "macro.dbt.default__get_rename_view_sql", "macro_sql": "{% macro default__get_rename_view_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1282701, "supported_languages": null}, "macro.dbt.get_create_view_as_sql": {"name": "get_create_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.get_create_view_as_sql", "macro_sql": "{% macro get_create_view_as_sql(relation, sql) -%}\n {{ adapter.dispatch('get_create_view_as_sql', 'dbt')(relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1285079, "supported_languages": null}, "macro.dbt.default__get_create_view_as_sql": {"name": "default__get_create_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.default__get_create_view_as_sql", "macro_sql": "{% macro default__get_create_view_as_sql(relation, sql) -%}\n {{ return(create_view_as(relation, sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1285949, "supported_languages": null}, "macro.dbt.create_view_as": {"name": "create_view_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.create_view_as", "macro_sql": "{% macro create_view_as(relation, sql) -%}\n {{ adapter.dispatch('create_view_as', 'dbt')(relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.128691, "supported_languages": null}, "macro.dbt.default__create_view_as": {"name": "default__create_view_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.default__create_view_as", "macro_sql": "{% macro default__create_view_as(relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create view {{ relation }}\n {% set contract_config = config.get('contract') %}\n {% if contract_config.enforced %}\n {{ get_assert_columns_equivalent(sql) }}\n {%- endif %}\n as (\n {{ sql }}\n );\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1289768, "supported_languages": null}, "macro.dbt.default__test_relationships": {"name": "default__test_relationships", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/relationships.sql", "original_file_path": "macros/generic_test_sql/relationships.sql", "unique_id": "macro.dbt.default__test_relationships", "macro_sql": "{% macro default__test_relationships(model, column_name, to, field) %}\n\nwith child as (\n select {{ column_name }} as from_field\n from {{ model }}\n where {{ column_name }} is not null\n),\n\nparent as (\n select {{ field }} as to_field\n from {{ to }}\n)\n\nselect\n from_field\n\nfrom child\nleft join parent\n on child.from_field = parent.to_field\n\nwhere parent.to_field is null\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.129181, "supported_languages": null}, "macro.dbt.default__test_not_null": {"name": "default__test_not_null", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/not_null.sql", "original_file_path": "macros/generic_test_sql/not_null.sql", "unique_id": "macro.dbt.default__test_not_null", "macro_sql": "{% macro default__test_not_null(model, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else column_name %}\n\nselect {{ column_list }}\nfrom {{ model }}\nwhere {{ column_name }} is null\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_store_failures"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1293418, "supported_languages": null}, "macro.dbt.default__test_unique": {"name": "default__test_unique", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/unique.sql", "original_file_path": "macros/generic_test_sql/unique.sql", "unique_id": "macro.dbt.default__test_unique", "macro_sql": "{% macro default__test_unique(model, column_name) %}\n\nselect\n {{ column_name }} as unique_field,\n count(*) as n_records\n\nfrom {{ model }}\nwhere {{ column_name }} is not null\ngroup by {{ column_name }}\nhaving count(*) > 1\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.129483, "supported_languages": null}, "macro.dbt.default__test_accepted_values": {"name": "default__test_accepted_values", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/accepted_values.sql", "original_file_path": "macros/generic_test_sql/accepted_values.sql", "unique_id": "macro.dbt.default__test_accepted_values", "macro_sql": "{% macro default__test_accepted_values(model, column_name, values, quote=True) %}\n\nwith all_values as (\n\n select\n {{ column_name }} as value_field,\n count(*) as n_records\n\n from {{ model }}\n group by {{ column_name }}\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n)\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.129802, "supported_languages": null}, "macro.dbt.statement": {"name": "statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "unique_id": "macro.dbt.statement", "macro_sql": "\n{%- macro statement(name=None, fetch_result=False, auto_begin=True, language='sql') -%}\n {%- if execute: -%}\n {%- set compiled_code = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime {} for node \"{}\"'.format(language, model['unique_id'])) }}\n {{ write(compiled_code) }}\n {%- endif -%}\n {%- if language == 'sql'-%}\n {%- set res, table = adapter.execute(compiled_code, auto_begin=auto_begin, fetch=fetch_result) -%}\n {%- elif language == 'python' -%}\n {%- set res = submit_python_job(model, compiled_code) -%}\n {#-- TODO: What should table be for python models? --#}\n {%- set table = None -%}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"statement macro didn't get supported language\") %}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_result(name, response=res, agate_table=table) }}\n {%- endif -%}\n\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.130641, "supported_languages": null}, "macro.dbt.noop_statement": {"name": "noop_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "unique_id": "macro.dbt.noop_statement", "macro_sql": "{% macro noop_statement(name=None, message=None, code=None, rows_affected=None, res=None) -%}\n {%- set sql = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime SQL for node \"{}\"'.format(model['unique_id'])) }}\n {{ write(sql) }}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_raw_result(name, message=message, code=code, rows_affected=rows_affected, agate_table=res) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1309462, "supported_languages": null}, "macro.dbt.run_query": {"name": "run_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "unique_id": "macro.dbt.run_query", "macro_sql": "{% macro run_query(sql) %}\n {% call statement(\"run_query_statement\", fetch_result=true, auto_begin=false) %}\n {{ sql }}\n {% endcall %}\n\n {% do return(load_result(\"run_query_statement\").table) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.131104, "supported_languages": null}, "macro.dbt.convert_datetime": {"name": "convert_datetime", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.convert_datetime", "macro_sql": "{% macro convert_datetime(date_str, date_fmt) %}\n\n {% set error_msg -%}\n The provided partition date '{{ date_str }}' does not match the expected format '{{ date_fmt }}'\n {%- endset %}\n\n {% set res = try_or_compiler_error(error_msg, modules.datetime.datetime.strptime, date_str.strip(), date_fmt) %}\n {{ return(res) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1321962, "supported_languages": null}, "macro.dbt.dates_in_range": {"name": "dates_in_range", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.dates_in_range", "macro_sql": "{% macro dates_in_range(start_date_str, end_date_str=none, in_fmt=\"%Y%m%d\", out_fmt=\"%Y%m%d\") %}\n {% set end_date_str = start_date_str if end_date_str is none else end_date_str %}\n\n {% set start_date = convert_datetime(start_date_str, in_fmt) %}\n {% set end_date = convert_datetime(end_date_str, in_fmt) %}\n\n {% set day_count = (end_date - start_date).days %}\n {% if day_count < 0 %}\n {% set msg -%}\n Partition start date is after the end date ({{ start_date }}, {{ end_date }})\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg, model) }}\n {% endif %}\n\n {% set date_list = [] %}\n {% for i in range(0, day_count + 1) %}\n {% set the_date = (modules.datetime.timedelta(days=i) + start_date) %}\n {% if not out_fmt %}\n {% set _ = date_list.append(the_date) %}\n {% else %}\n {% set _ = date_list.append(the_date.strftime(out_fmt)) %}\n {% endif %}\n {% endfor %}\n\n {{ return(date_list) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.convert_datetime"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1328168, "supported_languages": null}, "macro.dbt.partition_range": {"name": "partition_range", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.partition_range", "macro_sql": "{% macro partition_range(raw_partition_date, date_fmt='%Y%m%d') %}\n {% set partition_range = (raw_partition_date | string).split(\",\") %}\n\n {% if (partition_range | length) == 1 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = none %}\n {% elif (partition_range | length) == 2 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = partition_range[1] %}\n {% else %}\n {{ exceptions.raise_compiler_error(\"Invalid partition time. Expected format: {Start Date}[,{End Date}]. Got: \" ~ raw_partition_date) }}\n {% endif %}\n\n {{ return(dates_in_range(start_date, end_date, in_fmt=date_fmt)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.dates_in_range"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.133219, "supported_languages": null}, "macro.dbt.py_current_timestring": {"name": "py_current_timestring", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.py_current_timestring", "macro_sql": "{% macro py_current_timestring() %}\n {% set dt = modules.datetime.datetime.now() %}\n {% do return(dt.strftime(\"%Y%m%d%H%M%S%f\")) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.13335, "supported_languages": null}, "macro.dbt.except": {"name": "except", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/except.sql", "original_file_path": "macros/utils/except.sql", "unique_id": "macro.dbt.except", "macro_sql": "{% macro except() %}\n {{ return(adapter.dispatch('except', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1334772, "supported_languages": null}, "macro.dbt.default__except": {"name": "default__except", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/except.sql", "original_file_path": "macros/utils/except.sql", "unique_id": "macro.dbt.default__except", "macro_sql": "{% macro default__except() %}\n\n except\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1335208, "supported_languages": null}, "macro.dbt.get_intervals_between": {"name": "get_intervals_between", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.get_intervals_between", "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt')(start_date, end_date, datepart)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_intervals_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1339278, "supported_languages": null}, "macro.dbt.default__get_intervals_between": {"name": "default__get_intervals_between", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.default__get_intervals_between", "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.134238, "supported_languages": null}, "macro.dbt.date_spine": {"name": "date_spine", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.date_spine", "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt')(datepart, start_date, end_date)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__date_spine"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.134366, "supported_languages": null}, "macro.dbt.default__date_spine": {"name": "default__date_spine", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.default__date_spine", "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n {# call as follows:\n\n date_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n ) #}\n\n\n with rawdata as (\n\n {{dbt.generate_series(\n dbt.get_intervals_between(start_date, end_date, datepart)\n )}}\n\n ),\n\n all_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n ),\n\n filtered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n )\n\n select * from filtered\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.generate_series", "macro.dbt.get_intervals_between", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.134563, "supported_languages": null}, "macro.dbt.date": {"name": "date", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date.sql", "original_file_path": "macros/utils/date.sql", "unique_id": "macro.dbt.date", "macro_sql": "{% macro date(year, month, day) %}\n {{ return(adapter.dispatch('date', 'dbt') (year, month, day)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__date"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.134753, "supported_languages": null}, "macro.dbt.default__date": {"name": "default__date", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date.sql", "original_file_path": "macros/utils/date.sql", "unique_id": "macro.dbt.default__date", "macro_sql": "{% macro default__date(year, month, day) -%}\n {%- set dt = modules.datetime.date(year, month, day) -%}\n {%- set iso_8601_formatted_date = dt.strftime('%Y-%m-%d') -%}\n to_date('{{ iso_8601_formatted_date }}', 'YYYY-MM-DD')\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.134913, "supported_languages": null}, "macro.dbt.replace": {"name": "replace", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/replace.sql", "original_file_path": "macros/utils/replace.sql", "unique_id": "macro.dbt.replace", "macro_sql": "{% macro replace(field, old_chars, new_chars) -%}\n {{ return(adapter.dispatch('replace', 'dbt') (field, old_chars, new_chars)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__replace"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.135103, "supported_languages": null}, "macro.dbt.default__replace": {"name": "default__replace", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/replace.sql", "original_file_path": "macros/utils/replace.sql", "unique_id": "macro.dbt.default__replace", "macro_sql": "{% macro default__replace(field, old_chars, new_chars) %}\n\n replace(\n {{ field }},\n {{ old_chars }},\n {{ new_chars }}\n )\n\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1352, "supported_languages": null}, "macro.dbt.concat": {"name": "concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/concat.sql", "original_file_path": "macros/utils/concat.sql", "unique_id": "macro.dbt.concat", "macro_sql": "{% macro concat(fields) -%}\n {{ return(adapter.dispatch('concat', 'dbt')(fields)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.135346, "supported_languages": null}, "macro.dbt.default__concat": {"name": "default__concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/concat.sql", "original_file_path": "macros/utils/concat.sql", "unique_id": "macro.dbt.default__concat", "macro_sql": "{% macro default__concat(fields) -%}\n {{ fields|join(' || ') }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.135416, "supported_languages": null}, "macro.dbt.get_powers_of_two": {"name": "get_powers_of_two", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.get_powers_of_two", "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.135905, "supported_languages": null}, "macro.dbt.default__get_powers_of_two": {"name": "default__get_powers_of_two", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.default__get_powers_of_two", "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1361861, "supported_languages": null}, "macro.dbt.generate_series": {"name": "generate_series", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.generate_series", "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_series"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.13629, "supported_languages": null}, "macro.dbt.default__generate_series": {"name": "default__generate_series", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.default__generate_series", "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.136563, "supported_languages": null}, "macro.dbt.length": {"name": "length", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/length.sql", "original_file_path": "macros/utils/length.sql", "unique_id": "macro.dbt.length", "macro_sql": "{% macro length(expression) -%}\n {{ return(adapter.dispatch('length', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__length"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.136706, "supported_languages": null}, "macro.dbt.default__length": {"name": "default__length", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/length.sql", "original_file_path": "macros/utils/length.sql", "unique_id": "macro.dbt.default__length", "macro_sql": "{% macro default__length(expression) %}\n\n length(\n {{ expression }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.136766, "supported_languages": null}, "macro.dbt.dateadd": {"name": "dateadd", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/dateadd.sql", "original_file_path": "macros/utils/dateadd.sql", "unique_id": "macro.dbt.dateadd", "macro_sql": "{% macro dateadd(datepart, interval, from_date_or_timestamp) %}\n {{ return(adapter.dispatch('dateadd', 'dbt')(datepart, interval, from_date_or_timestamp)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.136951, "supported_languages": null}, "macro.dbt.default__dateadd": {"name": "default__dateadd", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/dateadd.sql", "original_file_path": "macros/utils/dateadd.sql", "unique_id": "macro.dbt.default__dateadd", "macro_sql": "{% macro default__dateadd(datepart, interval, from_date_or_timestamp) %}\n\n dateadd(\n {{ datepart }},\n {{ interval }},\n {{ from_date_or_timestamp }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.13704, "supported_languages": null}, "macro.dbt.intersect": {"name": "intersect", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/intersect.sql", "original_file_path": "macros/utils/intersect.sql", "unique_id": "macro.dbt.intersect", "macro_sql": "{% macro intersect() %}\n {{ return(adapter.dispatch('intersect', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__intersect"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.137166, "supported_languages": null}, "macro.dbt.default__intersect": {"name": "default__intersect", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/intersect.sql", "original_file_path": "macros/utils/intersect.sql", "unique_id": "macro.dbt.default__intersect", "macro_sql": "{% macro default__intersect() %}\n\n intersect\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1372092, "supported_languages": null}, "macro.dbt.escape_single_quotes": {"name": "escape_single_quotes", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "unique_id": "macro.dbt.escape_single_quotes", "macro_sql": "{% macro escape_single_quotes(expression) %}\n {{ return(adapter.dispatch('escape_single_quotes', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__escape_single_quotes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.137353, "supported_languages": null}, "macro.dbt.default__escape_single_quotes": {"name": "default__escape_single_quotes", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "unique_id": "macro.dbt.default__escape_single_quotes", "macro_sql": "{% macro default__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\",\"''\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1374311, "supported_languages": null}, "macro.dbt.right": {"name": "right", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "unique_id": "macro.dbt.right", "macro_sql": "{% macro right(string_text, length_expression) -%}\n {{ return(adapter.dispatch('right', 'dbt') (string_text, length_expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__right"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1375911, "supported_languages": null}, "macro.dbt.default__right": {"name": "default__right", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "unique_id": "macro.dbt.default__right", "macro_sql": "{% macro default__right(string_text, length_expression) %}\n\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.137666, "supported_languages": null}, "macro.dbt.listagg": {"name": "listagg", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/listagg.sql", "original_file_path": "macros/utils/listagg.sql", "unique_id": "macro.dbt.listagg", "macro_sql": "{% macro listagg(measure, delimiter_text=\"','\", order_by_clause=none, limit_num=none) -%}\n {{ return(adapter.dispatch('listagg', 'dbt') (measure, delimiter_text, order_by_clause, limit_num)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__listagg"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1380212, "supported_languages": null}, "macro.dbt.default__listagg": {"name": "default__listagg", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/listagg.sql", "original_file_path": "macros/utils/listagg.sql", "unique_id": "macro.dbt.default__listagg", "macro_sql": "{% macro default__listagg(measure, delimiter_text, order_by_clause, limit_num) -%}\n\n {% if limit_num -%}\n array_to_string(\n array_slice(\n array_agg(\n {{ measure }}\n ){% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n ,0\n ,{{ limit_num }}\n ),\n {{ delimiter_text }}\n )\n {%- else %}\n listagg(\n {{ measure }},\n {{ delimiter_text }}\n )\n {% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n {%- endif %}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.13824, "supported_languages": null}, "macro.dbt.datediff": {"name": "datediff", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/datediff.sql", "original_file_path": "macros/utils/datediff.sql", "unique_id": "macro.dbt.datediff", "macro_sql": "{% macro datediff(first_date, second_date, datepart) %}\n {{ return(adapter.dispatch('datediff', 'dbt')(first_date, second_date, datepart)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1384268, "supported_languages": null}, "macro.dbt.default__datediff": {"name": "default__datediff", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/datediff.sql", "original_file_path": "macros/utils/datediff.sql", "unique_id": "macro.dbt.default__datediff", "macro_sql": "{% macro default__datediff(first_date, second_date, datepart) -%}\n\n datediff(\n {{ datepart }},\n {{ first_date }},\n {{ second_date }}\n )\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.138517, "supported_languages": null}, "macro.dbt.safe_cast": {"name": "safe_cast", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "unique_id": "macro.dbt.safe_cast", "macro_sql": "{% macro safe_cast(field, type) %}\n {{ return(adapter.dispatch('safe_cast', 'dbt') (field, type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__safe_cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1386821, "supported_languages": null}, "macro.dbt.default__safe_cast": {"name": "default__safe_cast", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "unique_id": "macro.dbt.default__safe_cast", "macro_sql": "{% macro default__safe_cast(field, type) %}\n {# most databases don't support this function yet\n so we just need to use cast #}\n cast({{field}} as {{type}})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.138759, "supported_languages": null}, "macro.dbt.hash": {"name": "hash", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/hash.sql", "original_file_path": "macros/utils/hash.sql", "unique_id": "macro.dbt.hash", "macro_sql": "{% macro hash(field) -%}\n {{ return(adapter.dispatch('hash', 'dbt') (field)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__hash"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1389031, "supported_languages": null}, "macro.dbt.default__hash": {"name": "default__hash", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/hash.sql", "original_file_path": "macros/utils/hash.sql", "unique_id": "macro.dbt.default__hash", "macro_sql": "{% macro default__hash(field) -%}\n md5(cast({{ field }} as {{ api.Column.translate_type('string') }}))\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.138991, "supported_languages": null}, "macro.dbt.cast_bool_to_text": {"name": "cast_bool_to_text", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/cast_bool_to_text.sql", "original_file_path": "macros/utils/cast_bool_to_text.sql", "unique_id": "macro.dbt.cast_bool_to_text", "macro_sql": "{% macro cast_bool_to_text(field) %}\n {{ adapter.dispatch('cast_bool_to_text', 'dbt') (field) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__cast_bool_to_text"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1391308, "supported_languages": null}, "macro.dbt.default__cast_bool_to_text": {"name": "default__cast_bool_to_text", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/cast_bool_to_text.sql", "original_file_path": "macros/utils/cast_bool_to_text.sql", "unique_id": "macro.dbt.default__cast_bool_to_text", "macro_sql": "{% macro default__cast_bool_to_text(field) %}\n cast({{ field }} as {{ api.Column.translate_type('string') }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1392179, "supported_languages": null}, "macro.dbt.cast": {"name": "cast", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/cast.sql", "original_file_path": "macros/utils/cast.sql", "unique_id": "macro.dbt.cast", "macro_sql": "{% macro cast(field, type) %}\n {{ return(adapter.dispatch('cast', 'dbt') (field, type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.139372, "supported_languages": null}, "macro.dbt.default__cast": {"name": "default__cast", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/cast.sql", "original_file_path": "macros/utils/cast.sql", "unique_id": "macro.dbt.default__cast", "macro_sql": "{% macro default__cast(field, type) %}\n cast({{field}} as {{type}})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.139443, "supported_languages": null}, "macro.dbt.any_value": {"name": "any_value", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/any_value.sql", "original_file_path": "macros/utils/any_value.sql", "unique_id": "macro.dbt.any_value", "macro_sql": "{% macro any_value(expression) -%}\n {{ return(adapter.dispatch('any_value', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__any_value"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.139576, "supported_languages": null}, "macro.dbt.default__any_value": {"name": "default__any_value", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/any_value.sql", "original_file_path": "macros/utils/any_value.sql", "unique_id": "macro.dbt.default__any_value", "macro_sql": "{% macro default__any_value(expression) -%}\n\n any_value({{ expression }})\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1396348, "supported_languages": null}, "macro.dbt.position": {"name": "position", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/position.sql", "original_file_path": "macros/utils/position.sql", "unique_id": "macro.dbt.position", "macro_sql": "{% macro position(substring_text, string_text) -%}\n {{ return(adapter.dispatch('position', 'dbt') (substring_text, string_text)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__position"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.139799, "supported_languages": null}, "macro.dbt.default__position": {"name": "default__position", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/position.sql", "original_file_path": "macros/utils/position.sql", "unique_id": "macro.dbt.default__position", "macro_sql": "{% macro default__position(substring_text, string_text) %}\n\n position(\n {{ substring_text }} in {{ string_text }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.13994, "supported_languages": null}, "macro.dbt.string_literal": {"name": "string_literal", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/literal.sql", "original_file_path": "macros/utils/literal.sql", "unique_id": "macro.dbt.string_literal", "macro_sql": "{%- macro string_literal(value) -%}\n {{ return(adapter.dispatch('string_literal', 'dbt') (value)) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__string_literal"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.140078, "supported_languages": null}, "macro.dbt.default__string_literal": {"name": "default__string_literal", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/literal.sql", "original_file_path": "macros/utils/literal.sql", "unique_id": "macro.dbt.default__string_literal", "macro_sql": "{% macro default__string_literal(value) -%}\n '{{ value }}'\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.140136, "supported_languages": null}, "macro.dbt.type_string": {"name": "type_string", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_string", "macro_sql": "\n\n{%- macro type_string() -%}\n {{ return(adapter.dispatch('type_string', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.140722, "supported_languages": null}, "macro.dbt.default__type_string": {"name": "default__type_string", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_string", "macro_sql": "{% macro default__type_string() %}\n {{ return(api.Column.translate_type(\"string\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.140805, "supported_languages": null}, "macro.dbt.type_timestamp": {"name": "type_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_timestamp", "macro_sql": "\n\n{%- macro type_timestamp() -%}\n {{ return(adapter.dispatch('type_timestamp', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1408918, "supported_languages": null}, "macro.dbt.default__type_timestamp": {"name": "default__type_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_timestamp", "macro_sql": "{% macro default__type_timestamp() %}\n {{ return(api.Column.translate_type(\"timestamp\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1409762, "supported_languages": null}, "macro.dbt.type_float": {"name": "type_float", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_float", "macro_sql": "\n\n{%- macro type_float() -%}\n {{ return(adapter.dispatch('type_float', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_float"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.141066, "supported_languages": null}, "macro.dbt.default__type_float": {"name": "default__type_float", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_float", "macro_sql": "{% macro default__type_float() %}\n {{ return(api.Column.translate_type(\"float\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1411479, "supported_languages": null}, "macro.dbt.type_numeric": {"name": "type_numeric", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_numeric", "macro_sql": "\n\n{%- macro type_numeric() -%}\n {{ return(adapter.dispatch('type_numeric', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_numeric"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.141237, "supported_languages": null}, "macro.dbt.default__type_numeric": {"name": "default__type_numeric", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_numeric", "macro_sql": "{% macro default__type_numeric() %}\n {{ return(api.Column.numeric_type(\"numeric\", 28, 6)) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.141332, "supported_languages": null}, "macro.dbt.type_bigint": {"name": "type_bigint", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_bigint", "macro_sql": "\n\n{%- macro type_bigint() -%}\n {{ return(adapter.dispatch('type_bigint', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_bigint"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.141419, "supported_languages": null}, "macro.dbt.default__type_bigint": {"name": "default__type_bigint", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_bigint", "macro_sql": "{% macro default__type_bigint() %}\n {{ return(api.Column.translate_type(\"bigint\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1415, "supported_languages": null}, "macro.dbt.type_int": {"name": "type_int", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_int", "macro_sql": "\n\n{%- macro type_int() -%}\n {{ return(adapter.dispatch('type_int', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_int"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.141589, "supported_languages": null}, "macro.dbt.default__type_int": {"name": "default__type_int", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_int", "macro_sql": "{%- macro default__type_int() -%}\n {{ return(api.Column.translate_type(\"integer\")) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.141671, "supported_languages": null}, "macro.dbt.type_boolean": {"name": "type_boolean", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_boolean", "macro_sql": "\n\n{%- macro type_boolean() -%}\n {{ return(adapter.dispatch('type_boolean', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_boolean"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1417558, "supported_languages": null}, "macro.dbt.default__type_boolean": {"name": "default__type_boolean", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_boolean", "macro_sql": "{%- macro default__type_boolean() -%}\n {{ return(api.Column.translate_type(\"boolean\")) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.141838, "supported_languages": null}, "macro.dbt.array_concat": {"name": "array_concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_concat.sql", "original_file_path": "macros/utils/array_concat.sql", "unique_id": "macro.dbt.array_concat", "macro_sql": "{% macro array_concat(array_1, array_2) -%}\n {{ return(adapter.dispatch('array_concat', 'dbt')(array_1, array_2)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__array_concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1419919, "supported_languages": null}, "macro.dbt.default__array_concat": {"name": "default__array_concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_concat.sql", "original_file_path": "macros/utils/array_concat.sql", "unique_id": "macro.dbt.default__array_concat", "macro_sql": "{% macro default__array_concat(array_1, array_2) -%}\n array_cat({{ array_1 }}, {{ array_2 }})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.142066, "supported_languages": null}, "macro.dbt.bool_or": {"name": "bool_or", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "unique_id": "macro.dbt.bool_or", "macro_sql": "{% macro bool_or(expression) -%}\n {{ return(adapter.dispatch('bool_or', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__bool_or"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.142209, "supported_languages": null}, "macro.dbt.default__bool_or": {"name": "default__bool_or", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "unique_id": "macro.dbt.default__bool_or", "macro_sql": "{% macro default__bool_or(expression) -%}\n\n bool_or({{ expression }})\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.142279, "supported_languages": null}, "macro.dbt.last_day": {"name": "last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "unique_id": "macro.dbt.last_day", "macro_sql": "{% macro last_day(date, datepart) %}\n {{ return(adapter.dispatch('last_day', 'dbt') (date, datepart)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1424708, "supported_languages": null}, "macro.dbt.default_last_day": {"name": "default_last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "unique_id": "macro.dbt.default_last_day", "macro_sql": "\n\n{%- macro default_last_day(date, datepart) -%}\n cast(\n {{dbt.dateadd('day', '-1',\n dbt.dateadd(datepart, '1', dbt.date_trunc(datepart, date))\n )}}\n as date)\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.142616, "supported_languages": null}, "macro.dbt.default__last_day": {"name": "default__last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "unique_id": "macro.dbt.default__last_day", "macro_sql": "{% macro default__last_day(date, datepart) -%}\n {{dbt.default_last_day(date, datepart)}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default_last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1426969, "supported_languages": null}, "macro.dbt.split_part": {"name": "split_part", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "unique_id": "macro.dbt.split_part", "macro_sql": "{% macro split_part(string_text, delimiter_text, part_number) %}\n {{ return(adapter.dispatch('split_part', 'dbt') (string_text, delimiter_text, part_number)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__split_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.142983, "supported_languages": null}, "macro.dbt.default__split_part": {"name": "default__split_part", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "unique_id": "macro.dbt.default__split_part", "macro_sql": "{% macro default__split_part(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n {{ part_number }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.143074, "supported_languages": null}, "macro.dbt._split_part_negative": {"name": "_split_part_negative", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "unique_id": "macro.dbt._split_part_negative", "macro_sql": "{% macro _split_part_negative(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n length({{ string_text }})\n - length(\n replace({{ string_text }}, {{ delimiter_text }}, '')\n ) + 2 + {{ part_number }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.143192, "supported_languages": null}, "macro.dbt.date_trunc": {"name": "date_trunc", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_trunc.sql", "original_file_path": "macros/utils/date_trunc.sql", "unique_id": "macro.dbt.date_trunc", "macro_sql": "{% macro date_trunc(datepart, date) -%}\n {{ return(adapter.dispatch('date_trunc', 'dbt') (datepart, date)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.143409, "supported_languages": null}, "macro.dbt.default__date_trunc": {"name": "default__date_trunc", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_trunc.sql", "original_file_path": "macros/utils/date_trunc.sql", "unique_id": "macro.dbt.default__date_trunc", "macro_sql": "{% macro default__date_trunc(datepart, date) -%}\n date_trunc('{{datepart}}', {{date}})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.143481, "supported_languages": null}, "macro.dbt.array_construct": {"name": "array_construct", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "unique_id": "macro.dbt.array_construct", "macro_sql": "{% macro array_construct(inputs=[], data_type=api.Column.translate_type('integer')) -%}\n {{ return(adapter.dispatch('array_construct', 'dbt')(inputs, data_type)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__array_construct"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1436858, "supported_languages": null}, "macro.dbt.default__array_construct": {"name": "default__array_construct", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "unique_id": "macro.dbt.default__array_construct", "macro_sql": "{% macro default__array_construct(inputs, data_type) -%}\n {% if inputs|length > 0 %}\n array[ {{ inputs|join(' , ') }} ]\n {% else %}\n array[]::{{data_type}}[]\n {% endif %}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.14382, "supported_languages": null}, "macro.dbt.array_append": {"name": "array_append", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_append.sql", "original_file_path": "macros/utils/array_append.sql", "unique_id": "macro.dbt.array_append", "macro_sql": "{% macro array_append(array, new_element) -%}\n {{ return(adapter.dispatch('array_append', 'dbt')(array, new_element)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__array_append"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.143976, "supported_languages": null}, "macro.dbt.default__array_append": {"name": "default__array_append", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_append.sql", "original_file_path": "macros/utils/array_append.sql", "unique_id": "macro.dbt.default__array_append", "macro_sql": "{% macro default__array_append(array, new_element) -%}\n array_append({{ array }}, {{ new_element }})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.144049, "supported_languages": null}, "macro.dbt.create_schema": {"name": "create_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.create_schema", "macro_sql": "{% macro create_schema(relation) -%}\n {{ adapter.dispatch('create_schema', 'dbt')(relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_schema"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.144258, "supported_languages": null}, "macro.dbt.default__create_schema": {"name": "default__create_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.default__create_schema", "macro_sql": "{% macro default__create_schema(relation) -%}\n {%- call statement('create_schema') -%}\n create schema if not exists {{ relation.without_identifier() }}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1443572, "supported_languages": null}, "macro.dbt.drop_schema": {"name": "drop_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.drop_schema", "macro_sql": "{% macro drop_schema(relation) -%}\n {{ adapter.dispatch('drop_schema', 'dbt')(relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_schema"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.144452, "supported_languages": null}, "macro.dbt.default__drop_schema": {"name": "default__drop_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.default__drop_schema", "macro_sql": "{% macro default__drop_schema(relation) -%}\n {%- call statement('drop_schema') -%}\n drop schema if exists {{ relation.without_identifier() }} cascade\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.144554, "supported_languages": null}, "macro.dbt.current_timestamp": {"name": "current_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.current_timestamp", "macro_sql": "{%- macro current_timestamp() -%}\n {{ adapter.dispatch('current_timestamp', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.144843, "supported_languages": null}, "macro.dbt.default__current_timestamp": {"name": "default__current_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp", "macro_sql": "{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n 'current_timestamp macro not implemented for adapter ' + adapter.type()) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.144928, "supported_languages": null}, "macro.dbt.snapshot_get_time": {"name": "snapshot_get_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.snapshot_get_time", "macro_sql": "\n\n{%- macro snapshot_get_time() -%}\n {{ adapter.dispatch('snapshot_get_time', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__snapshot_get_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.14501, "supported_languages": null}, "macro.dbt.default__snapshot_get_time": {"name": "default__snapshot_get_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__snapshot_get_time", "macro_sql": "{% macro default__snapshot_get_time() %}\n {{ current_timestamp() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.145068, "supported_languages": null}, "macro.dbt.current_timestamp_backcompat": {"name": "current_timestamp_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.current_timestamp_backcompat", "macro_sql": "{% macro current_timestamp_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1451578, "supported_languages": null}, "macro.dbt.default__current_timestamp_backcompat": {"name": "default__current_timestamp_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp_backcompat", "macro_sql": "{% macro default__current_timestamp_backcompat() %}\n current_timestamp::timestamp\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1452029, "supported_languages": null}, "macro.dbt.current_timestamp_in_utc_backcompat": {"name": "current_timestamp_in_utc_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.current_timestamp_in_utc_backcompat", "macro_sql": "{% macro current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_in_utc_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.14529, "supported_languages": null}, "macro.dbt.default__current_timestamp_in_utc_backcompat": {"name": "default__current_timestamp_in_utc_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp_in_utc_backcompat", "macro_sql": "{% macro default__current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.current_timestamp_backcompat", "macro.dbt_snowflake.snowflake__current_timestamp_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.145378, "supported_languages": null}, "macro.dbt.get_create_index_sql": {"name": "get_create_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.get_create_index_sql", "macro_sql": "{% macro get_create_index_sql(relation, index_dict) -%}\n {{ return(adapter.dispatch('get_create_index_sql', 'dbt')(relation, index_dict)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_index_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.145889, "supported_languages": null}, "macro.dbt.default__get_create_index_sql": {"name": "default__get_create_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__get_create_index_sql", "macro_sql": "{% macro default__get_create_index_sql(relation, index_dict) -%}\n {% do return(None) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.145967, "supported_languages": null}, "macro.dbt.create_indexes": {"name": "create_indexes", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.create_indexes", "macro_sql": "{% macro create_indexes(relation) -%}\n {{ adapter.dispatch('create_indexes', 'dbt')(relation) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.146061, "supported_languages": null}, "macro.dbt.default__create_indexes": {"name": "default__create_indexes", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__create_indexes", "macro_sql": "{% macro default__create_indexes(relation) -%}\n {%- set _indexes = config.get('indexes', default=[]) -%}\n\n {% for _index_dict in _indexes %}\n {% set create_index_sql = get_create_index_sql(relation, _index_dict) %}\n {% if create_index_sql %}\n {% do run_query(create_index_sql) %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_create_index_sql", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.146278, "supported_languages": null}, "macro.dbt.get_drop_index_sql": {"name": "get_drop_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.get_drop_index_sql", "macro_sql": "{% macro get_drop_index_sql(relation, index_name) -%}\n {{ adapter.dispatch('get_drop_index_sql', 'dbt')(relation, index_name) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_drop_index_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.14638, "supported_languages": null}, "macro.dbt.default__get_drop_index_sql": {"name": "default__get_drop_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__get_drop_index_sql", "macro_sql": "{% macro default__get_drop_index_sql(relation, index_name) -%}\n {{ exceptions.raise_compiler_error(\"`get_drop_index_sql has not been implemented for this adapter.\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.146456, "supported_languages": null}, "macro.dbt.get_show_indexes_sql": {"name": "get_show_indexes_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.get_show_indexes_sql", "macro_sql": "{% macro get_show_indexes_sql(relation) -%}\n {{ adapter.dispatch('get_show_indexes_sql', 'dbt')(relation) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_show_indexes_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.146541, "supported_languages": null}, "macro.dbt.default__get_show_indexes_sql": {"name": "default__get_show_indexes_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__get_show_indexes_sql", "macro_sql": "{% macro default__get_show_indexes_sql(relation) -%}\n {{ exceptions.raise_compiler_error(\"`get_show_indexes_sql has not been implemented for this adapter.\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.146613, "supported_languages": null}, "macro.dbt.make_intermediate_relation": {"name": "make_intermediate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.make_intermediate_relation", "macro_sql": "{% macro make_intermediate_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_intermediate_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_intermediate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.147841, "supported_languages": null}, "macro.dbt.default__make_intermediate_relation": {"name": "default__make_intermediate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__make_intermediate_relation", "macro_sql": "{% macro default__make_intermediate_relation(base_relation, suffix) %}\n {{ return(default__make_temp_relation(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_temp_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1479309, "supported_languages": null}, "macro.dbt.make_temp_relation": {"name": "make_temp_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.make_temp_relation", "macro_sql": "{% macro make_temp_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_temp_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_temp_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1480489, "supported_languages": null}, "macro.dbt.default__make_temp_relation": {"name": "default__make_temp_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__make_temp_relation", "macro_sql": "{% macro default__make_temp_relation(base_relation, suffix) %}\n {%- set temp_identifier = base_relation.identifier ~ suffix -%}\n {%- set temp_relation = base_relation.incorporate(\n path={\"identifier\": temp_identifier}) -%}\n\n {{ return(temp_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.148203, "supported_languages": null}, "macro.dbt.make_backup_relation": {"name": "make_backup_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.make_backup_relation", "macro_sql": "{% macro make_backup_relation(base_relation, backup_relation_type, suffix='__dbt_backup') %}\n {{ return(adapter.dispatch('make_backup_relation', 'dbt')(base_relation, backup_relation_type, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_backup_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.148334, "supported_languages": null}, "macro.dbt.default__make_backup_relation": {"name": "default__make_backup_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__make_backup_relation", "macro_sql": "{% macro default__make_backup_relation(base_relation, backup_relation_type, suffix) %}\n {%- set backup_identifier = base_relation.identifier ~ suffix -%}\n {%- set backup_relation = base_relation.incorporate(\n path={\"identifier\": backup_identifier},\n type=backup_relation_type\n ) -%}\n {{ return(backup_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.148505, "supported_languages": null}, "macro.dbt.truncate_relation": {"name": "truncate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.truncate_relation", "macro_sql": "{% macro truncate_relation(relation) -%}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.148606, "supported_languages": null}, "macro.dbt.default__truncate_relation": {"name": "default__truncate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__truncate_relation", "macro_sql": "{% macro default__truncate_relation(relation) -%}\n {% call statement('truncate_relation') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.148694, "supported_languages": null}, "macro.dbt.get_or_create_relation": {"name": "get_or_create_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.get_or_create_relation", "macro_sql": "{% macro get_or_create_relation(database, schema, identifier, type) -%}\n {{ return(adapter.dispatch('get_or_create_relation', 'dbt')(database, schema, identifier, type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_or_create_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.148831, "supported_languages": null}, "macro.dbt.default__get_or_create_relation": {"name": "default__get_or_create_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__get_or_create_relation", "macro_sql": "{% macro default__get_or_create_relation(database, schema, identifier, type) %}\n {%- set target_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% if target_relation %}\n {% do return([true, target_relation]) %}\n {% endif %}\n\n {%- set new_relation = api.Relation.create(\n database=database,\n schema=schema,\n identifier=identifier,\n type=type\n ) -%}\n {% do return([false, new_relation]) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.149123, "supported_languages": null}, "macro.dbt.load_cached_relation": {"name": "load_cached_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.load_cached_relation", "macro_sql": "{% macro load_cached_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1492522, "supported_languages": null}, "macro.dbt.load_relation": {"name": "load_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.load_relation", "macro_sql": "{% macro load_relation(relation) %}\n {{ return(load_cached_relation(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.149329, "supported_languages": null}, "macro.dbt.collect_freshness": {"name": "collect_freshness", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/freshness.sql", "original_file_path": "macros/adapters/freshness.sql", "unique_id": "macro.dbt.collect_freshness", "macro_sql": "{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter.dispatch('collect_freshness', 'dbt')(source, loaded_at_field, filter))}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__collect_freshness"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1495638, "supported_languages": null}, "macro.dbt.default__collect_freshness": {"name": "default__collect_freshness", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/freshness.sql", "original_file_path": "macros/adapters/freshness.sql", "unique_id": "macro.dbt.default__collect_freshness", "macro_sql": "{% macro default__collect_freshness(source, loaded_at_field, filter) %}\n {% call statement('collect_freshness', fetch_result=True, auto_begin=False) -%}\n select\n max({{ loaded_at_field }}) as max_loaded_at,\n {{ current_timestamp() }} as snapshotted_at\n from {{ source }}\n {% if filter %}\n where {{ filter }}\n {% endif %}\n {% endcall %}\n {{ return(load_result('collect_freshness')) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.149777, "supported_languages": null}, "macro.dbt.validate_sql": {"name": "validate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/validate_sql.sql", "original_file_path": "macros/adapters/validate_sql.sql", "unique_id": "macro.dbt.validate_sql", "macro_sql": "{% macro validate_sql(sql) -%}\n {{ return(adapter.dispatch('validate_sql', 'dbt')(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__validate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.149939, "supported_languages": null}, "macro.dbt.default__validate_sql": {"name": "default__validate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/validate_sql.sql", "original_file_path": "macros/adapters/validate_sql.sql", "unique_id": "macro.dbt.default__validate_sql", "macro_sql": "{% macro default__validate_sql(sql) -%}\n {% call statement('validate_sql') -%}\n explain {{ sql }}\n {% endcall %}\n {{ return(load_result('validate_sql')) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.150057, "supported_languages": null}, "macro.dbt.copy_grants": {"name": "copy_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.copy_grants", "macro_sql": "{% macro copy_grants() %}\n {{ return(adapter.dispatch('copy_grants', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__copy_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.151061, "supported_languages": null}, "macro.dbt.default__copy_grants": {"name": "default__copy_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__copy_grants", "macro_sql": "{% macro default__copy_grants() %}\n {{ return(True) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.151125, "supported_languages": null}, "macro.dbt.support_multiple_grantees_per_dcl_statement": {"name": "support_multiple_grantees_per_dcl_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.support_multiple_grantees_per_dcl_statement", "macro_sql": "{% macro support_multiple_grantees_per_dcl_statement() %}\n {{ return(adapter.dispatch('support_multiple_grantees_per_dcl_statement', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.151217, "supported_languages": null}, "macro.dbt.default__support_multiple_grantees_per_dcl_statement": {"name": "default__support_multiple_grantees_per_dcl_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__support_multiple_grantees_per_dcl_statement", "macro_sql": "\n\n{%- macro default__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(True) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1512809, "supported_languages": null}, "macro.dbt.should_revoke": {"name": "should_revoke", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.should_revoke", "macro_sql": "{% macro should_revoke(existing_relation, full_refresh_mode=True) %}\n\n {% if not existing_relation %}\n {#-- The table doesn't already exist, so no grants to copy over --#}\n {{ return(False) }}\n {% elif full_refresh_mode %}\n {#-- The object is being REPLACED -- whether grants are copied over depends on the value of user config --#}\n {{ return(copy_grants()) }}\n {% else %}\n {#-- The table is being merged/upserted/inserted -- grants will be carried over --#}\n {{ return(True) }}\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.copy_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1514611, "supported_languages": null}, "macro.dbt.get_show_grant_sql": {"name": "get_show_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_show_grant_sql", "macro_sql": "{% macro get_show_grant_sql(relation) %}\n {{ return(adapter.dispatch(\"get_show_grant_sql\", \"dbt\")(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_show_grant_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1515641, "supported_languages": null}, "macro.dbt.default__get_show_grant_sql": {"name": "default__get_show_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_show_grant_sql", "macro_sql": "{% macro default__get_show_grant_sql(relation) %}\n show grants on {{ relation }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.151621, "supported_languages": null}, "macro.dbt.get_grant_sql": {"name": "get_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_grant_sql", "macro_sql": "{% macro get_grant_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_grant_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_grant_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1517398, "supported_languages": null}, "macro.dbt.default__get_grant_sql": {"name": "default__get_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_grant_sql", "macro_sql": "\n\n{%- macro default__get_grant_sql(relation, privilege, grantees) -%}\n grant {{ privilege }} on {{ relation }} to {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.15185, "supported_languages": null}, "macro.dbt.get_revoke_sql": {"name": "get_revoke_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_revoke_sql", "macro_sql": "{% macro get_revoke_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_revoke_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_revoke_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.151973, "supported_languages": null}, "macro.dbt.default__get_revoke_sql": {"name": "default__get_revoke_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_revoke_sql", "macro_sql": "\n\n{%- macro default__get_revoke_sql(relation, privilege, grantees) -%}\n revoke {{ privilege }} on {{ relation }} from {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1522539, "supported_languages": null}, "macro.dbt.get_dcl_statement_list": {"name": "get_dcl_statement_list", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_dcl_statement_list", "macro_sql": "{% macro get_dcl_statement_list(relation, grant_config, get_dcl_macro) %}\n {{ return(adapter.dispatch('get_dcl_statement_list', 'dbt')(relation, grant_config, get_dcl_macro)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_dcl_statement_list"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.15238, "supported_languages": null}, "macro.dbt.default__get_dcl_statement_list": {"name": "default__get_dcl_statement_list", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_dcl_statement_list", "macro_sql": "\n\n{%- macro default__get_dcl_statement_list(relation, grant_config, get_dcl_macro) -%}\n {#\n -- Unpack grant_config into specific privileges and the set of users who need them granted/revoked.\n -- Depending on whether this database supports multiple grantees per statement, pass in the list of\n -- all grantees per privilege, or (if not) template one statement per privilege-grantee pair.\n -- `get_dcl_macro` will be either `get_grant_sql` or `get_revoke_sql`\n #}\n {%- set dcl_statements = [] -%}\n {%- for privilege, grantees in grant_config.items() %}\n {%- if support_multiple_grantees_per_dcl_statement() and grantees -%}\n {%- set dcl = get_dcl_macro(relation, privilege, grantees) -%}\n {%- do dcl_statements.append(dcl) -%}\n {%- else -%}\n {%- for grantee in grantees -%}\n {% set dcl = get_dcl_macro(relation, privilege, [grantee]) %}\n {%- do dcl_statements.append(dcl) -%}\n {% endfor -%}\n {%- endif -%}\n {%- endfor -%}\n {{ return(dcl_statements) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.support_multiple_grantees_per_dcl_statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.152739, "supported_languages": null}, "macro.dbt.call_dcl_statements": {"name": "call_dcl_statements", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.call_dcl_statements", "macro_sql": "{% macro call_dcl_statements(dcl_statement_list) %}\n {{ return(adapter.dispatch(\"call_dcl_statements\", \"dbt\")(dcl_statement_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__call_dcl_statements"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.152844, "supported_languages": null}, "macro.dbt.default__call_dcl_statements": {"name": "default__call_dcl_statements", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__call_dcl_statements", "macro_sql": "{% macro default__call_dcl_statements(dcl_statement_list) %}\n {#\n -- By default, supply all grant + revoke statements in a single semicolon-separated block,\n -- so that they're all processed together.\n\n -- Some databases do not support this. Those adapters will need to override this macro\n -- to run each statement individually.\n #}\n {% call statement('grants') %}\n {% for dcl_statement in dcl_statement_list %}\n {{ dcl_statement }};\n {% endfor %}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.152981, "supported_languages": null}, "macro.dbt.apply_grants": {"name": "apply_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.apply_grants", "macro_sql": "{% macro apply_grants(relation, grant_config, should_revoke) %}\n {{ return(adapter.dispatch(\"apply_grants\", \"dbt\")(relation, grant_config, should_revoke)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.153103, "supported_languages": null}, "macro.dbt.default__apply_grants": {"name": "default__apply_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__apply_grants", "macro_sql": "{% macro default__apply_grants(relation, grant_config, should_revoke=True) %}\n {#-- If grant_config is {} or None, this is a no-op --#}\n {% if grant_config %}\n {% if should_revoke %}\n {#-- We think previous grants may have carried over --#}\n {#-- Show current grants and calculate diffs --#}\n {% set current_grants_table = run_query(get_show_grant_sql(relation)) %}\n {% set current_grants_dict = adapter.standardize_grants_dict(current_grants_table) %}\n {% set needs_granting = diff_of_two_dicts(grant_config, current_grants_dict) %}\n {% set needs_revoking = diff_of_two_dicts(current_grants_dict, grant_config) %}\n {% if not (needs_granting or needs_revoking) %}\n {{ log('On ' ~ relation ~': All grants are in place, no revocation or granting needed.')}}\n {% endif %}\n {% else %}\n {#-- We don't think there's any chance of previous grants having carried over. --#}\n {#-- Jump straight to granting what the user has configured. --#}\n {% set needs_revoking = {} %}\n {% set needs_granting = grant_config %}\n {% endif %}\n {% if needs_granting or needs_revoking %}\n {% set revoke_statement_list = get_dcl_statement_list(relation, needs_revoking, get_revoke_sql) %}\n {% set grant_statement_list = get_dcl_statement_list(relation, needs_granting, get_grant_sql) %}\n {% set dcl_statement_list = revoke_statement_list + grant_statement_list %}\n {% if dcl_statement_list %}\n {{ call_dcl_statements(dcl_statement_list) }}\n {% endif %}\n {% endif %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.get_show_grant_sql", "macro.dbt.get_dcl_statement_list", "macro.dbt.call_dcl_statements"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.153685, "supported_languages": null}, "macro.dbt.get_show_sql": {"name": "get_show_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/show.sql", "original_file_path": "macros/adapters/show.sql", "unique_id": "macro.dbt.get_show_sql", "macro_sql": "{% macro get_show_sql(compiled_code, sql_header, limit) -%}\n {%- if sql_header -%}\n {{ sql_header }}\n {%- endif -%}\n {%- if limit is not none -%}\n {{ get_limit_subquery_sql(compiled_code, limit) }}\n {%- else -%}\n {{ compiled_code }}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_limit_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.153993, "supported_languages": null}, "macro.dbt.get_limit_subquery_sql": {"name": "get_limit_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/show.sql", "original_file_path": "macros/adapters/show.sql", "unique_id": "macro.dbt.get_limit_subquery_sql", "macro_sql": "{% macro get_limit_subquery_sql(sql, limit) %}\n {{ adapter.dispatch('get_limit_subquery_sql', 'dbt')(sql, limit) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_limit_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1540961, "supported_languages": null}, "macro.dbt.default__get_limit_subquery_sql": {"name": "default__get_limit_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/show.sql", "original_file_path": "macros/adapters/show.sql", "unique_id": "macro.dbt.default__get_limit_subquery_sql", "macro_sql": "{% macro default__get_limit_subquery_sql(sql, limit) %}\n select *\n from (\n {{ sql }}\n ) as model_limit_subq\n limit {{ limit }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.154171, "supported_languages": null}, "macro.dbt.alter_column_comment": {"name": "alter_column_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.alter_column_comment", "macro_sql": "{% macro alter_column_comment(relation, column_dict) -%}\n {{ return(adapter.dispatch('alter_column_comment', 'dbt')(relation, column_dict)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_column_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1545842, "supported_languages": null}, "macro.dbt.default__alter_column_comment": {"name": "default__alter_column_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.default__alter_column_comment", "macro_sql": "{% macro default__alter_column_comment(relation, column_dict) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_column_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.154679, "supported_languages": null}, "macro.dbt.alter_relation_comment": {"name": "alter_relation_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.alter_relation_comment", "macro_sql": "{% macro alter_relation_comment(relation, relation_comment) -%}\n {{ return(adapter.dispatch('alter_relation_comment', 'dbt')(relation, relation_comment)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_relation_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.154787, "supported_languages": null}, "macro.dbt.default__alter_relation_comment": {"name": "default__alter_relation_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.default__alter_relation_comment", "macro_sql": "{% macro default__alter_relation_comment(relation, relation_comment) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_relation_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.154879, "supported_languages": null}, "macro.dbt.persist_docs": {"name": "persist_docs", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.persist_docs", "macro_sql": "{% macro persist_docs(relation, model, for_relation=true, for_columns=true) -%}\n {{ return(adapter.dispatch('persist_docs', 'dbt')(relation, model, for_relation, for_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.15503, "supported_languages": null}, "macro.dbt.default__persist_docs": {"name": "default__persist_docs", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.default__persist_docs", "macro_sql": "{% macro default__persist_docs(relation, model, for_relation, for_columns) -%}\n {% if for_relation and config.persist_relation_docs() and model.description %}\n {% do run_query(alter_relation_comment(relation, model.description)) %}\n {% endif %}\n\n {% if for_columns and config.persist_column_docs() and model.columns %}\n {% do run_query(alter_column_comment(relation, model.columns)) %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.alter_relation_comment", "macro.dbt.alter_column_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1552908, "supported_languages": null}, "macro.dbt.get_catalog_relations": {"name": "get_catalog_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_catalog_relations", "macro_sql": "{% macro get_catalog_relations(information_schema, relations) -%}\n {{ return(adapter.dispatch('get_catalog_relations', 'dbt')(information_schema, relations)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.157108, "supported_languages": null}, "macro.dbt.default__get_catalog_relations": {"name": "default__get_catalog_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_catalog_relations", "macro_sql": "{% macro default__get_catalog_relations(information_schema, relations) -%}\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog_relations not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.157248, "supported_languages": null}, "macro.dbt.get_catalog": {"name": "get_catalog", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_catalog", "macro_sql": "{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter.dispatch('get_catalog', 'dbt')(information_schema, schemas)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.157362, "supported_languages": null}, "macro.dbt.default__get_catalog": {"name": "default__get_catalog", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_catalog", "macro_sql": "{% macro default__get_catalog(information_schema, schemas) -%}\n\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1575081, "supported_languages": null}, "macro.dbt.information_schema_name": {"name": "information_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.information_schema_name", "macro_sql": "{% macro information_schema_name(database) %}\n {{ return(adapter.dispatch('information_schema_name', 'dbt')(database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__information_schema_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1576068, "supported_languages": null}, "macro.dbt.default__information_schema_name": {"name": "default__information_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__information_schema_name", "macro_sql": "{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ database }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1576939, "supported_languages": null}, "macro.dbt.list_schemas": {"name": "list_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.list_schemas", "macro_sql": "{% macro list_schemas(database) -%}\n {{ return(adapter.dispatch('list_schemas', 'dbt')(database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__list_schemas"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.157791, "supported_languages": null}, "macro.dbt.default__list_schemas": {"name": "default__list_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__list_schemas", "macro_sql": "{% macro default__list_schemas(database) -%}\n {% set sql %}\n select distinct schema_name\n from {{ information_schema_name(database) }}.SCHEMATA\n where catalog_name ilike '{{ database }}'\n {% endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.information_schema_name", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.157921, "supported_languages": null}, "macro.dbt.check_schema_exists": {"name": "check_schema_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.check_schema_exists", "macro_sql": "{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter.dispatch('check_schema_exists', 'dbt')(information_schema, schema)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__check_schema_exists"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.158033, "supported_languages": null}, "macro.dbt.default__check_schema_exists": {"name": "default__check_schema_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__check_schema_exists", "macro_sql": "{% macro default__check_schema_exists(information_schema, schema) -%}\n {% set sql -%}\n select count(*)\n from {{ information_schema.replace(information_schema_view='SCHEMATA') }}\n where catalog_name='{{ information_schema.database }}'\n and schema_name='{{ schema }}'\n {%- endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.replace", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.158261, "supported_languages": null}, "macro.dbt.list_relations_without_caching": {"name": "list_relations_without_caching", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.list_relations_without_caching", "macro_sql": "{% macro list_relations_without_caching(schema_relation) %}\n {{ return(adapter.dispatch('list_relations_without_caching', 'dbt')(schema_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__list_relations_without_caching"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.158368, "supported_languages": null}, "macro.dbt.default__list_relations_without_caching": {"name": "default__list_relations_without_caching", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__list_relations_without_caching", "macro_sql": "{% macro default__list_relations_without_caching(schema_relation) %}\n {{ exceptions.raise_not_implemented(\n 'list_relations_without_caching macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.15846, "supported_languages": null}, "macro.dbt.get_relations": {"name": "get_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_relations", "macro_sql": "{% macro get_relations() %}\n {{ return(adapter.dispatch('get_relations', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.15855, "supported_languages": null}, "macro.dbt.default__get_relations": {"name": "default__get_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_relations", "macro_sql": "{% macro default__get_relations() %}\n {{ exceptions.raise_not_implemented(\n 'get_relations macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.158635, "supported_languages": null}, "macro.dbt.get_relation_last_modified": {"name": "get_relation_last_modified", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_relation_last_modified", "macro_sql": "{% macro get_relation_last_modified(information_schema, relations) %}\n {{ return(adapter.dispatch('get_relation_last_modified', 'dbt')(information_schema, relations)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_relation_last_modified"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.158745, "supported_languages": null}, "macro.dbt.default__get_relation_last_modified": {"name": "default__get_relation_last_modified", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_relation_last_modified", "macro_sql": "{% macro default__get_relation_last_modified(information_schema, relations) %}\n {{ exceptions.raise_not_implemented(\n 'get_relation_last_modified macro not implemented for adapter ' + adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.158838, "supported_languages": null}, "macro.dbt.get_columns_in_relation": {"name": "get_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_columns_in_relation", "macro_sql": "{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter.dispatch('get_columns_in_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.160141, "supported_languages": null}, "macro.dbt.default__get_columns_in_relation": {"name": "default__get_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_columns_in_relation", "macro_sql": "{% macro default__get_columns_in_relation(relation) -%}\n {{ exceptions.raise_not_implemented(\n 'get_columns_in_relation macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1602309, "supported_languages": null}, "macro.dbt.sql_convert_columns_in_relation": {"name": "sql_convert_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.sql_convert_columns_in_relation", "macro_sql": "{% macro sql_convert_columns_in_relation(table) -%}\n {% set columns = [] %}\n {% for row in table %}\n {% do columns.append(api.Column(*row)) %}\n {% endfor %}\n {{ return(columns) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.160395, "supported_languages": null}, "macro.dbt.get_empty_subquery_sql": {"name": "get_empty_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_empty_subquery_sql", "macro_sql": "{% macro get_empty_subquery_sql(select_sql, select_sql_header=none) -%}\n {{ return(adapter.dispatch('get_empty_subquery_sql', 'dbt')(select_sql, select_sql_header)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.160516, "supported_languages": null}, "macro.dbt.default__get_empty_subquery_sql": {"name": "default__get_empty_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_empty_subquery_sql", "macro_sql": "{% macro default__get_empty_subquery_sql(select_sql, select_sql_header=none) %}\n {%- if select_sql_header is not none -%}\n {{ select_sql_header }}\n {%- endif -%}\n select * from (\n {{ select_sql }}\n ) as __dbt_sbq\n where false\n limit 0\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.160634, "supported_languages": null}, "macro.dbt.get_empty_schema_sql": {"name": "get_empty_schema_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_empty_schema_sql", "macro_sql": "{% macro get_empty_schema_sql(columns) -%}\n {{ return(adapter.dispatch('get_empty_schema_sql', 'dbt')(columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_empty_schema_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1607318, "supported_languages": null}, "macro.dbt.default__get_empty_schema_sql": {"name": "default__get_empty_schema_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_empty_schema_sql", "macro_sql": "{% macro default__get_empty_schema_sql(columns) %}\n {%- set col_err = [] -%}\n {%- set col_naked_numeric = [] -%}\n select\n {% for i in columns %}\n {%- set col = columns[i] -%}\n {%- if col['data_type'] is not defined -%}\n {%- do col_err.append(col['name']) -%}\n {#-- If this column's type is just 'numeric' then it is missing precision/scale, raise a warning --#}\n {%- elif col['data_type'].strip().lower() in ('numeric', 'decimal', 'number') -%}\n {%- do col_naked_numeric.append(col['name']) -%}\n {%- endif -%}\n {% set col_name = adapter.quote(col['name']) if col.get('quote') else col['name'] %}\n {{ cast('null', col['data_type']) }} as {{ col_name }}{{ \", \" if not loop.last }}\n {%- endfor -%}\n {%- if (col_err | length) > 0 -%}\n {{ exceptions.column_type_missing(column_names=col_err) }}\n {%- elif (col_naked_numeric | length) > 0 -%}\n {{ exceptions.warn(\"Detected columns with numeric type and unspecified precision/scale, this can lead to unintended rounding: \" ~ col_naked_numeric ~ \"`\") }}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.161342, "supported_languages": null}, "macro.dbt.get_column_schema_from_query": {"name": "get_column_schema_from_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_column_schema_from_query", "macro_sql": "{% macro get_column_schema_from_query(select_sql, select_sql_header=none) -%}\n {% set columns = [] %}\n {# -- Using an 'empty subquery' here to get the same schema as the given select_sql statement, without necessitating a data scan.#}\n {% set sql = get_empty_subquery_sql(select_sql, select_sql_header) %}\n {% set column_schema = adapter.get_column_schema_from_query(sql) %}\n {{ return(column_schema) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.161526, "supported_languages": null}, "macro.dbt.get_columns_in_query": {"name": "get_columns_in_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_columns_in_query", "macro_sql": "{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter.dispatch('get_columns_in_query', 'dbt')(select_sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_columns_in_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1616309, "supported_languages": null}, "macro.dbt.default__get_columns_in_query": {"name": "default__get_columns_in_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_columns_in_query", "macro_sql": "{% macro default__get_columns_in_query(select_sql) %}\n {% call statement('get_columns_in_query', fetch_result=True, auto_begin=False) -%}\n {{ get_empty_subquery_sql(select_sql) }}\n {% endcall %}\n {{ return(load_result('get_columns_in_query').table.columns | map(attribute='name') | list) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.161817, "supported_languages": null}, "macro.dbt.alter_column_type": {"name": "alter_column_type", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.alter_column_type", "macro_sql": "{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter.dispatch('alter_column_type', 'dbt')(relation, column_name, new_column_type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_column_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.161943, "supported_languages": null}, "macro.dbt.default__alter_column_type": {"name": "default__alter_column_type", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__alter_column_type", "macro_sql": "{% macro default__alter_column_type(relation, column_name, new_column_type) -%}\n {#\n 1. Create a new column (w/ temp name and correct type)\n 2. Copy data over to it\n 3. Drop the existing column (cascade!)\n 4. Rename the new column to existing column\n #}\n {%- set tmp_column = column_name + \"__dbt_alter\" -%}\n\n {% call statement('alter_column_type') %}\n alter table {{ relation }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};\n update {{ relation }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};\n alter table {{ relation }} drop column {{ adapter.quote(column_name) }} cascade;\n alter table {{ relation }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}\n {% endcall %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.162252, "supported_languages": null}, "macro.dbt.alter_relation_add_remove_columns": {"name": "alter_relation_add_remove_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.alter_relation_add_remove_columns", "macro_sql": "{% macro alter_relation_add_remove_columns(relation, add_columns = none, remove_columns = none) -%}\n {{ return(adapter.dispatch('alter_relation_add_remove_columns', 'dbt')(relation, add_columns, remove_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1623921, "supported_languages": null}, "macro.dbt.default__alter_relation_add_remove_columns": {"name": "default__alter_relation_add_remove_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__alter_relation_add_remove_columns", "macro_sql": "{% macro default__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if add_columns is none %}\n {% set add_columns = [] %}\n {% endif %}\n {% if remove_columns is none %}\n {% set remove_columns = [] %}\n {% endif %}\n\n {% set sql -%}\n\n alter {{ relation.type }} {{ relation }}\n\n {% for column in add_columns %}\n add column {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}{{ ',' if add_columns and remove_columns }}\n\n {% for column in remove_columns %}\n drop column {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.162793, "supported_languages": null}, "macro.dbt.get_fixture_sql": {"name": "get_fixture_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/unit_test_sql/get_fixture_sql.sql", "original_file_path": "macros/unit_test_sql/get_fixture_sql.sql", "unique_id": "macro.dbt.get_fixture_sql", "macro_sql": "{% macro get_fixture_sql(rows, column_name_to_data_types) %}\n-- Fixture for {{ model.name }}\n{% set default_row = {} %}\n\n{%- if not column_name_to_data_types -%}\n{#-- Use defer_relation IFF it is available in the manifest and 'this' is missing from the database --#}\n{%- set this_or_defer_relation = defer_relation if (defer_relation and not load_relation(this)) else this -%}\n{%- set columns_in_relation = adapter.get_columns_in_relation(this_or_defer_relation) -%}\n\n{%- set column_name_to_data_types = {} -%}\n{%- for column in columns_in_relation -%}\n{#-- This needs to be a case-insensitive comparison --#}\n{%- do column_name_to_data_types.update({column.name|lower: column.data_type}) -%}\n{%- endfor -%}\n{%- endif -%}\n\n{%- if not column_name_to_data_types -%}\n {{ exceptions.raise_compiler_error(\"Not able to get columns for unit test '\" ~ model.name ~ \"' from relation \" ~ this ~ \" because the relation doesn't exist\") }}\n{%- endif -%}\n\n{%- for column_name, column_type in column_name_to_data_types.items() -%}\n {%- do default_row.update({column_name: (safe_cast(\"null\", column_type) | trim )}) -%}\n{%- endfor -%}\n\n\n{%- for row in rows -%}\n{%- set formatted_row = format_row(row, column_name_to_data_types) -%}\n{%- set default_row_copy = default_row.copy() -%}\n{%- do default_row_copy.update(formatted_row) -%}\nselect\n{%- for column_name, column_value in default_row_copy.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%}, {%- endif %}\n{%- endfor %}\n{%- if not loop.last %}\nunion all\n{% endif %}\n{%- endfor -%}\n\n{%- if (rows | length) == 0 -%}\n select\n {%- for column_name, column_value in default_row.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%},{%- endif %}\n {%- endfor %}\n limit 0\n{%- endif -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.load_relation", "macro.dbt.safe_cast", "macro.dbt.format_row"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.164727, "supported_languages": null}, "macro.dbt.get_expected_sql": {"name": "get_expected_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/unit_test_sql/get_fixture_sql.sql", "original_file_path": "macros/unit_test_sql/get_fixture_sql.sql", "unique_id": "macro.dbt.get_expected_sql", "macro_sql": "{% macro get_expected_sql(rows, column_name_to_data_types) %}\n\n{%- if (rows | length) == 0 -%}\n select * from dbt_internal_unit_test_actual\n limit 0\n{%- else -%}\n{%- for row in rows -%}\n{%- set formatted_row = format_row(row, column_name_to_data_types) -%}\nselect\n{%- for column_name, column_value in formatted_row.items() %} {{ column_value }} as {{ column_name }}{% if not loop.last -%}, {%- endif %}\n{%- endfor %}\n{%- if not loop.last %}\nunion all\n{% endif %}\n{%- endfor -%}\n{%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.format_row"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.165025, "supported_languages": null}, "macro.dbt.format_row": {"name": "format_row", "resource_type": "macro", "package_name": "dbt", "path": "macros/unit_test_sql/get_fixture_sql.sql", "original_file_path": "macros/unit_test_sql/get_fixture_sql.sql", "unique_id": "macro.dbt.format_row", "macro_sql": "\n\n{%- macro format_row(row, column_name_to_data_types) -%}\n {#-- generate case-insensitive formatted row --#}\n {% set formatted_row = {} %}\n {%- for column_name, column_value in row.items() -%}\n {% set column_name = column_name|lower %}\n\n {%- if column_name not in column_name_to_data_types %}\n {#-- if user-provided row contains column name that relation does not contain, raise an error --#}\n {% set fixture_name = \"expected output\" if model.resource_type == 'unit_test' else (\"'\" ~ model.name ~ \"'\") %}\n {{ exceptions.raise_compiler_error(\n \"Invalid column name: '\" ~ column_name ~ \"' in unit test fixture for \" ~ fixture_name ~ \".\"\n \"\\nAccepted columns for \" ~ fixture_name ~ \" are: \" ~ (column_name_to_data_types.keys()|list)\n ) }}\n {%- endif -%}\n\n {%- set column_type = column_name_to_data_types[column_name] %}\n\n {#-- sanitize column_value: wrap yaml strings in quotes, apply cast --#}\n {%- set column_value_clean = column_value -%}\n {%- if column_value is string -%}\n {%- set column_value_clean = dbt.string_literal(dbt.escape_single_quotes(column_value)) -%}\n {%- elif column_value is none -%}\n {%- set column_value_clean = 'null' -%}\n {%- endif -%}\n\n {%- set row_update = {column_name: safe_cast(column_value_clean, column_type) } -%}\n {%- do formatted_row.update(row_update) -%}\n {%- endfor -%}\n {{ return(formatted_row) }}\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.string_literal", "macro.dbt.escape_single_quotes", "macro.dbt.safe_cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.1656268, "supported_languages": null}, "macro.dbt.resolve_model_name": {"name": "resolve_model_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.resolve_model_name", "macro_sql": "{% macro resolve_model_name(input_model_name) %}\n {{ return(adapter.dispatch('resolve_model_name', 'dbt')(input_model_name)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.166603, "supported_languages": null}, "macro.dbt.default__resolve_model_name": {"name": "default__resolve_model_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.default__resolve_model_name", "macro_sql": "\n\n{%- macro default__resolve_model_name(input_model_name) -%}\n {{ input_model_name | string | replace('\"', '\\\"') }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.166689, "supported_languages": null}, "macro.dbt.build_ref_function": {"name": "build_ref_function", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.build_ref_function", "macro_sql": "{% macro build_ref_function(model) %}\n\n {%- set ref_dict = {} -%}\n {%- for _ref in model.refs -%}\n {% set _ref_args = [_ref.get('package'), _ref['name']] if _ref.get('package') else [_ref['name'],] %}\n {%- set resolved = ref(*_ref_args, v=_ref.get('version')) -%}\n {%- if _ref.get('version') -%}\n {% do _ref_args.extend([\"v\" ~ _ref['version']]) %}\n {%- endif -%}\n {%- do ref_dict.update({_ref_args | join('.'): resolve_model_name(resolved)}) -%}\n {%- endfor -%}\n\ndef ref(*args, **kwargs):\n refs = {{ ref_dict | tojson }}\n key = '.'.join(args)\n version = kwargs.get(\"v\") or kwargs.get(\"version\")\n if version:\n key += f\".v{version}\"\n dbt_load_df_function = kwargs.get(\"dbt_load_df_function\")\n return dbt_load_df_function(refs[key])\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.167119, "supported_languages": null}, "macro.dbt.build_source_function": {"name": "build_source_function", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.build_source_function", "macro_sql": "{% macro build_source_function(model) %}\n\n {%- set source_dict = {} -%}\n {%- for _source in model.sources -%}\n {%- set resolved = source(*_source) -%}\n {%- do source_dict.update({_source | join('.'): resolve_model_name(resolved)}) -%}\n {%- endfor -%}\n\ndef source(*args, dbt_load_df_function):\n sources = {{ source_dict | tojson }}\n key = '.'.join(args)\n return dbt_load_df_function(sources[key])\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.167352, "supported_languages": null}, "macro.dbt.build_config_dict": {"name": "build_config_dict", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.build_config_dict", "macro_sql": "{% macro build_config_dict(model) %}\n {%- set config_dict = {} -%}\n {% set config_dbt_used = zip(model.config.config_keys_used, model.config.config_keys_defaults) | list %}\n {%- for key, default in config_dbt_used -%}\n {# weird type testing with enum, would be much easier to write this logic in Python! #}\n {%- if key == \"language\" -%}\n {%- set value = \"python\" -%}\n {%- endif -%}\n {%- set value = model.config.get(key, default) -%}\n {%- do config_dict.update({key: value}) -%}\n {%- endfor -%}\nconfig_dict = {{ config_dict }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.167661, "supported_languages": null}, "macro.dbt.py_script_postfix": {"name": "py_script_postfix", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.py_script_postfix", "macro_sql": "{% macro py_script_postfix(model) %}\n# This part is user provided model code\n# you will need to copy the next section to run the code\n# COMMAND ----------\n# this part is dbt logic for get ref work, do not modify\n\n{{ build_ref_function(model ) }}\n{{ build_source_function(model ) }}\n{{ build_config_dict(model) }}\n\nclass config:\n def __init__(self, *args, **kwargs):\n pass\n\n @staticmethod\n def get(key, default=None):\n return config_dict.get(key, default)\n\nclass this:\n \"\"\"dbt.this() or dbt.this.identifier\"\"\"\n database = \"{{ this.database }}\"\n schema = \"{{ this.schema }}\"\n identifier = \"{{ this.identifier }}\"\n {% set this_relation_name = resolve_model_name(this) %}\n def __repr__(self):\n return '{{ this_relation_name }}'\n\n\nclass dbtObj:\n def __init__(self, load_df_function) -> None:\n self.source = lambda *args: source(*args, dbt_load_df_function=load_df_function)\n self.ref = lambda *args, **kwargs: ref(*args, **kwargs, dbt_load_df_function=load_df_function)\n self.config = config\n self.this = this()\n self.is_incremental = {{ is_incremental() }}\n\n# COMMAND ----------\n{{py_script_comment()}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.build_ref_function", "macro.dbt.build_source_function", "macro.dbt.build_config_dict", "macro.dbt.resolve_model_name", "macro.dbt.is_incremental", "macro.dbt.py_script_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.16792, "supported_languages": null}, "macro.dbt.py_script_comment": {"name": "py_script_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.py_script_comment", "macro_sql": "{%macro py_script_comment()%}\n{%endmacro%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.167965, "supported_languages": null}, "macro.dbt.test_unique": {"name": "test_unique", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_unique", "macro_sql": "{% test unique(model, column_name) %}\n {% set macro = adapter.dispatch('test_unique', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_unique"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.168278, "supported_languages": null}, "macro.dbt.test_not_null": {"name": "test_not_null", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_not_null", "macro_sql": "{% test not_null(model, column_name) %}\n {% set macro = adapter.dispatch('test_not_null', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_not_null"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.16842, "supported_languages": null}, "macro.dbt.test_accepted_values": {"name": "test_accepted_values", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_accepted_values", "macro_sql": "{% test accepted_values(model, column_name, values, quote=True) %}\n {% set macro = adapter.dispatch('test_accepted_values', 'dbt') %}\n {{ macro(model, column_name, values, quote) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_accepted_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.168587, "supported_languages": null}, "macro.dbt.test_relationships": {"name": "test_relationships", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_relationships", "macro_sql": "{% test relationships(model, column_name, to, field) %}\n {% set macro = adapter.dispatch('test_relationships', 'dbt') %}\n {{ macro(model, column_name, to, field) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_relationships"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1724092450.16875, "supported_languages": null}}, "docs": {"doc.dbt.__overview__": {"name": "__overview__", "resource_type": "doc", "package_name": "dbt", "path": "overview.md", "original_file_path": "docs/overview.md", "unique_id": "doc.dbt.__overview__", "block_contents": "### Welcome!\n\nWelcome to the auto-generated documentation for your dbt project!\n\n### Navigation\n\nYou can use the `Project` and `Database` navigation tabs on the left side of the window to explore the models\nin your project.\n\n#### Project Tab\nThe `Project` tab mirrors the directory structure of your dbt project. In this tab, you can see all of the\nmodels defined in your dbt project, as well as models imported from dbt packages.\n\n#### Database Tab\nThe `Database` tab also exposes your models, but in a format that looks more like a database explorer. This view\nshows relations (tables and views) grouped into database schemas. Note that ephemeral models are _not_ shown\nin this interface, as they do not exist in the database.\n\n### Graph Exploration\nYou can click the blue icon on the bottom-right corner of the page to view the lineage graph of your models.\n\nOn model pages, you'll see the immediate parents and children of the model you're exploring. By clicking the `Expand`\nbutton at the top-right of this lineage pane, you'll be able to see all of the models that are used to build,\nor are built from, the model you're exploring.\n\nOnce expanded, you'll be able to use the `--select` and `--exclude` model selection syntax to filter the\nmodels in the graph. For more information on model selection, check out the [dbt docs](https://docs.getdbt.com/docs/model-selection-syntax).\n\nNote that you can also right-click on models to interactively filter and explore the graph.\n\n---\n\n### More information\n\n- [What is dbt](https://docs.getdbt.com/docs/introduction)?\n- Read the [dbt viewpoint](https://docs.getdbt.com/docs/viewpoint)\n- [Installation](https://docs.getdbt.com/docs/installation)\n- Join the [dbt Community](https://www.getdbt.com/community/) for questions and discussion"}}, "exposures": {}, "metrics": {}, "groups": {}, "selectors": {}, "disabled": {}, "parent_map": {"operation.dbt_constraints.dbt_constraints-on-run-end-0": []}, "child_map": {"operation.dbt_constraints.dbt_constraints-on-run-end-0": []}, "group_map": {}, "saved_queries": {}, "semantic_models": {}, "unit_tests": {}} \ No newline at end of file diff --git a/docs/run_results.json b/docs/run_results.json index 9bff03a..7ce0a15 100644 --- a/docs/run_results.json +++ b/docs/run_results.json @@ -1 +1 @@ -{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/run-results/v4.json", "dbt_version": "1.3.2", "generated_at": "2023-01-20T04:30:03.161471Z", "invocation_id": "134cbac7-4598-4147-95e0-4a1ee1fd6018", "env": {}}, "results": [{"status": "success", "timing": [{"name": "compile", "started_at": "2023-01-20T04:30:03.148101Z", "completed_at": "2023-01-20T04:30:03.158655Z"}, {"name": "execute", "started_at": "2023-01-20T04:30:03.159021Z", "completed_at": "2023-01-20T04:30:03.159048Z"}], "thread_id": "Thread-1", "execution_time": 0.012279033660888672, "adapter_response": {}, "message": null, "failures": null, "unique_id": "operation.dbt_constraints.dbt_constraints-on-run-end-0"}], "elapsed_time": 0.02072310447692871, "args": {"write_json": true, "use_colors": true, "printer_width": 80, "version_check": true, "partial_parse": true, "static_parser": true, "profiles_dir": "/Users/dflippo/.dbt", "send_anonymous_usage_stats": true, "event_buffer_size": 100000, "quiet": false, "no_print": false, "cache_selected_only": false, "compile": true, "which": "generate", "rpc_method": "docs.generate", "indirect_selection": "eager"}} \ No newline at end of file +{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/run-results/v6.json", "dbt_version": "1.8.5", "generated_at": "2024-08-19T18:34:12.756239Z", "invocation_id": "6248ccf8-48d0-470c-b010-2db8eb51c482", "env": {}}, "results": [{"status": "success", "timing": [{"name": "compile", "started_at": "2024-08-19T18:34:12.748983Z", "completed_at": "2024-08-19T18:34:12.754902Z"}, {"name": "execute", "started_at": "2024-08-19T18:34:12.755039Z", "completed_at": "2024-08-19T18:34:12.755046Z"}], "thread_id": "Thread-1 (worker)", "execution_time": 0.006446123123168945, "adapter_response": {}, "message": null, "failures": null, "unique_id": "operation.dbt_constraints.dbt_constraints-on-run-end-0", "compiled": true, "compiled_code": "", "relation_name": null}], "elapsed_time": 0.00990605354309082, "args": {"show_resource_report": false, "log_level": "info", "populate_cache": true, "warn_error_options": {"include": [], "exclude": []}, "version_check": true, "use_colors_file": true, "exclude": [], "quiet": false, "printer_width": 80, "defer": false, "source_freshness_run_project_hooks": false, "write_json": true, "require_explicit_package_overrides_for_builtin_materializations": true, "macro_debugging": false, "log_format_file": "debug", "profiles_dir": "/Users/dflippo/.dbt", "static_parser": true, "invocation_command": "dbt docs generate", "strict_mode": false, "log_path": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints/logs", "partial_parse": true, "project_dir": "/Users/dflippo/Documents/GitHub/Snowflake-Labs/dbt_constraints", "enable_legacy_logger": false, "send_anonymous_usage_stats": true, "print": true, "empty_catalog": false, "indirect_selection": "eager", "log_level_file": "debug", "vars": {}, "log_file_max_bytes": 10485760, "log_format": "default", "favor_state": false, "introspect": true, "use_colors": true, "partial_parse_file_diff": true, "require_resource_names_without_spaces": false, "compile": true, "cache_selected_only": false, "select": [], "static": false, "which": "generate"}} \ No newline at end of file diff --git a/docs/semantic_manifest.json b/docs/semantic_manifest.json new file mode 100644 index 0000000..a40b829 --- /dev/null +++ b/docs/semantic_manifest.json @@ -0,0 +1 @@ +{"semantic_models": [], "metrics": [], "project_configuration": {"time_spine_table_configurations": [], "metadata": null, "dsi_package_version": {"major_version": "0", "minor_version": "5", "patch_version": "1"}}, "saved_queries": []} \ No newline at end of file From eb424df96e7343d13dfbcd0e08f51a8671238cd0 Mon Sep 17 00:00:00 2001 From: Dan Flippo Date: Mon, 19 Aug 2024 16:27:48 -0400 Subject: [PATCH 4/5] Test always_create_constraint --- integration_tests/dbt_project.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_tests/dbt_project.yml b/integration_tests/dbt_project.yml index b18c802..e2fdcdc 100644 --- a/integration_tests/dbt_project.yml +++ b/integration_tests/dbt_project.yml @@ -52,8 +52,8 @@ seeds: #+full_refresh: false tests: - +dbt_constraints_integration_tests: - #+always_create_constraint: true + dbt_constraints_integration_tests: + +always_create_constraint: true # These configuration settings disable running tests or just constraints by path # +enabled: false #+dbt_constraints_enabled: false From 682e5ef799bfee1cf87daf3635b4b10e0ec3679d Mon Sep 17 00:00:00 2001 From: Dan Flippo Date: Mon, 19 Aug 2024 16:28:14 -0400 Subject: [PATCH 5/5] Increase dbt_utils version for integration tests --- integration_tests/packages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_tests/packages.yml b/integration_tests/packages.yml index 091d928..b11d59b 100644 --- a/integration_tests/packages.yml +++ b/integration_tests/packages.yml @@ -2,6 +2,6 @@ packages: # We will test unique keys based on dbt_utils.unique_combination_of_columns - package: dbt-labs/dbt_utils - version: [">=0.8.0"] + version: [">=1.2.0"] - local: ../