From e8ad68f06a251cb0ce65740954160055e0dacce5 Mon Sep 17 00:00:00 2001 From: Jacob Beck Date: Thu, 19 Mar 2020 15:26:19 -0600 Subject: [PATCH] When a user calls the 'get-manifest' API call, compile all the full project and return the compiled manifest from memory. 'get-manifest' returns an async ID, just like the existing compile/run/etc --- CHANGELOG.md | 3 +++ core/dbt/contracts/rpc.py | 38 +++++++++++++++++++++++++++ core/dbt/rpc/builtins.py | 6 +++++ core/dbt/rpc/wtf.py | 1 + core/dbt/task/rpc/project_commands.py | 25 ++++++++++++++++++ test/rpc/test_base.py | 29 ++++++++++++++++++++ test/rpc/util.py | 5 ++++ 7 files changed, 107 insertions(+) create mode 100644 core/dbt/rpc/wtf.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f4718345d0..81ff2181933 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## dbt next (release TBD) +### Features +- Added a `get-manifest` API call. ([#2168](https://github.com/fishtown-analytics/dbt/issues/2168), [#2232](https://github.com/fishtown-analytics/dbt/pull/2232)) + ### Fixes - When a jinja value is undefined, give a helpful error instead of failing with cryptic "cannot pickle ParserMacroCapture" errors ([#2110](https://github.com/fishtown-analytics/dbt/issues/2110), [#2184](https://github.com/fishtown-analytics/dbt/pull/2184)) diff --git a/core/dbt/contracts/rpc.py b/core/dbt/contracts/rpc.py index 06e41e84c64..132ce3bf1af 100644 --- a/core/dbt/contracts/rpc.py +++ b/core/dbt/contracts/rpc.py @@ -9,6 +9,7 @@ from hologram.helpers import StrEnum from dbt.contracts.graph.compiled import CompileResultNode +from dbt.contracts.graph.manifest import WritableManifest from dbt.contracts.results import ( TimingInfo, CatalogResults, @@ -143,8 +144,13 @@ class RPCSourceFreshnessParameters(RPCParameters): select: Union[None, str, List[str]] = None +@dataclass +class GetManifestParameters(RPCParameters): + pass + # Outputs + @dataclass class RemoteResult(JsonSchemaMixin): logs: List[LogMessage] @@ -322,6 +328,11 @@ class KillResult(RemoteResult): logs: List[LogMessage] = field(default_factory=list) +@dataclass +class GetManifestResult(RemoteResult): + manifest: WritableManifest + + # this is kind of carefuly structured: BlocksManifestTasks is implied by # RequiresConfigReloadBefore and RequiresManifestReloadAfter class RemoteMethodFlags(enum.Flag): @@ -526,8 +537,34 @@ class PollInProgressResult(PollResult): pass +@dataclass +class PollGetManifestResult(GetManifestResult, PollResult): + state: TaskHandlerState = field( + metadata=restrict_to(TaskHandlerState.Success, + TaskHandlerState.Failed), + ) + + @classmethod + def from_result( + cls: Type['PollCatalogCompleteResult'], + base: GetManifestResult, + tags: TaskTags, + timing: TaskTiming, + logs: List[LogMessage], + ) -> 'PollCatalogCompleteResult': + return cls( + manifest=base.manifest, + logs=logs, + tags=tags, + state=timing.state, + start=timing.start, + end=timing.end, + elapsed=timing.elapsed, + ) + # Manifest parsing types + class ManifestStatus(StrEnum): Init = 'init' Compiling = 'compiling' @@ -542,3 +579,4 @@ class LastParse(RemoteResult): error: Optional[Dict[str, Any]] = None timestamp: datetime = field(default_factory=datetime.utcnow) pid: int = field(default_factory=os.getpid) + diff --git a/core/dbt/rpc/builtins.py b/core/dbt/rpc/builtins.py index 25b696fc0e0..727950ad83a 100644 --- a/core/dbt/rpc/builtins.py +++ b/core/dbt/rpc/builtins.py @@ -10,6 +10,7 @@ LastParse, GCParameters, GCResult, + GetManifestResult, KillParameters, KillResult, KillResultStatus, @@ -27,6 +28,7 @@ PollInProgressResult, PollKilledResult, PollExecuteCompleteResult, + PollGetManifestResult, PollRunCompleteResult, PollCompileCompleteResult, PollCatalogCompleteResult, @@ -34,6 +36,7 @@ PollRunOperationCompleteResult, TaskHandlerState, TaskTiming, + ManifestStatus, ) from dbt.logger import LogMessage from dbt.rpc.error import dbt_error, RPCException @@ -144,6 +147,7 @@ def poll_complete( PollCatalogCompleteResult, PollRemoteEmptyCompleteResult, PollRunOperationCompleteResult, + PollGetManifestResult ]] if isinstance(result, RemoteExecutionResult): @@ -159,6 +163,8 @@ def poll_complete( cls = PollRemoteEmptyCompleteResult elif isinstance(result, RemoteRunOperationResult): cls = PollRunOperationCompleteResult + elif isinstance(result, GetManifestResult): + cls = PollGetManifestResult else: raise dbt.exceptions.InternalException( 'got invalid result in poll_complete: {}'.format(result) diff --git a/core/dbt/rpc/wtf.py b/core/dbt/rpc/wtf.py new file mode 100644 index 00000000000..aed9afa3104 --- /dev/null +++ b/core/dbt/rpc/wtf.py @@ -0,0 +1 @@ +wtf = {'state': 'failed', 'start': '2020-03-23T17:57:17.078997Z', 'end': '2020-03-23T17:57:17.217053Z', 'elapsed': 0.138056, 'logs': [{'timestamp': '2020-03-23T17:57:17.090809Z', 'message': 'Found 1 model, 0 tests, 0 snapshots, 0 analyses, 127 macros, 0 operations, 0 seed files, 0 sources', 'channel': 'dbt', 'level': 11, 'levelname': 'INFO', 'thread_name': 'Thread-18', 'process': 124, 'extra': {'request_id': 1, 'method': 'get-manifest', 'context': 'request', 'addr': '127.0.0.1', 'http_method': 'POST', 'run_state': 'internal'}, 'exc_info': None}, {'timestamp': '2020-03-23T17:57:17.093173Z', 'message': '', 'channel': 'dbt', 'level': 11, 'levelname': 'INFO', 'thread_name': 'Thread-18', 'process': 124, 'extra': {'text_only': True, 'request_id': 1, 'method': 'get-manifest', 'context': 'request', 'addr': '127.0.0.1', 'http_method': 'POST', 'run_state': 'internal'}, 'exc_info': None}, {'timestamp': '2020-03-23T17:57:17.093934Z', 'message': "17:57:17 | Concurrency: 4 threads (target='default')", 'channel': 'dbt', 'level': 11, 'levelname': 'INFO', 'thread_name': 'Thread-18', 'process': 124, 'extra': {'node_count': 1, 'request_id': 1, 'method': 'get-manifest', 'context': 'request', 'addr': '127.0.0.1', 'http_method': 'POST', 'run_state': 'internal'}, 'exc_info': None}, {'timestamp': '2020-03-23T17:57:17.094081Z', 'message': '17:57:17 | ', 'channel': 'dbt', 'level': 11, 'levelname': 'INFO', 'thread_name': 'Thread-18', 'process': 124, 'extra': {'text_only': True, 'request_id': 1, 'method': 'get-manifest', 'context': 'request', 'addr': '127.0.0.1', 'http_method': 'POST', 'run_state': 'internal'}, 'exc_info': None}, {'timestamp': '2020-03-23T17:57:17.099021Z', 'message': 'Began running node model.test.my_model', 'channel': 'dbt', 'level': 10, 'levelname': 'DEBUG', 'thread_name': 'Thread-19', 'process': 124, 'extra': {'node_alias': 'my_model', 'node_schema': 'test15849862311293', 'node_database': 'dbt', 'node_path': 'models/my_model.sql', 'node_name': 'my_model', 'resource_type': 'model', 'node_index': 1, 'node_materialized': 'view', 'node_started_at': '2020-03-23T17:57:17.099066', 'unique_id': 'model.test.my_model', 'run_state': 'running', 'context': 'server'}, 'exc_info': None}, {'timestamp': '2020-03-23T17:57:17.100236Z', 'message': 'Acquiring new postgres connection "model.test.my_model".', 'channel': 'dbt', 'level': 10, 'levelname': 'DEBUG', 'thread_name': 'Thread-19', 'process': 124, 'extra': {'unique_id': 'model.test.my_model', 'run_state': 'running', 'context': 'server'}, 'exc_info': None}, {'timestamp': '2020-03-23T17:57:17.100371Z', 'message': 'Opening a new connection, currently in state init', 'channel': 'dbt', 'level': 10, 'levelname': 'DEBUG', 'thread_name': 'Thread-19', 'process': 124, 'extra': {'unique_id': 'model.test.my_model', 'run_state': 'running', 'context': 'server'}, 'exc_info': None}, {'timestamp': '2020-03-23T17:57:17.100611Z', 'message': 'Compiling model.test.my_model', 'channel': 'dbt', 'level': 10, 'levelname': 'DEBUG', 'thread_name': 'Thread-19', 'process': 124, 'extra': {'unique_id': 'model.test.my_model', 'run_state': 'running', 'context': 'server'}, 'exc_info': None}, {'timestamp': '2020-03-23T17:57:17.120831Z', 'message': 'Writing injected SQL for node "model.test.my_model"', 'channel': 'dbt', 'level': 10, 'levelname': 'DEBUG', 'thread_name': 'Thread-19', 'process': 124, 'extra': {'unique_id': 'model.test.my_model', 'run_state': 'running', 'context': 'server'}, 'exc_info': None}, {'timestamp': '2020-03-23T17:57:17.121690Z', 'message': 'finished collecting timing info', 'channel': 'dbt', 'level': 10, 'levelname': 'DEBUG', 'thread_name': 'Thread-19', 'process': 124, 'extra': {'timing_info': {'name': 'compile', 'started_at': '2020-03-23T17:57:17.100573Z', 'completed_at': '2020-03-23T17:57:17.121634Z'}, 'json_only': True, 'unique_id': 'model.test.my_model', 'run_state': 'running', 'context': 'server'}, 'exc_info': None}, {'timestamp': '2020-03-23T17:57:17.122119Z', 'message': 'finished collecting timing info', 'channel': 'dbt', 'level': 10, 'levelname': 'DEBUG', 'thread_name': 'Thread-19', 'process': 124, 'extra': {'timing_info': {'name': 'execute', 'started_at': '2020-03-23T17:57:17.122060Z', 'completed_at': '2020-03-23T17:57:17.122088Z'}, 'json_only': True, 'unique_id': 'model.test.my_model', 'run_state': 'running', 'context': 'server'}, 'exc_info': None}, {'timestamp': '2020-03-23T17:57:17.122785Z', 'message': 'Finished running node model.test.my_model', 'channel': 'dbt', 'level': 10, 'levelname': 'DEBUG', 'thread_name': 'Thread-19', 'process': 124, 'extra': {'node_status': 'passed', 'node_finished_at': '2020-03-23T17:57:17.122799', 'unique_id': 'model.test.my_model', 'run_state': 'running', 'context': 'server'}, 'exc_info': None}, {'timestamp': '2020-03-23T17:57:17.201733Z', 'message': "Connection 'model.test.my_model' was properly closed.", 'channel': 'dbt', 'level': 10, 'levelname': 'DEBUG', 'thread_name': 'Thread-18', 'process': 124, 'extra': {'request_id': 1, 'method': 'get-manifest', 'context': 'request', 'addr': '127.0.0.1', 'http_method': 'POST', 'run_state': 'internal'}, 'exc_info': None}, {'timestamp': '2020-03-23T17:57:17.208672Z', 'message': '17:57:17 | Done.', 'channel': 'dbt', 'level': 11, 'levelname': 'INFO', 'thread_name': 'Thread-18', 'process': 124, 'extra': {'request_id': 1, 'method': 'get-manifest', 'context': 'request', 'addr': '127.0.0.1', 'http_method': 'POST', 'run_state': 'internal'}, 'exc_info': None}], 'tags': None, 'manifest': {'nodes': {'model.test.my_model': {'raw_sql': 'select 1 as id', 'database': 'dbt', 'schema': 'test15849862311293', 'fqn': ['test', 'my_model'], 'unique_id': 'model.test.my_model', 'package_name': 'test', 'root_path': '/tmp/pytest-of-dbt_test_user/pytest-0/popen-gw0/test_get_manifest0/project', 'path': 'my_model.sql', 'original_file_path': 'models/my_model.sql', 'name': 'my_model', 'resource_type': 'model', 'alias': 'my_model', 'config': {'enabled': True, 'materialized': 'view', 'persist_docs': {}, 'post-hook': [], 'pre-hook': [], 'vars': {}, 'quoting': {}, 'column_types': {}, 'tags': []}, 'tags': [], 'refs': [], 'sources': [], 'depends_on': {'macros': [], 'nodes': []}, 'description': '', 'columns': {}, 'meta': {}, 'docs': {'show': True}, 'patch_path': None, 'build_path': 'target/compiled/test/my_model.sql', 'compiled': True, 'compiled_sql': 'select 1 as id', 'extra_ctes_injected': True, 'extra_ctes': [], 'injected_sql': 'select 1 as id', 'wrapped_sql': None}}, 'macros': {'macro.dbt.statement': {'raw_sql': '{% macro statement(name=None, fetch_result=False, auto_begin=True) -%}\n {%- if execute: -%}\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 {%- set status, res = adapter.execute(sql, auto_begin=auto_begin, fetch=fetch_result) -%}\n {%- if name is not none -%}\n {{ store_result(name, status=status, agate_table=res) }}\n {%- endif -%}\n\n {%- endif -%}\n{%- endmacro %}\n\n{% macro noop_statement(name=None, status=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_result(name, status=status, agate_table=res) }}\n {%- endif -%}\n\n{%- endmacro %}', 'unique_id': 'macro.dbt.statement', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/core.sql', 'original_file_path': 'macros/core.sql', 'resource_type': 'macro', 'name': 'statement', 'macro_sql': '{% macro statement(name=None, fetch_result=False, auto_begin=True) -%}\n {%- if execute: -%}\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 {%- set status, res = adapter.execute(sql, auto_begin=auto_begin, fetch=fetch_result) -%}\n {%- if name is not none -%}\n {{ store_result(name, status=status, agate_table=res) }}\n {%- endif -%}\n\n {%- endif -%}\n{%- endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.noop_statement': {'raw_sql': '{% macro statement(name=None, fetch_result=False, auto_begin=True) -%}\n {%- if execute: -%}\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 {%- set status, res = adapter.execute(sql, auto_begin=auto_begin, fetch=fetch_result) -%}\n {%- if name is not none -%}\n {{ store_result(name, status=status, agate_table=res) }}\n {%- endif -%}\n\n {%- endif -%}\n{%- endmacro %}\n\n{% macro noop_statement(name=None, status=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_result(name, status=status, agate_table=res) }}\n {%- endif -%}\n\n{%- endmacro %}', 'unique_id': 'macro.dbt.noop_statement', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/core.sql', 'original_file_path': 'macros/core.sql', 'resource_type': 'macro', 'name': 'noop_statement', 'macro_sql': '{% macro noop_statement(name=None, status=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_result(name, status=status, agate_table=res) }}\n {%- endif -%}\n\n{%- endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.run_hooks': {'raw_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 %}\n\n\n{% macro column_list(columns) %}\n {%- for col in columns %}\n {{ col.name }} {% if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro column_list_for_create_table(columns) %}\n {%- for col in columns %}\n {{ col.name }} {{ col.data_type }} {%- if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({"sql": sql, "transaction": inside_transaction}) }}\n{% endmacro %}\n\n\n{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}\n\n\n{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}\n\n\n{% macro load_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt.run_hooks', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/helpers.sql', 'original_file_path': 'macros/materializations/helpers.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.column_list': {'raw_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 %}\n\n\n{% macro column_list(columns) %}\n {%- for col in columns %}\n {{ col.name }} {% if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro column_list_for_create_table(columns) %}\n {%- for col in columns %}\n {{ col.name }} {{ col.data_type }} {%- if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({"sql": sql, "transaction": inside_transaction}) }}\n{% endmacro %}\n\n\n{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}\n\n\n{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}\n\n\n{% macro load_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt.column_list', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/helpers.sql', 'original_file_path': 'macros/materializations/helpers.sql', 'resource_type': 'macro', 'name': 'column_list', 'macro_sql': '{% macro column_list(columns) %}\n {%- for col in columns %}\n {{ col.name }} {% if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.column_list_for_create_table': {'raw_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 %}\n\n\n{% macro column_list(columns) %}\n {%- for col in columns %}\n {{ col.name }} {% if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro column_list_for_create_table(columns) %}\n {%- for col in columns %}\n {{ col.name }} {{ col.data_type }} {%- if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({"sql": sql, "transaction": inside_transaction}) }}\n{% endmacro %}\n\n\n{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}\n\n\n{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}\n\n\n{% macro load_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt.column_list_for_create_table', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/helpers.sql', 'original_file_path': 'macros/materializations/helpers.sql', 'resource_type': 'macro', 'name': 'column_list_for_create_table', 'macro_sql': '{% macro column_list_for_create_table(columns) %}\n {%- for col in columns %}\n {{ col.name }} {{ col.data_type }} {%- if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.make_hook_config': {'raw_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 %}\n\n\n{% macro column_list(columns) %}\n {%- for col in columns %}\n {{ col.name }} {% if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro column_list_for_create_table(columns) %}\n {%- for col in columns %}\n {{ col.name }} {{ col.data_type }} {%- if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({"sql": sql, "transaction": inside_transaction}) }}\n{% endmacro %}\n\n\n{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}\n\n\n{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}\n\n\n{% macro load_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt.make_hook_config', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/helpers.sql', 'original_file_path': 'macros/materializations/helpers.sql', 'resource_type': 'macro', 'name': 'make_hook_config', 'macro_sql': '{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({"sql": sql, "transaction": inside_transaction}) }}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.before_begin': {'raw_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 %}\n\n\n{% macro column_list(columns) %}\n {%- for col in columns %}\n {{ col.name }} {% if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro column_list_for_create_table(columns) %}\n {%- for col in columns %}\n {{ col.name }} {{ col.data_type }} {%- if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({"sql": sql, "transaction": inside_transaction}) }}\n{% endmacro %}\n\n\n{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}\n\n\n{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}\n\n\n{% macro load_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt.before_begin', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/helpers.sql', 'original_file_path': 'macros/materializations/helpers.sql', 'resource_type': 'macro', 'name': 'before_begin', 'macro_sql': '{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.in_transaction': {'raw_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 %}\n\n\n{% macro column_list(columns) %}\n {%- for col in columns %}\n {{ col.name }} {% if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro column_list_for_create_table(columns) %}\n {%- for col in columns %}\n {{ col.name }} {{ col.data_type }} {%- if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({"sql": sql, "transaction": inside_transaction}) }}\n{% endmacro %}\n\n\n{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}\n\n\n{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}\n\n\n{% macro load_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt.in_transaction', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/helpers.sql', 'original_file_path': 'macros/materializations/helpers.sql', 'resource_type': 'macro', 'name': 'in_transaction', 'macro_sql': '{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.after_commit': {'raw_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 %}\n\n\n{% macro column_list(columns) %}\n {%- for col in columns %}\n {{ col.name }} {% if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro column_list_for_create_table(columns) %}\n {%- for col in columns %}\n {{ col.name }} {{ col.data_type }} {%- if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({"sql": sql, "transaction": inside_transaction}) }}\n{% endmacro %}\n\n\n{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}\n\n\n{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}\n\n\n{% macro load_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt.after_commit', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/helpers.sql', 'original_file_path': 'macros/materializations/helpers.sql', 'resource_type': 'macro', 'name': 'after_commit', 'macro_sql': '{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.drop_relation_if_exists': {'raw_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 %}\n\n\n{% macro column_list(columns) %}\n {%- for col in columns %}\n {{ col.name }} {% if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro column_list_for_create_table(columns) %}\n {%- for col in columns %}\n {{ col.name }} {{ col.data_type }} {%- if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({"sql": sql, "transaction": inside_transaction}) }}\n{% endmacro %}\n\n\n{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}\n\n\n{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}\n\n\n{% macro load_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt.drop_relation_if_exists', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/helpers.sql', 'original_file_path': 'macros/materializations/helpers.sql', 'resource_type': 'macro', '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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.load_relation': {'raw_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 %}\n\n\n{% macro column_list(columns) %}\n {%- for col in columns %}\n {{ col.name }} {% if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro column_list_for_create_table(columns) %}\n {%- for col in columns %}\n {{ col.name }} {{ col.data_type }} {%- if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}\n\n\n{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({"sql": sql, "transaction": inside_transaction}) }}\n{% endmacro %}\n\n\n{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}\n\n\n{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}\n\n\n{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}\n\n\n{% macro load_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt.load_relation', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/helpers.sql', 'original_file_path': 'macros/materializations/helpers.sql', 'resource_type': 'macro', 'name': 'load_relation', 'macro_sql': '{% macro load_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.snapshot_merge_sql': {'raw_sql': "{% macro snapshot_merge_sql(target, source, insert_cols) -%}\n {{ adapter_macro('snapshot_merge_sql', target, source, insert_cols) }}\n{%- endmacro %}\n\n\n{% 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 = 'update'\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 %}", 'unique_id': 'macro.dbt.snapshot_merge_sql', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/snapshot_merge.sql', 'original_file_path': 'macros/materializations/snapshot/snapshot_merge.sql', 'resource_type': 'macro', 'name': 'snapshot_merge_sql', 'macro_sql': "{% macro snapshot_merge_sql(target, source, insert_cols) -%}\n {{ adapter_macro('snapshot_merge_sql', target, source, insert_cols) }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__snapshot_merge_sql': {'raw_sql': "{% macro snapshot_merge_sql(target, source, insert_cols) -%}\n {{ adapter_macro('snapshot_merge_sql', target, source, insert_cols) }}\n{%- endmacro %}\n\n\n{% 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 = 'update'\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 %}", 'unique_id': 'macro.dbt.default__snapshot_merge_sql', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/snapshot_merge.sql', 'original_file_path': 'macros/materializations/snapshot/snapshot_merge.sql', 'resource_type': 'macro', '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 = 'update'\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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.strategy_dispatch': {'raw_sql': '{#\n Dispatch strategies by name, optionally qualified to a package\n#}\n{% 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 %}\n\n\n{#\n Create SCD Hash SQL fields cross-db\n#}\n{% macro snapshot_hash_arguments(args) -%}\n {{ adapter_macro(\'snapshot_hash_arguments\', args) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{#\n Get the current time cross-db\n#}\n{% macro snapshot_get_time() -%}\n {{ adapter_macro(\'snapshot_get_time\') }}\n{%- endmacro %}\n\n{% macro default__snapshot_get_time() -%}\n {{ current_timestamp() }}\n{%- endmacro %}\n\n\n{#\n Core strategy definitions\n#}\n{% 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\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.{{ updated_at }} < {{ 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 }) %}\n{% endmacro %}\n\n\n{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter_macro(\'snapshot_string_as_time\', timestamp) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}\n {%- set query_columns = get_columns_in_query(node[\'injected_sql\']) -%}\n {%- if not target_exists -%}\n {# no table yet -> return whatever the query does #}\n {{ return([false, query_columns]) }}\n {%- endif -%}\n {# handle any schema changes #}\n {%- set target_table = node.get(\'alias\', node.get(\'name\')) -%}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=target_table) -%}\n {%- set existing_cols = get_columns_in_query(\'select * from \' ~ target_relation) -%}\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(col) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return([ns.column_added, intersection]) }}\n{%- endmacro %}\n\n\n{% 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 select_current_time -%}\n select {{ snapshot_get_time() }} as snapshot_start\n {%- endset %}\n\n {# don\'t access the column by name, to avoid dealing with casing issues on snowflake #}\n {%- set now = run_query(select_current_time)[0][0] -%}\n {% if now is none or now is undefined -%}\n {%- do exceptions.raise_compiler_error(\'Could not get a snapshot start time from the database\') -%}\n {%- endif %}\n {% set updated_at = snapshot_string_as_time(now) %}\n\n {% set column_added = false %}\n\n {% if check_cols_config == \'all\' %}\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists) %}\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {% set check_cols = check_cols_config %}\n {% else %}\n {% do exceptions.raise_compiler_error("Invalid value for \'check_cols\': " ~ check_cols_config) %}\n {% endif %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n TRUE\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n ({{ snapshotted_rel }}.{{ col }} is null) != ({{ current_rel }}.{{ col }} is null)\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 }) %}\n{% endmacro %}', 'unique_id': 'macro.dbt.strategy_dispatch', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/strategies.sql', 'original_file_path': 'macros/materializations/snapshot/strategies.sql', 'resource_type': 'macro', '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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.snapshot_hash_arguments': {'raw_sql': '{#\n Dispatch strategies by name, optionally qualified to a package\n#}\n{% 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 %}\n\n\n{#\n Create SCD Hash SQL fields cross-db\n#}\n{% macro snapshot_hash_arguments(args) -%}\n {{ adapter_macro(\'snapshot_hash_arguments\', args) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{#\n Get the current time cross-db\n#}\n{% macro snapshot_get_time() -%}\n {{ adapter_macro(\'snapshot_get_time\') }}\n{%- endmacro %}\n\n{% macro default__snapshot_get_time() -%}\n {{ current_timestamp() }}\n{%- endmacro %}\n\n\n{#\n Core strategy definitions\n#}\n{% 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\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.{{ updated_at }} < {{ 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 }) %}\n{% endmacro %}\n\n\n{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter_macro(\'snapshot_string_as_time\', timestamp) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}\n {%- set query_columns = get_columns_in_query(node[\'injected_sql\']) -%}\n {%- if not target_exists -%}\n {# no table yet -> return whatever the query does #}\n {{ return([false, query_columns]) }}\n {%- endif -%}\n {# handle any schema changes #}\n {%- set target_table = node.get(\'alias\', node.get(\'name\')) -%}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=target_table) -%}\n {%- set existing_cols = get_columns_in_query(\'select * from \' ~ target_relation) -%}\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(col) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return([ns.column_added, intersection]) }}\n{%- endmacro %}\n\n\n{% 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 select_current_time -%}\n select {{ snapshot_get_time() }} as snapshot_start\n {%- endset %}\n\n {# don\'t access the column by name, to avoid dealing with casing issues on snowflake #}\n {%- set now = run_query(select_current_time)[0][0] -%}\n {% if now is none or now is undefined -%}\n {%- do exceptions.raise_compiler_error(\'Could not get a snapshot start time from the database\') -%}\n {%- endif %}\n {% set updated_at = snapshot_string_as_time(now) %}\n\n {% set column_added = false %}\n\n {% if check_cols_config == \'all\' %}\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists) %}\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {% set check_cols = check_cols_config %}\n {% else %}\n {% do exceptions.raise_compiler_error("Invalid value for \'check_cols\': " ~ check_cols_config) %}\n {% endif %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n TRUE\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n ({{ snapshotted_rel }}.{{ col }} is null) != ({{ current_rel }}.{{ col }} is null)\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 }) %}\n{% endmacro %}', 'unique_id': 'macro.dbt.snapshot_hash_arguments', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/strategies.sql', 'original_file_path': 'macros/materializations/snapshot/strategies.sql', 'resource_type': 'macro', 'name': 'snapshot_hash_arguments', 'macro_sql': "{% macro snapshot_hash_arguments(args) -%}\n {{ adapter_macro('snapshot_hash_arguments', args) }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__snapshot_hash_arguments': {'raw_sql': '{#\n Dispatch strategies by name, optionally qualified to a package\n#}\n{% 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 %}\n\n\n{#\n Create SCD Hash SQL fields cross-db\n#}\n{% macro snapshot_hash_arguments(args) -%}\n {{ adapter_macro(\'snapshot_hash_arguments\', args) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{#\n Get the current time cross-db\n#}\n{% macro snapshot_get_time() -%}\n {{ adapter_macro(\'snapshot_get_time\') }}\n{%- endmacro %}\n\n{% macro default__snapshot_get_time() -%}\n {{ current_timestamp() }}\n{%- endmacro %}\n\n\n{#\n Core strategy definitions\n#}\n{% 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\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.{{ updated_at }} < {{ 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 }) %}\n{% endmacro %}\n\n\n{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter_macro(\'snapshot_string_as_time\', timestamp) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}\n {%- set query_columns = get_columns_in_query(node[\'injected_sql\']) -%}\n {%- if not target_exists -%}\n {# no table yet -> return whatever the query does #}\n {{ return([false, query_columns]) }}\n {%- endif -%}\n {# handle any schema changes #}\n {%- set target_table = node.get(\'alias\', node.get(\'name\')) -%}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=target_table) -%}\n {%- set existing_cols = get_columns_in_query(\'select * from \' ~ target_relation) -%}\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(col) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return([ns.column_added, intersection]) }}\n{%- endmacro %}\n\n\n{% 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 select_current_time -%}\n select {{ snapshot_get_time() }} as snapshot_start\n {%- endset %}\n\n {# don\'t access the column by name, to avoid dealing with casing issues on snowflake #}\n {%- set now = run_query(select_current_time)[0][0] -%}\n {% if now is none or now is undefined -%}\n {%- do exceptions.raise_compiler_error(\'Could not get a snapshot start time from the database\') -%}\n {%- endif %}\n {% set updated_at = snapshot_string_as_time(now) %}\n\n {% set column_added = false %}\n\n {% if check_cols_config == \'all\' %}\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists) %}\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {% set check_cols = check_cols_config %}\n {% else %}\n {% do exceptions.raise_compiler_error("Invalid value for \'check_cols\': " ~ check_cols_config) %}\n {% endif %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n TRUE\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n ({{ snapshotted_rel }}.{{ col }} is null) != ({{ current_rel }}.{{ col }} is null)\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 }) %}\n{% endmacro %}', 'unique_id': 'macro.dbt.default__snapshot_hash_arguments', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/strategies.sql', 'original_file_path': 'macros/materializations/snapshot/strategies.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.snapshot_get_time': {'raw_sql': '{#\n Dispatch strategies by name, optionally qualified to a package\n#}\n{% 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 %}\n\n\n{#\n Create SCD Hash SQL fields cross-db\n#}\n{% macro snapshot_hash_arguments(args) -%}\n {{ adapter_macro(\'snapshot_hash_arguments\', args) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{#\n Get the current time cross-db\n#}\n{% macro snapshot_get_time() -%}\n {{ adapter_macro(\'snapshot_get_time\') }}\n{%- endmacro %}\n\n{% macro default__snapshot_get_time() -%}\n {{ current_timestamp() }}\n{%- endmacro %}\n\n\n{#\n Core strategy definitions\n#}\n{% 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\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.{{ updated_at }} < {{ 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 }) %}\n{% endmacro %}\n\n\n{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter_macro(\'snapshot_string_as_time\', timestamp) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}\n {%- set query_columns = get_columns_in_query(node[\'injected_sql\']) -%}\n {%- if not target_exists -%}\n {# no table yet -> return whatever the query does #}\n {{ return([false, query_columns]) }}\n {%- endif -%}\n {# handle any schema changes #}\n {%- set target_table = node.get(\'alias\', node.get(\'name\')) -%}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=target_table) -%}\n {%- set existing_cols = get_columns_in_query(\'select * from \' ~ target_relation) -%}\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(col) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return([ns.column_added, intersection]) }}\n{%- endmacro %}\n\n\n{% 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 select_current_time -%}\n select {{ snapshot_get_time() }} as snapshot_start\n {%- endset %}\n\n {# don\'t access the column by name, to avoid dealing with casing issues on snowflake #}\n {%- set now = run_query(select_current_time)[0][0] -%}\n {% if now is none or now is undefined -%}\n {%- do exceptions.raise_compiler_error(\'Could not get a snapshot start time from the database\') -%}\n {%- endif %}\n {% set updated_at = snapshot_string_as_time(now) %}\n\n {% set column_added = false %}\n\n {% if check_cols_config == \'all\' %}\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists) %}\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {% set check_cols = check_cols_config %}\n {% else %}\n {% do exceptions.raise_compiler_error("Invalid value for \'check_cols\': " ~ check_cols_config) %}\n {% endif %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n TRUE\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n ({{ snapshotted_rel }}.{{ col }} is null) != ({{ current_rel }}.{{ col }} is null)\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 }) %}\n{% endmacro %}', 'unique_id': 'macro.dbt.snapshot_get_time', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/strategies.sql', 'original_file_path': 'macros/materializations/snapshot/strategies.sql', 'resource_type': 'macro', 'name': 'snapshot_get_time', 'macro_sql': "{% macro snapshot_get_time() -%}\n {{ adapter_macro('snapshot_get_time') }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__snapshot_get_time': {'raw_sql': '{#\n Dispatch strategies by name, optionally qualified to a package\n#}\n{% 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 %}\n\n\n{#\n Create SCD Hash SQL fields cross-db\n#}\n{% macro snapshot_hash_arguments(args) -%}\n {{ adapter_macro(\'snapshot_hash_arguments\', args) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{#\n Get the current time cross-db\n#}\n{% macro snapshot_get_time() -%}\n {{ adapter_macro(\'snapshot_get_time\') }}\n{%- endmacro %}\n\n{% macro default__snapshot_get_time() -%}\n {{ current_timestamp() }}\n{%- endmacro %}\n\n\n{#\n Core strategy definitions\n#}\n{% 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\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.{{ updated_at }} < {{ 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 }) %}\n{% endmacro %}\n\n\n{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter_macro(\'snapshot_string_as_time\', timestamp) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}\n {%- set query_columns = get_columns_in_query(node[\'injected_sql\']) -%}\n {%- if not target_exists -%}\n {# no table yet -> return whatever the query does #}\n {{ return([false, query_columns]) }}\n {%- endif -%}\n {# handle any schema changes #}\n {%- set target_table = node.get(\'alias\', node.get(\'name\')) -%}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=target_table) -%}\n {%- set existing_cols = get_columns_in_query(\'select * from \' ~ target_relation) -%}\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(col) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return([ns.column_added, intersection]) }}\n{%- endmacro %}\n\n\n{% 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 select_current_time -%}\n select {{ snapshot_get_time() }} as snapshot_start\n {%- endset %}\n\n {# don\'t access the column by name, to avoid dealing with casing issues on snowflake #}\n {%- set now = run_query(select_current_time)[0][0] -%}\n {% if now is none or now is undefined -%}\n {%- do exceptions.raise_compiler_error(\'Could not get a snapshot start time from the database\') -%}\n {%- endif %}\n {% set updated_at = snapshot_string_as_time(now) %}\n\n {% set column_added = false %}\n\n {% if check_cols_config == \'all\' %}\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists) %}\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {% set check_cols = check_cols_config %}\n {% else %}\n {% do exceptions.raise_compiler_error("Invalid value for \'check_cols\': " ~ check_cols_config) %}\n {% endif %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n TRUE\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n ({{ snapshotted_rel }}.{{ col }} is null) != ({{ current_rel }}.{{ col }} is null)\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 }) %}\n{% endmacro %}', 'unique_id': 'macro.dbt.default__snapshot_get_time', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/strategies.sql', 'original_file_path': 'macros/materializations/snapshot/strategies.sql', 'resource_type': 'macro', 'name': 'default__snapshot_get_time', 'macro_sql': '{% macro default__snapshot_get_time() -%}\n {{ current_timestamp() }}\n{%- endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.snapshot_timestamp_strategy': {'raw_sql': '{#\n Dispatch strategies by name, optionally qualified to a package\n#}\n{% 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 %}\n\n\n{#\n Create SCD Hash SQL fields cross-db\n#}\n{% macro snapshot_hash_arguments(args) -%}\n {{ adapter_macro(\'snapshot_hash_arguments\', args) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{#\n Get the current time cross-db\n#}\n{% macro snapshot_get_time() -%}\n {{ adapter_macro(\'snapshot_get_time\') }}\n{%- endmacro %}\n\n{% macro default__snapshot_get_time() -%}\n {{ current_timestamp() }}\n{%- endmacro %}\n\n\n{#\n Core strategy definitions\n#}\n{% 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\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.{{ updated_at }} < {{ 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 }) %}\n{% endmacro %}\n\n\n{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter_macro(\'snapshot_string_as_time\', timestamp) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}\n {%- set query_columns = get_columns_in_query(node[\'injected_sql\']) -%}\n {%- if not target_exists -%}\n {# no table yet -> return whatever the query does #}\n {{ return([false, query_columns]) }}\n {%- endif -%}\n {# handle any schema changes #}\n {%- set target_table = node.get(\'alias\', node.get(\'name\')) -%}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=target_table) -%}\n {%- set existing_cols = get_columns_in_query(\'select * from \' ~ target_relation) -%}\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(col) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return([ns.column_added, intersection]) }}\n{%- endmacro %}\n\n\n{% 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 select_current_time -%}\n select {{ snapshot_get_time() }} as snapshot_start\n {%- endset %}\n\n {# don\'t access the column by name, to avoid dealing with casing issues on snowflake #}\n {%- set now = run_query(select_current_time)[0][0] -%}\n {% if now is none or now is undefined -%}\n {%- do exceptions.raise_compiler_error(\'Could not get a snapshot start time from the database\') -%}\n {%- endif %}\n {% set updated_at = snapshot_string_as_time(now) %}\n\n {% set column_added = false %}\n\n {% if check_cols_config == \'all\' %}\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists) %}\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {% set check_cols = check_cols_config %}\n {% else %}\n {% do exceptions.raise_compiler_error("Invalid value for \'check_cols\': " ~ check_cols_config) %}\n {% endif %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n TRUE\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n ({{ snapshotted_rel }}.{{ col }} is null) != ({{ current_rel }}.{{ col }} is null)\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 }) %}\n{% endmacro %}', 'unique_id': 'macro.dbt.snapshot_timestamp_strategy', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/strategies.sql', 'original_file_path': 'macros/materializations/snapshot/strategies.sql', 'resource_type': 'macro', '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\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.{{ updated_at }} < {{ 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 }) %}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.snapshot_string_as_time': {'raw_sql': '{#\n Dispatch strategies by name, optionally qualified to a package\n#}\n{% 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 %}\n\n\n{#\n Create SCD Hash SQL fields cross-db\n#}\n{% macro snapshot_hash_arguments(args) -%}\n {{ adapter_macro(\'snapshot_hash_arguments\', args) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{#\n Get the current time cross-db\n#}\n{% macro snapshot_get_time() -%}\n {{ adapter_macro(\'snapshot_get_time\') }}\n{%- endmacro %}\n\n{% macro default__snapshot_get_time() -%}\n {{ current_timestamp() }}\n{%- endmacro %}\n\n\n{#\n Core strategy definitions\n#}\n{% 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\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.{{ updated_at }} < {{ 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 }) %}\n{% endmacro %}\n\n\n{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter_macro(\'snapshot_string_as_time\', timestamp) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}\n {%- set query_columns = get_columns_in_query(node[\'injected_sql\']) -%}\n {%- if not target_exists -%}\n {# no table yet -> return whatever the query does #}\n {{ return([false, query_columns]) }}\n {%- endif -%}\n {# handle any schema changes #}\n {%- set target_table = node.get(\'alias\', node.get(\'name\')) -%}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=target_table) -%}\n {%- set existing_cols = get_columns_in_query(\'select * from \' ~ target_relation) -%}\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(col) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return([ns.column_added, intersection]) }}\n{%- endmacro %}\n\n\n{% 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 select_current_time -%}\n select {{ snapshot_get_time() }} as snapshot_start\n {%- endset %}\n\n {# don\'t access the column by name, to avoid dealing with casing issues on snowflake #}\n {%- set now = run_query(select_current_time)[0][0] -%}\n {% if now is none or now is undefined -%}\n {%- do exceptions.raise_compiler_error(\'Could not get a snapshot start time from the database\') -%}\n {%- endif %}\n {% set updated_at = snapshot_string_as_time(now) %}\n\n {% set column_added = false %}\n\n {% if check_cols_config == \'all\' %}\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists) %}\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {% set check_cols = check_cols_config %}\n {% else %}\n {% do exceptions.raise_compiler_error("Invalid value for \'check_cols\': " ~ check_cols_config) %}\n {% endif %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n TRUE\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n ({{ snapshotted_rel }}.{{ col }} is null) != ({{ current_rel }}.{{ col }} is null)\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 }) %}\n{% endmacro %}', 'unique_id': 'macro.dbt.snapshot_string_as_time', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/strategies.sql', 'original_file_path': 'macros/materializations/snapshot/strategies.sql', 'resource_type': 'macro', 'name': 'snapshot_string_as_time', 'macro_sql': "{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter_macro('snapshot_string_as_time', timestamp) }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__snapshot_string_as_time': {'raw_sql': '{#\n Dispatch strategies by name, optionally qualified to a package\n#}\n{% 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 %}\n\n\n{#\n Create SCD Hash SQL fields cross-db\n#}\n{% macro snapshot_hash_arguments(args) -%}\n {{ adapter_macro(\'snapshot_hash_arguments\', args) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{#\n Get the current time cross-db\n#}\n{% macro snapshot_get_time() -%}\n {{ adapter_macro(\'snapshot_get_time\') }}\n{%- endmacro %}\n\n{% macro default__snapshot_get_time() -%}\n {{ current_timestamp() }}\n{%- endmacro %}\n\n\n{#\n Core strategy definitions\n#}\n{% 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\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.{{ updated_at }} < {{ 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 }) %}\n{% endmacro %}\n\n\n{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter_macro(\'snapshot_string_as_time\', timestamp) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}\n {%- set query_columns = get_columns_in_query(node[\'injected_sql\']) -%}\n {%- if not target_exists -%}\n {# no table yet -> return whatever the query does #}\n {{ return([false, query_columns]) }}\n {%- endif -%}\n {# handle any schema changes #}\n {%- set target_table = node.get(\'alias\', node.get(\'name\')) -%}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=target_table) -%}\n {%- set existing_cols = get_columns_in_query(\'select * from \' ~ target_relation) -%}\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(col) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return([ns.column_added, intersection]) }}\n{%- endmacro %}\n\n\n{% 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 select_current_time -%}\n select {{ snapshot_get_time() }} as snapshot_start\n {%- endset %}\n\n {# don\'t access the column by name, to avoid dealing with casing issues on snowflake #}\n {%- set now = run_query(select_current_time)[0][0] -%}\n {% if now is none or now is undefined -%}\n {%- do exceptions.raise_compiler_error(\'Could not get a snapshot start time from the database\') -%}\n {%- endif %}\n {% set updated_at = snapshot_string_as_time(now) %}\n\n {% set column_added = false %}\n\n {% if check_cols_config == \'all\' %}\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists) %}\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {% set check_cols = check_cols_config %}\n {% else %}\n {% do exceptions.raise_compiler_error("Invalid value for \'check_cols\': " ~ check_cols_config) %}\n {% endif %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n TRUE\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n ({{ snapshotted_rel }}.{{ col }} is null) != ({{ current_rel }}.{{ col }} is null)\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 }) %}\n{% endmacro %}', 'unique_id': 'macro.dbt.default__snapshot_string_as_time', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/strategies.sql', 'original_file_path': 'macros/materializations/snapshot/strategies.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.snapshot_check_all_get_existing_columns': {'raw_sql': '{#\n Dispatch strategies by name, optionally qualified to a package\n#}\n{% 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 %}\n\n\n{#\n Create SCD Hash SQL fields cross-db\n#}\n{% macro snapshot_hash_arguments(args) -%}\n {{ adapter_macro(\'snapshot_hash_arguments\', args) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{#\n Get the current time cross-db\n#}\n{% macro snapshot_get_time() -%}\n {{ adapter_macro(\'snapshot_get_time\') }}\n{%- endmacro %}\n\n{% macro default__snapshot_get_time() -%}\n {{ current_timestamp() }}\n{%- endmacro %}\n\n\n{#\n Core strategy definitions\n#}\n{% 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\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.{{ updated_at }} < {{ 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 }) %}\n{% endmacro %}\n\n\n{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter_macro(\'snapshot_string_as_time\', timestamp) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}\n {%- set query_columns = get_columns_in_query(node[\'injected_sql\']) -%}\n {%- if not target_exists -%}\n {# no table yet -> return whatever the query does #}\n {{ return([false, query_columns]) }}\n {%- endif -%}\n {# handle any schema changes #}\n {%- set target_table = node.get(\'alias\', node.get(\'name\')) -%}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=target_table) -%}\n {%- set existing_cols = get_columns_in_query(\'select * from \' ~ target_relation) -%}\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(col) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return([ns.column_added, intersection]) }}\n{%- endmacro %}\n\n\n{% 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 select_current_time -%}\n select {{ snapshot_get_time() }} as snapshot_start\n {%- endset %}\n\n {# don\'t access the column by name, to avoid dealing with casing issues on snowflake #}\n {%- set now = run_query(select_current_time)[0][0] -%}\n {% if now is none or now is undefined -%}\n {%- do exceptions.raise_compiler_error(\'Could not get a snapshot start time from the database\') -%}\n {%- endif %}\n {% set updated_at = snapshot_string_as_time(now) %}\n\n {% set column_added = false %}\n\n {% if check_cols_config == \'all\' %}\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists) %}\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {% set check_cols = check_cols_config %}\n {% else %}\n {% do exceptions.raise_compiler_error("Invalid value for \'check_cols\': " ~ check_cols_config) %}\n {% endif %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n TRUE\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n ({{ snapshotted_rel }}.{{ col }} is null) != ({{ current_rel }}.{{ col }} is null)\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 }) %}\n{% endmacro %}', 'unique_id': 'macro.dbt.snapshot_check_all_get_existing_columns', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/strategies.sql', 'original_file_path': 'macros/materializations/snapshot/strategies.sql', 'resource_type': 'macro', 'name': 'snapshot_check_all_get_existing_columns', 'macro_sql': "{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}\n {%- set query_columns = get_columns_in_query(node['injected_sql']) -%}\n {%- if not target_exists -%}\n {# no table yet -> return whatever the query does #}\n {{ return([false, query_columns]) }}\n {%- endif -%}\n {# handle any schema changes #}\n {%- set target_table = node.get('alias', node.get('name')) -%}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=target_table) -%}\n {%- set existing_cols = get_columns_in_query('select * from ' ~ target_relation) -%}\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(col) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return([ns.column_added, intersection]) }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.snapshot_check_strategy': {'raw_sql': '{#\n Dispatch strategies by name, optionally qualified to a package\n#}\n{% 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 %}\n\n\n{#\n Create SCD Hash SQL fields cross-db\n#}\n{% macro snapshot_hash_arguments(args) -%}\n {{ adapter_macro(\'snapshot_hash_arguments\', args) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{#\n Get the current time cross-db\n#}\n{% macro snapshot_get_time() -%}\n {{ adapter_macro(\'snapshot_get_time\') }}\n{%- endmacro %}\n\n{% macro default__snapshot_get_time() -%}\n {{ current_timestamp() }}\n{%- endmacro %}\n\n\n{#\n Core strategy definitions\n#}\n{% 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\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.{{ updated_at }} < {{ 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 }) %}\n{% endmacro %}\n\n\n{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter_macro(\'snapshot_string_as_time\', timestamp) }}\n{%- endmacro %}\n\n\n{% 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 %}\n\n\n{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}\n {%- set query_columns = get_columns_in_query(node[\'injected_sql\']) -%}\n {%- if not target_exists -%}\n {# no table yet -> return whatever the query does #}\n {{ return([false, query_columns]) }}\n {%- endif -%}\n {# handle any schema changes #}\n {%- set target_table = node.get(\'alias\', node.get(\'name\')) -%}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=target_table) -%}\n {%- set existing_cols = get_columns_in_query(\'select * from \' ~ target_relation) -%}\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(col) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return([ns.column_added, intersection]) }}\n{%- endmacro %}\n\n\n{% 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 select_current_time -%}\n select {{ snapshot_get_time() }} as snapshot_start\n {%- endset %}\n\n {# don\'t access the column by name, to avoid dealing with casing issues on snowflake #}\n {%- set now = run_query(select_current_time)[0][0] -%}\n {% if now is none or now is undefined -%}\n {%- do exceptions.raise_compiler_error(\'Could not get a snapshot start time from the database\') -%}\n {%- endif %}\n {% set updated_at = snapshot_string_as_time(now) %}\n\n {% set column_added = false %}\n\n {% if check_cols_config == \'all\' %}\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists) %}\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {% set check_cols = check_cols_config %}\n {% else %}\n {% do exceptions.raise_compiler_error("Invalid value for \'check_cols\': " ~ check_cols_config) %}\n {% endif %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n TRUE\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n ({{ snapshotted_rel }}.{{ col }} is null) != ({{ current_rel }}.{{ col }} is null)\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 }) %}\n{% endmacro %}', 'unique_id': 'macro.dbt.snapshot_check_strategy', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/strategies.sql', 'original_file_path': 'macros/materializations/snapshot/strategies.sql', 'resource_type': 'macro', '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 select_current_time -%}\n select {{ snapshot_get_time() }} as snapshot_start\n {%- endset %}\n\n {# don\'t access the column by name, to avoid dealing with casing issues on snowflake #}\n {%- set now = run_query(select_current_time)[0][0] -%}\n {% if now is none or now is undefined -%}\n {%- do exceptions.raise_compiler_error(\'Could not get a snapshot start time from the database\') -%}\n {%- endif %}\n {% set updated_at = snapshot_string_as_time(now) %}\n\n {% set column_added = false %}\n\n {% if check_cols_config == \'all\' %}\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists) %}\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {% set check_cols = check_cols_config %}\n {% else %}\n {% do exceptions.raise_compiler_error("Invalid value for \'check_cols\': " ~ check_cols_config) %}\n {% endif %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n TRUE\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n ({{ snapshotted_rel }}.{{ col }} is null) != ({{ current_rel }}.{{ col }} is null)\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 }) %}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.create_columns': {'raw_sql': '{#\n Add new columns to the table if applicable\n#}\n{% macro create_columns(relation, columns) %}\n {{ adapter_macro(\'create_columns\', relation, columns) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro post_snapshot(staging_relation) %}\n {{ adapter_macro(\'post_snapshot\', staging_relation) }}\n{% endmacro %}\n\n{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}\n\n\n{% macro snapshot_staging_table_inserts(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\n ),\n\n source_data as (\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n insertions as (\n\n select\n \'insert\' as dbt_change_type,\n source_data.*\n\n from 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 snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n )\n\n select * from insertions\n\n{%- endmacro %}\n\n\n{% macro snapshot_staging_table_updates(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\n ),\n\n source_data as (\n\n select\n *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n updates as (\n\n select\n \'update\' as dbt_change_type,\n snapshotted_data.dbt_scd_id,\n source_data.dbt_valid_from as dbt_valid_to\n\n from source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n\n )\n\n select * from updates\n\n{%- endmacro %}\n\n\n{% macro 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 %}\n\n\n{% macro 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 %}\n\n{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n\n {% set inserts_select = snapshot_staging_table_inserts(strategy, sql, target_relation) %}\n {% set updates_select = snapshot_staging_table_updates(strategy, sql, target_relation) %}\n\n {% call statement(\'build_snapshot_staging_relation_inserts\') %}\n {{ create_table_as(True, tmp_relation, inserts_select) }}\n {% endcall %}\n\n {% call statement(\'build_snapshot_staging_relation_updates\') %}\n insert into {{ tmp_relation }} (dbt_change_type, dbt_scd_id, dbt_valid_to)\n select dbt_change_type, dbt_scd_id, dbt_valid_to from (\n {{ updates_select }}\n ) dbt_sbq\n {% endcall %}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n\n{% 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\n {% if not adapter.check_schema_exists(model.database, model.schema) %}\n {% do create_schema(model.database, model.schema) %}\n {% endif %}\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[\'injected_sql\']) %}\n {% call statement(\'main\') -%}\n {{ create_table_as(False, target_relation, build_sql) }}\n {% endcall %}\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 {% call statement(\'main\') %}\n {{ snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n }}\n {% endcall %}\n\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 %}', 'unique_id': 'macro.dbt.create_columns', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/snapshot.sql', 'original_file_path': 'macros/materializations/snapshot/snapshot.sql', 'resource_type': 'macro', 'name': 'create_columns', 'macro_sql': "{% macro create_columns(relation, columns) %}\n {{ adapter_macro('create_columns', relation, columns) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__create_columns': {'raw_sql': '{#\n Add new columns to the table if applicable\n#}\n{% macro create_columns(relation, columns) %}\n {{ adapter_macro(\'create_columns\', relation, columns) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro post_snapshot(staging_relation) %}\n {{ adapter_macro(\'post_snapshot\', staging_relation) }}\n{% endmacro %}\n\n{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}\n\n\n{% macro snapshot_staging_table_inserts(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\n ),\n\n source_data as (\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n insertions as (\n\n select\n \'insert\' as dbt_change_type,\n source_data.*\n\n from 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 snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n )\n\n select * from insertions\n\n{%- endmacro %}\n\n\n{% macro snapshot_staging_table_updates(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\n ),\n\n source_data as (\n\n select\n *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n updates as (\n\n select\n \'update\' as dbt_change_type,\n snapshotted_data.dbt_scd_id,\n source_data.dbt_valid_from as dbt_valid_to\n\n from source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n\n )\n\n select * from updates\n\n{%- endmacro %}\n\n\n{% macro 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 %}\n\n\n{% macro 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 %}\n\n{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n\n {% set inserts_select = snapshot_staging_table_inserts(strategy, sql, target_relation) %}\n {% set updates_select = snapshot_staging_table_updates(strategy, sql, target_relation) %}\n\n {% call statement(\'build_snapshot_staging_relation_inserts\') %}\n {{ create_table_as(True, tmp_relation, inserts_select) }}\n {% endcall %}\n\n {% call statement(\'build_snapshot_staging_relation_updates\') %}\n insert into {{ tmp_relation }} (dbt_change_type, dbt_scd_id, dbt_valid_to)\n select dbt_change_type, dbt_scd_id, dbt_valid_to from (\n {{ updates_select }}\n ) dbt_sbq\n {% endcall %}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n\n{% 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\n {% if not adapter.check_schema_exists(model.database, model.schema) %}\n {% do create_schema(model.database, model.schema) %}\n {% endif %}\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[\'injected_sql\']) %}\n {% call statement(\'main\') -%}\n {{ create_table_as(False, target_relation, build_sql) }}\n {% endcall %}\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 {% call statement(\'main\') %}\n {{ snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n }}\n {% endcall %}\n\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 %}', 'unique_id': 'macro.dbt.default__create_columns', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/snapshot.sql', 'original_file_path': 'macros/materializations/snapshot/snapshot.sql', 'resource_type': 'macro', '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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.post_snapshot': {'raw_sql': '{#\n Add new columns to the table if applicable\n#}\n{% macro create_columns(relation, columns) %}\n {{ adapter_macro(\'create_columns\', relation, columns) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro post_snapshot(staging_relation) %}\n {{ adapter_macro(\'post_snapshot\', staging_relation) }}\n{% endmacro %}\n\n{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}\n\n\n{% macro snapshot_staging_table_inserts(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\n ),\n\n source_data as (\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n insertions as (\n\n select\n \'insert\' as dbt_change_type,\n source_data.*\n\n from 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 snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n )\n\n select * from insertions\n\n{%- endmacro %}\n\n\n{% macro snapshot_staging_table_updates(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\n ),\n\n source_data as (\n\n select\n *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n updates as (\n\n select\n \'update\' as dbt_change_type,\n snapshotted_data.dbt_scd_id,\n source_data.dbt_valid_from as dbt_valid_to\n\n from source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n\n )\n\n select * from updates\n\n{%- endmacro %}\n\n\n{% macro 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 %}\n\n\n{% macro 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 %}\n\n{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n\n {% set inserts_select = snapshot_staging_table_inserts(strategy, sql, target_relation) %}\n {% set updates_select = snapshot_staging_table_updates(strategy, sql, target_relation) %}\n\n {% call statement(\'build_snapshot_staging_relation_inserts\') %}\n {{ create_table_as(True, tmp_relation, inserts_select) }}\n {% endcall %}\n\n {% call statement(\'build_snapshot_staging_relation_updates\') %}\n insert into {{ tmp_relation }} (dbt_change_type, dbt_scd_id, dbt_valid_to)\n select dbt_change_type, dbt_scd_id, dbt_valid_to from (\n {{ updates_select }}\n ) dbt_sbq\n {% endcall %}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n\n{% 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\n {% if not adapter.check_schema_exists(model.database, model.schema) %}\n {% do create_schema(model.database, model.schema) %}\n {% endif %}\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[\'injected_sql\']) %}\n {% call statement(\'main\') -%}\n {{ create_table_as(False, target_relation, build_sql) }}\n {% endcall %}\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 {% call statement(\'main\') %}\n {{ snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n }}\n {% endcall %}\n\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 %}', 'unique_id': 'macro.dbt.post_snapshot', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/snapshot.sql', 'original_file_path': 'macros/materializations/snapshot/snapshot.sql', 'resource_type': 'macro', 'name': 'post_snapshot', 'macro_sql': "{% macro post_snapshot(staging_relation) %}\n {{ adapter_macro('post_snapshot', staging_relation) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__post_snapshot': {'raw_sql': '{#\n Add new columns to the table if applicable\n#}\n{% macro create_columns(relation, columns) %}\n {{ adapter_macro(\'create_columns\', relation, columns) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro post_snapshot(staging_relation) %}\n {{ adapter_macro(\'post_snapshot\', staging_relation) }}\n{% endmacro %}\n\n{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}\n\n\n{% macro snapshot_staging_table_inserts(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\n ),\n\n source_data as (\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n insertions as (\n\n select\n \'insert\' as dbt_change_type,\n source_data.*\n\n from 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 snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n )\n\n select * from insertions\n\n{%- endmacro %}\n\n\n{% macro snapshot_staging_table_updates(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\n ),\n\n source_data as (\n\n select\n *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n updates as (\n\n select\n \'update\' as dbt_change_type,\n snapshotted_data.dbt_scd_id,\n source_data.dbt_valid_from as dbt_valid_to\n\n from source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n\n )\n\n select * from updates\n\n{%- endmacro %}\n\n\n{% macro 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 %}\n\n\n{% macro 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 %}\n\n{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n\n {% set inserts_select = snapshot_staging_table_inserts(strategy, sql, target_relation) %}\n {% set updates_select = snapshot_staging_table_updates(strategy, sql, target_relation) %}\n\n {% call statement(\'build_snapshot_staging_relation_inserts\') %}\n {{ create_table_as(True, tmp_relation, inserts_select) }}\n {% endcall %}\n\n {% call statement(\'build_snapshot_staging_relation_updates\') %}\n insert into {{ tmp_relation }} (dbt_change_type, dbt_scd_id, dbt_valid_to)\n select dbt_change_type, dbt_scd_id, dbt_valid_to from (\n {{ updates_select }}\n ) dbt_sbq\n {% endcall %}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n\n{% 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\n {% if not adapter.check_schema_exists(model.database, model.schema) %}\n {% do create_schema(model.database, model.schema) %}\n {% endif %}\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[\'injected_sql\']) %}\n {% call statement(\'main\') -%}\n {{ create_table_as(False, target_relation, build_sql) }}\n {% endcall %}\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 {% call statement(\'main\') %}\n {{ snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n }}\n {% endcall %}\n\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 %}', 'unique_id': 'macro.dbt.default__post_snapshot', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/snapshot.sql', 'original_file_path': 'macros/materializations/snapshot/snapshot.sql', 'resource_type': 'macro', 'name': 'default__post_snapshot', 'macro_sql': '{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.snapshot_staging_table_inserts': {'raw_sql': '{#\n Add new columns to the table if applicable\n#}\n{% macro create_columns(relation, columns) %}\n {{ adapter_macro(\'create_columns\', relation, columns) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro post_snapshot(staging_relation) %}\n {{ adapter_macro(\'post_snapshot\', staging_relation) }}\n{% endmacro %}\n\n{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}\n\n\n{% macro snapshot_staging_table_inserts(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\n ),\n\n source_data as (\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n insertions as (\n\n select\n \'insert\' as dbt_change_type,\n source_data.*\n\n from 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 snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n )\n\n select * from insertions\n\n{%- endmacro %}\n\n\n{% macro snapshot_staging_table_updates(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\n ),\n\n source_data as (\n\n select\n *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n updates as (\n\n select\n \'update\' as dbt_change_type,\n snapshotted_data.dbt_scd_id,\n source_data.dbt_valid_from as dbt_valid_to\n\n from source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n\n )\n\n select * from updates\n\n{%- endmacro %}\n\n\n{% macro 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 %}\n\n\n{% macro 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 %}\n\n{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n\n {% set inserts_select = snapshot_staging_table_inserts(strategy, sql, target_relation) %}\n {% set updates_select = snapshot_staging_table_updates(strategy, sql, target_relation) %}\n\n {% call statement(\'build_snapshot_staging_relation_inserts\') %}\n {{ create_table_as(True, tmp_relation, inserts_select) }}\n {% endcall %}\n\n {% call statement(\'build_snapshot_staging_relation_updates\') %}\n insert into {{ tmp_relation }} (dbt_change_type, dbt_scd_id, dbt_valid_to)\n select dbt_change_type, dbt_scd_id, dbt_valid_to from (\n {{ updates_select }}\n ) dbt_sbq\n {% endcall %}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n\n{% 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\n {% if not adapter.check_schema_exists(model.database, model.schema) %}\n {% do create_schema(model.database, model.schema) %}\n {% endif %}\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[\'injected_sql\']) %}\n {% call statement(\'main\') -%}\n {{ create_table_as(False, target_relation, build_sql) }}\n {% endcall %}\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 {% call statement(\'main\') %}\n {{ snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n }}\n {% endcall %}\n\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 %}', 'unique_id': 'macro.dbt.snapshot_staging_table_inserts', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/snapshot.sql', 'original_file_path': 'macros/materializations/snapshot/snapshot.sql', 'resource_type': 'macro', 'name': 'snapshot_staging_table_inserts', 'macro_sql': "{% macro snapshot_staging_table_inserts(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\n ),\n\n source_data as (\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n insertions as (\n\n select\n 'insert' as dbt_change_type,\n source_data.*\n\n from 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 snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n )\n\n select * from insertions\n\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.snapshot_staging_table_updates': {'raw_sql': '{#\n Add new columns to the table if applicable\n#}\n{% macro create_columns(relation, columns) %}\n {{ adapter_macro(\'create_columns\', relation, columns) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro post_snapshot(staging_relation) %}\n {{ adapter_macro(\'post_snapshot\', staging_relation) }}\n{% endmacro %}\n\n{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}\n\n\n{% macro snapshot_staging_table_inserts(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\n ),\n\n source_data as (\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n insertions as (\n\n select\n \'insert\' as dbt_change_type,\n source_data.*\n\n from 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 snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n )\n\n select * from insertions\n\n{%- endmacro %}\n\n\n{% macro snapshot_staging_table_updates(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\n ),\n\n source_data as (\n\n select\n *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n updates as (\n\n select\n \'update\' as dbt_change_type,\n snapshotted_data.dbt_scd_id,\n source_data.dbt_valid_from as dbt_valid_to\n\n from source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n\n )\n\n select * from updates\n\n{%- endmacro %}\n\n\n{% macro 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 %}\n\n\n{% macro 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 %}\n\n{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n\n {% set inserts_select = snapshot_staging_table_inserts(strategy, sql, target_relation) %}\n {% set updates_select = snapshot_staging_table_updates(strategy, sql, target_relation) %}\n\n {% call statement(\'build_snapshot_staging_relation_inserts\') %}\n {{ create_table_as(True, tmp_relation, inserts_select) }}\n {% endcall %}\n\n {% call statement(\'build_snapshot_staging_relation_updates\') %}\n insert into {{ tmp_relation }} (dbt_change_type, dbt_scd_id, dbt_valid_to)\n select dbt_change_type, dbt_scd_id, dbt_valid_to from (\n {{ updates_select }}\n ) dbt_sbq\n {% endcall %}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n\n{% 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\n {% if not adapter.check_schema_exists(model.database, model.schema) %}\n {% do create_schema(model.database, model.schema) %}\n {% endif %}\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[\'injected_sql\']) %}\n {% call statement(\'main\') -%}\n {{ create_table_as(False, target_relation, build_sql) }}\n {% endcall %}\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 {% call statement(\'main\') %}\n {{ snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n }}\n {% endcall %}\n\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 %}', 'unique_id': 'macro.dbt.snapshot_staging_table_updates', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/snapshot.sql', 'original_file_path': 'macros/materializations/snapshot/snapshot.sql', 'resource_type': 'macro', 'name': 'snapshot_staging_table_updates', 'macro_sql': "{% macro snapshot_staging_table_updates(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\n ),\n\n source_data as (\n\n select\n *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n updates as (\n\n select\n 'update' as dbt_change_type,\n snapshotted_data.dbt_scd_id,\n source_data.dbt_valid_from as dbt_valid_to\n\n from source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n\n )\n\n select * from updates\n\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.build_snapshot_table': {'raw_sql': '{#\n Add new columns to the table if applicable\n#}\n{% macro create_columns(relation, columns) %}\n {{ adapter_macro(\'create_columns\', relation, columns) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro post_snapshot(staging_relation) %}\n {{ adapter_macro(\'post_snapshot\', staging_relation) }}\n{% endmacro %}\n\n{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}\n\n\n{% macro snapshot_staging_table_inserts(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\n ),\n\n source_data as (\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n insertions as (\n\n select\n \'insert\' as dbt_change_type,\n source_data.*\n\n from 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 snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n )\n\n select * from insertions\n\n{%- endmacro %}\n\n\n{% macro snapshot_staging_table_updates(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\n ),\n\n source_data as (\n\n select\n *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n updates as (\n\n select\n \'update\' as dbt_change_type,\n snapshotted_data.dbt_scd_id,\n source_data.dbt_valid_from as dbt_valid_to\n\n from source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n\n )\n\n select * from updates\n\n{%- endmacro %}\n\n\n{% macro 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 %}\n\n\n{% macro 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 %}\n\n{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n\n {% set inserts_select = snapshot_staging_table_inserts(strategy, sql, target_relation) %}\n {% set updates_select = snapshot_staging_table_updates(strategy, sql, target_relation) %}\n\n {% call statement(\'build_snapshot_staging_relation_inserts\') %}\n {{ create_table_as(True, tmp_relation, inserts_select) }}\n {% endcall %}\n\n {% call statement(\'build_snapshot_staging_relation_updates\') %}\n insert into {{ tmp_relation }} (dbt_change_type, dbt_scd_id, dbt_valid_to)\n select dbt_change_type, dbt_scd_id, dbt_valid_to from (\n {{ updates_select }}\n ) dbt_sbq\n {% endcall %}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n\n{% 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\n {% if not adapter.check_schema_exists(model.database, model.schema) %}\n {% do create_schema(model.database, model.schema) %}\n {% endif %}\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[\'injected_sql\']) %}\n {% call statement(\'main\') -%}\n {{ create_table_as(False, target_relation, build_sql) }}\n {% endcall %}\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 {% call statement(\'main\') %}\n {{ snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n }}\n {% endcall %}\n\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 %}', 'unique_id': 'macro.dbt.build_snapshot_table', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/snapshot.sql', 'original_file_path': 'macros/materializations/snapshot/snapshot.sql', 'resource_type': 'macro', 'name': 'build_snapshot_table', 'macro_sql': '{% macro 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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.get_or_create_relation': {'raw_sql': '{#\n Add new columns to the table if applicable\n#}\n{% macro create_columns(relation, columns) %}\n {{ adapter_macro(\'create_columns\', relation, columns) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro post_snapshot(staging_relation) %}\n {{ adapter_macro(\'post_snapshot\', staging_relation) }}\n{% endmacro %}\n\n{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}\n\n\n{% macro snapshot_staging_table_inserts(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\n ),\n\n source_data as (\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n insertions as (\n\n select\n \'insert\' as dbt_change_type,\n source_data.*\n\n from 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 snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n )\n\n select * from insertions\n\n{%- endmacro %}\n\n\n{% macro snapshot_staging_table_updates(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\n ),\n\n source_data as (\n\n select\n *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n updates as (\n\n select\n \'update\' as dbt_change_type,\n snapshotted_data.dbt_scd_id,\n source_data.dbt_valid_from as dbt_valid_to\n\n from source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n\n )\n\n select * from updates\n\n{%- endmacro %}\n\n\n{% macro 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 %}\n\n\n{% macro 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 %}\n\n{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n\n {% set inserts_select = snapshot_staging_table_inserts(strategy, sql, target_relation) %}\n {% set updates_select = snapshot_staging_table_updates(strategy, sql, target_relation) %}\n\n {% call statement(\'build_snapshot_staging_relation_inserts\') %}\n {{ create_table_as(True, tmp_relation, inserts_select) }}\n {% endcall %}\n\n {% call statement(\'build_snapshot_staging_relation_updates\') %}\n insert into {{ tmp_relation }} (dbt_change_type, dbt_scd_id, dbt_valid_to)\n select dbt_change_type, dbt_scd_id, dbt_valid_to from (\n {{ updates_select }}\n ) dbt_sbq\n {% endcall %}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n\n{% 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\n {% if not adapter.check_schema_exists(model.database, model.schema) %}\n {% do create_schema(model.database, model.schema) %}\n {% endif %}\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[\'injected_sql\']) %}\n {% call statement(\'main\') -%}\n {{ create_table_as(False, target_relation, build_sql) }}\n {% endcall %}\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 {% call statement(\'main\') %}\n {{ snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n }}\n {% endcall %}\n\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 %}', 'unique_id': 'macro.dbt.get_or_create_relation', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/snapshot.sql', 'original_file_path': 'macros/materializations/snapshot/snapshot.sql', 'resource_type': 'macro', 'name': 'get_or_create_relation', 'macro_sql': '{% macro 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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.build_snapshot_staging_table': {'raw_sql': '{#\n Add new columns to the table if applicable\n#}\n{% macro create_columns(relation, columns) %}\n {{ adapter_macro(\'create_columns\', relation, columns) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro post_snapshot(staging_relation) %}\n {{ adapter_macro(\'post_snapshot\', staging_relation) }}\n{% endmacro %}\n\n{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}\n\n\n{% macro snapshot_staging_table_inserts(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\n ),\n\n source_data as (\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n insertions as (\n\n select\n \'insert\' as dbt_change_type,\n source_data.*\n\n from 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 snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n )\n\n select * from insertions\n\n{%- endmacro %}\n\n\n{% macro snapshot_staging_table_updates(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\n ),\n\n source_data as (\n\n select\n *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n updates as (\n\n select\n \'update\' as dbt_change_type,\n snapshotted_data.dbt_scd_id,\n source_data.dbt_valid_from as dbt_valid_to\n\n from source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n\n )\n\n select * from updates\n\n{%- endmacro %}\n\n\n{% macro 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 %}\n\n\n{% macro 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 %}\n\n{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n\n {% set inserts_select = snapshot_staging_table_inserts(strategy, sql, target_relation) %}\n {% set updates_select = snapshot_staging_table_updates(strategy, sql, target_relation) %}\n\n {% call statement(\'build_snapshot_staging_relation_inserts\') %}\n {{ create_table_as(True, tmp_relation, inserts_select) }}\n {% endcall %}\n\n {% call statement(\'build_snapshot_staging_relation_updates\') %}\n insert into {{ tmp_relation }} (dbt_change_type, dbt_scd_id, dbt_valid_to)\n select dbt_change_type, dbt_scd_id, dbt_valid_to from (\n {{ updates_select }}\n ) dbt_sbq\n {% endcall %}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n\n{% 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\n {% if not adapter.check_schema_exists(model.database, model.schema) %}\n {% do create_schema(model.database, model.schema) %}\n {% endif %}\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[\'injected_sql\']) %}\n {% call statement(\'main\') -%}\n {{ create_table_as(False, target_relation, build_sql) }}\n {% endcall %}\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 {% call statement(\'main\') %}\n {{ snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n }}\n {% endcall %}\n\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 %}', 'unique_id': 'macro.dbt.build_snapshot_staging_table', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/snapshot.sql', 'original_file_path': 'macros/materializations/snapshot/snapshot.sql', 'resource_type': 'macro', 'name': 'build_snapshot_staging_table', 'macro_sql': "{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n\n {% set inserts_select = snapshot_staging_table_inserts(strategy, sql, target_relation) %}\n {% set updates_select = snapshot_staging_table_updates(strategy, sql, target_relation) %}\n\n {% call statement('build_snapshot_staging_relation_inserts') %}\n {{ create_table_as(True, tmp_relation, inserts_select) }}\n {% endcall %}\n\n {% call statement('build_snapshot_staging_relation_updates') %}\n insert into {{ tmp_relation }} (dbt_change_type, dbt_scd_id, dbt_valid_to)\n select dbt_change_type, dbt_scd_id, dbt_valid_to from (\n {{ updates_select }}\n ) dbt_sbq\n {% endcall %}\n\n {% do return(tmp_relation) %}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.materialization_snapshot_default': {'raw_sql': '{#\n Add new columns to the table if applicable\n#}\n{% macro create_columns(relation, columns) %}\n {{ adapter_macro(\'create_columns\', relation, columns) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro post_snapshot(staging_relation) %}\n {{ adapter_macro(\'post_snapshot\', staging_relation) }}\n{% endmacro %}\n\n{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}\n\n\n{% macro snapshot_staging_table_inserts(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\n ),\n\n source_data as (\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n insertions as (\n\n select\n \'insert\' as dbt_change_type,\n source_data.*\n\n from 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 snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n )\n\n select * from insertions\n\n{%- endmacro %}\n\n\n{% macro snapshot_staging_table_updates(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\n ),\n\n source_data as (\n\n select\n *,\n {{ strategy.scd_id }} as dbt_scd_id,\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\n from snapshot_query\n ),\n\n updates as (\n\n select\n \'update\' as dbt_change_type,\n snapshotted_data.dbt_scd_id,\n source_data.dbt_valid_from as dbt_valid_to\n\n from source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_valid_to is null\n and (\n {{ strategy.row_changed }}\n )\n\n )\n\n select * from updates\n\n{%- endmacro %}\n\n\n{% macro 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 %}\n\n\n{% macro 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 %}\n\n{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n\n {% set inserts_select = snapshot_staging_table_inserts(strategy, sql, target_relation) %}\n {% set updates_select = snapshot_staging_table_updates(strategy, sql, target_relation) %}\n\n {% call statement(\'build_snapshot_staging_relation_inserts\') %}\n {{ create_table_as(True, tmp_relation, inserts_select) }}\n {% endcall %}\n\n {% call statement(\'build_snapshot_staging_relation_updates\') %}\n insert into {{ tmp_relation }} (dbt_change_type, dbt_scd_id, dbt_valid_to)\n select dbt_change_type, dbt_scd_id, dbt_valid_to from (\n {{ updates_select }}\n ) dbt_sbq\n {% endcall %}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n\n{% 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\n {% if not adapter.check_schema_exists(model.database, model.schema) %}\n {% do create_schema(model.database, model.schema) %}\n {% endif %}\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[\'injected_sql\']) %}\n {% call statement(\'main\') -%}\n {{ create_table_as(False, target_relation, build_sql) }}\n {% endcall %}\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 {% call statement(\'main\') %}\n {{ snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n }}\n {% endcall %}\n\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 %}', 'unique_id': 'macro.dbt.materialization_snapshot_default', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/snapshot/snapshot.sql', 'original_file_path': 'macros/materializations/snapshot/snapshot.sql', 'resource_type': 'macro', '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\n {% if not adapter.check_schema_exists(model.database, model.schema) %}\n {% do create_schema(model.database, model.schema) %}\n {% endif %}\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[\'injected_sql\']) %}\n {% call statement(\'main\') -%}\n {{ create_table_as(False, target_relation, build_sql) }}\n {% endcall %}\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 {% call statement(\'main\') %}\n {{ snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n }}\n {% endcall %}\n\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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.create_csv_table': {'raw_sql': '{% macro create_csv_table(model, agate_table) -%}\n {{ adapter_macro(\'create_csv_table\', model, agate_table) }}\n{%- endmacro %}\n\n{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter_macro(\'reset_csv_table\', model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}\n\n{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter_macro(\'load_csv_rows\', model, agate_table) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% macro basic_load_csv_rows(model, batch_size, agate_table) %}\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(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 %}\n\n\n{% macro default__load_csv_rows(model, agate_table) %}\n {{ return(basic_load_csv_rows(model, 10000, agate_table) )}}\n{% endmacro %}\n\n\n{% materialization seed, default %}\n\n {%- set identifier = model[\'alias\'] -%}\n {%- set full_refresh_mode = (flags.FULL_REFRESH == True) -%}\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 agate_table = load_agate_table() -%}\n {%- do store_result(\'agate_table\', status=\'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 status = \'CREATE\' if full_refresh_mode else \'INSERT\' %}\n {% set num_rows = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement(\'main\', status ~ \' \' ~ num_rows) %}\n {{ create_table_sql }};\n -- dbt seed --\n {{ sql }}\n {% endcall %}\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 {% set target_relation = this.incorporate(type=\'table\') %}\n {{ return({\'relations\': [target_relation]}) }}\n\n{% endmaterialization %}', 'unique_id': 'macro.dbt.create_csv_table', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/seed/seed.sql', 'original_file_path': 'macros/materializations/seed/seed.sql', 'resource_type': 'macro', 'name': 'create_csv_table', 'macro_sql': "{% macro create_csv_table(model, agate_table) -%}\n {{ adapter_macro('create_csv_table', model, agate_table) }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.reset_csv_table': {'raw_sql': '{% macro create_csv_table(model, agate_table) -%}\n {{ adapter_macro(\'create_csv_table\', model, agate_table) }}\n{%- endmacro %}\n\n{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter_macro(\'reset_csv_table\', model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}\n\n{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter_macro(\'load_csv_rows\', model, agate_table) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% macro basic_load_csv_rows(model, batch_size, agate_table) %}\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(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 %}\n\n\n{% macro default__load_csv_rows(model, agate_table) %}\n {{ return(basic_load_csv_rows(model, 10000, agate_table) )}}\n{% endmacro %}\n\n\n{% materialization seed, default %}\n\n {%- set identifier = model[\'alias\'] -%}\n {%- set full_refresh_mode = (flags.FULL_REFRESH == True) -%}\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 agate_table = load_agate_table() -%}\n {%- do store_result(\'agate_table\', status=\'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 status = \'CREATE\' if full_refresh_mode else \'INSERT\' %}\n {% set num_rows = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement(\'main\', status ~ \' \' ~ num_rows) %}\n {{ create_table_sql }};\n -- dbt seed --\n {{ sql }}\n {% endcall %}\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 {% set target_relation = this.incorporate(type=\'table\') %}\n {{ return({\'relations\': [target_relation]}) }}\n\n{% endmaterialization %}', 'unique_id': 'macro.dbt.reset_csv_table', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/seed/seed.sql', 'original_file_path': 'macros/materializations/seed/seed.sql', 'resource_type': 'macro', 'name': 'reset_csv_table', 'macro_sql': "{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter_macro('reset_csv_table', model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.load_csv_rows': {'raw_sql': '{% macro create_csv_table(model, agate_table) -%}\n {{ adapter_macro(\'create_csv_table\', model, agate_table) }}\n{%- endmacro %}\n\n{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter_macro(\'reset_csv_table\', model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}\n\n{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter_macro(\'load_csv_rows\', model, agate_table) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% macro basic_load_csv_rows(model, batch_size, agate_table) %}\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(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 %}\n\n\n{% macro default__load_csv_rows(model, agate_table) %}\n {{ return(basic_load_csv_rows(model, 10000, agate_table) )}}\n{% endmacro %}\n\n\n{% materialization seed, default %}\n\n {%- set identifier = model[\'alias\'] -%}\n {%- set full_refresh_mode = (flags.FULL_REFRESH == True) -%}\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 agate_table = load_agate_table() -%}\n {%- do store_result(\'agate_table\', status=\'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 status = \'CREATE\' if full_refresh_mode else \'INSERT\' %}\n {% set num_rows = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement(\'main\', status ~ \' \' ~ num_rows) %}\n {{ create_table_sql }};\n -- dbt seed --\n {{ sql }}\n {% endcall %}\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 {% set target_relation = this.incorporate(type=\'table\') %}\n {{ return({\'relations\': [target_relation]}) }}\n\n{% endmaterialization %}', 'unique_id': 'macro.dbt.load_csv_rows', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/seed/seed.sql', 'original_file_path': 'macros/materializations/seed/seed.sql', 'resource_type': 'macro', 'name': 'load_csv_rows', 'macro_sql': "{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter_macro('load_csv_rows', model, agate_table) }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__create_csv_table': {'raw_sql': '{% macro create_csv_table(model, agate_table) -%}\n {{ adapter_macro(\'create_csv_table\', model, agate_table) }}\n{%- endmacro %}\n\n{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter_macro(\'reset_csv_table\', model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}\n\n{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter_macro(\'load_csv_rows\', model, agate_table) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% macro basic_load_csv_rows(model, batch_size, agate_table) %}\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(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 %}\n\n\n{% macro default__load_csv_rows(model, agate_table) %}\n {{ return(basic_load_csv_rows(model, 10000, agate_table) )}}\n{% endmacro %}\n\n\n{% materialization seed, default %}\n\n {%- set identifier = model[\'alias\'] -%}\n {%- set full_refresh_mode = (flags.FULL_REFRESH == True) -%}\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 agate_table = load_agate_table() -%}\n {%- do store_result(\'agate_table\', status=\'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 status = \'CREATE\' if full_refresh_mode else \'INSERT\' %}\n {% set num_rows = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement(\'main\', status ~ \' \' ~ num_rows) %}\n {{ create_table_sql }};\n -- dbt seed --\n {{ sql }}\n {% endcall %}\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 {% set target_relation = this.incorporate(type=\'table\') %}\n {{ return({\'relations\': [target_relation]}) }}\n\n{% endmaterialization %}', 'unique_id': 'macro.dbt.default__create_csv_table', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/seed/seed.sql', 'original_file_path': 'macros/materializations/seed/seed.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__reset_csv_table': {'raw_sql': '{% macro create_csv_table(model, agate_table) -%}\n {{ adapter_macro(\'create_csv_table\', model, agate_table) }}\n{%- endmacro %}\n\n{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter_macro(\'reset_csv_table\', model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}\n\n{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter_macro(\'load_csv_rows\', model, agate_table) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% macro basic_load_csv_rows(model, batch_size, agate_table) %}\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(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 %}\n\n\n{% macro default__load_csv_rows(model, agate_table) %}\n {{ return(basic_load_csv_rows(model, 10000, agate_table) )}}\n{% endmacro %}\n\n\n{% materialization seed, default %}\n\n {%- set identifier = model[\'alias\'] -%}\n {%- set full_refresh_mode = (flags.FULL_REFRESH == True) -%}\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 agate_table = load_agate_table() -%}\n {%- do store_result(\'agate_table\', status=\'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 status = \'CREATE\' if full_refresh_mode else \'INSERT\' %}\n {% set num_rows = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement(\'main\', status ~ \' \' ~ num_rows) %}\n {{ create_table_sql }};\n -- dbt seed --\n {{ sql }}\n {% endcall %}\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 {% set target_relation = this.incorporate(type=\'table\') %}\n {{ return({\'relations\': [target_relation]}) }}\n\n{% endmaterialization %}', 'unique_id': 'macro.dbt.default__reset_csv_table', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/seed/seed.sql', 'original_file_path': 'macros/materializations/seed/seed.sql', 'resource_type': 'macro', '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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.get_seed_column_quoted_csv': {'raw_sql': '{% macro create_csv_table(model, agate_table) -%}\n {{ adapter_macro(\'create_csv_table\', model, agate_table) }}\n{%- endmacro %}\n\n{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter_macro(\'reset_csv_table\', model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}\n\n{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter_macro(\'load_csv_rows\', model, agate_table) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% macro basic_load_csv_rows(model, batch_size, agate_table) %}\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(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 %}\n\n\n{% macro default__load_csv_rows(model, agate_table) %}\n {{ return(basic_load_csv_rows(model, 10000, agate_table) )}}\n{% endmacro %}\n\n\n{% materialization seed, default %}\n\n {%- set identifier = model[\'alias\'] -%}\n {%- set full_refresh_mode = (flags.FULL_REFRESH == True) -%}\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 agate_table = load_agate_table() -%}\n {%- do store_result(\'agate_table\', status=\'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 status = \'CREATE\' if full_refresh_mode else \'INSERT\' %}\n {% set num_rows = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement(\'main\', status ~ \' \' ~ num_rows) %}\n {{ create_table_sql }};\n -- dbt seed --\n {{ sql }}\n {% endcall %}\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 {% set target_relation = this.incorporate(type=\'table\') %}\n {{ return({\'relations\': [target_relation]}) }}\n\n{% endmaterialization %}', 'unique_id': 'macro.dbt.get_seed_column_quoted_csv', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/seed/seed.sql', 'original_file_path': 'macros/materializations/seed/seed.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.basic_load_csv_rows': {'raw_sql': '{% macro create_csv_table(model, agate_table) -%}\n {{ adapter_macro(\'create_csv_table\', model, agate_table) }}\n{%- endmacro %}\n\n{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter_macro(\'reset_csv_table\', model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}\n\n{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter_macro(\'load_csv_rows\', model, agate_table) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% macro basic_load_csv_rows(model, batch_size, agate_table) %}\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(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 %}\n\n\n{% macro default__load_csv_rows(model, agate_table) %}\n {{ return(basic_load_csv_rows(model, 10000, agate_table) )}}\n{% endmacro %}\n\n\n{% materialization seed, default %}\n\n {%- set identifier = model[\'alias\'] -%}\n {%- set full_refresh_mode = (flags.FULL_REFRESH == True) -%}\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 agate_table = load_agate_table() -%}\n {%- do store_result(\'agate_table\', status=\'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 status = \'CREATE\' if full_refresh_mode else \'INSERT\' %}\n {% set num_rows = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement(\'main\', status ~ \' \' ~ num_rows) %}\n {{ create_table_sql }};\n -- dbt seed --\n {{ sql }}\n {% endcall %}\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 {% set target_relation = this.incorporate(type=\'table\') %}\n {{ return({\'relations\': [target_relation]}) }}\n\n{% endmaterialization %}', 'unique_id': 'macro.dbt.basic_load_csv_rows', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/seed/seed.sql', 'original_file_path': 'macros/materializations/seed/seed.sql', 'resource_type': 'macro', 'name': 'basic_load_csv_rows', 'macro_sql': '{% macro basic_load_csv_rows(model, batch_size, agate_table) %}\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(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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__load_csv_rows': {'raw_sql': '{% macro create_csv_table(model, agate_table) -%}\n {{ adapter_macro(\'create_csv_table\', model, agate_table) }}\n{%- endmacro %}\n\n{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter_macro(\'reset_csv_table\', model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}\n\n{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter_macro(\'load_csv_rows\', model, agate_table) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% macro basic_load_csv_rows(model, batch_size, agate_table) %}\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(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 %}\n\n\n{% macro default__load_csv_rows(model, agate_table) %}\n {{ return(basic_load_csv_rows(model, 10000, agate_table) )}}\n{% endmacro %}\n\n\n{% materialization seed, default %}\n\n {%- set identifier = model[\'alias\'] -%}\n {%- set full_refresh_mode = (flags.FULL_REFRESH == True) -%}\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 agate_table = load_agate_table() -%}\n {%- do store_result(\'agate_table\', status=\'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 status = \'CREATE\' if full_refresh_mode else \'INSERT\' %}\n {% set num_rows = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement(\'main\', status ~ \' \' ~ num_rows) %}\n {{ create_table_sql }};\n -- dbt seed --\n {{ sql }}\n {% endcall %}\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 {% set target_relation = this.incorporate(type=\'table\') %}\n {{ return({\'relations\': [target_relation]}) }}\n\n{% endmaterialization %}', 'unique_id': 'macro.dbt.default__load_csv_rows', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/seed/seed.sql', 'original_file_path': 'macros/materializations/seed/seed.sql', 'resource_type': 'macro', 'name': 'default__load_csv_rows', 'macro_sql': '{% macro default__load_csv_rows(model, agate_table) %}\n {{ return(basic_load_csv_rows(model, 10000, agate_table) )}}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.materialization_seed_default': {'raw_sql': '{% macro create_csv_table(model, agate_table) -%}\n {{ adapter_macro(\'create_csv_table\', model, agate_table) }}\n{%- endmacro %}\n\n{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter_macro(\'reset_csv_table\', model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}\n\n{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter_macro(\'load_csv_rows\', model, agate_table) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% 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 %}\n\n\n{% macro basic_load_csv_rows(model, batch_size, agate_table) %}\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(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 %}\n\n\n{% macro default__load_csv_rows(model, agate_table) %}\n {{ return(basic_load_csv_rows(model, 10000, agate_table) )}}\n{% endmacro %}\n\n\n{% materialization seed, default %}\n\n {%- set identifier = model[\'alias\'] -%}\n {%- set full_refresh_mode = (flags.FULL_REFRESH == True) -%}\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 agate_table = load_agate_table() -%}\n {%- do store_result(\'agate_table\', status=\'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 status = \'CREATE\' if full_refresh_mode else \'INSERT\' %}\n {% set num_rows = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement(\'main\', status ~ \' \' ~ num_rows) %}\n {{ create_table_sql }};\n -- dbt seed --\n {{ sql }}\n {% endcall %}\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 {% set target_relation = this.incorporate(type=\'table\') %}\n {{ return({\'relations\': [target_relation]}) }}\n\n{% endmaterialization %}', 'unique_id': 'macro.dbt.materialization_seed_default', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/seed/seed.sql', 'original_file_path': 'macros/materializations/seed/seed.sql', 'resource_type': 'macro', 'name': 'materialization_seed_default', 'macro_sql': '{% materialization seed, default %}\n\n {%- set identifier = model[\'alias\'] -%}\n {%- set full_refresh_mode = (flags.FULL_REFRESH == True) -%}\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 agate_table = load_agate_table() -%}\n {%- do store_result(\'agate_table\', status=\'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 status = \'CREATE\' if full_refresh_mode else \'INSERT\' %}\n {% set num_rows = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement(\'main\', status ~ \' \' ~ num_rows) %}\n {{ create_table_sql }};\n -- dbt seed --\n {{ sql }}\n {% endcall %}\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 {% set target_relation = this.incorporate(type=\'table\') %}\n {{ return({\'relations\': [target_relation]}) }}\n\n{% endmaterialization %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.incremental_upsert': {'raw_sql': '{% macro incremental_upsert(tmp_relation, target_relation, unique_key=none, statement_name="main") %}\n {%- set dest_columns = adapter.get_columns_in_relation(target_relation) -%}\n {%- set dest_cols_csv = dest_columns | map(attribute=\'quoted\') | join(\', \') -%}\n\n {%- if unique_key is not none -%}\n delete\n from {{ target_relation }}\n where ({{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ tmp_relation }}\n );\n {%- endif %}\n\n insert into {{ target_relation }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ tmp_relation }}\n );\n{%- endmacro %}', 'unique_id': 'macro.dbt.incremental_upsert', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/incremental/helpers.sql', 'original_file_path': 'macros/materializations/incremental/helpers.sql', 'resource_type': 'macro', 'name': 'incremental_upsert', 'macro_sql': '{% macro incremental_upsert(tmp_relation, target_relation, unique_key=none, statement_name="main") %}\n {%- set dest_columns = adapter.get_columns_in_relation(target_relation) -%}\n {%- set dest_cols_csv = dest_columns | map(attribute=\'quoted\') | join(\', \') -%}\n\n {%- if unique_key is not none -%}\n delete\n from {{ target_relation }}\n where ({{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ tmp_relation }}\n );\n {%- endif %}\n\n insert into {{ target_relation }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ tmp_relation }}\n );\n{%- endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.materialization_incremental_default': {'raw_sql': '{% materialization incremental, default -%}\n\n {% set unique_key = config.get(\'unique_key\') %}\n {% set full_refresh_mode = flags.FULL_REFRESH %}\n\n {% set target_relation = this %}\n {% set existing_relation = load_relation(this) %}\n {% set tmp_relation = make_temp_relation(this) %}\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 {% if existing_relation is none %}\n {% set build_sql = create_table_as(False, target_relation, sql) %}\n {% elif existing_relation.is_view or full_refresh_mode %}\n {#-- Make sure the backup doesn\'t exist so we don\'t encounter issues with the rename below #}\n {% set backup_identifier = existing_relation.identifier ~ "__dbt_backup" %}\n {% set backup_relation = existing_relation.incorporate(path={"identifier": backup_identifier}) %}\n {% do adapter.drop_relation(backup_relation) %}\n\n {% do adapter.rename_relation(target_relation, backup_relation) %}\n {% set build_sql = create_table_as(False, target_relation, sql) %}\n {% do to_drop.append(backup_relation) %}\n {% else %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n {% do run_query(create_table_as(True, tmp_relation, sql)) %}\n {% do adapter.expand_target_column_types(\n from_relation=tmp_relation,\n to_relation=target_relation) %}\n {% set build_sql = incremental_upsert(tmp_relation, target_relation, unique_key=unique_key) %}\n {% endif %}\n\n {% call statement("main") %}\n {{ build_sql }}\n {% endcall %}\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 %}', 'unique_id': 'macro.dbt.materialization_incremental_default', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/incremental/incremental.sql', 'original_file_path': 'macros/materializations/incremental/incremental.sql', 'resource_type': 'macro', 'name': 'materialization_incremental_default', 'macro_sql': '{% materialization incremental, default -%}\n\n {% set unique_key = config.get(\'unique_key\') %}\n {% set full_refresh_mode = flags.FULL_REFRESH %}\n\n {% set target_relation = this %}\n {% set existing_relation = load_relation(this) %}\n {% set tmp_relation = make_temp_relation(this) %}\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 {% if existing_relation is none %}\n {% set build_sql = create_table_as(False, target_relation, sql) %}\n {% elif existing_relation.is_view or full_refresh_mode %}\n {#-- Make sure the backup doesn\'t exist so we don\'t encounter issues with the rename below #}\n {% set backup_identifier = existing_relation.identifier ~ "__dbt_backup" %}\n {% set backup_relation = existing_relation.incorporate(path={"identifier": backup_identifier}) %}\n {% do adapter.drop_relation(backup_relation) %}\n\n {% do adapter.rename_relation(target_relation, backup_relation) %}\n {% set build_sql = create_table_as(False, target_relation, sql) %}\n {% do to_drop.append(backup_relation) %}\n {% else %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n {% do run_query(create_table_as(True, tmp_relation, sql)) %}\n {% do adapter.expand_target_column_types(\n from_relation=tmp_relation,\n to_relation=target_relation) %}\n {% set build_sql = incremental_upsert(tmp_relation, target_relation, unique_key=unique_key) %}\n {% endif %}\n\n {% call statement("main") %}\n {{ build_sql }}\n {% endcall %}\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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.get_merge_sql': {'raw_sql': '{% macro get_merge_sql(target, source, unique_key, dest_columns, predicates=none) -%}\n {{ adapter_macro(\'get_merge_sql\', target, source, unique_key, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ adapter_macro(\'get_delete_insert_merge_sql\', target, source, unique_key, dest_columns) }}\n{%- endmacro %}\n\n\n{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates) -%}\n {{ adapter_macro(\'get_insert_overwrite_merge_sql\', target, source, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% 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\n {% if unique_key %}\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 {% else %}\n {% do predicates.append(\'FALSE\') %}\n {% endif %}\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 in dest_columns -%}\n {{ adapter.quote(column.name) }} = DBT_INTERNAL_SOURCE.{{ adapter.quote(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 %}\n\n\n{% macro get_quoted_csv(column_names) %}\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{% endmacro %}\n\n\n{% macro common_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 is not none %}\n delete from {{ target }}\n where ({{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n );\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n );\n\n{%- endmacro %}\n\n{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ common_get_delete_insert_merge_sql(target, source, unique_key, dest_columns) }}\n{% endmacro %}\n\n\n{% macro default__get_insert_overwrite_merge_sql(target, source, 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\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 %}', 'unique_id': 'macro.dbt.get_merge_sql', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/common/merge.sql', 'original_file_path': 'macros/materializations/common/merge.sql', 'resource_type': 'macro', 'name': 'get_merge_sql', 'macro_sql': "{% macro get_merge_sql(target, source, unique_key, dest_columns, predicates=none) -%}\n {{ adapter_macro('get_merge_sql', target, source, unique_key, dest_columns, predicates) }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.get_delete_insert_merge_sql': {'raw_sql': '{% macro get_merge_sql(target, source, unique_key, dest_columns, predicates=none) -%}\n {{ adapter_macro(\'get_merge_sql\', target, source, unique_key, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ adapter_macro(\'get_delete_insert_merge_sql\', target, source, unique_key, dest_columns) }}\n{%- endmacro %}\n\n\n{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates) -%}\n {{ adapter_macro(\'get_insert_overwrite_merge_sql\', target, source, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% 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\n {% if unique_key %}\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 {% else %}\n {% do predicates.append(\'FALSE\') %}\n {% endif %}\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 in dest_columns -%}\n {{ adapter.quote(column.name) }} = DBT_INTERNAL_SOURCE.{{ adapter.quote(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 %}\n\n\n{% macro get_quoted_csv(column_names) %}\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{% endmacro %}\n\n\n{% macro common_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 is not none %}\n delete from {{ target }}\n where ({{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n );\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n );\n\n{%- endmacro %}\n\n{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ common_get_delete_insert_merge_sql(target, source, unique_key, dest_columns) }}\n{% endmacro %}\n\n\n{% macro default__get_insert_overwrite_merge_sql(target, source, 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\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 %}', 'unique_id': 'macro.dbt.get_delete_insert_merge_sql', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/common/merge.sql', 'original_file_path': 'macros/materializations/common/merge.sql', 'resource_type': 'macro', 'name': 'get_delete_insert_merge_sql', 'macro_sql': "{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ adapter_macro('get_delete_insert_merge_sql', target, source, unique_key, dest_columns) }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.get_insert_overwrite_merge_sql': {'raw_sql': '{% macro get_merge_sql(target, source, unique_key, dest_columns, predicates=none) -%}\n {{ adapter_macro(\'get_merge_sql\', target, source, unique_key, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ adapter_macro(\'get_delete_insert_merge_sql\', target, source, unique_key, dest_columns) }}\n{%- endmacro %}\n\n\n{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates) -%}\n {{ adapter_macro(\'get_insert_overwrite_merge_sql\', target, source, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% 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\n {% if unique_key %}\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 {% else %}\n {% do predicates.append(\'FALSE\') %}\n {% endif %}\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 in dest_columns -%}\n {{ adapter.quote(column.name) }} = DBT_INTERNAL_SOURCE.{{ adapter.quote(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 %}\n\n\n{% macro get_quoted_csv(column_names) %}\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{% endmacro %}\n\n\n{% macro common_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 is not none %}\n delete from {{ target }}\n where ({{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n );\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n );\n\n{%- endmacro %}\n\n{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ common_get_delete_insert_merge_sql(target, source, unique_key, dest_columns) }}\n{% endmacro %}\n\n\n{% macro default__get_insert_overwrite_merge_sql(target, source, 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\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 %}', 'unique_id': 'macro.dbt.get_insert_overwrite_merge_sql', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/common/merge.sql', 'original_file_path': 'macros/materializations/common/merge.sql', 'resource_type': 'macro', 'name': 'get_insert_overwrite_merge_sql', 'macro_sql': "{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates) -%}\n {{ adapter_macro('get_insert_overwrite_merge_sql', target, source, dest_columns, predicates) }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__get_merge_sql': {'raw_sql': '{% macro get_merge_sql(target, source, unique_key, dest_columns, predicates=none) -%}\n {{ adapter_macro(\'get_merge_sql\', target, source, unique_key, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ adapter_macro(\'get_delete_insert_merge_sql\', target, source, unique_key, dest_columns) }}\n{%- endmacro %}\n\n\n{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates) -%}\n {{ adapter_macro(\'get_insert_overwrite_merge_sql\', target, source, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% 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\n {% if unique_key %}\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 {% else %}\n {% do predicates.append(\'FALSE\') %}\n {% endif %}\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 in dest_columns -%}\n {{ adapter.quote(column.name) }} = DBT_INTERNAL_SOURCE.{{ adapter.quote(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 %}\n\n\n{% macro get_quoted_csv(column_names) %}\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{% endmacro %}\n\n\n{% macro common_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 is not none %}\n delete from {{ target }}\n where ({{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n );\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n );\n\n{%- endmacro %}\n\n{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ common_get_delete_insert_merge_sql(target, source, unique_key, dest_columns) }}\n{% endmacro %}\n\n\n{% macro default__get_insert_overwrite_merge_sql(target, source, 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\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 %}', 'unique_id': 'macro.dbt.default__get_merge_sql', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/common/merge.sql', 'original_file_path': 'macros/materializations/common/merge.sql', 'resource_type': 'macro', '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\n {% if unique_key %}\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 {% else %}\n {% do predicates.append(\'FALSE\') %}\n {% endif %}\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 in dest_columns -%}\n {{ adapter.quote(column.name) }} = DBT_INTERNAL_SOURCE.{{ adapter.quote(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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.get_quoted_csv': {'raw_sql': '{% macro get_merge_sql(target, source, unique_key, dest_columns, predicates=none) -%}\n {{ adapter_macro(\'get_merge_sql\', target, source, unique_key, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ adapter_macro(\'get_delete_insert_merge_sql\', target, source, unique_key, dest_columns) }}\n{%- endmacro %}\n\n\n{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates) -%}\n {{ adapter_macro(\'get_insert_overwrite_merge_sql\', target, source, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% 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\n {% if unique_key %}\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 {% else %}\n {% do predicates.append(\'FALSE\') %}\n {% endif %}\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 in dest_columns -%}\n {{ adapter.quote(column.name) }} = DBT_INTERNAL_SOURCE.{{ adapter.quote(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 %}\n\n\n{% macro get_quoted_csv(column_names) %}\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{% endmacro %}\n\n\n{% macro common_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 is not none %}\n delete from {{ target }}\n where ({{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n );\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n );\n\n{%- endmacro %}\n\n{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ common_get_delete_insert_merge_sql(target, source, unique_key, dest_columns) }}\n{% endmacro %}\n\n\n{% macro default__get_insert_overwrite_merge_sql(target, source, 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\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 %}', 'unique_id': 'macro.dbt.get_quoted_csv', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/common/merge.sql', 'original_file_path': 'macros/materializations/common/merge.sql', 'resource_type': 'macro', 'name': 'get_quoted_csv', 'macro_sql': "{% macro get_quoted_csv(column_names) %}\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{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.common_get_delete_insert_merge_sql': {'raw_sql': '{% macro get_merge_sql(target, source, unique_key, dest_columns, predicates=none) -%}\n {{ adapter_macro(\'get_merge_sql\', target, source, unique_key, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ adapter_macro(\'get_delete_insert_merge_sql\', target, source, unique_key, dest_columns) }}\n{%- endmacro %}\n\n\n{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates) -%}\n {{ adapter_macro(\'get_insert_overwrite_merge_sql\', target, source, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% 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\n {% if unique_key %}\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 {% else %}\n {% do predicates.append(\'FALSE\') %}\n {% endif %}\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 in dest_columns -%}\n {{ adapter.quote(column.name) }} = DBT_INTERNAL_SOURCE.{{ adapter.quote(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 %}\n\n\n{% macro get_quoted_csv(column_names) %}\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{% endmacro %}\n\n\n{% macro common_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 is not none %}\n delete from {{ target }}\n where ({{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n );\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n );\n\n{%- endmacro %}\n\n{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ common_get_delete_insert_merge_sql(target, source, unique_key, dest_columns) }}\n{% endmacro %}\n\n\n{% macro default__get_insert_overwrite_merge_sql(target, source, 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\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 %}', 'unique_id': 'macro.dbt.common_get_delete_insert_merge_sql', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/common/merge.sql', 'original_file_path': 'macros/materializations/common/merge.sql', 'resource_type': 'macro', 'name': 'common_get_delete_insert_merge_sql', 'macro_sql': '{% macro common_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 is not none %}\n delete from {{ target }}\n where ({{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n );\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n );\n\n{%- endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__get_delete_insert_merge_sql': {'raw_sql': '{% macro get_merge_sql(target, source, unique_key, dest_columns, predicates=none) -%}\n {{ adapter_macro(\'get_merge_sql\', target, source, unique_key, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ adapter_macro(\'get_delete_insert_merge_sql\', target, source, unique_key, dest_columns) }}\n{%- endmacro %}\n\n\n{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates) -%}\n {{ adapter_macro(\'get_insert_overwrite_merge_sql\', target, source, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% 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\n {% if unique_key %}\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 {% else %}\n {% do predicates.append(\'FALSE\') %}\n {% endif %}\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 in dest_columns -%}\n {{ adapter.quote(column.name) }} = DBT_INTERNAL_SOURCE.{{ adapter.quote(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 %}\n\n\n{% macro get_quoted_csv(column_names) %}\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{% endmacro %}\n\n\n{% macro common_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 is not none %}\n delete from {{ target }}\n where ({{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n );\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n );\n\n{%- endmacro %}\n\n{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ common_get_delete_insert_merge_sql(target, source, unique_key, dest_columns) }}\n{% endmacro %}\n\n\n{% macro default__get_insert_overwrite_merge_sql(target, source, 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\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 %}', 'unique_id': 'macro.dbt.default__get_delete_insert_merge_sql', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/common/merge.sql', 'original_file_path': 'macros/materializations/common/merge.sql', 'resource_type': 'macro', 'name': 'default__get_delete_insert_merge_sql', 'macro_sql': '{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ common_get_delete_insert_merge_sql(target, source, unique_key, dest_columns) }}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__get_insert_overwrite_merge_sql': {'raw_sql': '{% macro get_merge_sql(target, source, unique_key, dest_columns, predicates=none) -%}\n {{ adapter_macro(\'get_merge_sql\', target, source, unique_key, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ adapter_macro(\'get_delete_insert_merge_sql\', target, source, unique_key, dest_columns) }}\n{%- endmacro %}\n\n\n{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates) -%}\n {{ adapter_macro(\'get_insert_overwrite_merge_sql\', target, source, dest_columns, predicates) }}\n{%- endmacro %}\n\n\n{% 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\n {% if unique_key %}\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 {% else %}\n {% do predicates.append(\'FALSE\') %}\n {% endif %}\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 in dest_columns -%}\n {{ adapter.quote(column.name) }} = DBT_INTERNAL_SOURCE.{{ adapter.quote(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 %}\n\n\n{% macro get_quoted_csv(column_names) %}\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{% endmacro %}\n\n\n{% macro common_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 is not none %}\n delete from {{ target }}\n where ({{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n );\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n );\n\n{%- endmacro %}\n\n{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ common_get_delete_insert_merge_sql(target, source, unique_key, dest_columns) }}\n{% endmacro %}\n\n\n{% macro default__get_insert_overwrite_merge_sql(target, source, 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\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 %}', 'unique_id': 'macro.dbt.default__get_insert_overwrite_merge_sql', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/common/merge.sql', 'original_file_path': 'macros/materializations/common/merge.sql', 'resource_type': 'macro', 'name': 'default__get_insert_overwrite_merge_sql', 'macro_sql': '{% macro default__get_insert_overwrite_merge_sql(target, source, 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\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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.materialization_table_default': {'raw_sql': "{% materialization table, default %}\n {%- set identifier = model['alias'] -%}\n {%- set tmp_identifier = model['name'] + '__dbt_tmp' -%}\n {%- set backup_identifier = model['name'] + '__dbt_backup' -%}\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,\n type='table') -%}\n {%- set intermediate_relation = api.Relation.create(identifier=tmp_identifier,\n schema=schema,\n database=database,\n type='table') -%}\n\n /*\n See ../view/view.sql for more information about this relation.\n */\n {%- set backup_relation_type = 'table' if old_relation is none else old_relation.type -%}\n {%- set backup_relation = api.Relation.create(identifier=backup_identifier,\n schema=schema,\n database=database,\n type=backup_relation_type) -%}\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\n -- drop the temp relations if they exists for some reason\n {{ adapter.drop_relation(intermediate_relation) }}\n {{ adapter.drop_relation(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 {{ create_table_as(False, intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n {% if old_relation is not none %}\n {{ adapter.rename_relation(target_relation, backup_relation) }}\n {% endif %}\n\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\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 %}", 'unique_id': 'macro.dbt.materialization_table_default', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/table/table.sql', 'original_file_path': 'macros/materializations/table/table.sql', 'resource_type': 'macro', 'name': 'materialization_table_default', 'macro_sql': "{% materialization table, default %}\n {%- set identifier = model['alias'] -%}\n {%- set tmp_identifier = model['name'] + '__dbt_tmp' -%}\n {%- set backup_identifier = model['name'] + '__dbt_backup' -%}\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,\n type='table') -%}\n {%- set intermediate_relation = api.Relation.create(identifier=tmp_identifier,\n schema=schema,\n database=database,\n type='table') -%}\n\n /*\n See ../view/view.sql for more information about this relation.\n */\n {%- set backup_relation_type = 'table' if old_relation is none else old_relation.type -%}\n {%- set backup_relation = api.Relation.create(identifier=backup_identifier,\n schema=schema,\n database=database,\n type=backup_relation_type) -%}\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\n -- drop the temp relations if they exists for some reason\n {{ adapter.drop_relation(intermediate_relation) }}\n {{ adapter.drop_relation(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 {{ create_table_as(False, intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n {% if old_relation is not none %}\n {{ adapter.rename_relation(target_relation, backup_relation) }}\n {% endif %}\n\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.materialization_view_default': {'raw_sql': '{%- materialization view, default -%}\n\n {%- set identifier = model[\'alias\'] -%}\n {%- set tmp_identifier = model[\'name\'] + \'__dbt_tmp\' -%}\n {%- set backup_identifier = model[\'name\'] + \'__dbt_backup\' -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set target_relation = api.Relation.create(identifier=identifier, schema=schema, database=database,\n type=\'view\') -%}\n {%- set intermediate_relation = api.Relation.create(identifier=tmp_identifier,\n schema=schema, database=database, type=\'view\') -%}\n\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 "old_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 old_relation, if it exists,\n or else "view" as a sane default if it does not. Note that if the old_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 old_relation is none else old_relation.type -%}\n {%- set backup_relation = api.Relation.create(identifier=backup_identifier,\n schema=schema, database=database,\n type=backup_relation_type) -%}\n\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exists for some reason\n {{ adapter.drop_relation(intermediate_relation) }}\n {{ adapter.drop_relation(backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement(\'main\') -%}\n {{ create_view_as(intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n -- move the existing view out of the way\n {% if old_relation is not none %}\n {{ adapter.rename_relation(target_relation, backup_relation) }}\n {% endif %}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\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 -%}', 'unique_id': 'macro.dbt.materialization_view_default', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/view/view.sql', 'original_file_path': 'macros/materializations/view/view.sql', 'resource_type': 'macro', 'name': 'materialization_view_default', 'macro_sql': '{%- materialization view, default -%}\n\n {%- set identifier = model[\'alias\'] -%}\n {%- set tmp_identifier = model[\'name\'] + \'__dbt_tmp\' -%}\n {%- set backup_identifier = model[\'name\'] + \'__dbt_backup\' -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set target_relation = api.Relation.create(identifier=identifier, schema=schema, database=database,\n type=\'view\') -%}\n {%- set intermediate_relation = api.Relation.create(identifier=tmp_identifier,\n schema=schema, database=database, type=\'view\') -%}\n\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 "old_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 old_relation, if it exists,\n or else "view" as a sane default if it does not. Note that if the old_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 old_relation is none else old_relation.type -%}\n {%- set backup_relation = api.Relation.create(identifier=backup_identifier,\n schema=schema, database=database,\n type=backup_relation_type) -%}\n\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exists for some reason\n {{ adapter.drop_relation(intermediate_relation) }}\n {{ adapter.drop_relation(backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement(\'main\') -%}\n {{ create_view_as(intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n -- move the existing view out of the way\n {% if old_relation is not none %}\n {{ adapter.rename_relation(target_relation, backup_relation) }}\n {% endif %}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\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 -%}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.handle_existing_table': {'raw_sql': '{% macro handle_existing_table(full_refresh, old_relation) %}\n {{ adapter_macro("dbt.handle_existing_table", full_refresh, old_relation) }}\n{% endmacro %}\n\n{% macro default__handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.drop_relation(old_relation) }}\n{% endmacro %}\n\n{# /*\n Core materialization implementation. BigQuery and Snowflake are similar\n because both can use `create or replace view` where the resulting view schema\n is not necessarily the same as the existing view. On Redshift, this would\n result in: ERROR: cannot change number of columns in view\n\n This implementation is superior to the create_temp, swap_with_existing, drop_old\n paradigm because transactions don\'t run DDL queries atomically on Snowflake. By using\n `create or replace view`, the materialization becomes atomic in nature.\n */\n#}\n\n{% macro create_or_replace_view(run_outside_transaction_hooks=True) %}\n {%- set identifier = model[\'alias\'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\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\n {% if run_outside_transaction_hooks %}\n -- no transactions on BigQuery\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n {% endif %}\n\n -- `BEGIN` happens here on Snowflake\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\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(flags.FULL_REFRESH, old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement(\'main\') -%}\n {{ create_view_as(target_relation, sql) }}\n {%- endcall %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if run_outside_transaction_hooks %}\n -- No transactions on BigQuery\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n {% endif %}\n\n {{ return({\'relations\': [target_relation]}) }}\n\n{% endmacro %}', 'unique_id': 'macro.dbt.handle_existing_table', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/view/create_or_replace_view.sql', 'original_file_path': 'macros/materializations/view/create_or_replace_view.sql', 'resource_type': 'macro', 'name': 'handle_existing_table', 'macro_sql': '{% macro handle_existing_table(full_refresh, old_relation) %}\n {{ adapter_macro("dbt.handle_existing_table", full_refresh, old_relation) }}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__handle_existing_table': {'raw_sql': '{% macro handle_existing_table(full_refresh, old_relation) %}\n {{ adapter_macro("dbt.handle_existing_table", full_refresh, old_relation) }}\n{% endmacro %}\n\n{% macro default__handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.drop_relation(old_relation) }}\n{% endmacro %}\n\n{# /*\n Core materialization implementation. BigQuery and Snowflake are similar\n because both can use `create or replace view` where the resulting view schema\n is not necessarily the same as the existing view. On Redshift, this would\n result in: ERROR: cannot change number of columns in view\n\n This implementation is superior to the create_temp, swap_with_existing, drop_old\n paradigm because transactions don\'t run DDL queries atomically on Snowflake. By using\n `create or replace view`, the materialization becomes atomic in nature.\n */\n#}\n\n{% macro create_or_replace_view(run_outside_transaction_hooks=True) %}\n {%- set identifier = model[\'alias\'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\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\n {% if run_outside_transaction_hooks %}\n -- no transactions on BigQuery\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n {% endif %}\n\n -- `BEGIN` happens here on Snowflake\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\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(flags.FULL_REFRESH, old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement(\'main\') -%}\n {{ create_view_as(target_relation, sql) }}\n {%- endcall %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if run_outside_transaction_hooks %}\n -- No transactions on BigQuery\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n {% endif %}\n\n {{ return({\'relations\': [target_relation]}) }}\n\n{% endmacro %}', 'unique_id': 'macro.dbt.default__handle_existing_table', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/view/create_or_replace_view.sql', 'original_file_path': 'macros/materializations/view/create_or_replace_view.sql', 'resource_type': 'macro', 'name': 'default__handle_existing_table', 'macro_sql': '{% macro default__handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.drop_relation(old_relation) }}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.create_or_replace_view': {'raw_sql': '{% macro handle_existing_table(full_refresh, old_relation) %}\n {{ adapter_macro("dbt.handle_existing_table", full_refresh, old_relation) }}\n{% endmacro %}\n\n{% macro default__handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.drop_relation(old_relation) }}\n{% endmacro %}\n\n{# /*\n Core materialization implementation. BigQuery and Snowflake are similar\n because both can use `create or replace view` where the resulting view schema\n is not necessarily the same as the existing view. On Redshift, this would\n result in: ERROR: cannot change number of columns in view\n\n This implementation is superior to the create_temp, swap_with_existing, drop_old\n paradigm because transactions don\'t run DDL queries atomically on Snowflake. By using\n `create or replace view`, the materialization becomes atomic in nature.\n */\n#}\n\n{% macro create_or_replace_view(run_outside_transaction_hooks=True) %}\n {%- set identifier = model[\'alias\'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\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\n {% if run_outside_transaction_hooks %}\n -- no transactions on BigQuery\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n {% endif %}\n\n -- `BEGIN` happens here on Snowflake\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\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(flags.FULL_REFRESH, old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement(\'main\') -%}\n {{ create_view_as(target_relation, sql) }}\n {%- endcall %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if run_outside_transaction_hooks %}\n -- No transactions on BigQuery\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n {% endif %}\n\n {{ return({\'relations\': [target_relation]}) }}\n\n{% endmacro %}', 'unique_id': 'macro.dbt.create_or_replace_view', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/materializations/view/create_or_replace_view.sql', 'original_file_path': 'macros/materializations/view/create_or_replace_view.sql', 'resource_type': 'macro', 'name': 'create_or_replace_view', 'macro_sql': "{% macro create_or_replace_view(run_outside_transaction_hooks=True) %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\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\n {% if run_outside_transaction_hooks %}\n -- no transactions on BigQuery\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n {% endif %}\n\n -- `BEGIN` happens here on Snowflake\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\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(flags.FULL_REFRESH, old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ create_view_as(target_relation, sql) }}\n {%- endcall %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if run_outside_transaction_hooks %}\n -- No transactions on BigQuery\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n {% endif %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.generate_alias_name': {'raw_sql': '{#\n Renders a alias name given a custom alias name. If the custom\n alias name is none, then the resulting alias is just the filename of the\n model. If an alias override is specified, then that is used.\n\n This macro can be overriden in projects to define different semantics\n for rendering a alias name.\n\n Arguments:\n custom_alias_name: The custom alias name specified for a model, or none\n node: The available node that an alias is being generated for, or none\n\n#}\n{% macro 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 %}', 'unique_id': 'macro.dbt.generate_alias_name', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/etc/get_custom_alias.sql', 'original_file_path': 'macros/etc/get_custom_alias.sql', 'resource_type': 'macro', 'name': 'generate_alias_name', 'macro_sql': '{% macro 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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.run_query': {'raw_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 %}', 'unique_id': 'macro.dbt.run_query', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/etc/query.sql', 'original_file_path': 'macros/etc/query.sql', 'resource_type': 'macro', '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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.is_incremental': {'raw_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 flags.FULL_REFRESH) }}\n {% endif %}\n{% endmacro %}", 'unique_id': 'macro.dbt.is_incremental', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/etc/is_incremental.sql', 'original_file_path': 'macros/etc/is_incremental.sql', 'resource_type': 'macro', '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 flags.FULL_REFRESH) }}\n {% endif %}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.table_options': {'raw_sql': '{% macro table_options() %}\n {%- set raw_persist_docs = config.get(\'persist_docs\', {}) -%}\n\n{%- endmacro -%}\n\n{% macro get_relation_comment(persist_docs, model) %}\n\n {%- if persist_docs is not mapping -%}\n {{ exceptions.raise_compiler_error("Invalid value provided for \'persist_docs\'. Expected dict but got value: " ~ raw_persist_docs) }}\n {% endif %}\n\n {% if persist_docs.get(\'relation\', false) %}\n {{ return((model.description | tojson)[1:-1]) }}\n {%- else -%}\n {{ return(none) }}\n {% endif %}\n\n{% endmacro %}', 'unique_id': 'macro.dbt.table_options', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/etc/get_relation_comment.sql', 'original_file_path': 'macros/etc/get_relation_comment.sql', 'resource_type': 'macro', 'name': 'table_options', 'macro_sql': "{% macro table_options() %}\n {%- set raw_persist_docs = config.get('persist_docs', {}) -%}\n\n{%- endmacro -%}\n\n", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.get_relation_comment': {'raw_sql': '{% macro table_options() %}\n {%- set raw_persist_docs = config.get(\'persist_docs\', {}) -%}\n\n{%- endmacro -%}\n\n{% macro get_relation_comment(persist_docs, model) %}\n\n {%- if persist_docs is not mapping -%}\n {{ exceptions.raise_compiler_error("Invalid value provided for \'persist_docs\'. Expected dict but got value: " ~ raw_persist_docs) }}\n {% endif %}\n\n {% if persist_docs.get(\'relation\', false) %}\n {{ return((model.description | tojson)[1:-1]) }}\n {%- else -%}\n {{ return(none) }}\n {% endif %}\n\n{% endmacro %}', 'unique_id': 'macro.dbt.get_relation_comment', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/etc/get_relation_comment.sql', 'original_file_path': 'macros/etc/get_relation_comment.sql', 'resource_type': 'macro', 'name': 'get_relation_comment', 'macro_sql': '{% macro get_relation_comment(persist_docs, model) %}\n\n {%- if persist_docs is not mapping -%}\n {{ exceptions.raise_compiler_error("Invalid value provided for \'persist_docs\'. Expected dict but got value: " ~ raw_persist_docs) }}\n {% endif %}\n\n {% if persist_docs.get(\'relation\', false) %}\n {{ return((model.description | tojson)[1:-1]) }}\n {%- else -%}\n {{ return(none) }}\n {% endif %}\n\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.convert_datetime': {'raw_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 %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% 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 %}', 'unique_id': 'macro.dbt.convert_datetime', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/etc/datetime.sql', 'original_file_path': 'macros/etc/datetime.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.dates_in_range': {'raw_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 %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% 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 %}', 'unique_id': 'macro.dbt.dates_in_range', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/etc/datetime.sql', 'original_file_path': 'macros/etc/datetime.sql', 'resource_type': 'macro', '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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.partition_range': {'raw_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 %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% 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 %}', 'unique_id': 'macro.dbt.partition_range', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/etc/datetime.sql', 'original_file_path': 'macros/etc/datetime.sql', 'resource_type': 'macro', '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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.py_current_timestring': {'raw_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 %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% 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 %}', 'unique_id': 'macro.dbt.py_current_timestring', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/etc/datetime.sql', 'original_file_path': 'macros/etc/datetime.sql', 'resource_type': 'macro', '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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.generate_schema_name': {'raw_sql': '{#\n Renders a schema name given a custom schema name. If the custom\n schema name is none, then the resulting schema is just the "schema"\n value in the specified target. If a schema override is specified, then\n the resulting schema is the default schema concatenated with the\n custom schema.\n\n This macro can be overriden in projects to define different semantics\n for rendering a schema name.\n\n Arguments:\n custom_schema_name: The custom schema name specified for a model, or none\n node: The node the schema is being generated for\n\n#}\n{% macro 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 %}\n\n\n{#\n Renders a schema name given a custom schema name. In production, this macro\n will render out the overriden schema name for a model. Otherwise, the default\n schema specified in the active target is used.\n\n Arguments:\n custom_schema_name: The custom schema name specified for a model, or none\n node: The node the schema is being generated for\n\n#}\n{% 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 %}', 'unique_id': 'macro.dbt.generate_schema_name', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/etc/get_custom_schema.sql', 'original_file_path': 'macros/etc/get_custom_schema.sql', 'resource_type': 'macro', 'name': 'generate_schema_name', 'macro_sql': '{% macro 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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.generate_schema_name_for_env': {'raw_sql': '{#\n Renders a schema name given a custom schema name. If the custom\n schema name is none, then the resulting schema is just the "schema"\n value in the specified target. If a schema override is specified, then\n the resulting schema is the default schema concatenated with the\n custom schema.\n\n This macro can be overriden in projects to define different semantics\n for rendering a schema name.\n\n Arguments:\n custom_schema_name: The custom schema name specified for a model, or none\n node: The node the schema is being generated for\n\n#}\n{% macro 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 %}\n\n\n{#\n Renders a schema name given a custom schema name. In production, this macro\n will render out the overriden schema name for a model. Otherwise, the default\n schema specified in the active target is used.\n\n Arguments:\n custom_schema_name: The custom schema name specified for a model, or none\n node: The node the schema is being generated for\n\n#}\n{% 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 %}', 'unique_id': 'macro.dbt.generate_schema_name_for_env', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/etc/get_custom_schema.sql', 'original_file_path': 'macros/etc/get_custom_schema.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.generate_database_name': {'raw_sql': '{#\n Renders a database name given a custom database name. If the custom\n database name is none, then the resulting database is just the "database"\n value in the specified target. If a database override is specified, then\n the resulting database is the default database concatenated with the\n custom database.\n\n This macro can be overriden in projects to define different semantics\n for rendering a database name.\n\n Arguments:\n custom_database_name: The custom database name specified for a model, or none\n node: The node the database is being generated for\n\n#}\n{% macro 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 %}', 'unique_id': 'macro.dbt.generate_database_name', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/etc/get_custom_database.sql', 'original_file_path': 'macros/etc/get_custom_database.sql', 'resource_type': 'macro', 'name': 'generate_database_name', 'macro_sql': '{% macro 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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.adapter_macro': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.adapter_macro', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'adapter_macro', 'macro_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.get_columns_in_query': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.get_columns_in_query', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'get_columns_in_query', 'macro_sql': "{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro('get_columns_in_query', select_sql)) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__get_columns_in_query': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__get_columns_in_query', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.create_schema': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.create_schema', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'create_schema', 'macro_sql': "{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro('create_schema', database_name, schema_name) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__create_schema': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__create_schema', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'default__create_schema', 'macro_sql': "{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement('create_schema') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.drop_schema': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.drop_schema', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'drop_schema', 'macro_sql': "{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro('drop_schema', database_name, schema_name) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__drop_schema': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__drop_schema', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'default__drop_schema', 'macro_sql': "{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement('drop_schema') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.create_table_as': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.create_table_as', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'create_table_as', 'macro_sql': "{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro('create_table_as', temporary, relation, sql) }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__create_table_as': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__create_table_as', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.create_view_as': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.create_view_as', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'create_view_as', 'macro_sql': "{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro('create_view_as', relation, sql) }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__create_view_as': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__create_view_as', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.get_catalog': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.get_catalog', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'get_catalog', 'macro_sql': "{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro('get_catalog', information_schema, schemas)) }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__get_catalog': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__get_catalog', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', '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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.get_columns_in_relation': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.get_columns_in_relation', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'get_columns_in_relation', 'macro_sql': "{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro('get_columns_in_relation', relation)) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.sql_convert_columns_in_relation': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.sql_convert_columns_in_relation', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', '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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__get_columns_in_relation': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__get_columns_in_relation', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.alter_column_type': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.alter_column_type', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'alter_column_type', 'macro_sql': "{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro('alter_column_type', relation, column_name, new_column_type)) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__alter_column_type': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__alter_column_type', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', '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 %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.drop_relation': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.drop_relation', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'drop_relation', 'macro_sql': "{% macro drop_relation(relation) -%}\n {{ return(adapter_macro('drop_relation', relation)) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__drop_relation': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__drop_relation', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.truncate_relation': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.truncate_relation', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'truncate_relation', 'macro_sql': "{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro('truncate_relation', relation)) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__truncate_relation': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__truncate_relation', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'default__truncate_relation', 'macro_sql': "{% macro default__truncate_relation(relation) -%}\n {% call statement('truncate_relation') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.rename_relation': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.rename_relation', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'rename_relation', 'macro_sql': "{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro('rename_relation', from_relation, to_relation)) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__rename_relation': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__rename_relation', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.information_schema_name': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.information_schema_name', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'information_schema_name', 'macro_sql': "{% macro information_schema_name(database) %}\n {{ return(adapter_macro('information_schema_name', database)) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__information_schema_name': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__information_schema_name', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'default__information_schema_name', 'macro_sql': "{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, 'database') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.list_schemas': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.list_schemas', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'list_schemas', 'macro_sql': "{% macro list_schemas(database) -%}\n {{ return(adapter_macro('list_schemas', database)) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__list_schemas': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__list_schemas', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.check_schema_exists': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.check_schema_exists', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'check_schema_exists', 'macro_sql': "{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro('check_schema_exists', information_schema, schema)) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__check_schema_exists': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__check_schema_exists', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.list_relations_without_caching': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.list_relations_without_caching', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'list_relations_without_caching', 'macro_sql': "{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro('list_relations_without_caching', information_schema, schema)) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__list_relations_without_caching': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__list_relations_without_caching', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'default__list_relations_without_caching', 'macro_sql': "{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n 'list_relations_without_caching macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.current_timestamp': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.current_timestamp', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'current_timestamp', 'macro_sql': "{% macro current_timestamp() -%}\n {{ adapter_macro('current_timestamp') }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__current_timestamp': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__current_timestamp', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.collect_freshness': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.collect_freshness', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'collect_freshness', 'macro_sql': "{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro('collect_freshness', source, loaded_at_field, filter))}}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__collect_freshness': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__collect_freshness', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', '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 %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.make_temp_relation': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.make_temp_relation', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'make_temp_relation', 'macro_sql': "{% macro make_temp_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter_macro('make_temp_relation', base_relation, suffix))}}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.default__make_temp_relation': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.default__make_temp_relation', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'default__make_temp_relation', 'macro_sql': '{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.set_sql_header': {'raw_sql': '{% macro adapter_macro(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 In adapter_macro: 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 separator = \'__\' -%}\n {%- set search_name = adapter.type() + separator + name -%}\n {%- set default_name = \'default\' + separator + name -%}\n\n {%- if package_context.get(search_name) is not none -%}\n {{ return(package_context[search_name](*varargs, **kwargs)) }}\n {%- else -%}\n {{ return(package_context[default_name](*varargs, **kwargs)) }}\n {%- endif -%}\n{%- endmacro %}\n\n{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter_macro(\'get_columns_in_query\', select_sql)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% macro create_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'create_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__create_schema(database_name, schema_name) -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{database_name}}.{{schema_name}}\n {% endcall %}\n{% endmacro %}\n\n{% macro drop_schema(database_name, schema_name) -%}\n {{ adapter_macro(\'drop_schema\', database_name, schema_name) }}\n{% endmacro %}\n\n{% macro default__drop_schema(database_name, schema_name) -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{database_name}}.{{schema_name}} cascade\n {% endcall %}\n{% endmacro %}\n\n{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter_macro(\'create_table_as\', temporary, relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n{% macro create_view_as(relation, sql) -%}\n {{ adapter_macro(\'create_view_as\', relation, sql) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter_macro(\'get_catalog\', information_schema, schemas)) }}\n{%- endmacro %}\n\n{% 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 %}\n\n\n{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter_macro(\'get_columns_in_relation\', relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n{% 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 %}\n\n{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter_macro(\'alter_column_type\', relation, column_name, new_column_type)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro drop_relation(relation) -%}\n {{ return(adapter_macro(\'drop_relation\', relation)) }}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro truncate_relation(relation) -%}\n {{ return(adapter_macro(\'truncate_relation\', relation)) }}\n{% endmacro %}\n\n\n{% macro default__truncate_relation(relation) -%}\n {% call statement(\'truncate_relation\') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}\n\n{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter_macro(\'rename_relation\', from_relation, to_relation)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro information_schema_name(database) %}\n {{ return(adapter_macro(\'information_schema_name\', database)) }}\n{% endmacro %}\n\n{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ adapter.quote_as_configured(database, \'database\') }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}\n\n\n{% macro list_schemas(database) -%}\n {{ return(adapter_macro(\'list_schemas\', database)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter_macro(\'check_schema_exists\', information_schema, schema)) }}\n{% endmacro %}\n\n{% 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 %}\n\n\n{% macro list_relations_without_caching(information_schema, schema) %}\n {{ return(adapter_macro(\'list_relations_without_caching\', information_schema, schema)) }}\n{% endmacro %}\n\n\n{% macro default__list_relations_without_caching(information_schema, schema) %}\n {{ exceptions.raise_not_implemented(\n \'list_relations_without_caching macro not implemented for adapter \'+adapter.type()) }}\n{% endmacro %}\n\n\n{% macro current_timestamp() -%}\n {{ adapter_macro(\'current_timestamp\') }}\n{%- endmacro %}\n\n\n{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n \'current_timestamp macro not implemented for adapter \'+adapter.type()) }}\n{%- endmacro %}\n\n\n{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter_macro(\'collect_freshness\', source, loaded_at_field, filter))}}\n{% endmacro %}\n\n\n{% 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 %}\n\n{% macro make_temp_relation(base_relation, suffix=\'__dbt_tmp\') %}\n {{ return(adapter_macro(\'make_temp_relation\', base_relation, suffix))}}\n{% endmacro %}\n\n{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={"identifier": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}\n\n{% macro set_sql_header(config) -%}\n {{ config.set(\'sql_header\', caller()) }}\n{%- endmacro %}', 'unique_id': 'macro.dbt.set_sql_header', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/adapters/common.sql', 'original_file_path': 'macros/adapters/common.sql', 'resource_type': 'macro', 'name': 'set_sql_header', 'macro_sql': "{% macro set_sql_header(config) -%}\n {{ config.set('sql_header', caller()) }}\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.test_relationships': {'raw_sql': "{% macro test_relationships(model, to, field) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('from')) %}\n\n\nselect count(*)\nfrom (\n select {{ column_name }} as id from {{ model }}\n) as child\nleft join (\n select {{ field }} as id from {{ to }}\n) as parent on parent.id = child.id\nwhere child.id is not null\n and parent.id is null\n\n{% endmacro %}", 'unique_id': 'macro.dbt.test_relationships', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/schema_tests/relationships.sql', 'original_file_path': 'macros/schema_tests/relationships.sql', 'resource_type': 'macro', 'name': 'test_relationships', 'macro_sql': "{% macro test_relationships(model, to, field) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('from')) %}\n\n\nselect count(*)\nfrom (\n select {{ column_name }} as id from {{ model }}\n) as child\nleft join (\n select {{ field }} as id from {{ to }}\n) as parent on parent.id = child.id\nwhere child.id is not null\n and parent.id is null\n\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.test_not_null': {'raw_sql': "{% macro test_not_null(model) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n\nselect count(*)\nfrom {{ model }}\nwhere {{ column_name }} is null\n\n{% endmacro %}", 'unique_id': 'macro.dbt.test_not_null', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/schema_tests/not_null.sql', 'original_file_path': 'macros/schema_tests/not_null.sql', 'resource_type': 'macro', 'name': 'test_not_null', 'macro_sql': "{% macro test_not_null(model) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n\nselect count(*)\nfrom {{ model }}\nwhere {{ column_name }} is null\n\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.test_unique': {'raw_sql': "{% macro test_unique(model) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n\nselect count(*)\nfrom (\n\n select\n {{ column_name }}\n\n from {{ model }}\n where {{ column_name }} is not null\n group by {{ column_name }}\n having count(*) > 1\n\n) validation_errors\n\n{% endmacro %}", 'unique_id': 'macro.dbt.test_unique', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/schema_tests/unique.sql', 'original_file_path': 'macros/schema_tests/unique.sql', 'resource_type': 'macro', 'name': 'test_unique', 'macro_sql': "{% macro test_unique(model) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n\nselect count(*)\nfrom (\n\n select\n {{ column_name }}\n\n from {{ model }}\n where {{ column_name }} is not null\n group by {{ column_name }}\n having count(*) > 1\n\n) validation_errors\n\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt.test_accepted_values': {'raw_sql': "{% macro test_accepted_values(model, values) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('field')) %}\n{% set quote_values = kwargs.get('quote', True) %}\n\nwith all_values as (\n\n select distinct\n {{ column_name }} as value_field\n\n from {{ model }}\n\n),\n\nvalidation_errors as (\n\n select\n value_field\n\n from all_values\n where value_field not in (\n {% for value in values -%}\n {% if quote_values -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n )\n)\n\nselect count(*)\nfrom validation_errors\n\n{% endmacro %}", 'unique_id': 'macro.dbt.test_accepted_values', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'macros/schema_tests/accepted_values.sql', 'original_file_path': 'macros/schema_tests/accepted_values.sql', 'resource_type': 'macro', 'name': 'test_accepted_values', 'macro_sql': "{% macro test_accepted_values(model, values) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('field')) %}\n{% set quote_values = kwargs.get('quote', True) %}\n\nwith all_values as (\n\n select distinct\n {{ column_name }} as value_field\n\n from {{ model }}\n\n),\n\nvalidation_errors as (\n\n select\n value_field\n\n from all_values\n where value_field not in (\n {% for value in values -%}\n {% if quote_values -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n )\n)\n\nselect count(*)\nfrom validation_errors\n\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres__get_catalog': {'raw_sql': "{% macro postgres__get_catalog(information_schema, schemas) -%}\n\n {%- call statement('catalog', fetch_result=True) -%}\n {#\n If the user has multiple databases set and the first one is wrong, this will fail.\n But we won't fail in the case where there are multiple quoting-difference-only dbs, which is better.\n #}\n {% set database = information_schema.database %}\n {{ adapter.verify_database(database) }}\n\n select\n '{{ database }}' as table_database,\n sch.nspname as table_schema,\n tbl.relname as table_name,\n case tbl.relkind\n when 'v' then 'VIEW'\n else 'BASE TABLE'\n end as table_type,\n null::text as table_comment,\n col.attname as column_name,\n col.attnum as column_index,\n pg_catalog.format_type(col.atttypid, col.atttypmod) as column_type,\n null::text as column_comment,\n pg_get_userbyid(tbl.relowner) as table_owner\n\n from pg_catalog.pg_namespace sch\n join pg_catalog.pg_class tbl on tbl.relnamespace = sch.oid\n join pg_catalog.pg_attribute col on col.attrelid = tbl.oid\n\n where (\n {%- for schema in schemas -%}\n upper(sch.nspname) = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n and not pg_is_other_temp_schema(sch.oid) -- not a temporary schema belonging to another session\n and tbl.relpersistence = 'p' -- [p]ermanent table. Other values are [u]nlogged table, [t]emporary table\n and tbl.relkind in ('r', 'v', 'f', 'p') -- o[r]dinary table, [v]iew, [f]oreign table, [p]artitioned table. Other values are [i]ndex, [S]equence, [c]omposite type, [t]OAST table, [m]aterialized view\n and col.attnum > 0 -- negative numbers are used for system columns such as oid\n and not col.attisdropped -- column as not been dropped\n\n order by\n sch.nspname,\n tbl.relname,\n col.attnum\n\n {%- endcall -%}\n\n {{ return(load_result('catalog').table) }}\n\n{%- endmacro %}", 'unique_id': 'macro.dbt_postgres.postgres__get_catalog', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/catalog.sql', 'original_file_path': 'macros/catalog.sql', 'resource_type': 'macro', 'name': 'postgres__get_catalog', 'macro_sql': "{% macro postgres__get_catalog(information_schema, schemas) -%}\n\n {%- call statement('catalog', fetch_result=True) -%}\n {#\n If the user has multiple databases set and the first one is wrong, this will fail.\n But we won't fail in the case where there are multiple quoting-difference-only dbs, which is better.\n #}\n {% set database = information_schema.database %}\n {{ adapter.verify_database(database) }}\n\n select\n '{{ database }}' as table_database,\n sch.nspname as table_schema,\n tbl.relname as table_name,\n case tbl.relkind\n when 'v' then 'VIEW'\n else 'BASE TABLE'\n end as table_type,\n null::text as table_comment,\n col.attname as column_name,\n col.attnum as column_index,\n pg_catalog.format_type(col.atttypid, col.atttypmod) as column_type,\n null::text as column_comment,\n pg_get_userbyid(tbl.relowner) as table_owner\n\n from pg_catalog.pg_namespace sch\n join pg_catalog.pg_class tbl on tbl.relnamespace = sch.oid\n join pg_catalog.pg_attribute col on col.attrelid = tbl.oid\n\n where (\n {%- for schema in schemas -%}\n upper(sch.nspname) = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n and not pg_is_other_temp_schema(sch.oid) -- not a temporary schema belonging to another session\n and tbl.relpersistence = 'p' -- [p]ermanent table. Other values are [u]nlogged table, [t]emporary table\n and tbl.relkind in ('r', 'v', 'f', 'p') -- o[r]dinary table, [v]iew, [f]oreign table, [p]artitioned table. Other values are [i]ndex, [S]equence, [c]omposite type, [t]OAST table, [m]aterialized view\n and col.attnum > 0 -- negative numbers are used for system columns such as oid\n and not col.attisdropped -- column as not been dropped\n\n order by\n sch.nspname,\n tbl.relname,\n col.attnum\n\n {%- endcall -%}\n\n {{ return(load_result('catalog').table) }}\n\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres_get_relations': {'raw_sql': "{% macro postgres_get_relations () -%}\n\n {#\n -- in pg_depend, objid is the dependent, refobjid is the referenced object\n -- > a pg_depend entry indicates that the referenced object cannot be\n -- > dropped without also dropping the dependent object.\n #}\n\n {%- call statement('relations', fetch_result=True) -%}\n with relation as (\n select\n pg_rewrite.ev_class as class,\n pg_rewrite.oid as id\n from pg_rewrite\n ),\n class as (\n select\n oid as id,\n relname as name,\n relnamespace as schema,\n relkind as kind\n from pg_class\n ),\n dependency as (\n select\n pg_depend.objid as id,\n pg_depend.refobjid as ref\n from pg_depend\n ),\n schema as (\n select\n pg_namespace.oid as id,\n pg_namespace.nspname as name\n from pg_namespace\n where nspname != 'information_schema' and nspname not like 'pg\\_%'\n ),\n referenced as (\n select\n relation.id AS id,\n referenced_class.name ,\n referenced_class.schema ,\n referenced_class.kind\n from relation\n join class as referenced_class on relation.class=referenced_class.id\n where referenced_class.kind in ('r', 'v')\n ),\n relationships as (\n select\n referenced.name as referenced_name,\n referenced.schema as referenced_schema_id,\n dependent_class.name as dependent_name,\n dependent_class.schema as dependent_schema_id,\n referenced.kind as kind\n from referenced\n join dependency on referenced.id=dependency.id\n join class as dependent_class on dependency.ref=dependent_class.id\n where\n (referenced.name != dependent_class.name or\n referenced.schema != dependent_class.schema)\n )\n\n select\n referenced_schema.name as referenced_schema,\n relationships.referenced_name as referenced_name,\n dependent_schema.name as dependent_schema,\n relationships.dependent_name as dependent_name\n from relationships\n join schema as dependent_schema on relationships.dependent_schema_id=dependent_schema.id\n join schema as referenced_schema on relationships.referenced_schema_id=referenced_schema.id\n group by referenced_schema, referenced_name, dependent_schema, dependent_name\n order by referenced_schema, referenced_name, dependent_schema, dependent_name;\n\n {%- endcall -%}\n\n {{ return(load_result('relations').table) }}\n{% endmacro %}", 'unique_id': 'macro.dbt_postgres.postgres_get_relations', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/relations.sql', 'original_file_path': 'macros/relations.sql', 'resource_type': 'macro', 'name': 'postgres_get_relations', 'macro_sql': "{% macro postgres_get_relations () -%}\n\n {#\n -- in pg_depend, objid is the dependent, refobjid is the referenced object\n -- > a pg_depend entry indicates that the referenced object cannot be\n -- > dropped without also dropping the dependent object.\n #}\n\n {%- call statement('relations', fetch_result=True) -%}\n with relation as (\n select\n pg_rewrite.ev_class as class,\n pg_rewrite.oid as id\n from pg_rewrite\n ),\n class as (\n select\n oid as id,\n relname as name,\n relnamespace as schema,\n relkind as kind\n from pg_class\n ),\n dependency as (\n select\n pg_depend.objid as id,\n pg_depend.refobjid as ref\n from pg_depend\n ),\n schema as (\n select\n pg_namespace.oid as id,\n pg_namespace.nspname as name\n from pg_namespace\n where nspname != 'information_schema' and nspname not like 'pg\\_%'\n ),\n referenced as (\n select\n relation.id AS id,\n referenced_class.name ,\n referenced_class.schema ,\n referenced_class.kind\n from relation\n join class as referenced_class on relation.class=referenced_class.id\n where referenced_class.kind in ('r', 'v')\n ),\n relationships as (\n select\n referenced.name as referenced_name,\n referenced.schema as referenced_schema_id,\n dependent_class.name as dependent_name,\n dependent_class.schema as dependent_schema_id,\n referenced.kind as kind\n from referenced\n join dependency on referenced.id=dependency.id\n join class as dependent_class on dependency.ref=dependent_class.id\n where\n (referenced.name != dependent_class.name or\n referenced.schema != dependent_class.schema)\n )\n\n select\n referenced_schema.name as referenced_schema,\n relationships.referenced_name as referenced_name,\n dependent_schema.name as dependent_schema,\n relationships.dependent_name as dependent_name\n from relationships\n join schema as dependent_schema on relationships.dependent_schema_id=dependent_schema.id\n join schema as referenced_schema on relationships.referenced_schema_id=referenced_schema.id\n group by referenced_schema, referenced_name, dependent_schema, dependent_name\n order by referenced_schema, referenced_name, dependent_schema, dependent_name;\n\n {%- endcall -%}\n\n {{ return(load_result('relations').table) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres__create_table_as': {'raw_sql': '{% macro postgres__create_table_as(temporary, relation, sql) -%}\n {%- set unlogged = config.get(\'unlogged\', default=false) -%}\n {%- set sql_header = config.get(\'sql_header\', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary -%}\n temporary\n {%- elif unlogged -%}\n unlogged\n {%- endif %} table {{ relation }}\n as (\n {{ sql }}\n );\n{%- endmacro %}\n\n{% macro postgres__create_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{ schema_name }}\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__drop_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{ schema_name }} cascade\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__get_columns_in_relation(relation) -%}\n {% call statement(\'get_columns_in_relation\', fetch_result=True) %}\n select\n column_name,\n data_type,\n character_maximum_length,\n numeric_precision,\n numeric_scale\n\n from {{ relation.information_schema(\'columns\') }}\n where table_name = \'{{ relation.identifier }}\'\n {% if relation.schema %}\n and table_schema = \'{{ relation.schema }}\'\n {% endif %}\n order by ordinal_position\n\n {% endcall %}\n {% set table = load_result(\'get_columns_in_relation\').table %}\n {{ return(sql_convert_columns_in_relation(table)) }}\n{% endmacro %}\n\n\n{% macro postgres__list_relations_without_caching(information_schema, schema) %}\n {% call statement(\'list_relations_without_caching\', fetch_result=True) -%}\n select\n \'{{ information_schema.database }}\' as database,\n tablename as name,\n schemaname as schema,\n \'table\' as type\n from pg_tables\n where schemaname ilike \'{{ schema }}\'\n union all\n select\n \'{{ information_schema.database }}\' as database,\n viewname as name,\n schemaname as schema,\n \'view\' as type\n from pg_views\n where schemaname ilike \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'list_relations_without_caching\').table) }}\n{% endmacro %}\n\n{% macro postgres__information_schema_name(database) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n information_schema\n{%- endmacro %}\n\n{% macro postgres__list_schemas(database) %}\n {% if database -%}\n {{ adapter.verify_database(database) }}\n {%- endif -%}\n {% call statement(\'list_schemas\', fetch_result=True, auto_begin=False) %}\n select distinct nspname from pg_namespace\n {% endcall %}\n {{ return(load_result(\'list_schemas\').table) }}\n{% endmacro %}\n\n{% macro postgres__check_schema_exists(information_schema, schema) -%}\n {% if information_schema.database -%}\n {{ adapter.verify_database(information_schema.database) }}\n {%- endif -%}\n {% call statement(\'check_schema_exists\', fetch_result=True, auto_begin=False) %}\n select count(*) from pg_namespace where nspname = \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'check_schema_exists\').table) }}\n{% endmacro %}\n\n\n{% macro postgres__current_timestamp() -%}\n now()\n{%- endmacro %}\n\n{% macro postgres__snapshot_string_as_time(timestamp) -%}\n {%- set result = "\'" ~ timestamp ~ "\'::timestamp without time zone" -%}\n {{ return(result) }}\n{%- endmacro %}\n\n\n{% macro postgres__snapshot_get_time() -%}\n {{ current_timestamp() }}::timestamp without time zone\n{%- endmacro %}\n\n{% macro postgres__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix ~ py_current_timestring() %}\n {% do return(base_relation.incorporate(\n path={\n "identifier": tmp_identifier,\n "schema": none,\n "database": none\n })) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt_postgres.postgres__create_table_as', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/adapters.sql', 'original_file_path': 'macros/adapters.sql', 'resource_type': 'macro', 'name': 'postgres__create_table_as', 'macro_sql': "{% macro postgres__create_table_as(temporary, relation, sql) -%}\n {%- set unlogged = config.get('unlogged', default=false) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary -%}\n temporary\n {%- elif unlogged -%}\n unlogged\n {%- endif %} table {{ relation }}\n as (\n {{ sql }}\n );\n{%- endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres__create_schema': {'raw_sql': '{% macro postgres__create_table_as(temporary, relation, sql) -%}\n {%- set unlogged = config.get(\'unlogged\', default=false) -%}\n {%- set sql_header = config.get(\'sql_header\', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary -%}\n temporary\n {%- elif unlogged -%}\n unlogged\n {%- endif %} table {{ relation }}\n as (\n {{ sql }}\n );\n{%- endmacro %}\n\n{% macro postgres__create_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{ schema_name }}\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__drop_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{ schema_name }} cascade\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__get_columns_in_relation(relation) -%}\n {% call statement(\'get_columns_in_relation\', fetch_result=True) %}\n select\n column_name,\n data_type,\n character_maximum_length,\n numeric_precision,\n numeric_scale\n\n from {{ relation.information_schema(\'columns\') }}\n where table_name = \'{{ relation.identifier }}\'\n {% if relation.schema %}\n and table_schema = \'{{ relation.schema }}\'\n {% endif %}\n order by ordinal_position\n\n {% endcall %}\n {% set table = load_result(\'get_columns_in_relation\').table %}\n {{ return(sql_convert_columns_in_relation(table)) }}\n{% endmacro %}\n\n\n{% macro postgres__list_relations_without_caching(information_schema, schema) %}\n {% call statement(\'list_relations_without_caching\', fetch_result=True) -%}\n select\n \'{{ information_schema.database }}\' as database,\n tablename as name,\n schemaname as schema,\n \'table\' as type\n from pg_tables\n where schemaname ilike \'{{ schema }}\'\n union all\n select\n \'{{ information_schema.database }}\' as database,\n viewname as name,\n schemaname as schema,\n \'view\' as type\n from pg_views\n where schemaname ilike \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'list_relations_without_caching\').table) }}\n{% endmacro %}\n\n{% macro postgres__information_schema_name(database) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n information_schema\n{%- endmacro %}\n\n{% macro postgres__list_schemas(database) %}\n {% if database -%}\n {{ adapter.verify_database(database) }}\n {%- endif -%}\n {% call statement(\'list_schemas\', fetch_result=True, auto_begin=False) %}\n select distinct nspname from pg_namespace\n {% endcall %}\n {{ return(load_result(\'list_schemas\').table) }}\n{% endmacro %}\n\n{% macro postgres__check_schema_exists(information_schema, schema) -%}\n {% if information_schema.database -%}\n {{ adapter.verify_database(information_schema.database) }}\n {%- endif -%}\n {% call statement(\'check_schema_exists\', fetch_result=True, auto_begin=False) %}\n select count(*) from pg_namespace where nspname = \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'check_schema_exists\').table) }}\n{% endmacro %}\n\n\n{% macro postgres__current_timestamp() -%}\n now()\n{%- endmacro %}\n\n{% macro postgres__snapshot_string_as_time(timestamp) -%}\n {%- set result = "\'" ~ timestamp ~ "\'::timestamp without time zone" -%}\n {{ return(result) }}\n{%- endmacro %}\n\n\n{% macro postgres__snapshot_get_time() -%}\n {{ current_timestamp() }}::timestamp without time zone\n{%- endmacro %}\n\n{% macro postgres__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix ~ py_current_timestring() %}\n {% do return(base_relation.incorporate(\n path={\n "identifier": tmp_identifier,\n "schema": none,\n "database": none\n })) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt_postgres.postgres__create_schema', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/adapters.sql', 'original_file_path': 'macros/adapters.sql', 'resource_type': 'macro', 'name': 'postgres__create_schema', 'macro_sql': "{% macro postgres__create_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement('create_schema') -%}\n create schema if not exists {{ schema_name }}\n {%- endcall -%}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres__drop_schema': {'raw_sql': '{% macro postgres__create_table_as(temporary, relation, sql) -%}\n {%- set unlogged = config.get(\'unlogged\', default=false) -%}\n {%- set sql_header = config.get(\'sql_header\', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary -%}\n temporary\n {%- elif unlogged -%}\n unlogged\n {%- endif %} table {{ relation }}\n as (\n {{ sql }}\n );\n{%- endmacro %}\n\n{% macro postgres__create_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{ schema_name }}\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__drop_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{ schema_name }} cascade\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__get_columns_in_relation(relation) -%}\n {% call statement(\'get_columns_in_relation\', fetch_result=True) %}\n select\n column_name,\n data_type,\n character_maximum_length,\n numeric_precision,\n numeric_scale\n\n from {{ relation.information_schema(\'columns\') }}\n where table_name = \'{{ relation.identifier }}\'\n {% if relation.schema %}\n and table_schema = \'{{ relation.schema }}\'\n {% endif %}\n order by ordinal_position\n\n {% endcall %}\n {% set table = load_result(\'get_columns_in_relation\').table %}\n {{ return(sql_convert_columns_in_relation(table)) }}\n{% endmacro %}\n\n\n{% macro postgres__list_relations_without_caching(information_schema, schema) %}\n {% call statement(\'list_relations_without_caching\', fetch_result=True) -%}\n select\n \'{{ information_schema.database }}\' as database,\n tablename as name,\n schemaname as schema,\n \'table\' as type\n from pg_tables\n where schemaname ilike \'{{ schema }}\'\n union all\n select\n \'{{ information_schema.database }}\' as database,\n viewname as name,\n schemaname as schema,\n \'view\' as type\n from pg_views\n where schemaname ilike \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'list_relations_without_caching\').table) }}\n{% endmacro %}\n\n{% macro postgres__information_schema_name(database) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n information_schema\n{%- endmacro %}\n\n{% macro postgres__list_schemas(database) %}\n {% if database -%}\n {{ adapter.verify_database(database) }}\n {%- endif -%}\n {% call statement(\'list_schemas\', fetch_result=True, auto_begin=False) %}\n select distinct nspname from pg_namespace\n {% endcall %}\n {{ return(load_result(\'list_schemas\').table) }}\n{% endmacro %}\n\n{% macro postgres__check_schema_exists(information_schema, schema) -%}\n {% if information_schema.database -%}\n {{ adapter.verify_database(information_schema.database) }}\n {%- endif -%}\n {% call statement(\'check_schema_exists\', fetch_result=True, auto_begin=False) %}\n select count(*) from pg_namespace where nspname = \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'check_schema_exists\').table) }}\n{% endmacro %}\n\n\n{% macro postgres__current_timestamp() -%}\n now()\n{%- endmacro %}\n\n{% macro postgres__snapshot_string_as_time(timestamp) -%}\n {%- set result = "\'" ~ timestamp ~ "\'::timestamp without time zone" -%}\n {{ return(result) }}\n{%- endmacro %}\n\n\n{% macro postgres__snapshot_get_time() -%}\n {{ current_timestamp() }}::timestamp without time zone\n{%- endmacro %}\n\n{% macro postgres__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix ~ py_current_timestring() %}\n {% do return(base_relation.incorporate(\n path={\n "identifier": tmp_identifier,\n "schema": none,\n "database": none\n })) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt_postgres.postgres__drop_schema', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/adapters.sql', 'original_file_path': 'macros/adapters.sql', 'resource_type': 'macro', 'name': 'postgres__drop_schema', 'macro_sql': "{% macro postgres__drop_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement('drop_schema') -%}\n drop schema if exists {{ schema_name }} cascade\n {%- endcall -%}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres__get_columns_in_relation': {'raw_sql': '{% macro postgres__create_table_as(temporary, relation, sql) -%}\n {%- set unlogged = config.get(\'unlogged\', default=false) -%}\n {%- set sql_header = config.get(\'sql_header\', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary -%}\n temporary\n {%- elif unlogged -%}\n unlogged\n {%- endif %} table {{ relation }}\n as (\n {{ sql }}\n );\n{%- endmacro %}\n\n{% macro postgres__create_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{ schema_name }}\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__drop_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{ schema_name }} cascade\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__get_columns_in_relation(relation) -%}\n {% call statement(\'get_columns_in_relation\', fetch_result=True) %}\n select\n column_name,\n data_type,\n character_maximum_length,\n numeric_precision,\n numeric_scale\n\n from {{ relation.information_schema(\'columns\') }}\n where table_name = \'{{ relation.identifier }}\'\n {% if relation.schema %}\n and table_schema = \'{{ relation.schema }}\'\n {% endif %}\n order by ordinal_position\n\n {% endcall %}\n {% set table = load_result(\'get_columns_in_relation\').table %}\n {{ return(sql_convert_columns_in_relation(table)) }}\n{% endmacro %}\n\n\n{% macro postgres__list_relations_without_caching(information_schema, schema) %}\n {% call statement(\'list_relations_without_caching\', fetch_result=True) -%}\n select\n \'{{ information_schema.database }}\' as database,\n tablename as name,\n schemaname as schema,\n \'table\' as type\n from pg_tables\n where schemaname ilike \'{{ schema }}\'\n union all\n select\n \'{{ information_schema.database }}\' as database,\n viewname as name,\n schemaname as schema,\n \'view\' as type\n from pg_views\n where schemaname ilike \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'list_relations_without_caching\').table) }}\n{% endmacro %}\n\n{% macro postgres__information_schema_name(database) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n information_schema\n{%- endmacro %}\n\n{% macro postgres__list_schemas(database) %}\n {% if database -%}\n {{ adapter.verify_database(database) }}\n {%- endif -%}\n {% call statement(\'list_schemas\', fetch_result=True, auto_begin=False) %}\n select distinct nspname from pg_namespace\n {% endcall %}\n {{ return(load_result(\'list_schemas\').table) }}\n{% endmacro %}\n\n{% macro postgres__check_schema_exists(information_schema, schema) -%}\n {% if information_schema.database -%}\n {{ adapter.verify_database(information_schema.database) }}\n {%- endif -%}\n {% call statement(\'check_schema_exists\', fetch_result=True, auto_begin=False) %}\n select count(*) from pg_namespace where nspname = \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'check_schema_exists\').table) }}\n{% endmacro %}\n\n\n{% macro postgres__current_timestamp() -%}\n now()\n{%- endmacro %}\n\n{% macro postgres__snapshot_string_as_time(timestamp) -%}\n {%- set result = "\'" ~ timestamp ~ "\'::timestamp without time zone" -%}\n {{ return(result) }}\n{%- endmacro %}\n\n\n{% macro postgres__snapshot_get_time() -%}\n {{ current_timestamp() }}::timestamp without time zone\n{%- endmacro %}\n\n{% macro postgres__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix ~ py_current_timestring() %}\n {% do return(base_relation.incorporate(\n path={\n "identifier": tmp_identifier,\n "schema": none,\n "database": none\n })) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt_postgres.postgres__get_columns_in_relation', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/adapters.sql', 'original_file_path': 'macros/adapters.sql', 'resource_type': 'macro', 'name': 'postgres__get_columns_in_relation', 'macro_sql': "{% macro postgres__get_columns_in_relation(relation) -%}\n {% call statement('get_columns_in_relation', fetch_result=True) %}\n select\n column_name,\n data_type,\n character_maximum_length,\n numeric_precision,\n numeric_scale\n\n from {{ relation.information_schema('columns') }}\n where table_name = '{{ relation.identifier }}'\n {% if relation.schema %}\n and table_schema = '{{ relation.schema }}'\n {% endif %}\n order by ordinal_position\n\n {% endcall %}\n {% set table = load_result('get_columns_in_relation').table %}\n {{ return(sql_convert_columns_in_relation(table)) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres__list_relations_without_caching': {'raw_sql': '{% macro postgres__create_table_as(temporary, relation, sql) -%}\n {%- set unlogged = config.get(\'unlogged\', default=false) -%}\n {%- set sql_header = config.get(\'sql_header\', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary -%}\n temporary\n {%- elif unlogged -%}\n unlogged\n {%- endif %} table {{ relation }}\n as (\n {{ sql }}\n );\n{%- endmacro %}\n\n{% macro postgres__create_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{ schema_name }}\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__drop_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{ schema_name }} cascade\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__get_columns_in_relation(relation) -%}\n {% call statement(\'get_columns_in_relation\', fetch_result=True) %}\n select\n column_name,\n data_type,\n character_maximum_length,\n numeric_precision,\n numeric_scale\n\n from {{ relation.information_schema(\'columns\') }}\n where table_name = \'{{ relation.identifier }}\'\n {% if relation.schema %}\n and table_schema = \'{{ relation.schema }}\'\n {% endif %}\n order by ordinal_position\n\n {% endcall %}\n {% set table = load_result(\'get_columns_in_relation\').table %}\n {{ return(sql_convert_columns_in_relation(table)) }}\n{% endmacro %}\n\n\n{% macro postgres__list_relations_without_caching(information_schema, schema) %}\n {% call statement(\'list_relations_without_caching\', fetch_result=True) -%}\n select\n \'{{ information_schema.database }}\' as database,\n tablename as name,\n schemaname as schema,\n \'table\' as type\n from pg_tables\n where schemaname ilike \'{{ schema }}\'\n union all\n select\n \'{{ information_schema.database }}\' as database,\n viewname as name,\n schemaname as schema,\n \'view\' as type\n from pg_views\n where schemaname ilike \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'list_relations_without_caching\').table) }}\n{% endmacro %}\n\n{% macro postgres__information_schema_name(database) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n information_schema\n{%- endmacro %}\n\n{% macro postgres__list_schemas(database) %}\n {% if database -%}\n {{ adapter.verify_database(database) }}\n {%- endif -%}\n {% call statement(\'list_schemas\', fetch_result=True, auto_begin=False) %}\n select distinct nspname from pg_namespace\n {% endcall %}\n {{ return(load_result(\'list_schemas\').table) }}\n{% endmacro %}\n\n{% macro postgres__check_schema_exists(information_schema, schema) -%}\n {% if information_schema.database -%}\n {{ adapter.verify_database(information_schema.database) }}\n {%- endif -%}\n {% call statement(\'check_schema_exists\', fetch_result=True, auto_begin=False) %}\n select count(*) from pg_namespace where nspname = \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'check_schema_exists\').table) }}\n{% endmacro %}\n\n\n{% macro postgres__current_timestamp() -%}\n now()\n{%- endmacro %}\n\n{% macro postgres__snapshot_string_as_time(timestamp) -%}\n {%- set result = "\'" ~ timestamp ~ "\'::timestamp without time zone" -%}\n {{ return(result) }}\n{%- endmacro %}\n\n\n{% macro postgres__snapshot_get_time() -%}\n {{ current_timestamp() }}::timestamp without time zone\n{%- endmacro %}\n\n{% macro postgres__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix ~ py_current_timestring() %}\n {% do return(base_relation.incorporate(\n path={\n "identifier": tmp_identifier,\n "schema": none,\n "database": none\n })) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt_postgres.postgres__list_relations_without_caching', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/adapters.sql', 'original_file_path': 'macros/adapters.sql', 'resource_type': 'macro', 'name': 'postgres__list_relations_without_caching', 'macro_sql': "{% macro postgres__list_relations_without_caching(information_schema, schema) %}\n {% call statement('list_relations_without_caching', fetch_result=True) -%}\n select\n '{{ information_schema.database }}' as database,\n tablename as name,\n schemaname as schema,\n 'table' as type\n from pg_tables\n where schemaname ilike '{{ schema }}'\n union all\n select\n '{{ information_schema.database }}' as database,\n viewname as name,\n schemaname as schema,\n 'view' as type\n from pg_views\n where schemaname ilike '{{ schema }}'\n {% endcall %}\n {{ return(load_result('list_relations_without_caching').table) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres__information_schema_name': {'raw_sql': '{% macro postgres__create_table_as(temporary, relation, sql) -%}\n {%- set unlogged = config.get(\'unlogged\', default=false) -%}\n {%- set sql_header = config.get(\'sql_header\', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary -%}\n temporary\n {%- elif unlogged -%}\n unlogged\n {%- endif %} table {{ relation }}\n as (\n {{ sql }}\n );\n{%- endmacro %}\n\n{% macro postgres__create_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{ schema_name }}\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__drop_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{ schema_name }} cascade\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__get_columns_in_relation(relation) -%}\n {% call statement(\'get_columns_in_relation\', fetch_result=True) %}\n select\n column_name,\n data_type,\n character_maximum_length,\n numeric_precision,\n numeric_scale\n\n from {{ relation.information_schema(\'columns\') }}\n where table_name = \'{{ relation.identifier }}\'\n {% if relation.schema %}\n and table_schema = \'{{ relation.schema }}\'\n {% endif %}\n order by ordinal_position\n\n {% endcall %}\n {% set table = load_result(\'get_columns_in_relation\').table %}\n {{ return(sql_convert_columns_in_relation(table)) }}\n{% endmacro %}\n\n\n{% macro postgres__list_relations_without_caching(information_schema, schema) %}\n {% call statement(\'list_relations_without_caching\', fetch_result=True) -%}\n select\n \'{{ information_schema.database }}\' as database,\n tablename as name,\n schemaname as schema,\n \'table\' as type\n from pg_tables\n where schemaname ilike \'{{ schema }}\'\n union all\n select\n \'{{ information_schema.database }}\' as database,\n viewname as name,\n schemaname as schema,\n \'view\' as type\n from pg_views\n where schemaname ilike \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'list_relations_without_caching\').table) }}\n{% endmacro %}\n\n{% macro postgres__information_schema_name(database) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n information_schema\n{%- endmacro %}\n\n{% macro postgres__list_schemas(database) %}\n {% if database -%}\n {{ adapter.verify_database(database) }}\n {%- endif -%}\n {% call statement(\'list_schemas\', fetch_result=True, auto_begin=False) %}\n select distinct nspname from pg_namespace\n {% endcall %}\n {{ return(load_result(\'list_schemas\').table) }}\n{% endmacro %}\n\n{% macro postgres__check_schema_exists(information_schema, schema) -%}\n {% if information_schema.database -%}\n {{ adapter.verify_database(information_schema.database) }}\n {%- endif -%}\n {% call statement(\'check_schema_exists\', fetch_result=True, auto_begin=False) %}\n select count(*) from pg_namespace where nspname = \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'check_schema_exists\').table) }}\n{% endmacro %}\n\n\n{% macro postgres__current_timestamp() -%}\n now()\n{%- endmacro %}\n\n{% macro postgres__snapshot_string_as_time(timestamp) -%}\n {%- set result = "\'" ~ timestamp ~ "\'::timestamp without time zone" -%}\n {{ return(result) }}\n{%- endmacro %}\n\n\n{% macro postgres__snapshot_get_time() -%}\n {{ current_timestamp() }}::timestamp without time zone\n{%- endmacro %}\n\n{% macro postgres__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix ~ py_current_timestring() %}\n {% do return(base_relation.incorporate(\n path={\n "identifier": tmp_identifier,\n "schema": none,\n "database": none\n })) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt_postgres.postgres__information_schema_name', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/adapters.sql', 'original_file_path': 'macros/adapters.sql', 'resource_type': 'macro', 'name': 'postgres__information_schema_name', 'macro_sql': '{% macro postgres__information_schema_name(database) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n information_schema\n{%- endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres__list_schemas': {'raw_sql': '{% macro postgres__create_table_as(temporary, relation, sql) -%}\n {%- set unlogged = config.get(\'unlogged\', default=false) -%}\n {%- set sql_header = config.get(\'sql_header\', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary -%}\n temporary\n {%- elif unlogged -%}\n unlogged\n {%- endif %} table {{ relation }}\n as (\n {{ sql }}\n );\n{%- endmacro %}\n\n{% macro postgres__create_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{ schema_name }}\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__drop_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{ schema_name }} cascade\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__get_columns_in_relation(relation) -%}\n {% call statement(\'get_columns_in_relation\', fetch_result=True) %}\n select\n column_name,\n data_type,\n character_maximum_length,\n numeric_precision,\n numeric_scale\n\n from {{ relation.information_schema(\'columns\') }}\n where table_name = \'{{ relation.identifier }}\'\n {% if relation.schema %}\n and table_schema = \'{{ relation.schema }}\'\n {% endif %}\n order by ordinal_position\n\n {% endcall %}\n {% set table = load_result(\'get_columns_in_relation\').table %}\n {{ return(sql_convert_columns_in_relation(table)) }}\n{% endmacro %}\n\n\n{% macro postgres__list_relations_without_caching(information_schema, schema) %}\n {% call statement(\'list_relations_without_caching\', fetch_result=True) -%}\n select\n \'{{ information_schema.database }}\' as database,\n tablename as name,\n schemaname as schema,\n \'table\' as type\n from pg_tables\n where schemaname ilike \'{{ schema }}\'\n union all\n select\n \'{{ information_schema.database }}\' as database,\n viewname as name,\n schemaname as schema,\n \'view\' as type\n from pg_views\n where schemaname ilike \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'list_relations_without_caching\').table) }}\n{% endmacro %}\n\n{% macro postgres__information_schema_name(database) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n information_schema\n{%- endmacro %}\n\n{% macro postgres__list_schemas(database) %}\n {% if database -%}\n {{ adapter.verify_database(database) }}\n {%- endif -%}\n {% call statement(\'list_schemas\', fetch_result=True, auto_begin=False) %}\n select distinct nspname from pg_namespace\n {% endcall %}\n {{ return(load_result(\'list_schemas\').table) }}\n{% endmacro %}\n\n{% macro postgres__check_schema_exists(information_schema, schema) -%}\n {% if information_schema.database -%}\n {{ adapter.verify_database(information_schema.database) }}\n {%- endif -%}\n {% call statement(\'check_schema_exists\', fetch_result=True, auto_begin=False) %}\n select count(*) from pg_namespace where nspname = \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'check_schema_exists\').table) }}\n{% endmacro %}\n\n\n{% macro postgres__current_timestamp() -%}\n now()\n{%- endmacro %}\n\n{% macro postgres__snapshot_string_as_time(timestamp) -%}\n {%- set result = "\'" ~ timestamp ~ "\'::timestamp without time zone" -%}\n {{ return(result) }}\n{%- endmacro %}\n\n\n{% macro postgres__snapshot_get_time() -%}\n {{ current_timestamp() }}::timestamp without time zone\n{%- endmacro %}\n\n{% macro postgres__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix ~ py_current_timestring() %}\n {% do return(base_relation.incorporate(\n path={\n "identifier": tmp_identifier,\n "schema": none,\n "database": none\n })) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt_postgres.postgres__list_schemas', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/adapters.sql', 'original_file_path': 'macros/adapters.sql', 'resource_type': 'macro', 'name': 'postgres__list_schemas', 'macro_sql': "{% macro postgres__list_schemas(database) %}\n {% if database -%}\n {{ adapter.verify_database(database) }}\n {%- endif -%}\n {% call statement('list_schemas', fetch_result=True, auto_begin=False) %}\n select distinct nspname from pg_namespace\n {% endcall %}\n {{ return(load_result('list_schemas').table) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres__check_schema_exists': {'raw_sql': '{% macro postgres__create_table_as(temporary, relation, sql) -%}\n {%- set unlogged = config.get(\'unlogged\', default=false) -%}\n {%- set sql_header = config.get(\'sql_header\', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary -%}\n temporary\n {%- elif unlogged -%}\n unlogged\n {%- endif %} table {{ relation }}\n as (\n {{ sql }}\n );\n{%- endmacro %}\n\n{% macro postgres__create_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{ schema_name }}\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__drop_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{ schema_name }} cascade\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__get_columns_in_relation(relation) -%}\n {% call statement(\'get_columns_in_relation\', fetch_result=True) %}\n select\n column_name,\n data_type,\n character_maximum_length,\n numeric_precision,\n numeric_scale\n\n from {{ relation.information_schema(\'columns\') }}\n where table_name = \'{{ relation.identifier }}\'\n {% if relation.schema %}\n and table_schema = \'{{ relation.schema }}\'\n {% endif %}\n order by ordinal_position\n\n {% endcall %}\n {% set table = load_result(\'get_columns_in_relation\').table %}\n {{ return(sql_convert_columns_in_relation(table)) }}\n{% endmacro %}\n\n\n{% macro postgres__list_relations_without_caching(information_schema, schema) %}\n {% call statement(\'list_relations_without_caching\', fetch_result=True) -%}\n select\n \'{{ information_schema.database }}\' as database,\n tablename as name,\n schemaname as schema,\n \'table\' as type\n from pg_tables\n where schemaname ilike \'{{ schema }}\'\n union all\n select\n \'{{ information_schema.database }}\' as database,\n viewname as name,\n schemaname as schema,\n \'view\' as type\n from pg_views\n where schemaname ilike \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'list_relations_without_caching\').table) }}\n{% endmacro %}\n\n{% macro postgres__information_schema_name(database) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n information_schema\n{%- endmacro %}\n\n{% macro postgres__list_schemas(database) %}\n {% if database -%}\n {{ adapter.verify_database(database) }}\n {%- endif -%}\n {% call statement(\'list_schemas\', fetch_result=True, auto_begin=False) %}\n select distinct nspname from pg_namespace\n {% endcall %}\n {{ return(load_result(\'list_schemas\').table) }}\n{% endmacro %}\n\n{% macro postgres__check_schema_exists(information_schema, schema) -%}\n {% if information_schema.database -%}\n {{ adapter.verify_database(information_schema.database) }}\n {%- endif -%}\n {% call statement(\'check_schema_exists\', fetch_result=True, auto_begin=False) %}\n select count(*) from pg_namespace where nspname = \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'check_schema_exists\').table) }}\n{% endmacro %}\n\n\n{% macro postgres__current_timestamp() -%}\n now()\n{%- endmacro %}\n\n{% macro postgres__snapshot_string_as_time(timestamp) -%}\n {%- set result = "\'" ~ timestamp ~ "\'::timestamp without time zone" -%}\n {{ return(result) }}\n{%- endmacro %}\n\n\n{% macro postgres__snapshot_get_time() -%}\n {{ current_timestamp() }}::timestamp without time zone\n{%- endmacro %}\n\n{% macro postgres__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix ~ py_current_timestring() %}\n {% do return(base_relation.incorporate(\n path={\n "identifier": tmp_identifier,\n "schema": none,\n "database": none\n })) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt_postgres.postgres__check_schema_exists', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/adapters.sql', 'original_file_path': 'macros/adapters.sql', 'resource_type': 'macro', 'name': 'postgres__check_schema_exists', 'macro_sql': "{% macro postgres__check_schema_exists(information_schema, schema) -%}\n {% if information_schema.database -%}\n {{ adapter.verify_database(information_schema.database) }}\n {%- endif -%}\n {% call statement('check_schema_exists', fetch_result=True, auto_begin=False) %}\n select count(*) from pg_namespace where nspname = '{{ schema }}'\n {% endcall %}\n {{ return(load_result('check_schema_exists').table) }}\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres__current_timestamp': {'raw_sql': '{% macro postgres__create_table_as(temporary, relation, sql) -%}\n {%- set unlogged = config.get(\'unlogged\', default=false) -%}\n {%- set sql_header = config.get(\'sql_header\', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary -%}\n temporary\n {%- elif unlogged -%}\n unlogged\n {%- endif %} table {{ relation }}\n as (\n {{ sql }}\n );\n{%- endmacro %}\n\n{% macro postgres__create_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{ schema_name }}\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__drop_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{ schema_name }} cascade\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__get_columns_in_relation(relation) -%}\n {% call statement(\'get_columns_in_relation\', fetch_result=True) %}\n select\n column_name,\n data_type,\n character_maximum_length,\n numeric_precision,\n numeric_scale\n\n from {{ relation.information_schema(\'columns\') }}\n where table_name = \'{{ relation.identifier }}\'\n {% if relation.schema %}\n and table_schema = \'{{ relation.schema }}\'\n {% endif %}\n order by ordinal_position\n\n {% endcall %}\n {% set table = load_result(\'get_columns_in_relation\').table %}\n {{ return(sql_convert_columns_in_relation(table)) }}\n{% endmacro %}\n\n\n{% macro postgres__list_relations_without_caching(information_schema, schema) %}\n {% call statement(\'list_relations_without_caching\', fetch_result=True) -%}\n select\n \'{{ information_schema.database }}\' as database,\n tablename as name,\n schemaname as schema,\n \'table\' as type\n from pg_tables\n where schemaname ilike \'{{ schema }}\'\n union all\n select\n \'{{ information_schema.database }}\' as database,\n viewname as name,\n schemaname as schema,\n \'view\' as type\n from pg_views\n where schemaname ilike \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'list_relations_without_caching\').table) }}\n{% endmacro %}\n\n{% macro postgres__information_schema_name(database) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n information_schema\n{%- endmacro %}\n\n{% macro postgres__list_schemas(database) %}\n {% if database -%}\n {{ adapter.verify_database(database) }}\n {%- endif -%}\n {% call statement(\'list_schemas\', fetch_result=True, auto_begin=False) %}\n select distinct nspname from pg_namespace\n {% endcall %}\n {{ return(load_result(\'list_schemas\').table) }}\n{% endmacro %}\n\n{% macro postgres__check_schema_exists(information_schema, schema) -%}\n {% if information_schema.database -%}\n {{ adapter.verify_database(information_schema.database) }}\n {%- endif -%}\n {% call statement(\'check_schema_exists\', fetch_result=True, auto_begin=False) %}\n select count(*) from pg_namespace where nspname = \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'check_schema_exists\').table) }}\n{% endmacro %}\n\n\n{% macro postgres__current_timestamp() -%}\n now()\n{%- endmacro %}\n\n{% macro postgres__snapshot_string_as_time(timestamp) -%}\n {%- set result = "\'" ~ timestamp ~ "\'::timestamp without time zone" -%}\n {{ return(result) }}\n{%- endmacro %}\n\n\n{% macro postgres__snapshot_get_time() -%}\n {{ current_timestamp() }}::timestamp without time zone\n{%- endmacro %}\n\n{% macro postgres__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix ~ py_current_timestring() %}\n {% do return(base_relation.incorporate(\n path={\n "identifier": tmp_identifier,\n "schema": none,\n "database": none\n })) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt_postgres.postgres__current_timestamp', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/adapters.sql', 'original_file_path': 'macros/adapters.sql', 'resource_type': 'macro', 'name': 'postgres__current_timestamp', 'macro_sql': '{% macro postgres__current_timestamp() -%}\n now()\n{%- endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres__snapshot_string_as_time': {'raw_sql': '{% macro postgres__create_table_as(temporary, relation, sql) -%}\n {%- set unlogged = config.get(\'unlogged\', default=false) -%}\n {%- set sql_header = config.get(\'sql_header\', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary -%}\n temporary\n {%- elif unlogged -%}\n unlogged\n {%- endif %} table {{ relation }}\n as (\n {{ sql }}\n );\n{%- endmacro %}\n\n{% macro postgres__create_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{ schema_name }}\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__drop_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{ schema_name }} cascade\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__get_columns_in_relation(relation) -%}\n {% call statement(\'get_columns_in_relation\', fetch_result=True) %}\n select\n column_name,\n data_type,\n character_maximum_length,\n numeric_precision,\n numeric_scale\n\n from {{ relation.information_schema(\'columns\') }}\n where table_name = \'{{ relation.identifier }}\'\n {% if relation.schema %}\n and table_schema = \'{{ relation.schema }}\'\n {% endif %}\n order by ordinal_position\n\n {% endcall %}\n {% set table = load_result(\'get_columns_in_relation\').table %}\n {{ return(sql_convert_columns_in_relation(table)) }}\n{% endmacro %}\n\n\n{% macro postgres__list_relations_without_caching(information_schema, schema) %}\n {% call statement(\'list_relations_without_caching\', fetch_result=True) -%}\n select\n \'{{ information_schema.database }}\' as database,\n tablename as name,\n schemaname as schema,\n \'table\' as type\n from pg_tables\n where schemaname ilike \'{{ schema }}\'\n union all\n select\n \'{{ information_schema.database }}\' as database,\n viewname as name,\n schemaname as schema,\n \'view\' as type\n from pg_views\n where schemaname ilike \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'list_relations_without_caching\').table) }}\n{% endmacro %}\n\n{% macro postgres__information_schema_name(database) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n information_schema\n{%- endmacro %}\n\n{% macro postgres__list_schemas(database) %}\n {% if database -%}\n {{ adapter.verify_database(database) }}\n {%- endif -%}\n {% call statement(\'list_schemas\', fetch_result=True, auto_begin=False) %}\n select distinct nspname from pg_namespace\n {% endcall %}\n {{ return(load_result(\'list_schemas\').table) }}\n{% endmacro %}\n\n{% macro postgres__check_schema_exists(information_schema, schema) -%}\n {% if information_schema.database -%}\n {{ adapter.verify_database(information_schema.database) }}\n {%- endif -%}\n {% call statement(\'check_schema_exists\', fetch_result=True, auto_begin=False) %}\n select count(*) from pg_namespace where nspname = \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'check_schema_exists\').table) }}\n{% endmacro %}\n\n\n{% macro postgres__current_timestamp() -%}\n now()\n{%- endmacro %}\n\n{% macro postgres__snapshot_string_as_time(timestamp) -%}\n {%- set result = "\'" ~ timestamp ~ "\'::timestamp without time zone" -%}\n {{ return(result) }}\n{%- endmacro %}\n\n\n{% macro postgres__snapshot_get_time() -%}\n {{ current_timestamp() }}::timestamp without time zone\n{%- endmacro %}\n\n{% macro postgres__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix ~ py_current_timestring() %}\n {% do return(base_relation.incorporate(\n path={\n "identifier": tmp_identifier,\n "schema": none,\n "database": none\n })) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt_postgres.postgres__snapshot_string_as_time', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/adapters.sql', 'original_file_path': 'macros/adapters.sql', 'resource_type': 'macro', 'name': 'postgres__snapshot_string_as_time', 'macro_sql': '{% macro postgres__snapshot_string_as_time(timestamp) -%}\n {%- set result = "\'" ~ timestamp ~ "\'::timestamp without time zone" -%}\n {{ return(result) }}\n{%- endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres__snapshot_get_time': {'raw_sql': '{% macro postgres__create_table_as(temporary, relation, sql) -%}\n {%- set unlogged = config.get(\'unlogged\', default=false) -%}\n {%- set sql_header = config.get(\'sql_header\', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary -%}\n temporary\n {%- elif unlogged -%}\n unlogged\n {%- endif %} table {{ relation }}\n as (\n {{ sql }}\n );\n{%- endmacro %}\n\n{% macro postgres__create_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{ schema_name }}\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__drop_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{ schema_name }} cascade\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__get_columns_in_relation(relation) -%}\n {% call statement(\'get_columns_in_relation\', fetch_result=True) %}\n select\n column_name,\n data_type,\n character_maximum_length,\n numeric_precision,\n numeric_scale\n\n from {{ relation.information_schema(\'columns\') }}\n where table_name = \'{{ relation.identifier }}\'\n {% if relation.schema %}\n and table_schema = \'{{ relation.schema }}\'\n {% endif %}\n order by ordinal_position\n\n {% endcall %}\n {% set table = load_result(\'get_columns_in_relation\').table %}\n {{ return(sql_convert_columns_in_relation(table)) }}\n{% endmacro %}\n\n\n{% macro postgres__list_relations_without_caching(information_schema, schema) %}\n {% call statement(\'list_relations_without_caching\', fetch_result=True) -%}\n select\n \'{{ information_schema.database }}\' as database,\n tablename as name,\n schemaname as schema,\n \'table\' as type\n from pg_tables\n where schemaname ilike \'{{ schema }}\'\n union all\n select\n \'{{ information_schema.database }}\' as database,\n viewname as name,\n schemaname as schema,\n \'view\' as type\n from pg_views\n where schemaname ilike \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'list_relations_without_caching\').table) }}\n{% endmacro %}\n\n{% macro postgres__information_schema_name(database) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n information_schema\n{%- endmacro %}\n\n{% macro postgres__list_schemas(database) %}\n {% if database -%}\n {{ adapter.verify_database(database) }}\n {%- endif -%}\n {% call statement(\'list_schemas\', fetch_result=True, auto_begin=False) %}\n select distinct nspname from pg_namespace\n {% endcall %}\n {{ return(load_result(\'list_schemas\').table) }}\n{% endmacro %}\n\n{% macro postgres__check_schema_exists(information_schema, schema) -%}\n {% if information_schema.database -%}\n {{ adapter.verify_database(information_schema.database) }}\n {%- endif -%}\n {% call statement(\'check_schema_exists\', fetch_result=True, auto_begin=False) %}\n select count(*) from pg_namespace where nspname = \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'check_schema_exists\').table) }}\n{% endmacro %}\n\n\n{% macro postgres__current_timestamp() -%}\n now()\n{%- endmacro %}\n\n{% macro postgres__snapshot_string_as_time(timestamp) -%}\n {%- set result = "\'" ~ timestamp ~ "\'::timestamp without time zone" -%}\n {{ return(result) }}\n{%- endmacro %}\n\n\n{% macro postgres__snapshot_get_time() -%}\n {{ current_timestamp() }}::timestamp without time zone\n{%- endmacro %}\n\n{% macro postgres__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix ~ py_current_timestring() %}\n {% do return(base_relation.incorporate(\n path={\n "identifier": tmp_identifier,\n "schema": none,\n "database": none\n })) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt_postgres.postgres__snapshot_get_time', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/adapters.sql', 'original_file_path': 'macros/adapters.sql', 'resource_type': 'macro', 'name': 'postgres__snapshot_get_time', 'macro_sql': '{% macro postgres__snapshot_get_time() -%}\n {{ current_timestamp() }}::timestamp without time zone\n{%- endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres__make_temp_relation': {'raw_sql': '{% macro postgres__create_table_as(temporary, relation, sql) -%}\n {%- set unlogged = config.get(\'unlogged\', default=false) -%}\n {%- set sql_header = config.get(\'sql_header\', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary -%}\n temporary\n {%- elif unlogged -%}\n unlogged\n {%- endif %} table {{ relation }}\n as (\n {{ sql }}\n );\n{%- endmacro %}\n\n{% macro postgres__create_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'create_schema\') -%}\n create schema if not exists {{ schema_name }}\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__drop_schema(database_name, schema_name) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n {%- call statement(\'drop_schema\') -%}\n drop schema if exists {{ schema_name }} cascade\n {%- endcall -%}\n{% endmacro %}\n\n{% macro postgres__get_columns_in_relation(relation) -%}\n {% call statement(\'get_columns_in_relation\', fetch_result=True) %}\n select\n column_name,\n data_type,\n character_maximum_length,\n numeric_precision,\n numeric_scale\n\n from {{ relation.information_schema(\'columns\') }}\n where table_name = \'{{ relation.identifier }}\'\n {% if relation.schema %}\n and table_schema = \'{{ relation.schema }}\'\n {% endif %}\n order by ordinal_position\n\n {% endcall %}\n {% set table = load_result(\'get_columns_in_relation\').table %}\n {{ return(sql_convert_columns_in_relation(table)) }}\n{% endmacro %}\n\n\n{% macro postgres__list_relations_without_caching(information_schema, schema) %}\n {% call statement(\'list_relations_without_caching\', fetch_result=True) -%}\n select\n \'{{ information_schema.database }}\' as database,\n tablename as name,\n schemaname as schema,\n \'table\' as type\n from pg_tables\n where schemaname ilike \'{{ schema }}\'\n union all\n select\n \'{{ information_schema.database }}\' as database,\n viewname as name,\n schemaname as schema,\n \'view\' as type\n from pg_views\n where schemaname ilike \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'list_relations_without_caching\').table) }}\n{% endmacro %}\n\n{% macro postgres__information_schema_name(database) -%}\n {% if database_name -%}\n {{ adapter.verify_database(database_name) }}\n {%- endif -%}\n information_schema\n{%- endmacro %}\n\n{% macro postgres__list_schemas(database) %}\n {% if database -%}\n {{ adapter.verify_database(database) }}\n {%- endif -%}\n {% call statement(\'list_schemas\', fetch_result=True, auto_begin=False) %}\n select distinct nspname from pg_namespace\n {% endcall %}\n {{ return(load_result(\'list_schemas\').table) }}\n{% endmacro %}\n\n{% macro postgres__check_schema_exists(information_schema, schema) -%}\n {% if information_schema.database -%}\n {{ adapter.verify_database(information_schema.database) }}\n {%- endif -%}\n {% call statement(\'check_schema_exists\', fetch_result=True, auto_begin=False) %}\n select count(*) from pg_namespace where nspname = \'{{ schema }}\'\n {% endcall %}\n {{ return(load_result(\'check_schema_exists\').table) }}\n{% endmacro %}\n\n\n{% macro postgres__current_timestamp() -%}\n now()\n{%- endmacro %}\n\n{% macro postgres__snapshot_string_as_time(timestamp) -%}\n {%- set result = "\'" ~ timestamp ~ "\'::timestamp without time zone" -%}\n {{ return(result) }}\n{%- endmacro %}\n\n\n{% macro postgres__snapshot_get_time() -%}\n {{ current_timestamp() }}::timestamp without time zone\n{%- endmacro %}\n\n{% macro postgres__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix ~ py_current_timestring() %}\n {% do return(base_relation.incorporate(\n path={\n "identifier": tmp_identifier,\n "schema": none,\n "database": none\n })) -%}\n{% endmacro %}', 'unique_id': 'macro.dbt_postgres.postgres__make_temp_relation', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/adapters.sql', 'original_file_path': 'macros/adapters.sql', 'resource_type': 'macro', 'name': 'postgres__make_temp_relation', 'macro_sql': '{% macro postgres__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix ~ py_current_timestring() %}\n {% do return(base_relation.incorporate(\n path={\n "identifier": tmp_identifier,\n "schema": none,\n "database": none\n })) -%}\n{% endmacro %}', 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}, 'macro.dbt_postgres.postgres__snapshot_merge_sql': {'raw_sql': "{% macro postgres__snapshot_merge_sql(target, source, insert_cols) -%}\n {%- set insert_cols_csv = insert_cols | join(', ') -%}\n\n update {{ target }}\n set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to\n from {{ source }} as DBT_INTERNAL_SOURCE\n where DBT_INTERNAL_SOURCE.dbt_scd_id::text = {{ target }}.dbt_scd_id::text\n and DBT_INTERNAL_SOURCE.dbt_change_type::text = 'update'::text\n and {{ target }}.dbt_valid_to is null;\n\n insert into {{ target }} ({{ insert_cols_csv }})\n select {% for column in insert_cols -%}\n DBT_INTERNAL_SOURCE.{{ column }} {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n from {{ source }} as DBT_INTERNAL_SOURCE\n where DBT_INTERNAL_SOURCE.dbt_change_type::text = 'insert'::text;\n{% endmacro %}", 'unique_id': 'macro.dbt_postgres.postgres__snapshot_merge_sql', 'package_name': 'dbt_postgres', 'root_path': '/usr/app/plugins/postgres/dbt/include/postgres', 'path': 'macros/materializations/snapshot_merge.sql', 'original_file_path': 'macros/materializations/snapshot_merge.sql', 'resource_type': 'macro', 'name': 'postgres__snapshot_merge_sql', 'macro_sql': "{% macro postgres__snapshot_merge_sql(target, source, insert_cols) -%}\n {%- set insert_cols_csv = insert_cols | join(', ') -%}\n\n update {{ target }}\n set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to\n from {{ source }} as DBT_INTERNAL_SOURCE\n where DBT_INTERNAL_SOURCE.dbt_scd_id::text = {{ target }}.dbt_scd_id::text\n and DBT_INTERNAL_SOURCE.dbt_change_type::text = 'update'::text\n and {{ target }}.dbt_valid_to is null;\n\n insert into {{ target }} ({{ insert_cols_csv }})\n select {% for column in insert_cols -%}\n DBT_INTERNAL_SOURCE.{{ column }} {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n from {{ source }} as DBT_INTERNAL_SOURCE\n where DBT_INTERNAL_SOURCE.dbt_change_type::text = 'insert'::text;\n{% endmacro %}", 'tags': [], 'depends_on': {'macros': []}, 'description': '', 'meta': {}, 'patch_path': None, 'arguments': []}}, 'docs': {'dbt.__overview__': {'unique_id': 'dbt.__overview__', 'package_name': 'dbt', 'root_path': '/usr/app/core/dbt/include/global_project', 'path': 'overview.md', 'original_file_path': 'docs/overview.md', 'file_contents': "{% docs __overview__ %}\n\n### 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 `--models` 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/overview)?\n- Read the [dbt viewpoint](https://docs.getdbt.com/docs/viewpoint)\n- [Installation](https://docs.getdbt.com/docs/installation)\n- Join the [chat](https://slack.getdbt.com/) on Slack for live questions and support.\n\n{% enddocs %}", '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 `--models` 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/overview)?\n- Read the [dbt viewpoint](https://docs.getdbt.com/docs/viewpoint)\n- [Installation](https://docs.getdbt.com/docs/installation)\n- Join the [chat](https://slack.getdbt.com/) on Slack for live questions and support."}}, 'disabled': [], 'generated_at': '2020-03-23T17:57:12.224118Z', 'parent_map': {'model.test.my_model': []}, 'child_map': {'model.test.my_model': []}, 'metadata': {'project_id': '098f6bcd4621d373cade4e832627b4f6', 'user_id': None, 'send_anonymous_usage_stats': False, 'adapter_type': 'postgres'}, 'files': {'/usr/app/core/dbt/include/global_project/macros/core.sql': {'path': {'searched_path': 'macros', 'relative_path': 'core.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '9dde6e3cf4b01799f44b1c6d4f23e77f471567a1cbbeab763da5032f0d102821'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.statement', 'macro.dbt.noop_statement'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/materializations/helpers.sql': {'path': {'searched_path': 'macros', 'relative_path': 'materializations/helpers.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': 'f29316a03082e0c4e9e0b9cc5d73af75206c9db845d01b1e2068d7bb2ab58090'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.run_hooks', 'macro.dbt.column_list', 'macro.dbt.column_list_for_create_table', 'macro.dbt.make_hook_config', 'macro.dbt.before_begin', 'macro.dbt.in_transaction', 'macro.dbt.after_commit', 'macro.dbt.drop_relation_if_exists', 'macro.dbt.load_relation'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/materializations/snapshot/snapshot_merge.sql': {'path': {'searched_path': 'macros', 'relative_path': 'materializations/snapshot/snapshot_merge.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '5c6f5982ea4f6a4efe7106b9706c78197d355ef5a50d9ca1c254ba9fe8b5d114'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.snapshot_merge_sql', 'macro.dbt.default__snapshot_merge_sql'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/materializations/snapshot/strategies.sql': {'path': {'searched_path': 'macros', 'relative_path': 'materializations/snapshot/strategies.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '3f88751a98bef086ae59d67a8090e28140aebad8c3c4dbbf7fd462e422d808da'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.strategy_dispatch', 'macro.dbt.snapshot_hash_arguments', 'macro.dbt.default__snapshot_hash_arguments', 'macro.dbt.snapshot_get_time', 'macro.dbt.default__snapshot_get_time', 'macro.dbt.snapshot_timestamp_strategy', 'macro.dbt.snapshot_string_as_time', 'macro.dbt.default__snapshot_string_as_time', 'macro.dbt.snapshot_check_all_get_existing_columns', 'macro.dbt.snapshot_check_strategy'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/materializations/snapshot/snapshot.sql': {'path': {'searched_path': 'macros', 'relative_path': 'materializations/snapshot/snapshot.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '3f8c4854169daa7257c62bb2ecf4ee532d0e87b59ed2151382e6c4728b259cce'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.create_columns', 'macro.dbt.default__create_columns', 'macro.dbt.post_snapshot', 'macro.dbt.default__post_snapshot', 'macro.dbt.snapshot_staging_table_inserts', 'macro.dbt.snapshot_staging_table_updates', 'macro.dbt.build_snapshot_table', 'macro.dbt.get_or_create_relation', 'macro.dbt.build_snapshot_staging_table', 'macro.dbt.materialization_snapshot_default'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/materializations/seed/seed.sql': {'path': {'searched_path': 'macros', 'relative_path': 'materializations/seed/seed.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '3108894047b1bbf22594ec0e7e1cc9769c58bf3caa4f699b6827aa67dcdbc5dd'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.create_csv_table', 'macro.dbt.reset_csv_table', 'macro.dbt.load_csv_rows', 'macro.dbt.default__create_csv_table', 'macro.dbt.default__reset_csv_table', 'macro.dbt.get_seed_column_quoted_csv', 'macro.dbt.basic_load_csv_rows', 'macro.dbt.default__load_csv_rows', 'macro.dbt.materialization_seed_default'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/materializations/incremental/helpers.sql': {'path': {'searched_path': 'macros', 'relative_path': 'materializations/incremental/helpers.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': 'c37f9127e9c8a575db6ac76470aa8e4bea07d5d8c714511349a74607e32306e1'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.incremental_upsert'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/materializations/incremental/incremental.sql': {'path': {'searched_path': 'macros', 'relative_path': 'materializations/incremental/incremental.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': 'f29fd9555f8f24be85b629603b4499e3eac7dde2e52d92343921b6506fad07c7'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.materialization_incremental_default'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/materializations/common/merge.sql': {'path': {'searched_path': 'macros', 'relative_path': 'materializations/common/merge.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '6f9ce33fdf66a2fa542434570298490548047e6e0ae845d82424bac51bba2322'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.get_merge_sql', 'macro.dbt.get_delete_insert_merge_sql', 'macro.dbt.get_insert_overwrite_merge_sql', 'macro.dbt.default__get_merge_sql', 'macro.dbt.get_quoted_csv', 'macro.dbt.common_get_delete_insert_merge_sql', 'macro.dbt.default__get_delete_insert_merge_sql', 'macro.dbt.default__get_insert_overwrite_merge_sql'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/materializations/table/table.sql': {'path': {'searched_path': 'macros', 'relative_path': 'materializations/table/table.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '7532a98937b3f467b639610ab7d68b121f94f2570576e84ebb285e326c52d93f'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.materialization_table_default'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/materializations/view/view.sql': {'path': {'searched_path': 'macros', 'relative_path': 'materializations/view/view.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '495441a9fa472aa6e369a9e87c469e3e82bd2f5cdf90605a3e574b6bfcf9a999'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.materialization_view_default'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/materializations/view/create_or_replace_view.sql': {'path': {'searched_path': 'macros', 'relative_path': 'materializations/view/create_or_replace_view.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': 'f248f585af455af494d885fb929bcca529e44e080670740feb2c792674599eba'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.handle_existing_table', 'macro.dbt.default__handle_existing_table', 'macro.dbt.create_or_replace_view'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/etc/get_custom_alias.sql': {'path': {'searched_path': 'macros', 'relative_path': 'etc/get_custom_alias.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': 'a5e6fbf352700a021e2a4726818beb8b164bb8f29d664fbb68aa8fe142ec589e'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.generate_alias_name'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/etc/query.sql': {'path': {'searched_path': 'macros', 'relative_path': 'etc/query.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '332f51dd1615c90e372c87aeb65651c2a66a6f8313be34dfae1e91eb7c5e1316'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.run_query'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/etc/is_incremental.sql': {'path': {'searched_path': 'macros', 'relative_path': 'etc/is_incremental.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '08a74e7b1a42476e996dedbd89c97ffb47e95c864b9fec6ddad6e9771eeeb7f1'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.is_incremental'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/etc/get_relation_comment.sql': {'path': {'searched_path': 'macros', 'relative_path': 'etc/get_relation_comment.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '653267a61c95a535c6d47f8baea9dbbc533fcb3c671e6cd1d8ac5419d218da26'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.table_options', 'macro.dbt.get_relation_comment'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/etc/datetime.sql': {'path': {'searched_path': 'macros', 'relative_path': 'etc/datetime.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '0ebb8f28f68f1506962974dd513917a68a196f0cabf70ce3a43d9a72159ddc6c'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.convert_datetime', 'macro.dbt.dates_in_range', 'macro.dbt.partition_range', 'macro.dbt.py_current_timestring'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/etc/get_custom_schema.sql': {'path': {'searched_path': 'macros', 'relative_path': 'etc/get_custom_schema.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '3a7d4b9d5105010dd92327027f81c9e079b9a5cd68098b02682fedde376fa5de'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.generate_schema_name', 'macro.dbt.generate_schema_name_for_env'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/etc/get_custom_database.sql': {'path': {'searched_path': 'macros', 'relative_path': 'etc/get_custom_database.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '2b76c8cc7aede4270f5e37d5623788978688e5c382f4dc4e222453a592b0b532'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.generate_database_name'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/adapters/common.sql': {'path': {'searched_path': 'macros', 'relative_path': 'adapters/common.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': 'b20f3411a1cb7997bdbbe6df7867d993d405230b63c8bf14710eb9fefd96ca56'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.adapter_macro', 'macro.dbt.get_columns_in_query', 'macro.dbt.default__get_columns_in_query', 'macro.dbt.create_schema', 'macro.dbt.default__create_schema', 'macro.dbt.drop_schema', 'macro.dbt.default__drop_schema', 'macro.dbt.create_table_as', 'macro.dbt.default__create_table_as', 'macro.dbt.create_view_as', 'macro.dbt.default__create_view_as', 'macro.dbt.get_catalog', 'macro.dbt.default__get_catalog', 'macro.dbt.get_columns_in_relation', 'macro.dbt.sql_convert_columns_in_relation', 'macro.dbt.default__get_columns_in_relation', 'macro.dbt.alter_column_type', 'macro.dbt.default__alter_column_type', 'macro.dbt.drop_relation', 'macro.dbt.default__drop_relation', 'macro.dbt.truncate_relation', 'macro.dbt.default__truncate_relation', 'macro.dbt.rename_relation', 'macro.dbt.default__rename_relation', 'macro.dbt.information_schema_name', 'macro.dbt.default__information_schema_name', 'macro.dbt.list_schemas', 'macro.dbt.default__list_schemas', 'macro.dbt.check_schema_exists', 'macro.dbt.default__check_schema_exists', 'macro.dbt.list_relations_without_caching', 'macro.dbt.default__list_relations_without_caching', 'macro.dbt.current_timestamp', 'macro.dbt.default__current_timestamp', 'macro.dbt.collect_freshness', 'macro.dbt.default__collect_freshness', 'macro.dbt.make_temp_relation', 'macro.dbt.default__make_temp_relation', 'macro.dbt.set_sql_header'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/schema_tests/relationships.sql': {'path': {'searched_path': 'macros', 'relative_path': 'schema_tests/relationships.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '4f50036d55fcfe56fbe7d283b8d29b6af935ca7e9abffa57043e20e5680609be'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.test_relationships'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/schema_tests/not_null.sql': {'path': {'searched_path': 'macros', 'relative_path': 'schema_tests/not_null.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': 'a7fd6f2e1f9645059f33cd6a94598a2d72a7bf9c5d568eefc604b1824640efc7'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.test_not_null'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/schema_tests/unique.sql': {'path': {'searched_path': 'macros', 'relative_path': 'schema_tests/unique.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': 'a4d53f54a4fa7e846d347418471ebf00e364f4e850f2655e3ce8c6fb49e83bf4'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.test_unique'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/macros/schema_tests/accepted_values.sql': {'path': {'searched_path': 'macros', 'relative_path': 'schema_tests/accepted_values.sql', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': 'b7c3adabeeb96b9e19e19a8fe0e9f56dcc5af20804a613f71f100eba8ae520a9'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt.test_accepted_values'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/plugins/postgres/dbt/include/postgres/macros/catalog.sql': {'path': {'searched_path': 'macros', 'relative_path': 'catalog.sql', 'project_root': '/usr/app/plugins/postgres/dbt/include/postgres'}, 'checksum': {'name': 'sha256', 'checksum': '66026d3423ab9e6ed0f2ab7fb7924d2f474de06cb19453072df22fc13addf3cd'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt_postgres.postgres__get_catalog'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/plugins/postgres/dbt/include/postgres/macros/relations.sql': {'path': {'searched_path': 'macros', 'relative_path': 'relations.sql', 'project_root': '/usr/app/plugins/postgres/dbt/include/postgres'}, 'checksum': {'name': 'sha256', 'checksum': '6b4cb13349d8314702b5eee62d8b6d4d1a14586b1851bcae7dc77ee5d1956ba9'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt_postgres.postgres_get_relations'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/plugins/postgres/dbt/include/postgres/macros/adapters.sql': {'path': {'searched_path': 'macros', 'relative_path': 'adapters.sql', 'project_root': '/usr/app/plugins/postgres/dbt/include/postgres'}, 'checksum': {'name': 'sha256', 'checksum': 'e8b9338cc35fd28109ed2b282dd89b18803bd8bfa7e9861dd7432d862896005d'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt_postgres.postgres__create_table_as', 'macro.dbt_postgres.postgres__create_schema', 'macro.dbt_postgres.postgres__drop_schema', 'macro.dbt_postgres.postgres__get_columns_in_relation', 'macro.dbt_postgres.postgres__list_relations_without_caching', 'macro.dbt_postgres.postgres__information_schema_name', 'macro.dbt_postgres.postgres__list_schemas', 'macro.dbt_postgres.postgres__check_schema_exists', 'macro.dbt_postgres.postgres__current_timestamp', 'macro.dbt_postgres.postgres__snapshot_string_as_time', 'macro.dbt_postgres.postgres__snapshot_get_time', 'macro.dbt_postgres.postgres__make_temp_relation'], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/plugins/postgres/dbt/include/postgres/macros/materializations/snapshot_merge.sql': {'path': {'searched_path': 'macros', 'relative_path': 'materializations/snapshot_merge.sql', 'project_root': '/usr/app/plugins/postgres/dbt/include/postgres'}, 'checksum': {'name': 'sha256', 'checksum': '8b3bbe37eddd6ac43d224b116c4c9d4fa7c2729412c4ec69d409e15d2e140aa7'}, 'nodes': [], 'docs': [], 'macros': ['macro.dbt_postgres.postgres__snapshot_merge_sql'], 'sources': [], 'patches': [], 'macro_patches': []}, '/tmp/pytest-of-dbt_test_user/pytest-0/popen-gw0/test_get_manifest0/project/models/my_model.sql': {'path': {'searched_path': 'models', 'relative_path': 'my_model.sql', 'project_root': '/tmp/pytest-of-dbt_test_user/pytest-0/popen-gw0/test_get_manifest0/project'}, 'checksum': {'name': 'sha256', 'checksum': '3ea0f972fa1b56aa2dc2f56ee784b6a5796312f9a813d59ae70fd8855f10d16d'}, 'nodes': ['model.test.my_model'], 'docs': [], 'macros': [], 'sources': [], 'patches': [], 'macro_patches': []}, '/usr/app/core/dbt/include/global_project/docs/overview.md': {'path': {'searched_path': 'docs', 'relative_path': 'overview.md', 'project_root': '/usr/app/core/dbt/include/global_project'}, 'checksum': {'name': 'sha256', 'checksum': '66db3d93aa0f4fa15a61ea3441e71b887d93e11c626bb000d73b6da808231747'}, 'nodes': [], 'docs': ['dbt.__overview__'], 'macros': [], 'sources': [], 'patches': [], 'macro_patches': []}}}} diff --git a/core/dbt/task/rpc/project_commands.py b/core/dbt/task/rpc/project_commands.py index d88f46b5371..09f0fcba72c 100644 --- a/core/dbt/task/rpc/project_commands.py +++ b/core/dbt/task/rpc/project_commands.py @@ -3,6 +3,8 @@ from dbt.contracts.rpc import ( + GetManifestParameters, + GetManifestResult, RPCCompileParameters, RPCDocsGenerateParameters, RPCRunOperationParameters, @@ -188,3 +190,26 @@ def set_args(self, params: RPCSourceFreshnessParameters) -> None: if params.threads is not None: self.args.threads = params.threads self.args.output = None + + +# this is a weird and special method. +class GetManifest( + RemoteManifestMethod[GetManifestParameters, GetManifestResult] +): + METHOD_NAME = 'get-manifest' + + def set_args(self, params: GetManifestParameters) -> None: + self.args.models = None + self.args.exclude = None + + def handle_request(self) -> GetManifestResult: + task = RemoteCompileProjectTask(self.args, self.config, self.manifest) + task.run() + + return GetManifestResult( + logs=[], + manifest=task.manifest, + ) + + def interpret_results(self, results): + return True diff --git a/test/rpc/test_base.py b/test/rpc/test_base.py index 14694f155a3..e94f86d49a6 100644 --- a/test/rpc/test_base.py +++ b/test/rpc/test_base.py @@ -885,3 +885,32 @@ def test_rpc_vars( results = querier.async_wait_for_result(querier.cli_args('run --vars "{param: 100}"')) assert len(results['results']) == 1 assert results['results'][0]['node']['compiled_sql'] == 'select 100 as id' + + +def test_get_manifest( + project_root, profiles_root, postgres_profile, unique_schema +): + project = ProjectDefinition( + models={ + 'my_model.sql': 'select 1 as id', + }, + ) + querier_ctx = get_querier( + project_def=project, + project_dir=project_root, + profiles_dir=profiles_root, + schema=unique_schema, + test_kwargs={}, + ) + + with querier_ctx as querier: + results = querier.async_wait_for_result(querier.cli_args('run')) + assert len(results['results']) == 1 + assert results['results'][0]['node']['compiled_sql'] == 'select 1 as id' + result = querier.async_wait_for_result(querier.get_manifest()) + assert 'manifest' in result + manifest = result['manifest'] + assert manifest['nodes']['model.test.my_model']['raw_sql'] == 'select 1 as id' + assert 'manifest' in result + manifest = result['manifest'] + assert manifest['nodes']['model.test.my_model']['compiled_sql'] == 'select 1 as id' diff --git a/test/rpc/util.py b/test/rpc/util.py index 43e7a3ff87d..c684238f95c 100644 --- a/test/rpc/util.py +++ b/test/rpc/util.py @@ -369,6 +369,11 @@ def run_sql( method='run_sql', params=params, request_id=request_id ) + def get_manifest(self, request_id=1): + return self.request( + method='get-manifest', params={}, request_id=request_id + ) + def is_result(self, data: Dict[str, Any], id=None) -> Dict[str, Any]: if id is not None: assert data['id'] == id