From 926e66eec1653d43dc77781222166bb33d2d775d Mon Sep 17 00:00:00 2001 From: suryaiyer95 Date: Wed, 24 Jan 2024 22:19:30 -0800 Subject: [PATCH] feat: first commit --- setup.py | 12 +- src/datapilot/__main__.py | 4 +- src/datapilot/cli.py | 23 - src/datapilot/cli/__init__.py | 0 src/datapilot/cli/main.py | 12 + src/datapilot/config/__init__.py | 0 src/datapilot/config/config.py | 14 + src/datapilot/config/utils.py | 17 + src/datapilot/core/__init__.py | 0 src/datapilot/core/insights/__init__.py | 2 + src/datapilot/core/insights/base/__init__.py | 0 src/datapilot/core/insights/base/insight.py | 24 + src/datapilot/core/insights/report.py | 16 + src/datapilot/core/insights/schema.py | 24 + src/datapilot/core/insights/sql/__init__.py | 0 .../core/insights/sql/base/__init__.py | 0 .../core/insights/sql/base/insight.py | 18 + .../core/insights/sql/runtime/__init__.py | 0 .../core/insights/sql/static/__init__.py | 0 src/datapilot/core/insights/utils.py | 20 + src/datapilot/core/platforms/__init__.py | 0 src/datapilot/core/platforms/dbt/__init__.py | 0 .../core/platforms/dbt/cli/__init__.py | 1 + src/datapilot/core/platforms/dbt/cli/cli.py | 66 + src/datapilot/core/platforms/dbt/constants.py | 34 + .../core/platforms/dbt/exceptions.py | 2 + src/datapilot/core/platforms/dbt/executor.py | 114 + src/datapilot/core/platforms/dbt/factory.py | 23 + .../core/platforms/dbt/formatting.py | 43 + .../core/platforms/dbt/insights/__init__.py | 45 + .../core/platforms/dbt/insights/base.py | 86 + .../dbt/insights/dbt_test/__init__.py | 2 + .../platforms/dbt/insights/dbt_test/base.py | 23 + .../dbt_test/missing_primary_key_tests.py | 129 + .../dbt/insights/dbt_test/test_coverage.py | 111 + .../dbt/insights/governance/__init__.py | 6 + .../platforms/dbt/insights/governance/base.py | 23 + .../documentation_on_stale_columns.py | 123 + .../exposures_dependent_on_private_models.py | 92 + .../public_models_without_contracts.py | 91 + .../governance/undocumented_columns.py | 140 + .../governance/undocumented_public_models.py | 110 + .../dbt/insights/modelling/README.md | 15 + .../dbt/insights/modelling/__init__.py | 15 + .../platforms/dbt/insights/modelling/base.py | 30 + .../modelling/direct_join_to_source.py | 124 + .../downstream_models_dependent_on_source.py | 112 + .../insights/modelling/duplicate_sources.py | 89 + .../modelling/hard_coded_references.py | 81 + .../modelling/joining_of_upstream_concepts.py | 79 + .../dbt/insights/modelling/model_fanout.py | 115 + .../modelling/multiple_sources_joined.py | 84 + .../dbt/insights/modelling/root_model.py | 84 + .../dbt/insights/modelling/source_fanout.py | 91 + ...ng_model_dependent_on_downstream_models.py | 101 + ...aging_model_dependent_on_staging_models.py | 91 + .../dbt/insights/modelling/unused_sources.py | 61 + .../dbt/insights/performance/__init__.py | 2 + .../dbt/insights/performance/base.py | 26 + .../performance/chain_view_linking.py | 83 + .../exposure_parent_materializations.py | 107 + .../core/platforms/dbt/insights/schema.py | 69 + .../dbt/insights/structure/__init__.py | 4 + .../platforms/dbt/insights/structure/base.py | 30 + .../structure/model_directories_structuire.py | 93 + .../structure/model_naming_conventions.py | 96 + .../structure/source_directories_structure.py | 82 + .../structure/test_directory_structure.py | 74 + .../core/platforms/dbt/schemas/__init__.py | 0 .../core/platforms/dbt/schemas/catalog.py | 69 + .../core/platforms/dbt/schemas/manifest.py | 343 + src/datapilot/core/platforms/dbt/utils.py | 426 + .../core/platforms/dbt/wrappers/__init__.py | 0 .../dbt/wrappers/catalog/__init__.py | 0 .../dbt/wrappers/catalog/v1/__init__.py | 0 .../dbt/wrappers/catalog/v1/wrapper.py | 19 + .../platforms/dbt/wrappers/catalog/wrapper.py | 9 + .../dbt/wrappers/manifest/__init__.py | 0 .../dbt/wrappers/manifest/v11/__init__.py | 0 .../dbt/wrappers/manifest/v11/schemas.py | 31 + .../dbt/wrappers/manifest/v11/wrapper.py | 276 + .../dbt/wrappers/manifest/wrapper.py | 26 + .../dbt/wrappers/run_results/__init__.py | 0 .../dbt/wrappers/run_results/run_results.py | 41 + src/datapilot/exceptions/__init__.py | 0 src/datapilot/exceptions/exceptions.py | 10 + src/datapilot/schemas/__init__.py | 0 src/datapilot/schemas/constants.py | 4 + src/datapilot/schemas/sql.py | 10 + src/datapilot/utils/__init__.py | 0 src/datapilot/utils/formatting/__init__.py | 0 src/datapilot/utils/formatting/utils.py | 59 + src/datapilot/utils/utils.py | 41 + tests/core/__init__.py | 0 tests/core/platform/__init__.py | 0 tests/core/platform/dbt/__init__.py | 0 tests/core/platform/dbt/test_utils.py | 139 + tests/data/catalog_v1.json | 5233 +++ tests/data/config.yml | 17 + tests/data/manifest_v11.json | 38002 ++++++++++++++++ tests/test_datapilot.py | 11 - tests/utils/__init__.py | 0 tests/utils/test_utils.py | 17 + 103 files changed, 48030 insertions(+), 41 deletions(-) delete mode 100644 src/datapilot/cli.py create mode 100644 src/datapilot/cli/__init__.py create mode 100644 src/datapilot/cli/main.py create mode 100644 src/datapilot/config/__init__.py create mode 100644 src/datapilot/config/config.py create mode 100644 src/datapilot/config/utils.py create mode 100644 src/datapilot/core/__init__.py create mode 100644 src/datapilot/core/insights/__init__.py create mode 100644 src/datapilot/core/insights/base/__init__.py create mode 100644 src/datapilot/core/insights/base/insight.py create mode 100644 src/datapilot/core/insights/report.py create mode 100644 src/datapilot/core/insights/schema.py create mode 100644 src/datapilot/core/insights/sql/__init__.py create mode 100644 src/datapilot/core/insights/sql/base/__init__.py create mode 100644 src/datapilot/core/insights/sql/base/insight.py create mode 100644 src/datapilot/core/insights/sql/runtime/__init__.py create mode 100644 src/datapilot/core/insights/sql/static/__init__.py create mode 100644 src/datapilot/core/insights/utils.py create mode 100644 src/datapilot/core/platforms/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/cli/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/cli/cli.py create mode 100644 src/datapilot/core/platforms/dbt/constants.py create mode 100644 src/datapilot/core/platforms/dbt/exceptions.py create mode 100644 src/datapilot/core/platforms/dbt/executor.py create mode 100644 src/datapilot/core/platforms/dbt/factory.py create mode 100644 src/datapilot/core/platforms/dbt/formatting.py create mode 100644 src/datapilot/core/platforms/dbt/insights/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/insights/base.py create mode 100644 src/datapilot/core/platforms/dbt/insights/dbt_test/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/insights/dbt_test/base.py create mode 100644 src/datapilot/core/platforms/dbt/insights/dbt_test/missing_primary_key_tests.py create mode 100644 src/datapilot/core/platforms/dbt/insights/dbt_test/test_coverage.py create mode 100644 src/datapilot/core/platforms/dbt/insights/governance/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/insights/governance/base.py create mode 100644 src/datapilot/core/platforms/dbt/insights/governance/documentation_on_stale_columns.py create mode 100644 src/datapilot/core/platforms/dbt/insights/governance/exposures_dependent_on_private_models.py create mode 100644 src/datapilot/core/platforms/dbt/insights/governance/public_models_without_contracts.py create mode 100644 src/datapilot/core/platforms/dbt/insights/governance/undocumented_columns.py create mode 100644 src/datapilot/core/platforms/dbt/insights/governance/undocumented_public_models.py create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/README.md create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/base.py create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/direct_join_to_source.py create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/downstream_models_dependent_on_source.py create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/duplicate_sources.py create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/hard_coded_references.py create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/joining_of_upstream_concepts.py create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/model_fanout.py create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/multiple_sources_joined.py create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/root_model.py create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/source_fanout.py create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/staging_model_dependent_on_downstream_models.py create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/staging_model_dependent_on_staging_models.py create mode 100644 src/datapilot/core/platforms/dbt/insights/modelling/unused_sources.py create mode 100644 src/datapilot/core/platforms/dbt/insights/performance/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/insights/performance/base.py create mode 100644 src/datapilot/core/platforms/dbt/insights/performance/chain_view_linking.py create mode 100644 src/datapilot/core/platforms/dbt/insights/performance/exposure_parent_materializations.py create mode 100644 src/datapilot/core/platforms/dbt/insights/schema.py create mode 100644 src/datapilot/core/platforms/dbt/insights/structure/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/insights/structure/base.py create mode 100644 src/datapilot/core/platforms/dbt/insights/structure/model_directories_structuire.py create mode 100644 src/datapilot/core/platforms/dbt/insights/structure/model_naming_conventions.py create mode 100644 src/datapilot/core/platforms/dbt/insights/structure/source_directories_structure.py create mode 100644 src/datapilot/core/platforms/dbt/insights/structure/test_directory_structure.py create mode 100644 src/datapilot/core/platforms/dbt/schemas/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/schemas/catalog.py create mode 100644 src/datapilot/core/platforms/dbt/schemas/manifest.py create mode 100644 src/datapilot/core/platforms/dbt/utils.py create mode 100644 src/datapilot/core/platforms/dbt/wrappers/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/wrappers/catalog/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/wrappers/catalog/v1/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/wrappers/catalog/v1/wrapper.py create mode 100644 src/datapilot/core/platforms/dbt/wrappers/catalog/wrapper.py create mode 100644 src/datapilot/core/platforms/dbt/wrappers/manifest/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/wrappers/manifest/v11/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/wrappers/manifest/v11/schemas.py create mode 100644 src/datapilot/core/platforms/dbt/wrappers/manifest/v11/wrapper.py create mode 100644 src/datapilot/core/platforms/dbt/wrappers/manifest/wrapper.py create mode 100644 src/datapilot/core/platforms/dbt/wrappers/run_results/__init__.py create mode 100644 src/datapilot/core/platforms/dbt/wrappers/run_results/run_results.py create mode 100644 src/datapilot/exceptions/__init__.py create mode 100644 src/datapilot/exceptions/exceptions.py create mode 100644 src/datapilot/schemas/__init__.py create mode 100644 src/datapilot/schemas/constants.py create mode 100644 src/datapilot/schemas/sql.py create mode 100644 src/datapilot/utils/__init__.py create mode 100644 src/datapilot/utils/formatting/__init__.py create mode 100644 src/datapilot/utils/formatting/utils.py create mode 100644 src/datapilot/utils/utils.py create mode 100644 tests/core/__init__.py create mode 100644 tests/core/platform/__init__.py create mode 100644 tests/core/platform/dbt/__init__.py create mode 100644 tests/core/platform/dbt/test_utils.py create mode 100644 tests/data/catalog_v1.json create mode 100644 tests/data/config.yml create mode 100644 tests/data/manifest_v11.json delete mode 100644 tests/test_datapilot.py create mode 100644 tests/utils/__init__.py create mode 100644 tests/utils/test_utils.py diff --git a/setup.py b/setup.py index fa5d6ecf..7f9c922c 100755 --- a/setup.py +++ b/setup.py @@ -2,8 +2,7 @@ import re from pathlib import Path -from setuptools import find_packages -from setuptools import setup +from setuptools import find_packages, setup def read(*names, **kwargs): @@ -62,8 +61,11 @@ def read(*names, **kwargs): ], python_requires=">=3.8", install_requires=[ - "click", - # eg: "aspectlib==1.1.1", "six>=1.7", + "click==8.1.7", + "sqlglot==18.3.0", + "dbt-artifacts-parser==0.5.1", + "configtree==0.6", + "tabulate==0.9.0", ], extras_require={ # eg: @@ -72,7 +74,7 @@ def read(*names, **kwargs): }, entry_points={ "console_scripts": [ - "datapilot = datapilot.cli:main", + "datapilot = datapilot.cli.main:datapilot", ] }, ) diff --git a/src/datapilot/__main__.py b/src/datapilot/__main__.py index b9bba99b..dc0c0781 100644 --- a/src/datapilot/__main__.py +++ b/src/datapilot/__main__.py @@ -8,7 +8,7 @@ - https://docs.python.org/2/using/cmdline.html#cmdoption-m - https://docs.python.org/3/using/cmdline.html#cmdoption-m """ -from datapilot.cli import main +from datapilot.cli.main import datapilot if __name__ == "__main__": - main() + datapilot() diff --git a/src/datapilot/cli.py b/src/datapilot/cli.py deleted file mode 100644 index e0878d81..00000000 --- a/src/datapilot/cli.py +++ /dev/null @@ -1,23 +0,0 @@ -""" -Module that contains the command line app. - -Why does this file exist, and why not put this in __main__? - - You might be tempted to import things from __main__ later, but that will cause - problems: the code will get executed twice: - - - When you run `python -mdatapilot` python will execute - ``__main__.py`` as a script. That means there will not be any - ``datapilot.__main__`` in ``sys.modules``. - - When you import __main__ it will get executed again (as a module) because - there"s no ``datapilot.__main__`` in ``sys.modules``. - - Also see (1) from http://click.pocoo.org/5/setuptools/#setuptools-integration -""" -import click - - -@click.command() -@click.argument("names", nargs=-1) -def main(names): - click.echo(repr(names)) diff --git a/src/datapilot/cli/__init__.py b/src/datapilot/cli/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/cli/main.py b/src/datapilot/cli/main.py new file mode 100644 index 00000000..38f1d7ab --- /dev/null +++ b/src/datapilot/cli/main.py @@ -0,0 +1,12 @@ +import click + +from datapilot.core.platforms.dbt.cli import dbt + + +@click.group() +def datapilot(): + """Altimate CLI for DBT project management.""" + pass + + +datapilot.add_command(dbt) diff --git a/src/datapilot/config/__init__.py b/src/datapilot/config/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/config/config.py b/src/datapilot/config/config.py new file mode 100644 index 00000000..0e6a191d --- /dev/null +++ b/src/datapilot/config/config.py @@ -0,0 +1,14 @@ +from typing import Text + +from configtree import Loader +from configtree.tree import Tree + + +def load_config(config_file_path: Text) -> Tree: + load = Loader() + return load(config_file_path) + + +if __name__ == "__main__": + config = load_config("/Users/surya/repos/altimate_dbt_package/tests/data/config.yml") + print(config) diff --git a/src/datapilot/config/utils.py b/src/datapilot/config/utils.py new file mode 100644 index 00000000..3da157c2 --- /dev/null +++ b/src/datapilot/config/utils.py @@ -0,0 +1,17 @@ +from typing import Dict, Optional, Text + +from datapilot.core.platforms.dbt.constants import FOLDER, MODEL +from datapilot.schemas.constants import (CONFIG_FOLDER_TYPE_PATTERNS, + CONFIG_MODEL_TYPE_PATTERNS) + + +def get_regex_configuration( + config: Optional[Dict], +) -> Dict[Text, Optional[Dict[Text, Text]]]: + model_type_patterns = config.get(CONFIG_MODEL_TYPE_PATTERNS, None) + folder_type_patterns = config.get(CONFIG_MODEL_TYPE_PATTERNS, None) + return { + MODEL: model_type_patterns, + FOLDER: folder_type_patterns, + } + # Return the configured fanout threshold or the default if not specified diff --git a/src/datapilot/core/__init__.py b/src/datapilot/core/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/insights/__init__.py b/src/datapilot/core/insights/__init__.py new file mode 100644 index 00000000..5216d6d1 --- /dev/null +++ b/src/datapilot/core/insights/__init__.py @@ -0,0 +1,2 @@ +DBT = [] +SQL = [] diff --git a/src/datapilot/core/insights/base/__init__.py b/src/datapilot/core/insights/base/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/insights/base/insight.py b/src/datapilot/core/insights/base/insight.py new file mode 100644 index 00000000..217bd6a7 --- /dev/null +++ b/src/datapilot/core/insights/base/insight.py @@ -0,0 +1,24 @@ +import logging +from abc import ABC, abstractmethod +from typing import Dict, Optional, Text, Tuple + +from datapilot.core.insights.schema import InsightResponse + + +class Insight(ABC): + def __init__(self, config: Optional[Dict] = None, *args, **kwargs): + self.config = config or {} + self.args = args + self.kwargs = kwargs + self.logger = logging.getLogger(self.__class__.__name__) + + @abstractmethod + def generate(self, *args, **kwargs) -> InsightResponse: + pass + + @classmethod + def has_all_required_data(cls, **kwargs) -> Tuple[bool, Text]: + """ + return False + """ + return False, "Not implemented" diff --git a/src/datapilot/core/insights/report.py b/src/datapilot/core/insights/report.py new file mode 100644 index 00000000..9fbc8036 --- /dev/null +++ b/src/datapilot/core/insights/report.py @@ -0,0 +1,16 @@ +def generate_ci_cd_report(insights_data): + """ + Generates a CI/CD friendly report from DBT model insights. + + :param insights_data: List of DBTInsightResult objects. + """ + divider = "-" * 80 + for insight in insights_data: + print(divider) + print(f"Project: {insight.package_name}") + print(f"Model ID: {insight.model_unique_id}") + print(f"Name: {insight.metadata['model']}") + print(f"Message: {insight.message}") + print(f"Reason: {insight.reason_to_flag}") + print(f"Recommendation: {insight.recommendation}") + print(divider) diff --git a/src/datapilot/core/insights/schema.py b/src/datapilot/core/insights/schema.py new file mode 100644 index 00000000..952c8a48 --- /dev/null +++ b/src/datapilot/core/insights/schema.py @@ -0,0 +1,24 @@ +from enum import Enum +from typing import Dict, Text + +from pydantic import BaseModel + + +class Severity(Enum): + INFO = "INFO" + WARNING = "WARNING" + ERROR = "ERROR" + + +class InsightResult(BaseModel): + name: Text + type: Text + message: Text + recommendation: Text + reason_to_flag: Text + metadata: Dict + + +class InsightResponse(BaseModel): + insight: InsightResult + severity: Severity = Severity.ERROR diff --git a/src/datapilot/core/insights/sql/__init__.py b/src/datapilot/core/insights/sql/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/insights/sql/base/__init__.py b/src/datapilot/core/insights/sql/base/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/insights/sql/base/insight.py b/src/datapilot/core/insights/sql/base/insight.py new file mode 100644 index 00000000..16df908e --- /dev/null +++ b/src/datapilot/core/insights/sql/base/insight.py @@ -0,0 +1,18 @@ +from abc import abstractmethod +from typing import Optional, Text + +from datapilot.core.insights.base.insight import Insight +from datapilot.schemas.sql import Dialect + + +class SqlInsight(Insight): + NAME = "SqlInsight" + + def __init__(self, sql: Text, dialect: Optional[Dialect], *args, **kwargs): + self.sql = sql + self.dialect = dialect + super().__init__(*args, **kwargs) + + @abstractmethod + def generate(self, *args, **kwargs) -> dict: + pass diff --git a/src/datapilot/core/insights/sql/runtime/__init__.py b/src/datapilot/core/insights/sql/runtime/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/insights/sql/static/__init__.py b/src/datapilot/core/insights/sql/static/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/insights/utils.py b/src/datapilot/core/insights/utils.py new file mode 100644 index 00000000..14b1892f --- /dev/null +++ b/src/datapilot/core/insights/utils.py @@ -0,0 +1,20 @@ +from typing import Optional + +from configtree.tree import Tree + +from datapilot.core.insights.schema import Severity +from datapilot.schemas.constants import CONFIG_METRICS, CONFIG_SEVERITY + + +def get_severity( + config: Optional[Tree], + alias: str, + default_severity: Severity, +): + if config is None: + return default_severity + + insights = config.get(CONFIG_METRICS, {}) + metric = insights.get(alias, {}) + severity = metric.get(CONFIG_SEVERITY, default_severity) + return severity diff --git a/src/datapilot/core/platforms/__init__.py b/src/datapilot/core/platforms/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/platforms/dbt/__init__.py b/src/datapilot/core/platforms/dbt/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/platforms/dbt/cli/__init__.py b/src/datapilot/core/platforms/dbt/cli/__init__.py new file mode 100644 index 00000000..3559e672 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/cli/__init__.py @@ -0,0 +1 @@ +from .cli import dbt diff --git a/src/datapilot/core/platforms/dbt/cli/cli.py b/src/datapilot/core/platforms/dbt/cli/cli.py new file mode 100644 index 00000000..a095f114 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/cli/cli.py @@ -0,0 +1,66 @@ +import logging + +import click + +from datapilot.config.config import load_config +from datapilot.core.platforms.dbt.constants import MODEL, PROJECT +from datapilot.core.platforms.dbt.executor import DBTInsightGenerator +from datapilot.core.platforms.dbt.formatting import ( + generate_model_insights_table, generate_project_insights_table) +from datapilot.utils.formatting.utils import tabulate_data + +logging.basicConfig(level=logging.INFO) + + +# New dbt group +@click.group() +def dbt(): + """DBT specific commands.""" + pass + + +@dbt.command("project-health") +@click.option( + "--manifest-path", + required=True, + help="Path to the DBT manifest file", +) +@click.option( + "--catalog-path", + required=False, + help="Path to the DBT catalog file", +) +@click.option( + "--config-path", + required=False, + help="Path to the DBT config file", +) +def project_health(manifest_path, catalog_path, config_path=None): + """ + Validate the DBT project's configuration and structure. + :param manifest_path: Path to the DBT manifest file. + """ + config = None + if config_path: + config = load_config(config_path) + insight_generator = DBTInsightGenerator(manifest_path, catalog_path=catalog_path, config=config) + reports = insight_generator.run() + + package_insights = reports[PROJECT] + model_insights = reports[MODEL] + model_report = generate_model_insights_table(model_insights) + if len(model_report) > 0: + click.echo("--" * 50) + click.echo("Model Insights") + click.echo("--" * 50) + for model_id, report in model_report.items(): + click.echo(f"Model: {model_id}") + click.echo(f"File path: {report['path']}") + click.echo(tabulate_data(report["table"], headers="keys")) + click.echo("\n") + + project_report = generate_project_insights_table(package_insights) + click.echo("--" * 50) + click.echo("Project Insights") + click.echo("--" * 50) + click.echo(tabulate_data(project_report, headers="keys")) diff --git a/src/datapilot/core/platforms/dbt/constants.py b/src/datapilot/core/platforms/dbt/constants.py new file mode 100644 index 00000000..5357b66d --- /dev/null +++ b/src/datapilot/core/platforms/dbt/constants.py @@ -0,0 +1,34 @@ +SEED = "seed" +MACRO = "macro" +TEST = "test" +MODEL = "model" +SOURCE = "source" + + +PROJECT = "project" +SQL = "sql" + +# Model Types +MART: str = "mart" +STAGING = "staging" +INTERMEDIATE = "intermediate" +BASE = "base" +OTHER = "other" + +# MATERIALIZATION +TABLE = "table" +INCREMENTAL = "incremental" +VIEW = "view" +EPHEMERAL = "ephemeral" + + +MATERIALIZED = [TABLE, INCREMENTAL] +NON_MATERIALIZED = [VIEW, EPHEMERAL] + + +GENERIC = "generic" +SINGULAR = "singular" +OTHER_TEST_NODE = "other_test_node" + + +FOLDER = "folder" diff --git a/src/datapilot/core/platforms/dbt/exceptions.py b/src/datapilot/core/platforms/dbt/exceptions.py new file mode 100644 index 00000000..daecd602 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/exceptions.py @@ -0,0 +1,2 @@ +class AltimateInvalidManifestError(Exception): + pass diff --git a/src/datapilot/core/platforms/dbt/executor.py b/src/datapilot/core/platforms/dbt/executor.py new file mode 100644 index 00000000..46364cae --- /dev/null +++ b/src/datapilot/core/platforms/dbt/executor.py @@ -0,0 +1,114 @@ +import logging +# from src.utils.formatting.utils import generate_model_insights_table +from typing import Optional, Text + +from configtree.tree import Tree + +from datapilot.config.config import load_config +from datapilot.core.platforms.dbt.constants import MODEL, PROJECT +from datapilot.core.platforms.dbt.factory import DBTFactory +from datapilot.core.platforms.dbt.formatting import ( + generate_model_insights_table, generate_project_insights_table) +from datapilot.core.platforms.dbt.insights import INSIGHTS +from datapilot.core.platforms.dbt.utils import load_catalog, load_manifest +from datapilot.utils.formatting.utils import (RED, YELLOW, color_text, + tabulate_data) + + +class DBTInsightGenerator: + def __init__( + self, + manifest_path: Text, + catalog_path: Optional[Text] = None, + run_results_path: Optional[Text] = None, + env: Optional[Text] = None, + config: Optional[Tree] = None, + target: Text = "dev", + ): + self.manifest_path = manifest_path + self.catalog_path = catalog_path + self.run_results_path = run_results_path + self.target = target + self.env = env + self.config = config or Tree() + manifest = load_manifest(self.manifest_path) + + self.manifest_wrapper = DBTFactory.get_manifest_wrapper(manifest) + self.manifest_present = True + self.catalog_present = False + self.catalog_wrapper = None + + if catalog_path: + catalog = load_catalog(self.catalog_path) + self.catalog_wrapper = DBTFactory.get_catalog_wrapper(catalog) + self.catalog_present = True + + self.run_results_present = False + self.logger = logging.getLogger("dbt-insight-generator") + + self.nodes = self.manifest_wrapper.get_nodes() + self.sources = self.manifest_wrapper.get_sources() + self.exposures = self.manifest_wrapper.get_exposures() + self.children_map = self.manifest_wrapper.parent_to_child_map(self.nodes) + self.tests = self.manifest_wrapper.get_tests() + self.project_name = self.manifest_wrapper.get_package() + # TODO - add catalog and run results wrappers + + def _check_if_skipped(self, insight): + if self.config.get("disabled"): + if insight.ALIAS in self.config.get("disabled", []): + return True + return False + + def run(self): + reports = { + MODEL: {}, + PROJECT: [], + } + for insight_class in INSIGHTS: + # TODO: Skip insight based on config + + run_insight, message = insight_class.has_all_required_data( + has_manifest=self.manifest_present, + has_catalog=self.catalog_present, + has_run_results=self.run_results_present, + ) + + if run_insight: + self.logger.info(f"Running insight {insight_class.NAME}") + insight = insight_class( + manifest_wrapper=self.manifest_wrapper, + catalog_wrapper=self.catalog_wrapper, + nodes=self.nodes, + sources=self.sources, + exposures=self.exposures, + children_map=self.children_map, + tests=self.tests, + project_name=self.project_name, + config=self.config, + ) + if self._check_if_skipped(insight): + self.logger.info( + color_text( + f"Skipping insight {insight_class.NAME} as it is not enabled in config", + YELLOW, + ) + ) + continue + insights = insight.generate() + num_insights = len(insights) + text = f"Found {num_insights} insights for {insight_class.NAME}" + if num_insights > 0: + self.logger.info(color_text(text, RED)) + else: + self.logger.info(f"No insights found for {insight_class.NAME}") + + for insight in insights: + if insight.insight_level == MODEL: + reports[MODEL].setdefault(insight.unique_id, []).append(insight) + else: + reports[PROJECT].append(insight) + else: + self.logger.info(color_text(f"Skipping insight {insight_class.NAME} as {message}", YELLOW)) + + return reports diff --git a/src/datapilot/core/platforms/dbt/factory.py b/src/datapilot/core/platforms/dbt/factory.py new file mode 100644 index 00000000..846d4f9a --- /dev/null +++ b/src/datapilot/core/platforms/dbt/factory.py @@ -0,0 +1,23 @@ +from dbt_artifacts_parser.parsers.catalog.catalog_v1 import CatalogV1 +from dbt_artifacts_parser.parsers.manifest.manifest_v11 import ManifestV11 + +from datapilot.core.platforms.dbt.schemas.manifest import Catalog, Manifest +from datapilot.core.platforms.dbt.wrappers.catalog.v1.wrapper import \ + CatalogV1Wrapper +from datapilot.core.platforms.dbt.wrappers.manifest.v11.wrapper import \ + ManifestV11Wrapper +from datapilot.exceptions.exceptions import AltimateNotSupportedError + + +class DBTFactory: + @classmethod + def get_manifest_wrapper(cls, manifest: Manifest): + if isinstance(manifest, ManifestV11): + return ManifestV11Wrapper(manifest) + raise AltimateNotSupportedError(f"Manifest version {manifest.metadata.dbt_schema_version} not supported") + + @classmethod + def get_catalog_wrapper(cls, catalog: Catalog): + if isinstance(catalog, CatalogV1): + return CatalogV1Wrapper(catalog) + raise AltimateNotSupportedError(f"Catalog version {catalog.metadata.dbt_schema_version} not supported") diff --git a/src/datapilot/core/platforms/dbt/formatting.py b/src/datapilot/core/platforms/dbt/formatting.py new file mode 100644 index 00000000..c1abd247 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/formatting.py @@ -0,0 +1,43 @@ +from typing import Dict, List, Text + +from datapilot.core.insights.schema import InsightResult, Severity +from datapilot.core.platforms.dbt.insights.schema import ( + DBTModelInsightResponse, DBTProjectInsightResponse) +from datapilot.utils.formatting.utils import color_based_on_severity + + +def gen_table(insight: InsightResult, severity: Severity) -> Dict[Text, Text]: + return { + "name": insight.name, + "type": insight.type, + "level": color_based_on_severity(severity), + "message": insight.message, + "recommendation": insight.recommendation, + "reason_to_flag": insight.reason_to_flag, + } + + +def generate_model_insights_table(model_insights: Dict[Text, List[DBTModelInsightResponse]]): + results = {} + + for model_id, insights in model_insights.items(): + for insight in insights: + if model_id not in results: + results[model_id] = { + "package_name": insight.package_name, + "unique_id": insight.unique_id, + "path": insight.original_file_path, + "table": [], + } + + results[model_id]["table"].append(gen_table(insight.insight, insight.severity)) + return results + + +def generate_project_insights_table(project_insights: List[DBTProjectInsightResponse]): + results = [] + + for project_insight in project_insights: + for insight in project_insight.insights: + results.append(gen_table(insight, project_insight.severity)) + return results diff --git a/src/datapilot/core/platforms/dbt/insights/__init__.py b/src/datapilot/core/platforms/dbt/insights/__init__.py new file mode 100644 index 00000000..02006a08 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/__init__.py @@ -0,0 +1,45 @@ +from datapilot.core.platforms.dbt.insights.dbt_test import ( + DBTTestCoverage, MissingPrimaryKeyTests) +from datapilot.core.platforms.dbt.insights.governance import ( + DBTDocumentationStaleColumns, DBTExposureDependentOnPrivateModels, + DBTMissingDocumentation, DBTPublicModelWithoutContracts, + DBTUndocumentedPublicModels) +from datapilot.core.platforms.dbt.insights.modelling import ( + DBTDirectJoinSource, DBTDownstreamModelsDependentOnSource, + DBTDuplicateSources, DBTHardCodedReferences, DBTModelFanout, + DBTModelsMultipleSourcesJoined, DBTRejoiningOfUpstreamConcepts, + DBTRootModel, DBTSourceFanout, DBTStagingModelsDependentOnDownstreamModels, + DBTStagingModelsDependentOnStagingModels, DBTUnusedSources) +from datapilot.core.platforms.dbt.insights.performance import ( + DBTChainViewLinking, DBTExposureParentMaterialization) +from datapilot.core.platforms.dbt.insights.structure import ( + DBTModelDirectoryStructure, DBTModelNamingConvention, + DBTSourceDirectoryStructure, DBTTestDirectoryStructure) + +INSIGHTS = [ + DBTDirectJoinSource, + DBTDownstreamModelsDependentOnSource, + DBTDuplicateSources, + DBTModelFanout, + DBTRootModel, + DBTSourceFanout, + DBTStagingModelsDependentOnDownstreamModels, + DBTStagingModelsDependentOnStagingModels, + DBTUnusedSources, + DBTModelsMultipleSourcesJoined, + DBTHardCodedReferences, + DBTRejoiningOfUpstreamConcepts, + DBTExposureDependentOnPrivateModels, + DBTUndocumentedPublicModels, + DBTPublicModelWithoutContracts, + DBTChainViewLinking, + DBTExposureParentMaterialization, + DBTMissingDocumentation, + DBTDocumentationStaleColumns, + MissingPrimaryKeyTests, + DBTTestCoverage, + DBTModelDirectoryStructure, + DBTModelNamingConvention, + DBTSourceDirectoryStructure, + DBTTestDirectoryStructure, +] diff --git a/src/datapilot/core/platforms/dbt/insights/base.py b/src/datapilot/core/platforms/dbt/insights/base.py new file mode 100644 index 00000000..a54410c0 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/base.py @@ -0,0 +1,86 @@ +from abc import abstractmethod +from typing import Dict, List, Text, Union + +from datapilot.core.insights.base.insight import Insight +from datapilot.core.insights.schema import Severity +from datapilot.core.platforms.dbt.constants import NON_MATERIALIZED +from datapilot.core.platforms.dbt.schemas.manifest import ( + AltimateManifestExposureNode, AltimateManifestNode, + AltimateManifestSourceNode, AltimateManifestTestNode, AltimateResourceType) +from datapilot.core.platforms.dbt.wrappers.manifest.wrapper import \ + BaseManifestWrapper + + +class DBTInsight(Insight): + DEFAULT_SEVERITY = Severity.ERROR + + def __init__( + self, + manifest_wrapper: BaseManifestWrapper, + nodes: Dict[Text, AltimateManifestNode], + sources: Dict[Text, AltimateManifestSourceNode], + exposures: Dict[Text, AltimateManifestExposureNode], + tests: Dict[Text, AltimateManifestTestNode], + children_map: Dict[Text, List[Text]], + project_name: Text, + *args, + **kwargs, + ): + self.manifest = manifest_wrapper + self.nodes = nodes + self.sources = sources + self.exposures = exposures + self.tests = tests + self.children_map = children_map + self.project_name = project_name + super().__init__(*args, **kwargs) + + @abstractmethod + def generate(self, *args, **kwargs) -> dict: + pass + + def check_part_of_project(self, node_project_name: Text) -> bool: + return node_project_name == self.project_name + + def get_node( + self, node_id: Text + ) -> Union[AltimateManifestNode, AltimateManifestSourceNode, AltimateManifestExposureNode, AltimateManifestTestNode,]: + if node_id in self.nodes: + return self.nodes[node_id] + elif node_id in self.sources: + return self.sources[node_id] + elif node_id in self.exposures: + return self.exposures[node_id] + elif node_id in self.tests: + return self.tests[node_id] + else: + raise ValueError(f"Node {node_id} not found in manifest.") + + def find_long_chains(self, min_chain_length=4): + """ + Find chains of nodes with 'materialized' set to 'view' or 'ephemeral' of a given minimum length. + + :param nodes: Dictionary of nodes where key is node_id and value is a node with 'depends_on' and 'materialized'. + :param min_chain_length: Minimum length of the chain to be found. + :return: A list of chains, where each chain is a list of node IDs. + """ + + def is_not_materialized(node: Union[AltimateManifestNode, AltimateManifestSourceNode]) -> bool: + if node.resource_type == AltimateResourceType.source: + return False + return node.config.materialized in NON_MATERIALIZED + + def build_chain(node_id, current_chain): + if len(current_chain) >= min_chain_length: + long_chains.append(current_chain) + return + for parent_id in self.get_node(node_id).depends_on.nodes: + if is_not_materialized(self.get_node(parent_id)): + build_chain(parent_id, current_chain + [parent_id]) + + long_chains = [] + for node_id, node in self.nodes.items(): + if is_not_materialized(node): + build_chain(node_id, [node_id]) + + return long_chains diff --git a/src/datapilot/core/platforms/dbt/insights/dbt_test/__init__.py b/src/datapilot/core/platforms/dbt/insights/dbt_test/__init__.py new file mode 100644 index 00000000..9824cddb --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/dbt_test/__init__.py @@ -0,0 +1,2 @@ +from .missing_primary_key_tests import MissingPrimaryKeyTests +from .test_coverage import DBTTestCoverage diff --git a/src/datapilot/core/platforms/dbt/insights/dbt_test/base.py b/src/datapilot/core/platforms/dbt/insights/dbt_test/base.py new file mode 100644 index 00000000..b0ca4ba5 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/dbt_test/base.py @@ -0,0 +1,23 @@ +from abc import abstractmethod +from typing import Tuple + +from datapilot.core.platforms.dbt.insights.base import DBTInsight + + +class DBTTestInsight(DBTInsight): + TYPE = "Test" + + @abstractmethod + def generate(self, *args, **kwargs) -> dict: + pass + + @classmethod + def has_all_required_data(cls, has_manifest: bool, **kwargs) -> Tuple[bool, str]: + """ + Check if all required data is available for the insight to run. + :param has_manifest: A boolean indicating if manifest is available. + :return: A boolean indicating if all required data is available. + """ + if not has_manifest: + return False, "manifest is required for insight to run." + return True, "" diff --git a/src/datapilot/core/platforms/dbt/insights/dbt_test/missing_primary_key_tests.py b/src/datapilot/core/platforms/dbt/insights/dbt_test/missing_primary_key_tests.py new file mode 100644 index 00000000..b6ab8934 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/dbt_test/missing_primary_key_tests.py @@ -0,0 +1,129 @@ +from typing import Dict, List, Optional, Text + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.constants import GENERIC +from datapilot.core.platforms.dbt.insights.dbt_test.base import DBTTestInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType + + +class MissingPrimaryKeyTests(DBTTestInsight): + """ + This class identifies DBT models that are missing primary key tests. + Primary key tests are essential for ensuring data integrity in DBT models. + This class generates insights for each model that lacks proper primary key tests. + """ + + _ALL_TESTS_KEY = "_all_tests" + NOT_NULL = "not_null" + UNIQUE = "unique" + UNIQUE_COMBINATION_OF_COLUMNS = "unique_combination_of_columns" + NAME = "Missing Primary Key Tests" + ALIAS = "missing_primary_key_tests" + DESCRIPTION = ( + "Identifies dbt models in the project that lack primary key tests. Tests in DBT are essential " + "for ensuring the correctness of models and resources. Models without primary key tests may be at risk " + "of data integrity issues, impacting project reliability and scalability." + ) + REASON_TO_FLAG = ( + "dbt tests play a crucial role in asserting data correctness. The absence of primary key tests can increase " + "the risk of data integrity issues, affecting project reliability and scalability." + ) + FAILURE_MESSAGE = ( + "dbt model `{model_unique_id}` does not have a primary key test. " "This omission may lead to data integrity challenges." + ) + RECOMMENDATION = ( + "To address this, apply a uniqueness test and a not-null test to the column representing the model's grain. " + "For models with unique combinations of columns, consider adding a surrogate key and " + "applying these tests to that column. You can refer to dbt_utils for a surrogate_key macro" + " and unique_combination_of_columns test." + ) + + def _build_failure_result(self, model_unique_id: str) -> DBTInsightResult: + """ + Constructs a failure result for a given model. + + :param model_unique_id: Unique ID of the model being evaluated. + :return: An instance of DBTInsightResult containing failure details. + """ + self.logger.debug(f"Building failure result for model {model_unique_id}") + failure = self.FAILURE_MESSAGE.format(model_unique_id=model_unique_id) + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure, + recommendation=self.RECOMMENDATION, + reason_to_flag=self.REASON_TO_FLAG, + metadata={"model_unique_id": model_unique_id}, + ) + + def _has_primary_key_test(self, column_tests: Optional[Dict[Text, List]]) -> bool: + """ + Checks if the given column tests include a primary key test. + + :param column_tests: Dictionary of column tests. + :return: True if primary key test exists, False otherwise. + """ + self.logger.debug("Checking for primary key tests") + if not column_tests: + return False + + if self.UNIQUE_COMBINATION_OF_COLUMNS in column_tests.get(self._ALL_TESTS_KEY, []): + return True + + column_tests.pop(self._ALL_TESTS_KEY, None) + + for column, tests in column_tests.items(): + if self.NOT_NULL in tests and self.UNIQUE in tests: + return True + + return False + + def _get_nodes_which_need_tests(self) -> List[str]: + return [ + node_id + for node_id, node in self.nodes.items() + if self.check_part_of_project(node.package_name) and node.resource_type == AltimateResourceType.model + ] + + def _get_nodes_with_tests(self, tests) -> Dict[str, Dict[str, List]]: + nodes_with_tests = {} + for test in tests.values(): + for node_id in test.depends_on.nodes or []: + column = test.test_metadata.kwargs.get("column_name") + key = column if column else self._ALL_TESTS_KEY + nodes_with_tests.setdefault(node_id, {}).setdefault(key, []).append(test.test_metadata.name) + return nodes_with_tests + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + """ + Generates insights for each DBT model in the project. + + :return: A list of DBTModelInsightResponse objects with insights for each model. + """ + self.logger.debug("Generating insights for DBT models") + tests = self.manifest.get_tests([GENERIC]) + + nodes_which_need_tests = self._get_nodes_which_need_tests() + + nodes_which_have_test = self._get_nodes_with_tests(tests) + + insights = [] + for node_id in nodes_which_need_tests: + if not self._has_primary_key_test(nodes_which_have_test.get(node_id)): + node = self.get_node(node_id) + self.logger.debug(f"Adding insight for model {node_id}") + insights.append( + DBTModelInsightResponse( + unique_id=node_id, + package_name=node.package_name, + path=node.original_file_path, + original_file_path=node.original_file_path, + insight=self._build_failure_result(node_id), + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + self.logger.debug("Completed generating insights") + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/dbt_test/test_coverage.py b/src/datapilot/core/platforms/dbt/insights/dbt_test/test_coverage.py new file mode 100644 index 00000000..091c8435 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/dbt_test/test_coverage.py @@ -0,0 +1,111 @@ +from typing import List + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.constants import SINGULAR +from datapilot.core.platforms.dbt.insights.dbt_test.base import DBTTestInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTProjectInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.schemas.constants import CONFIG_METRICS + + +class DBTTestCoverage(DBTTestInsight): + """ + This class identifies DBT models with test coverage below a specified threshold. + It aims to ensure that a minimum percentage of tests are applied to each model to maintain data integrity. + """ + + NAME = "Low Test Coverage in dbt Models" + ALIAS = "dbt_low_test_coverage" + DESCRIPTION = ( + "Identifies dbt models in the project with low test coverage, where the test coverage percentage falls below " + "the minimum required threshold. Adequate test coverage is essential to maintain data integrity" + " and ensure the accuracy of data transformations." + ) + REASON_TO_FLAG = ( + "dbt models should have a minimum test coverage percentage to ensure the reliability and accuracy " + "of data transformations. Low test coverage can lead to data quality issues." + ) + FAILURE_MESSAGE = ( + "The test coverage {coverage_percent}% is below the minimum threshold" + " of {min_coverage_percent}%. Insufficient test coverage can impact data integrity and transformation accuracy." + ) + RECOMMENDATION = ( + "To address this issue, review and increase the number and variety of tests applied to your model to " + "improve its test coverage. Consider adding different types of tests such as uniqueness, not_null, " + "and referential integrity tests to ensure data quality and accuracy." + ) + MIN_COVERAGE_PERCENT = 100 + MIN_COVERAGE_PERCENT_STR = "min_test_coverage_percent" + + def _build_failure_result(self, coverage: float, min_coverage=MIN_COVERAGE_PERCENT) -> DBTInsightResult: + """ + Constructs a failure result for a given model with low test coverage. + :param coverage: The calculated test coverage percentage for the model. + :param min_coverage: The minimum required test coverage percentage. + :return: An instance of DBTInsightResult containing failure details. + """ + self.logger.debug(f"CALCULATED COVERAGE: {coverage}") + failure = self.FAILURE_MESSAGE.format(min_coverage_percent=min_coverage, coverage_percent=coverage) + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure, + recommendation=self.RECOMMENDATION, + reason_to_flag=self.REASON_TO_FLAG, + metadata={"min_coverage_percent": min_coverage, "coverage": coverage}, + ) + + def _calculate_coverage(self) -> float: + """ + :return: Test coverage percentage for the model. + """ + num_models = len( + [ + node.unique_id + for node in self.nodes.values() + if node.resource_type == AltimateResourceType.model and self.check_part_of_project(node.package_name) + ] + ) + + models_with_tests = set() + for test in self.tests.values(): + if test.test_type == SINGULAR: + return 100 + if test.package_name == self.project_name: + models_with_tests = models_with_tests.union(set(test.depends_on.nodes) if test.depends_on else set()) + + return round((len(models_with_tests) / num_models) * 100) if num_models > 0 else 0 + + def _get_min_coverage_percent(self) -> int: + """ + :return: The minimum required test coverage percentage. + """ + metrics_config = self.config.get(CONFIG_METRICS, {}) + metric_config = metrics_config.get(self.ALIAS, {}) + self.logger.debug(f"METRIC CONFIG: {metric_config}") + # Return the configured fanout threshold or the default if not specified + return metric_config.get(self.MIN_COVERAGE_PERCENT_STR, self.MIN_COVERAGE_PERCENT) + + def generate(self, *args, **kwargs) -> List[DBTProjectInsightResponse]: + """ + Generates insights for each DBT model in the project, focusing on test coverage. + + :return: A list of DBTModelInsightResponse objects with insights for each model. + """ + self.logger.debug("Generating test coverage insights for DBT models") + min_coverage = self._get_min_coverage_percent() + coverage = self._calculate_coverage() + + insights = [] + if coverage < min_coverage: + insights.append( + DBTProjectInsightResponse( + package_name=self.project_name, + insights=[self._build_failure_result(coverage, min_coverage)], + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + self.logger.debug("Completed generating test coverage insights") + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/governance/__init__.py b/src/datapilot/core/platforms/dbt/insights/governance/__init__.py new file mode 100644 index 00000000..190b530b --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/governance/__init__.py @@ -0,0 +1,6 @@ +from .documentation_on_stale_columns import DBTDocumentationStaleColumns +from .exposures_dependent_on_private_models import \ + DBTExposureDependentOnPrivateModels +from .public_models_without_contracts import DBTPublicModelWithoutContracts +from .undocumented_columns import DBTMissingDocumentation +from .undocumented_public_models import DBTUndocumentedPublicModels diff --git a/src/datapilot/core/platforms/dbt/insights/governance/base.py b/src/datapilot/core/platforms/dbt/insights/governance/base.py new file mode 100644 index 00000000..23bea9b6 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/governance/base.py @@ -0,0 +1,23 @@ +from abc import abstractmethod +from typing import Tuple + +from datapilot.core.platforms.dbt.insights.base import DBTInsight + + +class DBTGovernanceInsight(DBTInsight): + TYPE = "governance" + + @abstractmethod + def generate(self, *args, **kwargs) -> dict: + pass + + @classmethod + def has_all_required_data(cls, has_manifest: bool, **kwargs) -> Tuple[bool, str]: + """ + Check if all required data is available for the insight to run. + :param has_manifest: A boolean indicating if manifest is available. + :return: A boolean indicating if all required data is available. + """ + if not has_manifest: + return False, "manifest is required for insight to run." + return True, "" diff --git a/src/datapilot/core/platforms/dbt/insights/governance/documentation_on_stale_columns.py b/src/datapilot/core/platforms/dbt/insights/governance/documentation_on_stale_columns.py new file mode 100644 index 00000000..4c31a563 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/governance/documentation_on_stale_columns.py @@ -0,0 +1,123 @@ +from typing import List, Text, Tuple + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.insights.governance.base import \ + DBTGovernanceInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.core.platforms.dbt.wrappers.catalog.wrapper import \ + BaseCatalogWrapper +from datapilot.utils.formatting.utils import numbered_list + + +class DBTDocumentationStaleColumns(DBTGovernanceInsight): + """ + DBTDocumentationStaleColumns identifies columns that have been documented but are no longer present in the model. + """ + + NAME = "Documentation of Stale Columns" + ALIAS = "documentation_on_stale_columns" + DESCRIPTION = ( + "Checks for columns that are documented in the dbt project but have been removed from their respective models. " + "Maintaining accurate documentation is crucial for clarity and consistency, especially in collaborative " + "environments." + ) + REASON_TO_FLAG = ( + "A column has been documented but is no longer present in the model/database. " + "This discrepancy can cause confusion and mislead users of the dbt project." + ) + FAILURE_MESSAGE = ( + "The following documented columns are no longer present in the model `{model_unique_id}`:\n{stale_columns}. " + "This inconsistency can lead to confusion regarding the model's current structure." + ) + RECOMMENDATION = ( + "Review and update the documentation for model `{model_unique_id}`. Remove documentation entries for columns " + "that are no longer present to maintain clarity and accuracy in the project documentation." + ) + + def __init__(self, catalog_wrapper: BaseCatalogWrapper, *args, **kwargs): + self.catalog = catalog_wrapper + super().__init__(*args, **kwargs) + + def _build_failure_result(self, model_unique_id: str, columns: List[str]) -> DBTInsightResult: + """ + Build failure result for the insight if a model is a root model with 0 direct parents. + + :param model_unique_id: Unique ID of the current model being evaluated. + :param columns: List of columns that are documented but no longer present in the model. + :return: An instance of InsightResult containing failure message and recommendation. + """ + self.logger.debug(f"Building failure result for model {model_unique_id} with stale columns {columns}") + + failure = self.FAILURE_MESSAGE.format( + stale_columns=numbered_list(columns), + model_unique_id=model_unique_id, + ) + + recommendation = self.RECOMMENDATION.format(model_unique_id=model_unique_id) + + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure, + recommendation=recommendation, + reason_to_flag=self.REASON_TO_FLAG, + metadata={"stale_columns": columns, "model_unique_id": model_unique_id}, + ) + + def _get_columns_documented(self, node_id) -> List[Text]: + """ + Get the list of columns that are documented for a given node. + :param node_id: The unique ID of the node. + :return: A list of column names. + """ + columns = [] + for column_name, column_node in self.get_node(node_id).columns.items(): + if column_node.description: + columns.append(column_name.lower()) + return columns + + def _get_columns_in_model(self, node_id) -> List[Text]: + if node_id not in self.catalog.get_schema(): + return [] + return [k.lower() for k in self.catalog.get_schema()[node_id].keys()] + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + """ + Generate a list of InsightResponse objects for each model in the DBT project, + identifying root models with 0 direct parents. + :return: A list of InsightResponse objects. + """ + insights = [] + for node_id, node in self.nodes.items(): + if node.resource_type == AltimateResourceType.model: + columns_documented = self._get_columns_documented(node_id) + db_columns = self._get_columns_in_model(node_id) + columns_stale = list(set(columns_documented) - set(db_columns)) + if columns_stale: + insights.append( + DBTModelInsightResponse( + unique_id=node_id, + package_name=node.package_name, + path=node.original_file_path, + original_file_path=node.original_file_path, + insight=self._build_failure_result(node_id, columns_stale), + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + return insights + + @classmethod + def has_all_required_data(cls, has_manifest: bool, has_catalog: bool, **kwargs) -> Tuple[bool, Text]: + """ + return False + """ + if not has_manifest: + return False, "manifest is required for insight to run." + + if not has_catalog: + return False, "catalog is required for insight to run." + + return True, "" diff --git a/src/datapilot/core/platforms/dbt/insights/governance/exposures_dependent_on_private_models.py b/src/datapilot/core/platforms/dbt/insights/governance/exposures_dependent_on_private_models.py new file mode 100644 index 00000000..23ea6613 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/governance/exposures_dependent_on_private_models.py @@ -0,0 +1,92 @@ +from typing import List + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.insights.governance.base import \ + DBTGovernanceInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateAccess +from datapilot.utils.formatting.utils import numbered_list + + +class DBTExposureDependentOnPrivateModels(DBTGovernanceInsight): + """ + DBTExposureDependentOnPrivateModels identifies exposures that are dependent on private models. + """ + + NAME = "Exposures Dependent on Private Models" + ALIAS = "exposures_dependent_on_private_models" + DESCRIPTION = ( + "Detects if exposures in the dbt project are dependent on private models. Exposures should ideally depend " + "on public, well-documented, and contracted models that represent trusted data sources " + "for downstream consumption." + ) + REASON_TO_FLAG = ( + "Exposures illustrate how and where data is consumed in downstream tools. These tools should utilize " + "data from public, trusted, and contracted sources to ensure data reliability and integrity." + ) + FAILURE_MESSAGE = ( + "Exposure `{exposure_unique_id}` is dependent on private models, which may not be ideal for " + "downstream consumption:\n`{private_models}`." + ) + RECOMMENDATION = ( + "Consider revising the yml file to ensure that the models your exposures depend on are fully " + "exposed and public. While this rule flags non-public models, it is also recommended to document" + " and formalize contracts for these public models for best practices." + ) + + def _build_failure_result(self, exposure_unique_id: str, private_models: List[str]) -> DBTInsightResult: + """ + Build failure result for the insight if a model is a root model with 0 direct parents. + + :param exposure_unique_id: Unique ID of the current model being evaluated. + :return: An instance of InsightResult containing failure message and recommendation. + """ + self.logger.debug(f"Building failure result exposure {exposure_unique_id} depends on private models {private_models}") + + failure = self.FAILURE_MESSAGE.format( + exposure_unique_id=exposure_unique_id, + private_models=numbered_list(private_models), + ) + + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure, + recommendation=self.RECOMMENDATION, + reason_to_flag=self.REASON_TO_FLAG, + metadata={"exposure": exposure_unique_id, "private_models": private_models}, + ) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + """ + Generate a list of InsightResponse objects for each model in the dbt project, + identifying root models with 0 direct parents. + :return: A list of InsightResponse objects. + """ + if len(self.exposures) == 0: + self.logger.debug(f"No exposures found in project {self.project_name}") + return [] + insights = [] + for exposure_id, exposure in self.exposures.items(): + self.logger.debug("Checking exposure {}".format(exposure_id)) + private_models = [] + for dependency_id in exposure.depends_on.nodes: + dependency_node = self.get_node(dependency_id) + if dependency_node.access == AltimateAccess.private: + private_models.append(dependency_id) + + if private_models: + insight_result = self._build_failure_result(exposure_unique_id=exposure_id, private_models=private_models) + insights.append( + DBTModelInsightResponse( + unique_id=exposure_id, + package_name=exposure.package_name, + path=exposure.original_file_path, + original_file_path=exposure.original_file_path, + insight=insight_result, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/governance/public_models_without_contracts.py b/src/datapilot/core/platforms/dbt/insights/governance/public_models_without_contracts.py new file mode 100644 index 00000000..4e903686 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/governance/public_models_without_contracts.py @@ -0,0 +1,91 @@ +from typing import List + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.insights.governance.base import \ + DBTGovernanceInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import ( + AltimateAccess, AltimateResourceType) + + +class DBTPublicModelWithoutContracts(DBTGovernanceInsight): + """ + DBTUndocumentedPublicModels identifies public models that are not documented. + """ + + NAME = "Public Models Without Contracts" + ALIAS = "public_models_without_contracts" + DESCRIPTION = ( + "Identifies models in the dbt project that have public access, meaning they can be consumed by" + " any downstream consumer. However, these public models should have contracts to provide guarantees " + "regarding data types and columns." + ) + REASON_TO_FLAG = ( + "Public models are accessible to all downstream consumers, making it crucial to have clear " + "contracts that specify data types and columns. This ensures consistency and predictability " + "in data consumption." + ) + FAILURE_MESSAGE = ( + "Model `{model_unique_id}` is marked as public but does not have a contract. " + "This can lead to ambiguity regarding data types and columns, impacting downstream consumers." + ) + RECOMMENDATION = ( + "Enhance the model `{model_unique_id}` by adding clear contract entries for columns along " + "with their data types. Contracts provide essential documentation and guarantees for downstream consumers." + ) + + def _build_failure_result( + self, + model_unique_id: str, + ) -> DBTInsightResult: + """ + Build failure result for the insight if a model is a root model with 0 direct parents. + + :param model_unique_id: Unique ID of the current model being evaluated. + :return: An instance of InsightResult containing failure message and recommendation. + """ + self.logger.debug(f"Building failure result model {model_unique_id} is public but not documented.") + + failure = self.FAILURE_MESSAGE.format( + model_unique_id=model_unique_id, + ) + recommendation = self.RECOMMENDATION.format( + model_unique_id=model_unique_id, + ) + + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure, + recommendation=recommendation, + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "model": model_unique_id, + }, + ) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + """ + Generate a list of InsightResponse objects for each model in the DBT project, + identifying root models with 0 direct parents. + """ + self.logger.debug("Generating insights for public models without contracts") + insights = [] + for node_id, node in self.nodes.items(): + if node.resource_type == AltimateResourceType.model and node.access == AltimateAccess.public: + if (not node.contract) or (not node.contract.enforced): + self.logger.debug(f"Found public model {node_id} without contract enforced") + insight_result = self._build_failure_result(node_id) + insights.append( + DBTModelInsightResponse( + unique_id=node_id, + package_name=node.package_name, + path=node.original_file_path, + original_file_path=node.original_file_path, + insight=insight_result, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + self.logger.debug("Finished generating insights for public models without contracts") + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/governance/undocumented_columns.py b/src/datapilot/core/platforms/dbt/insights/governance/undocumented_columns.py new file mode 100644 index 00000000..de2b8d94 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/governance/undocumented_columns.py @@ -0,0 +1,140 @@ +from typing import List, Text, Tuple + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.insights.governance.base import \ + DBTGovernanceInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.core.platforms.dbt.wrappers.catalog.wrapper import \ + BaseCatalogWrapper +from datapilot.utils.formatting.utils import numbered_list + + +class DBTMissingDocumentation(DBTGovernanceInsight): + """ + DBTDocumentationStaleColumns identifies columns that have been documented but are no longer present in the model. + """ + + NAME = "Missing Documentation" + ALIAS = "missing_documentation" + DESCRIPTION = ( + "Detects columns and models in the dbt project that lack documentation. Proper documentation is essential " + "for understanding data structures and facilitating collaboration and usage of the dbt project." + ) + REASON_TO_FLAG = ( + "Missing documentation for columns and models can lead to confusion and hinder effective data " + "modeling and analysis. It's important to document data structures comprehensively." + ) + FAILURE_MESSAGE = ( + "The following columns in the model `{model_unique_id}` are missing documentation:\n{columns}. " + "Lack of documentation can impede understanding and usage of the model." + ) + RECOMMENDATION = ( + "Enhance the documentation for the columns listed above in the model `{model_unique_id}`. " + "Documentation provides valuable context and aids in data understanding and collaboration." + ) + + def __init__(self, catalog_wrapper: BaseCatalogWrapper, *args, **kwargs): + self.catalog = catalog_wrapper + super().__init__(*args, **kwargs) + + def _build_failure_result( + self, + model_unique_id: str, + model_description_is_missing: bool, + columns: List[str], + ) -> DBTInsightResult: + """ + Build failure result for the insight if a model is a root model with 0 direct parents. + + :param model_unique_id: Unique ID of the current model being evaluated. + :param columns: List of columns that are documented but no longer present in the model. + :return: An instance of InsightResult containing failure message and recommendation. + """ + self.logger.debug(f"Building failure result for model {model_unique_id} with stale columns {columns}") + failure_message = "" + if model_description_is_missing: + failure_message += f"The model {model_unique_id} is missing a description.\n" + + if columns: + failure_message += self.FAILURE_MESSAGE.format( + columns=numbered_list(columns), + model_unique_id=model_unique_id, + ) + + recommendation = self.RECOMMENDATION.format(model_unique_id=model_unique_id) + + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure_message, + recommendation=recommendation, + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "columns": columns, + "model_unique_id": model_unique_id, + "model_description_is_missing": model_description_is_missing, + }, + ) + + def _get_columns_documented(self, node_id) -> List[Text]: + """ + Get the list of columns that are documented for a given node. + :param node_id: The unique ID of the node. + :return: A list of column names. + """ + columns = [] + for column_name, column_node in self.get_node(node_id).columns.items(): + if column_node.description: + columns.append(column_name.lower()) + return columns + + def _get_columns_in_model(self, node_id) -> List[Text]: + if node_id not in self.catalog.get_schema(): + return [] + return [k.lower() for k in self.catalog.get_schema()[node_id].keys()] + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + """ + Generate a list of InsightResponse objects for each model in the DBT project, + identifying root models with 0 direct parents. + :return: A list of InsightResponse objects. + """ + insights = [] + for node_id, node in self.nodes.items(): + if node.resource_type == AltimateResourceType.model: + model_description_is_missing = not node.description + columns_documented = self._get_columns_documented(node_id) + db_columns = self._get_columns_in_model(node_id) + columns_missing_documentation = list(set(db_columns) - set(columns_documented)) + if columns_missing_documentation: + insights.append( + DBTModelInsightResponse( + unique_id=node_id, + package_name=node.package_name, + path=node.original_file_path, + original_file_path=node.original_file_path, + insight=self._build_failure_result( + node_id, + model_description_is_missing, + columns_missing_documentation, + ), + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + return insights + + @classmethod + def has_all_required_data(cls, has_manifest: bool, has_catalog: bool, **kwargs) -> Tuple[bool, Text]: + """ + return False + """ + if not has_manifest: + return False, "manifest is required for insight to run." + + if not has_catalog: + return False, "catalog is required for insight to run." + + return True, "" diff --git a/src/datapilot/core/platforms/dbt/insights/governance/undocumented_public_models.py b/src/datapilot/core/platforms/dbt/insights/governance/undocumented_public_models.py new file mode 100644 index 00000000..093e8af6 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/governance/undocumented_public_models.py @@ -0,0 +1,110 @@ +from typing import List + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.insights.governance.base import \ + DBTGovernanceInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import ( + AltimateAccess, AltimateManifestNode, AltimateResourceType) +from datapilot.utils.formatting.utils import numbered_list + + +# TODO: Include catalog information to make this better! +class DBTUndocumentedPublicModels(DBTGovernanceInsight): + """ + DBTUndocumentedPublicModels identifies public models that are not documented. + """ + + NAME = "Undocumented Public Models" + ALIAS = "undocumented_public_models" + DESCRIPTION = ( + "Identifies models in the dbt project that are marked as public but lack documentation. Public models should " + "be thoroughly documented to ensure that consumers of the data have a clear understanding " + "of their structure and purpose." + ) + REASON_TO_FLAG = ( + "Public models are accessible to a wide range of data consumers. To promote understanding and usability, " + "it's essential to document these models comprehensively." + ) + FAILURE_MESSAGE = ( + "Model `{model_unique_id}` is marked as public but is not documented. " + "Lack of documentation can lead to confusion for data consumers." + ) + RECOMMENDATION = ( + "For best practices, ensure that all models with public access are documented adequately. " + "Documentation enhances data understanding and facilitates collaboration among data consumers." + ) + + def _build_failure_result( + self, + model_unique_id: str, + model_description_is_missing: bool, + columns: List[str] = None, + ) -> DBTInsightResult: + """ + Build failure result for the insight if a model is a root model with 0 direct parents. + + :param model_unique_id: Unique ID of the current model being evaluated. + :param model_description_is_missing: Whether the model description is missing. + :param columns: List of columns that are missing documentation. + :return: An instance of InsightResult containing failure message and recommendation. + """ + self.logger.debug(f"Building failure result model {model_unique_id} is public but not documented.") + + failure = self.FAILURE_MESSAGE.format( + model_unique_id=model_unique_id, + ) + failure += f"Missing Model documentation." if model_description_is_missing else "" + + failure += f"\n Columns missing documentation: {numbered_list(columns)}" if columns else "" + + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure, + recommendation=self.RECOMMENDATION, + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "model": model_unique_id, + "columns_without_documentation": columns, + "model_description_missing": model_description_is_missing, + }, + ) + + def _get_missing_column_documentation(self, node: AltimateManifestNode) -> List[str]: + columns = [] + for column in node.columns: + if not column.description: + columns.append(column.name) + return columns + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + """ + Generate a list of InsightResponse objects for each model in the DBT project, + identifying root models with 0 direct parents. + """ + self.logger.debug("Generating insights for undocumented public models") + insights = [] + for node_id, node in self.nodes.items(): + if node.resource_type == AltimateResourceType.model: + if node.access == AltimateAccess.public: + missing_model_documentation = not node.description + missing_columns = self._get_missing_column_documentation(node) + if missing_model_documentation or missing_columns: + insights.append( + DBTModelInsightResponse( + unique_id=node_id, + package_name=node.package_name, + path=node.original_file_path, + original_file_path=node.original_file_path, + insight=self._build_failure_result( + node_id, + not missing_model_documentation, + missing_columns, + ), + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/README.md b/src/datapilot/core/platforms/dbt/insights/modelling/README.md new file mode 100644 index 00000000..920d32b9 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/README.md @@ -0,0 +1,15 @@ +## Insights + + +- Direct Join to Source | Done +- Downstream Models Dependent on Source | Done +- Duplicate Sources | Done +- Hard Coded References | Done +- Model Fanout | Done +- Multiple Sources Joined | Done +- Rejoining of Upstream Concepts +- Root Models | Done +- Source Fanout | Done +- Staging Models Dependent on Downstream Models | Done +- Staging Models Dependent on Other Staging Models | Done +- Unused Sources | Done \ No newline at end of file diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/__init__.py b/src/datapilot/core/platforms/dbt/insights/modelling/__init__.py new file mode 100644 index 00000000..1dcc776d --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/__init__.py @@ -0,0 +1,15 @@ +from .direct_join_to_source import DBTDirectJoinSource +from .downstream_models_dependent_on_source import \ + DBTDownstreamModelsDependentOnSource +from .duplicate_sources import DBTDuplicateSources +from .hard_coded_references import DBTHardCodedReferences +from .joining_of_upstream_concepts import DBTRejoiningOfUpstreamConcepts +from .model_fanout import DBTModelFanout +from .multiple_sources_joined import DBTModelsMultipleSourcesJoined +from .root_model import DBTRootModel +from .source_fanout import DBTSourceFanout +from .staging_model_dependent_on_downstream_models import \ + DBTStagingModelsDependentOnDownstreamModels +from .staging_model_dependent_on_staging_models import \ + DBTStagingModelsDependentOnStagingModels +from .unused_sources import DBTUnusedSources diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/base.py b/src/datapilot/core/platforms/dbt/insights/modelling/base.py new file mode 100644 index 00000000..6f156956 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/base.py @@ -0,0 +1,30 @@ +from abc import abstractmethod +from typing import Any, Dict, List, Optional, Text, Tuple + +from datapilot.core.insights.schema import Severity +from datapilot.core.platforms.dbt.insights.base import DBTInsight +from datapilot.schemas.constants import CONFIG_METRICS + + +class DBTModellingInsight(DBTInsight): + NAME = "DBTModellingInsight" + TYPE = "Modelling" + + def __init__(self, config: Optional[Dict[Text, Any]] = None, *args, **kwargs): + self.config = config or {} + super().__init__(*args, **kwargs) + + @abstractmethod + def generate(self, *args, **kwargs) -> dict: + pass + + @classmethod + def has_all_required_data(cls, has_manifest: bool, **kwargs) -> Tuple[bool, str]: + """ + Check if all required data is available for the insight to run. + :param has_manifest: A boolean indicating if manifest is available. + :return: A boolean indicating if all required data is available. + """ + if not has_manifest: + return False, "manifest is required for insight to run." + return True, "" diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/direct_join_to_source.py b/src/datapilot/core/platforms/dbt/insights/modelling/direct_join_to_source.py new file mode 100644 index 00000000..47ed422a --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/direct_join_to_source.py @@ -0,0 +1,124 @@ +from typing import Dict, List, Optional + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.constants import MODEL, SOURCE +from datapilot.core.platforms.dbt.insights.modelling.base import \ + DBTModellingInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.utils.formatting.utils import numbered_list + + +class DBTDirectJoinSource(DBTModellingInsight): + """ + DBTDirectJoinSource is used to ensure that DBT models have a proper mapping + from source to staging models and to flag any direct dependencies on multiple + sources without intermediate staging models. + Ref: https://github.com/dbt-labs/dbt-project-evaluator/blob/main/models/marts/dag/fct_direct_join_to_source.sql + """ + + ALIAS = "source_staging_model_integrity" + NAME = "Source-Staging Model Integrity" + DESCRIPTION = ( + "Ensures that each source has a dedicated staging model and is not directly joined to downstream models. " + "This practice facilitates consistent data transformation and column renaming at the staging level, " + "promoting uniformity across all models consuming the source data." + ) + REASON_TO_FLAG = ( + "Flagged when a model directly joins a source and a model without a staging intermediary. " + "Direct source-model joins bypass the staging layer, leading to potential inconsistencies in data handling." + ) + FAILURE_MESSAGE = ( + "Model `{current_model_unique_id}` has direct joins to both sources and other models. " + "\n### Detected Sources\n{sources}\n\n### Connected Models \n{models}" + ) + RECOMMENDATION = ( + "Create a dedicated staging model for the source(s) and modify `{current_model_unique_id}` " + "to depend on this staging model. This ensures consistent initial data processing steps." + ) + + def _build_failure_result(self, current_model_unique_id: str, dependencies: Dict) -> DBTInsightResult: + """ + Build failure result for the insight if a model is directly joining to a source + and other models. + + :param current_model_unique_id: Unique ID of the current model being evaluated. + :param dependencies: A dictionary of dependencies categorized as 'source' and 'model'. + :return: An instance of InsightResult containing failure message and recommendation and metadata. + """ + self.logger.debug(f"Found multiple sources and models for {current_model_unique_id}") + failure = self.FAILURE_MESSAGE.format( + current_model_unique_id=current_model_unique_id, + sources=numbered_list(dependencies["source"]), + models=numbered_list(dependencies["model"]), + ) + recommendation = self.RECOMMENDATION.format(current_model_unique_id=current_model_unique_id) + + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure, + recommendation=recommendation, + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "model": current_model_unique_id, + "dependencies": dependencies, + }, + ) + + def _check_dependency_on_both_models_and_sources(self, current_node) -> Optional[DBTInsightResult]: + """ + Check if the current node has dependencies on both models and sources or multiple sources. + + :param current_node: The node representing the current model. + :return: A list of InsightResult instances with recommendations for each violation. + """ + self.logger.debug(f"Checking dependencies for model {current_node.unique_id}") + dependencies = { + MODEL: [], + SOURCE: [], + } + excluded_nodes = self.config.get("excluded_nodes", []) + for dependent_unique_id in current_node.depends_on.nodes: + if dependent_unique_id in excluded_nodes: + self.logger.debug(f"Skipping dependency {dependent_unique_id} as it is excluded list of the config") + continue + dependent_node = self.get_node(dependent_unique_id) + if dependent_node.resource_type == AltimateResourceType.model: + self.logger.debug(f"Found dependent model {dependent_unique_id} for model {current_node.unique_id}") + dependencies[MODEL].append(dependent_node.unique_id) + elif dependent_node.resource_type == AltimateResourceType.source: + self.logger.debug(f"Found dependent source {dependent_unique_id} for model {current_node.unique_id}") + dependencies[SOURCE].append(dependent_node.unique_id) + if dependencies[MODEL] and dependencies[SOURCE]: + self.logger.debug(f"Found dependencies on both models and sources for model {current_node.unique_id}") + return self._build_failure_result(current_node.unique_id, dependencies) + else: + self.logger.debug(f"No dependencies on both models and sources for model {current_node.unique_id}") + return None + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + """ + Generate a list of InsightResponse objects for each model in the DBT project, + containing insights about direct source dependencies. + :return: A list of InsightResponse objects. + """ + self.logger.debug(f"Generating insights for DBTDirectJoinSource for project {self.project_name}") + recommendations = [] + for node_id, node in self.nodes.items(): + if node.resource_type == AltimateResourceType.model: + recommendation = self._check_dependency_on_both_models_and_sources(node) + if recommendation: + self.logger.debug(f"Found recommendation for model {node_id} in DBTDirectJoinSource") + recommendations.append( + DBTModelInsightResponse( + unique_id=node_id, + package_name=node.package_name, + path=node.path, + original_file_path=node.original_file_path, + insight=recommendation, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + return recommendations diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/downstream_models_dependent_on_source.py b/src/datapilot/core/platforms/dbt/insights/modelling/downstream_models_dependent_on_source.py new file mode 100644 index 00000000..96f5a419 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/downstream_models_dependent_on_source.py @@ -0,0 +1,112 @@ +from typing import List + +from datapilot.config.utils import get_regex_configuration +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.constants import INTERMEDIATE, MART +from datapilot.core.platforms.dbt.insights.modelling.base import \ + DBTModellingInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.core.platforms.dbt.utils import classify_model_type +from datapilot.utils.formatting.utils import numbered_list + + +class DBTDownstreamModelsDependentOnSource(DBTModellingInsight): + """ + DBTDownstreamModelsDependentOnSource identifies downstream models (either marts or intermediate) + in a dbt project that depend directly on a source node. + """ + + NAME = "Downstream Models Dependent on Source" + ALIAS = "downstream_source_dependence" + DESCRIPTION = ( + "Evaluates if downstream models (marts or intermediates) are improperly dependent directly on a source. " + "Aims to ensure that all downstream models depend on staging models, not directly on source nodes." + ) + REASON_TO_FLAG = ( + "Direct dependency of marts or intermediate models on a source node suggests a missing staging model. " + "Staging models serve as atomic units, maintaining a one-to-one relationship with source data tables, " + "while providing a consistent format for downstream consumption." + ) + FAILURE_MESSAGE = ( + "Downstream model `{current_model_unique_id}` of type {model_type} is directly dependent on a source nodes." + "Direct source dependencies bypass the critical staging layer, leading to potential data consistency issues." + " Source dependencies: {source_dependencies}" + ) + RECOMMENDATION = ( + "Introduce or utilize an existing staging model for the source node involved. Refactor the downstream model " + "`{current_model_unique_id}` to select from this staging layer, ensuring a proper abstraction layer between " + "raw data and downstream data artifacts." + ) + MODEL_TYPES = [INTERMEDIATE, MART] + + def _build_failure_result( + self, + current_model_unique_id: str, + source_dependencies: List[str], + model_type: str, + ) -> DBTInsightResult: + """ + Build failure result for the insight if a downstream model depends directly on a source node. + + :param current_model_unique_id: Unique ID of the current model being evaluated. + :param source_dependencies: List of source dependencies for the current model. + :return: An instance of InsightResult containing failure message and recommendation. + """ + self.logger.debug(f"Building failure result for model {current_model_unique_id} with direct source dependencies") + + failure = self.FAILURE_MESSAGE.format( + current_model_unique_id=current_model_unique_id, + model_type=model_type, + source_dependencies=numbered_list(source_dependencies), + ) + + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure, + recommendation=self.RECOMMENDATION.format(current_model_unique_id=current_model_unique_id), + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "model": current_model_unique_id, + "source_dependencies": source_dependencies, + "model_type": model_type, + }, + ) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + """ + Generate a list of InsightResponse objects for each downstream model in the DBT project, + identifying those that depend directly on source nodes. + :return: A list of InsightResponse objects. + """ + self.logger.debug(f"Generating insights for DBTDownstreamModelsDependentOnSource for project {self.manifest.get_package()}") + insights = [] + regex_configuration = get_regex_configuration(self.config) + for node_id, node in self.nodes.items(): + if node.resource_type == AltimateResourceType.model: + model_type = classify_model_type(node.name, node.original_file_path, regex_configuration) + source_dependencies = [ + dependent_node_id + for dependent_node_id in node.depends_on.nodes + if self.get_node(dependent_node_id).resource_type == AltimateResourceType.source + ] + + if source_dependencies and model_type in self.MODEL_TYPES: + self.logger.debug(f"Found downstream model {node_id} of type {model_type} with direct source dependencies") + insight_result = self._build_failure_result(node.unique_id, source_dependencies, model_type) + insights.append( + DBTModelInsightResponse( + unique_id=node_id, + package_name=node.package_name, + path=node.path, + original_file_path=node.original_file_path, + insight=insight_result, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + self.logger.debug( + f"Finished generating insights for DBTDownstreamModelsDependentOnSource. Found {len(insights)} models with direct source dependencies" + ) + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/duplicate_sources.py b/src/datapilot/core/platforms/dbt/insights/modelling/duplicate_sources.py new file mode 100644 index 00000000..b77535e4 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/duplicate_sources.py @@ -0,0 +1,89 @@ +from collections import defaultdict +from typing import List + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.insights.modelling.base import \ + DBTModellingInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTProjectInsightResponse) +from datapilot.core.platforms.dbt.utils import get_table_name_from_source +from datapilot.utils.formatting.utils import numbered_list + + +class DBTDuplicateSources(DBTModellingInsight): + """ + Check if the DBT project has duplicate sources. + Ref: https://github.com/dbt-labs/dbt-project-evaluator/blob/main/models/marts/dag/fct_duplicate_sources.sql + """ + + NAME = "Duplicate Sources" + ALIAS = "Duplicate_Sources" + DESCRIPTION = ( + "Identifies cases where multiple source nodes in a dbt project refer to the same database object. " + "Ensures that each database object is represented by a single, unique source node." + ) + REASON_TO_FLAG = ( + "Having multiple source nodes pointing to the same database location can lead to an inaccurate " + "representation of data lineage and potential confusion in data management." + ) + FAILURE_MESSAGE = ( + "Duplicate source nodes detected: Multiple source nodes are referencing the same database object. " + "Database location {source_table} is referenced by:\n {source_nodes_list}" + ) + RECOMMENDATION = ( + "Consolidate the duplicate source nodes so that each database location has only a single source definition " + "in your dbt project. This will help maintain clear and accurate data lineage." + ) + + def _build_failure_result(self, source_table: str, source_ids: List[str]) -> DBTInsightResult: + """ + Build Insight result if a source table has multiple source models defined. + :param source_table: Name of the source table. + :param source_ids: List of source IDs which are referencing the source table. + :return: An instance of DBTInsightResult containing failure message and recommendation and metadata. + """ + self.logger.debug(f"Building failure result for source table {source_table}") + return DBTInsightResult( + name=self.NAME, + type=self.TYPE, + reason_to_flag=self.REASON_TO_FLAG, + message=self.FAILURE_MESSAGE.format(source_table=source_table, source_nodes_list=numbered_list(source_ids)), + recommendation=self.RECOMMENDATION.format(source_table=source_table), + metadata={ + "source_table": source_table, + "source_ids": source_ids, + }, + ) + + def generate(self, *args, **kwargs) -> List[DBTProjectInsightResponse]: + """ + Generate a list of InsightResponse objects for each model in the DBT project, + containing insights about direct source dependencies. + :return: A list of InsightResponse objects. + """ + + self.logger.debug(f"Generating insights for DBTDuplicateSources for project {self.project_name}") + + source_table_to_id_map = defaultdict(list) + for source_id, source in self.sources.items(): + table_name = get_table_name_from_source(source) + source_table_to_id_map[table_name].append(source_id) + + self.logger.debug(f"source_table_to_id_map: {source_table_to_id_map}") + insight_results = [] + for source_table, source_ids in source_table_to_id_map.items(): + if len(source_ids) > 1: + insight_results.append(self._build_failure_result(source_table, source_ids)) + + if insight_results: + self.logger.debug("Duplicate source models found") + return [ + DBTProjectInsightResponse( + package_name=self.project_name, + insights=insight_results, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ] + + self.logger.debug("No duplicate sources found") + return [] diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/hard_coded_references.py b/src/datapilot/core/platforms/dbt/insights/modelling/hard_coded_references.py new file mode 100644 index 00000000..c74874ea --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/hard_coded_references.py @@ -0,0 +1,81 @@ +from typing import List + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.constants import SQL +from datapilot.core.platforms.dbt.insights.modelling.base import \ + DBTModellingInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.core.platforms.dbt.utils import get_hard_coded_references +from datapilot.utils.formatting.utils import numbered_list + + +class DBTHardCodedReferences(DBTModellingInsight): + """ + Checks if the dbt model has hard coded references to other models. + """ + + NAME = "Hard Coded References" + ALIAS = "hard_coded_references" + DESCRIPTION = ( + "Identifies and flags instances where SQL code within models contains hard-coded references. " + "These references can obscure data lineage and complicate project maintenance." + ) + REASON_TO_FLAG = ( + "Hard-coded references in SQL prevent easy identification and tracking of data lineage, " + "and can lead to issues in maintainability and scalability of the data models." + ) + SOURCE_FANOUT_THRESHOLD = 1 # Default threshold, can be overridden as needed + FAILURE_MESSAGE = ( + "Model `{model_unique_id}` contains hard-coded references, which may obscure data lineage. " + "Detected hard-coded references: \n{hard_coded_references}" + ) + RECOMMENDATION = ( + "Replace hard-coded references in `{model_unique_id}` with dbt sources or model references to " + "improve clarity and maintainability of data lineage." + ) + + def _build_failure_result(self, model_unique_id: str, hard_coded_references: List[str]) -> DBTInsightResult: + failure_message = self.FAILURE_MESSAGE.format( + model_unique_id=model_unique_id, + hard_coded_references=numbered_list(hard_coded_references), + ) + return DBTInsightResult( + name=self.NAME, + type=self.TYPE, + message=failure_message, + recommendation=self.RECOMMENDATION.format(model_unique_id=model_unique_id), + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "model": model_unique_id, + "hard_coded_references": hard_coded_references, + }, + ) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + insights = [] + + for node in self.nodes.values(): + if node.resource_type == AltimateResourceType.model: + raw_code = node.raw_code + if (not raw_code) or node.language != SQL: + continue + hard_coded_references = get_hard_coded_references(raw_code) + if hard_coded_references: + insight_result = self._build_failure_result( + model_unique_id=node.unique_id, + hard_coded_references=hard_coded_references, + ) + insights.append( + DBTModelInsightResponse( + unique_id=node.unique_id, + package_name=node.package_name, + path=node.path, + original_file_path=node.original_file_path, + insight=insight_result, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/joining_of_upstream_concepts.py b/src/datapilot/core/platforms/dbt/insights/modelling/joining_of_upstream_concepts.py new file mode 100644 index 00000000..788cedd0 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/joining_of_upstream_concepts.py @@ -0,0 +1,79 @@ +from typing import List + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.insights.modelling.base import \ + DBTModellingInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) + + +class DBTRejoiningOfUpstreamConcepts(DBTModellingInsight): + """ + DBTRejoiningOfUpstreamConcepts identifies cases in the dbt project where a parent model's direct child + is also the direct child of another one of the parent's direct children, with the condition that the intermediate + model has no other downstream dependencies. + """ + + NAME = "Rejoining of Upstream Concepts" + ALIAS = "rejoining_upstream_concepts" + DESCRIPTION = ( + "Detects scenarios where a parent's direct child is also a direct child of another one " + "of the parent's direct children. This pattern may indicate potential loops or unnecessary" + " complexity in the DAG." + ) + REASON_TO_FLAG = ( + "Flagged to identify cases where a parent model has a direct child that is also a direct child " + "of another one of the parent's direct children. Such patterns can suggest loops or redundancies in the DAG." + ) + FAILURE_MESSAGE = ( + "Model `{child}` has a rejoining upstream concept with parent model `{parent_model}` " + "and downstream child: `{downstream_child}`. This may indicate a loop or redundancy in the DAG." + ) + RECOMMENDATION = ( + "Review and potentially refactor the model relationships in `{child}`," + " `{parent_model}`, and `{downstream_child}` to simplify the DAG and " + "avoid unnecessary complexity or potential loops." + ) + + def _build_failure_result(self, child: str, parent_model: str, children_list: List[str]) -> DBTInsightResult: + failure_message = self.FAILURE_MESSAGE.format(child=child, parent_model=parent_model, downstream_child=children_list[0]) + + recommendation = self.RECOMMENDATION.format(child=child, parent_model=parent_model, downstream_child=children_list[0]) + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure_message, + recommendation=recommendation, + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "model": parent_model, + "children": children_list, + }, + ) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + insights = [] + for parent_model, children in self.children_map.items(): + for child in children: + child_child_is_also_parent_child = any( + [dwn_stream_child in self.children_map[child] for dwn_stream_child in self.children_map[parent_model]] + ) + if child_child_is_also_parent_child and len(self.children_map[child]) == 1: + insight_result = self._build_failure_result( + child=child, + parent_model=parent_model, + children_list=list(self.children_map[child]), + ) + child_node = self.get_node(child) + insights.append( + DBTModelInsightResponse( + unique_id=child_node.unique_id, + package_name=child_node.package_name, + path=child_node.path, + original_file_path=child_node.original_file_path, + insight=insight_result, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/model_fanout.py b/src/datapilot/core/platforms/dbt/insights/modelling/model_fanout.py new file mode 100644 index 00000000..c0bd47ac --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/model_fanout.py @@ -0,0 +1,115 @@ +from typing import List + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.insights.modelling.base import \ + DBTModellingInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.schemas.constants import CONFIG_METRICS + + +class DBTModelFanout(DBTModellingInsight): + """ + DBTModelFanout identifies parent models in a dbt project with more than a specified number + of direct leaf children, indicating a high model fanout. + """ + + NAME = "Model Fanout Analysis" + ALIAS = "model_fanout" + DESCRIPTION = ( + "Assesses parent models to identify high fanout scenarios. High fanout can indicate points in the DAG where " + "transformations may be more efficiently moved to the BI layer, or where common business logic could be " + "better positioned upstream in the data pipeline." + ) + REASON_TO_FLAG = ( + "Flagged to highlight parent models with an unusually high number of leaf children. This can suggest areas " + "in the data pipeline where complexity is increased and transformations might be optimized." + ) + FANOUT_THRESHOLD = 3 # Default threshold, can be overridden as needed + FAILURE_MESSAGE = ( + "Model `{parent_model_unique_id}` has `{leaf_children}` leaf children, " + "exceeding the fanout threshold of `{fanout_threshold}`. This level of fanout may lead to increased complexity." + ) + RECOMMENDATION = ( + "Consider reviewing and restructuring `{parent_model_unique_id}` to simplify its dependencies. " + "Reducing the number of leaf children can lead to a more streamlined and maintainable data pipeline." + ) + + FANOUT_THRESHOLD_STR = "max_fanout" + + def _build_failure_result( + self, + parent_model_unique_id: str, + leaf_children: List[str], + fanout_threshold: int, + ) -> DBTInsightResult: + # Logic to build the failure result + self.logger.debug(f"Found {len(leaf_children)} leaf children for {parent_model_unique_id}") + failure_message = self.FAILURE_MESSAGE.format( + parent_model_unique_id=parent_model_unique_id, + leaf_children=len(leaf_children), + fanout_threshold=fanout_threshold, + ) + + recommendation = self.RECOMMENDATION.format( + parent_model_unique_id=parent_model_unique_id, + ) + + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure_message, + recommendation=recommendation, + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "model": parent_model_unique_id, + "leaf_children_count": len(leaf_children), + "leaf_children": leaf_children, + }, + ) + + def _get_fanout_threshold(self) -> int: + # Check if metrics configuration and specific metric alias are present in the config + metrics_config = self.config.get(CONFIG_METRICS, {}) + metric_config = metrics_config.get(self.ALIAS, {}) + + # Return the configured fanout threshold or the default if not specified + return metric_config.get(self.FANOUT_THRESHOLD_STR, self.FANOUT_THRESHOLD) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + fanout_threshold = self._get_fanout_threshold() + insights = [] + self.logger.debug(f"Checking for models with fanout greater than {fanout_threshold}") + for parent, children_set in self.children_map.items(): + node = self.get_node(parent) + if node.resource_type != AltimateResourceType.model: + continue + + leaf_children = [ + child + for child in children_set + if len(self.children_map[child]) == 0 + and self.get_node(child).resource_type + not in [ + AltimateResourceType.test, + AltimateResourceType.analysis, + AltimateResourceType.metric, + ] + ] + + if len(leaf_children) > fanout_threshold: + insight_result = self._build_failure_result(parent, leaf_children, fanout_threshold) + insights.append( + DBTModelInsightResponse( + unique_id=parent, + package_name=node.package_name, + path=node.path, + original_file_path=node.original_file_path, + insight=insight_result, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + self.logger.debug(f"Found {len(insights)} models with high fanout") + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/multiple_sources_joined.py b/src/datapilot/core/platforms/dbt/insights/modelling/multiple_sources_joined.py new file mode 100644 index 00000000..3f099b86 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/multiple_sources_joined.py @@ -0,0 +1,84 @@ +from typing import List + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.insights.modelling.base import \ + DBTModellingInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.utils.formatting.utils import numbered_list + + +class DBTModelsMultipleSourcesJoined(DBTModellingInsight): + """ + DBTModelsMultipleSourcesJoined identifies models in a dbt project that reference more than one source. + """ + + NAME = "Multiple Sources Joined" + ALIAS = "multiple_sources_joined" + DESCRIPTION = ( + "Checks if a model directly joins multiple source tables. Encourages the use of a single staging" + " model per source, which then serves as the dependency for downstream models. This practice" + " enhances data consistency and maintainability." + ) + REASON_TO_FLAG = ( + "Best practice is to have a single staging model per source and use this staging model as a " + "dependency for downstream models. Directly joining multiple sources in a single model can " + "lead to data management complexities and inconsistencies." + ) + FAILURE_MESSAGE = ( + "Model `{model_id}` directly uses multiple sources, which may complicate data management and lineage tracking. " + "Detected sources: \n{sources_list}" + ) + RECOMMENDATION = ( + "Consider refactoring `{model_id}` to reference a single source or " + "intermediate models that consolidate these sources. This approach simplifies data lineage" + " and improves maintainability." + ) + + def _build_failure_result(self, model_id: str, source_dependencies: List[str]) -> DBTInsightResult: + failure = self.FAILURE_MESSAGE.format( + model_id=model_id, + sources_list=numbered_list(source_dependencies), + ) + recommendation = self.RECOMMENDATION.format(model_id=model_id) + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure, + recommendation=recommendation, + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "model": model_id, + "source_dependencies": source_dependencies, + }, + ) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + self.logger.debug(f"Generating insights for DBTModelsMultipleSourcesJoined for project {self.manifest.get_package()}") + + insights = [] + + for node_id, node in self.nodes.items(): + if node.resource_type == AltimateResourceType.model: + source_dependencies = [ + dependent_node_id + for dependent_node_id in node.depends_on.nodes + if self.get_node(dependent_node_id).resource_type == AltimateResourceType.source + ] + + if len(source_dependencies) > 1: + self.logger.debug(f"Model {node_id} references multiple sources") + insight_result = self._build_failure_result(node_id, source_dependencies) + insights.append( + DBTModelInsightResponse( + unique_id=node_id, + package_name=node.package_name, + path=node.path, + original_file_path=node.original_file_path, + insight=insight_result, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/root_model.py b/src/datapilot/core/platforms/dbt/insights/modelling/root_model.py new file mode 100644 index 00000000..f468c5d5 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/root_model.py @@ -0,0 +1,84 @@ +from typing import List + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.insights.modelling.base import \ + DBTModellingInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType + + +class DBTRootModel(DBTModellingInsight): + """ + DBTRootModels is used to identify models in a dbt project with 0 direct parents, + meaning these models cannot be traced back to a declared source or model. + """ + + NAME = "Root Model Traceability" + ALIAS = "root_model" + DESCRIPTION = ( + "Identifies root models that do not have direct parents, either sources or other models within the " + "dbt project. Ensures that all models can be traced back to a source or are interconnected within the project, " + "which is a best practice for clear data lineage and project integrity." + ) + REASON_TO_FLAG = ( + "Best Practice is to ensure all models can be traced back to a source or another model in the project. " + "Root models with no direct parents can lead to challenges in tracking data lineage and understanding" + " the overall data model." + ) + FAILURE_MESSAGE = ( + "Model `{current_model_unique_id}` is identified as a root model with no direct parents. " + "This can hinder traceability and clarity in the data model." + ) + RECOMMENDATION = ( + "Ensure that model `{current_model_unique_id}` is appropriately linked to a source or another model " + "within the dbt project. This linkage is crucial for maintaining clear data lineage and project coherence." + ) + + def _build_failure_result(self, current_model_unique_id: str) -> DBTInsightResult: + """ + Build failure result for the insight if a model is a root model with 0 direct parents. + + :param current_model_unique_id: Unique ID of the current model being evaluated. + :return: An instance of InsightResult containing failure message and recommendation. + """ + self.logger.debug(f"Building failure result for root model {current_model_unique_id}") + + failure = self.FAILURE_MESSAGE.format(current_model_unique_id=current_model_unique_id) + recommendation = self.RECOMMENDATION.format(current_model_unique_id=current_model_unique_id) + + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure, + recommendation=recommendation, + reason_to_flag=self.REASON_TO_FLAG, + metadata={"model": current_model_unique_id}, + ) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + """ + Generate a list of InsightResponse objects for each model in the DBT project, + identifying root models with 0 direct parents. + :return: A list of InsightResponse objects. + """ + self.logger.debug(f"Generating insights for DBTRootModels for project {self.project_name}") + insights = [] + + for node_id, node in self.nodes.items(): + if node.resource_type == AltimateResourceType.model and not node.depends_on.nodes: + self.logger.debug(f"Found root model {node_id} with no direct parents") + insight_result = self._build_failure_result(node.unique_id) + insights.append( + DBTModelInsightResponse( + unique_id=node_id, + package_name=node.package_name, + path=node.path, + original_file_path=node.original_file_path, + insight=insight_result, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + self.logger.debug(f"Found {len(insights)} root models") + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/source_fanout.py b/src/datapilot/core/platforms/dbt/insights/modelling/source_fanout.py new file mode 100644 index 00000000..62c67e49 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/source_fanout.py @@ -0,0 +1,91 @@ +from typing import List + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.insights.modelling.base import \ + DBTModellingInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.schemas.constants import CONFIG_METRICS + + +class DBTSourceFanout(DBTModellingInsight): + """ + DBTSourceFanout identifies instances where a source is the direct parent of multiple resources in the DAG. + """ + + NAME = "Source Fanout Analysis" + ALIAS = "source_fanout" + DESCRIPTION = ( + "Evaluates sources for high fanout, which occurs when a single source has a" + " large number of direct child models. High fanout can be indicative of a data model" + " that might be overly complex or overly reliant on a specific source." + ) + REASON_TO_FLAG = ( + "Identifying sources with high fanout can indicate areas where the data model might be overly complex " + "or dependent on a single source. Such dependencies can introduce risks and " + "complicate maintenance and scalability." + ) + SOURCE_FANOUT_THRESHOLD = 1 # Default threshold, can be overridden as needed + FAILURE_MESSAGE = ( + "Source `{source_unique_id}` has `{children_count}` direct children, " + "exceeding the fanout threshold of `{fanout_threshold}`. This level of fanout may lead to increased complexity." + ) + RECOMMENDATION = ( + "Review the source `{source_unique_id}` to identify opportunities to reduce its direct dependencies. " + "This can help in simplifying the data model and reducing the risk associated with high source reliance." + ) + SOURCE_FANOUT_THRESHOLD_STR = "max_fanout" + + def _build_failure_result(self, source_unique_id: str, children_count: int, fanout_threshold: int) -> DBTInsightResult: + failure_message = self.FAILURE_MESSAGE.format( + source_unique_id=source_unique_id, + children_count=children_count, + fanout_threshold=fanout_threshold, + ) + + recommendation = self.RECOMMENDATION.format(source_unique_id=source_unique_id) + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure_message, + recommendation=recommendation, + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "source": source_unique_id, + "direct_children_count": children_count, + }, + ) + + def _get_source_fanout_threshold(self) -> int: + metrics_config = self.config.get(CONFIG_METRICS, {}) + metric_config = metrics_config.get(self.ALIAS, {}) + + # Return the configured fanout threshold or the default if not specified + return metric_config.get(self.SOURCE_FANOUT_THRESHOLD_STR, self.SOURCE_FANOUT_THRESHOLD) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + fanout_threshold = self._get_source_fanout_threshold() + insights = [] + + for node_id, children_set in self.children_map.items(): + node = self.get_node(node_id) + if node.resource_type == AltimateResourceType.source: + if len(children_set) > fanout_threshold: + insight_result = self._build_failure_result( + source_unique_id=node_id, + children_count=len(children_set), + fanout_threshold=fanout_threshold, + ) + + insights.append( + DBTModelInsightResponse( + unique_id=node_id, + package_name=node.package_name, + path=node.path, + original_file_path=node.original_file_path, + insight=insight_result, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/staging_model_dependent_on_downstream_models.py b/src/datapilot/core/platforms/dbt/insights/modelling/staging_model_dependent_on_downstream_models.py new file mode 100644 index 00000000..a5c0b6c2 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/staging_model_dependent_on_downstream_models.py @@ -0,0 +1,101 @@ +from typing import List + +from datapilot.config.utils import get_regex_configuration +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.constants import INTERMEDIATE, MART, STAGING +from datapilot.core.platforms.dbt.insights.modelling.base import \ + DBTModellingInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.core.platforms.dbt.utils import classify_model_type +from datapilot.schemas.constants import CONFIG_METRICS +from datapilot.utils.formatting.utils import numbered_list + + +class DBTStagingModelsDependentOnDownstreamModels(DBTModellingInsight): + """ + DBTStagingModelsDependentOnDownstream identifies staging models in a dbt project that depend on downstream models. + """ + + NAME = "Staging Models Dependency Check" + ALIAS = "staging_models_dependency" + DESCRIPTION = ( + "Checks whether staging models depend on downstream models, instead of source or raw data models. " + "Staging models should ideally depend on upstream data sources to maintain a clear and logical data flow." + ) + REASON_TO_FLAG = ( + "Best practice is for staging models to depend on source or raw data models, not on downstream models. " + "Dependencies in the wrong direction can lead to complications in data processing and lineage tracing." + ) + FAILURE_MESSAGE = ( + "Staging model `{current_model_unique_id}` has dependencies on downstream models, " + "which is against best practices: \n{downstream_dependencies}" + ) + RECOMMENDATION = ( + "Refactor the staging model `{current_model_unique_id}` to ensure it depends on source or raw data models. " + "This will align the model with best practices, enhancing data flow clarity and lineage tracing." + ) + DOWNSTREAM_MODEL_TYPES_STR = "downstream_model_types" + DOWNSTREAM_MODEL_TYPES = [MART, INTERMEDIATE] + + def _build_failure_result(self, current_model_unique_id: str, downstream_dependencies: List[str]) -> DBTInsightResult: + failure = self.FAILURE_MESSAGE.format( + current_model_unique_id=current_model_unique_id, + downstream_dependencies=numbered_list(downstream_dependencies), + ) + recommendation = self.RECOMMENDATION.format(current_model_unique_id=current_model_unique_id) + + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure, + recommendation=recommendation, + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "model": current_model_unique_id, + "downstream_dependencies": downstream_dependencies, + }, + ) + + def _get_downstream_models(self) -> List[str]: + metrics_config = self.config.get(CONFIG_METRICS, {}) + metric_config = metrics_config.get(self.ALIAS, {}) + + # Return the configured fanout threshold or the default if not specified + return metric_config.get(self.DOWNSTREAM_MODEL_TYPES_STR, self.DOWNSTREAM_MODEL_TYPES) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + insights = [] + downstream_models = self._get_downstream_models() + regex_configuration = get_regex_configuration(self.config) + for node_id, node in self.nodes.items(): + if ( + node.resource_type == AltimateResourceType.model + and classify_model_type(node.name, node.original_file_path, regex_configuration) == STAGING + ): + downstream_dependencies = [ + dependent_node_id + for dependent_node_id in node.depends_on.nodes + if classify_model_type( + self.get_node(dependent_node_id).name, + self.get_node(dependent_node_id).original_file_path, + regex_configuration, + ) + in downstream_models + ] + + if downstream_dependencies: + insight_result = self._build_failure_result(node_id, downstream_dependencies) + insights.append( + DBTModelInsightResponse( + unique_id=node_id, + package_name=node.package_name, + path=node.path, + original_file_path=node.original_file_path, + insight=insight_result, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/staging_model_dependent_on_staging_models.py b/src/datapilot/core/platforms/dbt/insights/modelling/staging_model_dependent_on_staging_models.py new file mode 100644 index 00000000..450d5b2f --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/staging_model_dependent_on_staging_models.py @@ -0,0 +1,91 @@ +from typing import List + +from datapilot.config.utils import get_regex_configuration +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.constants import STAGING +from datapilot.core.platforms.dbt.insights.modelling.base import \ + DBTModellingInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.core.platforms.dbt.utils import classify_model_type +from datapilot.utils.formatting.utils import numbered_list + + +class DBTStagingModelsDependentOnStagingModels(DBTModellingInsight): + """ + DBTStagingModelsDependentOnStagingModels identifies staging models in a dbt project that depend on staging models. + """ + + NAME = "Staging Models Dependency on Staging Models" + ALIAS = "staging_models_on_staging" + DESCRIPTION = ( + "Checks if staging models are depending on other staging models instead of depending on source " + "or raw data models. Ensures that staging models are used appropriately, maintaining a clear " + "and logical data flow from sources to staging." + ) + REASON_TO_FLAG = ( + "Best practice is for staging models to depend on source or raw data models, not on other staging models. " + "Dependencies among staging models can lead to complicated data flows and hinder data lineage tracking." + ) + FAILURE_MESSAGE = ( + "Staging model `{current_model_unique_id}` has dependencies on other staging models, " + "which is against best practices: \n{downstream_dependencies}" + ) + RECOMMENDATION = ( + "Refactor staging model `{current_model_unique_id}` to ensure it depends on source or raw data models, " + "not on other staging models. This realignment with best practices promotes clear and effective data flow." + ) + + def _build_failure_result(self, current_model_unique_id: str, downstream_dependencies: List[str]) -> DBTInsightResult: + failure = self.FAILURE_MESSAGE.format( + current_model_unique_id=current_model_unique_id, + downstream_dependencies=numbered_list(downstream_dependencies), + ) + recommendation = self.RECOMMENDATION.format(current_model_unique_id=current_model_unique_id) + + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure, + recommendation=recommendation, + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "model": current_model_unique_id, + "downstream_dependencies": downstream_dependencies, + }, + ) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + insights = [] + regex_configuration = get_regex_configuration(self.config) + for node_id, node in self.nodes.items(): + if ( + node.resource_type == AltimateResourceType.model + and classify_model_type(node.name, node.original_file_path, regex_configuration) == STAGING + ): + downstream_dependencies = [ + dependent_node_id + for dependent_node_id in node.depends_on.nodes + if classify_model_type( + self.get_node(dependent_node_id).name, + self.get_node(dependent_node_id).original_file_path, + regex_configuration, + ) + == STAGING + ] + + if downstream_dependencies: + insight_result = self._build_failure_result(node_id, downstream_dependencies) + insights.append( + DBTModelInsightResponse( + unique_id=node_id, + package_name=node.package_name, + path=node.path, + original_file_path=node.original_file_path, + insight=insight_result, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/modelling/unused_sources.py b/src/datapilot/core/platforms/dbt/insights/modelling/unused_sources.py new file mode 100644 index 00000000..5aaeb2b7 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/modelling/unused_sources.py @@ -0,0 +1,61 @@ +from typing import List + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.insights.modelling.base import \ + DBTModellingInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) + + +class DBTUnusedSources(DBTModellingInsight): + """ + DBTUnusedSources identifies sources in a dbt project that are not being referenced by any models. + """ + + NAME = "Unused Sources Detection" + ALIAS = "unused_sources" + DESCRIPTION = ( + "Identifies sources that are defined in the project's YML files but not used in any models, " + "or sources that have become redundant due to model deprecation. Such unused sources contribute " + "to unnecessary complexity and clutter in the dbt project." + ) + REASON_TO_FLAG = ( + "Unused sources, either defined in YML but not used in any model or leftover from deprecated models, " + "represent unnecessary complexity in the project. It's important to keep the dbt project lean and relevant." + ) + FAILURE_MESSAGE = "Source `{source_unique_id}` is not being referenced by any model, indicating it is unused." + RECOMMENDATION = ( + "Review the source `{source_unique_id}`. Consider removing it or integrating it into the project " + "if it's needed. Keeping only relevant sources in the project reduces complexity and improves maintainability." + ) + + def _build_failure_result(self, source_unique_id: str) -> DBTInsightResult: + failure_message = self.FAILURE_MESSAGE.format(source_unique_id=source_unique_id) + recommendation = self.RECOMMENDATION.format(source_unique_id=source_unique_id) + + return DBTInsightResult( + type=self.TYPE, + name=self.NAME, + message=failure_message, + recommendation=recommendation, + reason_to_flag=self.REASON_TO_FLAG, + metadata={"source": source_unique_id}, + ) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + insights = [] + for source_id, source in self.sources.items(): + if source_id not in self.children_map.keys(): + insight_result = self._build_failure_result(source_id) + insights.append( + DBTModelInsightResponse( + unique_id=source_id, + package_name=source.package_name, + path=source.path, + original_file_path=source.original_file_path, + insight=insight_result, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/performance/__init__.py b/src/datapilot/core/platforms/dbt/insights/performance/__init__.py new file mode 100644 index 00000000..be76e440 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/performance/__init__.py @@ -0,0 +1,2 @@ +from .chain_view_linking import DBTChainViewLinking +from .exposure_parent_materializations import DBTExposureParentMaterialization diff --git a/src/datapilot/core/platforms/dbt/insights/performance/base.py b/src/datapilot/core/platforms/dbt/insights/performance/base.py new file mode 100644 index 00000000..7789ab36 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/performance/base.py @@ -0,0 +1,26 @@ +from abc import abstractmethod +from typing import Tuple + +from datapilot.core.platforms.dbt.insights.base import DBTInsight + + +class DBTPerformanceInsight(DBTInsight): + TYPE = "Performance" + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + @abstractmethod + def generate(self, *args, **kwargs) -> dict: + pass + + @classmethod + def has_all_required_data(cls, has_manifest: bool, **kwargs) -> Tuple[bool, str]: + """ + Check if all required data is available for the insight to run. + :param has_manifest: A boolean indicating if manifest is available. + :return: A boolean indicating if all required data is available. + """ + if not has_manifest: + return False, "manifest is required for insight to run." + return True, "" diff --git a/src/datapilot/core/platforms/dbt/insights/performance/chain_view_linking.py b/src/datapilot/core/platforms/dbt/insights/performance/chain_view_linking.py new file mode 100644 index 00000000..e2de0b0e --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/performance/chain_view_linking.py @@ -0,0 +1,83 @@ +from typing import List, Text + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.insights.performance.base import \ + DBTPerformanceInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTProjectInsightResponse) +from datapilot.schemas.constants import CONFIG_METRICS +from datapilot.utils.formatting.utils import numbered_list + + +class DBTChainViewLinking(DBTPerformanceInsight): + """ + Checks if the dbt model has a chain of views in it + """ + + CHAIN_LENGTH_STR = "chain_length" + NAME = "Chain View Linking" + ALIAS = "chain_view_linking" + CHAIN_LENGTH = 4 # Default chain length, can be adjusted as needed + DESCRIPTION = ( + "Analyzes the dbt project to identify long chains of non-physically-materialized models (views and ephemerals)." + " Such long chains can result in increased runtime for models built on top of them due to extended computation" + " and memory usage." + ) + REASON_TO_FLAG = ( + "Long runtime can occur for a model when it is built on top of a long chain of 'non-physically-materialized'" + " models. Identifying these chains is crucial to optimize performance and reduce computation overhead." + ) + FAILURE_MESSAGE = ( + "Detected {number_of_chains} chains of views/ephemeral models in your dbt project that are at least {" + "chain_length} models long. Chains of concern: \n{chain_views}" + ) + RECOMMENDATION = ( + "Consider altering the materialization strategy of some key upstream models to 'table' or 'incremental'. " + "This change can reduce computation time, minimize in-memory data processing, and " + "prevent excessive nesting of views." + ) + + def _build_failure_result( + self, + chain_views: List[List[Text]], + chain_length: int = CHAIN_LENGTH, + ) -> DBTInsightResult: + chains = [" -> ".join(chain_view[::-1]) for chain_view in chain_views] + failure_message = self.FAILURE_MESSAGE.format( + number_of_chains=len(chains), + chain_length=chain_length, + chain_views=numbered_list(chains), + ) + + return DBTInsightResult( + name=self.NAME, + type=self.TYPE, + message=failure_message, + recommendation=self.RECOMMENDATION, + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "chains": chains, + }, + ) + + def _get_chain_length(self): + metrics_config = self.config.get(CONFIG_METRICS, {}) + metric_config = metrics_config.get(self.ALIAS, {}) + # Return the configured fanout threshold or the default if not specified + return metric_config.get(self.CHAIN_LENGTH_STR, self.CHAIN_LENGTH) + + def generate(self, *args, **kwargs) -> List[DBTProjectInsightResponse]: + chain_length = self._get_chain_length() + chain_views = self.find_long_chains(chain_length) + + if chain_views: + insight_result = self._build_failure_result(chain_views) + + return [ + DBTProjectInsightResponse( + package_name=self.project_name, + insights=[insight_result], + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ] + return [] diff --git a/src/datapilot/core/platforms/dbt/insights/performance/exposure_parent_materializations.py b/src/datapilot/core/platforms/dbt/insights/performance/exposure_parent_materializations.py new file mode 100644 index 00000000..fdf5a0d6 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/performance/exposure_parent_materializations.py @@ -0,0 +1,107 @@ +from typing import List, Text + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.constants import SOURCE +from datapilot.core.platforms.dbt.insights.performance.base import \ + DBTPerformanceInsight +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.utils.formatting.utils import numbered_list + + +class DBTExposureParentMaterialization(DBTPerformanceInsight): + """ + Checks if the dbt model has hard coded references to other models. + """ + + NAME = "Exposure Parent Materialization Check" + ALIAS = "exposure_parent_bad_materialization" + DESCRIPTION = ( + "Evaluates the materialization types of parent models of exposures. Ensures that exposures rely on " + "business logic encoded into dbt models or metrics rather than raw sources. Also checks if these parent " + "models are materialized in a manner that ensures performance efficiency, " + "considering their likely heavy use in downstream systems." + ) + REASON_TO_FLAG = ( + "Exposures should depend on transformed data models or metrics, not raw untransformed sources. " + "Moreover, parent models of exposures, being heavily used in downstream systems, " + "should be materialized efficiently to ensure performance when queried." + ) + FAILURE_MESSAGE = ( + "Exposure `{exposure_unique_id}` has parent models with suboptimal materialization types. " + "This could impact performance and clarity in downstream systems." + ) + RECOMMENDATION = ( + "Review the parent models of exposure `{exposure_unique_id}`. If using sources, " + "consider transforming the raw data into a model first. If parent models are views or ephemerals," + " evaluate materializing them as tables to enhance query performance." + ) + + def _build_failure_result( + self, + exposure_unique_id: Text, + source_parents: List[Text], + bad_materializations: List[Text], + ) -> DBTInsightResult: + failure_message = self.FAILURE_MESSAGE.format( + exposure_unique_id=exposure_unique_id, + ) + + failure_message += f" It has some source models as it's parents:\n {numbered_list(source_parents)}" if source_parents else "" + + failure_message += ( + f" The following parent models are not materialized as table " f"or incremental :\n {numbered_list(bad_materializations)}" + if bad_materializations + else "" + ) + + recommendation = self.RECOMMENDATION.format( + exposure_unique_id=exposure_unique_id, + ) + + return DBTInsightResult( + name=self.NAME, + type=self.TYPE, + message=failure_message, + recommendation=recommendation, + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "exposure_unique_id": exposure_unique_id, + "source_parents": source_parents, + "bad_materialization_parents": bad_materializations, + }, + ) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + insights = [] + + for exposure_id, exposure in self.exposures.items(): + bad_materializations = [] + source_parents = [] + for parent_model in exposure.depends_on.nodes: + if parent_model.split(".")[0] == SOURCE: + source_parents.append(parent_model) + else: + node = self.nodes.get(parent_model) + materialization = node.config.materialized if node.config else "not defined" + if node and node.resource_type == AltimateResourceType.model and materialization not in ["table", "incremental"]: + bad_materializations.append(parent_model) + + if source_parents or bad_materializations: + insights.append( + DBTModelInsightResponse( + unique_id=exposure_id, + package_name=exposure.package_name, + path=exposure.path, + original_file_path=exposure.original_file_path, + insight=self._build_failure_result( + exposure_unique_id=exposure.unique_id, + source_parents=source_parents, + bad_materializations=bad_materializations, + ), + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/schema.py b/src/datapilot/core/platforms/dbt/insights/schema.py new file mode 100644 index 00000000..f00e1e82 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/schema.py @@ -0,0 +1,69 @@ +from typing import List, Optional, Text + +from datapilot.core.insights.schema import InsightResponse, InsightResult +from datapilot.core.platforms.dbt.constants import MODEL, PROJECT + +# from src.utils.formatting.utils import get_severity_color, reset_color, bold, underline + + +class DBTInsightResult(InsightResult): + pass + + +class DBTInsightResponse(InsightResponse): + pass + + +class DBTModelInsightResponse(DBTInsightResponse): + unique_id: Text + package_name: Text + path: Text + original_file_path: Text + insight_level: Text = MODEL + + # def get_report(self, do_format=True) -> str: + # divider = "-" * 40 + # report_lines = [ + # f"{bold('Package Name:', do_format)} {self.package_name}", + # f"{bold('Unique ID:', do_format)} {self.unique_id}", + # f"{bold('File Path:', do_format)} {self.original_file_path}", + # f"{underline('Insight Details:', do_format)}", + # f" {bold('Name:', do_format)} {self.insight.name}", + # f" {bold('Severity:', do_format)} {get_severity_color(self.severity)}{self.severity.value}{reset_color(do_format) }", + # f" {bold('Message:', do_format)} {self.insight.message}", + # f" {bold('Recommendation:', do_format)} {self.insight.recommendation}", + # f" {bold('Reason to Flag:', do_format)} {self.insight.reason_to_flag}", + # divider, + # ] + # return "\n".join(report_lines) + + +class DBTProjectInsightResponse(DBTInsightResponse): + package_name: Text + insight_level: Text = PROJECT + insights: List[DBTInsightResult] + insight: Optional[DBTInsightResult] = None + # + # def get_report(self, do_format=True) -> str: + # divider = "-" * 40 + # severity_color = get_severity_color(self.severity) + # report_lines = [ + # f"Package Name: {self.package_name}", + # f"Insight Level: {self.insight_level}", + # divider, + # ] + # + # for insight in self.insights: + # report_lines.extend( + # [ + # f"Insight Name: {insight.name}", + # f"Type: {insight.type}", + # f"Severity: {severity_color}{self.severity.value}{reset_color()}", + # f"Message: {insight.message}", + # f"Recommendation: {insight.recommendation}", + # f"Reason to Flag: {insight.reason_to_flag}", + # divider, + # ] + # ) + # + # return "\n".join(report_lines) diff --git a/src/datapilot/core/platforms/dbt/insights/structure/__init__.py b/src/datapilot/core/platforms/dbt/insights/structure/__init__.py new file mode 100644 index 00000000..355b0d52 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/structure/__init__.py @@ -0,0 +1,4 @@ +from .model_directories_structuire import DBTModelDirectoryStructure +from .model_naming_conventions import DBTModelNamingConvention +from .source_directories_structure import DBTSourceDirectoryStructure +from .test_directory_structure import DBTTestDirectoryStructure diff --git a/src/datapilot/core/platforms/dbt/insights/structure/base.py b/src/datapilot/core/platforms/dbt/insights/structure/base.py new file mode 100644 index 00000000..a606cd08 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/structure/base.py @@ -0,0 +1,30 @@ +from abc import abstractmethod +from typing import Any, Dict, Optional, Text, Tuple + +from datapilot.core.insights.schema import Severity +from datapilot.core.platforms.dbt.insights.base import DBTInsight + + +class DBTStructureInsight(DBTInsight): + NAME = "DBTStructureInsight" + TYPE = "structure" + DEFAULT_SEVERITY = Severity.WARNING + + def __init__(self, config: Optional[Dict[Text, Any]] = None, *args, **kwargs): + self.config = config or {} + super().__init__(*args, **kwargs) + + @abstractmethod + def generate(self, *args, **kwargs) -> dict: + pass + + @classmethod + def has_all_required_data(cls, has_manifest: bool, **kwargs) -> Tuple[bool, str]: + """ + Check if all required data is available for the insight to run. + :param has_manifest: A boolean indicating if manifest is available. + :return: A boolean indicating if all required data is available. + """ + if not has_manifest: + return False, "manifest is required for insight to run." + return True, "" diff --git a/src/datapilot/core/platforms/dbt/insights/structure/model_directories_structuire.py b/src/datapilot/core/platforms/dbt/insights/structure/model_directories_structuire.py new file mode 100644 index 00000000..4ef5ce5b --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/structure/model_directories_structuire.py @@ -0,0 +1,93 @@ +from typing import List, Optional + +from datapilot.config.utils import get_regex_configuration +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.constants import OTHER +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.insights.structure.base import \ + DBTStructureInsight +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.core.platforms.dbt.utils import (_check_model_folder_convention, + classify_model_type) + + +class DBTModelDirectoryStructure(DBTStructureInsight): + """ + DBTModelDirectoryStructure checks if models are placed in the correct directories. + """ + + NAME = "Bad Model Directory Structure" + ALIAS = "model_directory_structure" + DESCRIPTION = ( + "This rule identifies models that are not placed in their correct directories. " + "Proper directory structure is essential for the organization, discoverability, " + "and maintenance of models within the dbt project." + ) + REASON_TO_FLAG = ( + "Placing models in the correct directories is vital for maintaining a structured and " + "efficient data warehouse. Incorrectly placed models can lead to confusion, hinder " + "discoverability, and complicate maintenance and scaling of the dbt project." + ) + FAILURE_MESSAGE = ( + "Incorrect Directory Placement Detected: The model `{model_unique_id}` is incorrectly " + "placed in the current directory. As a `{model_type}` model, it should be located in " + "the `{convention}` directory." + ) + RECOMMENDATION = ( + "To resolve this issue, please move the model `{model_unique_id}` to the `{convention}` " + "directory. This change will align the model's location with the established directory " + "structure, improving organization and ease of access in your dbt project." + ) + + def _build_failure_result(self, model_unique_id: str, model_type: str, convention: Optional[str]) -> DBTInsightResult: + failure_message = self.FAILURE_MESSAGE.format( + model_unique_id=model_unique_id, + model_type=model_type, + convention=convention, + ) + return DBTInsightResult( + name=self.NAME, + type=self.TYPE, + message=failure_message, + recommendation=self.RECOMMENDATION.format(model_unique_id=model_unique_id, convention=convention), + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "model": model_unique_id, + "model_type": model_type, + "convention": convention, + }, + ) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + insights = [] + regex_configuration = get_regex_configuration(self.config) + for node in self.nodes.values(): + if node.resource_type == AltimateResourceType.model: + model_type = classify_model_type(node.name, node.original_file_path, regex_configuration) + if model_type == OTHER: + continue + + valid_convention, message = _check_model_folder_convention( + model_type, + node.original_file_path, + regex_configuration, + node=node, + sources=self.sources, + ) + if not valid_convention: + insights.append( + DBTModelInsightResponse( + unique_id=node.unique_id, + package_name=node.package_name, + path=node.path, + original_file_path=node.original_file_path, + insight=self._build_failure_result( + model_unique_id=node.unique_id, + model_type=model_type, + convention=message, + ), + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/structure/model_naming_conventions.py b/src/datapilot/core/platforms/dbt/insights/structure/model_naming_conventions.py new file mode 100644 index 00000000..e3a48bc1 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/structure/model_naming_conventions.py @@ -0,0 +1,96 @@ +from typing import List, Optional + +from datapilot.config.utils import get_regex_configuration +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.constants import MODEL, OTHER +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.insights.structure.base import \ + DBTStructureInsight +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.core.platforms.dbt.utils import (_check_model_naming_convention, + classify_model_type) + + +class DBTModelNamingConvention(DBTStructureInsight): + """ + DBTModelNamingConvention identifies models that do not follow the naming convention. + """ + + NAME = "Bad Model Naming Convention" + ALIAS = "model_naming_convention_check" + DESCRIPTION = "This rule ensures all models in the data warehouse adhere to a predefined naming convention. " + "A consistent naming convention is crucial for clarity and understanding of the model's purpose, " + "helping to identify the model type (e.g., staging, fact, dimension) and enhancing navigation and " + "maintenance within the dbt project." + REASON_TO_FLAG = ( + "Inconsistent or unclear naming conventions can lead to confusion and errors in querying the data warehouse. " + "A well-defined naming convention clarifies the model type and purpose, promoting better understanding " + "and effective data management. This rule flags models that deviate from established naming standards." + ) + FAILURE_MESSAGE = ( + "Naming Convention Violation Detected: The model `{model_unique_id}` does not comply with the " + "established naming convention. It is identified as a `{model_type}` model, but its name does not " + "reflect the required prefix or convention `{convention}`. Please update the model name to align " + "with the naming standards." + ) + RECOMMENDATION = "Please rename the model `{model_unique_id}` to follow the appropriate naming convention. " + + def _build_failure_result(self, model_unique_id: str, model_type: str, convention: Optional[str]) -> DBTInsightResult: + if model_type != OTHER: + failure_message = self.FAILURE_MESSAGE.format( + model_unique_id=model_unique_id, + model_type=model_type, + convention=convention, + ) + else: + failure_message = ( + "The model `{model_unique_id}` was not classified as any of the known model types. " + "The naming conventions for it may not be appropriate" + ).format(model_unique_id=model_unique_id) + + return DBTInsightResult( + name=self.NAME, + type=self.TYPE, + message=failure_message, + recommendation=self.RECOMMENDATION.format(model_unique_id=model_unique_id), + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "model": model_unique_id, + "model_type": model_type, + "convention": convention, + }, + ) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + insights = [] + regex_configuration = get_regex_configuration(self.config) + for node in self.nodes.values(): + if node.resource_type == AltimateResourceType.model: + model_type = classify_model_type(node.name, node.original_file_path, regex_configuration) + if model_type == OTHER: + insights.append( + DBTModelInsightResponse( + unique_id=node.unique_id, + package_name=node.package_name, + path=node.path, + original_file_path=node.original_file_path, + insight=self._build_failure_result(node.unique_id, model_type, None), + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + continue + valid_name, expected_model_type = _check_model_naming_convention(node.name, model_type, regex_configuration.get(MODEL)) + if not valid_name: + insight_result = self._build_failure_result(node.unique_id, model_type, expected_model_type) + insights.append( + DBTModelInsightResponse( + unique_id=node.unique_id, + package_name=node.package_name, + path=node.path, + original_file_path=node.original_file_path, + insight=insight_result, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/structure/source_directories_structure.py b/src/datapilot/core/platforms/dbt/insights/structure/source_directories_structure.py new file mode 100644 index 00000000..db0de5b0 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/structure/source_directories_structure.py @@ -0,0 +1,82 @@ +from typing import Dict, List, Optional, Text + +from datapilot.config.utils import get_regex_configuration +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.constants import OTHER +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.insights.structure.base import \ + DBTStructureInsight +from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType +from datapilot.core.platforms.dbt.utils import _check_source_folder_convention + + +class DBTSourceDirectoryStructure(DBTStructureInsight): + """ + DBTSourcesDirectoryStructure checks if sources are placed in the correct directories. + """ + + NAME = "Bad Source Directory Structure" + ALIAS = "source_directory_structure" + DESCRIPTION = ( + "This rule checks if sources are placed in the correct directories within the dbt project. " + "Proper directory placement is crucial for better organization and easy searchability of source files." + ) + REASON_TO_FLAG = ( + "Sources need to be organized in the correct directories to ensure an efficient and " + "maintainable data architecture. Proper directory structure facilitates easy navigation, " + "improves readability, and aids in managing the data sources effectively." + ) + FAILURE_MESSAGE = ( + "Inappropriate Directory Placement Detected: The source file for {source_id} is currently " + "placed in an incorrect directory. This can lead to organizational issues and hinder " + "efficient source management." + ) + RECOMMENDATION = ( + "To address this issue, please move the source file for {source_id} to the appropriate " + "directory. The recommended directory structure is {convention}, which aligns with best " + "practices for organizing source files in dbt projects." + ) + + def _build_failure_result(self, model_unique_id: str, convention: Optional[str]) -> DBTInsightResult: + failure_message = self.FAILURE_MESSAGE.format( + source_id=model_unique_id, + ) + return DBTInsightResult( + name=self.NAME, + type=self.TYPE, + message=failure_message, + recommendation=self.RECOMMENDATION.format(source_id=model_unique_id, convention=convention), + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "source_id": model_unique_id, + "convention": convention, + }, + ) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + insights = [] + regex_configuration = get_regex_configuration(self.config) + for source_id, source in self.sources.items(): + valid_convention, expected_directory = _check_source_folder_convention( + source_name=source.source_name, + folder_path=source.original_file_path, + patterns=regex_configuration, + ) + if not valid_convention: + insight = self._build_failure_result( + model_unique_id=source_id, + convention=expected_directory, + ) + insights.append( + DBTModelInsightResponse( + unique_id=source.unique_id, + package_name=source.package_name, + path=source.path, + original_file_path=source.original_file_path, + insight=insight, + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + + return insights diff --git a/src/datapilot/core/platforms/dbt/insights/structure/test_directory_structure.py b/src/datapilot/core/platforms/dbt/insights/structure/test_directory_structure.py new file mode 100644 index 00000000..6830b39c --- /dev/null +++ b/src/datapilot/core/platforms/dbt/insights/structure/test_directory_structure.py @@ -0,0 +1,74 @@ +from typing import List, Optional + +from datapilot.core.insights.utils import get_severity +from datapilot.core.platforms.dbt.insights.schema import ( + DBTInsightResult, DBTModelInsightResponse) +from datapilot.core.platforms.dbt.insights.structure.base import \ + DBTStructureInsight +from datapilot.utils.utils import get_dir_path + + +class DBTTestDirectoryStructure(DBTStructureInsight): + """ + DBTTestDirectoryStructure checks if tests are placed in the correct directories. + """ + + NAME = "Bad Test Directory Structure" + ALIAS = "test_directory_structure" + DESCRIPTION = ( + "This rule checks if tests are correctly placed in the same directories as their corresponding models. " + "Ensuring tests are co-located with their models aids in maintainability and clarity." + ) + REASON_TO_FLAG = ( + "It is important for tests to be placed in the same directory as their corresponding models to maintain " + "a coherent and easy-to-navigate project structure. This practice enhances the ease of understanding " + "and updating tests in parallel with model changes." + ) + FAILURE_MESSAGE = ( + "Incorrect Test Placement Detected: The test `{model_unique_id}` is not in the correct directory. " + "For consistent project structure and easy maintenance, it should be placed in the same directory as " + "its corresponding model." + ) + RECOMMENDATION = ( + "To rectify this, move the test `{model_unique_id}` to the directory `{convention}`, where its corresponding " + "model is located. This adjustment will align your test's location with best practices for" + " project organization." + ) + + def _build_failure_result(self, model_unique_id: str, convention: Optional[str]) -> DBTInsightResult: + failure_message = self.FAILURE_MESSAGE.format( + model_unique_id=model_unique_id, + ) + return DBTInsightResult( + name=self.NAME, + type=self.TYPE, + message=failure_message, + recommendation=self.RECOMMENDATION.format(model_unique_id=model_unique_id, convention=convention), + reason_to_flag=self.REASON_TO_FLAG, + metadata={ + "model": model_unique_id, + "convention": convention, + }, + ) + + def generate(self, *args, **kwargs) -> List[DBTModelInsightResponse]: + insights = [] + for test_id, test in self.tests.items(): + test_file_path = get_dir_path(test_id) + for node_id in test.depends_on.nodes: + node = self.get_node(node_id) + if not node: + continue + expected_dir_path = get_dir_path(node_id) + if expected_dir_path != test_file_path: + insights.append( + DBTModelInsightResponse( + unique_id=test_id, + package_name=test.package_name, + path=test.path, + original_file_path=test.original_file_path, + insight=self._build_failure_result(test_id, expected_dir_path), + severity=get_severity(self.config, self.ALIAS, self.DEFAULT_SEVERITY), + ) + ) + return insights diff --git a/src/datapilot/core/platforms/dbt/schemas/__init__.py b/src/datapilot/core/platforms/dbt/schemas/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/platforms/dbt/schemas/catalog.py b/src/datapilot/core/platforms/dbt/schemas/catalog.py new file mode 100644 index 00000000..3ae58399 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/schemas/catalog.py @@ -0,0 +1,69 @@ +from datetime import datetime +from typing import Dict, List, Optional, Text, Union + +from pydantic.config import Extra +from pydantic.main import BaseModel + + +class AltimateCatalogMetadata(BaseModel): + class Config: + extra = Extra.forbid + + dbt_schema_version: Optional[Text] = "https://schemas.getdbt.com/dbt/catalog/v1.json" + dbt_version: Optional[Text] = "0.19.0" + generated_at: Optional[datetime] = "2021-02-10T04:42:33.680487Z" + invocation_id: Optional[Optional[Text]] = None + env: Optional[Dict[Text, Text]] = {} + + +class AltimateCatalogTableMetadata(BaseModel): + class Config: + extra = Extra.forbid + + type: Text + database: Optional[Optional[Text]] = None + schema_name: Text + name: Text + comment: Optional[Optional[Text]] = None + owner: Optional[Optional[Text]] = None + + +class AltimateCatalogColumnMetadata(BaseModel): + class Config: + extra = Extra.forbid + + type: Text + comment: Optional[Optional[Text]] = None + index: int + name: Text + + +class AltimateCatalogStatsItem(BaseModel): + class Config: + extra = Extra.forbid + + id: Text + label: Text + value: Optional[Optional[Union[bool, Text, float]]] = None + description: Optional[Optional[Text]] = None + include: bool + + +class AltimateCatalogTable(BaseModel): + class Config: + extra = Extra.forbid + + metadata: AltimateCatalogTableMetadata + columns: Dict[Text, AltimateCatalogColumnMetadata] + stats: Dict[Text, AltimateCatalogStatsItem] + unique_id: Optional[Optional[Text]] = None + + +class AltimateCatalogCatalogV1(BaseModel): + class Config: + extra = Extra.forbid + + metadata: AltimateCatalogMetadata + nodes: Dict[Text, AltimateCatalogTable] + sources: Dict[Text, AltimateCatalogTable] + errors: Optional[Optional[List[Text]]] = None diff --git a/src/datapilot/core/platforms/dbt/schemas/manifest.py b/src/datapilot/core/platforms/dbt/schemas/manifest.py new file mode 100644 index 00000000..66f4cca6 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/schemas/manifest.py @@ -0,0 +1,343 @@ +from enum import Enum +from typing import Any, Dict, List, Optional, Union + +from dbt_artifacts_parser.parsers.catalog.catalog_v1 import CatalogV1 +from dbt_artifacts_parser.parsers.manifest.manifest_v1 import ManifestV1 +from dbt_artifacts_parser.parsers.manifest.manifest_v2 import ManifestV2 +from dbt_artifacts_parser.parsers.manifest.manifest_v3 import ManifestV3 +from dbt_artifacts_parser.parsers.manifest.manifest_v4 import ManifestV4 +from dbt_artifacts_parser.parsers.manifest.manifest_v5 import ManifestV5 +from dbt_artifacts_parser.parsers.manifest.manifest_v6 import ManifestV6 +from dbt_artifacts_parser.parsers.manifest.manifest_v7 import ManifestV7 +from dbt_artifacts_parser.parsers.manifest.manifest_v8 import ManifestV8 +from dbt_artifacts_parser.parsers.manifest.manifest_v9 import ManifestV9 +from dbt_artifacts_parser.parsers.manifest.manifest_v10 import ManifestV10 +from dbt_artifacts_parser.parsers.manifest.manifest_v11 import ManifestV11 +from pydantic import BaseModel, Extra + + +class DBTVersion(BaseModel): + MAJOR: int + MINOR: int + PATCH: Optional[int] + + +Manifest = Union[ + ManifestV11, + ManifestV10, + ManifestV9, + ManifestV8, + ManifestV7, + ManifestV6, + ManifestV5, + ManifestV4, + ManifestV3, + ManifestV2, + ManifestV1, +] + +Catalog = Union[CatalogV1] + + +class AltimateDependsOn(BaseModel): + nodes: Optional[List[str]] + macros: Optional[List[str]] + + +class AltimateManifestColumnInfo(BaseModel): + name: str + description: Optional[str] = "" + meta: Optional[Dict[str, Any]] = {} + data_type: Optional[Optional[str]] = None + quote: Optional[Optional[bool]] = None + tags: Optional[List[str]] = [] + + +class AltimateFileHash(BaseModel): + name: str + checksum: str + + +class AltimateResourceType(Enum): + source = "source" + seed = "seed" + snapshot = "snapshot" + analysis = "analysis" + model = "model" + test = "test" + doc = "doc" + operation = "operation" + macro = "macro" + rpc = "rpc" + single_run_operation = "single_run_operation" + hook = "hook" + sql_operation = "sql_operation" + metric = "metric" + exposure = "exposure" + group = "group" + + +class AltimateAccess(Enum): + private = "private" + public = "public" + protected = "protected" + + +class AltimateDBTContract(BaseModel): + class Config: + extra = Extra.forbid + + enforced: Optional[bool] = False + alias_types: Optional[bool] = True + checksum: Optional[Optional[str]] = None + + +class AltimateHook(BaseModel): + class Config: + extra = Extra.forbid + + sql: str + transaction: Optional[bool] = True + index: Optional[Optional[int]] = None + + +# TODO: Need to add the rest of the fields +class AltimateNodeConfig(BaseModel): + class Config: + extra = Extra.allow + + _extra: Optional[Dict[str, Any]] = None + enabled: Optional[bool] = True + alias: Optional[Optional[str]] = None + schema_: Optional[Optional[str]] = None + database: Optional[Optional[str]] = None + tags: Optional[Union[List[str], str]] = None + meta: Optional[Dict[str, Any]] = None + group: Optional[Optional[str]] = None + materialized: Optional[str] = "view" + incremental_strategy: Optional[Optional[str]] = None + persist_docs: Optional[Dict[str, Any]] = None + post_hook: Optional[List[AltimateHook]] + pre_hook: Optional[List[AltimateHook]] + quoting: Optional[Dict[str, Any]] = None + column_types: Optional[Dict[str, Any]] = None + full_refresh: Optional[Optional[bool]] = None + unique_key: Optional[Optional[Union[str, List[str]]]] = None + on_schema_change: Optional[Optional[str]] = "ignore" + + +class AltimateManifestNode(BaseModel): + database: Optional[str] + resource_type: AltimateResourceType + schema_name: str + name: str + package_name: str + path: str + original_file_path: str + unique_id: str + fqn: List[str] + alias: str + config: Optional[AltimateNodeConfig] = None + raw_code: Optional[str] = "" + language: Optional[str] = "sql" + checksum: AltimateFileHash + description: Optional[str] = "" + columns: Optional[Dict[str, AltimateManifestColumnInfo]] = None + relation_name: Optional[Optional[str]] = None + sources: Optional[List[List[str]]] = None + metrics: Optional[List[List[str]]] = None + depends_on: Optional[AltimateDependsOn] = None + compiled_path: Optional[Optional[str]] = None + compiled: Optional[bool] = False + compiled_code: Optional[Optional[str]] = None + access: Optional[AltimateAccess] + contract: Optional[AltimateDBTContract] = None + + +class AltimateQuoting(BaseModel): + database: Optional[Optional[bool]] = None + schema_: Optional[Optional[bool]] = None + identifier: Optional[Optional[bool]] = None + column: Optional[Optional[bool]] = None + + +class AltimateFreshnessThreshold(BaseModel): + warn_after: Optional[Dict] = None + error_after: Optional[Dict] = None + filter: Optional[str] = None + + +class AltimateExternalPartition(BaseModel): + name: Optional[str] = "" + description: Optional[str] = "" + data_type: Optional[str] = "" + meta: Optional[Dict[str, Any]] = {} + + +class AltimateExternalTable(BaseModel): + location: Optional[Optional[str]] = None + file_format: Optional[Optional[str]] = None + row_format: Optional[Optional[str]] = None + tbl_properties: Optional[Optional[str]] = None + partitions: Optional[Optional[List[AltimateExternalPartition]]] = None + + +class AltimateSourceConfig(BaseModel): + enabled: Optional[bool] = True + + +class AltimateManifestSourceNode(BaseModel): + database: Optional[str] + resource_type: AltimateResourceType + schema_name: str + name: str + package_name: str + path: str + original_file_path: str + unique_id: str + fqn: List[str] + source_name: str + source_description: str + loader: str + identifier: str + quoting: Optional[AltimateQuoting] = None + loaded_at_field: Optional[Optional[str]] = None + freshness: Optional[Optional[AltimateFreshnessThreshold]] = None + external: Optional[Optional[AltimateExternalTable]] = None + description: Optional[str] = "" + columns: Optional[Dict[str, AltimateManifestColumnInfo]] = None + meta: Optional[Dict[str, Any]] = None + relation_name: Optional[Optional[str]] = None + source_meta: Optional[Dict[str, Any]] = None + tags: Optional[List[str]] = None + config: Optional[AltimateSourceConfig] = None + patch_path: Optional[Optional[str]] = None + unrendered_config: Optional[Dict[str, Any]] = None + created_at: Optional[float] = None + + +class AltimateExposureType(Enum): + dashboard = "dashboard" + notebook = "notebook" + analysis = "analysis" + ml = "ml" + application = "application" + + +class AltimateOwner(BaseModel): + class Config: + extra = Extra.allow + + _extra: Optional[Dict[str, Any]] = None + email: Optional[Optional[str]] = None + name: Optional[Optional[str]] = None + + +class AltimateMaturityEnum(Enum): + low = "low" + medium = "medium" + high = "high" + + +class AltimateRefArgs(BaseModel): + class Config: + extra = Extra.forbid + + name: str + package: Optional[Optional[str]] = None + version: Optional[Optional[Union[str, float]]] = None + + +class AltimateExposureConfig(BaseModel): + class Config: + extra = Extra.allow + + _extra: Optional[Dict[str, Any]] = None + enabled: Optional[bool] = True + + +class AltimateManifestExposureNode(BaseModel): + name: str + resource_type: AltimateResourceType + package_name: str + path: str + original_file_path: str + unique_id: str + fqn: List[str] + type: AltimateExposureType + owner: AltimateOwner + description: Optional[str] = "" + label: Optional[Optional[str]] = None + maturity: Optional[Optional[AltimateMaturityEnum]] = None + meta: Optional[Dict[str, Any]] = None + tags: Optional[List[str]] = None + config: Optional[AltimateExposureConfig] = None + unrendered_config: Optional[Dict[str, Any]] = None + url: Optional[Optional[str]] = None + depends_on: Optional[AltimateDependsOn] = None + refs: Optional[List[AltimateRefArgs]] = None + sources: Optional[List[List[str]]] = None + metrics: Optional[List[List[str]]] = None + created_at: Optional[float] = None + + +class AltimateTestMetadata(BaseModel): + class Config: + extra = Extra.forbid + + name: str + kwargs: Optional[Dict[str, Any]] = None + namespace: Optional[Optional[str]] = None + + +class AltimateTestConfig(BaseModel): + class Config: + extra = Extra.allow + + _extra: Optional[Dict[str, Any]] = None + enabled: Optional[bool] = True + alias: Optional[Optional[str]] = None + schema_: Optional[Optional[str]] = None + database: Optional[Optional[str]] = None + tags: Optional[Union[List[str], str]] = None + meta: Optional[Dict[str, Any]] = None + group: Optional[Optional[str]] = None + materialized: Optional[str] = "test" + severity: Optional[str] = "ERROR" + store_failures: Optional[Optional[bool]] = None + store_failures_as: Optional[Optional[str]] = None + where: Optional[Optional[str]] = None + limit: Optional[Optional[int]] = None + fail_calc: Optional[str] = "count(*)" + warn_if: Optional[str] = "!= 0" + error_if: Optional[str] = "!= 0" + + +class AltimateManifestTestNode(BaseModel): + test_metadata: Optional[AltimateTestMetadata] = None + test_type: Optional[str] = None + name: str + resource_type: AltimateResourceType + package_name: str + path: str + original_file_path: str + unique_id: str + fqn: List[str] + alias: str + checksum: AltimateFileHash + config: Optional[AltimateTestConfig] = None + _event_status: Optional[Dict[str, Any]] = None + tags: Optional[List[str]] = None + description: Optional[str] = "" + columns: Optional[Dict[str, AltimateManifestColumnInfo]] = None + meta: Optional[Dict[str, Any]] = None + group: Optional[Optional[str]] = None + raw_code: Optional[str] = "" + language: Optional[str] = "sql" + refs: Optional[List[AltimateRefArgs]] = None + sources: Optional[List[List[str]]] = None + metrics: Optional[List[List[str]]] = None + depends_on: Optional[AltimateDependsOn] = None + compiled_path: Optional[Optional[str]] = None + compiled: Optional[bool] = False + compiled_code: Optional[Optional[str]] = None diff --git a/src/datapilot/core/platforms/dbt/utils.py b/src/datapilot/core/platforms/dbt/utils.py new file mode 100644 index 00000000..0dc1d1f7 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/utils.py @@ -0,0 +1,426 @@ +import re +from typing import Dict, Optional, Text, Tuple + +from dbt_artifacts_parser.parser import parse_catalog, parse_manifest + +from datapilot.core.platforms.dbt.constants import (BASE, FOLDER, INTERMEDIATE, + MART, MODEL, OTHER, + STAGING) +from datapilot.core.platforms.dbt.exceptions import \ + AltimateInvalidManifestError +from datapilot.core.platforms.dbt.schemas.manifest import ( + AltimateManifestNode, AltimateManifestSourceNode, Catalog, Manifest) +from datapilot.exceptions.exceptions import (AltimateFileNotFoundError, + AltimateInvalidJSONError) +from datapilot.utils.utils import (extract_dir_name_from_file_path, + extract_folders_in_path, load_json) + +MODEL_TYPE_PATTERNS = { + STAGING: r"^stg_.*", # Example: models starting with 'stg_' + MART: r"^(mrt_|mart_|fct_|dim_).*", # Example: models starting with 'mrt_' or 'mart_' + INTERMEDIATE: r"^int_.*", # Example: models starting with 'int_' + BASE: r"^base_.*", # Example: models starting with 'base_' + # Add other model types with their regex patterns here +} + +FOLDER_MAP = { + STAGING: STAGING, + MART: MART, + INTERMEDIATE: INTERMEDIATE, + BASE: BASE, + # Add other model types with their folder names here +} + + +def combine_dict(dict1: Dict, dict2: Optional[Dict]) -> Dict: + dict2 = dict2 or {} + return {**dict1, **dict2} + + +def load_manifest(manifest_path: Text) -> Manifest: + try: + manifest_dict = load_json(manifest_path) + except FileNotFoundError as e: + raise AltimateFileNotFoundError(f"Manifest file not found: {manifest_path}. Error: {e}") + except ValueError as e: + raise AltimateInvalidJSONError(f"Invalid JSON file: {manifest_path}. Error: {e}") + + try: + manifest: Manifest = parse_manifest(manifest_dict) + except ValueError as e: + raise AltimateInvalidManifestError(f"Invalid manifest file: {manifest_path}. Error: {e}") + + return manifest + + +def load_catalog(catalog_path: Text) -> Catalog: + try: + catalog_dict = load_json(catalog_path) + except FileNotFoundError as e: + raise AltimateFileNotFoundError(f"Manifest file not found: {catalog_path}. Error: {e}") + except ValueError as e: + raise AltimateInvalidJSONError(f"Invalid JSON file: {catalog_path}. Error: {e}") + + try: + catalog: Catalog = parse_catalog(catalog_dict) + except ValueError as e: + raise AltimateInvalidManifestError(f"Invalid manifest file: {catalog_path}. Error: {e}") + + return catalog + + +def load_run_results(run_results_path: Text) -> Manifest: + raise NotImplementedError + + +# TODO: Add tests! +def get_table_name_from_source(source: AltimateManifestSourceNode) -> Text: + db = source.database + schema = source.schema_name + identifier = source.identifier + if db: + return f"{db}.{schema}.{identifier}" + return f"{schema}.{identifier}" + + +def classify_model_type_by_name( + model_name: Text, + model_name_pattern: Optional[Dict[Text, Text]], +): + types_patterns = combine_dict(MODEL_TYPE_PATTERNS, model_name_pattern) + for model_type, pattern in types_patterns.items(): + if re.match(pattern, model_name): + return model_type + + return None + + +def classify_model_type_by_folder(model_path: Text, model_folder_pattern: Optional[Dict[Text, Text]]) -> Text: + folder_patterns = combine_dict(FOLDER_MAP, model_folder_pattern) + dirname = extract_dir_name_from_file_path(model_path) + for model_type, pattern in folder_patterns.items(): + if re.match(pattern, dirname): + return model_type + + return OTHER + + +# TODO: Add tests! +def classify_model_type( + model_name: Text, + folder_path: Text = None, + patterns: Dict[Text, Optional[Dict[Text, Text]]] = None, +) -> Optional[Text]: + """ + Classify the type of a model based on its name using regex patterns. + + :param model_name: The name of the model. + :param types_patterns: A dictionary mapping model types to their regex patterns. + :return: The type of the model or None if no match is found. + """ + type_patterns = patterns.get(MODEL, {}) + model_type = classify_model_type_by_name(model_name, type_patterns) + + if model_type: + return model_type + + if folder_path: + folder_patterns = patterns.get(FOLDER, {}) + model_type = classify_model_type_by_folder(folder_path, folder_patterns) + if model_type: + return model_type + return OTHER # if no pattern matches + + +def _check_model_naming_convention( + model_name: Text, expected_model_type: Text, patterns: Optional[Dict[Text, Text]] +) -> Tuple[bool, Optional[Text]]: + model_patterns = combine_dict(MODEL_TYPE_PATTERNS, patterns) + expected_model_pattern = model_patterns.get(expected_model_type) + if expected_model_pattern: + if re.match(expected_model_pattern, model_name): + return True, None + return False, expected_model_pattern + + +def get_node_source_name( + node: AltimateManifestNode, + sources: Dict[Text, AltimateManifestSourceNode], +) -> Text: + for node_id in node.depends_on.nodes: + if node_id in sources: + return sources[node_id].source_name + + +def _check_mart_convention(folder_patterns, directory_name, node_name): + if re.match(folder_patterns.get(MART, ""), directory_name): + return True, None + return ( + False, + f"*/{folder_patterns.get(MART, '')}/{node_name}.sql", + ) + + +def _staging_error_message(source_name, node_name, staging_pattern): + return f"*/{staging_pattern}/{source_name}/{node_name}.sql" + + +def _check_staging_convention(folder_path, folder_patterns, directory_name, node, sources): + directories = extract_folders_in_path(folder_path) + source_name = get_node_source_name(node, sources) + if not source_name: + return True, None + if directory_name != source_name: + return False, _staging_error_message(source_name, node.name, folder_patterns.get(STAGING, "")) + + staging_pattern = folder_patterns.get(STAGING) + if staging_pattern and len(directories) > 2 and not re.match(staging_pattern, directories[-2]): + return False, _staging_error_message(source_name, node.name, staging_pattern) + + return True, None + + +def _check_source_folder_convention(source_name, folder_path, patterns=Optional[Dict[Text, Dict[Text, Text]]]): + folder_patterns = combine_dict(FOLDER_MAP, patterns.get(FOLDER)) + directories = extract_folders_in_path(folder_path) + directory_name = extract_dir_name_from_file_path(folder_path) + if directory_name != source_name: + return False, f"{folder_patterns.get(STAGING)}/{source_name}/source.yml" + + if len(directories) > 2 and not re.match(folder_patterns.get(STAGING), directories[-2]): + return False, f"{folder_patterns.get(STAGING)}/{source_name}/source.yml" + + return True, None + + +def _check_model_folder_convention( + model_type: str, + folder_path: str, + patterns: Dict[str, Optional[Dict[str, str]]], + node: AltimateManifestNode, + sources: Dict[str, AltimateManifestSourceNode], +) -> Tuple[bool, Optional[str]]: + folder_patterns = patterns.get(FOLDER, {}) or {} + folder_patterns = {**FOLDER_MAP, **folder_patterns} + directory_name = extract_dir_name_from_file_path(folder_path) + if model_type == MART: + return _check_mart_convention(folder_patterns, directory_name, node.name) + + if model_type == STAGING: + return _check_staging_convention(folder_path, folder_patterns, directory_name, node, sources) + + return True, None + + +# TODO: Add tests! +def get_children_map(nodes: Dict[str, AltimateManifestNode]) -> Dict[str, AltimateManifestNode]: + """ + Current manifest contains information about parents + THis gives an information of node to children + + :param nodes: A dictionary of nodes in a manifest. + :return: A dictionary of all the children of a node. + """ + children_map = {} + for node_id, node in nodes.items(): + for parent in node.depends_on.nodes: + children_map.setdefault(parent, set()).add(node_id) + return children_map + + +# TODO: Add tests! +def get_hard_coded_references(sql_code): + """ + Find all hard-coded references in the given SQL code. + + :param sql_code: A string containing the SQL code to be analyzed. + :return: A set of unique hard-coded references found in the SQL code. + """ + # Define regex patterns to match different types of hard-coded references + from_hard_coded_references = { + "from_var_1": """(?ix) + + # first matching group + # from or join followed by at least 1 whitespace character + (from | join)\s + + + # second matching group + # opening {{, 0 or more whitespace character(s), var, 0 or more whitespace character(s), an opening parenthesis, 0 or more whitespace character(s), 1 or 0 quotation mark + ({{\s * var\s * \(\s *[\'\"]?) + + # third matching group + # at least 1 of anything except a parenthesis or quotation mark + ([^)\'\"]+) + + # fourth matching group + # 1 or 0 quotation mark, 0 or more whitespace character(s) + ([\'\"]?\s*) + + # fifth matching group + # a closing parenthesis, 0 or more whitespace character(s), closing }} + (\)\s *}}) + + """, + "from_var_2": """(?ix) + + # first matching group + # from or join followed by at least 1 whitespace character + ( + from | join)\s + + + # second matching group + # opening {{, 0 or more whitespace character(s), var, 0 or more whitespace character(s), an opening parenthesis, 0 or more whitespace character(s), 1 or 0 quotation mark + ({{\s * var\s * \(\s *[\'\"]?) + + # third matching group + # at least 1 of anything except a parenthesis or quotation mark + ([^)\'\"]+) + + # fourth matching group + # 1 or 0 quotation mark, 0 or more whitespace character(s) + ([\'\"]?\s*) + + # fifth matching group + # a comma + (,) + + # sixth matching group + # 0 or more whitespace character(s), 1 or 0 quotation mark + (\s *[\'\"]?) + + # seventh matching group + # at least 1 of anything except a parenthesis or quotation mark + ([^)\'\"]+) + + # eighth matching group + # 1 or 0 quotation mark, 0 or more whitespace character(s) + ([\'\"]?\s*) + + # ninth matching group + # a closing parenthesis, 0 or more whitespace character(s), closing }} + (\)\s *}}) + + """, + "from_table_1": """(?ix) + + # first matching group + # from or join followed by at least 1 whitespace character + ( + from | join)\s + + + # second matching group + # 1 or 0 of (opening bracket, backtick, or quotation mark) + ([\[`\"\']?) + + # third matching group + # at least 1 word character + (\w+) + + # fouth matching group + # 1 or 0 of (closing bracket, backtick, or quotation mark) + ([\]`\"\']?) + + # fifth matching group + # a period + (\.) + + # sixth matching group + # 1 or 0 of (opening bracket, backtick, or quotation mark) + ([\[`\"\']?) + + # seventh matching group + # at least 1 word character + (\w+) + + # eighth matching group + # 1 or 0 of (closing bracket, backtick, or quotation mark) folowed by a whitespace character or end of string + ([\]`\"\']?)(?=\s|$) + + """, + "from_table_2": """(?ix) + + # first matching group + # from or join followed by at least 1 whitespace character + ( + from | join)\s + + + # second matching group + # 1 or 0 of (opening bracket, backtick, or quotation mark) + ([\[`\"\']?) + + # third matching group + # at least 1 word character + (\w+) + # fouth matching group + # 1 or 0 of (closing bracket, backtick, or quotation mark) + ([\]`\"\']?) + + # fifth matching group + # a period + (\.) + + # sixth matching group + # 1 or 0 of (opening bracket, backtick, or quotation mark) + ([\[`\"\']?) + + # seventh matching group + # at least 1 word character + (\w+) + + # eighth matching group + # 1 or 0 of (closing bracket, backtick, or quotation mark) + ([\]`\"\']?) + + # ninth matching group + # a period + (\.) + + # tenth matching group + # 1 or 0 of (closing bracket, backtick, or quotation mark) + ([\[`\"\']?) + + # eleventh matching group + # at least 1 word character + (\w+) + + # twelfth matching group + # 1 or 0 of (closing bracket, backtick, or quotation mark) folowed by a whitespace character or end of string + ([\]`\"\']?)(?=\s|$) + + """, + "from_table_3": """(?ix) + + # first matching group + # from or join followed by at least 1 whitespace character + ( + from | join)\s + + + # second matching group + # 1 of (opening bracket, backtick, or quotation mark) + ([\[`\"\']) + + # third matching group + # at least 1 word character or space + ([\w]+) + + # fourth matching group + # 1 of (closing bracket, backtick, or quotation mark) folowed by a whitespace character or end of string + ([\]`\"\'])(?=\s|$) + + """, + } + + # Set to store all unique hard-coded references + hard_coded_references = set() + for regex_name, regex_pattern in from_hard_coded_references.items(): + # Compile the regex pattern + all_regex_matches = re.findall(regex_pattern, sql_code) + + # Find all matches in the SQL code + # Process each match + for match in all_regex_matches: + # Extract all groups except the first one and join them + raw_reference = "".join(match[1:]).strip() # + + hard_coded_references.add(raw_reference) + return hard_coded_references diff --git a/src/datapilot/core/platforms/dbt/wrappers/__init__.py b/src/datapilot/core/platforms/dbt/wrappers/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/platforms/dbt/wrappers/catalog/__init__.py b/src/datapilot/core/platforms/dbt/wrappers/catalog/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/platforms/dbt/wrappers/catalog/v1/__init__.py b/src/datapilot/core/platforms/dbt/wrappers/catalog/v1/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/platforms/dbt/wrappers/catalog/v1/wrapper.py b/src/datapilot/core/platforms/dbt/wrappers/catalog/v1/wrapper.py new file mode 100644 index 00000000..7ab938f3 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/wrappers/catalog/v1/wrapper.py @@ -0,0 +1,19 @@ +from dbt_artifacts_parser.parsers.catalog.catalog_v1 import CatalogV1 + +from datapilot.core.platforms.dbt.wrappers.catalog.wrapper import \ + BaseCatalogWrapper + + +class CatalogV1Wrapper(BaseCatalogWrapper): + def __init__(self, catalog: CatalogV1): + self.catalog = catalog + + def get_schema(self): + nodes_with_schemas = {} + for node_id, catalog_table_node in self.catalog.nodes.items(): + nodes_with_schemas[node_id] = {column_name: column_node.type for column_name, column_node in catalog_table_node.columns.items()} + for source_id, catalog_source_node in self.catalog.sources.items(): + nodes_with_schemas[source_id] = { + column_name: column_node.type for column_name, column_node in catalog_source_node.columns.items() + } + return nodes_with_schemas diff --git a/src/datapilot/core/platforms/dbt/wrappers/catalog/wrapper.py b/src/datapilot/core/platforms/dbt/wrappers/catalog/wrapper.py new file mode 100644 index 00000000..aefe1ed3 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/wrappers/catalog/wrapper.py @@ -0,0 +1,9 @@ +from abc import ABC +from typing import Dict, Text + + +class BaseCatalogWrapper(ABC): + pass + + def get_schema(self) -> Dict[Text, Dict[Text, Text]]: + pass diff --git a/src/datapilot/core/platforms/dbt/wrappers/manifest/__init__.py b/src/datapilot/core/platforms/dbt/wrappers/manifest/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/platforms/dbt/wrappers/manifest/v11/__init__.py b/src/datapilot/core/platforms/dbt/wrappers/manifest/v11/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/platforms/dbt/wrappers/manifest/v11/schemas.py b/src/datapilot/core/platforms/dbt/wrappers/manifest/v11/schemas.py new file mode 100644 index 00000000..92a48183 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/wrappers/manifest/v11/schemas.py @@ -0,0 +1,31 @@ +from typing import Dict, Type, Union + +from dbt_artifacts_parser.parsers.manifest.manifest_v11 import ( + AnalysisNode, Exposure, GenericTestNode, HookNode, ModelNode, RPCNode, + SeedNode, SingularTestNode, SnapshotNode, SourceDefinition, SqlNode) + +from datapilot.core.platforms.dbt.constants import GENERIC, SINGULAR + +ManifestNode = Union[ + AnalysisNode, + SingularTestNode, + HookNode, + ModelNode, + RPCNode, + SqlNode, + GenericTestNode, + SnapshotNode, + SeedNode, +] + +SourceNode = Union[SourceDefinition] + +ExposureNode = Union[Exposure] + +TestNode = Union[GenericTestNode, SingularTestNode] + + +TEST_TYPE_TO_NODE_MAP: dict[str, Type[GenericTestNode | SingularTestNode]] = { + GENERIC: GenericTestNode, + SINGULAR: SingularTestNode, +} diff --git a/src/datapilot/core/platforms/dbt/wrappers/manifest/v11/wrapper.py b/src/datapilot/core/platforms/dbt/wrappers/manifest/v11/wrapper.py new file mode 100644 index 00000000..0d8ea9e2 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/wrappers/manifest/v11/wrapper.py @@ -0,0 +1,276 @@ +from typing import Dict, Set, Text, Union + +from dbt_artifacts_parser.parsers.manifest.manifest_v11 import ( + GenericTestNode, ManifestV11, SingularTestNode) + +from datapilot.core.platforms.dbt.constants import (GENERIC, OTHER_TEST_NODE, + SEED, SINGULAR) +from datapilot.core.platforms.dbt.schemas.manifest import ( + AltimateDBTContract, AltimateDependsOn, AltimateExposureType, + AltimateExternalTable, AltimateFileHash, AltimateFreshnessThreshold, + AltimateManifestColumnInfo, AltimateManifestExposureNode, + AltimateManifestNode, AltimateManifestSourceNode, AltimateManifestTestNode, + AltimateMaturityEnum, AltimateNodeConfig, AltimateOwner, AltimateQuoting, + AltimateRefArgs, AltimateResourceType, AltimateSourceConfig, + AltimateTestConfig, AltimateTestMetadata) +from datapilot.core.platforms.dbt.wrappers.manifest.v11.schemas import ( + TEST_TYPE_TO_NODE_MAP, ExposureNode, ManifestNode, SourceNode, TestNode) +from datapilot.core.platforms.dbt.wrappers.manifest.wrapper import \ + BaseManifestWrapper + + +class ManifestV11Wrapper(BaseManifestWrapper): + def __init__(self, manifest: ManifestV11): + self.manifest = manifest + + def _get_node(self, node: ManifestNode) -> AltimateManifestNode: + ( + sources, + metrics, + compiled_path, + compiled, + compiled_code, + depends_on_nodes, + raw_code, + language, + contract, + ) = ([], [], None, None, None, None, "", "", None) + if node.resource_type.value != SEED: + sources = node.sources + metrics = node.metrics + depends_on_nodes = node.depends_on.nodes + compiled_path = node.compiled_path + compiled = node.compiled + raw_code = node.raw_code + language = node.language + contract = AltimateDBTContract(**node.contract.__dict__) if node.contract else None + + return AltimateManifestNode( + database=node.database, + schema_name=node.schema_, + name=node.name, + resource_type=AltimateResourceType(node.resource_type.value), + package_name=node.package_name, + path=node.path, + description=node.description, + original_file_path=node.original_file_path, + unique_id=node.unique_id, + fqn=node.fqn, + alias=node.alias, + raw_code=raw_code, + language=language, + config=AltimateNodeConfig(**node.config.__dict__) if node.config else None, + checksum=AltimateFileHash( + name=node.checksum.name, + checksum=node.checksum.checksum, + ), + columns={ + name: AltimateManifestColumnInfo( + name=column.name, + description=column.description, + meta=column.meta, + data_type=column.data_type, + quote=column.quote, + tags=column.tags, + ) + for name, column in node.columns.items() + }, + relation_name=node.relation_name, + sources=sources, + metrics=metrics, + depends_on=AltimateDependsOn( + nodes=depends_on_nodes, + macros=node.depends_on.macros, + ), + compiled_path=compiled_path, + compiled=compiled, + compiled_code=compiled_code, + contract=contract, + ) + + def _get_source(self, source: SourceNode) -> AltimateManifestSourceNode: + return AltimateManifestSourceNode( + database=source.database, + resource_type=AltimateResourceType(source.resource_type.value), + schema_name=source.schema_, + name=source.name, + package_name=source.package_name, + path=source.path, + original_file_path=source.original_file_path, + unique_id=source.unique_id, + fqn=source.fqn, + source_name=source.source_name, + source_description=source.source_description, + loader=source.loader, + identifier=source.identifier, + quoting=AltimateQuoting(**source.quoting.dict()) if source.quoting else None, + loaded_at_field=source.loaded_at_field, + freshness=AltimateFreshnessThreshold(**source.freshness.dict()) if source.freshness else None, + external=AltimateExternalTable(**source.external.dict()) if source.external else None, + description=source.description, + columns={ + name: AltimateManifestColumnInfo( + name=column.name, + description=column.description, + meta=column.meta, + data_type=column.data_type, + quote=column.quote, + tags=column.tags, + ) + for name, column in source.columns.items() + }, + meta=source.meta, + relation_name=source.relation_name, + source_meta=source.source_meta, + tags=source.tags, + config=AltimateSourceConfig(**source.config.dict()) if source.config else None, + patch_path=source.patch_path, + unrendered_config=source.unrendered_config, + created_at=source.created_at, + ) + + def _get_exposure(self, exposure: ExposureNode) -> AltimateManifestExposureNode: + return AltimateManifestExposureNode( + name=exposure.name, + resource_type=exposure.resource_type, + package_name=exposure.package_name, + path=exposure.path, + original_file_path=exposure.original_file_path, + unique_id=exposure.unique_id, + fqn=exposure.fqn, + type=AltimateExposureType(exposure.type.value), + owner=AltimateOwner(**exposure.owner.dict()) if exposure.owner else None, + description=exposure.description, + label=exposure.label, + maturity=AltimateMaturityEnum(exposure.maturity.value), + meta=exposure.meta, + tags=exposure.tags, + config=AltimateSourceConfig(**exposure.config.dict()) if exposure.config else None, + unrendered_config=exposure.unrendered_config, + url=exposure.url, + depends_on=AltimateDependsOn( + nodes=exposure.depends_on.nodes, + macros=exposure.depends_on.macros, + ), + refs=[AltimateRefArgs(**ref.dict()) for ref in exposure.refs] if exposure.refs else None, + sources=exposure.sources, + metrics=exposure.metrics, + created_at=exposure.created_at, + ) + + def _get_tests(self, test: TestNode) -> AltimateManifestTestNode: + if isinstance(test, GenericTestNode): + test_type = GENERIC + elif isinstance(test, SingularTestNode): + test_type = SINGULAR + else: + test_type = OTHER_TEST_NODE + return AltimateManifestTestNode( + test_metadata=AltimateTestMetadata(**test.test_metadata.dict()) if test.test_metadata else None, + test_type=test_type, + name=test.name, + resource_type=AltimateResourceType(test.resource_type.value), + package_name=test.package_name, + path=test.path, + original_file_path=test.original_file_path, + unique_id=test.unique_id, + fqn=test.fqn, + alias=test.alias, + checksum=AltimateFileHash( + name=test.checksum.name, + checksum=test.checksum.checksum, + ), + config=AltimateTestConfig(**test.config.dict()) if test.config else None, + description=test.description, + tags=test.tags, + columns={ + name: AltimateManifestColumnInfo( + name=column.name, + description=column.description, + meta=column.meta, + data_type=column.data_type, + quote=column.quote, + tags=column.tags, + ) + for name, column in test.columns.items() + } + if test.columns + else None, + meta=test.meta, + relation_name=test.relation_name, + group=test.group, + raw_code=test.raw_code, + language=test.language, + refs=[AltimateRefArgs(**ref.dict()) for ref in test.refs] if test.refs else None, + sources=test.sources, + metrics=test.metrics, + depends_on=AltimateDependsOn( + nodes=test.depends_on.nodes, + macros=test.depends_on.macros, + ), + compiled_path=test.compiled_path, + compiled=test.compiled, + compiled_code=test.compiled_code, + ) + + def get_nodes( + self, + ) -> Dict[Text, AltimateManifestNode]: + nodes = {} + for node in self.manifest.nodes.values(): + if ( + node.resource_type + in [ + AltimateResourceType.seed, + AltimateResourceType.test, + ] + or node.package_name != self.get_package() + ): + continue + nodes[node.unique_id] = self._get_node(node) + return nodes + + def get_package(self) -> Text: + return self.manifest.metadata.project_name + + def get_sources(self) -> Dict[Text, AltimateManifestSourceNode]: + sources = {} + for source in self.manifest.sources.values(): + sources[source.unique_id] = self._get_source(source) + return sources + + def get_exposures(self) -> Dict[Text, AltimateManifestExposureNode]: + exposures = {} + for exposure in self.manifest.exposures.values(): + exposures[exposure.unique_id] = self._get_exposure(exposure) + return exposures + + def get_tests(self, types=None) -> Dict[Text, AltimateManifestTestNode]: + tests = {} + if types is None: + types = TestNode + else: + type_list = [TEST_TYPE_TO_NODE_MAP.get(t) for t in types if t in TEST_TYPE_TO_NODE_MAP] + types = Union[tuple(type_list)] + + for node in self.manifest.nodes.values(): + if node.resource_type.value != AltimateResourceType.test.value: + continue + if isinstance(node, types or TestNode): + tests[node.unique_id] = self._get_tests(node) + return tests + + def parent_to_child_map(self, nodes: Dict[Text, AltimateManifestNode]) -> Dict[Text, Set[Text]]: + """ + Current manifest contains information about parents + THis gives an information of node to childre + :param nodes: A dictionary of nodes in a manifest. + :return: A dictionary of all the children of a node. + """ + children_map = {} + for node_id, node in nodes.items(): + if node_id not in children_map: + children_map[node_id] = set() + for parent in node.depends_on.nodes or []: + children_map.setdefault(parent, set()).add(node_id) + return children_map diff --git a/src/datapilot/core/platforms/dbt/wrappers/manifest/wrapper.py b/src/datapilot/core/platforms/dbt/wrappers/manifest/wrapper.py new file mode 100644 index 00000000..45af82b8 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/wrappers/manifest/wrapper.py @@ -0,0 +1,26 @@ +from abc import ABC +from typing import Dict, Set, Text + +from datapilot.core.platforms.dbt.schemas.manifest import ( + AltimateManifestExposureNode, AltimateManifestNode, + AltimateManifestSourceNode, AltimateManifestTestNode) + + +class BaseManifestWrapper(ABC): + def get_nodes(self) -> Dict[Text, AltimateManifestNode]: + pass + + def get_package(self) -> str: + pass + + def get_sources(self) -> Dict[Text, AltimateManifestSourceNode]: + pass + + def get_exposures(self) -> Dict[Text, AltimateManifestExposureNode]: + pass + + def parent_to_child_map(self, nodes: Dict[Text, AltimateManifestNode]) -> Dict[Text, Set[Text]]: + pass + + def get_tests(self, types=None) -> Dict[Text, AltimateManifestTestNode]: + pass diff --git a/src/datapilot/core/platforms/dbt/wrappers/run_results/__init__.py b/src/datapilot/core/platforms/dbt/wrappers/run_results/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/core/platforms/dbt/wrappers/run_results/run_results.py b/src/datapilot/core/platforms/dbt/wrappers/run_results/run_results.py new file mode 100644 index 00000000..e5d18bd5 --- /dev/null +++ b/src/datapilot/core/platforms/dbt/wrappers/run_results/run_results.py @@ -0,0 +1,41 @@ +from abc import ABC + +from dbt_artifacts_parser.parsers.run_results.run_results_v1 import \ + RunResultsV1 +from dbt_artifacts_parser.parsers.run_results.run_results_v2 import \ + RunResultsV2 +from dbt_artifacts_parser.parsers.run_results.run_results_v3 import \ + RunResultsV3 +from dbt_artifacts_parser.parsers.run_results.run_results_v4 import \ + RunResultsV4 +from dbt_artifacts_parser.parsers.run_results.run_results_v5 import \ + RunResultsV5 + + +class BaseRunResultsWrapper(ABC): + pass + + +class RunResultsV1Wrapper(BaseRunResultsWrapper): + def __init__(self, run_results: RunResultsV1): + self.run_results = run_results + + +class RunResultsV2Wrapper(BaseRunResultsWrapper): + def __init__(self, run_results: RunResultsV2): + self.run_results = run_results + + +class RunResultsV3Wrapper(BaseRunResultsWrapper): + def __init__(self, run_results: RunResultsV3): + self.run_results = run_results + + +class RunResultsV4Wrapper(BaseRunResultsWrapper): + def __init__(self, run_results: RunResultsV4): + self.run_results = run_results + + +class RunResultsV5Wrapper(BaseRunResultsWrapper): + def __init__(self, run_results: RunResultsV5): + self.run_results = run_results diff --git a/src/datapilot/exceptions/__init__.py b/src/datapilot/exceptions/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/exceptions/exceptions.py b/src/datapilot/exceptions/exceptions.py new file mode 100644 index 00000000..49ac1bba --- /dev/null +++ b/src/datapilot/exceptions/exceptions.py @@ -0,0 +1,10 @@ +class AltimateFileNotFoundError(Exception): + pass + + +class AltimateInvalidJSONError(Exception): + pass + + +class AltimateNotSupportedError(Exception): + pass diff --git a/src/datapilot/schemas/__init__.py b/src/datapilot/schemas/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/schemas/constants.py b/src/datapilot/schemas/constants.py new file mode 100644 index 00000000..5dcec8ce --- /dev/null +++ b/src/datapilot/schemas/constants.py @@ -0,0 +1,4 @@ +CONFIG_METRICS = "insights" +CONFIG_MODEL_TYPE_PATTERNS = "model_type_patterns" +CONFIG_FOLDER_TYPE_PATTERNS = "folder_type_patterns" +CONFIG_SEVERITY = "severity" diff --git a/src/datapilot/schemas/sql.py b/src/datapilot/schemas/sql.py new file mode 100644 index 00000000..6afd8598 --- /dev/null +++ b/src/datapilot/schemas/sql.py @@ -0,0 +1,10 @@ +from enum import Enum + + +class Dialect(Enum): + SNOWFLAKE = "snowflake" + POSTGRES = "postgres" + REDSHIFT = "redshift" + MYSQL = "mysql" + BIGQUERY = "bigquery" + OTHERS = "others" diff --git a/src/datapilot/utils/__init__.py b/src/datapilot/utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/utils/formatting/__init__.py b/src/datapilot/utils/formatting/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/datapilot/utils/formatting/utils.py b/src/datapilot/utils/formatting/utils.py new file mode 100644 index 00000000..9bda63e6 --- /dev/null +++ b/src/datapilot/utils/formatting/utils.py @@ -0,0 +1,59 @@ +from tabulate import tabulate + +from datapilot.core.insights.schema import Severity + +RED = "\033[91m" +YELLOW = "\033[93m" +BLUE = "\033[94m" +NO_COLOR = "\033[0m" + +BOLD = "\033[1m" +UNDERLINE = "\033[4m" +ITALIC = "\033[3m" + + +def numbered_list(items): + return "\n".join(f"{i}. {item}" for i, item in enumerate(items, 1)) + + +def get_severity_color(severity: Severity): + colors = { + Severity.ERROR: RED, + Severity.WARNING: YELLOW, + Severity.INFO: BLUE, + } + return colors.get(severity, NO_COLOR) # Default to no color + + +def reset_color(do_format=True): + return NO_COLOR if do_format else "" + + +def bold(text, do_format=True): + return f"{BOLD if do_format else ''}{text}{NO_COLOR if do_format else ''}" + + +def underline(text, do_format=True): + return f"{UNDERLINE if do_format else ''}{text}{NO_COLOR if do_format else ''}" + + +def italic(text, do_format=True): + return f"{ITALIC if do_format else ''}{text}{NO_COLOR if do_format else ''}" + + +def tabulate_data(data, headers, tablefmt="grid"): + return tabulate( + data, + headers=headers, + tablefmt=tablefmt, + maxcolwidths=[None, None, None, 60, 60, 60], + ) + + +def color_text(text, color): + return f"{color}{text}{NO_COLOR}" + + +def color_based_on_severity(severity: Severity): + color = get_severity_color(severity) + return color_text(severity.value, color) diff --git a/src/datapilot/utils/utils.py b/src/datapilot/utils/utils.py new file mode 100644 index 00000000..8c7146e7 --- /dev/null +++ b/src/datapilot/utils/utils.py @@ -0,0 +1,41 @@ +import json +import os +from typing import Dict, Text + + +def load_json(file_path: Text) -> Dict: + try: + with open(file_path) as f: + return json.load(f) + except FileNotFoundError: + raise + except json.decoder.JSONDecodeError: + raise ValueError(f"Invalid JSON file: {file_path}") + + +def extract_dir_name_from_file_path(path: Text) -> Text: + # Handle both Windows and Linux paths using os.path + # Get root directory name + return os.path.basename(os.path.dirname(path)) + + +def extract_folders_in_path(path: str) -> list: + # Split the path into parts + path_parts = path.split(os.path.sep) + + # Exclude the last part if it's a file (has a file extension) + if "." in path_parts[-1]: + path_parts = path_parts[:-1] + path_parts = [part for part in path_parts if part != ""] + return path_parts + + +def get_dir_path(path: str) -> str: + """ + Get the directory path of a file path. + For example, if the path is /a/b/c/d.txt, the directory path is /a/b/c + + :param path: + :return: + """ + return os.path.dirname(path) diff --git a/tests/core/__init__.py b/tests/core/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/core/platform/__init__.py b/tests/core/platform/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/core/platform/dbt/__init__.py b/tests/core/platform/dbt/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/core/platform/dbt/test_utils.py b/tests/core/platform/dbt/test_utils.py new file mode 100644 index 00000000..97ca164a --- /dev/null +++ b/tests/core/platform/dbt/test_utils.py @@ -0,0 +1,139 @@ +import pytest + +from datapilot.core.platforms.dbt.constants import (BASE, INTERMEDIATE, MART, + OTHER, STAGING) +from datapilot.core.platforms.dbt.utils import (MODEL_TYPE_PATTERNS, + _check_model_naming_convention, + classify_model_type_by_folder, + classify_model_type_by_name, + get_hard_coded_references) + +test_cases = [ + # Test with a simple FROM clause + ("SELECT * FROM table1", set()), + # Test with a JOIN clause + ("SELECT * FROM table1 JOIN table2", set()), + # Test with hard-coded references using {{ var() }} + ("SELECT * FROM {{ var('schema.table') }}", {"{{ var('schema.table') }}"}), + # Test with more complex SQL code + ( + """ + SELECT * + FROM schema.table1 + JOIN schema.table2 ON table1.id = table2.id + WHERE table1.column = 'value' + """, + {"schema.table1", "schema.table2"}, + ), + ( + """ + SELECT * FROM {{ ref('schema.table1') }} JOIN {{ ref('schema.table2') }} ON table1.id = table2.id + """, + set(), + ), + ( + """ + SELECT * FROM {{ ref('schema.table1') }} JOIN a.b ON table1.id = table2.id + """, + {"a.b"}, + ), +] + + +@pytest.mark.parametrize("sql_code,expected", test_cases) +def test_get_hard_coded_references(sql_code, expected): + assert get_hard_coded_references(sql_code) == expected + + +# Define the test cases +# Each test case includes: model_path, model_folder_pattern (optional), expected_output +test_cases = [ + # Test cases without additional folder patterns + ("/path/to/staging/model_file.sql", None, STAGING), + ("/path/to/mart/model_file.sql", None, MART), + ("/path/to/intermediate/model_file.sql", None, INTERMEDIATE), + ("/path/to/base/model_file.sql", None, BASE), + ("/path/to/other/model_fil.sql", None, OTHER), + ("/path/to/base/model_fil", None, BASE), + # Test cases with additional folder patterns + ("/path/to/custom/model_file.sql", {"CUSTOM": "custom"}, "CUSTOM"), + ("/path/to/unknown/model_file.sql", {"CUSTOM": "custom"}, OTHER), + ("/path/to/unknown/model_file", {"CUSTOM": "custom"}, OTHER), + # OVerride the default folder patterns + ("/path/to/staging/model_file.sql", {STAGING: "^staging_.*"}, OTHER), + ("/path/to/staging_1/model_file.sql", {STAGING: "^staging_.*"}, STAGING), + ("/path/to/staging_1/model_file.sql", {STAGING: "^staging_.*"}, STAGING), + ( + "/path/to/staging_1/model_file.sql", + {STAGING: "^staging_.*", OTHER: "^other_.*"}, + STAGING, + ), + ( + "/path/to/other_1/model_file.sql", + {STAGING: "^staging_.*", OTHER: "^other_.*"}, + OTHER, + ), +] + + +@pytest.mark.parametrize("model_path, model_folder_pattern, expected", test_cases) +def test_classify_model_type_by_folder(model_path, model_folder_pattern, expected): + assert classify_model_type_by_folder(model_path, model_folder_pattern) == expected + + +test_cases = [ + # Test cases without additional patterns + ("stg_example_model", None, STAGING), + ("mrt_example_model", None, MART), + ("mart_example_model", None, MART), + ("fct_example_model", None, MART), + ("dim_example_model", None, MART), + ("int_example_model", None, INTERMEDIATE), + ("base_example_model", None, BASE), + ("unmatched_model", None, None), + # Test cases with additional patterns + ("custom_stg_model", {"CUSTOM": "^custom_.*"}, "CUSTOM"), + ("custom_model", {"CUSTOM": "^custom_.*"}, "CUSTOM"), + # Overriding the default pattern + ("stg_example_model", {STAGING: "^staging_.*"}, None), + ("staging_example_model", {STAGING: "^staging_.*"}, STAGING), + # Overriding the default pattern with a custom pattern + ("stg_example_model", {STAGING: "^custom_.*"}, None), +] + + +@pytest.mark.parametrize("model_name, model_name_pattern, expected", test_cases) +def test_classify_model_type_by_name(model_name, model_name_pattern, expected): + assert classify_model_type_by_name(model_name, model_name_pattern) == expected + + +test_cases = [ + # Valid model names + ("stg_model", STAGING, None, (True, None)), + ("mrt_model", MART, None, (True, None)), + ("int_model", INTERMEDIATE, None, (True, None)), + ("base_model", BASE, None, (True, None)), + # Invalid model names + ("invalid_stg_model", STAGING, None, (False, MODEL_TYPE_PATTERNS[STAGING])), + ("invalid_mrt_model", MART, None, (False, MODEL_TYPE_PATTERNS[MART])), + ( + "invalid_int_model", + INTERMEDIATE, + None, + (False, MODEL_TYPE_PATTERNS[INTERMEDIATE]), + ), + ("invalid_base_model", BASE, None, (False, MODEL_TYPE_PATTERNS[BASE])), + # Test cases with additional patterns + ("custom_model", "CUSTOM", {"CUSTOM": r"^custom_.*"}, (True, None)), + ( + "invalid_custom_model", + "CUSTOM", + {"CUSTOM": r"^custom_.*"}, + (False, r"^custom_.*"), + ), +] + + +@pytest.mark.parametrize("model_name, expected_model_type, patterns, expected", test_cases) +def test_check_model_naming_convention(model_name, expected_model_type, patterns, expected): + assert _check_model_naming_convention(model_name, expected_model_type, patterns) == expected diff --git a/tests/data/catalog_v1.json b/tests/data/catalog_v1.json new file mode 100644 index 00000000..e6f1649c --- /dev/null +++ b/tests/data/catalog_v1.json @@ -0,0 +1,5233 @@ +{ + "metadata": { + "dbt_schema_version": "https://schemas.getdbt.com/dbt/catalog/v1.json", + "dbt_version": "1.7.4", + "generated_at": "2024-01-13T01:22:34.335584Z", + "invocation_id": "4cc35bf3-4c5a-4af6-b569-1d16b145a046", + "env": {} + }, + "nodes": { + "model.elementary.dbt_source_freshness_results": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "DBT_SOURCE_FRESHNESS_RESULTS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "SOURCE_FRESHNESS_EXECUTION_ID": { + "type": "TEXT", + "index": 1, + "name": "SOURCE_FRESHNESS_EXECUTION_ID", + "comment": null + }, + "UNIQUE_ID": { + "type": "TEXT", + "index": 2, + "name": "UNIQUE_ID", + "comment": null + }, + "MAX_LOADED_AT": { + "type": "TEXT", + "index": 3, + "name": "MAX_LOADED_AT", + "comment": null + }, + "SNAPSHOTTED_AT": { + "type": "TEXT", + "index": 4, + "name": "SNAPSHOTTED_AT", + "comment": null + }, + "GENERATED_AT": { + "type": "TEXT", + "index": 5, + "name": "GENERATED_AT", + "comment": null + }, + "CREATED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 6, + "name": "CREATED_AT", + "comment": null + }, + "MAX_LOADED_AT_TIME_AGO_IN_S": { + "type": "FLOAT", + "index": 7, + "name": "MAX_LOADED_AT_TIME_AGO_IN_S", + "comment": null + }, + "STATUS": { + "type": "TEXT", + "index": 8, + "name": "STATUS", + "comment": null + }, + "ERROR": { + "type": "TEXT", + "index": 9, + "name": "ERROR", + "comment": null + }, + "COMPILE_STARTED_AT": { + "type": "TEXT", + "index": 10, + "name": "COMPILE_STARTED_AT", + "comment": null + }, + "COMPILE_COMPLETED_AT": { + "type": "TEXT", + "index": 11, + "name": "COMPILE_COMPLETED_AT", + "comment": null + }, + "EXECUTE_STARTED_AT": { + "type": "TEXT", + "index": 12, + "name": "EXECUTE_STARTED_AT", + "comment": null + }, + "EXECUTE_COMPLETED_AT": { + "type": "TEXT", + "index": 13, + "name": "EXECUTE_COMPLETED_AT", + "comment": null + }, + "INVOCATION_ID": { + "type": "TEXT", + "index": 14, + "name": "INVOCATION_ID", + "comment": null + }, + "WARN_AFTER": { + "type": "TEXT", + "index": 15, + "name": "WARN_AFTER", + "comment": null + }, + "ERROR_AFTER": { + "type": "TEXT", + "index": 16, + "name": "ERROR_AFTER", + "comment": null + }, + "FILTER": { + "type": "TEXT", + "index": 17, + "name": "FILTER", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 0, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 0, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-02 17:57UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.dbt_source_freshness_results" + }, + "model.elementary.dbt_exposures": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "DBT_EXPOSURES", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "UNIQUE_ID": { + "type": "TEXT", + "index": 1, + "name": "UNIQUE_ID", + "comment": null + }, + "NAME": { + "type": "TEXT", + "index": 2, + "name": "NAME", + "comment": null + }, + "MATURITY": { + "type": "TEXT", + "index": 3, + "name": "MATURITY", + "comment": null + }, + "TYPE": { + "type": "TEXT", + "index": 4, + "name": "TYPE", + "comment": null + }, + "OWNER_EMAIL": { + "type": "TEXT", + "index": 5, + "name": "OWNER_EMAIL", + "comment": null + }, + "OWNER_NAME": { + "type": "TEXT", + "index": 6, + "name": "OWNER_NAME", + "comment": null + }, + "URL": { + "type": "TEXT", + "index": 7, + "name": "URL", + "comment": null + }, + "DEPENDS_ON_MACROS": { + "type": "TEXT", + "index": 8, + "name": "DEPENDS_ON_MACROS", + "comment": null + }, + "DEPENDS_ON_NODES": { + "type": "TEXT", + "index": 9, + "name": "DEPENDS_ON_NODES", + "comment": null + }, + "DESCRIPTION": { + "type": "TEXT", + "index": 10, + "name": "DESCRIPTION", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 11, + "name": "TAGS", + "comment": null + }, + "META": { + "type": "TEXT", + "index": 12, + "name": "META", + "comment": null + }, + "PACKAGE_NAME": { + "type": "TEXT", + "index": 13, + "name": "PACKAGE_NAME", + "comment": null + }, + "ORIGINAL_PATH": { + "type": "TEXT", + "index": 14, + "name": "ORIGINAL_PATH", + "comment": null + }, + "PATH": { + "type": "TEXT", + "index": 15, + "name": "PATH", + "comment": null + }, + "GENERATED_AT": { + "type": "TEXT", + "index": 16, + "name": "GENERATED_AT", + "comment": null + }, + "METADATA_HASH": { + "type": "TEXT", + "index": 17, + "name": "METADATA_HASH", + "comment": null + }, + "LABEL": { + "type": "TEXT", + "index": 18, + "name": "LABEL", + "comment": null + }, + "RAW_QUERIES": { + "type": "TEXT", + "index": 19, + "name": "RAW_QUERIES", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 0, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 0, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:08UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.dbt_exposures" + }, + "model.jaffle_shop_package.stg_depends_on_downstream": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "STG_DEPENDS_ON_DOWNSTREAM", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 1, + "name": "CUSTOMER_ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + }, + "FIRST_ORDER_DATE": { + "type": "DATE", + "index": 4, + "name": "FIRST_ORDER_DATE", + "comment": null + }, + "MOST_RECENT_ORDER_DATE": { + "type": "DATE", + "index": 5, + "name": "MOST_RECENT_ORDER_DATE", + "comment": null + }, + "NUMBER_OF_ORDERS": { + "type": "NUMBER", + "index": 6, + "name": "NUMBER_OF_ORDERS", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.stg_depends_on_downstream" + }, + "model.elementary.dbt_invocations": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "DBT_INVOCATIONS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "INVOCATION_ID": { + "type": "TEXT", + "index": 1, + "name": "INVOCATION_ID", + "comment": null + }, + "JOB_ID": { + "type": "TEXT", + "index": 2, + "name": "JOB_ID", + "comment": null + }, + "JOB_NAME": { + "type": "TEXT", + "index": 3, + "name": "JOB_NAME", + "comment": null + }, + "JOB_RUN_ID": { + "type": "TEXT", + "index": 4, + "name": "JOB_RUN_ID", + "comment": null + }, + "RUN_STARTED_AT": { + "type": "TEXT", + "index": 5, + "name": "RUN_STARTED_AT", + "comment": null + }, + "RUN_COMPLETED_AT": { + "type": "TEXT", + "index": 6, + "name": "RUN_COMPLETED_AT", + "comment": null + }, + "GENERATED_AT": { + "type": "TEXT", + "index": 7, + "name": "GENERATED_AT", + "comment": null + }, + "CREATED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 8, + "name": "CREATED_AT", + "comment": null + }, + "COMMAND": { + "type": "TEXT", + "index": 9, + "name": "COMMAND", + "comment": null + }, + "DBT_VERSION": { + "type": "TEXT", + "index": 10, + "name": "DBT_VERSION", + "comment": null + }, + "ELEMENTARY_VERSION": { + "type": "TEXT", + "index": 11, + "name": "ELEMENTARY_VERSION", + "comment": null + }, + "FULL_REFRESH": { + "type": "BOOLEAN", + "index": 12, + "name": "FULL_REFRESH", + "comment": null + }, + "INVOCATION_VARS": { + "type": "TEXT", + "index": 13, + "name": "INVOCATION_VARS", + "comment": null + }, + "VARS": { + "type": "TEXT", + "index": 14, + "name": "VARS", + "comment": null + }, + "TARGET_NAME": { + "type": "TEXT", + "index": 15, + "name": "TARGET_NAME", + "comment": null + }, + "TARGET_DATABASE": { + "type": "TEXT", + "index": 16, + "name": "TARGET_DATABASE", + "comment": null + }, + "TARGET_SCHEMA": { + "type": "TEXT", + "index": 17, + "name": "TARGET_SCHEMA", + "comment": null + }, + "TARGET_PROFILE_NAME": { + "type": "TEXT", + "index": 18, + "name": "TARGET_PROFILE_NAME", + "comment": null + }, + "THREADS": { + "type": "NUMBER", + "index": 19, + "name": "THREADS", + "comment": null + }, + "SELECTED": { + "type": "TEXT", + "index": 20, + "name": "SELECTED", + "comment": null + }, + "YAML_SELECTOR": { + "type": "TEXT", + "index": 21, + "name": "YAML_SELECTOR", + "comment": null + }, + "PROJECT_ID": { + "type": "TEXT", + "index": 22, + "name": "PROJECT_ID", + "comment": null + }, + "PROJECT_NAME": { + "type": "TEXT", + "index": 23, + "name": "PROJECT_NAME", + "comment": null + }, + "ENV": { + "type": "TEXT", + "index": 24, + "name": "ENV", + "comment": null + }, + "ENV_ID": { + "type": "TEXT", + "index": 25, + "name": "ENV_ID", + "comment": null + }, + "CAUSE_CATEGORY": { + "type": "TEXT", + "index": 26, + "name": "CAUSE_CATEGORY", + "comment": null + }, + "CAUSE": { + "type": "TEXT", + "index": 27, + "name": "CAUSE", + "comment": null + }, + "PULL_REQUEST_ID": { + "type": "TEXT", + "index": 28, + "name": "PULL_REQUEST_ID", + "comment": null + }, + "GIT_SHA": { + "type": "TEXT", + "index": 29, + "name": "GIT_SHA", + "comment": null + }, + "ORCHESTRATOR": { + "type": "TEXT", + "index": 30, + "name": "ORCHESTRATOR", + "comment": null + }, + "DBT_USER": { + "type": "TEXT", + "index": 31, + "name": "DBT_USER", + "comment": null + }, + "JOB_URL": { + "type": "TEXT", + "index": 32, + "name": "JOB_URL", + "comment": null + }, + "JOB_RUN_URL": { + "type": "TEXT", + "index": 33, + "name": "JOB_RUN_URL", + "comment": null + }, + "ACCOUNT_ID": { + "type": "TEXT", + "index": 34, + "name": "ACCOUNT_ID", + "comment": null + }, + "TARGET_ADAPTER_SPECIFIC_FIELDS": { + "type": "TEXT", + "index": 35, + "name": "TARGET_ADAPTER_SPECIFIC_FIELDS", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 18, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 10240, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:10UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.dbt_invocations" + }, + "model.elementary.alerts_schema_changes": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "ALERTS_SCHEMA_CHANGES", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ALERT_ID": { + "type": "TEXT", + "index": 1, + "name": "ALERT_ID", + "comment": null + }, + "DATA_ISSUE_ID": { + "type": "TEXT", + "index": 2, + "name": "DATA_ISSUE_ID", + "comment": null + }, + "TEST_EXECUTION_ID": { + "type": "TEXT", + "index": 3, + "name": "TEST_EXECUTION_ID", + "comment": null + }, + "TEST_UNIQUE_ID": { + "type": "TEXT", + "index": 4, + "name": "TEST_UNIQUE_ID", + "comment": null + }, + "MODEL_UNIQUE_ID": { + "type": "TEXT", + "index": 5, + "name": "MODEL_UNIQUE_ID", + "comment": null + }, + "DETECTED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 6, + "name": "DETECTED_AT", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 7, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 8, + "name": "SCHEMA_NAME", + "comment": null + }, + "TABLE_NAME": { + "type": "TEXT", + "index": 9, + "name": "TABLE_NAME", + "comment": null + }, + "COLUMN_NAME": { + "type": "TEXT", + "index": 10, + "name": "COLUMN_NAME", + "comment": null + }, + "ALERT_TYPE": { + "type": "TEXT", + "index": 11, + "name": "ALERT_TYPE", + "comment": null + }, + "SUB_TYPE": { + "type": "TEXT", + "index": 12, + "name": "SUB_TYPE", + "comment": null + }, + "ALERT_DESCRIPTION": { + "type": "TEXT", + "index": 13, + "name": "ALERT_DESCRIPTION", + "comment": null + }, + "OWNERS": { + "type": "TEXT", + "index": 14, + "name": "OWNERS", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 15, + "name": "TAGS", + "comment": null + }, + "ALERT_RESULTS_QUERY": { + "type": "TEXT", + "index": 16, + "name": "ALERT_RESULTS_QUERY", + "comment": null + }, + "OTHER": { + "type": "TEXT", + "index": 17, + "name": "OTHER", + "comment": null + }, + "TEST_NAME": { + "type": "TEXT", + "index": 18, + "name": "TEST_NAME", + "comment": null + }, + "TEST_SHORT_NAME": { + "type": "TEXT", + "index": 19, + "name": "TEST_SHORT_NAME", + "comment": null + }, + "TEST_PARAMS": { + "type": "TEXT", + "index": 20, + "name": "TEST_PARAMS", + "comment": null + }, + "SEVERITY": { + "type": "TEXT", + "index": 21, + "name": "SEVERITY", + "comment": null + }, + "STATUS": { + "type": "TEXT", + "index": 22, + "name": "STATUS", + "comment": null + }, + "RESULT_ROWS": { + "type": "TEXT", + "index": 23, + "name": "RESULT_ROWS", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.alerts_schema_changes" + }, + "model.elementary.metrics_anomaly_score": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "METRICS_ANOMALY_SCORE", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ID": { + "type": "TEXT", + "index": 1, + "name": "ID", + "comment": null + }, + "FULL_TABLE_NAME": { + "type": "TEXT", + "index": 2, + "name": "FULL_TABLE_NAME", + "comment": null + }, + "COLUMN_NAME": { + "type": "TEXT", + "index": 3, + "name": "COLUMN_NAME", + "comment": null + }, + "DIMENSION": { + "type": "TEXT", + "index": 4, + "name": "DIMENSION", + "comment": null + }, + "DIMENSION_VALUE": { + "type": "TEXT", + "index": 5, + "name": "DIMENSION_VALUE", + "comment": null + }, + "METRIC_NAME": { + "type": "TEXT", + "index": 6, + "name": "METRIC_NAME", + "comment": null + }, + "ANOMALY_SCORE": { + "type": "FLOAT", + "index": 7, + "name": "ANOMALY_SCORE", + "comment": null + }, + "LATEST_METRIC_VALUE": { + "type": "FLOAT", + "index": 8, + "name": "LATEST_METRIC_VALUE", + "comment": null + }, + "BUCKET_START": { + "type": "TIMESTAMP_NTZ", + "index": 9, + "name": "BUCKET_START", + "comment": null + }, + "BUCKET_END": { + "type": "TIMESTAMP_NTZ", + "index": 10, + "name": "BUCKET_END", + "comment": null + }, + "TRAINING_AVG": { + "type": "FLOAT", + "index": 11, + "name": "TRAINING_AVG", + "comment": null + }, + "TRAINING_STDDEV": { + "type": "FLOAT", + "index": 12, + "name": "TRAINING_STDDEV", + "comment": null + }, + "TRAINING_START": { + "type": "TIMESTAMP_NTZ", + "index": 13, + "name": "TRAINING_START", + "comment": null + }, + "TRAINING_END": { + "type": "TIMESTAMP_NTZ", + "index": 14, + "name": "TRAINING_END", + "comment": null + }, + "TRAINING_SET_SIZE": { + "type": "NUMBER", + "index": 15, + "name": "TRAINING_SET_SIZE", + "comment": null + }, + "UPDATED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 16, + "name": "UPDATED_AT", + "comment": null + }, + "IS_ANOMALY": { + "type": "BOOLEAN", + "index": 17, + "name": "IS_ANOMALY", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.metrics_anomaly_score" + }, + "model.elementary.alerts_anomaly_detection": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "ALERTS_ANOMALY_DETECTION", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ALERT_ID": { + "type": "TEXT", + "index": 1, + "name": "ALERT_ID", + "comment": null + }, + "DATA_ISSUE_ID": { + "type": "TEXT", + "index": 2, + "name": "DATA_ISSUE_ID", + "comment": null + }, + "TEST_EXECUTION_ID": { + "type": "TEXT", + "index": 3, + "name": "TEST_EXECUTION_ID", + "comment": null + }, + "TEST_UNIQUE_ID": { + "type": "TEXT", + "index": 4, + "name": "TEST_UNIQUE_ID", + "comment": null + }, + "MODEL_UNIQUE_ID": { + "type": "TEXT", + "index": 5, + "name": "MODEL_UNIQUE_ID", + "comment": null + }, + "DETECTED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 6, + "name": "DETECTED_AT", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 7, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 8, + "name": "SCHEMA_NAME", + "comment": null + }, + "TABLE_NAME": { + "type": "TEXT", + "index": 9, + "name": "TABLE_NAME", + "comment": null + }, + "COLUMN_NAME": { + "type": "TEXT", + "index": 10, + "name": "COLUMN_NAME", + "comment": null + }, + "ALERT_TYPE": { + "type": "TEXT", + "index": 11, + "name": "ALERT_TYPE", + "comment": null + }, + "SUB_TYPE": { + "type": "TEXT", + "index": 12, + "name": "SUB_TYPE", + "comment": null + }, + "ALERT_DESCRIPTION": { + "type": "TEXT", + "index": 13, + "name": "ALERT_DESCRIPTION", + "comment": null + }, + "OWNERS": { + "type": "TEXT", + "index": 14, + "name": "OWNERS", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 15, + "name": "TAGS", + "comment": null + }, + "ALERT_RESULTS_QUERY": { + "type": "TEXT", + "index": 16, + "name": "ALERT_RESULTS_QUERY", + "comment": null + }, + "OTHER": { + "type": "TEXT", + "index": 17, + "name": "OTHER", + "comment": null + }, + "TEST_NAME": { + "type": "TEXT", + "index": 18, + "name": "TEST_NAME", + "comment": null + }, + "TEST_SHORT_NAME": { + "type": "TEXT", + "index": 19, + "name": "TEST_SHORT_NAME", + "comment": null + }, + "TEST_PARAMS": { + "type": "TEXT", + "index": 20, + "name": "TEST_PARAMS", + "comment": null + }, + "SEVERITY": { + "type": "TEXT", + "index": 21, + "name": "SEVERITY", + "comment": null + }, + "STATUS": { + "type": "TEXT", + "index": 22, + "name": "STATUS", + "comment": null + }, + "RESULT_ROWS": { + "type": "TEXT", + "index": 23, + "name": "RESULT_ROWS", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.alerts_anomaly_detection" + }, + "model.elementary.information_schema_columns": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "INFORMATION_SCHEMA_COLUMNS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "FULL_TABLE_NAME": { + "type": "TEXT", + "index": 1, + "name": "FULL_TABLE_NAME", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 2, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 3, + "name": "SCHEMA_NAME", + "comment": null + }, + "TABLE_NAME": { + "type": "TEXT", + "index": 4, + "name": "TABLE_NAME", + "comment": null + }, + "COLUMN_NAME": { + "type": "TEXT", + "index": 5, + "name": "COLUMN_NAME", + "comment": null + }, + "DATA_TYPE": { + "type": "TEXT", + "index": 6, + "name": "DATA_TYPE", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.information_schema_columns" + }, + "model.jaffle_shop_package.int_downstream_model_dependent_on_source": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "INT_DOWNSTREAM_MODEL_DEPENDENT_ON_SOURCE", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 1, + "name": "CUSTOMER_ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + }, + "FIRST_ORDER_DATE": { + "type": "DATE", + "index": 4, + "name": "FIRST_ORDER_DATE", + "comment": null + }, + "MOST_RECENT_ORDER_DATE": { + "type": "DATE", + "index": 5, + "name": "MOST_RECENT_ORDER_DATE", + "comment": null + }, + "NUMBER_OF_ORDERS": { + "type": "NUMBER", + "index": 6, + "name": "NUMBER_OF_ORDERS", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.int_downstream_model_dependent_on_source" + }, + "seed.jaffle_shop_package.raw_payments": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP", + "name": "RAW_PAYMENTS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ID": { + "type": "NUMBER", + "index": 1, + "name": "ID", + "comment": null + }, + "ORDER_ID": { + "type": "NUMBER", + "index": 2, + "name": "ORDER_ID", + "comment": null + }, + "PAYMENT_METHOD": { + "type": "TEXT", + "index": 3, + "name": "PAYMENT_METHOD", + "comment": null + }, + "AMOUNT": { + "type": "NUMBER", + "index": 4, + "name": "AMOUNT", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 113, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 2560, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:09UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "seed.jaffle_shop_package.raw_payments" + }, + "model.elementary.dbt_snapshots": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "DBT_SNAPSHOTS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "UNIQUE_ID": { + "type": "TEXT", + "index": 1, + "name": "UNIQUE_ID", + "comment": null + }, + "ALIAS": { + "type": "TEXT", + "index": 2, + "name": "ALIAS", + "comment": null + }, + "CHECKSUM": { + "type": "TEXT", + "index": 3, + "name": "CHECKSUM", + "comment": null + }, + "MATERIALIZATION": { + "type": "TEXT", + "index": 4, + "name": "MATERIALIZATION", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 5, + "name": "TAGS", + "comment": null + }, + "META": { + "type": "TEXT", + "index": 6, + "name": "META", + "comment": null + }, + "OWNER": { + "type": "TEXT", + "index": 7, + "name": "OWNER", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 8, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 9, + "name": "SCHEMA_NAME", + "comment": null + }, + "DEPENDS_ON_MACROS": { + "type": "TEXT", + "index": 10, + "name": "DEPENDS_ON_MACROS", + "comment": null + }, + "DEPENDS_ON_NODES": { + "type": "TEXT", + "index": 11, + "name": "DEPENDS_ON_NODES", + "comment": null + }, + "DESCRIPTION": { + "type": "TEXT", + "index": 12, + "name": "DESCRIPTION", + "comment": null + }, + "NAME": { + "type": "TEXT", + "index": 13, + "name": "NAME", + "comment": null + }, + "PACKAGE_NAME": { + "type": "TEXT", + "index": 14, + "name": "PACKAGE_NAME", + "comment": null + }, + "ORIGINAL_PATH": { + "type": "TEXT", + "index": 15, + "name": "ORIGINAL_PATH", + "comment": null + }, + "PATH": { + "type": "TEXT", + "index": 16, + "name": "PATH", + "comment": null + }, + "PATCH_PATH": { + "type": "TEXT", + "index": 17, + "name": "PATCH_PATH", + "comment": null + }, + "GENERATED_AT": { + "type": "TEXT", + "index": 18, + "name": "GENERATED_AT", + "comment": null + }, + "METADATA_HASH": { + "type": "TEXT", + "index": 19, + "name": "METADATA_HASH", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 0, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 0, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:08UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.dbt_snapshots" + }, + "model.elementary.enriched_columns": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "ENRICHED_COLUMNS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "DATABASE_NAME": { + "type": "TEXT", + "index": 1, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 2, + "name": "SCHEMA_NAME", + "comment": null + }, + "TABLE_NAME": { + "type": "TEXT", + "index": 3, + "name": "TABLE_NAME", + "comment": null + }, + "NAME": { + "type": "TEXT", + "index": 4, + "name": "NAME", + "comment": null + }, + "DATA_TYPE": { + "type": "TEXT", + "index": 5, + "name": "DATA_TYPE", + "comment": null + }, + "DESCRIPTION": { + "type": "TEXT", + "index": 6, + "name": "DESCRIPTION", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.enriched_columns" + }, + "model.elementary.metadata": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "METADATA", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "DBT_PKG_VERSION": { + "type": "TEXT", + "index": 1, + "name": "DBT_PKG_VERSION", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 1, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 1024, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:09UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.metadata" + }, + "model.elementary.dbt_columns": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "DBT_COLUMNS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "UNIQUE_ID": { + "type": "TEXT", + "index": 1, + "name": "UNIQUE_ID", + "comment": null + }, + "PARENT_UNIQUE_ID": { + "type": "TEXT", + "index": 2, + "name": "PARENT_UNIQUE_ID", + "comment": null + }, + "NAME": { + "type": "TEXT", + "index": 3, + "name": "NAME", + "comment": null + }, + "DATA_TYPE": { + "type": "TEXT", + "index": 4, + "name": "DATA_TYPE", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 5, + "name": "TAGS", + "comment": null + }, + "META": { + "type": "TEXT", + "index": 6, + "name": "META", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 7, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 8, + "name": "SCHEMA_NAME", + "comment": null + }, + "TABLE_NAME": { + "type": "TEXT", + "index": 9, + "name": "TABLE_NAME", + "comment": null + }, + "DESCRIPTION": { + "type": "TEXT", + "index": 10, + "name": "DESCRIPTION", + "comment": null + }, + "RESOURCE_TYPE": { + "type": "TEXT", + "index": 11, + "name": "RESOURCE_TYPE", + "comment": null + }, + "GENERATED_AT": { + "type": "TEXT", + "index": 12, + "name": "GENERATED_AT", + "comment": null + }, + "METADATA_HASH": { + "type": "TEXT", + "index": 13, + "name": "METADATA_HASH", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 185, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 17920, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:08UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.dbt_columns" + }, + "model.jaffle_shop_package.stg_orders": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "STG_ORDERS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ORDER_ID": { + "type": "NUMBER", + "index": 1, + "name": "ORDER_ID", + "comment": null + }, + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 2, + "name": "CUSTOMER_ID", + "comment": null + }, + "ORDER_DATE": { + "type": "DATE", + "index": 3, + "name": "ORDER_DATE", + "comment": null + }, + "STATUS": { + "type": "TEXT", + "index": 4, + "name": "STATUS", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.stg_orders" + }, + "model.elementary.elementary_test_results": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "ELEMENTARY_TEST_RESULTS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ID": { + "type": "TEXT", + "index": 1, + "name": "ID", + "comment": null + }, + "DATA_ISSUE_ID": { + "type": "TEXT", + "index": 2, + "name": "DATA_ISSUE_ID", + "comment": null + }, + "TEST_EXECUTION_ID": { + "type": "TEXT", + "index": 3, + "name": "TEST_EXECUTION_ID", + "comment": null + }, + "TEST_UNIQUE_ID": { + "type": "TEXT", + "index": 4, + "name": "TEST_UNIQUE_ID", + "comment": null + }, + "MODEL_UNIQUE_ID": { + "type": "TEXT", + "index": 5, + "name": "MODEL_UNIQUE_ID", + "comment": null + }, + "INVOCATION_ID": { + "type": "TEXT", + "index": 6, + "name": "INVOCATION_ID", + "comment": null + }, + "DETECTED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 7, + "name": "DETECTED_AT", + "comment": null + }, + "CREATED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 8, + "name": "CREATED_AT", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 9, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 10, + "name": "SCHEMA_NAME", + "comment": null + }, + "TABLE_NAME": { + "type": "TEXT", + "index": 11, + "name": "TABLE_NAME", + "comment": null + }, + "COLUMN_NAME": { + "type": "TEXT", + "index": 12, + "name": "COLUMN_NAME", + "comment": null + }, + "TEST_TYPE": { + "type": "TEXT", + "index": 13, + "name": "TEST_TYPE", + "comment": null + }, + "TEST_SUB_TYPE": { + "type": "TEXT", + "index": 14, + "name": "TEST_SUB_TYPE", + "comment": null + }, + "TEST_RESULTS_DESCRIPTION": { + "type": "TEXT", + "index": 15, + "name": "TEST_RESULTS_DESCRIPTION", + "comment": null + }, + "OWNERS": { + "type": "TEXT", + "index": 16, + "name": "OWNERS", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 17, + "name": "TAGS", + "comment": null + }, + "TEST_RESULTS_QUERY": { + "type": "TEXT", + "index": 18, + "name": "TEST_RESULTS_QUERY", + "comment": null + }, + "OTHER": { + "type": "TEXT", + "index": 19, + "name": "OTHER", + "comment": null + }, + "TEST_NAME": { + "type": "TEXT", + "index": 20, + "name": "TEST_NAME", + "comment": null + }, + "TEST_PARAMS": { + "type": "TEXT", + "index": 21, + "name": "TEST_PARAMS", + "comment": null + }, + "SEVERITY": { + "type": "TEXT", + "index": 22, + "name": "SEVERITY", + "comment": null + }, + "STATUS": { + "type": "TEXT", + "index": 23, + "name": "STATUS", + "comment": null + }, + "FAILURES": { + "type": "NUMBER", + "index": 24, + "name": "FAILURES", + "comment": null + }, + "TEST_SHORT_NAME": { + "type": "TEXT", + "index": 25, + "name": "TEST_SHORT_NAME", + "comment": null + }, + "TEST_ALIAS": { + "type": "TEXT", + "index": 26, + "name": "TEST_ALIAS", + "comment": null + }, + "RESULT_ROWS": { + "type": "TEXT", + "index": 27, + "name": "RESULT_ROWS", + "comment": null + }, + "FAILED_ROW_COUNT": { + "type": "NUMBER", + "index": 28, + "name": "FAILED_ROW_COUNT", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 103, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 20480, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:10UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.elementary_test_results" + }, + "model.elementary.test_result_rows": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "TEST_RESULT_ROWS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ELEMENTARY_TEST_RESULTS_ID": { + "type": "TEXT", + "index": 1, + "name": "ELEMENTARY_TEST_RESULTS_ID", + "comment": null + }, + "RESULT_ROW": { + "type": "TEXT", + "index": 2, + "name": "RESULT_ROW", + "comment": null + }, + "DETECTED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 3, + "name": "DETECTED_AT", + "comment": null + }, + "CREATED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 4, + "name": "CREATED_AT", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 0, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 0, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-02 17:57UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.test_result_rows" + }, + "model.elementary.alerts_dbt_tests": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "ALERTS_DBT_TESTS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ALERT_ID": { + "type": "TEXT", + "index": 1, + "name": "ALERT_ID", + "comment": null + }, + "DATA_ISSUE_ID": { + "type": "TEXT", + "index": 2, + "name": "DATA_ISSUE_ID", + "comment": null + }, + "TEST_EXECUTION_ID": { + "type": "TEXT", + "index": 3, + "name": "TEST_EXECUTION_ID", + "comment": null + }, + "TEST_UNIQUE_ID": { + "type": "TEXT", + "index": 4, + "name": "TEST_UNIQUE_ID", + "comment": null + }, + "MODEL_UNIQUE_ID": { + "type": "TEXT", + "index": 5, + "name": "MODEL_UNIQUE_ID", + "comment": null + }, + "DETECTED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 6, + "name": "DETECTED_AT", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 7, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 8, + "name": "SCHEMA_NAME", + "comment": null + }, + "TABLE_NAME": { + "type": "TEXT", + "index": 9, + "name": "TABLE_NAME", + "comment": null + }, + "COLUMN_NAME": { + "type": "TEXT", + "index": 10, + "name": "COLUMN_NAME", + "comment": null + }, + "ALERT_TYPE": { + "type": "TEXT", + "index": 11, + "name": "ALERT_TYPE", + "comment": null + }, + "SUB_TYPE": { + "type": "TEXT", + "index": 12, + "name": "SUB_TYPE", + "comment": null + }, + "ALERT_DESCRIPTION": { + "type": "TEXT", + "index": 13, + "name": "ALERT_DESCRIPTION", + "comment": null + }, + "OWNERS": { + "type": "TEXT", + "index": 14, + "name": "OWNERS", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 15, + "name": "TAGS", + "comment": null + }, + "ALERT_RESULTS_QUERY": { + "type": "TEXT", + "index": 16, + "name": "ALERT_RESULTS_QUERY", + "comment": null + }, + "OTHER": { + "type": "TEXT", + "index": 17, + "name": "OTHER", + "comment": null + }, + "TEST_NAME": { + "type": "TEXT", + "index": 18, + "name": "TEST_NAME", + "comment": null + }, + "TEST_SHORT_NAME": { + "type": "TEXT", + "index": 19, + "name": "TEST_SHORT_NAME", + "comment": null + }, + "TEST_PARAMS": { + "type": "TEXT", + "index": 20, + "name": "TEST_PARAMS", + "comment": null + }, + "SEVERITY": { + "type": "TEXT", + "index": 21, + "name": "SEVERITY", + "comment": null + }, + "STATUS": { + "type": "TEXT", + "index": 22, + "name": "STATUS", + "comment": null + }, + "RESULT_ROWS": { + "type": "TEXT", + "index": 23, + "name": "RESULT_ROWS", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.alerts_dbt_tests" + }, + "model.jaffle_shop_package.customers_downstream": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "CUSTOMERS_DOWNSTREAM", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 1, + "name": "CUSTOMER_ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + }, + "FIRST_ORDER": { + "type": "DATE", + "index": 4, + "name": "FIRST_ORDER", + "comment": null + }, + "MOST_RECENT_ORDER": { + "type": "DATE", + "index": 5, + "name": "MOST_RECENT_ORDER", + "comment": null + }, + "NUMBER_OF_ORDERS": { + "type": "NUMBER", + "index": 6, + "name": "NUMBER_OF_ORDERS", + "comment": null + }, + "CUSTOMER_LIFETIME_VALUE": { + "type": "NUMBER", + "index": 7, + "name": "CUSTOMER_LIFETIME_VALUE", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.customers_downstream" + }, + "model.jaffle_shop_package.customers": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "CUSTOMERS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 1, + "name": "CUSTOMER_ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + }, + "FIRST_ORDER": { + "type": "DATE", + "index": 4, + "name": "FIRST_ORDER", + "comment": null + }, + "MOST_RECENT_ORDER": { + "type": "DATE", + "index": 5, + "name": "MOST_RECENT_ORDER", + "comment": null + }, + "NUMBER_OF_ORDERS": { + "type": "NUMBER", + "index": 6, + "name": "NUMBER_OF_ORDERS", + "comment": null + }, + "CUSTOMER_LIFETIME_VALUE": { + "type": "NUMBER", + "index": 7, + "name": "CUSTOMER_LIFETIME_VALUE", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.customers" + }, + "model.jaffle_shop_package.source_fanout2": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "SOURCE_FANOUT2", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 1, + "name": "CUSTOMER_ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + }, + "FIRST_ORDER_DATE": { + "type": "DATE", + "index": 4, + "name": "FIRST_ORDER_DATE", + "comment": null + }, + "MOST_RECENT_ORDER_DATE": { + "type": "DATE", + "index": 5, + "name": "MOST_RECENT_ORDER_DATE", + "comment": null + }, + "NUMBER_OF_ORDERS": { + "type": "NUMBER", + "index": 6, + "name": "NUMBER_OF_ORDERS", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.source_fanout2" + }, + "model.elementary.alerts_dbt_source_freshness": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "ALERTS_DBT_SOURCE_FRESHNESS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ALERT_ID": { + "type": "TEXT", + "index": 1, + "name": "ALERT_ID", + "comment": null + }, + "MAX_LOADED_AT": { + "type": "TEXT", + "index": 2, + "name": "MAX_LOADED_AT", + "comment": null + }, + "SNAPSHOTTED_AT": { + "type": "TEXT", + "index": 3, + "name": "SNAPSHOTTED_AT", + "comment": null + }, + "DETECTED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 4, + "name": "DETECTED_AT", + "comment": null + }, + "MAX_LOADED_AT_TIME_AGO_IN_S": { + "type": "FLOAT", + "index": 5, + "name": "MAX_LOADED_AT_TIME_AGO_IN_S", + "comment": null + }, + "STATUS": { + "type": "TEXT", + "index": 6, + "name": "STATUS", + "comment": null + }, + "ERROR": { + "type": "TEXT", + "index": 7, + "name": "ERROR", + "comment": null + }, + "WARN_AFTER": { + "type": "TEXT", + "index": 8, + "name": "WARN_AFTER", + "comment": null + }, + "ERROR_AFTER": { + "type": "TEXT", + "index": 9, + "name": "ERROR_AFTER", + "comment": null + }, + "FILTER": { + "type": "TEXT", + "index": 10, + "name": "FILTER", + "comment": null + }, + "UNIQUE_ID": { + "type": "TEXT", + "index": 11, + "name": "UNIQUE_ID", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 12, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 13, + "name": "SCHEMA_NAME", + "comment": null + }, + "SOURCE_NAME": { + "type": "TEXT", + "index": 14, + "name": "SOURCE_NAME", + "comment": null + }, + "IDENTIFIER": { + "type": "TEXT", + "index": 15, + "name": "IDENTIFIER", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 16, + "name": "TAGS", + "comment": null + }, + "META": { + "type": "TEXT", + "index": 17, + "name": "META", + "comment": null + }, + "OWNER": { + "type": "TEXT", + "index": 18, + "name": "OWNER", + "comment": null + }, + "PACKAGE_NAME": { + "type": "TEXT", + "index": 19, + "name": "PACKAGE_NAME", + "comment": null + }, + "PATH": { + "type": "TEXT", + "index": 20, + "name": "PATH", + "comment": null + }, + "FRESHNESS_ERROR_AFTER": { + "type": "TEXT", + "index": 21, + "name": "FRESHNESS_ERROR_AFTER", + "comment": null + }, + "FRESHNESS_WARN_AFTER": { + "type": "TEXT", + "index": 22, + "name": "FRESHNESS_WARN_AFTER", + "comment": null + }, + "FRESHNESS_FILTER": { + "type": "TEXT", + "index": 23, + "name": "FRESHNESS_FILTER", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.alerts_dbt_source_freshness" + }, + "model.jaffle_shop_package.stg_customers": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "STG_CUSTOMERS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 1, + "name": "CUSTOMER_ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.stg_customers" + }, + "model.elementary.model_run_results": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "MODEL_RUN_RESULTS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "MODEL_EXECUTION_ID": { + "type": "TEXT", + "index": 1, + "name": "MODEL_EXECUTION_ID", + "comment": null + }, + "UNIQUE_ID": { + "type": "TEXT", + "index": 2, + "name": "UNIQUE_ID", + "comment": null + }, + "INVOCATION_ID": { + "type": "TEXT", + "index": 3, + "name": "INVOCATION_ID", + "comment": null + }, + "QUERY_ID": { + "type": "TEXT", + "index": 4, + "name": "QUERY_ID", + "comment": null + }, + "NAME": { + "type": "TEXT", + "index": 5, + "name": "NAME", + "comment": null + }, + "GENERATED_AT": { + "type": "TEXT", + "index": 6, + "name": "GENERATED_AT", + "comment": null + }, + "STATUS": { + "type": "TEXT", + "index": 7, + "name": "STATUS", + "comment": null + }, + "FULL_REFRESH": { + "type": "BOOLEAN", + "index": 8, + "name": "FULL_REFRESH", + "comment": null + }, + "MESSAGE": { + "type": "TEXT", + "index": 9, + "name": "MESSAGE", + "comment": null + }, + "EXECUTION_TIME": { + "type": "FLOAT", + "index": 10, + "name": "EXECUTION_TIME", + "comment": null + }, + "EXECUTE_STARTED_AT": { + "type": "TEXT", + "index": 11, + "name": "EXECUTE_STARTED_AT", + "comment": null + }, + "EXECUTE_COMPLETED_AT": { + "type": "TEXT", + "index": 12, + "name": "EXECUTE_COMPLETED_AT", + "comment": null + }, + "COMPILE_STARTED_AT": { + "type": "TEXT", + "index": 13, + "name": "COMPILE_STARTED_AT", + "comment": null + }, + "COMPILE_COMPLETED_AT": { + "type": "TEXT", + "index": 14, + "name": "COMPILE_COMPLETED_AT", + "comment": null + }, + "COMPILED_CODE": { + "type": "TEXT", + "index": 15, + "name": "COMPILED_CODE", + "comment": null + }, + "ADAPTER_RESPONSE": { + "type": "TEXT", + "index": 16, + "name": "ADAPTER_RESPONSE", + "comment": null + }, + "THREAD_ID": { + "type": "TEXT", + "index": 17, + "name": "THREAD_ID", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 18, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 19, + "name": "SCHEMA_NAME", + "comment": null + }, + "MATERIALIZATION": { + "type": "TEXT", + "index": 20, + "name": "MATERIALIZATION", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 21, + "name": "TAGS", + "comment": null + }, + "PACKAGE_NAME": { + "type": "TEXT", + "index": 22, + "name": "PACKAGE_NAME", + "comment": null + }, + "PATH": { + "type": "TEXT", + "index": 23, + "name": "PATH", + "comment": null + }, + "ORIGINAL_PATH": { + "type": "TEXT", + "index": 24, + "name": "ORIGINAL_PATH", + "comment": null + }, + "OWNER": { + "type": "TEXT", + "index": 25, + "name": "OWNER", + "comment": null + }, + "ALIAS": { + "type": "TEXT", + "index": 26, + "name": "ALIAS", + "comment": null + }, + "MODEL_INVOCATION_REVERSE_INDEX": { + "type": "NUMBER", + "index": 27, + "name": "MODEL_INVOCATION_REVERSE_INDEX", + "comment": null + }, + "IS_THE_FIRST_INVOCATION_OF_THE_DAY": { + "type": "BOOLEAN", + "index": 28, + "name": "IS_THE_FIRST_INVOCATION_OF_THE_DAY", + "comment": null + }, + "IS_THE_LAST_INVOCATION_OF_THE_DAY": { + "type": "BOOLEAN", + "index": 29, + "name": "IS_THE_LAST_INVOCATION_OF_THE_DAY", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.model_run_results" + }, + "model.elementary.dbt_sources": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "DBT_SOURCES", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "UNIQUE_ID": { + "type": "TEXT", + "index": 1, + "name": "UNIQUE_ID", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 2, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 3, + "name": "SCHEMA_NAME", + "comment": null + }, + "SOURCE_NAME": { + "type": "TEXT", + "index": 4, + "name": "SOURCE_NAME", + "comment": null + }, + "NAME": { + "type": "TEXT", + "index": 5, + "name": "NAME", + "comment": null + }, + "IDENTIFIER": { + "type": "TEXT", + "index": 6, + "name": "IDENTIFIER", + "comment": null + }, + "LOADED_AT_FIELD": { + "type": "TEXT", + "index": 7, + "name": "LOADED_AT_FIELD", + "comment": null + }, + "FRESHNESS_WARN_AFTER": { + "type": "TEXT", + "index": 8, + "name": "FRESHNESS_WARN_AFTER", + "comment": null + }, + "FRESHNESS_ERROR_AFTER": { + "type": "TEXT", + "index": 9, + "name": "FRESHNESS_ERROR_AFTER", + "comment": null + }, + "FRESHNESS_FILTER": { + "type": "TEXT", + "index": 10, + "name": "FRESHNESS_FILTER", + "comment": null + }, + "FRESHNESS_DESCRIPTION": { + "type": "TEXT", + "index": 11, + "name": "FRESHNESS_DESCRIPTION", + "comment": null + }, + "RELATION_NAME": { + "type": "TEXT", + "index": 12, + "name": "RELATION_NAME", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 13, + "name": "TAGS", + "comment": null + }, + "META": { + "type": "TEXT", + "index": 14, + "name": "META", + "comment": null + }, + "OWNER": { + "type": "TEXT", + "index": 15, + "name": "OWNER", + "comment": null + }, + "PACKAGE_NAME": { + "type": "TEXT", + "index": 16, + "name": "PACKAGE_NAME", + "comment": null + }, + "ORIGINAL_PATH": { + "type": "TEXT", + "index": 17, + "name": "ORIGINAL_PATH", + "comment": null + }, + "PATH": { + "type": "TEXT", + "index": 18, + "name": "PATH", + "comment": null + }, + "SOURCE_DESCRIPTION": { + "type": "TEXT", + "index": 19, + "name": "SOURCE_DESCRIPTION", + "comment": null + }, + "DESCRIPTION": { + "type": "TEXT", + "index": 20, + "name": "DESCRIPTION", + "comment": null + }, + "GENERATED_AT": { + "type": "TEXT", + "index": 21, + "name": "GENERATED_AT", + "comment": null + }, + "METADATA_HASH": { + "type": "TEXT", + "index": 22, + "name": "METADATA_HASH", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 4, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 7168, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:08UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.dbt_sources" + }, + "model.elementary.dbt_metrics": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "DBT_METRICS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "UNIQUE_ID": { + "type": "TEXT", + "index": 1, + "name": "UNIQUE_ID", + "comment": null + }, + "NAME": { + "type": "TEXT", + "index": 2, + "name": "NAME", + "comment": null + }, + "LABEL": { + "type": "TEXT", + "index": 3, + "name": "LABEL", + "comment": null + }, + "MODEL": { + "type": "TEXT", + "index": 4, + "name": "MODEL", + "comment": null + }, + "TYPE": { + "type": "TEXT", + "index": 5, + "name": "TYPE", + "comment": null + }, + "SQL": { + "type": "TEXT", + "index": 6, + "name": "SQL", + "comment": null + }, + "TIMESTAMP": { + "type": "TEXT", + "index": 7, + "name": "TIMESTAMP", + "comment": null + }, + "FILTERS": { + "type": "TEXT", + "index": 8, + "name": "FILTERS", + "comment": null + }, + "TIME_GRAINS": { + "type": "TEXT", + "index": 9, + "name": "TIME_GRAINS", + "comment": null + }, + "DIMENSIONS": { + "type": "TEXT", + "index": 10, + "name": "DIMENSIONS", + "comment": null + }, + "DEPENDS_ON_MACROS": { + "type": "TEXT", + "index": 11, + "name": "DEPENDS_ON_MACROS", + "comment": null + }, + "DEPENDS_ON_NODES": { + "type": "TEXT", + "index": 12, + "name": "DEPENDS_ON_NODES", + "comment": null + }, + "DESCRIPTION": { + "type": "TEXT", + "index": 13, + "name": "DESCRIPTION", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 14, + "name": "TAGS", + "comment": null + }, + "META": { + "type": "TEXT", + "index": 15, + "name": "META", + "comment": null + }, + "PACKAGE_NAME": { + "type": "TEXT", + "index": 16, + "name": "PACKAGE_NAME", + "comment": null + }, + "ORIGINAL_PATH": { + "type": "TEXT", + "index": 17, + "name": "ORIGINAL_PATH", + "comment": null + }, + "PATH": { + "type": "TEXT", + "index": 18, + "name": "PATH", + "comment": null + }, + "GENERATED_AT": { + "type": "TEXT", + "index": 19, + "name": "GENERATED_AT", + "comment": null + }, + "METADATA_HASH": { + "type": "TEXT", + "index": 20, + "name": "METADATA_HASH", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 0, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 0, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:08UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.dbt_metrics" + }, + "model.jaffle_shop_package.direct_join_to_source": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "DIRECT_JOIN_TO_SOURCE", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 1, + "name": "CUSTOMER_ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + }, + "FIRST_ORDER": { + "type": "DATE", + "index": 4, + "name": "FIRST_ORDER", + "comment": null + }, + "MOST_RECENT_ORDER": { + "type": "DATE", + "index": 5, + "name": "MOST_RECENT_ORDER", + "comment": null + }, + "NUMBER_OF_ORDERS": { + "type": "NUMBER", + "index": 6, + "name": "NUMBER_OF_ORDERS", + "comment": null + }, + "CUSTOMER_LIFETIME_VALUE": { + "type": "NUMBER", + "index": 7, + "name": "CUSTOMER_LIFETIME_VALUE", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.direct_join_to_source" + }, + "seed.jaffle_shop_package.raw_customers": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP", + "name": "RAW_CUSTOMERS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ID": { + "type": "NUMBER", + "index": 1, + "name": "ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 100, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 2560, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:09UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "seed.jaffle_shop_package.raw_customers" + }, + "seed.jaffle_shop_package.raw_orders": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP", + "name": "RAW_ORDERS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ID": { + "type": "NUMBER", + "index": 1, + "name": "ID", + "comment": null + }, + "USER_ID": { + "type": "NUMBER", + "index": 2, + "name": "USER_ID", + "comment": null + }, + "ORDER_DATE": { + "type": "DATE", + "index": 3, + "name": "ORDER_DATE", + "comment": null + }, + "STATUS": { + "type": "TEXT", + "index": 4, + "name": "STATUS", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 99, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 2048, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:09UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "seed.jaffle_shop_package.raw_orders" + }, + "model.jaffle_shop_package.dim_downstream_model_dependent_on_source": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "DIM_DOWNSTREAM_MODEL_DEPENDENT_ON_SOURCE", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 1, + "name": "CUSTOMER_ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + }, + "FIRST_ORDER_DATE": { + "type": "DATE", + "index": 4, + "name": "FIRST_ORDER_DATE", + "comment": null + }, + "MOST_RECENT_ORDER_DATE": { + "type": "DATE", + "index": 5, + "name": "MOST_RECENT_ORDER_DATE", + "comment": null + }, + "NUMBER_OF_ORDERS": { + "type": "NUMBER", + "index": 6, + "name": "NUMBER_OF_ORDERS", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.dim_downstream_model_dependent_on_source" + }, + "model.elementary.snapshot_run_results": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "SNAPSHOT_RUN_RESULTS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "MODEL_EXECUTION_ID": { + "type": "TEXT", + "index": 1, + "name": "MODEL_EXECUTION_ID", + "comment": null + }, + "UNIQUE_ID": { + "type": "TEXT", + "index": 2, + "name": "UNIQUE_ID", + "comment": null + }, + "INVOCATION_ID": { + "type": "TEXT", + "index": 3, + "name": "INVOCATION_ID", + "comment": null + }, + "QUERY_ID": { + "type": "TEXT", + "index": 4, + "name": "QUERY_ID", + "comment": null + }, + "NAME": { + "type": "TEXT", + "index": 5, + "name": "NAME", + "comment": null + }, + "GENERATED_AT": { + "type": "TEXT", + "index": 6, + "name": "GENERATED_AT", + "comment": null + }, + "STATUS": { + "type": "TEXT", + "index": 7, + "name": "STATUS", + "comment": null + }, + "FULL_REFRESH": { + "type": "BOOLEAN", + "index": 8, + "name": "FULL_REFRESH", + "comment": null + }, + "MESSAGE": { + "type": "TEXT", + "index": 9, + "name": "MESSAGE", + "comment": null + }, + "EXECUTION_TIME": { + "type": "FLOAT", + "index": 10, + "name": "EXECUTION_TIME", + "comment": null + }, + "EXECUTE_STARTED_AT": { + "type": "TEXT", + "index": 11, + "name": "EXECUTE_STARTED_AT", + "comment": null + }, + "EXECUTE_COMPLETED_AT": { + "type": "TEXT", + "index": 12, + "name": "EXECUTE_COMPLETED_AT", + "comment": null + }, + "COMPILE_STARTED_AT": { + "type": "TEXT", + "index": 13, + "name": "COMPILE_STARTED_AT", + "comment": null + }, + "COMPILE_COMPLETED_AT": { + "type": "TEXT", + "index": 14, + "name": "COMPILE_COMPLETED_AT", + "comment": null + }, + "COMPILED_CODE": { + "type": "TEXT", + "index": 15, + "name": "COMPILED_CODE", + "comment": null + }, + "ADAPTER_RESPONSE": { + "type": "TEXT", + "index": 16, + "name": "ADAPTER_RESPONSE", + "comment": null + }, + "THREAD_ID": { + "type": "TEXT", + "index": 17, + "name": "THREAD_ID", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 18, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 19, + "name": "SCHEMA_NAME", + "comment": null + }, + "MATERIALIZATION": { + "type": "TEXT", + "index": 20, + "name": "MATERIALIZATION", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 21, + "name": "TAGS", + "comment": null + }, + "PACKAGE_NAME": { + "type": "TEXT", + "index": 22, + "name": "PACKAGE_NAME", + "comment": null + }, + "PATH": { + "type": "TEXT", + "index": 23, + "name": "PATH", + "comment": null + }, + "ORIGINAL_PATH": { + "type": "TEXT", + "index": 24, + "name": "ORIGINAL_PATH", + "comment": null + }, + "OWNER": { + "type": "TEXT", + "index": 25, + "name": "OWNER", + "comment": null + }, + "ALIAS": { + "type": "TEXT", + "index": 26, + "name": "ALIAS", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.snapshot_run_results" + }, + "model.elementary.dbt_run_results": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "DBT_RUN_RESULTS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "MODEL_EXECUTION_ID": { + "type": "TEXT", + "index": 1, + "name": "MODEL_EXECUTION_ID", + "comment": null + }, + "UNIQUE_ID": { + "type": "TEXT", + "index": 2, + "name": "UNIQUE_ID", + "comment": null + }, + "INVOCATION_ID": { + "type": "TEXT", + "index": 3, + "name": "INVOCATION_ID", + "comment": null + }, + "GENERATED_AT": { + "type": "TEXT", + "index": 4, + "name": "GENERATED_AT", + "comment": null + }, + "CREATED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 5, + "name": "CREATED_AT", + "comment": null + }, + "NAME": { + "type": "TEXT", + "index": 6, + "name": "NAME", + "comment": null + }, + "MESSAGE": { + "type": "TEXT", + "index": 7, + "name": "MESSAGE", + "comment": null + }, + "STATUS": { + "type": "TEXT", + "index": 8, + "name": "STATUS", + "comment": null + }, + "RESOURCE_TYPE": { + "type": "TEXT", + "index": 9, + "name": "RESOURCE_TYPE", + "comment": null + }, + "EXECUTION_TIME": { + "type": "FLOAT", + "index": 10, + "name": "EXECUTION_TIME", + "comment": null + }, + "EXECUTE_STARTED_AT": { + "type": "TEXT", + "index": 11, + "name": "EXECUTE_STARTED_AT", + "comment": null + }, + "EXECUTE_COMPLETED_AT": { + "type": "TEXT", + "index": 12, + "name": "EXECUTE_COMPLETED_AT", + "comment": null + }, + "COMPILE_STARTED_AT": { + "type": "TEXT", + "index": 13, + "name": "COMPILE_STARTED_AT", + "comment": null + }, + "COMPILE_COMPLETED_AT": { + "type": "TEXT", + "index": 14, + "name": "COMPILE_COMPLETED_AT", + "comment": null + }, + "ROWS_AFFECTED": { + "type": "NUMBER", + "index": 15, + "name": "ROWS_AFFECTED", + "comment": null + }, + "FULL_REFRESH": { + "type": "BOOLEAN", + "index": 16, + "name": "FULL_REFRESH", + "comment": null + }, + "COMPILED_CODE": { + "type": "TEXT", + "index": 17, + "name": "COMPILED_CODE", + "comment": null + }, + "FAILURES": { + "type": "NUMBER", + "index": 18, + "name": "FAILURES", + "comment": null + }, + "QUERY_ID": { + "type": "TEXT", + "index": 19, + "name": "QUERY_ID", + "comment": null + }, + "THREAD_ID": { + "type": "TEXT", + "index": 20, + "name": "THREAD_ID", + "comment": null + }, + "MATERIALIZATION": { + "type": "TEXT", + "index": 21, + "name": "MATERIALIZATION", + "comment": null + }, + "ADAPTER_RESPONSE": { + "type": "TEXT", + "index": 22, + "name": "ADAPTER_RESPONSE", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 338, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 88576, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:09UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.dbt_run_results" + }, + "model.elementary.dbt_artifacts_hashes": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "DBT_ARTIFACTS_HASHES", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ARTIFACTS_MODEL": { + "type": "TEXT", + "index": 1, + "name": "ARTIFACTS_MODEL", + "comment": null + }, + "METADATA_HASH": { + "type": "TEXT", + "index": 2, + "name": "METADATA_HASH", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.dbt_artifacts_hashes" + }, + "model.jaffle_shop_package.fct_downstream_model_dependent_on_source": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "FCT_DOWNSTREAM_MODEL_DEPENDENT_ON_SOURCE", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 1, + "name": "CUSTOMER_ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + }, + "FIRST_ORDER_DATE": { + "type": "DATE", + "index": 4, + "name": "FIRST_ORDER_DATE", + "comment": null + }, + "MOST_RECENT_ORDER_DATE": { + "type": "DATE", + "index": 5, + "name": "MOST_RECENT_ORDER_DATE", + "comment": null + }, + "NUMBER_OF_ORDERS": { + "type": "NUMBER", + "index": 6, + "name": "NUMBER_OF_ORDERS", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.fct_downstream_model_dependent_on_source" + }, + "model.elementary.job_run_results": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "JOB_RUN_RESULTS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "NAME": { + "type": "TEXT", + "index": 1, + "name": "NAME", + "comment": null + }, + "ID": { + "type": "TEXT", + "index": 2, + "name": "ID", + "comment": null + }, + "RUN_ID": { + "type": "TEXT", + "index": 3, + "name": "RUN_ID", + "comment": null + }, + "RUN_STARTED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 4, + "name": "RUN_STARTED_AT", + "comment": null + }, + "RUN_COMPLETED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 5, + "name": "RUN_COMPLETED_AT", + "comment": null + }, + "RUN_EXECUTION_TIME": { + "type": "NUMBER", + "index": 6, + "name": "RUN_EXECUTION_TIME", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.job_run_results" + }, + "model.elementary.monitors_runs": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "MONITORS_RUNS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "FULL_TABLE_NAME": { + "type": "TEXT", + "index": 1, + "name": "FULL_TABLE_NAME", + "comment": null + }, + "COLUMN_NAME": { + "type": "TEXT", + "index": 2, + "name": "COLUMN_NAME", + "comment": null + }, + "METRIC_NAME": { + "type": "TEXT", + "index": 3, + "name": "METRIC_NAME", + "comment": null + }, + "METRIC_PROPERTIES": { + "type": "TEXT", + "index": 4, + "name": "METRIC_PROPERTIES", + "comment": null + }, + "LAST_BUCKET_END": { + "type": "TIMESTAMP_NTZ", + "index": 5, + "name": "LAST_BUCKET_END", + "comment": null + }, + "FIRST_BUCKET_END": { + "type": "TIMESTAMP_NTZ", + "index": 6, + "name": "FIRST_BUCKET_END", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.monitors_runs" + }, + "model.elementary.dbt_tests": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "DBT_TESTS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "UNIQUE_ID": { + "type": "TEXT", + "index": 1, + "name": "UNIQUE_ID", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 2, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 3, + "name": "SCHEMA_NAME", + "comment": null + }, + "NAME": { + "type": "TEXT", + "index": 4, + "name": "NAME", + "comment": null + }, + "SHORT_NAME": { + "type": "TEXT", + "index": 5, + "name": "SHORT_NAME", + "comment": null + }, + "ALIAS": { + "type": "TEXT", + "index": 6, + "name": "ALIAS", + "comment": null + }, + "TEST_COLUMN_NAME": { + "type": "TEXT", + "index": 7, + "name": "TEST_COLUMN_NAME", + "comment": null + }, + "SEVERITY": { + "type": "TEXT", + "index": 8, + "name": "SEVERITY", + "comment": null + }, + "WARN_IF": { + "type": "TEXT", + "index": 9, + "name": "WARN_IF", + "comment": null + }, + "ERROR_IF": { + "type": "TEXT", + "index": 10, + "name": "ERROR_IF", + "comment": null + }, + "TEST_PARAMS": { + "type": "TEXT", + "index": 11, + "name": "TEST_PARAMS", + "comment": null + }, + "TEST_NAMESPACE": { + "type": "TEXT", + "index": 12, + "name": "TEST_NAMESPACE", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 13, + "name": "TAGS", + "comment": null + }, + "MODEL_TAGS": { + "type": "TEXT", + "index": 14, + "name": "MODEL_TAGS", + "comment": null + }, + "MODEL_OWNERS": { + "type": "TEXT", + "index": 15, + "name": "MODEL_OWNERS", + "comment": null + }, + "META": { + "type": "TEXT", + "index": 16, + "name": "META", + "comment": null + }, + "DEPENDS_ON_MACROS": { + "type": "TEXT", + "index": 17, + "name": "DEPENDS_ON_MACROS", + "comment": null + }, + "DEPENDS_ON_NODES": { + "type": "TEXT", + "index": 18, + "name": "DEPENDS_ON_NODES", + "comment": null + }, + "PARENT_MODEL_UNIQUE_ID": { + "type": "TEXT", + "index": 19, + "name": "PARENT_MODEL_UNIQUE_ID", + "comment": null + }, + "DESCRIPTION": { + "type": "TEXT", + "index": 20, + "name": "DESCRIPTION", + "comment": null + }, + "PACKAGE_NAME": { + "type": "TEXT", + "index": 21, + "name": "PACKAGE_NAME", + "comment": null + }, + "TYPE": { + "type": "TEXT", + "index": 22, + "name": "TYPE", + "comment": null + }, + "ORIGINAL_PATH": { + "type": "TEXT", + "index": 23, + "name": "ORIGINAL_PATH", + "comment": null + }, + "PATH": { + "type": "TEXT", + "index": 24, + "name": "PATH", + "comment": null + }, + "GENERATED_AT": { + "type": "TEXT", + "index": 25, + "name": "GENERATED_AT", + "comment": null + }, + "METADATA_HASH": { + "type": "TEXT", + "index": 26, + "name": "METADATA_HASH", + "comment": null + }, + "QUALITY_DIMENSION": { + "type": "TEXT", + "index": 27, + "name": "QUALITY_DIMENSION", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 20, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 12800, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:09UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.dbt_tests" + }, + "model.jaffle_shop_package.stg_depends_on_stg": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "STG_DEPENDS_ON_STG", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 1, + "name": "CUSTOMER_ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + }, + "FIRST_ORDER_DATE": { + "type": "DATE", + "index": 4, + "name": "FIRST_ORDER_DATE", + "comment": null + }, + "MOST_RECENT_ORDER_DATE": { + "type": "DATE", + "index": 5, + "name": "MOST_RECENT_ORDER_DATE", + "comment": null + }, + "NUMBER_OF_ORDERS": { + "type": "NUMBER", + "index": 6, + "name": "NUMBER_OF_ORDERS", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.stg_depends_on_stg" + }, + "model.jaffle_shop_package.mart_downstream_model_dependent_on_source": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "MART_DOWNSTREAM_MODEL_DEPENDENT_ON_SOURCE", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 1, + "name": "CUSTOMER_ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + }, + "FIRST_ORDER_DATE": { + "type": "DATE", + "index": 4, + "name": "FIRST_ORDER_DATE", + "comment": null + }, + "MOST_RECENT_ORDER_DATE": { + "type": "DATE", + "index": 5, + "name": "MOST_RECENT_ORDER_DATE", + "comment": null + }, + "NUMBER_OF_ORDERS": { + "type": "NUMBER", + "index": 6, + "name": "NUMBER_OF_ORDERS", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.mart_downstream_model_dependent_on_source" + }, + "model.jaffle_shop_package.source_fanout1": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "SOURCE_FANOUT1", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 1, + "name": "CUSTOMER_ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + }, + "FIRST_ORDER_DATE": { + "type": "DATE", + "index": 4, + "name": "FIRST_ORDER_DATE", + "comment": null + }, + "MOST_RECENT_ORDER_DATE": { + "type": "DATE", + "index": 5, + "name": "MOST_RECENT_ORDER_DATE", + "comment": null + }, + "NUMBER_OF_ORDERS": { + "type": "NUMBER", + "index": 6, + "name": "NUMBER_OF_ORDERS", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.source_fanout1" + }, + "model.jaffle_shop_package.stg_payments": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "STG_PAYMENTS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "PAYMENT_ID": { + "type": "NUMBER", + "index": 1, + "name": "PAYMENT_ID", + "comment": null + }, + "ORDER_ID": { + "type": "NUMBER", + "index": 2, + "name": "ORDER_ID", + "comment": null + }, + "PAYMENT_METHOD": { + "type": "TEXT", + "index": 3, + "name": "PAYMENT_METHOD", + "comment": null + }, + "AMOUNT": { + "type": "NUMBER", + "index": 4, + "name": "AMOUNT", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.stg_payments" + }, + "model.elementary.data_monitoring_metrics": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "DATA_MONITORING_METRICS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ID": { + "type": "TEXT", + "index": 1, + "name": "ID", + "comment": null + }, + "FULL_TABLE_NAME": { + "type": "TEXT", + "index": 2, + "name": "FULL_TABLE_NAME", + "comment": null + }, + "COLUMN_NAME": { + "type": "TEXT", + "index": 3, + "name": "COLUMN_NAME", + "comment": null + }, + "METRIC_NAME": { + "type": "TEXT", + "index": 4, + "name": "METRIC_NAME", + "comment": null + }, + "METRIC_VALUE": { + "type": "FLOAT", + "index": 5, + "name": "METRIC_VALUE", + "comment": null + }, + "SOURCE_VALUE": { + "type": "TEXT", + "index": 6, + "name": "SOURCE_VALUE", + "comment": null + }, + "BUCKET_START": { + "type": "TIMESTAMP_NTZ", + "index": 7, + "name": "BUCKET_START", + "comment": null + }, + "BUCKET_END": { + "type": "TIMESTAMP_NTZ", + "index": 8, + "name": "BUCKET_END", + "comment": null + }, + "BUCKET_DURATION_HOURS": { + "type": "NUMBER", + "index": 9, + "name": "BUCKET_DURATION_HOURS", + "comment": null + }, + "UPDATED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 10, + "name": "UPDATED_AT", + "comment": null + }, + "DIMENSION": { + "type": "TEXT", + "index": 11, + "name": "DIMENSION", + "comment": null + }, + "DIMENSION_VALUE": { + "type": "TEXT", + "index": 12, + "name": "DIMENSION_VALUE", + "comment": null + }, + "METRIC_PROPERTIES": { + "type": "TEXT", + "index": 13, + "name": "METRIC_PROPERTIES", + "comment": null + }, + "CREATED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 14, + "name": "CREATED_AT", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 206, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 9728, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:09UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.data_monitoring_metrics" + }, + "model.elementary.alerts_dbt_models": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "ALERTS_DBT_MODELS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ALERT_ID": { + "type": "TEXT", + "index": 1, + "name": "ALERT_ID", + "comment": null + }, + "UNIQUE_ID": { + "type": "TEXT", + "index": 2, + "name": "UNIQUE_ID", + "comment": null + }, + "DETECTED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 3, + "name": "DETECTED_AT", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 4, + "name": "DATABASE_NAME", + "comment": null + }, + "MATERIALIZATION": { + "type": "TEXT", + "index": 5, + "name": "MATERIALIZATION", + "comment": null + }, + "PATH": { + "type": "TEXT", + "index": 6, + "name": "PATH", + "comment": null + }, + "ORIGINAL_PATH": { + "type": "TEXT", + "index": 7, + "name": "ORIGINAL_PATH", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 8, + "name": "SCHEMA_NAME", + "comment": null + }, + "MESSAGE": { + "type": "TEXT", + "index": 9, + "name": "MESSAGE", + "comment": null + }, + "OWNERS": { + "type": "TEXT", + "index": 10, + "name": "OWNERS", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 11, + "name": "TAGS", + "comment": null + }, + "ALIAS": { + "type": "TEXT", + "index": 12, + "name": "ALIAS", + "comment": null + }, + "STATUS": { + "type": "TEXT", + "index": 13, + "name": "STATUS", + "comment": null + }, + "FULL_REFRESH": { + "type": "BOOLEAN", + "index": 14, + "name": "FULL_REFRESH", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.alerts_dbt_models" + }, + "model.jaffle_shop_package.orders": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP", + "name": "ORDERS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "ORDER_ID": { + "type": "NUMBER", + "index": 1, + "name": "ORDER_ID", + "comment": null + }, + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 2, + "name": "CUSTOMER_ID", + "comment": null + }, + "ORDER_DATE": { + "type": "DATE", + "index": 3, + "name": "ORDER_DATE", + "comment": null + }, + "STATUS": { + "type": "TEXT", + "index": 4, + "name": "STATUS", + "comment": null + }, + "CREDIT_CARD_AMOUNT": { + "type": "NUMBER", + "index": 5, + "name": "CREDIT_CARD_AMOUNT", + "comment": null + }, + "COUPON_AMOUNT": { + "type": "NUMBER", + "index": 6, + "name": "COUPON_AMOUNT", + "comment": null + }, + "BANK_TRANSFER_AMOUNT": { + "type": "NUMBER", + "index": 7, + "name": "BANK_TRANSFER_AMOUNT", + "comment": null + }, + "GIFT_CARD_AMOUNT": { + "type": "NUMBER", + "index": 8, + "name": "GIFT_CARD_AMOUNT", + "comment": null + }, + "AMOUNT": { + "type": "NUMBER", + "index": 9, + "name": "AMOUNT", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.jaffle_shop_package.orders" + }, + "model.elementary.anomaly_threshold_sensitivity": { + "metadata": { + "type": "VIEW", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "ANOMALY_THRESHOLD_SENSITIVITY", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "FULL_TABLE_NAME": { + "type": "TEXT", + "index": 1, + "name": "FULL_TABLE_NAME", + "comment": null + }, + "COLUMN_NAME": { + "type": "TEXT", + "index": 2, + "name": "COLUMN_NAME", + "comment": null + }, + "METRIC_NAME": { + "type": "TEXT", + "index": 3, + "name": "METRIC_NAME", + "comment": null + }, + "LATEST_METRIC_VALUE": { + "type": "FLOAT", + "index": 4, + "name": "LATEST_METRIC_VALUE", + "comment": null + }, + "METRIC_AVG": { + "type": "FLOAT", + "index": 5, + "name": "METRIC_AVG", + "comment": null + }, + "METRIC_STDDEV": { + "type": "FLOAT", + "index": 6, + "name": "METRIC_STDDEV", + "comment": null + }, + "ANOMALY_SCORE": { + "type": "FLOAT", + "index": 7, + "name": "ANOMALY_SCORE", + "comment": null + }, + "is_anomaly_1_5": { + "type": "BOOLEAN", + "index": 8, + "name": "is_anomaly_1_5", + "comment": null + }, + "is_anomaly_2": { + "type": "BOOLEAN", + "index": 9, + "name": "is_anomaly_2", + "comment": null + }, + "is_anomaly_2_5": { + "type": "BOOLEAN", + "index": 10, + "name": "is_anomaly_2_5", + "comment": null + }, + "is_anomaly_3": { + "type": "BOOLEAN", + "index": 11, + "name": "is_anomaly_3", + "comment": null + }, + "is_anomaly_3_5": { + "type": "BOOLEAN", + "index": 12, + "name": "is_anomaly_3_5", + "comment": null + }, + "is_anomaly_4": { + "type": "BOOLEAN", + "index": 13, + "name": "is_anomaly_4", + "comment": null + }, + "is_anomaly_4_5": { + "type": "BOOLEAN", + "index": 14, + "name": "is_anomaly_4_5", + "comment": null + } + }, + "stats": { + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": false, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.anomaly_threshold_sensitivity" + }, + "model.elementary.dbt_seeds": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "DBT_SEEDS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "UNIQUE_ID": { + "type": "TEXT", + "index": 1, + "name": "UNIQUE_ID", + "comment": null + }, + "ALIAS": { + "type": "TEXT", + "index": 2, + "name": "ALIAS", + "comment": null + }, + "CHECKSUM": { + "type": "TEXT", + "index": 3, + "name": "CHECKSUM", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 4, + "name": "TAGS", + "comment": null + }, + "META": { + "type": "TEXT", + "index": 5, + "name": "META", + "comment": null + }, + "OWNER": { + "type": "TEXT", + "index": 6, + "name": "OWNER", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 7, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 8, + "name": "SCHEMA_NAME", + "comment": null + }, + "DESCRIPTION": { + "type": "TEXT", + "index": 9, + "name": "DESCRIPTION", + "comment": null + }, + "NAME": { + "type": "TEXT", + "index": 10, + "name": "NAME", + "comment": null + }, + "PACKAGE_NAME": { + "type": "TEXT", + "index": 11, + "name": "PACKAGE_NAME", + "comment": null + }, + "ORIGINAL_PATH": { + "type": "TEXT", + "index": 12, + "name": "ORIGINAL_PATH", + "comment": null + }, + "PATH": { + "type": "TEXT", + "index": 13, + "name": "PATH", + "comment": null + }, + "GENERATED_AT": { + "type": "TEXT", + "index": 14, + "name": "GENERATED_AT", + "comment": null + }, + "METADATA_HASH": { + "type": "TEXT", + "index": 15, + "name": "METADATA_HASH", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 3, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 5632, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:08UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.dbt_seeds" + }, + "model.elementary.dbt_models": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "DBT_MODELS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "UNIQUE_ID": { + "type": "TEXT", + "index": 1, + "name": "UNIQUE_ID", + "comment": null + }, + "ALIAS": { + "type": "TEXT", + "index": 2, + "name": "ALIAS", + "comment": null + }, + "CHECKSUM": { + "type": "TEXT", + "index": 3, + "name": "CHECKSUM", + "comment": null + }, + "MATERIALIZATION": { + "type": "TEXT", + "index": 4, + "name": "MATERIALIZATION", + "comment": null + }, + "TAGS": { + "type": "TEXT", + "index": 5, + "name": "TAGS", + "comment": null + }, + "META": { + "type": "TEXT", + "index": 6, + "name": "META", + "comment": null + }, + "OWNER": { + "type": "TEXT", + "index": 7, + "name": "OWNER", + "comment": null + }, + "DATABASE_NAME": { + "type": "TEXT", + "index": 8, + "name": "DATABASE_NAME", + "comment": null + }, + "SCHEMA_NAME": { + "type": "TEXT", + "index": 9, + "name": "SCHEMA_NAME", + "comment": null + }, + "DEPENDS_ON_MACROS": { + "type": "TEXT", + "index": 10, + "name": "DEPENDS_ON_MACROS", + "comment": null + }, + "DEPENDS_ON_NODES": { + "type": "TEXT", + "index": 11, + "name": "DEPENDS_ON_NODES", + "comment": null + }, + "DESCRIPTION": { + "type": "TEXT", + "index": 12, + "name": "DESCRIPTION", + "comment": null + }, + "NAME": { + "type": "TEXT", + "index": 13, + "name": "NAME", + "comment": null + }, + "PACKAGE_NAME": { + "type": "TEXT", + "index": 14, + "name": "PACKAGE_NAME", + "comment": null + }, + "ORIGINAL_PATH": { + "type": "TEXT", + "index": 15, + "name": "ORIGINAL_PATH", + "comment": null + }, + "PATH": { + "type": "TEXT", + "index": 16, + "name": "PATH", + "comment": null + }, + "PATCH_PATH": { + "type": "TEXT", + "index": 17, + "name": "PATCH_PATH", + "comment": null + }, + "GENERATED_AT": { + "type": "TEXT", + "index": 18, + "name": "GENERATED_AT", + "comment": null + }, + "METADATA_HASH": { + "type": "TEXT", + "index": 19, + "name": "METADATA_HASH", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 48, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 18432, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-13 00:08UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.dbt_models" + }, + "model.elementary.schema_columns_snapshot": { + "metadata": { + "type": "BASE TABLE", + "schema": "JAFFLE_SHOP_ELEMENTARY", + "name": "SCHEMA_COLUMNS_SNAPSHOT", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "COLUMN_STATE_ID": { + "type": "TEXT", + "index": 1, + "name": "COLUMN_STATE_ID", + "comment": null + }, + "FULL_COLUMN_NAME": { + "type": "TEXT", + "index": 2, + "name": "FULL_COLUMN_NAME", + "comment": null + }, + "FULL_TABLE_NAME": { + "type": "TEXT", + "index": 3, + "name": "FULL_TABLE_NAME", + "comment": null + }, + "COLUMN_NAME": { + "type": "TEXT", + "index": 4, + "name": "COLUMN_NAME", + "comment": null + }, + "DATA_TYPE": { + "type": "TEXT", + "index": 5, + "name": "DATA_TYPE", + "comment": null + }, + "IS_NEW": { + "type": "BOOLEAN", + "index": 6, + "name": "IS_NEW", + "comment": null + }, + "DETECTED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 7, + "name": "DETECTED_AT", + "comment": null + }, + "CREATED_AT": { + "type": "TIMESTAMP_NTZ", + "index": 8, + "name": "CREATED_AT", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 0, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 0, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2024-01-02 17:57UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "model.elementary.schema_columns_snapshot" + } + }, + "sources": { + "source.jaffle_shop_package.jaffle_shop.customers": { + "metadata": { + "type": "BASE TABLE", + "schema": "PUBLIC", + "name": "CUSTOMERS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 1, + "name": "CUSTOMER_ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + }, + "FIRST_ORDER_DATE": { + "type": "DATE", + "index": 4, + "name": "FIRST_ORDER_DATE", + "comment": null + }, + "MOST_RECENT_ORDER_DATE": { + "type": "DATE", + "index": 5, + "name": "MOST_RECENT_ORDER_DATE", + "comment": null + }, + "NUMBER_OF_ORDERS": { + "type": "NUMBER", + "index": 6, + "name": "NUMBER_OF_ORDERS", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 100, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 3584, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2023-12-16 02:56UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "source.jaffle_shop_package.jaffle_shop.customers" + }, + "source.jaffle_shop_package.stripe.stripe_customers": { + "metadata": { + "type": "BASE TABLE", + "schema": "PUBLIC", + "name": "CUSTOMERS", + "database": "ANALYTICS", + "comment": null, + "owner": "ACCOUNTADMIN" + }, + "columns": { + "CUSTOMER_ID": { + "type": "NUMBER", + "index": 1, + "name": "CUSTOMER_ID", + "comment": null + }, + "FIRST_NAME": { + "type": "TEXT", + "index": 2, + "name": "FIRST_NAME", + "comment": null + }, + "LAST_NAME": { + "type": "TEXT", + "index": 3, + "name": "LAST_NAME", + "comment": null + }, + "FIRST_ORDER_DATE": { + "type": "DATE", + "index": 4, + "name": "FIRST_ORDER_DATE", + "comment": null + }, + "MOST_RECENT_ORDER_DATE": { + "type": "DATE", + "index": 5, + "name": "MOST_RECENT_ORDER_DATE", + "comment": null + }, + "NUMBER_OF_ORDERS": { + "type": "NUMBER", + "index": 6, + "name": "NUMBER_OF_ORDERS", + "comment": null + } + }, + "stats": { + "row_count": { + "id": "row_count", + "label": "Row Count", + "value": 100, + "include": true, + "description": "An approximate count of rows in this table" + }, + "bytes": { + "id": "bytes", + "label": "Approximate Size", + "value": 3584, + "include": true, + "description": "Approximate size of the table as reported by Snowflake" + }, + "last_modified": { + "id": "last_modified", + "label": "Last Modified", + "value": "2023-12-16 02:56UTC", + "include": true, + "description": "The timestamp for last update/change" + }, + "has_stats": { + "id": "has_stats", + "label": "Has Stats?", + "value": true, + "include": false, + "description": "Indicates whether there are statistics for this table" + } + }, + "unique_id": "source.jaffle_shop_package.stripe.stripe_customers" + } + }, + "errors": null +} \ No newline at end of file diff --git a/tests/data/config.yml b/tests/data/config.yml new file mode 100644 index 00000000..0e59afe5 --- /dev/null +++ b/tests/data/config.yml @@ -0,0 +1,17 @@ +version: v1 + +model_type_patterns: + staging: "^stg_.*" + mart: "^(mrt_|mart_|fct_|dim_).*" + intermediate: "^int_.*" + base: "^base_.*" + + +insights: + dbt_low_test_coverage: + min_test_coverage_percent: 30 + severity: WARNING + model_fanout.max_fanout: 10 + source_fanout.max_fanout: 10 + staging_models_dependency.downstream_model_types: + - mart diff --git a/tests/data/manifest_v11.json b/tests/data/manifest_v11.json new file mode 100644 index 00000000..132d17e1 --- /dev/null +++ b/tests/data/manifest_v11.json @@ -0,0 +1,38002 @@ +{ + "metadata": { + "dbt_schema_version": "https://schemas.getdbt.com/dbt/manifest/v11.json", + "dbt_version": "1.7.4", + "generated_at": "2024-01-13T01:22:22.335824Z", + "invocation_id": "4cc35bf3-4c5a-4af6-b569-1d16b145a046", + "env": {}, + "project_name": "jaffle_shop_package", + "project_id": "f0e4870a7bce5cac53eb27a209d47924", + "user_id": "0d283f3c-5036-486e-ba8b-5049eb27db3e", + "send_anonymous_usage_stats": true, + "adapter_type": "snowflake" + }, + "nodes": { + "model.jaffle_shop_package.hard_coded": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "hard_coded", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "hard_coded.sql", + "original_file_path": "models/hard_coded.sql", + "unique_id": "model.jaffle_shop_package.hard_coded", + "fqn": [ + "jaffle_shop_package", + "hard_coded" + ], + "alias": "hard_coded", + "checksum": { + "name": "sha256", + "checksum": "a09bc4cc95da8b115f8effc04b3e84bb6a96cd726e8358e3bc670b3919379105" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031517.9006279, + "relation_name": "analytics.jaffle_shop.hard_coded", + "raw_code": "select * from analytics.raw.orders", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/hard_coded.sql", + "compiled": true, + "compiled_code": "select * from analytics.raw.orders", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.customers": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "customers", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "customers.sql", + "original_file_path": "models/customers.sql", + "unique_id": "model.jaffle_shop_package.customers", + "fqn": [ + "jaffle_shop_package", + "customers" + ], + "alias": "customers", + "checksum": { + "name": "sha256", + "checksum": "60bd72e33da43fff3a7e7609135c17cd4468bd22afec0735dd36018bfb5af30a" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "This table has basic information about a customer, as well as some derived facts based on a customer's orders", + "columns": { + "customer_id": { + "name": "customer_id", + "description": "This is a unique identifier for a customer", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "first_name": { + "name": "first_name", + "description": "Customer's first name. PII.", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "last_name": { + "name": "last_name", + "description": "Customer's last name. PII.", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "first_order": { + "name": "first_order", + "description": "Date (UTC) of a customer's first order", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "most_recent_order": { + "name": "most_recent_order", + "description": "Date (UTC) of a customer's most recent order", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "number_of_orders": { + "name": "number_of_orders", + "description": "Count of the number of orders a customer has placed", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "total_order_amount": { + "name": "total_order_amount", + "description": "Total value (AUD) of a customer's orders", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + } + }, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "jaffle_shop_package://models/schema.yml", + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.576149, + "relation_name": "analytics.jaffle_shop.customers", + "raw_code": "with customers as (\n\n select * from {{ ref('stg_customers') }}\n\n),\n\norders as (\n\n select * from {{ ref('stg_orders') }}\n\n),\n\npayments as (\n\n select * from {{ ref('stg_payments') }}\n\n),\n\ncustomer_orders as (\n\n select\n customer_id,\n\n min(order_date) as first_order,\n max(order_date) as most_recent_order,\n count(order_id) as number_of_orders\n from orders\n\n group by customer_id\n\n),\n\ncustomer_payments as (\n\n select\n orders.customer_id,\n sum(amount) as total_amount\n\n from payments\n\n left join orders on\n payments.order_id = orders.order_id\n\n group by orders.customer_id\n\n),\n\nfinal as (\n\n select\n customers.customer_id,\n customers.first_name,\n customers.last_name,\n customer_orders.first_order,\n customer_orders.most_recent_order,\n customer_orders.number_of_orders,\n customer_payments.total_amount as customer_lifetime_value\n\n from customers\n\n left join customer_orders\n on customers.customer_id = customer_orders.customer_id\n\n left join customer_payments\n on customers.customer_id = customer_payments.customer_id\n\n)\n\nselect * from final", + "language": "sql", + "refs": [ + { + "name": "stg_customers", + "package": null, + "version": null + }, + { + "name": "stg_orders", + "package": null, + "version": null + }, + { + "name": "stg_payments", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "model.jaffle_shop_package.stg_customers", + "model.jaffle_shop_package.stg_orders", + "model.jaffle_shop_package.stg_payments" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/customers.sql", + "compiled": true, + "compiled_code": "with customers as (\n\n select * from analytics.jaffle_shop.stg_customers\n\n),\n\norders as (\n\n select * from analytics.jaffle_shop.stg_orders\n\n),\n\npayments as (\n\n select * from analytics.jaffle_shop.stg_payments\n\n),\n\ncustomer_orders as (\n\n select\n customer_id,\n\n min(order_date) as first_order,\n max(order_date) as most_recent_order,\n count(order_id) as number_of_orders\n from orders\n\n group by customer_id\n\n),\n\ncustomer_payments as (\n\n select\n orders.customer_id,\n sum(amount) as total_amount\n\n from payments\n\n left join orders on\n payments.order_id = orders.order_id\n\n group by orders.customer_id\n\n),\n\nfinal as (\n\n select\n customers.customer_id,\n customers.first_name,\n customers.last_name,\n customer_orders.first_order,\n customer_orders.most_recent_order,\n customer_orders.number_of_orders,\n customer_payments.total_amount as customer_lifetime_value\n\n from customers\n\n left join customer_orders\n on customers.customer_id = customer_orders.customer_id\n\n left join customer_payments\n on customers.customer_id = customer_payments.customer_id\n\n)\n\nselect * from final", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.direct_join_to_source": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "direct_join_to_source", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "direct_join_to_source.sql", + "original_file_path": "models/direct_join_to_source.sql", + "unique_id": "model.jaffle_shop_package.direct_join_to_source", + "fqn": [ + "jaffle_shop_package", + "direct_join_to_source" + ], + "alias": "direct_join_to_source", + "checksum": { + "name": "sha256", + "checksum": "32e886539d1734c797b551b1c828f7f8e91452f30acc7de96570f6fa59f9def4" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031517.903476, + "relation_name": "analytics.jaffle_shop.direct_join_to_source", + "raw_code": "select a.* from {{ ref('customers') }} a join {{ source('jaffle_shop', 'customers') }}", + "language": "sql", + "refs": [ + { + "name": "customers", + "package": null, + "version": null + } + ], + "sources": [ + [ + "jaffle_shop", + "customers" + ] + ], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "source.jaffle_shop_package.jaffle_shop.customers", + "model.jaffle_shop_package.customers" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/direct_join_to_source.sql", + "compiled": true, + "compiled_code": "select a.* from analytics.jaffle_shop.customers a join analytics.public.customers", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.orders": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "orders", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "orders.sql", + "original_file_path": "models/orders.sql", + "unique_id": "model.jaffle_shop_package.orders", + "fqn": [ + "jaffle_shop_package", + "orders" + ], + "alias": "orders", + "checksum": { + "name": "sha256", + "checksum": "27f8c79aad1cfd8411ab9c3d2ce8da1d787f7f05c58bbee1d247510dc426be0f" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "This table has basic information about orders, as well as some derived facts based on payments", + "columns": { + "order_id": { + "name": "order_id", + "description": "This is a unique identifier for an order", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "customer_id": { + "name": "customer_id", + "description": "Foreign key to the customers table", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "order_date": { + "name": "order_date", + "description": "Date (UTC) that the order was placed", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "status": { + "name": "status", + "description": "Orders can be one of the following statuses:\n\n| status | description |\n|----------------|------------------------------------------------------------------------------------------------------------------------|\n| placed | The order has been placed but has not yet left the warehouse |\n| shipped | The order has ben shipped to the customer and is currently in transit |\n| completed | The order has been received by the customer |\n| return_pending | The customer has indicated that they would like to return the order, but it has not yet been received at the warehouse |\n| returned | The order has been returned by the customer and received at the warehouse |", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "amount": { + "name": "amount", + "description": "Total amount (AUD) of the order", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "credit_card_amount": { + "name": "credit_card_amount", + "description": "Amount of the order (AUD) paid for by credit card", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "coupon_amount": { + "name": "coupon_amount", + "description": "Amount of the order (AUD) paid for by coupon", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "bank_transfer_amount": { + "name": "bank_transfer_amount", + "description": "Amount of the order (AUD) paid for by bank transfer", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "gift_card_amount": { + "name": "gift_card_amount", + "description": "Amount of the order (AUD) paid for by gift card", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + } + }, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "jaffle_shop_package://models/schema.yml", + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.577984, + "relation_name": "analytics.jaffle_shop.orders", + "raw_code": "{% set payment_methods = ['credit_card', 'coupon', 'bank_transfer', 'gift_card'] %}\n\nwith orders as (\n\n select * from {{ ref('stg_orders') }}\n\n),\n\npayments as (\n\n select * from {{ ref('stg_payments') }}\n\n),\n\norder_payments as (\n\n select\n order_id,\n\n {% for payment_method in payment_methods -%}\n sum(case when payment_method = '{{ payment_method }}' then amount else 0 end) as {{ payment_method }}_amount,\n {% endfor -%}\n\n sum(amount) as total_amount\n\n from payments\n\n group by order_id\n\n),\n\nfinal as (\n\n select\n orders.order_id,\n orders.customer_id,\n orders.order_date,\n orders.status,\n\n {% for payment_method in payment_methods -%}\n\n order_payments.{{ payment_method }}_amount,\n\n {% endfor -%}\n\n order_payments.total_amount as amount\n\n from orders\n\n\n left join order_payments\n on orders.order_id = order_payments.order_id\n\n)\n\nselect * from final", + "language": "sql", + "refs": [ + { + "name": "stg_orders", + "package": null, + "version": null + }, + { + "name": "stg_payments", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "model.jaffle_shop_package.stg_orders", + "model.jaffle_shop_package.stg_payments" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/orders.sql", + "compiled": true, + "compiled_code": "\n\nwith orders as (\n\n select * from analytics.jaffle_shop.stg_orders\n\n),\n\npayments as (\n\n select * from analytics.jaffle_shop.stg_payments\n\n),\n\norder_payments as (\n\n select\n order_id,\n\n sum(case when payment_method = 'credit_card' then amount else 0 end) as credit_card_amount,\n sum(case when payment_method = 'coupon' then amount else 0 end) as coupon_amount,\n sum(case when payment_method = 'bank_transfer' then amount else 0 end) as bank_transfer_amount,\n sum(case when payment_method = 'gift_card' then amount else 0 end) as gift_card_amount,\n sum(amount) as total_amount\n\n from payments\n\n group by order_id\n\n),\n\nfinal as (\n\n select\n orders.order_id,\n orders.customer_id,\n orders.order_date,\n orders.status,\n\n order_payments.credit_card_amount,\n\n order_payments.coupon_amount,\n\n order_payments.bank_transfer_amount,\n\n order_payments.gift_card_amount,\n\n order_payments.total_amount as amount\n\n from orders\n\n\n left join order_payments\n on orders.order_id = order_payments.order_id\n\n)\n\nselect * from final", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.stg_customers": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "stg_customers", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "staging/stg_customers.sql", + "original_file_path": "models/staging/stg_customers.sql", + "unique_id": "model.jaffle_shop_package.stg_customers", + "fqn": [ + "jaffle_shop_package", + "staging", + "stg_customers" + ], + "alias": "stg_customers", + "checksum": { + "name": "sha256", + "checksum": "80e3223cd54387e11fa16cd0f4cbe15f8ff74dcd9900b93856b9e39416178c9d" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": { + "customer_id": { + "name": "customer_id", + "description": "", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + } + }, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "jaffle_shop_package://models/staging/schema.yml", + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.678302, + "relation_name": "analytics.jaffle_shop.stg_customers", + "raw_code": "with source as (\n\n {#-\n Normally we would select from the table here, but we are using seeds to load\n our data in this project\n #}\n select * from {{ ref('raw_customers') }}\n\n),\n\nrenamed as (\n\n select\n id as customer_id,\n first_name,\n last_name\n\n from source\n\n)\n\nselect * from renamed", + "language": "sql", + "refs": [ + { + "name": "raw_customers", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "seed.jaffle_shop_package.raw_customers" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/staging/stg_customers.sql", + "compiled": true, + "compiled_code": "with source as (\n select * from analytics.jaffle_shop.raw_customers\n\n),\n\nrenamed as (\n\n select\n id as customer_id,\n first_name,\n last_name\n\n from source\n\n)\n\nselect * from renamed", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.stg_payments": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "stg_payments", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "staging/stg_payments.sql", + "original_file_path": "models/staging/stg_payments.sql", + "unique_id": "model.jaffle_shop_package.stg_payments", + "fqn": [ + "jaffle_shop_package", + "staging", + "stg_payments" + ], + "alias": "stg_payments", + "checksum": { + "name": "sha256", + "checksum": "9c1ee3bfb10e07c2dfc325d55925da0e521887136d9051768cb8acf09dc86bda" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": { + "payment_id": { + "name": "payment_id", + "description": "", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "payment_method": { + "name": "payment_method", + "description": "", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + } + }, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "jaffle_shop_package://models/staging/schema.yml", + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.6793349, + "relation_name": "analytics.jaffle_shop.stg_payments", + "raw_code": "with source as (\n \n {#-\n Normally we would select from the table here, but we are using seeds to load\n our data in this project\n #}\n select * from {{ ref('raw_payments') }}\n\n),\n\nrenamed as (\n\n select\n id as payment_id,\n order_id,\n payment_method,\n\n -- `amount` is currently stored in cents, so we convert it to dollars\n amount / 100 as amount\n\n from source\n\n)\n\nselect * from renamed", + "language": "sql", + "refs": [ + { + "name": "raw_payments", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "seed.jaffle_shop_package.raw_payments" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/staging/stg_payments.sql", + "compiled": true, + "compiled_code": "with source as (\n select * from analytics.jaffle_shop.raw_payments\n\n),\n\nrenamed as (\n\n select\n id as payment_id,\n order_id,\n payment_method,\n\n -- `amount` is currently stored in cents, so we convert it to dollars\n amount / 100 as amount\n\n from source\n\n)\n\nselect * from renamed", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.stg_orders": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "stg_orders", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "staging/stg_orders.sql", + "original_file_path": "models/staging/stg_orders.sql", + "unique_id": "model.jaffle_shop_package.stg_orders", + "fqn": [ + "jaffle_shop_package", + "staging", + "stg_orders" + ], + "alias": "stg_orders", + "checksum": { + "name": "sha256", + "checksum": "f4f881cb09d2c4162200fc331d7401df6d1abd4fed492554a7db70dede347108" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": { + "order_id": { + "name": "order_id", + "description": "", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "status": { + "name": "status", + "description": "", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + } + }, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "jaffle_shop_package://models/staging/schema.yml", + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.678633, + "relation_name": "analytics.jaffle_shop.stg_orders", + "raw_code": "with source as (\n\n {#-\n Normally we would select from the table here, but we are using seeds to load\n our data in this project\n #}\n select * from {{ ref('raw_orders') }}\n\n),\n\nrenamed as (\n\n select\n id as order_id,\n user_id as customer_id,\n order_date,\n status\n\n from source\n\n)\n\nselect * from renamed", + "language": "sql", + "refs": [ + { + "name": "raw_orders", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "seed.jaffle_shop_package.raw_orders" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/staging/stg_orders.sql", + "compiled": true, + "compiled_code": "with source as (\n select * from analytics.jaffle_shop.raw_orders\n\n),\n\nrenamed as (\n\n select\n id as order_id,\n user_id as customer_id,\n order_date,\n status\n\n from source\n\n)\n\nselect * from renamed", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "seed.jaffle_shop_package.raw_customers": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "raw_customers", + "resource_type": "seed", + "package_name": "jaffle_shop_package", + "path": "raw_customers.csv", + "original_file_path": "seeds/raw_customers.csv", + "unique_id": "seed.jaffle_shop_package.raw_customers", + "fqn": [ + "jaffle_shop_package", + "raw_customers" + ], + "alias": "raw_customers", + "checksum": { + "name": "sha256", + "checksum": "357d173dda65a741ad97d6683502286cc2655bb396ab5f4dfad12b8c39bd2a63" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "seed", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "delimiter": ",", + "quote_columns": null + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031517.961062, + "relation_name": "analytics.jaffle_shop.raw_customers", + "raw_code": "", + "root_path": "/Users/surya/repos/dbt-testing/jafle_shop_testing", + "depends_on": { + "macros": [] + } + }, + "seed.jaffle_shop_package.raw_orders": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "raw_orders", + "resource_type": "seed", + "package_name": "jaffle_shop_package", + "path": "raw_orders.csv", + "original_file_path": "seeds/raw_orders.csv", + "unique_id": "seed.jaffle_shop_package.raw_orders", + "fqn": [ + "jaffle_shop_package", + "raw_orders" + ], + "alias": "raw_orders", + "checksum": { + "name": "sha256", + "checksum": "ddecd7adf70a07a88b9c302aec2a03fce615b925c2c06f2d5ef99a5c97b41250" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "seed", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "delimiter": ",", + "quote_columns": null + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031517.9624808, + "relation_name": "analytics.jaffle_shop.raw_orders", + "raw_code": "", + "root_path": "/Users/surya/repos/dbt-testing/jafle_shop_testing", + "depends_on": { + "macros": [] + } + }, + "seed.jaffle_shop_package.raw_payments": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "raw_payments", + "resource_type": "seed", + "package_name": "jaffle_shop_package", + "path": "raw_payments.csv", + "original_file_path": "seeds/raw_payments.csv", + "unique_id": "seed.jaffle_shop_package.raw_payments", + "fqn": [ + "jaffle_shop_package", + "raw_payments" + ], + "alias": "raw_payments", + "checksum": { + "name": "sha256", + "checksum": "6de0626a8db9c1750eefd1b2e17fac4c2a4b9f778eb50532d8b377b90de395e6" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "seed", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "delimiter": ",", + "quote_columns": null + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031517.963795, + "relation_name": "analytics.jaffle_shop.raw_payments", + "raw_code": "", + "root_path": "/Users/surya/repos/dbt-testing/jafle_shop_testing", + "depends_on": { + "macros": [] + } + }, + "model.elementary.snapshot_run_results": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "snapshot_run_results", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/run_results/snapshot_run_results.sql", + "original_file_path": "models/edr/run_results/snapshot_run_results.sql", + "unique_id": "model.elementary.snapshot_run_results", + "fqn": [ + "elementary", + "edr", + "run_results", + "snapshot_run_results" + ], + "alias": "snapshot_run_results", + "checksum": { + "name": "sha256", + "checksum": "1b4464b5d2043628e6ca2f1b435220ef0d577a48eecfc07b5ea5657e69c55b02" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "bind": false + }, + "tags": [], + "description": "Run results of dbt snapshots, enriched with snapshots metadata. Each row is the result of a single snapshot. This is a view that joins data from `dbt_run_results` and `dbt_snapshots`.\n", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/run_results.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "view", + "bind": false, + "schema": "elementary" + }, + "created_at": 1705031518.716854, + "relation_name": "analytics.jaffle_shop_elementary.snapshot_run_results", + "raw_code": "{{\n config(\n materialized = 'view',\n bind=False\n )\n}}\n\nwith dbt_run_results as (\n select * from {{ ref('dbt_run_results') }}\n),\n\ndbt_snapshots as (\n select * from {{ ref('dbt_snapshots') }}\n)\n\nSELECT\n run_results.model_execution_id,\n run_results.unique_id,\n run_results.invocation_id,\n run_results.query_id,\n run_results.name,\n run_results.generated_at,\n run_results.status,\n run_results.full_refresh,\n run_results.message,\n run_results.execution_time,\n run_results.execute_started_at,\n run_results.execute_completed_at,\n run_results.compile_started_at,\n run_results.compile_completed_at,\n run_results.compiled_code,\n run_results.adapter_response,\n run_results.thread_id,\n snapshots.database_name,\n snapshots.schema_name,\n coalesce(run_results.materialization, snapshots.materialization) as materialization,\n snapshots.tags,\n snapshots.package_name,\n snapshots.path,\n snapshots.original_path,\n snapshots.owner,\n snapshots.alias\nFROM dbt_run_results run_results\nJOIN dbt_snapshots snapshots ON run_results.unique_id = snapshots.unique_id", + "language": "sql", + "refs": [ + { + "name": "dbt_run_results", + "package": null, + "version": null + }, + { + "name": "dbt_snapshots", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "model.elementary.dbt_run_results", + "model.elementary.dbt_snapshots" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/run_results/snapshot_run_results.sql", + "compiled": true, + "compiled_code": "\n\nwith dbt_run_results as (\n select * from analytics.jaffle_shop_elementary.dbt_run_results\n),\n\ndbt_snapshots as (\n select * from analytics.jaffle_shop_elementary.dbt_snapshots\n)\n\nSELECT\n run_results.model_execution_id,\n run_results.unique_id,\n run_results.invocation_id,\n run_results.query_id,\n run_results.name,\n run_results.generated_at,\n run_results.status,\n run_results.full_refresh,\n run_results.message,\n run_results.execution_time,\n run_results.execute_started_at,\n run_results.execute_completed_at,\n run_results.compile_started_at,\n run_results.compile_completed_at,\n run_results.compiled_code,\n run_results.adapter_response,\n run_results.thread_id,\n snapshots.database_name,\n snapshots.schema_name,\n coalesce(run_results.materialization, snapshots.materialization) as materialization,\n snapshots.tags,\n snapshots.package_name,\n snapshots.path,\n snapshots.original_path,\n snapshots.owner,\n snapshots.alias\nFROM dbt_run_results run_results\nJOIN dbt_snapshots snapshots ON run_results.unique_id = snapshots.unique_id", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.job_run_results": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "job_run_results", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/run_results/job_run_results.sql", + "original_file_path": "models/edr/run_results/job_run_results.sql", + "unique_id": "model.elementary.job_run_results", + "fqn": [ + "elementary", + "edr", + "run_results", + "job_run_results" + ], + "alias": "job_run_results", + "checksum": { + "name": "sha256", + "checksum": "70fa0f75184f074237575d1146a8caf3048d0d0300a5da5013b7a88f137bc810" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "bind": false + }, + "tags": [], + "description": "Run results of dbt invocations, enriched with jobs metadata. Each row is the result of a single job. This is a view on `dbt_invocations`.", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/run_results.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "view", + "bind": false, + "schema": "elementary" + }, + "created_at": 1705031518.717057, + "relation_name": "analytics.jaffle_shop_elementary.job_run_results", + "raw_code": "{{\n config(\n materialized = 'view',\n bind=False\n )\n}}\n\n{% set job_run_started_at %}\nmin({{ elementary.edr_cast_as_timestamp(\"run_started_at\") }})\n{% endset %}\n\n{% set job_run_completed_at %}\nmax({{ elementary.edr_cast_as_timestamp(\"run_completed_at\") }})\n{% endset %}\n\nwith jobs as (\n select\n job_name,\n job_id,\n job_run_id,\n {{ job_run_started_at }} as job_run_started_at,\n {{ job_run_completed_at }} as job_run_completed_at,\n {{ elementary.timediff(\"second\", job_run_started_at, job_run_completed_at) }} as job_run_execution_time\n from {{ ref('dbt_invocations') }}\n where job_id is not null\n group by job_name, job_id, job_run_id\n)\n\nselect\n job_name as name,\n job_id as id,\n job_run_id as run_id,\n job_run_started_at as run_started_at,\n job_run_completed_at as run_completed_at,\n job_run_execution_time as run_execution_time\nfrom jobs", + "language": "sql", + "refs": [ + { + "name": "dbt_invocations", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.timediff" + ], + "nodes": [ + "model.elementary.dbt_invocations" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/run_results/job_run_results.sql", + "compiled": true, + "compiled_code": "\n\n\n\n\n\nwith jobs as (\n select\n job_name,\n job_id,\n job_run_id,\n \nmin(cast(run_started_at as timestamp))\n as job_run_started_at,\n \nmax(cast(run_completed_at as timestamp))\n as job_run_completed_at,\n \n datediff(\n second,\n \nmin(cast(run_started_at as timestamp))\n,\n \nmax(cast(run_completed_at as timestamp))\n\n )\n as job_run_execution_time\n from analytics.jaffle_shop_elementary.dbt_invocations\n where job_id is not null\n group by job_name, job_id, job_run_id\n)\n\nselect\n job_name as name,\n job_id as id,\n job_run_id as run_id,\n job_run_started_at as run_started_at,\n job_run_completed_at as run_completed_at,\n job_run_execution_time as run_execution_time\nfrom jobs", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.model_run_results": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "model_run_results", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/run_results/model_run_results.sql", + "original_file_path": "models/edr/run_results/model_run_results.sql", + "unique_id": "model.elementary.model_run_results", + "fqn": [ + "elementary", + "edr", + "run_results", + "model_run_results" + ], + "alias": "model_run_results", + "checksum": { + "name": "sha256", + "checksum": "99fba47e42516fbdc31e2546f687e3f780f21eaa5ac303e1ed22d23262ac5ec9" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "bind": false + }, + "tags": [], + "description": "Run results of dbt models, enriched with models metadata. Each row is the result of a single model. This is a view that joins data from `dbt_run_results` and `dbt_models`.\n", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/run_results.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "view", + "bind": false, + "schema": "elementary" + }, + "created_at": 1705031518.7166479, + "relation_name": "analytics.jaffle_shop_elementary.model_run_results", + "raw_code": "{{\n config(\n materialized = 'view',\n bind=False\n )\n}}\n\nwith dbt_run_results as (\n select * from {{ ref('dbt_run_results') }}\n),\n\ndbt_models as (\n select * from {{ ref('dbt_models') }}\n)\n\nSELECT\n run_results.model_execution_id,\n run_results.unique_id,\n run_results.invocation_id,\n run_results.query_id,\n run_results.name,\n run_results.generated_at,\n run_results.status,\n run_results.full_refresh,\n run_results.message,\n run_results.execution_time,\n run_results.execute_started_at,\n run_results.execute_completed_at,\n run_results.compile_started_at,\n run_results.compile_completed_at,\n run_results.compiled_code,\n run_results.adapter_response,\n run_results.thread_id,\n models.database_name,\n models.schema_name,\n coalesce(run_results.materialization, models.materialization) as materialization,\n models.tags,\n models.package_name,\n models.path,\n models.original_path,\n models.owner,\n models.alias,\n ROW_NUMBER() OVER (PARTITION BY run_results.unique_id ORDER BY run_results.generated_at DESC) AS model_invocation_reverse_index,\n CASE WHEN FIRST_VALUE(invocation_id) OVER (PARTITION BY {{ elementary.edr_time_trunc('day', 'run_results.generated_at') }} ORDER BY run_results.generated_at ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) = invocation_id\n THEN TRUE\n ELSE FALSE \n END AS is_the_first_invocation_of_the_day,\n CASE WHEN LAST_VALUE(invocation_id) OVER (PARTITION BY {{ elementary.edr_time_trunc('day', 'run_results.generated_at') }} ORDER BY run_results.generated_at ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) = invocation_id\n THEN TRUE\n ELSE FALSE \n END AS is_the_last_invocation_of_the_day\n \nFROM dbt_run_results run_results\nJOIN dbt_models models ON run_results.unique_id = models.unique_id", + "language": "sql", + "refs": [ + { + "name": "dbt_run_results", + "package": null, + "version": null + }, + { + "name": "dbt_models", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.edr_time_trunc" + ], + "nodes": [ + "model.elementary.dbt_run_results", + "model.elementary.dbt_models" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/run_results/model_run_results.sql", + "compiled": true, + "compiled_code": "\n\nwith dbt_run_results as (\n select * from analytics.jaffle_shop_elementary.dbt_run_results\n),\n\ndbt_models as (\n select * from analytics.jaffle_shop_elementary.dbt_models\n)\n\nSELECT\n run_results.model_execution_id,\n run_results.unique_id,\n run_results.invocation_id,\n run_results.query_id,\n run_results.name,\n run_results.generated_at,\n run_results.status,\n run_results.full_refresh,\n run_results.message,\n run_results.execution_time,\n run_results.execute_started_at,\n run_results.execute_completed_at,\n run_results.compile_started_at,\n run_results.compile_completed_at,\n run_results.compiled_code,\n run_results.adapter_response,\n run_results.thread_id,\n models.database_name,\n models.schema_name,\n coalesce(run_results.materialization, models.materialization) as materialization,\n models.tags,\n models.package_name,\n models.path,\n models.original_path,\n models.owner,\n models.alias,\n ROW_NUMBER() OVER (PARTITION BY run_results.unique_id ORDER BY run_results.generated_at DESC) AS model_invocation_reverse_index,\n CASE WHEN FIRST_VALUE(invocation_id) OVER (PARTITION BY \n date_trunc('day', cast(run_results.generated_at as timestamp))\n ORDER BY run_results.generated_at ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) = invocation_id\n THEN TRUE\n ELSE FALSE \n END AS is_the_first_invocation_of_the_day,\n CASE WHEN LAST_VALUE(invocation_id) OVER (PARTITION BY \n date_trunc('day', cast(run_results.generated_at as timestamp))\n ORDER BY run_results.generated_at ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) = invocation_id\n THEN TRUE\n ELSE FALSE \n END AS is_the_last_invocation_of_the_day\n \nFROM dbt_run_results run_results\nJOIN dbt_models models ON run_results.unique_id = models.unique_id", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.test_result_rows": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "test_result_rows", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/run_results/test_result_rows.sql", + "original_file_path": "models/edr/run_results/test_result_rows.sql", + "unique_id": "model.elementary.test_result_rows", + "fqn": [ + "elementary", + "edr", + "run_results", + "test_result_rows" + ], + "alias": "test_result_rows", + "checksum": { + "name": "sha256", + "checksum": "60f29c6ec225f876c714075d2ffd1b81198268ee2eb2e5138b4c3a8b94604de4" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "detected_at" + }, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [ + { + "sql": "{{ elementary.backfill_result_rows() }}", + "transaction": true, + "index": null + } + ], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "elementary_test_results_id", + "on_schema_change": "append_new_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "table_type": null + }, + "tags": [], + "description": "", + "columns": {}, + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "detected_at" + }, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "incremental", + "unique_key": "elementary_test_results_id", + "on_schema_change": "append_new_columns", + "full_refresh": false, + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "detected_at" + }, + "table_type": null, + "incremental_strategy": null, + "post-hook": [ + "{{ elementary.backfill_result_rows() }}" + ], + "schema": "elementary" + }, + "created_at": 1705031518.015477, + "relation_name": "analytics.jaffle_shop_elementary.test_result_rows", + "raw_code": "{{\n config(\n materialized = 'incremental',\n unique_key = 'elementary_test_results_id',\n on_schema_change = 'append_new_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n post_hook='{{ elementary.backfill_result_rows() }}',\n meta={\n \"timestamp_column\": \"created_at\",\n \"prev_timestamp_column\": \"detected_at\",\n },\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy()\n )\n}}\n\n-- depends_on: {{ ref('elementary_test_results') }}\n{{ elementary.empty_table([\n ('elementary_test_results_id', 'long_string'),\n ('result_row', 'long_string'),\n ('detected_at','timestamp'),\n ('created_at','timestamp'),\n]) }}", + "language": "sql", + "refs": [ + { + "name": "elementary_test_results", + "package": null, + "version": null + }, + { + "name": "elementary_test_results", + "package": null, + "version": null + }, + { + "name": "elementary_test_results", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.empty_table", + "macro.elementary.backfill_result_rows" + ], + "nodes": [ + "model.elementary.elementary_test_results" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/run_results/test_result_rows.sql", + "compiled": true, + "compiled_code": "\n\n-- depends_on: analytics.jaffle_shop_elementary.elementary_test_results\nselect * from (\n select\n \n \n cast('this_is_just_a_long_dummy_string' as varchar) as elementary_test_results_id\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as result_row\n\n,\n cast('2091-02-17' as timestamp) as detected_at\n\n,\n cast('2091-02-17' as timestamp) as created_at\n\n\n ) as empty_table\n where 1 = 0", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.elementary_test_results": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "elementary_test_results", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/run_results/elementary_test_results.sql", + "original_file_path": "models/edr/run_results/elementary_test_results.sql", + "unique_id": "model.elementary.elementary_test_results", + "fqn": [ + "elementary", + "edr", + "run_results", + "elementary_test_results" + ], + "alias": "elementary_test_results", + "checksum": { + "name": "sha256", + "checksum": "df74ce864e711c45b8f20af4d3246257f95ef0735e17d83dce220bdd80bde93a" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "detected_at" + }, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "id", + "on_schema_change": "append_new_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "table_type": null + }, + "tags": [], + "description": "Run results of all dbt tests, with fields and metadata needed to produce the Elementary report UI. Each row is the result of a single test, including native dbt tests, packages tests and elementary tests. New data is loaded to this model on an on-run-end hook named `elementary.handle_tests_results`.\n", + "columns": {}, + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "detected_at" + }, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/run_results.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "incremental", + "unique_key": "id", + "on_schema_change": "append_new_columns", + "full_refresh": false, + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "detected_at" + }, + "table_type": null, + "incremental_strategy": null, + "schema": "elementary" + }, + "created_at": 1705031518.716436, + "relation_name": "analytics.jaffle_shop_elementary.elementary_test_results", + "raw_code": "{{\n config(\n materialized = 'incremental',\n unique_key = 'id',\n on_schema_change = 'append_new_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n meta={\n \"timestamp_column\": \"created_at\",\n \"prev_timestamp_column\": \"detected_at\",\n },\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy()\n )\n}}\n\n{{ elementary.empty_elementary_test_results() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.empty_elementary_test_results" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/run_results/elementary_test_results.sql", + "compiled": true, + "compiled_code": "\n\n\n select * from (\n select\n \n \n cast('this_is_just_a_long_dummy_string' as varchar) as id\n\n,\n \n cast('dummy_string' as varchar) as data_issue_id\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as test_execution_id\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as test_unique_id\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as model_unique_id\n\n,\n \n cast('dummy_string' as varchar) as invocation_id\n\n,\n cast('2091-02-17' as timestamp) as detected_at\n\n,\n cast('2091-02-17' as timestamp) as created_at\n\n,\n \n cast('dummy_string' as varchar) as database_name\n\n,\n \n cast('dummy_string' as varchar) as schema_name\n\n,\n \n cast('dummy_string' as varchar) as table_name\n\n,\n \n cast('dummy_string' as varchar) as column_name\n\n,\n \n cast('dummy_string' as varchar) as test_type\n\n,\n \n cast('dummy_string' as varchar) as test_sub_type\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as test_results_description\n\n,\n \n cast('dummy_string' as varchar) as owners\n\n,\n \n cast('dummy_string' as varchar) as tags\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as test_results_query\n\n,\n \n cast('dummy_string' as varchar) as other\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as test_name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as test_params\n\n,\n \n cast('dummy_string' as varchar) as severity\n\n,\n \n cast('dummy_string' as varchar) as status\n\n,\n \n cast(31474836478 as bigint) as failures\n\n,\n \n cast('dummy_string' as varchar) as test_short_name\n\n,\n \n cast('dummy_string' as varchar) as test_alias\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as result_rows\n\n,\n \n cast(31474836478 as bigint) as failed_row_count\n\n\n ) as empty_table\n where 1 = 0\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.dbt_source_freshness_results": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "dbt_source_freshness_results", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/run_results/dbt_source_freshness_results.sql", + "original_file_path": "models/edr/run_results/dbt_source_freshness_results.sql", + "unique_id": "model.elementary.dbt_source_freshness_results", + "fqn": [ + "elementary", + "edr", + "run_results", + "dbt_source_freshness_results" + ], + "alias": "dbt_source_freshness_results", + "checksum": { + "name": "sha256", + "checksum": "fb063c8eb524356395464854c25d33038742ce2e0c3d4b3936ce8919a0ee27d6" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "generated_at" + }, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "source_freshness_execution_id", + "on_schema_change": "append_new_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "table_type": null + }, + "tags": [], + "description": "", + "columns": {}, + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "generated_at" + }, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "incremental", + "unique_key": "source_freshness_execution_id", + "on_schema_change": "append_new_columns", + "full_refresh": false, + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "generated_at" + }, + "table_type": null, + "incremental_strategy": null, + "schema": "elementary" + }, + "created_at": 1705031518.07288, + "relation_name": "analytics.jaffle_shop_elementary.dbt_source_freshness_results", + "raw_code": "{{\n config(\n materialized = 'incremental',\n unique_key = 'source_freshness_execution_id',\n on_schema_change = 'append_new_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n meta={\n \"timestamp_column\": \"created_at\",\n \"prev_timestamp_column\": \"generated_at\",\n },\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy()\n )\n}}\n\n{{ elementary.empty_dbt_source_freshness_results() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.empty_dbt_source_freshness_results" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/run_results/dbt_source_freshness_results.sql", + "compiled": true, + "compiled_code": "\n\n\n select * from (\n select\n \n \n cast('dummy_string' as varchar) as source_freshness_execution_id\n\n,\n \n cast('dummy_string' as varchar) as unique_id\n\n,\n \n cast('dummy_string' as varchar) as max_loaded_at\n\n,\n \n cast('dummy_string' as varchar) as snapshotted_at\n\n,\n \n cast('dummy_string' as varchar) as generated_at\n\n,\n cast('2091-02-17' as timestamp) as created_at\n\n,\n \n cast(123456789.99 as float) as max_loaded_at_time_ago_in_s\n\n,\n \n cast('dummy_string' as varchar) as status\n\n,\n \n cast('dummy_string' as varchar) as error\n\n,\n \n cast('dummy_string' as varchar) as compile_started_at\n\n,\n \n cast('dummy_string' as varchar) as compile_completed_at\n\n,\n \n cast('dummy_string' as varchar) as execute_started_at\n\n,\n \n cast('dummy_string' as varchar) as execute_completed_at\n\n,\n \n cast('dummy_string' as varchar) as invocation_id\n\n,\n \n cast('dummy_string' as varchar) as warn_after\n\n,\n \n cast('dummy_string' as varchar) as error_after\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as filter\n\n\n ) as empty_table\n where 1 = 0\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.alerts_dbt_tests": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "alerts_dbt_tests", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/alerts/alerts_dbt_tests.sql", + "original_file_path": "models/edr/alerts/alerts_dbt_tests.sql", + "unique_id": "model.elementary.alerts_dbt_tests", + "fqn": [ + "elementary", + "edr", + "alerts", + "alerts_dbt_tests" + ], + "alias": "alerts_dbt_tests", + "checksum": { + "name": "sha256", + "checksum": "d15f2b4a7ade165ad09b2b9f6d143d9d47ab0f080b2de5dce1c6fae9e30375ba" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "bind": false + }, + "tags": [], + "description": "A view that is used by the Elementary CLI to generate dbt tests alerts, including all the fields the alert will include such as owner, tags, error message, etc. This view includes data about all dbt tests except elementary tests. It filters alerts according to configuration.\n", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/alerts_views.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "view", + "bind": false, + "schema": "elementary" + }, + "created_at": 1705031518.705544, + "relation_name": "analytics.jaffle_shop_elementary.alerts_dbt_tests", + "raw_code": "{{\n config(\n materialized = 'view',\n bind=False\n )\n}}\n\nwith elementary_test_results as (\n select * from {{ ref('elementary_test_results') }}\n),\n\nalerts_dbt_tests as (\n select id as alert_id,\n data_issue_id,\n test_execution_id,\n test_unique_id,\n model_unique_id,\n detected_at,\n database_name,\n schema_name,\n table_name,\n column_name,\n test_type as alert_type,\n test_sub_type as sub_type,\n test_results_description as alert_description,\n owners,\n tags,\n test_results_query as alert_results_query,\n other,\n test_name,\n test_short_name,\n test_params,\n severity,\n status,\n result_rows\n from elementary_test_results\n where {{ not elementary.get_config_var('disable_test_alerts') }} and lower(status) != 'pass' {% if elementary.get_config_var('disable_warn_alerts') %} and lower(status) != 'warn' {% endif %} {% if elementary.get_config_var('disable_skipped_test_alerts') %} and lower(status) != 'skipped' {% endif %} and test_type = 'dbt_test'\n)\n\nselect * from alerts_dbt_tests", + "language": "sql", + "refs": [ + { + "name": "elementary_test_results", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var" + ], + "nodes": [ + "model.elementary.elementary_test_results" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/alerts/alerts_dbt_tests.sql", + "compiled": true, + "compiled_code": "\n\nwith elementary_test_results as (\n select * from analytics.jaffle_shop_elementary.elementary_test_results\n),\n\nalerts_dbt_tests as (\n select id as alert_id,\n data_issue_id,\n test_execution_id,\n test_unique_id,\n model_unique_id,\n detected_at,\n database_name,\n schema_name,\n table_name,\n column_name,\n test_type as alert_type,\n test_sub_type as sub_type,\n test_results_description as alert_description,\n owners,\n tags,\n test_results_query as alert_results_query,\n other,\n test_name,\n test_short_name,\n test_params,\n severity,\n status,\n result_rows\n from elementary_test_results\n where True and lower(status) != 'pass' and lower(status) != 'skipped' and test_type = 'dbt_test'\n)\n\nselect * from alerts_dbt_tests", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.alerts_schema_changes": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "alerts_schema_changes", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/alerts/alerts_schema_changes.sql", + "original_file_path": "models/edr/alerts/alerts_schema_changes.sql", + "unique_id": "model.elementary.alerts_schema_changes", + "fqn": [ + "elementary", + "edr", + "alerts", + "alerts_schema_changes" + ], + "alias": "alerts_schema_changes", + "checksum": { + "name": "sha256", + "checksum": "bad7007c54d8885efe0496bd6289998cfed84a250ada4899fb8e53765236db0b" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "bind": false + }, + "tags": [], + "description": "A view that is used by the Elementary CLI to generate alerts on schema changes detected using elementary tests. The view filters alerts according to configuration.", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/alerts_views.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "view", + "bind": false, + "schema": "elementary" + }, + "created_at": 1705031518.705947, + "relation_name": "analytics.jaffle_shop_elementary.alerts_schema_changes", + "raw_code": "{{\n config(\n materialized = 'view',\n bind=False,\n )\n}}\n\n\nwith elementary_test_results as (\n select * from {{ ref('elementary_test_results') }}\n),\n\nalerts_schema_changes as (\n select id as alert_id,\n data_issue_id,\n test_execution_id,\n test_unique_id,\n model_unique_id,\n detected_at,\n database_name,\n schema_name,\n table_name,\n column_name,\n test_type as alert_type,\n test_sub_type as sub_type,\n test_results_description as alert_description,\n owners,\n tags,\n test_results_query as alert_results_query,\n other,\n test_name,\n test_short_name,\n test_params,\n severity,\n status,\n result_rows\n from elementary_test_results\n where {{ not elementary.get_config_var('disable_test_alerts') }} and lower(status) != 'pass' {%- if elementary.get_config_var('disable_warn_alerts') -%} and lower(status) != 'warn' {%- endif -%} {%- if elementary.get_config_var('disable_skipped_test_alerts') -%} and lower(status) != 'skipped' {%- endif -%} and test_type = 'schema_change'\n)\n\nselect * from alerts_schema_changes", + "language": "sql", + "refs": [ + { + "name": "elementary_test_results", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var" + ], + "nodes": [ + "model.elementary.elementary_test_results" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/alerts/alerts_schema_changes.sql", + "compiled": true, + "compiled_code": "\n\n\nwith elementary_test_results as (\n select * from analytics.jaffle_shop_elementary.elementary_test_results\n),\n\nalerts_schema_changes as (\n select id as alert_id,\n data_issue_id,\n test_execution_id,\n test_unique_id,\n model_unique_id,\n detected_at,\n database_name,\n schema_name,\n table_name,\n column_name,\n test_type as alert_type,\n test_sub_type as sub_type,\n test_results_description as alert_description,\n owners,\n tags,\n test_results_query as alert_results_query,\n other,\n test_name,\n test_short_name,\n test_params,\n severity,\n status,\n result_rows\n from elementary_test_results\n where True and lower(status) != 'pass'and lower(status) != 'skipped'and test_type = 'schema_change'\n)\n\nselect * from alerts_schema_changes", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.alerts_dbt_source_freshness": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "alerts_dbt_source_freshness", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/alerts/alerts_dbt_source_freshness.sql", + "original_file_path": "models/edr/alerts/alerts_dbt_source_freshness.sql", + "unique_id": "model.elementary.alerts_dbt_source_freshness", + "fqn": [ + "elementary", + "edr", + "alerts", + "alerts_dbt_source_freshness" + ], + "alias": "alerts_dbt_source_freshness", + "checksum": { + "name": "sha256", + "checksum": "59b6900cf93ce1ac9e61f07c3358a21aecda80b7980e55e4387c80ea3463f012" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "bind": false + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "view", + "bind": false, + "schema": "elementary" + }, + "created_at": 1705031518.1029341, + "relation_name": "analytics.jaffle_shop_elementary.alerts_dbt_source_freshness", + "raw_code": "{{\n config(\n materialized = 'view',\n bind=False\n )\n}}\n\nwith results as (\n select * from {{ ref('dbt_source_freshness_results') }}\n),\n\nsources as (\n select * from {{ ref('dbt_sources') }}\n)\n\nselect\n results.source_freshness_execution_id as alert_id,\n results.max_loaded_at,\n results.snapshotted_at,\n {{ elementary.edr_cast_as_timestamp(\"results.generated_at\") }} as detected_at,\n results.max_loaded_at_time_ago_in_s,\n results.status,\n results.error,\n results.warn_after,\n results.error_after,\n results.filter,\n sources.unique_id,\n sources.database_name,\n sources.schema_name,\n sources.source_name,\n sources.identifier,\n sources.tags,\n sources.meta,\n sources.owner,\n sources.package_name,\n sources.path,\n -- These columns below are deprecated. We add them since this view\n -- was used to be loaded into an incremental model with those columns, their names were later changed\n -- and Databricks doesn't respect `on_schema_change = 'append_new_columns'` properly, as described here -\n -- https://docs.databricks.com/en/delta/update-schema.html#automatic-schema-evolution-for-delta-lake-merge\n results.error_after as freshness_error_after,\n results.warn_after as freshness_warn_after,\n results.filter as freshness_filter\nfrom results\njoin sources on results.unique_id = sources.unique_id\nwhere {{ not elementary.get_config_var('disable_source_freshness_alerts') }} and lower(status) != 'pass'", + "language": "sql", + "refs": [ + { + "name": "dbt_source_freshness_results", + "package": null, + "version": null + }, + { + "name": "dbt_sources", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.get_config_var" + ], + "nodes": [ + "model.elementary.dbt_source_freshness_results", + "model.elementary.dbt_sources" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/alerts/alerts_dbt_source_freshness.sql", + "compiled": true, + "compiled_code": "\n\nwith results as (\n select * from analytics.jaffle_shop_elementary.dbt_source_freshness_results\n),\n\nsources as (\n select * from analytics.jaffle_shop_elementary.dbt_sources\n)\n\nselect\n results.source_freshness_execution_id as alert_id,\n results.max_loaded_at,\n results.snapshotted_at,\n cast(results.generated_at as timestamp) as detected_at,\n results.max_loaded_at_time_ago_in_s,\n results.status,\n results.error,\n results.warn_after,\n results.error_after,\n results.filter,\n sources.unique_id,\n sources.database_name,\n sources.schema_name,\n sources.source_name,\n sources.identifier,\n sources.tags,\n sources.meta,\n sources.owner,\n sources.package_name,\n sources.path,\n -- These columns below are deprecated. We add them since this view\n -- was used to be loaded into an incremental model with those columns, their names were later changed\n -- and Databricks doesn't respect `on_schema_change = 'append_new_columns'` properly, as described here -\n -- https://docs.databricks.com/en/delta/update-schema.html#automatic-schema-evolution-for-delta-lake-merge\n results.error_after as freshness_error_after,\n results.warn_after as freshness_warn_after,\n results.filter as freshness_filter\nfrom results\njoin sources on results.unique_id = sources.unique_id\nwhere True and lower(status) != 'pass'", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.alerts_anomaly_detection": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "alerts_anomaly_detection", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/alerts/alerts_anomaly_detection.sql", + "original_file_path": "models/edr/alerts/alerts_anomaly_detection.sql", + "unique_id": "model.elementary.alerts_anomaly_detection", + "fqn": [ + "elementary", + "edr", + "alerts", + "alerts_anomaly_detection" + ], + "alias": "alerts_anomaly_detection", + "checksum": { + "name": "sha256", + "checksum": "0d2bb9c33ded81e6501643abeeacde1b21695f406b861f748923e4bd9ce0c4c8" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "bind": false + }, + "tags": [], + "description": "A view that is used by the Elementary CLI to generate alerts on data anomalies detected using the elementary anomaly detection tests. The view filters alerts according to configuration.\n", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/alerts_views.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "view", + "bind": false, + "schema": "elementary" + }, + "created_at": 1705031518.705749, + "relation_name": "analytics.jaffle_shop_elementary.alerts_anomaly_detection", + "raw_code": "{{\n config(\n materialized = 'view',\n bind =False\n )\n}}\n\nwith elementary_test_results as (\n select * from {{ ref('elementary_test_results') }}\n),\n\nalerts_anomaly_detection as (\n select id as alert_id,\n data_issue_id,\n test_execution_id,\n test_unique_id,\n model_unique_id,\n detected_at,\n database_name,\n schema_name,\n table_name,\n column_name,\n test_type as alert_type,\n test_sub_type as sub_type,\n test_results_description as alert_description,\n owners,\n tags,\n test_results_query as alert_results_query,\n other,\n test_name,\n test_short_name,\n test_params,\n severity,\n status,\n result_rows\n from elementary_test_results\n where {{ not elementary.get_config_var('disable_test_alerts') }} and lower(status) != 'pass' {%- if elementary.get_config_var('disable_warn_alerts') -%} and lower(status) != 'warn' {%- endif -%} {%- if elementary.get_config_var('disable_skipped_test_alerts') -%} and lower(status) != 'skipped' {%- endif -%} and test_type = 'anomaly_detection'\n)\n\nselect * from alerts_anomaly_detection", + "language": "sql", + "refs": [ + { + "name": "elementary_test_results", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var" + ], + "nodes": [ + "model.elementary.elementary_test_results" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/alerts/alerts_anomaly_detection.sql", + "compiled": true, + "compiled_code": "\n\nwith elementary_test_results as (\n select * from analytics.jaffle_shop_elementary.elementary_test_results\n),\n\nalerts_anomaly_detection as (\n select id as alert_id,\n data_issue_id,\n test_execution_id,\n test_unique_id,\n model_unique_id,\n detected_at,\n database_name,\n schema_name,\n table_name,\n column_name,\n test_type as alert_type,\n test_sub_type as sub_type,\n test_results_description as alert_description,\n owners,\n tags,\n test_results_query as alert_results_query,\n other,\n test_name,\n test_short_name,\n test_params,\n severity,\n status,\n result_rows\n from elementary_test_results\n where True and lower(status) != 'pass'and lower(status) != 'skipped'and test_type = 'anomaly_detection'\n)\n\nselect * from alerts_anomaly_detection", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.alerts_dbt_models": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "alerts_dbt_models", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/alerts/alerts_dbt_models.sql", + "original_file_path": "models/edr/alerts/alerts_dbt_models.sql", + "unique_id": "model.elementary.alerts_dbt_models", + "fqn": [ + "elementary", + "edr", + "alerts", + "alerts_dbt_models" + ], + "alias": "alerts_dbt_models", + "checksum": { + "name": "sha256", + "checksum": "6b76b9a7b5f40ef4f9ff316fe90b4d48451442cafac243dc5abf0ac10b4c67eb" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "bind": false + }, + "tags": [], + "description": "A view that is used by the Elementary CLI to generate models alerts, including all the fields the alert will include such as owner, tags, error message, etc. It joins data about models and snapshots run results, and filters alerts according to configuration.\n", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/alerts_views.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "view", + "bind": false, + "schema": "elementary" + }, + "created_at": 1705031518.705344, + "relation_name": "analytics.jaffle_shop_elementary.alerts_dbt_models", + "raw_code": "{{\n config(\n materialized = 'view',\n bind=False\n )\n}}\n\nwith error_models as (\n \n select model_execution_id,\n unique_id,\n invocation_id,\n name,\n generated_at,\n status,\n full_refresh,\n message,\n execution_time,\n execute_started_at,\n execute_completed_at,\n compile_started_at,\n compile_completed_at,\n compiled_code,\n database_name,\n schema_name,\n materialization,\n tags,\n package_name,\n path,\n original_path,\n owner,\n alias \n from {{ ref('model_run_results') }}\n \n union all\n \n select model_execution_id,\n unique_id,\n invocation_id,\n name,\n generated_at,\n status,\n full_refresh,\n message,\n execution_time,\n execute_started_at,\n execute_completed_at,\n compile_started_at,\n compile_completed_at,\n compiled_code,\n database_name,\n schema_name,\n materialization,\n tags,\n package_name,\n path,\n original_path,\n owner,\n alias \n from {{ ref('snapshot_run_results') }}\n)\n\n\nselect model_execution_id as alert_id,\n unique_id,\n {{ elementary.edr_cast_as_timestamp(\"generated_at\") }} as detected_at,\n database_name,\n materialization,\n path,\n original_path,\n schema_name,\n message,\n owner as owners,\n tags,\n alias,\n status,\n full_refresh\nfrom error_models\nwhere {{ not elementary.get_config_var('disable_model_alerts') }} and lower(status) != 'success' {%- if elementary.get_config_var('disable_skipped_model_alerts') -%} and lower(status) != 'skipped' {%- endif -%}", + "language": "sql", + "refs": [ + { + "name": "model_run_results", + "package": null, + "version": null + }, + { + "name": "snapshot_run_results", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.get_config_var" + ], + "nodes": [ + "model.elementary.model_run_results", + "model.elementary.snapshot_run_results" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/alerts/alerts_dbt_models.sql", + "compiled": true, + "compiled_code": "\n\nwith error_models as (\n \n select model_execution_id,\n unique_id,\n invocation_id,\n name,\n generated_at,\n status,\n full_refresh,\n message,\n execution_time,\n execute_started_at,\n execute_completed_at,\n compile_started_at,\n compile_completed_at,\n compiled_code,\n database_name,\n schema_name,\n materialization,\n tags,\n package_name,\n path,\n original_path,\n owner,\n alias \n from analytics.jaffle_shop_elementary.model_run_results\n \n union all\n \n select model_execution_id,\n unique_id,\n invocation_id,\n name,\n generated_at,\n status,\n full_refresh,\n message,\n execution_time,\n execute_started_at,\n execute_completed_at,\n compile_started_at,\n compile_completed_at,\n compiled_code,\n database_name,\n schema_name,\n materialization,\n tags,\n package_name,\n path,\n original_path,\n owner,\n alias \n from analytics.jaffle_shop_elementary.snapshot_run_results\n)\n\n\nselect model_execution_id as alert_id,\n unique_id,\n cast(generated_at as timestamp) as detected_at,\n database_name,\n materialization,\n path,\n original_path,\n schema_name,\n message,\n owner as owners,\n tags,\n alias,\n status,\n full_refresh\nfrom error_models\nwhere True and lower(status) != 'success'and lower(status) != 'skipped'", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.monitors_runs": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "monitors_runs", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/system/monitors_runs.sql", + "original_file_path": "models/edr/system/monitors_runs.sql", + "unique_id": "model.elementary.monitors_runs", + "fqn": [ + "elementary", + "edr", + "system", + "monitors_runs" + ], + "alias": "monitors_runs", + "checksum": { + "name": "sha256", + "checksum": "3720e206635d4f2f95c193835727b0d533ec1a5fa56e5dec79331418d07e934f" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "bind": false + }, + "tags": [], + "description": "This is a view on `data_monitoring_metrics` that is used to determine when a specific anomaly detection test was last executed. Each anomaly detection test queries this view to decide on a start time for collecting metrics.\n", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/elementary_tests.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "view", + "bind": false, + "schema": "elementary" + }, + "created_at": 1705031518.70486, + "relation_name": "analytics.jaffle_shop_elementary.monitors_runs", + "raw_code": "{{\n config(\n materialized = 'view',\n bind=False\n )\n}}\n\nwith data_monitoring_metrics as (\n\n select * from {{ ref('data_monitoring_metrics') }}\n\n),\n\nmax_bucket_end as (\n\n select full_table_name,\n column_name,\n metric_name,\n metric_properties,\n max(bucket_end) as last_bucket_end,\n min(bucket_end) as first_bucket_end\n from data_monitoring_metrics\n group by 1,2,3,4\n\n)\n\nselect * from max_bucket_end", + "language": "sql", + "refs": [ + { + "name": "data_monitoring_metrics", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "model.elementary.data_monitoring_metrics" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/system/monitors_runs.sql", + "compiled": true, + "compiled_code": "\n\nwith data_monitoring_metrics as (\n\n select * from analytics.jaffle_shop_elementary.data_monitoring_metrics\n\n),\n\nmax_bucket_end as (\n\n select full_table_name,\n column_name,\n metric_name,\n metric_properties,\n max(bucket_end) as last_bucket_end,\n min(bucket_end) as first_bucket_end\n from data_monitoring_metrics\n group by 1,2,3,4\n\n)\n\nselect * from max_bucket_end", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.metadata": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "metadata", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/system/metadata.sql", + "original_file_path": "models/edr/system/metadata.sql", + "unique_id": "model.elementary.metadata", + "fqn": [ + "elementary", + "edr", + "system", + "metadata" + ], + "alias": "metadata", + "checksum": { + "name": "sha256", + "checksum": "7d06c726499b330d51c340d2dc2774ac95f958fd6824c09711b3881b39b76a84" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "table", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "table", + "schema": "elementary" + }, + "created_at": 1705031518.158357, + "relation_name": "analytics.jaffle_shop_elementary.metadata", + "raw_code": "{{ config(materialized='table') }}\n\nSELECT\n '{{ elementary.get_elementary_package_version() }}' as dbt_pkg_version", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_elementary_package_version" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/system/metadata.sql", + "compiled": true, + "compiled_code": "\n\nSELECT\n '0.13.1' as dbt_pkg_version", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.dbt_tests": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "dbt_tests", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/dbt_artifacts/dbt_tests.sql", + "original_file_path": "models/edr/dbt_artifacts/dbt_tests.sql", + "unique_id": "model.elementary.dbt_tests", + "fqn": [ + "elementary", + "edr", + "dbt_artifacts", + "dbt_tests" + ], + "alias": "dbt_tests", + "checksum": { + "name": "sha256", + "checksum": "e3e387b5d7f7df8bdfdc358f4458dd69b8311803d989c7a0a571314bb1f1dfc2" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [ + { + "sql": "{{ elementary.upload_dbt_tests() }}", + "transaction": true, + "index": null + } + ], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "transient": false, + "table_type": null + }, + "tags": [], + "description": "Metadata about tests in the project, including configuration and properties from the dbt graph. Each row contains information about a single test. Data is loaded every time this model is executed. It is recommended to execute the model every time a change is merged to the project.\n", + "columns": { + "unique_id": { + "name": "unique_id", + "description": "The unique id of the test.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "database_name": { + "name": "database_name", + "description": "The tested model database name.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "schema_name": { + "name": "schema_name", + "description": "The tested model schema name.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "name": { + "name": "name", + "description": "The test name.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "short_name": { + "name": "short_name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "alias": { + "name": "alias", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "test_column_name": { + "name": "test_column_name", + "description": "The name of the tested column.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "severity": { + "name": "severity", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "warn_if": { + "name": "warn_if", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "error_if": { + "name": "error_if", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "test_params": { + "name": "test_params", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "test_namespace": { + "name": "test_namespace", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "tags": { + "name": "tags", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "model_tags": { + "name": "model_tags", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "model_owners": { + "name": "model_owners", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "meta": { + "name": "meta", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "depends_on_macros": { + "name": "depends_on_macros", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "depends_on_nodes": { + "name": "depends_on_nodes", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "parent_model_unique_id": { + "name": "parent_model_unique_id", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "description": { + "name": "description", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "package_name": { + "name": "package_name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "type": { + "name": "type", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "original_path": { + "name": "original_path", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "path": { + "name": "path", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "generated_at": { + "name": "generated_at", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + } + }, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/dbt_artifacts.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "incremental", + "transient": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "full_refresh": false, + "table_type": null, + "incremental_strategy": null, + "post-hook": [ + "{{ elementary.upload_dbt_tests() }}" + ], + "schema": "elementary" + }, + "created_at": 1705031518.722328, + "relation_name": "analytics.jaffle_shop_elementary.dbt_tests", + "raw_code": "{{\n config(\n materialized='incremental',\n transient=False,\n post_hook='{{ elementary.upload_dbt_tests() }}',\n unique_key='unique_id',\n on_schema_change='sync_all_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy()\n )\n}}\n\n{{ elementary.get_dbt_tests_empty_table_query() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.get_dbt_tests_empty_table_query", + "macro.elementary.upload_dbt_tests" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/dbt_artifacts/dbt_tests.sql", + "compiled": true, + "compiled_code": "\n\nselect * from (\n select\n \n \n cast('dummy_string' as varchar) as unique_id\n\n,\n \n cast('dummy_string' as varchar) as database_name\n\n,\n \n cast('dummy_string' as varchar) as schema_name\n\n,\n \n cast('dummy_string' as varchar) as name\n\n,\n \n cast('dummy_string' as varchar) as short_name\n\n,\n \n cast('dummy_string' as varchar) as alias\n\n,\n \n cast('dummy_string' as varchar) as test_column_name\n\n,\n \n cast('dummy_string' as varchar) as severity\n\n,\n \n cast('dummy_string' as varchar) as warn_if\n\n,\n \n cast('dummy_string' as varchar) as error_if\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as test_params\n\n,\n \n cast('dummy_string' as varchar) as test_namespace\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as tags\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as model_tags\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as model_owners\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as meta\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as depends_on_macros\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as depends_on_nodes\n\n,\n \n cast('dummy_string' as varchar) as parent_model_unique_id\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as description\n\n,\n \n cast('dummy_string' as varchar) as package_name\n\n,\n \n cast('dummy_string' as varchar) as type\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as original_path\n\n,\n \n cast('dummy_string' as varchar) as path\n\n,\n \n cast('dummy_string' as varchar) as generated_at\n\n,\n \n cast('dummy_string' as varchar) as metadata_hash\n\n,\n \n cast('dummy_string' as varchar) as quality_dimension\n\n\n ) as empty_table\n where 1 = 0", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.dbt_models": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "dbt_models", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/dbt_artifacts/dbt_models.sql", + "original_file_path": "models/edr/dbt_artifacts/dbt_models.sql", + "unique_id": "model.elementary.dbt_models", + "fqn": [ + "elementary", + "edr", + "dbt_artifacts", + "dbt_models" + ], + "alias": "dbt_models", + "checksum": { + "name": "sha256", + "checksum": "3b137ff6fc5007c98c2cce8c57010d5a8386ed4f9d217b08506e9106ab9168fd" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [ + { + "sql": "{{ elementary.upload_dbt_models() }}", + "transaction": true, + "index": null + } + ], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "transient": false, + "table_type": null + }, + "tags": [], + "description": "Metadata about models in the project, including configuration and properties from the dbt graph. Each row contains information about a single model. Data is loaded every time this model is executed. It is recommended to execute the model every time a change is merged to the project.\n", + "columns": { + "unique_id": { + "name": "unique_id", + "description": "The unique id of the model.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "alias": { + "name": "alias", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "checksum": { + "name": "checksum", + "description": "Model file checksum.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "materialization": { + "name": "materialization", + "description": "The model materialization config.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "tags": { + "name": "tags", + "description": "Model tags property.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "meta": { + "name": "meta", + "description": "The content of 'meta' property key.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "owner": { + "name": "owner", + "description": "Model owner property (configured under 'meta' key).", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "database_name": { + "name": "database_name", + "description": "The model database name.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "schema_name": { + "name": "schema_name", + "description": "The model schema name.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "depends_on_macros": { + "name": "depends_on_macros", + "description": "The macros the model directly depends on.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "depends_on_nodes": { + "name": "depends_on_nodes", + "description": "The nodes the model directly depends on.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "description": { + "name": "description", + "description": "Model description.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "name": { + "name": "name", + "description": "Model name.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "package_name": { + "name": "package_name", + "description": "Package name of the model.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "original_path": { + "name": "original_path", + "description": "Full path of the model file.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "path": { + "name": "path", + "description": "Short path of the model file.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "generated_at": { + "name": "generated_at", + "description": "Update time of the table.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + } + }, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/dbt_artifacts.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "incremental", + "transient": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "full_refresh": false, + "table_type": null, + "incremental_strategy": null, + "post-hook": [ + "{{ elementary.upload_dbt_models() }}" + ], + "schema": "elementary" + }, + "created_at": 1705031518.7199738, + "relation_name": "analytics.jaffle_shop_elementary.dbt_models", + "raw_code": "{{\n config(\n materialized='incremental',\n transient=False,\n post_hook='{{ elementary.upload_dbt_models() }}',\n unique_key='unique_id',\n on_schema_change='sync_all_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy()\n )\n}}\n\n{{ elementary.get_dbt_models_empty_table_query() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.get_dbt_models_empty_table_query", + "macro.elementary.upload_dbt_models" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/dbt_artifacts/dbt_models.sql", + "compiled": true, + "compiled_code": "\n\nselect * from (\n select\n \n \n cast('dummy_string' as varchar) as unique_id\n\n,\n \n cast('dummy_string' as varchar) as alias\n\n,\n \n cast('dummy_string' as varchar) as checksum\n\n,\n \n cast('dummy_string' as varchar) as materialization\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as tags\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as meta\n\n,\n \n cast('dummy_string' as varchar) as owner\n\n,\n \n cast('dummy_string' as varchar) as database_name\n\n,\n \n cast('dummy_string' as varchar) as schema_name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as depends_on_macros\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as depends_on_nodes\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as description\n\n,\n \n cast('dummy_string' as varchar) as name\n\n,\n \n cast('dummy_string' as varchar) as package_name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as original_path\n\n,\n \n cast('dummy_string' as varchar) as path\n\n,\n \n cast('dummy_string' as varchar) as patch_path\n\n,\n \n cast('dummy_string' as varchar) as generated_at\n\n,\n \n cast('dummy_string' as varchar) as metadata_hash\n\n\n ) as empty_table\n where 1 = 0", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.dbt_sources": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "dbt_sources", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/dbt_artifacts/dbt_sources.sql", + "original_file_path": "models/edr/dbt_artifacts/dbt_sources.sql", + "unique_id": "model.elementary.dbt_sources", + "fqn": [ + "elementary", + "edr", + "dbt_artifacts", + "dbt_sources" + ], + "alias": "dbt_sources", + "checksum": { + "name": "sha256", + "checksum": "1abd5241398ed596cf8fcf85b84a45835ae0a3e67069f00d7b519757b009cbb3" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [ + { + "sql": "{{ elementary.upload_dbt_sources() }}", + "transaction": true, + "index": null + } + ], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "transient": false, + "table_type": null + }, + "tags": [], + "description": "Metadata about sources in the project, including configuration and properties from the dbt graph. Each row contains information about a single source. Data is loaded every time this model is executed. It is recommended to execute the model every time a change is merged to the project.\n", + "columns": { + "unique_id": { + "name": "unique_id", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "database_name": { + "name": "database_name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "schema_name": { + "name": "schema_name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "source_name": { + "name": "source_name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "name": { + "name": "name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "identifier": { + "name": "identifier", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "loaded_at_field": { + "name": "loaded_at_field", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "freshness_warn_after": { + "name": "freshness_warn_after", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "freshness_error_after": { + "name": "freshness_error_after", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "freshness_filter": { + "name": "freshness_filter", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "relation_name": { + "name": "relation_name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "tags": { + "name": "tags", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "meta": { + "name": "meta", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "owner": { + "name": "owner", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "package_name": { + "name": "package_name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "original_path": { + "name": "original_path", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "path": { + "name": "path", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "source_description": { + "name": "source_description", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "description": { + "name": "description", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "generated_at": { + "name": "generated_at", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + } + }, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/dbt_artifacts.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "incremental", + "transient": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "full_refresh": false, + "table_type": null, + "incremental_strategy": null, + "post-hook": [ + "{{ elementary.upload_dbt_sources() }}" + ], + "schema": "elementary" + }, + "created_at": 1705031518.724181, + "relation_name": "analytics.jaffle_shop_elementary.dbt_sources", + "raw_code": "{{\n config(\n materialized='incremental',\n transient=False,\n post_hook='{{ elementary.upload_dbt_sources() }}',\n unique_key='unique_id',\n on_schema_change='sync_all_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy()\n )\n}}\n\n{{ elementary.get_dbt_sources_empty_table_query() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.get_dbt_sources_empty_table_query", + "macro.elementary.upload_dbt_sources" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/dbt_artifacts/dbt_sources.sql", + "compiled": true, + "compiled_code": "\n\nselect * from (\n select\n \n \n cast('dummy_string' as varchar) as unique_id\n\n,\n \n cast('dummy_string' as varchar) as database_name\n\n,\n \n cast('dummy_string' as varchar) as schema_name\n\n,\n \n cast('dummy_string' as varchar) as source_name\n\n,\n \n cast('dummy_string' as varchar) as name\n\n,\n \n cast('dummy_string' as varchar) as identifier\n\n,\n \n cast('dummy_string' as varchar) as loaded_at_field\n\n,\n \n cast('dummy_string' as varchar) as freshness_warn_after\n\n,\n \n cast('dummy_string' as varchar) as freshness_error_after\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as freshness_filter\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as freshness_description\n\n,\n \n cast('dummy_string' as varchar) as relation_name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as tags\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as meta\n\n,\n \n cast('dummy_string' as varchar) as owner\n\n,\n \n cast('dummy_string' as varchar) as package_name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as original_path\n\n,\n \n cast('dummy_string' as varchar) as path\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as source_description\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as description\n\n,\n \n cast('dummy_string' as varchar) as generated_at\n\n,\n \n cast('dummy_string' as varchar) as metadata_hash\n\n\n ) as empty_table\n where 1 = 0", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.dbt_snapshots": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "dbt_snapshots", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/dbt_artifacts/dbt_snapshots.sql", + "original_file_path": "models/edr/dbt_artifacts/dbt_snapshots.sql", + "unique_id": "model.elementary.dbt_snapshots", + "fqn": [ + "elementary", + "edr", + "dbt_artifacts", + "dbt_snapshots" + ], + "alias": "dbt_snapshots", + "checksum": { + "name": "sha256", + "checksum": "84129810bfd9a5181f3d1552ba85143966cd16d64b9fc9169c1b089eab0c6ac2" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [ + { + "sql": "{{ elementary.upload_dbt_snapshots() }}", + "transaction": true, + "index": null + } + ], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "transient": false, + "table_type": null + }, + "tags": [], + "description": "Metadata about snapshots in the project, including configuration and properties from the dbt graph. Each row contains information about a single snapshot. Data is loaded every time this model is executed. It is recommended to execute the model every time a change is merged to the project.\n", + "columns": { + "unique_id": { + "name": "unique_id", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "alias": { + "name": "alias", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "checksum": { + "name": "checksum", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "materialization": { + "name": "materialization", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "tags": { + "name": "tags", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "meta": { + "name": "meta", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "owner": { + "name": "owner", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "database_name": { + "name": "database_name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "schema_name": { + "name": "schema_name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "depends_on_macros": { + "name": "depends_on_macros", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "depends_on_nodes": { + "name": "depends_on_nodes", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "description": { + "name": "description", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "name": { + "name": "name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "package_name": { + "name": "package_name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "original_path": { + "name": "original_path", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "path": { + "name": "path", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "generated_at": { + "name": "generated_at", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + } + }, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/dbt_artifacts.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "incremental", + "transient": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "full_refresh": false, + "table_type": null, + "incremental_strategy": null, + "post-hook": [ + "{{ elementary.upload_dbt_snapshots() }}" + ], + "schema": "elementary" + }, + "created_at": 1705031518.724907, + "relation_name": "analytics.jaffle_shop_elementary.dbt_snapshots", + "raw_code": "{{\n config(\n materialized='incremental',\n transient=False,\n post_hook='{{ elementary.upload_dbt_snapshots() }}',\n unique_key='unique_id',\n on_schema_change='sync_all_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy()\n )\n}}\n\n{{ elementary.get_dbt_models_empty_table_query() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.get_dbt_models_empty_table_query", + "macro.elementary.upload_dbt_snapshots" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/dbt_artifacts/dbt_snapshots.sql", + "compiled": true, + "compiled_code": "\n\nselect * from (\n select\n \n \n cast('dummy_string' as varchar) as unique_id\n\n,\n \n cast('dummy_string' as varchar) as alias\n\n,\n \n cast('dummy_string' as varchar) as checksum\n\n,\n \n cast('dummy_string' as varchar) as materialization\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as tags\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as meta\n\n,\n \n cast('dummy_string' as varchar) as owner\n\n,\n \n cast('dummy_string' as varchar) as database_name\n\n,\n \n cast('dummy_string' as varchar) as schema_name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as depends_on_macros\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as depends_on_nodes\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as description\n\n,\n \n cast('dummy_string' as varchar) as name\n\n,\n \n cast('dummy_string' as varchar) as package_name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as original_path\n\n,\n \n cast('dummy_string' as varchar) as path\n\n,\n \n cast('dummy_string' as varchar) as patch_path\n\n,\n \n cast('dummy_string' as varchar) as generated_at\n\n,\n \n cast('dummy_string' as varchar) as metadata_hash\n\n\n ) as empty_table\n where 1 = 0", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.dbt_columns": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "dbt_columns", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/dbt_artifacts/dbt_columns.sql", + "original_file_path": "models/edr/dbt_artifacts/dbt_columns.sql", + "unique_id": "model.elementary.dbt_columns", + "fqn": [ + "elementary", + "edr", + "dbt_artifacts", + "dbt_columns" + ], + "alias": "dbt_columns", + "checksum": { + "name": "sha256", + "checksum": "b8a1cdacc7886a9dc3c8595a28fe850e1c39090ca6da04e3431b6549b986dc99" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [ + { + "sql": "{{ elementary.upload_dbt_columns() }}", + "transaction": true, + "index": null + } + ], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "transient": false, + "table_type": null + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "incremental", + "transient": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "full_refresh": false, + "table_type": null, + "incremental_strategy": null, + "post-hook": [ + "{{ elementary.upload_dbt_columns() }}" + ], + "schema": "elementary" + }, + "created_at": 1705031518.249325, + "relation_name": "analytics.jaffle_shop_elementary.dbt_columns", + "raw_code": "{{\n config(\n materialized='incremental',\n transient=False,\n post_hook='{{ elementary.upload_dbt_columns() }}',\n unique_key='unique_id',\n on_schema_change='sync_all_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy()\n )\n}}\n\n{{ elementary.get_dbt_columns_empty_table_query() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.get_dbt_columns_empty_table_query", + "macro.elementary.upload_dbt_columns" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/dbt_artifacts/dbt_columns.sql", + "compiled": true, + "compiled_code": "\n\nselect * from (\n select\n \n \n cast('dummy_string' as varchar) as unique_id\n\n,\n \n cast('dummy_string' as varchar) as parent_unique_id\n\n,\n \n cast('dummy_string' as varchar) as name\n\n,\n \n cast('dummy_string' as varchar) as data_type\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as tags\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as meta\n\n,\n \n cast('dummy_string' as varchar) as database_name\n\n,\n \n cast('dummy_string' as varchar) as schema_name\n\n,\n \n cast('dummy_string' as varchar) as table_name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as description\n\n,\n \n cast('dummy_string' as varchar) as resource_type\n\n,\n \n cast('dummy_string' as varchar) as generated_at\n\n,\n \n cast('dummy_string' as varchar) as metadata_hash\n\n\n ) as empty_table\n where 1 = 0", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.enriched_columns": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "enriched_columns", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/dbt_artifacts/enriched_columns.sql", + "original_file_path": "models/edr/dbt_artifacts/enriched_columns.sql", + "unique_id": "model.elementary.enriched_columns", + "fqn": [ + "elementary", + "edr", + "dbt_artifacts", + "enriched_columns" + ], + "alias": "enriched_columns", + "checksum": { + "name": "sha256", + "checksum": "de13843dd09be742938fe58c752b0b44350377ea6202d8ecec71096ceb0b9a8b" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "bind": false + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "view", + "bind": false, + "schema": "elementary" + }, + "created_at": 1705031518.2648342, + "relation_name": "analytics.jaffle_shop_elementary.enriched_columns", + "raw_code": "{{\n config(\n materialized = 'view',\n bind=False\n )\n}}\n\n\nwith information_schema_columns as (\n select\n lower(database_name) as database_name,\n lower(schema_name) as schema_name,\n lower(table_name) as table_name,\n lower(column_name) as name,\n data_type\n from {{ ref(\"information_schema_columns\") }}\n),\n\ndbt_columns as (\n select\n lower(database_name) as database_name,\n lower(schema_name) as schema_name,\n lower(table_name) as table_name,\n lower(name) as name,\n description\n from {{ ref(\"dbt_columns\") }}\n)\n\nselect\n database_name,\n schema_name,\n table_name,\n name,\n data_type,\n description\nfrom information_schema_columns\nleft join dbt_columns using (database_name, schema_name, table_name, name)", + "language": "sql", + "refs": [ + { + "name": "information_schema_columns", + "package": null, + "version": null + }, + { + "name": "dbt_columns", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "model.elementary.information_schema_columns", + "model.elementary.dbt_columns" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/dbt_artifacts/enriched_columns.sql", + "compiled": true, + "compiled_code": "\n\n\nwith information_schema_columns as (\n select\n lower(database_name) as database_name,\n lower(schema_name) as schema_name,\n lower(table_name) as table_name,\n lower(column_name) as name,\n data_type\n from analytics.jaffle_shop_elementary.information_schema_columns\n),\n\ndbt_columns as (\n select\n lower(database_name) as database_name,\n lower(schema_name) as schema_name,\n lower(table_name) as table_name,\n lower(name) as name,\n description\n from analytics.jaffle_shop_elementary.dbt_columns\n)\n\nselect\n database_name,\n schema_name,\n table_name,\n name,\n data_type,\n description\nfrom information_schema_columns\nleft join dbt_columns using (database_name, schema_name, table_name, name)", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.dbt_invocations": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "dbt_invocations", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/dbt_artifacts/dbt_invocations.sql", + "original_file_path": "models/edr/dbt_artifacts/dbt_invocations.sql", + "unique_id": "model.elementary.dbt_invocations", + "fqn": [ + "elementary", + "edr", + "dbt_artifacts", + "dbt_invocations" + ], + "alias": "dbt_invocations", + "checksum": { + "name": "sha256", + "checksum": "6ec0cb09a0a3991db91ebd8a52625cc508faa4aac958138022aeaa3abb960755" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "generated_at" + }, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "invocation_id", + "on_schema_change": "append_new_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "transient": false, + "table_type": null + }, + "tags": [], + "description": "Attributes associated with each dbt invocation. Inserted at the end of each invocation.\n", + "columns": { + "invocation_id": { + "name": "invocation_id", + "description": "Primary key of this table.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "run_started_at": { + "name": "run_started_at", + "description": "Timestamp the invocation was started.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "run_completed_at": { + "name": "run_completed_at", + "description": "Timestamp the invocation was completed", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "generated_at": { + "name": "generated_at", + "description": "The time this invocation was uploaded to the database.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "command": { + "name": "command", + "description": "dbt command that was used. For example, run.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "dbt_version": { + "name": "dbt_version", + "description": "Version of dbt that was used in this invocation.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "elementary_version": { + "name": "elementary_version", + "description": "Version of the elementary package that was used in this invocation.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "full_refresh": { + "name": "full_refresh", + "description": "Whether or not this invocation was executed as a full-refresh.", + "meta": {}, + "data_type": "boolean", + "constraints": [], + "quote": null, + "tags": [] + }, + "invocation_vars": { + "name": "invocation_vars", + "description": "Dictionary of the variables (and values) that were declared in the invocation.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "vars": { + "name": "vars", + "description": "Dictionary of all variables (and values) in the dbt project. If none were declared at runtime, these are the variables declared in dbt_project yml", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "target_name": { + "name": "target_name", + "description": "Name of the target used in this invocation.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "target_database": { + "name": "target_database", + "description": "Name of the target database that was used in this invocation.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "target_schema": { + "name": "target_schema", + "description": "Name of the target schema that was used in this invocation.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "target_profile_name": { + "name": "target_profile_name", + "description": "Name of the dbt profile that was used in this invocation.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "threads": { + "name": "threads", + "description": "Number of threads that were used to run this dbt invocation. (This number could impact the performance of a dbt invocation).", + "meta": {}, + "data_type": "integer", + "constraints": [], + "quote": null, + "tags": [] + }, + "selected": { + "name": "selected", + "description": "The selected resources in the dbt command. While this is a string in the database, this can easily be converted to an array.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "yaml_selector": { + "name": "yaml_selector", + "description": "The yaml selector that was passed in this invocation.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "job_id": { + "name": "job_id", + "description": "The ID of a job, defined in the `job_id` var or in the `JOB_ID` env var or by the orchestrator (dbt Cloud, GitHub Actions, etc).", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "job_name": { + "name": "job_name", + "description": "The name of a job, defined in the `job_name` var or in the `JOB_NAME` env var.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "job_run_id": { + "name": "job_run_id", + "description": "The run ID of a job, defined in the `job_run_id` var or in the `DBT_JOB_RUN_ID` env var or by the orchestrator (dbt Cloud, GitHub Actions, etc).", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "env": { + "name": "env", + "description": "The environment's name, defined in the `DBT_ENV` env var.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "env_id": { + "name": "env_id", + "description": "The ID of an environment, defined in the `DBT_ENV_ID` env var.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "project_id": { + "name": "project_id", + "description": "The ID of a project, defined in the `DBT_PROJECT_ID` env var or by the orchestrator (dbt Cloud, GitHub Actions, etc).", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "cause_category": { + "name": "cause_category", + "description": "The category of the cause of the invocation. For example, if the invocation was triggered by a schedule, the cause category would be schedule.\nDefined in the `DBT_CAUSE_CATEGORY` env var or by the orchestrator (dbt Cloud, GitHub Actions, etc).\n", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "cause": { + "name": "cause", + "description": "The cause of the invocation. For example, if the invocation was triggered by a manual run, the cause would be _\"Kicked off by Joe.\"_.\nDefined in the `DBT_CAUSE` env var or by the orchestrator (dbt Cloud, GitHub Actions, etc).\n", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "pull_request_id": { + "name": "pull_request_id", + "description": "The ID of a pull request, defined in the `DBT_PULL_REQUEST_ID` env var or by the orchestrator (dbt Cloud, GitHub Actions, etc).", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "git_sha": { + "name": "git_sha", + "description": "The git SHA of the commit that was used in this invocation, defined in the `DBT_GIT_SHA` env var or by the orchestrator (dbt Cloud, GitHub Actions, etc).", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "orchestrator": { + "name": "orchestrator", + "description": "The orchestrator that was used to run this invocation, defined in the `orchestrator` var or in the `ORCHESTRATOR` env var or by the orchestrator env vars. For example, dbt Cloud, GitHub Actions, etc.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "job_url": { + "name": "job_url", + "description": "The name of a job, defined in the `job_url` var or in the `JOB_URL` env var or by the orchestrator. For GitHub Actions orchestrator, the value is calculated.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "account_id": { + "name": "account_id", + "description": "The ID of the account, defined in the `account_id` var or in the `ACCOUNT_ID` env var or by the orchestrator.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + } + }, + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "generated_at" + }, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/run_results.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "incremental", + "transient": false, + "unique_key": "invocation_id", + "on_schema_change": "append_new_columns", + "full_refresh": false, + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "generated_at" + }, + "table_type": null, + "incremental_strategy": null, + "schema": "elementary" + }, + "created_at": 1705031518.711714, + "relation_name": "analytics.jaffle_shop_elementary.dbt_invocations", + "raw_code": "{{\n config(\n materialized = 'incremental',\n transient=False,\n unique_key = 'invocation_id',\n on_schema_change = 'append_new_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n meta={\n \"timestamp_column\": \"created_at\",\n \"prev_timestamp_column\": \"generated_at\",\n },\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy()\n )\n}}\n\n{{ elementary.get_dbt_invocations_empty_table_query() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.get_dbt_invocations_empty_table_query" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/dbt_artifacts/dbt_invocations.sql", + "compiled": true, + "compiled_code": "\n\nselect * from (\n select\n \n \n cast('this_is_just_a_long_dummy_string' as varchar) as invocation_id\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as job_id\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as job_name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as job_run_id\n\n,\n \n cast('dummy_string' as varchar) as run_started_at\n\n,\n \n cast('dummy_string' as varchar) as run_completed_at\n\n,\n \n cast('dummy_string' as varchar) as generated_at\n\n,\n cast('2091-02-17' as timestamp) as created_at\n\n,\n \n cast('dummy_string' as varchar) as command\n\n,\n \n cast('dummy_string' as varchar) as dbt_version\n\n,\n \n cast('dummy_string' as varchar) as elementary_version\n\n,\n \n cast (True as boolean) as full_refresh\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as invocation_vars\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as vars\n\n,\n \n cast('dummy_string' as varchar) as target_name\n\n,\n \n cast('dummy_string' as varchar) as target_database\n\n,\n \n cast('dummy_string' as varchar) as target_schema\n\n,\n \n cast('dummy_string' as varchar) as target_profile_name\n\n,\n \n cast(123456789 as integer) as threads\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as selected\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as yaml_selector\n\n,\n \n cast('dummy_string' as varchar) as project_id\n\n,\n \n cast('dummy_string' as varchar) as project_name\n\n,\n \n cast('dummy_string' as varchar) as env\n\n,\n \n cast('dummy_string' as varchar) as env_id\n\n,\n \n cast('dummy_string' as varchar) as cause_category\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as cause\n\n,\n \n cast('dummy_string' as varchar) as pull_request_id\n\n,\n \n cast('dummy_string' as varchar) as git_sha\n\n,\n \n cast('dummy_string' as varchar) as orchestrator\n\n,\n \n cast('dummy_string' as varchar) as dbt_user\n\n,\n \n cast('dummy_string' as varchar) as job_url\n\n,\n \n cast('dummy_string' as varchar) as job_run_url\n\n,\n \n cast('dummy_string' as varchar) as account_id\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as target_adapter_specific_fields\n\n\n ) as empty_table\n where 1 = 0", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.dbt_metrics": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "dbt_metrics", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/dbt_artifacts/dbt_metrics.sql", + "original_file_path": "models/edr/dbt_artifacts/dbt_metrics.sql", + "unique_id": "model.elementary.dbt_metrics", + "fqn": [ + "elementary", + "edr", + "dbt_artifacts", + "dbt_metrics" + ], + "alias": "dbt_metrics", + "checksum": { + "name": "sha256", + "checksum": "86136f6682874137b3f9277098edf419c918548c440e1cd03c29f930d13d6dca" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [ + { + "sql": "{{ elementary.upload_dbt_metrics() }}", + "transaction": true, + "index": null + } + ], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "transient": false, + "table_type": null + }, + "tags": [], + "description": "Metadata about metrics in the project, including configuration and properties from the dbt graph. Each row contains information about a single metric. Data is loaded every time this model is executed. It is recommended to execute the model every time a change is merged to the project.\n", + "columns": { + "unique_id": { + "name": "unique_id", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "name": { + "name": "name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "label": { + "name": "label", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "model": { + "name": "model", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "type": { + "name": "type", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "sql": { + "name": "sql", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "timestamp": { + "name": "timestamp", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "filters": { + "name": "filters", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "time_grains": { + "name": "time_grains", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "dimensions": { + "name": "dimensions", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "depends_on_macros": { + "name": "depends_on_macros", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "depends_on_nodes": { + "name": "depends_on_nodes", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "description": { + "name": "description", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "tags": { + "name": "tags", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "meta": { + "name": "meta", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "package_name": { + "name": "package_name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "original_path": { + "name": "original_path", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "path": { + "name": "path", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "generated_at": { + "name": "generated_at", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + } + }, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/dbt_artifacts.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "incremental", + "transient": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "full_refresh": false, + "table_type": null, + "incremental_strategy": null, + "post-hook": [ + "{{ elementary.upload_dbt_metrics() }}" + ], + "schema": "elementary" + }, + "created_at": 1705031518.726552, + "relation_name": "analytics.jaffle_shop_elementary.dbt_metrics", + "raw_code": "{{\n config(\n materialized='incremental',\n transient=False,\n post_hook='{{ elementary.upload_dbt_metrics() }}',\n unique_key='unique_id',\n on_schema_change='sync_all_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy()\n )\n}}\n\n{{ elementary.get_dbt_metrics_empty_table_query() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.get_dbt_metrics_empty_table_query", + "macro.elementary.upload_dbt_metrics" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/dbt_artifacts/dbt_metrics.sql", + "compiled": true, + "compiled_code": "\n\nselect * from (\n select\n \n \n cast('dummy_string' as varchar) as unique_id\n\n,\n \n cast('dummy_string' as varchar) as name\n\n,\n \n cast('dummy_string' as varchar) as label\n\n,\n \n cast('dummy_string' as varchar) as model\n\n,\n \n cast('dummy_string' as varchar) as type\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as sql\n\n,\n \n cast('dummy_string' as varchar) as timestamp\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as filters\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as time_grains\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as dimensions\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as depends_on_macros\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as depends_on_nodes\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as description\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as tags\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as meta\n\n,\n \n cast('dummy_string' as varchar) as package_name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as original_path\n\n,\n \n cast('dummy_string' as varchar) as path\n\n,\n \n cast('dummy_string' as varchar) as generated_at\n\n,\n \n cast('dummy_string' as varchar) as metadata_hash\n\n\n ) as empty_table\n where 1 = 0", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.dbt_seeds": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "dbt_seeds", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/dbt_artifacts/dbt_seeds.sql", + "original_file_path": "models/edr/dbt_artifacts/dbt_seeds.sql", + "unique_id": "model.elementary.dbt_seeds", + "fqn": [ + "elementary", + "edr", + "dbt_artifacts", + "dbt_seeds" + ], + "alias": "dbt_seeds", + "checksum": { + "name": "sha256", + "checksum": "e768cbfb8ca753297d627bc51d661b4d4278e48650f9479d6a64431cb291a551" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [ + { + "sql": "{{ elementary.upload_dbt_seeds() }}", + "transaction": true, + "index": null + } + ], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "transient": false, + "table_type": null + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "incremental", + "transient": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "full_refresh": false, + "table_type": null, + "incremental_strategy": null, + "post-hook": [ + "{{ elementary.upload_dbt_seeds() }}" + ], + "schema": "elementary" + }, + "created_at": 1705031518.316746, + "relation_name": "analytics.jaffle_shop_elementary.dbt_seeds", + "raw_code": "{{\n config(\n materialized='incremental',\n transient=False,\n post_hook='{{ elementary.upload_dbt_seeds() }}',\n unique_key='unique_id',\n on_schema_change='sync_all_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy()\n )\n}}\n\n{{ elementary.get_dbt_seeds_empty_table_query() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.get_dbt_seeds_empty_table_query", + "macro.elementary.upload_dbt_seeds" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/dbt_artifacts/dbt_seeds.sql", + "compiled": true, + "compiled_code": "\n\nselect * from (\n select\n \n \n cast('dummy_string' as varchar) as unique_id\n\n,\n \n cast('dummy_string' as varchar) as alias\n\n,\n \n cast('dummy_string' as varchar) as checksum\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as tags\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as meta\n\n,\n \n cast('dummy_string' as varchar) as owner\n\n,\n \n cast('dummy_string' as varchar) as database_name\n\n,\n \n cast('dummy_string' as varchar) as schema_name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as description\n\n,\n \n cast('dummy_string' as varchar) as name\n\n,\n \n cast('dummy_string' as varchar) as package_name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as original_path\n\n,\n \n cast('dummy_string' as varchar) as path\n\n,\n \n cast('dummy_string' as varchar) as generated_at\n\n,\n \n cast('dummy_string' as varchar) as metadata_hash\n\n\n ) as empty_table\n where 1 = 0", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.dbt_artifacts_hashes": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "dbt_artifacts_hashes", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/dbt_artifacts/dbt_artifacts_hashes.sql", + "original_file_path": "models/edr/dbt_artifacts/dbt_artifacts_hashes.sql", + "unique_id": "model.elementary.dbt_artifacts_hashes", + "fqn": [ + "elementary", + "edr", + "dbt_artifacts", + "dbt_artifacts_hashes" + ], + "alias": "dbt_artifacts_hashes", + "checksum": { + "name": "sha256", + "checksum": "830e8b8053c5f914ccc03c0fde90786590b17ce0c736a1b91d1d48c57f22a8ed" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "bind": false + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "view", + "bind": false, + "schema": "elementary" + }, + "created_at": 1705031518.333196, + "relation_name": "analytics.jaffle_shop_elementary.dbt_artifacts_hashes", + "raw_code": "{{\n config(\n materialized = 'view',\n bind=False\n )\n}}\n\n{% set artifact_models = [\n \"dbt_models\",\n \"dbt_tests\",\n \"dbt_sources\",\n \"dbt_snapshots\",\n \"dbt_metrics\",\n \"dbt_exposures\",\n \"dbt_seeds\",\n \"dbt_columns\",\n] %}\n\n{% for artifact_model in artifact_models %}\nselect\n '{{ artifact_model }}' as artifacts_model,\n metadata_hash\nfrom {{ ref(artifact_model) }}\n{% if not loop.last %} union all {% endif %}\n{% endfor %}\norder by metadata_hash", + "language": "sql", + "refs": [ + { + "name": "dbt_models", + "package": null, + "version": null + }, + { + "name": "dbt_tests", + "package": null, + "version": null + }, + { + "name": "dbt_sources", + "package": null, + "version": null + }, + { + "name": "dbt_snapshots", + "package": null, + "version": null + }, + { + "name": "dbt_metrics", + "package": null, + "version": null + }, + { + "name": "dbt_exposures", + "package": null, + "version": null + }, + { + "name": "dbt_seeds", + "package": null, + "version": null + }, + { + "name": "dbt_columns", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "model.elementary.dbt_models", + "model.elementary.dbt_tests", + "model.elementary.dbt_sources", + "model.elementary.dbt_snapshots", + "model.elementary.dbt_metrics", + "model.elementary.dbt_exposures", + "model.elementary.dbt_seeds", + "model.elementary.dbt_columns" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/dbt_artifacts/dbt_artifacts_hashes.sql", + "compiled": true, + "compiled_code": "\n\n\n\n\nselect\n 'dbt_models' as artifacts_model,\n metadata_hash\nfrom analytics.jaffle_shop_elementary.dbt_models\n union all \n\nselect\n 'dbt_tests' as artifacts_model,\n metadata_hash\nfrom analytics.jaffle_shop_elementary.dbt_tests\n union all \n\nselect\n 'dbt_sources' as artifacts_model,\n metadata_hash\nfrom analytics.jaffle_shop_elementary.dbt_sources\n union all \n\nselect\n 'dbt_snapshots' as artifacts_model,\n metadata_hash\nfrom analytics.jaffle_shop_elementary.dbt_snapshots\n union all \n\nselect\n 'dbt_metrics' as artifacts_model,\n metadata_hash\nfrom analytics.jaffle_shop_elementary.dbt_metrics\n union all \n\nselect\n 'dbt_exposures' as artifacts_model,\n metadata_hash\nfrom analytics.jaffle_shop_elementary.dbt_exposures\n union all \n\nselect\n 'dbt_seeds' as artifacts_model,\n metadata_hash\nfrom analytics.jaffle_shop_elementary.dbt_seeds\n union all \n\nselect\n 'dbt_columns' as artifacts_model,\n metadata_hash\nfrom analytics.jaffle_shop_elementary.dbt_columns\n\n\norder by metadata_hash", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.dbt_run_results": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "dbt_run_results", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/dbt_artifacts/dbt_run_results.sql", + "original_file_path": "models/edr/dbt_artifacts/dbt_run_results.sql", + "unique_id": "model.elementary.dbt_run_results", + "fqn": [ + "elementary", + "edr", + "dbt_artifacts", + "dbt_run_results" + ], + "alias": "dbt_run_results", + "checksum": { + "name": "sha256", + "checksum": "9b2317042e53c953bc3839ef18c3e197d2c347ece4d5968731093dd324b349c5" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": { + "deprecated_columns": [ + { + "name": "compiled_sql", + "data_type": "string", + "description": "The compiled SQL executed against the database." + } + ], + "dedup_by_column": "model_execution_id", + "timestamp_column": "created_at", + "prev_timestamp_column": "generated_at" + }, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "model_execution_id", + "on_schema_change": "append_new_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "transient": false, + "table_type": null + }, + "tags": [], + "description": "Run results of dbt invocations, inserted at the end of each invocation. Each row is the invocation result of a single resource (model, test, snapshot, etc). New data is loaded to this model on an on-run-end hook named 'elementary.upload_run_results' from each invocation that produces a result object. This is an incremental model.\n", + "columns": { + "model_execution_id": { + "name": "model_execution_id", + "description": "Execution id generated by joining the unique_id of the resource and the invocation_id. This is the unique key of each row in this model.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "unique_id": { + "name": "unique_id", + "description": "The unique id of the resource (would be similar for all executions of the same resource).", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "invocation_id": { + "name": "invocation_id", + "description": "The unique id of the invocation (would be similar for all resources executed on the same invocation). FK to dbt_invocations.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "generated_at": { + "name": "generated_at", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "name": { + "name": "name", + "description": "Resource name.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "message": { + "name": "message", + "description": "Execution results message returned by dbt.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "status": { + "name": "status", + "description": "Execution result status (success, error, pass, fail)", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "resource_type": { + "name": "resource_type", + "description": "Resource type (model, test, snapshot, seed, etc)", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "execution_time": { + "name": "execution_time", + "description": "Resource execution duration in seconds.", + "meta": {}, + "data_type": "float", + "constraints": [], + "quote": null, + "tags": [] + }, + "execute_started_at": { + "name": "execute_started_at", + "description": "Start time of the execution.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "execute_completed_at": { + "name": "execute_completed_at", + "description": "End time of the execution.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "compile_started_at": { + "name": "compile_started_at", + "description": "Start time of resource compile action.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "compile_completed_at": { + "name": "compile_completed_at", + "description": "End time of resource compile action.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "rows_affected": { + "name": "rows_affected", + "description": "", + "meta": {}, + "data_type": "int", + "constraints": [], + "quote": null, + "tags": [] + }, + "full_refresh": { + "name": "full_refresh", + "description": "Was this a full refresh execution.", + "meta": {}, + "data_type": "boolean", + "constraints": [], + "quote": null, + "tags": [] + }, + "compiled_code": { + "name": "compiled_code", + "description": "The compiled code (SQL / Python) executed against the database.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "failures": { + "name": "failures", + "description": "Number of failures in this run.", + "meta": {}, + "data_type": "int", + "constraints": [], + "quote": null, + "tags": [] + }, + "query_id": { + "name": "query_id", + "description": "Query ID in the data warehouse, if returned by the adapter (currently only supported in Snowflake, is null for any other adapter).", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "thread_id": { + "name": "thread_id", + "description": "Id of the thread of this resource run.", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "adapter_response": { + "name": "adapter_response", + "description": "Response returned by the adapter (Fields will be different for each adapters).", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + } + }, + "meta": { + "deprecated_columns": [ + { + "name": "compiled_sql", + "data_type": "string", + "description": "The compiled SQL executed against the database." + } + ], + "dedup_by_column": "model_execution_id", + "timestamp_column": "created_at", + "prev_timestamp_column": "generated_at" + }, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/run_results.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "meta": { + "dedup_by_column": "model_execution_id", + "timestamp_column": "created_at", + "prev_timestamp_column": "generated_at" + }, + "materialized": "incremental", + "transient": false, + "unique_key": "model_execution_id", + "on_schema_change": "append_new_columns", + "full_refresh": false, + "table_type": null, + "incremental_strategy": null, + "schema": "elementary" + }, + "created_at": 1705031518.7161942, + "relation_name": "analytics.jaffle_shop_elementary.dbt_run_results", + "raw_code": "{{\n config(\n materialized = 'incremental',\n transient=False,\n unique_key = 'model_execution_id',\n on_schema_change = 'append_new_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n meta={\n \"dedup_by_column\": \"model_execution_id\",\n \"timestamp_column\": \"created_at\",\n \"prev_timestamp_column\": \"generated_at\",\n },\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy()\n )\n}}\n\n{{ elementary.get_dbt_run_results_empty_table_query() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.get_dbt_run_results_empty_table_query" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/dbt_artifacts/dbt_run_results.sql", + "compiled": true, + "compiled_code": "\n\nselect * from (\n select\n \n \n cast('this_is_just_a_long_dummy_string' as varchar) as model_execution_id\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as unique_id\n\n,\n \n cast('dummy_string' as varchar) as invocation_id\n\n,\n \n cast('dummy_string' as varchar) as generated_at\n\n,\n cast('2091-02-17' as timestamp) as created_at\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as message\n\n,\n \n cast('dummy_string' as varchar) as status\n\n,\n \n cast('dummy_string' as varchar) as resource_type\n\n,\n \n cast(123456789.99 as float) as execution_time\n\n,\n \n cast('dummy_string' as varchar) as execute_started_at\n\n,\n \n cast('dummy_string' as varchar) as execute_completed_at\n\n,\n \n cast('dummy_string' as varchar) as compile_started_at\n\n,\n \n cast('dummy_string' as varchar) as compile_completed_at\n\n,\n \n cast(31474836478 as bigint) as rows_affected\n\n,\n \n cast (True as boolean) as full_refresh\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as compiled_code\n\n,\n \n cast(31474836478 as bigint) as failures\n\n,\n \n cast('dummy_string' as varchar) as query_id\n\n,\n \n cast('dummy_string' as varchar) as thread_id\n\n,\n \n cast('dummy_string' as varchar) as materialization\n\n,\n \n cast('dummy_string' as varchar) as adapter_response\n\n\n ) as empty_table\n where 1 = 0", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.information_schema_columns": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "information_schema_columns", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/dbt_artifacts/information_schema_columns.sql", + "original_file_path": "models/edr/dbt_artifacts/information_schema_columns.sql", + "unique_id": "model.elementary.information_schema_columns", + "fqn": [ + "elementary", + "edr", + "dbt_artifacts", + "information_schema_columns" + ], + "alias": "information_schema_columns", + "checksum": { + "name": "sha256", + "checksum": "6490e0d9234e48632239108ba3211607d83aa25720bdd3124699b360fe6745b6" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "view", + "schema": "elementary" + }, + "created_at": 1705031518.356805, + "relation_name": "analytics.jaffle_shop_elementary.information_schema_columns", + "raw_code": "{{\n config(\n materialized=elementary.get_information_schema_columns_materialized(),\n )\n}}\n{% if elementary.get_information_schema_columns_materialized() == \"view\" %}\n {{ elementary.get_information_schema_columns_query() }}\n{% else %}\n {{ elementary.get_empty_columns_from_information_schema_table() }}\n{% endif %}", + "language": "sql", + "refs": [ + { + "name": "dbt_models", + "package": null, + "version": null + }, + { + "name": "dbt_snapshots", + "package": null, + "version": null + }, + { + "name": "dbt_sources", + "package": null, + "version": null + }, + { + "name": "dbt_seeds", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_information_schema_columns_materialized", + "macro.elementary.get_information_schema_columns_query" + ], + "nodes": [ + "model.elementary.dbt_models", + "model.elementary.dbt_snapshots", + "model.elementary.dbt_sources", + "model.elementary.dbt_seeds" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/dbt_artifacts/information_schema_columns.sql", + "compiled": true, + "compiled_code": "\n\n \n \n \n \n\n with dbt_models_data as (\n select\n database_name,\n schema_name,\n alias as table_name\n from analytics.jaffle_shop_elementary.dbt_models\n ),\n\n dbt_snapshots_data as (\n select\n database_name,\n schema_name,\n alias as table_name\n from analytics.jaffle_shop_elementary.dbt_snapshots\n ),\n\n dbt_sources_data as (\n select\n database_name,\n schema_name,\n name as table_name\n from analytics.jaffle_shop_elementary.dbt_sources\n ),\n\n dbt_seeds_data as (\n select\n database_name,\n schema_name,\n name as table_name\n from analytics.jaffle_shop_elementary.dbt_seeds\n ),\n\n tables_information as (\n select * from dbt_models_data\n union all\n select * from dbt_sources_data\n union all\n select * from dbt_snapshots_data\n union all\n select * from dbt_seeds_data\n ),\n\n columns_information as (\n \n \n \n \n (\n \n \n select\n upper(table_catalog || '.' || table_schema || '.' || table_name) as full_table_name,\n upper(table_catalog) as database_name,\n upper(table_schema) as schema_name,\n upper(table_name) as table_name,\n upper(column_name) as column_name,\n data_type\n from analytics.INFORMATION_SCHEMA.COLUMNS\n where upper(table_schema) = upper('public')\n \n)\n \n union all\n \n \n (\n \n \n select\n upper(table_catalog || '.' || table_schema || '.' || table_name) as full_table_name,\n upper(table_catalog) as database_name,\n upper(table_schema) as schema_name,\n upper(table_name) as table_name,\n upper(column_name) as column_name,\n data_type\n from analytics.INFORMATION_SCHEMA.COLUMNS\n where upper(table_schema) = upper('jaffle_shop')\n \n)\n \n \n\n\n\n ),\n\n information_schema_columns as (\n select col_info.*\n from tables_information tbl_info\n join columns_information col_info\n on (lower(tbl_info.database_name) = lower(col_info.database_name) and\n lower(tbl_info.schema_name) = lower(col_info.schema_name) and\n lower(tbl_info.table_name) = lower(col_info.table_name)\n )\n )\n\n select *\n from information_schema_columns\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.dbt_exposures": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "dbt_exposures", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/dbt_artifacts/dbt_exposures.sql", + "original_file_path": "models/edr/dbt_artifacts/dbt_exposures.sql", + "unique_id": "model.elementary.dbt_exposures", + "fqn": [ + "elementary", + "edr", + "dbt_artifacts", + "dbt_exposures" + ], + "alias": "dbt_exposures", + "checksum": { + "name": "sha256", + "checksum": "11693171043651333132be14894b4b7acad2ce7f09dea0ae0f722cf7d2417bb0" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [ + { + "sql": "{{ elementary.upload_dbt_exposures() }}", + "transaction": true, + "index": null + } + ], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "transient": false, + "table_type": null + }, + "tags": [], + "description": "Metadata about exposures in the project, including configuration and properties from the dbt graph. Each row contains information about a single exposure. Data is loaded every time this model is executed. It is recommended to execute the model every time a change is merged to the project.\n", + "columns": { + "unique_id": { + "name": "unique_id", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "name": { + "name": "name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "maturity": { + "name": "maturity", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "type": { + "name": "type", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "owner_email": { + "name": "owner_email", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "owner_name": { + "name": "owner_name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "url": { + "name": "url", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "depends_on_macros": { + "name": "depends_on_macros", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "depends_on_nodes": { + "name": "depends_on_nodes", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "description": { + "name": "description", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "tags": { + "name": "tags", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "meta": { + "name": "meta", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "package_name": { + "name": "package_name", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "original_path": { + "name": "original_path", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "path": { + "name": "path", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + }, + "generated_at": { + "name": "generated_at", + "description": "", + "meta": {}, + "data_type": "string", + "constraints": [], + "quote": null, + "tags": [] + } + }, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/dbt_artifacts.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "incremental", + "transient": false, + "unique_key": "unique_id", + "on_schema_change": "sync_all_columns", + "full_refresh": false, + "table_type": null, + "incremental_strategy": null, + "post-hook": [ + "{{ elementary.upload_dbt_exposures() }}" + ], + "schema": "elementary" + }, + "created_at": 1705031518.727793, + "relation_name": "analytics.jaffle_shop_elementary.dbt_exposures", + "raw_code": "{{\n config(\n materialized='incremental',\n transient=False,\n post_hook='{{ elementary.upload_dbt_exposures() }}',\n unique_key='unique_id',\n on_schema_change='sync_all_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy()\n )\n}}\n\n{{ elementary.get_dbt_exposures_empty_table_query() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.get_dbt_exposures_empty_table_query", + "macro.elementary.upload_dbt_exposures" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/dbt_artifacts/dbt_exposures.sql", + "compiled": true, + "compiled_code": "\n\nselect * from (\n select\n \n \n cast('dummy_string' as varchar) as unique_id\n\n,\n \n cast('dummy_string' as varchar) as name\n\n,\n \n cast('dummy_string' as varchar) as maturity\n\n,\n \n cast('dummy_string' as varchar) as type\n\n,\n \n cast('dummy_string' as varchar) as owner_email\n\n,\n \n cast('dummy_string' as varchar) as owner_name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as url\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as depends_on_macros\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as depends_on_nodes\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as description\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as tags\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as meta\n\n,\n \n cast('dummy_string' as varchar) as package_name\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as original_path\n\n,\n \n cast('dummy_string' as varchar) as path\n\n,\n \n cast('dummy_string' as varchar) as generated_at\n\n,\n \n cast('dummy_string' as varchar) as metadata_hash\n\n,\n \n cast('dummy_string' as varchar) as label\n\n,\n \n cast('this_is_just_a_long_dummy_string' as varchar) as raw_queries\n\n\n ) as empty_table\n where 1 = 0", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.metrics_anomaly_score": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "metrics_anomaly_score", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/data_monitoring/anomaly_detection/metrics_anomaly_score.sql", + "original_file_path": "models/edr/data_monitoring/anomaly_detection/metrics_anomaly_score.sql", + "unique_id": "model.elementary.metrics_anomaly_score", + "fqn": [ + "elementary", + "edr", + "data_monitoring", + "anomaly_detection", + "metrics_anomaly_score" + ], + "alias": "metrics_anomaly_score", + "checksum": { + "name": "sha256", + "checksum": "3c24ecb37454bb7fc0cd30ea889676be6759d558716df6e99b8306eee4feab4f" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "bind": false + }, + "tags": [], + "description": "This is a view on `data_monitoring_metrics` that runs the same query the anomaly detection tests run to calculate anomaly scores. The purpose of this view is to provide visibility to the results of anomaly detection tests.\n", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/elementary_tests.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "view", + "bind": false, + "schema": "elementary" + }, + "created_at": 1705031518.704433, + "relation_name": "analytics.jaffle_shop_elementary.metrics_anomaly_score", + "raw_code": "{{\n config(\n materialized = 'view',\n bind=False\n )\n}}\n\nwith data_monitoring_metrics as (\n\n select * from {{ ref('data_monitoring_metrics') }}\n\n),\n\ntime_window_aggregation as (\n\n select\n id,\n full_table_name,\n column_name,\n dimension,\n dimension_value,\n metric_name,\n metric_value,\n source_value,\n bucket_start,\n bucket_end,\n bucket_duration_hours,\n updated_at,\n avg(metric_value) over (partition by metric_name, full_table_name, column_name order by bucket_start asc rows between unbounded preceding and current row) as training_avg,\n stddev(metric_value) over (partition by metric_name, full_table_name, column_name order by bucket_start asc rows between unbounded preceding and current row) as training_stddev,\n count(metric_value) over (partition by metric_name, full_table_name, column_name order by bucket_start asc rows between unbounded preceding and current row) as training_set_size,\n last_value(bucket_end) over (partition by metric_name, full_table_name, column_name order by bucket_start asc rows between unbounded preceding and current row) training_end,\n first_value(bucket_end) over (partition by metric_name, full_table_name, column_name order by bucket_start asc rows between unbounded preceding and current row) as training_start\n from data_monitoring_metrics\n {{ dbt_utils.group_by(12) }}\n),\n\nmetrics_anomaly_score as (\n\n select\n id,\n full_table_name,\n column_name,\n dimension,\n dimension_value,\n metric_name,\n case\n when training_stddev is null then null\n when training_stddev = 0 then 0\n else (metric_value - training_avg) / (training_stddev)\n end as anomaly_score,\n metric_value as latest_metric_value,\n bucket_start,\n bucket_end,\n training_avg,\n training_stddev,\n training_start,\n training_end,\n training_set_size,\n max(updated_at) as updated_at\n from time_window_aggregation\n where\n metric_value is not null\n and training_avg is not null\n and bucket_end >= {{ elementary.edr_timeadd('day', '-7', elementary.edr_date_trunc('day', elementary.edr_current_timestamp())) }}\n {{ dbt_utils.group_by(15) }}\n order by bucket_end desc\n\n\n),\n\nfinal as (\n\n select\n id,\n full_table_name,\n column_name,\n dimension,\n dimension_value,\n metric_name,\n anomaly_score,\n latest_metric_value,\n bucket_start,\n bucket_end,\n training_avg,\n training_stddev,\n training_start,\n training_end,\n training_set_size,\n updated_at,\n case\n when abs(anomaly_score) > {{ elementary.get_config_var('anomaly_sensitivity') }} then true\n else false end\n as is_anomaly\n from metrics_anomaly_score\n)\n\nselect * from final", + "language": "sql", + "refs": [ + { + "name": "data_monitoring_metrics", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt_utils.group_by", + "macro.elementary.edr_current_timestamp", + "macro.elementary.edr_date_trunc", + "macro.elementary.edr_timeadd", + "macro.elementary.get_config_var" + ], + "nodes": [ + "model.elementary.data_monitoring_metrics" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/data_monitoring/anomaly_detection/metrics_anomaly_score.sql", + "compiled": true, + "compiled_code": "\n\nwith data_monitoring_metrics as (\n\n select * from analytics.jaffle_shop_elementary.data_monitoring_metrics\n\n),\n\ntime_window_aggregation as (\n\n select\n id,\n full_table_name,\n column_name,\n dimension,\n dimension_value,\n metric_name,\n metric_value,\n source_value,\n bucket_start,\n bucket_end,\n bucket_duration_hours,\n updated_at,\n avg(metric_value) over (partition by metric_name, full_table_name, column_name order by bucket_start asc rows between unbounded preceding and current row) as training_avg,\n stddev(metric_value) over (partition by metric_name, full_table_name, column_name order by bucket_start asc rows between unbounded preceding and current row) as training_stddev,\n count(metric_value) over (partition by metric_name, full_table_name, column_name order by bucket_start asc rows between unbounded preceding and current row) as training_set_size,\n last_value(bucket_end) over (partition by metric_name, full_table_name, column_name order by bucket_start asc rows between unbounded preceding and current row) training_end,\n first_value(bucket_end) over (partition by metric_name, full_table_name, column_name order by bucket_start asc rows between unbounded preceding and current row) as training_start\n from data_monitoring_metrics\n group by 1,2,3,4,5,6,7,8,9,10,11,12\n),\n\nmetrics_anomaly_score as (\n\n select\n id,\n full_table_name,\n column_name,\n dimension,\n dimension_value,\n metric_name,\n case\n when training_stddev is null then null\n when training_stddev = 0 then 0\n else (metric_value - training_avg) / (training_stddev)\n end as anomaly_score,\n metric_value as latest_metric_value,\n bucket_start,\n bucket_end,\n training_avg,\n training_stddev,\n training_start,\n training_end,\n training_set_size,\n max(updated_at) as updated_at\n from time_window_aggregation\n where\n metric_value is not null\n and training_avg is not null\n and bucket_end >= \n dateadd(day, cast(-7 as integer), cast(date_trunc('day', \n current_timestamp::timestamp\n) as timestamp))\n\n group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15\n order by bucket_end desc\n\n\n),\n\nfinal as (\n\n select\n id,\n full_table_name,\n column_name,\n dimension,\n dimension_value,\n metric_name,\n anomaly_score,\n latest_metric_value,\n bucket_start,\n bucket_end,\n training_avg,\n training_stddev,\n training_start,\n training_end,\n training_set_size,\n updated_at,\n case\n when abs(anomaly_score) > 3 then true\n else false end\n as is_anomaly\n from metrics_anomaly_score\n)\n\nselect * from final", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.anomaly_threshold_sensitivity": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "anomaly_threshold_sensitivity", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/data_monitoring/anomaly_detection/anomaly_threshold_sensitivity.sql", + "original_file_path": "models/edr/data_monitoring/anomaly_detection/anomaly_threshold_sensitivity.sql", + "unique_id": "model.elementary.anomaly_threshold_sensitivity", + "fqn": [ + "elementary", + "edr", + "data_monitoring", + "anomaly_detection", + "anomaly_threshold_sensitivity" + ], + "alias": "anomaly_threshold_sensitivity", + "checksum": { + "name": "sha256", + "checksum": "b0e4310abc62902b98a6ad6fd465713d5aeb5e884b52594e8a1b2ff6429b1b2d" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "bind": false + }, + "tags": [], + "description": "This is a view on `metrics_anomaly_score` that calculates if values of metrics from latest runs would have been considered anomalies in different anomaly scores. This can help you decide if there is a need to adjust the `anomaly_score_threshold`.\n", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/elementary_tests.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "view", + "bind": false, + "schema": "elementary" + }, + "created_at": 1705031518.70465, + "relation_name": "analytics.jaffle_shop_elementary.anomaly_threshold_sensitivity", + "raw_code": "{{\n config(\n materialized = 'view',\n bind=False\n )\n}}\n\nwith metrics_anomaly_score as (\n\n select * from {{ ref('metrics_anomaly_score') }}\n\n),\n\nscore_sensitivity as (\n\n select\n full_table_name,\n column_name,\n metric_name,\n latest_metric_value,\n training_avg as metric_avg,\n training_stddev as metric_stddev,\n anomaly_score,\n case when abs(anomaly_score) >= 1.5 then true else false end as {{ elementary.edr_quote_column('is_anomaly_1_5') }},\n case when abs(anomaly_score) >= 2 then true else false end as {{ elementary.edr_quote_column('is_anomaly_2') }},\n case when abs(anomaly_score) >= 2.5 then true else false end as {{ elementary.edr_quote_column('is_anomaly_2_5') }},\n case when abs(anomaly_score) >= 3 then true else false end as {{ elementary.edr_quote_column('is_anomaly_3') }},\n case when abs(anomaly_score) >= 3.5 then true else false end as {{ elementary.edr_quote_column('is_anomaly_3_5') }},\n case when abs(anomaly_score) >= 4 then true else false end as {{ elementary.edr_quote_column('is_anomaly_4') }},\n case when abs(anomaly_score) >= 4.5 then true else false end as {{ elementary.edr_quote_column('is_anomaly_4_5') }}\n from metrics_anomaly_score\n where abs(anomaly_score) >= 1.5\n\n)\n\nselect * from score_sensitivity", + "language": "sql", + "refs": [ + { + "name": "metrics_anomaly_score", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.edr_quote_column" + ], + "nodes": [ + "model.elementary.metrics_anomaly_score" + ] + }, + "compiled_path": "target/compiled/elementary/models/edr/data_monitoring/anomaly_detection/anomaly_threshold_sensitivity.sql", + "compiled": true, + "compiled_code": "\n\nwith metrics_anomaly_score as (\n\n select * from analytics.jaffle_shop_elementary.metrics_anomaly_score\n\n),\n\nscore_sensitivity as (\n\n select\n full_table_name,\n column_name,\n metric_name,\n latest_metric_value,\n training_avg as metric_avg,\n training_stddev as metric_stddev,\n anomaly_score,\n case when abs(anomaly_score) >= 1.5 then true else false end as \"is_anomaly_1_5\",\n case when abs(anomaly_score) >= 2 then true else false end as \"is_anomaly_2\",\n case when abs(anomaly_score) >= 2.5 then true else false end as \"is_anomaly_2_5\",\n case when abs(anomaly_score) >= 3 then true else false end as \"is_anomaly_3\",\n case when abs(anomaly_score) >= 3.5 then true else false end as \"is_anomaly_3_5\",\n case when abs(anomaly_score) >= 4 then true else false end as \"is_anomaly_4\",\n case when abs(anomaly_score) >= 4.5 then true else false end as \"is_anomaly_4_5\"\n from metrics_anomaly_score\n where abs(anomaly_score) >= 1.5\n\n)\n\nselect * from score_sensitivity", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.schema_columns_snapshot": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "schema_columns_snapshot", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/data_monitoring/schema_changes/schema_columns_snapshot.sql", + "original_file_path": "models/edr/data_monitoring/schema_changes/schema_columns_snapshot.sql", + "unique_id": "model.elementary.schema_columns_snapshot", + "fqn": [ + "elementary", + "edr", + "data_monitoring", + "schema_changes", + "schema_columns_snapshot" + ], + "alias": "schema_columns_snapshot", + "checksum": { + "name": "sha256", + "checksum": "91a98d3190bef02e47f763520b5443197e120ceb132a86b1d90608ca30c33374" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "detected_at" + }, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "column_state_id", + "on_schema_change": "append_new_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "table_type": null + }, + "tags": [], + "description": "Stores the schema details for tables that are monitored with elementary schema changes test. In order to compare current schema to previous state, we must store the previous state. The data is from a view that queries the data warehouse information schema. This is an incremental table.", + "columns": {}, + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "detected_at" + }, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/elementary_tests.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "incremental", + "unique_key": "column_state_id", + "on_schema_change": "append_new_columns", + "full_refresh": false, + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "detected_at" + }, + "table_type": null, + "incremental_strategy": null, + "schema": "elementary" + }, + "created_at": 1705031518.705065, + "relation_name": "analytics.jaffle_shop_elementary.schema_columns_snapshot", + "raw_code": "{{\n config(\n materialized='incremental',\n unique_key = 'column_state_id',\n on_schema_change = 'append_new_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n meta={\n \"timestamp_column\": \"created_at\",\n \"prev_timestamp_column\": \"detected_at\",\n },\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy()\n )\n}}\n\n{{ elementary.empty_schema_columns_snapshot() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.empty_schema_columns_snapshot" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/data_monitoring/schema_changes/schema_columns_snapshot.sql", + "compiled": true, + "compiled_code": "\n\n\n select * from (\n select\n \n \n cast('dummy_string' as varchar) as column_state_id\n\n,\n \n cast('dummy_string' as varchar) as full_column_name\n\n,\n \n cast('dummy_string' as varchar) as full_table_name\n\n,\n \n cast('dummy_string' as varchar) as column_name\n\n,\n \n cast('dummy_string' as varchar) as data_type\n\n,\n \n cast (True as boolean) as is_new\n\n,\n cast('2091-02-17' as timestamp) as detected_at\n\n,\n cast('2091-02-17' as timestamp) as created_at\n\n\n ) as empty_table\n where 1 = 0\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.elementary.data_monitoring_metrics": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "data_monitoring_metrics", + "resource_type": "model", + "package_name": "elementary", + "path": "edr/data_monitoring/data_monitoring/data_monitoring_metrics.sql", + "original_file_path": "models/edr/data_monitoring/data_monitoring/data_monitoring_metrics.sql", + "unique_id": "model.elementary.data_monitoring_metrics", + "fqn": [ + "elementary", + "edr", + "data_monitoring", + "data_monitoring", + "data_monitoring_metrics" + ], + "alias": "data_monitoring_metrics", + "checksum": { + "name": "sha256", + "checksum": "0c19743330c3a4220c42f142eaf58cb571aef26ab24ea27070f3eeb9e3cc925c" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "updated_at" + }, + "group": null, + "materialized": "incremental", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": false, + "unique_key": "id", + "on_schema_change": "append_new_columns", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected", + "table_type": null + }, + "tags": [], + "description": "Elementary anomaly detection tests monitor metrics such as volume, freshness and data quality metrics. This incremental table is used to store the metrics over time. On each anomaly detection test, the test queries this table for historical metrics, and compares to the latest values. The table is updated with new metrics on the on-run-end named handle_test_results that is executed at the end of dbt test invocations.\n", + "columns": {}, + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "updated_at" + }, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "elementary://models/elementary_tests.yml", + "build_path": null, + "deferred": false, + "unrendered_config": { + "materialized": "incremental", + "unique_key": "id", + "on_schema_change": "append_new_columns", + "full_refresh": false, + "meta": { + "timestamp_column": "created_at", + "prev_timestamp_column": "updated_at" + }, + "table_type": null, + "incremental_strategy": null, + "schema": "elementary" + }, + "created_at": 1705031518.704135, + "relation_name": "analytics.jaffle_shop_elementary.data_monitoring_metrics", + "raw_code": "{{\n config(\n materialized='incremental',\n unique_key='id',\n on_schema_change='append_new_columns',\n full_refresh=elementary.get_config_var('elementary_full_refresh'),\n meta={\n \"timestamp_column\": \"created_at\",\n \"prev_timestamp_column\": \"updated_at\",\n },\n table_type=elementary.get_default_table_type(),\n incremental_strategy=elementary.get_default_incremental_strategy(),\n )\n}}\n\n{{ elementary.empty_data_monitoring_metrics() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_default_table_type", + "macro.elementary.get_default_incremental_strategy", + "macro.elementary.empty_data_monitoring_metrics" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/models/edr/data_monitoring/data_monitoring/data_monitoring_metrics.sql", + "compiled": true, + "compiled_code": "\n\n\n \n \n \n \n select * from (\n select\n \n \n cast('dummy_string' as varchar) as id\n\n,\n \n cast('dummy_string' as varchar) as full_table_name\n\n,\n \n cast('dummy_string' as varchar) as column_name\n\n,\n \n cast('dummy_string' as varchar) as metric_name\n\n,\n \n cast(123456789.99 as float) as metric_value\n\n,\n \n cast('dummy_string' as varchar) as source_value\n\n,\n cast('2091-02-17' as timestamp) as bucket_start\n\n,\n cast('2091-02-17' as timestamp) as bucket_end\n\n,\n \n cast(123456789 as integer) as bucket_duration_hours\n\n,\n cast('2091-02-17' as timestamp) as updated_at\n\n,\n \n cast('dummy_string' as varchar) as dimension\n\n,\n \n cast('dummy_string' as varchar) as dimension_value\n\n,\n \n cast('dummy_string' as varchar) as metric_properties\n\n,\n cast('2091-02-17' as timestamp) as created_at\n\n\n ) as empty_table\n where 1 = 0\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "operation.elementary.elementary-on-run-start-0": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "elementary-on-run-start-0", + "resource_type": "operation", + "package_name": "elementary", + "path": "hooks/elementary-on-run-start-0.sql", + "original_file_path": "./dbt_project.yml", + "unique_id": "operation.elementary.elementary-on-run-start-0", + "fqn": [ + "elementary", + "hooks", + "elementary-on-run-start-0" + ], + "alias": "elementary-on-run-start-0", + "checksum": { + "name": "sha256", + "checksum": "1ab453c41a2cb6c43c01fc049f60a3d57d780f5d7ba90f0706ffed053aad94fd" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + } + }, + "tags": [ + "on-run-start" + ], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": { + "schema": "elementary" + }, + "created_at": 1705031518.487652, + "relation_name": null, + "raw_code": "{{ elementary.on_run_start() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.on_run_start" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/./dbt_project.yml/hooks/elementary-on-run-start-0.sql", + "compiled": true, + "compiled_code": "\n \n \n\n \n \n\n \n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "index": 0 + }, + "operation.elementary.elementary-on-run-end-0": { + "database": "analytics", + "schema": "jaffle_shop_elementary", + "name": "elementary-on-run-end-0", + "resource_type": "operation", + "package_name": "elementary", + "path": "hooks/elementary-on-run-end-0.sql", + "original_file_path": "./dbt_project.yml", + "unique_id": "operation.elementary.elementary-on-run-end-0", + "fqn": [ + "elementary", + "hooks", + "elementary-on-run-end-0" + ], + "alias": "elementary-on-run-end-0", + "checksum": { + "name": "sha256", + "checksum": "1ab453c41a2cb6c43c01fc049f60a3d57d780f5d7ba90f0706ffed053aad94fd" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "elementary", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + } + }, + "tags": [ + "on-run-end" + ], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": { + "schema": "elementary" + }, + "created_at": 1705031518.493953, + "relation_name": null, + "raw_code": "{{ elementary.on_run_end() }}", + "language": "sql", + "refs": [], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.elementary.on_run_end" + ], + "nodes": [] + }, + "compiled_path": "target/compiled/elementary/./dbt_project.yml/hooks/elementary-on-run-end-0.sql", + "compiled": true, + "compiled_code": "\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "index": 0 + }, + "test.jaffle_shop_package.unique_customers_customer_id.c5af1ff4b1": { + "test_metadata": { + "name": "unique", + "kwargs": { + "column_name": "customer_id", + "model": "{{ get_where_subquery(ref('customers')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "unique_customers_customer_id", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "unique_customers_customer_id.sql", + "original_file_path": "models/schema.yml", + "unique_id": "test.jaffle_shop_package.unique_customers_customer_id.c5af1ff4b1", + "fqn": [ + "jaffle_shop_package", + "unique_customers_customer_id" + ], + "alias": "unique_customers_customer_id", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.620248, + "relation_name": null, + "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "customers", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_unique", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.customers" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/schema.yml/unique_customers_customer_id.sql", + "compiled": true, + "compiled_code": "\n \n \n\nselect\n customer_id as unique_field,\n count(*) as n_records\n\nfrom analytics.jaffle_shop.customers\nwhere customer_id is not null\ngroup by customer_id\nhaving count(*) > 1\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "customer_id", + "file_key_name": "models.customers", + "attached_node": "model.jaffle_shop_package.customers" + }, + "test.jaffle_shop_package.not_null_customers_customer_id.5c9bf9911d": { + "test_metadata": { + "name": "not_null", + "kwargs": { + "column_name": "customer_id", + "model": "{{ get_where_subquery(ref('customers')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "not_null_customers_customer_id", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "not_null_customers_customer_id.sql", + "original_file_path": "models/schema.yml", + "unique_id": "test.jaffle_shop_package.not_null_customers_customer_id.5c9bf9911d", + "fqn": [ + "jaffle_shop_package", + "not_null_customers_customer_id" + ], + "alias": "not_null_customers_customer_id", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.621564, + "relation_name": null, + "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "customers", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_not_null", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.customers" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/schema.yml/not_null_customers_customer_id.sql", + "compiled": true, + "compiled_code": "\n \n \n\n\n\nselect customer_id\nfrom analytics.jaffle_shop.customers\nwhere customer_id is null\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "customer_id", + "file_key_name": "models.customers", + "attached_node": "model.jaffle_shop_package.customers" + }, + "test.jaffle_shop_package.unique_orders_order_id.fed79b3a6e": { + "test_metadata": { + "name": "unique", + "kwargs": { + "column_name": "order_id", + "model": "{{ get_where_subquery(ref('orders')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "unique_orders_order_id", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "unique_orders_order_id.sql", + "original_file_path": "models/schema.yml", + "unique_id": "test.jaffle_shop_package.unique_orders_order_id.fed79b3a6e", + "fqn": [ + "jaffle_shop_package", + "unique_orders_order_id" + ], + "alias": "unique_orders_order_id", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.62269, + "relation_name": null, + "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "orders", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_unique", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.orders" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/schema.yml/unique_orders_order_id.sql", + "compiled": true, + "compiled_code": "\n \n \n\nselect\n order_id as unique_field,\n count(*) as n_records\n\nfrom analytics.jaffle_shop.orders\nwhere order_id is not null\ngroup by order_id\nhaving count(*) > 1\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "order_id", + "file_key_name": "models.orders", + "attached_node": "model.jaffle_shop_package.orders" + }, + "test.jaffle_shop_package.not_null_orders_order_id.cf6c17daed": { + "test_metadata": { + "name": "not_null", + "kwargs": { + "column_name": "order_id", + "model": "{{ get_where_subquery(ref('orders')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "not_null_orders_order_id", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "not_null_orders_order_id.sql", + "original_file_path": "models/schema.yml", + "unique_id": "test.jaffle_shop_package.not_null_orders_order_id.cf6c17daed", + "fqn": [ + "jaffle_shop_package", + "not_null_orders_order_id" + ], + "alias": "not_null_orders_order_id", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.623772, + "relation_name": null, + "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "orders", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_not_null", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.orders" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/schema.yml/not_null_orders_order_id.sql", + "compiled": true, + "compiled_code": "\n \n \n\n\n\nselect order_id\nfrom analytics.jaffle_shop.orders\nwhere order_id is null\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "order_id", + "file_key_name": "models.orders", + "attached_node": "model.jaffle_shop_package.orders" + }, + "test.jaffle_shop_package.not_null_orders_customer_id.c5f02694af": { + "test_metadata": { + "name": "not_null", + "kwargs": { + "column_name": "customer_id", + "model": "{{ get_where_subquery(ref('orders')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "not_null_orders_customer_id", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "not_null_orders_customer_id.sql", + "original_file_path": "models/schema.yml", + "unique_id": "test.jaffle_shop_package.not_null_orders_customer_id.c5f02694af", + "fqn": [ + "jaffle_shop_package", + "not_null_orders_customer_id" + ], + "alias": "not_null_orders_customer_id", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.6248288, + "relation_name": null, + "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "orders", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_not_null", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.orders" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/schema.yml/not_null_orders_customer_id.sql", + "compiled": true, + "compiled_code": "\n \n \n\n\n\nselect customer_id\nfrom analytics.jaffle_shop.orders\nwhere customer_id is null\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "customer_id", + "file_key_name": "models.orders", + "attached_node": "model.jaffle_shop_package.orders" + }, + "test.jaffle_shop_package.relationships_orders_customer_id__customer_id__ref_customers_.c6ec7f58f2": { + "test_metadata": { + "name": "relationships", + "kwargs": { + "to": "ref('customers')", + "field": "customer_id", + "column_name": "customer_id", + "model": "{{ get_where_subquery(ref('orders')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "relationships_orders_customer_id__customer_id__ref_customers_", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "relationships_orders_customer_id__customer_id__ref_customers_.sql", + "original_file_path": "models/schema.yml", + "unique_id": "test.jaffle_shop_package.relationships_orders_customer_id__customer_id__ref_customers_.c6ec7f58f2", + "fqn": [ + "jaffle_shop_package", + "relationships_orders_customer_id__customer_id__ref_customers_" + ], + "alias": "relationships_orders_customer_id__customer_id__ref_customers_", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.626627, + "relation_name": null, + "raw_code": "{{ test_relationships(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "customers", + "package": null, + "version": null + }, + { + "name": "orders", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_relationships", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.customers", + "model.jaffle_shop_package.orders" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/schema.yml/relationships_orders_customer_id__customer_id__ref_customers_.sql", + "compiled": true, + "compiled_code": "\n \n \n\nwith child as (\n select customer_id as from_field\n from analytics.jaffle_shop.orders\n where customer_id is not null\n),\n\nparent as (\n select customer_id as to_field\n from analytics.jaffle_shop.customers\n)\n\nselect\n from_field\n\nfrom child\nleft join parent\n on child.from_field = parent.to_field\n\nwhere parent.to_field is null\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "customer_id", + "file_key_name": "models.orders", + "attached_node": "model.jaffle_shop_package.orders" + }, + "test.jaffle_shop_package.accepted_values_orders_status__placed__shipped__completed__return_pending__returned.be6b5b5ec3": { + "test_metadata": { + "name": "accepted_values", + "kwargs": { + "values": [ + "placed", + "shipped", + "completed", + "return_pending", + "returned" + ], + "column_name": "status", + "model": "{{ get_where_subquery(ref('orders')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "accepted_values_orders_status__placed__shipped__completed__return_pending__returned", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "accepted_values_orders_1ce6ab157c285f7cd2ac656013faf758.sql", + "original_file_path": "models/schema.yml", + "unique_id": "test.jaffle_shop_package.accepted_values_orders_status__placed__shipped__completed__return_pending__returned.be6b5b5ec3", + "fqn": [ + "jaffle_shop_package", + "accepted_values_orders_status__placed__shipped__completed__return_pending__returned" + ], + "alias": "accepted_values_orders_1ce6ab157c285f7cd2ac656013faf758", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": "accepted_values_orders_1ce6ab157c285f7cd2ac656013faf758", + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": { + "alias": "accepted_values_orders_1ce6ab157c285f7cd2ac656013faf758" + }, + "created_at": 1705031518.6329238, + "relation_name": null, + "raw_code": "{{ test_accepted_values(**_dbt_generic_test_kwargs) }}{{ config(alias=\"accepted_values_orders_1ce6ab157c285f7cd2ac656013faf758\") }}", + "language": "sql", + "refs": [ + { + "name": "orders", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_accepted_values", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.orders" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/schema.yml/accepted_values_orders_1ce6ab157c285f7cd2ac656013faf758.sql", + "compiled": true, + "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n status as value_field,\n count(*) as n_records\n\n from analytics.jaffle_shop.orders\n group by status\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'placed','shipped','completed','return_pending','returned'\n)\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "status", + "file_key_name": "models.orders", + "attached_node": "model.jaffle_shop_package.orders" + }, + "test.jaffle_shop_package.not_null_orders_amount.106140f9fd": { + "test_metadata": { + "name": "not_null", + "kwargs": { + "column_name": "amount", + "model": "{{ get_where_subquery(ref('orders')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "not_null_orders_amount", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "not_null_orders_amount.sql", + "original_file_path": "models/schema.yml", + "unique_id": "test.jaffle_shop_package.not_null_orders_amount.106140f9fd", + "fqn": [ + "jaffle_shop_package", + "not_null_orders_amount" + ], + "alias": "not_null_orders_amount", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.638201, + "relation_name": null, + "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "orders", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_not_null", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.orders" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/schema.yml/not_null_orders_amount.sql", + "compiled": true, + "compiled_code": "\n \n \n\n\n\nselect amount\nfrom analytics.jaffle_shop.orders\nwhere amount is null\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "amount", + "file_key_name": "models.orders", + "attached_node": "model.jaffle_shop_package.orders" + }, + "test.jaffle_shop_package.not_null_orders_credit_card_amount.d3ca593b59": { + "test_metadata": { + "name": "not_null", + "kwargs": { + "column_name": "credit_card_amount", + "model": "{{ get_where_subquery(ref('orders')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "not_null_orders_credit_card_amount", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "not_null_orders_credit_card_amount.sql", + "original_file_path": "models/schema.yml", + "unique_id": "test.jaffle_shop_package.not_null_orders_credit_card_amount.d3ca593b59", + "fqn": [ + "jaffle_shop_package", + "not_null_orders_credit_card_amount" + ], + "alias": "not_null_orders_credit_card_amount", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.639292, + "relation_name": null, + "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "orders", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_not_null", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.orders" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/schema.yml/not_null_orders_credit_card_amount.sql", + "compiled": true, + "compiled_code": "\n \n \n\n\n\nselect credit_card_amount\nfrom analytics.jaffle_shop.orders\nwhere credit_card_amount is null\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "credit_card_amount", + "file_key_name": "models.orders", + "attached_node": "model.jaffle_shop_package.orders" + }, + "test.jaffle_shop_package.not_null_orders_coupon_amount.ab90c90625": { + "test_metadata": { + "name": "not_null", + "kwargs": { + "column_name": "coupon_amount", + "model": "{{ get_where_subquery(ref('orders')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "not_null_orders_coupon_amount", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "not_null_orders_coupon_amount.sql", + "original_file_path": "models/schema.yml", + "unique_id": "test.jaffle_shop_package.not_null_orders_coupon_amount.ab90c90625", + "fqn": [ + "jaffle_shop_package", + "not_null_orders_coupon_amount" + ], + "alias": "not_null_orders_coupon_amount", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.640648, + "relation_name": null, + "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "orders", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_not_null", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.orders" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/schema.yml/not_null_orders_coupon_amount.sql", + "compiled": true, + "compiled_code": "\n \n \n\n\n\nselect coupon_amount\nfrom analytics.jaffle_shop.orders\nwhere coupon_amount is null\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "coupon_amount", + "file_key_name": "models.orders", + "attached_node": "model.jaffle_shop_package.orders" + }, + "test.jaffle_shop_package.not_null_orders_bank_transfer_amount.7743500c49": { + "test_metadata": { + "name": "not_null", + "kwargs": { + "column_name": "bank_transfer_amount", + "model": "{{ get_where_subquery(ref('orders')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "not_null_orders_bank_transfer_amount", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "not_null_orders_bank_transfer_amount.sql", + "original_file_path": "models/schema.yml", + "unique_id": "test.jaffle_shop_package.not_null_orders_bank_transfer_amount.7743500c49", + "fqn": [ + "jaffle_shop_package", + "not_null_orders_bank_transfer_amount" + ], + "alias": "not_null_orders_bank_transfer_amount", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.641752, + "relation_name": null, + "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "orders", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_not_null", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.orders" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/schema.yml/not_null_orders_bank_transfer_amount.sql", + "compiled": true, + "compiled_code": "\n \n \n\n\n\nselect bank_transfer_amount\nfrom analytics.jaffle_shop.orders\nwhere bank_transfer_amount is null\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "bank_transfer_amount", + "file_key_name": "models.orders", + "attached_node": "model.jaffle_shop_package.orders" + }, + "test.jaffle_shop_package.not_null_orders_gift_card_amount.413a0d2d7a": { + "test_metadata": { + "name": "not_null", + "kwargs": { + "column_name": "gift_card_amount", + "model": "{{ get_where_subquery(ref('orders')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "not_null_orders_gift_card_amount", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "not_null_orders_gift_card_amount.sql", + "original_file_path": "models/schema.yml", + "unique_id": "test.jaffle_shop_package.not_null_orders_gift_card_amount.413a0d2d7a", + "fqn": [ + "jaffle_shop_package", + "not_null_orders_gift_card_amount" + ], + "alias": "not_null_orders_gift_card_amount", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.642827, + "relation_name": null, + "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "orders", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_not_null", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.orders" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/schema.yml/not_null_orders_gift_card_amount.sql", + "compiled": true, + "compiled_code": "\n \n \n\n\n\nselect gift_card_amount\nfrom analytics.jaffle_shop.orders\nwhere gift_card_amount is null\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "gift_card_amount", + "file_key_name": "models.orders", + "attached_node": "model.jaffle_shop_package.orders" + }, + "test.jaffle_shop_package.unique_stg_customers_customer_id.c7614daada": { + "test_metadata": { + "name": "unique", + "kwargs": { + "column_name": "customer_id", + "model": "{{ get_where_subquery(ref('stg_customers')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "unique_stg_customers_customer_id", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "unique_stg_customers_customer_id.sql", + "original_file_path": "models/staging/schema.yml", + "unique_id": "test.jaffle_shop_package.unique_stg_customers_customer_id.c7614daada", + "fqn": [ + "jaffle_shop_package", + "staging", + "unique_stg_customers_customer_id" + ], + "alias": "unique_stg_customers_customer_id", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.679838, + "relation_name": null, + "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "stg_customers", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_unique", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.stg_customers" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/staging/schema.yml/unique_stg_customers_customer_id.sql", + "compiled": true, + "compiled_code": "\n \n \n\nselect\n customer_id as unique_field,\n count(*) as n_records\n\nfrom analytics.jaffle_shop.stg_customers\nwhere customer_id is not null\ngroup by customer_id\nhaving count(*) > 1\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "customer_id", + "file_key_name": "models.stg_customers", + "attached_node": "model.jaffle_shop_package.stg_customers" + }, + "test.jaffle_shop_package.not_null_stg_customers_customer_id.e2cfb1f9aa": { + "test_metadata": { + "name": "not_null", + "kwargs": { + "column_name": "customer_id", + "model": "{{ get_where_subquery(ref('stg_customers')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "not_null_stg_customers_customer_id", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "not_null_stg_customers_customer_id.sql", + "original_file_path": "models/staging/schema.yml", + "unique_id": "test.jaffle_shop_package.not_null_stg_customers_customer_id.e2cfb1f9aa", + "fqn": [ + "jaffle_shop_package", + "staging", + "not_null_stg_customers_customer_id" + ], + "alias": "not_null_stg_customers_customer_id", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.681042, + "relation_name": null, + "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "stg_customers", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_not_null", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.stg_customers" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/staging/schema.yml/not_null_stg_customers_customer_id.sql", + "compiled": true, + "compiled_code": "\n \n \n\n\n\nselect customer_id\nfrom analytics.jaffle_shop.stg_customers\nwhere customer_id is null\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "customer_id", + "file_key_name": "models.stg_customers", + "attached_node": "model.jaffle_shop_package.stg_customers" + }, + "test.jaffle_shop_package.unique_stg_orders_order_id.e3b841c71a": { + "test_metadata": { + "name": "unique", + "kwargs": { + "column_name": "order_id", + "model": "{{ get_where_subquery(ref('stg_orders')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "unique_stg_orders_order_id", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "unique_stg_orders_order_id.sql", + "original_file_path": "models/staging/schema.yml", + "unique_id": "test.jaffle_shop_package.unique_stg_orders_order_id.e3b841c71a", + "fqn": [ + "jaffle_shop_package", + "staging", + "unique_stg_orders_order_id" + ], + "alias": "unique_stg_orders_order_id", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.682121, + "relation_name": null, + "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "stg_orders", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_unique", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.stg_orders" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/staging/schema.yml/unique_stg_orders_order_id.sql", + "compiled": true, + "compiled_code": "\n \n \n\nselect\n order_id as unique_field,\n count(*) as n_records\n\nfrom analytics.jaffle_shop.stg_orders\nwhere order_id is not null\ngroup by order_id\nhaving count(*) > 1\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "order_id", + "file_key_name": "models.stg_orders", + "attached_node": "model.jaffle_shop_package.stg_orders" + }, + "test.jaffle_shop_package.not_null_stg_orders_order_id.81cfe2fe64": { + "test_metadata": { + "name": "not_null", + "kwargs": { + "column_name": "order_id", + "model": "{{ get_where_subquery(ref('stg_orders')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "not_null_stg_orders_order_id", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "not_null_stg_orders_order_id.sql", + "original_file_path": "models/staging/schema.yml", + "unique_id": "test.jaffle_shop_package.not_null_stg_orders_order_id.81cfe2fe64", + "fqn": [ + "jaffle_shop_package", + "staging", + "not_null_stg_orders_order_id" + ], + "alias": "not_null_stg_orders_order_id", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.683188, + "relation_name": null, + "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "stg_orders", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_not_null", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.stg_orders" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/staging/schema.yml/not_null_stg_orders_order_id.sql", + "compiled": true, + "compiled_code": "\n \n \n\n\n\nselect order_id\nfrom analytics.jaffle_shop.stg_orders\nwhere order_id is null\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "order_id", + "file_key_name": "models.stg_orders", + "attached_node": "model.jaffle_shop_package.stg_orders" + }, + "test.jaffle_shop_package.accepted_values_stg_orders_status__placed__shipped__completed__return_pending__returned.080fb20aad": { + "test_metadata": { + "name": "accepted_values", + "kwargs": { + "values": [ + "placed", + "shipped", + "completed", + "return_pending", + "returned" + ], + "column_name": "status", + "model": "{{ get_where_subquery(ref('stg_orders')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "accepted_values_stg_orders_status__placed__shipped__completed__return_pending__returned", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "accepted_values_stg_orders_4f514bf94b77b7ea437830eec4421c58.sql", + "original_file_path": "models/staging/schema.yml", + "unique_id": "test.jaffle_shop_package.accepted_values_stg_orders_status__placed__shipped__completed__return_pending__returned.080fb20aad", + "fqn": [ + "jaffle_shop_package", + "staging", + "accepted_values_stg_orders_status__placed__shipped__completed__return_pending__returned" + ], + "alias": "accepted_values_stg_orders_4f514bf94b77b7ea437830eec4421c58", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": "accepted_values_stg_orders_4f514bf94b77b7ea437830eec4421c58", + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": { + "alias": "accepted_values_stg_orders_4f514bf94b77b7ea437830eec4421c58" + }, + "created_at": 1705031518.6843112, + "relation_name": null, + "raw_code": "{{ test_accepted_values(**_dbt_generic_test_kwargs) }}{{ config(alias=\"accepted_values_stg_orders_4f514bf94b77b7ea437830eec4421c58\") }}", + "language": "sql", + "refs": [ + { + "name": "stg_orders", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_accepted_values", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.stg_orders" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/staging/schema.yml/accepted_values_stg_orders_4f514bf94b77b7ea437830eec4421c58.sql", + "compiled": true, + "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n status as value_field,\n count(*) as n_records\n\n from analytics.jaffle_shop.stg_orders\n group by status\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'placed','shipped','completed','return_pending','returned'\n)\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "status", + "file_key_name": "models.stg_orders", + "attached_node": "model.jaffle_shop_package.stg_orders" + }, + "test.jaffle_shop_package.unique_stg_payments_payment_id.3744510712": { + "test_metadata": { + "name": "unique", + "kwargs": { + "column_name": "payment_id", + "model": "{{ get_where_subquery(ref('stg_payments')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "unique_stg_payments_payment_id", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "unique_stg_payments_payment_id.sql", + "original_file_path": "models/staging/schema.yml", + "unique_id": "test.jaffle_shop_package.unique_stg_payments_payment_id.3744510712", + "fqn": [ + "jaffle_shop_package", + "staging", + "unique_stg_payments_payment_id" + ], + "alias": "unique_stg_payments_payment_id", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.6871932, + "relation_name": null, + "raw_code": "{{ test_unique(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "stg_payments", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_unique", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.stg_payments" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/staging/schema.yml/unique_stg_payments_payment_id.sql", + "compiled": true, + "compiled_code": "\n \n \n\nselect\n payment_id as unique_field,\n count(*) as n_records\n\nfrom analytics.jaffle_shop.stg_payments\nwhere payment_id is not null\ngroup by payment_id\nhaving count(*) > 1\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "payment_id", + "file_key_name": "models.stg_payments", + "attached_node": "model.jaffle_shop_package.stg_payments" + }, + "test.jaffle_shop_package.not_null_stg_payments_payment_id.c19cc50075": { + "test_metadata": { + "name": "not_null", + "kwargs": { + "column_name": "payment_id", + "model": "{{ get_where_subquery(ref('stg_payments')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "not_null_stg_payments_payment_id", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "not_null_stg_payments_payment_id.sql", + "original_file_path": "models/staging/schema.yml", + "unique_id": "test.jaffle_shop_package.not_null_stg_payments_payment_id.c19cc50075", + "fqn": [ + "jaffle_shop_package", + "staging", + "not_null_stg_payments_payment_id" + ], + "alias": "not_null_stg_payments_payment_id", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": null, + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705031518.688288, + "relation_name": null, + "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", + "language": "sql", + "refs": [ + { + "name": "stg_payments", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_not_null", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.stg_payments" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/staging/schema.yml/not_null_stg_payments_payment_id.sql", + "compiled": true, + "compiled_code": "\n \n \n\n\n\nselect payment_id\nfrom analytics.jaffle_shop.stg_payments\nwhere payment_id is null\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "payment_id", + "file_key_name": "models.stg_payments", + "attached_node": "model.jaffle_shop_package.stg_payments" + }, + "test.jaffle_shop_package.accepted_values_stg_payments_payment_method__credit_card__coupon__bank_transfer__gift_card.3c3820f278": { + "test_metadata": { + "name": "accepted_values", + "kwargs": { + "values": [ + "credit_card", + "coupon", + "bank_transfer", + "gift_card" + ], + "column_name": "payment_method", + "model": "{{ get_where_subquery(ref('stg_payments')) }}" + }, + "namespace": null + }, + "database": "analytics", + "schema": "jaffle_shop_dbt_test__audit", + "name": "accepted_values_stg_payments_payment_method__credit_card__coupon__bank_transfer__gift_card", + "resource_type": "test", + "package_name": "jaffle_shop_package", + "path": "accepted_values_stg_payments_c7909fb19b1f0177c2bf99c7912f06ef.sql", + "original_file_path": "models/staging/schema.yml", + "unique_id": "test.jaffle_shop_package.accepted_values_stg_payments_payment_method__credit_card__coupon__bank_transfer__gift_card.3c3820f278", + "fqn": [ + "jaffle_shop_package", + "staging", + "accepted_values_stg_payments_payment_method__credit_card__coupon__bank_transfer__gift_card" + ], + "alias": "accepted_values_stg_payments_c7909fb19b1f0177c2bf99c7912f06ef", + "checksum": { + "name": "none", + "checksum": "" + }, + "config": { + "enabled": true, + "alias": "accepted_values_stg_payments_c7909fb19b1f0177c2bf99c7912f06ef", + "schema": "dbt_test__audit", + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "test", + "severity": "ERROR", + "store_failures": null, + "store_failures_as": null, + "where": null, + "limit": null, + "fail_calc": "count(*)", + "warn_if": "!= 0", + "error_if": "!= 0" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": { + "alias": "accepted_values_stg_payments_c7909fb19b1f0177c2bf99c7912f06ef" + }, + "created_at": 1705031518.690055, + "relation_name": null, + "raw_code": "{{ test_accepted_values(**_dbt_generic_test_kwargs) }}{{ config(alias=\"accepted_values_stg_payments_c7909fb19b1f0177c2bf99c7912f06ef\") }}", + "language": "sql", + "refs": [ + { + "name": "stg_payments", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [ + "macro.dbt.test_accepted_values", + "macro.dbt.get_where_subquery" + ], + "nodes": [ + "model.jaffle_shop_package.stg_payments" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/staging/schema.yml/accepted_values_stg_payments_c7909fb19b1f0177c2bf99c7912f06ef.sql", + "compiled": true, + "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n payment_method as value_field,\n count(*) as n_records\n\n from analytics.jaffle_shop.stg_payments\n group by payment_method\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'credit_card','coupon','bank_transfer','gift_card'\n)\n\n\n", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "column_name": "payment_method", + "file_key_name": "models.stg_payments", + "attached_node": "model.jaffle_shop_package.stg_payments" + }, + "model.jaffle_shop_package.dim_downstream_model_dependent_on_source": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "dim_downstream_model_dependent_on_source", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "dim_downstream_model_dependent_on_source.sql", + "original_file_path": "models/dim_downstream_model_dependent_on_source.sql", + "unique_id": "model.jaffle_shop_package.dim_downstream_model_dependent_on_source", + "fqn": [ + "jaffle_shop_package", + "dim_downstream_model_dependent_on_source" + ], + "alias": "dim_downstream_model_dependent_on_source", + "checksum": { + "name": "sha256", + "checksum": "1af12cdf034fa72e295aedb1783534d67362df46aa8adda00931855faa6d5bb4" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705033874.235662, + "relation_name": "analytics.jaffle_shop.dim_downstream_model_dependent_on_source", + "raw_code": "select * from {{ source('jaffle_shop', 'customers') }}", + "language": "sql", + "refs": [], + "sources": [ + [ + "jaffle_shop", + "customers" + ] + ], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "source.jaffle_shop_package.jaffle_shop.customers" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/dim_downstream_model_dependent_on_source.sql", + "compiled": true, + "compiled_code": "select * from analytics.public.customers", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.mart_downstream_model_dependent_on_source": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "mart_downstream_model_dependent_on_source", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "mart_downstream_model_dependent_on_source.sql", + "original_file_path": "models/mart_downstream_model_dependent_on_source.sql", + "unique_id": "model.jaffle_shop_package.mart_downstream_model_dependent_on_source", + "fqn": [ + "jaffle_shop_package", + "mart_downstream_model_dependent_on_source" + ], + "alias": "mart_downstream_model_dependent_on_source", + "checksum": { + "name": "sha256", + "checksum": "1af12cdf034fa72e295aedb1783534d67362df46aa8adda00931855faa6d5bb4" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705033879.370749, + "relation_name": "analytics.jaffle_shop.mart_downstream_model_dependent_on_source", + "raw_code": "select * from {{ source('jaffle_shop', 'customers') }}", + "language": "sql", + "refs": [], + "sources": [ + [ + "jaffle_shop", + "customers" + ] + ], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "source.jaffle_shop_package.jaffle_shop.customers" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/mart_downstream_model_dependent_on_source.sql", + "compiled": true, + "compiled_code": "select * from analytics.public.customers", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.int_downstream_model_dependent_on_source": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "int_downstream_model_dependent_on_source", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "int_downstream_model_dependent_on_source.sql", + "original_file_path": "models/int_downstream_model_dependent_on_source.sql", + "unique_id": "model.jaffle_shop_package.int_downstream_model_dependent_on_source", + "fqn": [ + "jaffle_shop_package", + "int_downstream_model_dependent_on_source" + ], + "alias": "int_downstream_model_dependent_on_source", + "checksum": { + "name": "sha256", + "checksum": "1af12cdf034fa72e295aedb1783534d67362df46aa8adda00931855faa6d5bb4" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705033882.481601, + "relation_name": "analytics.jaffle_shop.int_downstream_model_dependent_on_source", + "raw_code": "select * from {{ source('jaffle_shop', 'customers') }}", + "language": "sql", + "refs": [], + "sources": [ + [ + "jaffle_shop", + "customers" + ] + ], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "source.jaffle_shop_package.jaffle_shop.customers" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/int_downstream_model_dependent_on_source.sql", + "compiled": true, + "compiled_code": "select * from analytics.public.customers", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.customers_downstream": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "customers_downstream", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "customers_downstream.sql", + "original_file_path": "models/customers_downstream.sql", + "unique_id": "model.jaffle_shop_package.customers_downstream", + "fqn": [ + "jaffle_shop_package", + "customers_downstream" + ], + "alias": "customers_downstream", + "checksum": { + "name": "sha256", + "checksum": "85302a290e52a84ebe6d9b408ba8819fbc322fa5dc12e18b05b36e84c61964e1" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705034210.709997, + "relation_name": "analytics.jaffle_shop.customers_downstream", + "raw_code": "select * from {{ ref('customers') }}", + "language": "sql", + "refs": [ + { + "name": "customers", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "model.jaffle_shop_package.customers" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/customers_downstream.sql", + "compiled": true, + "compiled_code": "select * from analytics.jaffle_shop.customers", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.joining_of_upstream_contexts": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "joining_of_upstream_contexts", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "joining_of_upstream_contexts.sql", + "original_file_path": "models/joining_of_upstream_contexts.sql", + "unique_id": "model.jaffle_shop_package.joining_of_upstream_contexts", + "fqn": [ + "jaffle_shop_package", + "joining_of_upstream_contexts" + ], + "alias": "joining_of_upstream_contexts", + "checksum": { + "name": "sha256", + "checksum": "d1d1c61236c53f3b535ebdae9b8fae6dce5195e33183b2057d0d72094ef2b701" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705034210.7193458, + "relation_name": "analytics.jaffle_shop.joining_of_upstream_contexts", + "raw_code": "select * from {{ ref('customers') }} join {{ ref('customers_downstream') }}", + "language": "sql", + "refs": [ + { + "name": "customers", + "package": null, + "version": null + }, + { + "name": "customers_downstream", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "model.jaffle_shop_package.customers", + "model.jaffle_shop_package.customers_downstream" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/joining_of_upstream_contexts.sql", + "compiled": true, + "compiled_code": "select * from analytics.jaffle_shop.customers join analytics.jaffle_shop.customers_downstream", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.multiple_sources_joined": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "multiple_sources_joined", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "multiple_sources_joined.sql", + "original_file_path": "models/multiple_sources_joined.sql", + "unique_id": "model.jaffle_shop_package.multiple_sources_joined", + "fqn": [ + "jaffle_shop_package", + "multiple_sources_joined" + ], + "alias": "multiple_sources_joined", + "checksum": { + "name": "sha256", + "checksum": "dc8eae6c12a5f1695b8e84cb2940e45cb8f684c97a81d5f237df95f064e1dabd" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705035162.574242, + "relation_name": "analytics.jaffle_shop.multiple_sources_joined", + "raw_code": "select * from {{ source('stripe', 'stripe_customers') }} join {{ source('stripe', 'stripe_daily_rate') }}", + "language": "sql", + "refs": [], + "sources": [ + [ + "stripe", + "stripe_daily_rate" + ], + [ + "stripe", + "stripe_customers" + ] + ], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "source.jaffle_shop_package.stripe.stripe_daily_rate", + "source.jaffle_shop_package.stripe.stripe_customers" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/multiple_sources_joined.sql", + "compiled": true, + "compiled_code": "select * from analytics.public.customers join analytics.public.daily_rate", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.source_fanout1": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "source_fanout1", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "source_fanout1.sql", + "original_file_path": "models/source_fanout1.sql", + "unique_id": "model.jaffle_shop_package.source_fanout1", + "fqn": [ + "jaffle_shop_package", + "source_fanout1" + ], + "alias": "source_fanout1", + "checksum": { + "name": "sha256", + "checksum": "643d2e2077d80fc69cacfaa3e40aa147fea11f7a6df0e2fd5d2dcd38400b3364" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705035464.138558, + "relation_name": "analytics.jaffle_shop.source_fanout1", + "raw_code": "select * from {{ source('stripe', 'stripe_customers') }}", + "language": "sql", + "refs": [], + "sources": [ + [ + "stripe", + "stripe_customers" + ] + ], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "source.jaffle_shop_package.stripe.stripe_customers" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/source_fanout1.sql", + "compiled": true, + "compiled_code": "select * from analytics.public.customers", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.source_fanout2": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "source_fanout2", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "source_fanout2.sql", + "original_file_path": "models/source_fanout2.sql", + "unique_id": "model.jaffle_shop_package.source_fanout2", + "fqn": [ + "jaffle_shop_package", + "source_fanout2" + ], + "alias": "source_fanout2", + "checksum": { + "name": "sha256", + "checksum": "643d2e2077d80fc69cacfaa3e40aa147fea11f7a6df0e2fd5d2dcd38400b3364" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705035472.194263, + "relation_name": "analytics.jaffle_shop.source_fanout2", + "raw_code": "select * from {{ source('stripe', 'stripe_customers') }}", + "language": "sql", + "refs": [], + "sources": [ + [ + "stripe", + "stripe_customers" + ] + ], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "source.jaffle_shop_package.stripe.stripe_customers" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/source_fanout2.sql", + "compiled": true, + "compiled_code": "select * from analytics.public.customers", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.stg_depends_on_stg": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "stg_depends_on_stg", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "stg_depends_on_stg.sql", + "original_file_path": "models/stg_depends_on_stg.sql", + "unique_id": "model.jaffle_shop_package.stg_depends_on_stg", + "fqn": [ + "jaffle_shop_package", + "stg_depends_on_stg" + ], + "alias": "stg_depends_on_stg", + "checksum": { + "name": "sha256", + "checksum": "73688d766ae47381092b48af9ed99717c3b14e302d6729dd871d3155b2a141df" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705035918.3310819, + "relation_name": "analytics.jaffle_shop.stg_depends_on_stg", + "raw_code": "select * from {{ ref('stg_depends_on_downstream') }}", + "language": "sql", + "refs": [ + { + "name": "stg_depends_on_downstream", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "model.jaffle_shop_package.stg_depends_on_downstream" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/stg_depends_on_stg.sql", + "compiled": true, + "compiled_code": "select * from analytics.jaffle_shop.stg_depends_on_downstream", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.stg_depends_on_downstream": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "stg_depends_on_downstream", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "stg_depends_on_downstream.sql", + "original_file_path": "models/stg_depends_on_downstream.sql", + "unique_id": "model.jaffle_shop_package.stg_depends_on_downstream", + "fqn": [ + "jaffle_shop_package", + "stg_depends_on_downstream" + ], + "alias": "stg_depends_on_downstream", + "checksum": { + "name": "sha256", + "checksum": "060b31d623819471aea36323f3085da61cf60ce45a3f501d891d9f386e42b34d" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": {}, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705035918.340084, + "relation_name": "analytics.jaffle_shop.stg_depends_on_downstream", + "raw_code": "select * from {{ ref('fct_downstream_model_dependent_on_source') }}", + "language": "sql", + "refs": [ + { + "name": "fct_downstream_model_dependent_on_source", + "package": null, + "version": null + } + ], + "sources": [], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "model.jaffle_shop_package.fct_downstream_model_dependent_on_source" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/stg_depends_on_downstream.sql", + "compiled": true, + "compiled_code": "select * from analytics.jaffle_shop.fct_downstream_model_dependent_on_source", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + }, + "model.jaffle_shop_package.fct_downstream_model_dependent_on_source": { + "database": "analytics", + "schema": "jaffle_shop", + "name": "fct_downstream_model_dependent_on_source", + "resource_type": "model", + "package_name": "jaffle_shop_package", + "path": "fct_downstream_model_dependent_on_source.sql", + "original_file_path": "models/fct_downstream_model_dependent_on_source.sql", + "unique_id": "model.jaffle_shop_package.fct_downstream_model_dependent_on_source", + "fqn": [ + "jaffle_shop_package", + "fct_downstream_model_dependent_on_source" + ], + "alias": "fct_downstream_model_dependent_on_source", + "checksum": { + "name": "sha256", + "checksum": "1af12cdf034fa72e295aedb1783534d67362df46aa8adda00931855faa6d5bb4" + }, + "config": { + "enabled": true, + "alias": null, + "schema": null, + "database": null, + "tags": [], + "meta": {}, + "group": null, + "materialized": "view", + "incremental_strategy": null, + "persist_docs": {}, + "post-hook": [], + "pre-hook": [], + "quoting": {}, + "column_types": {}, + "full_refresh": null, + "unique_key": null, + "on_schema_change": "ignore", + "on_configuration_change": "apply", + "grants": {}, + "packages": [], + "docs": { + "show": true, + "node_color": null + }, + "contract": { + "enforced": false, + "alias_types": true + }, + "access": "protected" + }, + "tags": [], + "description": "", + "columns": { + "CUSTOMER_ID": { + "name": "CUSTOMER_ID", + "description": "The unique identifier for each customer. This column is essential for tracking and identifying individual customers in the dataset. It can be used as a primary key for joining with other tables or datasets. Data analysts can utilize this column to segment and analyze customer behavior, such as purchase history, preferences, and engagement patterns. It is particularly useful for customer segmentation, cohort analysis, and personalized marketing campaigns.", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "FIRST_NAME": { + "name": "FIRST_NAME", + "description": "", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "LAST_NAME": { + "name": "LAST_NAME", + "description": "", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "FIRST_ORDER_DATE": { + "name": "FIRST_ORDER_DATE", + "description": "", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "MOST_RECENT_ORDER_DATE": { + "name": "MOST_RECENT_ORDER_DATE", + "description": "", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "NUMBER_OF_ORDERS": { + "name": "NUMBER_OF_ORDERS", + "description": "", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + }, + "EXTRA": { + "name": "EXTRA", + "description": "test", + "meta": {}, + "data_type": null, + "constraints": [], + "quote": null, + "tags": [] + } + }, + "meta": {}, + "group": null, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": "jaffle_shop_package://models/schema.yml", + "build_path": null, + "deferred": false, + "unrendered_config": {}, + "created_at": 1705108942.536182, + "relation_name": "analytics.jaffle_shop.fct_downstream_model_dependent_on_source", + "raw_code": "select * from {{ source('jaffle_shop', 'customers') }}", + "language": "sql", + "refs": [], + "sources": [ + [ + "jaffle_shop", + "customers" + ] + ], + "metrics": [], + "depends_on": { + "macros": [], + "nodes": [ + "source.jaffle_shop_package.jaffle_shop.customers" + ] + }, + "compiled_path": "target/compiled/jaffle_shop_package/models/fct_downstream_model_dependent_on_source.sql", + "compiled": true, + "compiled_code": "select * from analytics.public.customers", + "extra_ctes_injected": true, + "extra_ctes": [], + "contract": { + "enforced": false, + "alias_types": true, + "checksum": null + }, + "access": "protected", + "constraints": [], + "version": null, + "latest_version": null, + "deprecation_date": null + } + }, + "sources": { + "source.jaffle_shop_package.jaffle_shop.daily_rate": { + "database": "analytics", + "schema": "public", + "name": "daily_rate", + "resource_type": "source", + "package_name": "jaffle_shop_package", + "path": "models/sources.yml", + "original_file_path": "models/sources.yml", + "unique_id": "source.jaffle_shop_package.jaffle_shop.daily_rate", + "fqn": [ + "jaffle_shop_package", + "jaffle_shop", + "daily_rate" + ], + "source_name": "jaffle_shop", + "source_description": "", + "loader": "", + "identifier": "daily_rate", + "quoting": { + "database": null, + "schema": null, + "identifier": null, + "column": null + }, + "loaded_at_field": null, + "freshness": { + "warn_after": { + "count": null, + "period": null + }, + "error_after": { + "count": null, + "period": null + }, + "filter": null + }, + "external": null, + "description": "", + "columns": {}, + "meta": {}, + "source_meta": {}, + "tags": [], + "config": { + "enabled": true + }, + "patch_path": null, + "unrendered_config": {}, + "relation_name": "analytics.public.daily_rate", + "created_at": 1705031518.7288818 + }, + "source.jaffle_shop_package.jaffle_shop.customers": { + "database": "analytics", + "schema": "public", + "name": "customers", + "resource_type": "source", + "package_name": "jaffle_shop_package", + "path": "models/sources.yml", + "original_file_path": "models/sources.yml", + "unique_id": "source.jaffle_shop_package.jaffle_shop.customers", + "fqn": [ + "jaffle_shop_package", + "jaffle_shop", + "customers" + ], + "source_name": "jaffle_shop", + "source_description": "", + "loader": "", + "identifier": "customers", + "quoting": { + "database": null, + "schema": null, + "identifier": null, + "column": null + }, + "loaded_at_field": null, + "freshness": { + "warn_after": { + "count": null, + "period": null + }, + "error_after": { + "count": null, + "period": null + }, + "filter": null + }, + "external": null, + "description": "", + "columns": {}, + "meta": {}, + "source_meta": {}, + "tags": [], + "config": { + "enabled": true + }, + "patch_path": null, + "unrendered_config": {}, + "relation_name": "analytics.public.customers", + "created_at": 1705031518.728991 + }, + "source.jaffle_shop_package.stripe.stripe_daily_rate": { + "database": "analytics", + "schema": "public", + "name": "stripe_daily_rate", + "resource_type": "source", + "package_name": "jaffle_shop_package", + "path": "models/sources.yml", + "original_file_path": "models/sources.yml", + "unique_id": "source.jaffle_shop_package.stripe.stripe_daily_rate", + "fqn": [ + "jaffle_shop_package", + "stripe", + "stripe_daily_rate" + ], + "source_name": "stripe", + "source_description": "", + "loader": "", + "identifier": "daily_rate", + "quoting": { + "database": null, + "schema": null, + "identifier": null, + "column": null + }, + "loaded_at_field": null, + "freshness": { + "warn_after": { + "count": null, + "period": null + }, + "error_after": { + "count": null, + "period": null + }, + "filter": null + }, + "external": null, + "description": "", + "columns": {}, + "meta": {}, + "source_meta": {}, + "tags": [], + "config": { + "enabled": true + }, + "patch_path": null, + "unrendered_config": {}, + "relation_name": "analytics.public.daily_rate", + "created_at": 1705035110.488428 + }, + "source.jaffle_shop_package.stripe.stripe_customers": { + "database": "analytics", + "schema": "public", + "name": "stripe_customers", + "resource_type": "source", + "package_name": "jaffle_shop_package", + "path": "models/sources.yml", + "original_file_path": "models/sources.yml", + "unique_id": "source.jaffle_shop_package.stripe.stripe_customers", + "fqn": [ + "jaffle_shop_package", + "stripe", + "stripe_customers" + ], + "source_name": "stripe", + "source_description": "", + "loader": "", + "identifier": "customers", + "quoting": { + "database": null, + "schema": null, + "identifier": null, + "column": null + }, + "loaded_at_field": null, + "freshness": { + "warn_after": { + "count": null, + "period": null + }, + "error_after": { + "count": null, + "period": null + }, + "filter": null + }, + "external": null, + "description": "", + "columns": {}, + "meta": {}, + "source_meta": {}, + "tags": [], + "config": { + "enabled": true + }, + "patch_path": null, + "unrendered_config": {}, + "relation_name": "analytics.public.customers", + "created_at": 1705035110.488571 + } + }, + "macros": { + "macro.dbt_snowflake.snowflake__get_catalog": { + "name": "snowflake__get_catalog", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/catalog.sql", + "original_file_path": "macros/catalog.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_catalog", + "macro_sql": "{% macro snowflake__get_catalog(information_schema, schemas) -%}\n\n {% set query %}\n with tables as (\n {{ snowflake__get_catalog_tables_sql(information_schema) }}\n {{ snowflake__get_catalog_schemas_where_clause_sql(schemas) }}\n ),\n columns as (\n {{ snowflake__get_catalog_columns_sql(information_schema) }}\n {{ snowflake__get_catalog_schemas_where_clause_sql(schemas) }}\n )\n {{ snowflake__get_catalog_results_sql() }}\n {%- endset -%}\n\n {{ return(run_query(query)) }}\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_catalog_tables_sql", + "macro.dbt_snowflake.snowflake__get_catalog_schemas_where_clause_sql", + "macro.dbt_snowflake.snowflake__get_catalog_columns_sql", + "macro.dbt_snowflake.snowflake__get_catalog_results_sql", + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3032582, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_catalog_relations": { + "name": "snowflake__get_catalog_relations", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/catalog.sql", + "original_file_path": "macros/catalog.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_relations", + "macro_sql": "{% macro snowflake__get_catalog_relations(information_schema, relations) -%}\n\n {% set query %}\n with tables as (\n {{ snowflake__get_catalog_tables_sql(information_schema) }}\n {{ snowflake__get_catalog_relations_where_clause_sql(relations) }}\n ),\n columns as (\n {{ snowflake__get_catalog_columns_sql(information_schema) }}\n {{ snowflake__get_catalog_relations_where_clause_sql(relations) }}\n )\n {{ snowflake__get_catalog_results_sql() }}\n {%- endset -%}\n\n {{ return(run_query(query)) }}\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_catalog_tables_sql", + "macro.dbt_snowflake.snowflake__get_catalog_relations_where_clause_sql", + "macro.dbt_snowflake.snowflake__get_catalog_columns_sql", + "macro.dbt_snowflake.snowflake__get_catalog_results_sql", + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.303662, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_catalog_tables_sql": { + "name": "snowflake__get_catalog_tables_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/catalog.sql", + "original_file_path": "macros/catalog.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_tables_sql", + "macro_sql": "{% macro snowflake__get_catalog_tables_sql(information_schema) -%}\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n coalesce(table_type, 'DYNAMIC TABLE') as \"table_type\",\n comment as \"table_comment\",\n\n -- note: this is the _role_ that owns the table\n table_owner as \"table_owner\",\n\n 'Clustering Key' as \"stats:clustering_key:label\",\n clustering_key as \"stats:clustering_key:value\",\n 'The key used to cluster this table' as \"stats:clustering_key:description\",\n (clustering_key is not null) as \"stats:clustering_key:include\",\n\n 'Row Count' as \"stats:row_count:label\",\n row_count as \"stats:row_count:value\",\n 'An approximate count of rows in this table' as \"stats:row_count:description\",\n (row_count is not null) as \"stats:row_count:include\",\n\n 'Approximate Size' as \"stats:bytes:label\",\n bytes as \"stats:bytes:value\",\n 'Approximate size of the table as reported by Snowflake' as \"stats:bytes:description\",\n (bytes is not null) as \"stats:bytes:include\",\n\n 'Last Modified' as \"stats:last_modified:label\",\n to_varchar(convert_timezone('UTC', last_altered), 'yyyy-mm-dd HH24:MI'||'UTC') as \"stats:last_modified:value\",\n 'The timestamp for last update/change' as \"stats:last_modified:description\",\n (last_altered is not null and table_type='BASE TABLE') as \"stats:last_modified:include\"\n from {{ information_schema }}.tables\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.303862, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_catalog_columns_sql": { + "name": "snowflake__get_catalog_columns_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/catalog.sql", + "original_file_path": "macros/catalog.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_columns_sql", + "macro_sql": "{% macro snowflake__get_catalog_columns_sql(information_schema) -%}\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n\n column_name as \"column_name\",\n ordinal_position as \"column_index\",\n data_type as \"column_type\",\n comment as \"column_comment\"\n from {{ information_schema }}.columns\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3039849, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_catalog_results_sql": { + "name": "snowflake__get_catalog_results_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/catalog.sql", + "original_file_path": "macros/catalog.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_results_sql", + "macro_sql": "{% macro snowflake__get_catalog_results_sql() -%}\n select *\n from tables\n join columns using (\"table_database\", \"table_schema\", \"table_name\")\n order by \"column_index\"\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3040671, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_catalog_schemas_where_clause_sql": { + "name": "snowflake__get_catalog_schemas_where_clause_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/catalog.sql", + "original_file_path": "macros/catalog.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_schemas_where_clause_sql", + "macro_sql": "{% macro snowflake__get_catalog_schemas_where_clause_sql(schemas) -%}\n where ({%- for schema in schemas -%}\n upper(\"table_schema\") = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%}\n {%- endfor -%})\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.304308, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_catalog_relations_where_clause_sql": { + "name": "snowflake__get_catalog_relations_where_clause_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/catalog.sql", + "original_file_path": "macros/catalog.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_catalog_relations_where_clause_sql", + "macro_sql": "{% macro snowflake__get_catalog_relations_where_clause_sql(relations) -%}\n where (\n {%- for relation in relations -%}\n {% if relation.schema and relation.identifier %}\n (\n upper(\"table_schema\") = upper('{{ relation.schema }}')\n and upper(\"table_name\") = upper('{{ relation.identifier }}')\n )\n {% elif relation.schema %}\n (\n upper(\"table_schema\") = upper('{{ relation.schema }}')\n )\n {% else %}\n {% do exceptions.raise_compiler_error(\n '`get_catalog_relations` requires a list of relations, each with a schema'\n ) %}\n {% endif %}\n\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.305162, + "supported_languages": null + }, + "macro.dbt_snowflake.get_column_comment_sql": { + "name": "get_column_comment_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.get_column_comment_sql", + "macro_sql": "{% macro get_column_comment_sql(column_name, column_dict) -%}\n {% if (column_name|upper in column_dict) -%}\n {% set matched_column = column_name|upper -%}\n {% elif (column_name|lower in column_dict) -%}\n {% set matched_column = column_name|lower -%}\n {% elif (column_name in column_dict) -%}\n {% set matched_column = column_name -%}\n {% else -%}\n {% set matched_column = None -%}\n {% endif -%}\n {% if matched_column -%}\n {{ adapter.quote(column_name) }} COMMENT $${{ column_dict[matched_column]['description'] | replace('$', '[$]') }}$$\n {%- else -%}\n {{ adapter.quote(column_name) }} COMMENT $$$$\n {%- endif -%}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3158379, + "supported_languages": null + }, + "macro.dbt_snowflake.get_persist_docs_column_list": { + "name": "get_persist_docs_column_list", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.get_persist_docs_column_list", + "macro_sql": "{% macro get_persist_docs_column_list(model_columns, query_columns) %}\n(\n {% for column_name in query_columns %}\n {{ get_column_comment_sql(column_name, model_columns) }}\n {{- \", \" if not loop.last else \"\" }}\n {% endfor %}\n)\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.get_column_comment_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.316128, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_columns_in_relation": { + "name": "snowflake__get_columns_in_relation", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_columns_in_relation", + "macro_sql": "{% macro snowflake__get_columns_in_relation(relation) -%}\n {%- set sql -%}\n describe table {{ relation }}\n {%- endset -%}\n {%- set result = run_query(sql) -%}\n\n {% set maximum = 10000 %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many columns in relation {{ relation }}! dbt can only get\n information about relations with fewer than {{ maximum }} columns.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n\n {% set columns = [] %}\n {% for row in result %}\n {% do columns.append(api.Column.from_description(row['name'], row['type'])) %}\n {% endfor %}\n {% do return(columns) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.31692, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__list_schemas": { + "name": "snowflake__list_schemas", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.snowflake__list_schemas", + "macro_sql": "{% macro snowflake__list_schemas(database) -%}\n {# 10k limit from here: https://docs.snowflake.net/manuals/sql-reference/sql/show-schemas.html#usage-notes #}\n {% set maximum = 10000 %}\n {% set sql -%}\n show terse schemas in database {{ database }}\n limit {{ maximum }}\n {%- endset %}\n {% set result = run_query(sql) %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many schemas in database {{ database }}! dbt can only get\n information about databases with fewer than {{ maximum }} schemas.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n {{ return(result) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.317562, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_paginated_relations_array": { + "name": "snowflake__get_paginated_relations_array", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_paginated_relations_array", + "macro_sql": "{% macro snowflake__get_paginated_relations_array(max_iter, max_results_per_iter, max_total_results, schema_relation, watermark) %}\n\n {% set paginated_relations = [] %}\n\n {% for _ in range(0, max_iter) %}\n\n {%- set paginated_sql -%}\n show terse objects in {{ schema_relation }} limit {{ max_results_per_iter }} from '{{ watermark.table_name }}'\n {%- endset -%}\n\n {%- set paginated_result = run_query(paginated_sql) %}\n {%- set paginated_n = (paginated_result | length) -%}\n\n {#\n terminating condition: if there are 0 records in the result we reached\n the end exactly on the previous iteration\n #}\n {%- if paginated_n == 0 -%}\n {%- break -%}\n {%- endif -%}\n\n {#\n terminating condition: At some point the user needs to be reasonable with how\n many objects are contained in their schemas. Since there was already\n one iteration before attempting pagination, loop.index == max_iter means\n the limit has been surpassed.\n #}\n\n {%- if loop.index == max_iter -%}\n {%- set msg -%}\n dbt will list a maximum of {{ max_total_results }} objects in schema {{ schema_relation }}.\n Your schema exceeds this limit. Please contact support@getdbt.com for troubleshooting tips,\n or review and reduce the number of objects contained.\n {%- endset -%}\n\n {% do exceptions.raise_compiler_error(msg) %}\n {%- endif -%}\n\n {%- do paginated_relations.append(paginated_result) -%}\n {% set watermark.table_name = paginated_result.columns[1].values()[-1] %}\n\n {#\n terminating condition: paginated_n < max_results_per_iter means we reached the end\n #}\n {%- if paginated_n < max_results_per_iter -%}\n {%- break -%}\n {%- endif -%}\n {%- endfor -%}\n\n {{ return(paginated_relations) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.31861, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__list_relations_without_caching": { + "name": "snowflake__list_relations_without_caching", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.snowflake__list_relations_without_caching", + "macro_sql": "{% macro snowflake__list_relations_without_caching(schema_relation, max_iter=10, max_results_per_iter=10000) %}\n\n {%- set max_total_results = max_results_per_iter * max_iter -%}\n\n {%- set sql -%}\n show terse objects in {{ schema_relation }} limit {{ max_results_per_iter }}\n {%- endset -%}\n\n {%- set result = run_query(sql) -%}\n\n {%- set n = (result | length) -%}\n {%- set watermark = namespace(table_name=result.columns[1].values()[-1]) -%}\n {%- set paginated = namespace(result=[]) -%}\n\n {% if n >= max_results_per_iter %}\n\n {% set paginated.result = snowflake__get_paginated_relations_array(\n max_iter,\n max_results_per_iter,\n max_total_results,\n schema_relation,\n watermark\n )\n %}\n\n {% endif %}\n\n {%- set all_results_array = [result] + paginated.result -%}\n {%- set result = result.merge(all_results_array) -%}\n {%- do return(result) -%}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query", + "macro.dbt_snowflake.snowflake__get_paginated_relations_array" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.319524, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__check_schema_exists": { + "name": "snowflake__check_schema_exists", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.snowflake__check_schema_exists", + "macro_sql": "{% macro snowflake__check_schema_exists(information_schema, schema) -%}\n {% call statement('check_schema_exists', fetch_result=True) -%}\n select count(*)\n from {{ information_schema }}.schemata\n where upper(schema_name) = upper('{{ schema }}')\n and upper(catalog_name) = upper('{{ information_schema.database }}')\n {%- endcall %}\n {{ return(load_result('check_schema_exists').table) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.319851, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__alter_column_type": { + "name": "snowflake__alter_column_type", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.snowflake__alter_column_type", + "macro_sql": "{% macro snowflake__alter_column_type(relation, column_name, new_column_type) -%}\n {% call statement('alter_column_type') %}\n alter table {{ relation }} alter {{ adapter.quote(column_name) }} set data type {{ new_column_type }};\n {% endcall %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3201, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__alter_relation_comment": { + "name": "snowflake__alter_relation_comment", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.snowflake__alter_relation_comment", + "macro_sql": "{% macro snowflake__alter_relation_comment(relation, relation_comment) -%}\n {%- if relation.is_dynamic_table -%}\n {%- set relation_type = 'dynamic table' -%}\n {%- else -%}\n {%- set relation_type = relation.type -%}\n {%- endif -%}\n comment on {{ relation_type }} {{ relation }} IS $${{ relation_comment | replace('$', '[$]') }}$$;\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.320429, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__alter_column_comment": { + "name": "snowflake__alter_column_comment", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.snowflake__alter_column_comment", + "macro_sql": "{% macro snowflake__alter_column_comment(relation, column_dict) -%}\n {% set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute=\"name\") | list %}\n {% if relation.is_dynamic_table -%}\n {% set relation_type = \"table\" %}\n {% else -%}\n {% set relation_type = relation.type %}\n {% endif %}\n alter {{ relation_type }} {{ relation }} alter\n {% for column_name in existing_columns if (column_name in existing_columns) or (column_name|lower in existing_columns) %}\n {{ get_column_comment_sql(column_name, column_dict) }} {{- ',' if not loop.last else ';' }}\n {% endfor %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.get_column_comment_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.321072, + "supported_languages": null + }, + "macro.dbt_snowflake.get_current_query_tag": { + "name": "get_current_query_tag", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.get_current_query_tag", + "macro_sql": "{% macro get_current_query_tag() -%}\n {{ return(run_query(\"show parameters like 'query_tag' in session\").rows[0]['value']) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.321255, + "supported_languages": null + }, + "macro.dbt_snowflake.set_query_tag": { + "name": "set_query_tag", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.set_query_tag", + "macro_sql": "{% macro set_query_tag() -%}\n {{ return(adapter.dispatch('set_query_tag', 'dbt')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__set_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.321416, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__set_query_tag": { + "name": "snowflake__set_query_tag", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.snowflake__set_query_tag", + "macro_sql": "{% macro snowflake__set_query_tag() -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% set original_query_tag = get_current_query_tag() %}\n {{ log(\"Setting query_tag to '\" ~ new_query_tag ~ \"'. Will reset to '\" ~ original_query_tag ~ \"' after materialization.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(new_query_tag)) %}\n {{ return(original_query_tag)}}\n {% endif %}\n {{ return(none)}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.get_current_query_tag", + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.321886, + "supported_languages": null + }, + "macro.dbt_snowflake.unset_query_tag": { + "name": "unset_query_tag", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.unset_query_tag", + "macro_sql": "{% macro unset_query_tag(original_query_tag) -%}\n {{ return(adapter.dispatch('unset_query_tag', 'dbt')(original_query_tag)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__unset_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.322067, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__unset_query_tag": { + "name": "snowflake__unset_query_tag", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.snowflake__unset_query_tag", + "macro_sql": "{% macro snowflake__unset_query_tag(original_query_tag) -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% if original_query_tag %}\n {{ log(\"Resetting query_tag to '\" ~ original_query_tag ~ \"'.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(original_query_tag)) %}\n {% else %}\n {{ log(\"No original query_tag, unsetting parameter.\") }}\n {% do run_query(\"alter session unset query_tag\") %}\n {% endif %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3225422, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns": { + "name": "snowflake__alter_relation_add_remove_columns", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns", + "macro_sql": "{% macro snowflake__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if relation.is_dynamic_table -%}\n {% set relation_type = \"dynamic table\" %}\n {% else -%}\n {% set relation_type = relation.type %}\n {% endif %}\n\n {% if add_columns %}\n\n {% set sql -%}\n alter {{ relation_type }} {{ relation }} add column\n {% for column in add_columns %}\n {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n {% endif %}\n\n {% if remove_columns %}\n\n {% set sql -%}\n alter {{ relation_type }} {{ relation }} drop column\n {% for column in remove_columns %}\n {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n {% endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.323408, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake_dml_explicit_transaction": { + "name": "snowflake_dml_explicit_transaction", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.snowflake_dml_explicit_transaction", + "macro_sql": "{% macro snowflake_dml_explicit_transaction(dml) %}\n {#\n Use this macro to wrap all INSERT, MERGE, UPDATE, DELETE, and TRUNCATE\n statements before passing them into run_query(), or calling in the 'main' statement\n of a materialization\n #}\n {% set dml_transaction -%}\n begin;\n {{ dml }};\n commit;\n {%- endset %}\n\n {% do return(dml_transaction) %}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.323627, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__truncate_relation": { + "name": "snowflake__truncate_relation", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/adapters.sql", + "original_file_path": "macros/adapters.sql", + "unique_id": "macro.dbt_snowflake.snowflake__truncate_relation", + "macro_sql": "{% macro snowflake__truncate_relation(relation) -%}\n {% set truncate_dml %}\n truncate table {{ relation }}\n {% endset %}\n {% call statement('truncate_relation') -%}\n {{ snowflake_dml_explicit_transaction(truncate_dml) }}\n {%- endcall %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.dbt_snowflake.snowflake_dml_explicit_transaction" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.323869, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__copy_grants": { + "name": "snowflake__copy_grants", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/apply_grants.sql", + "original_file_path": "macros/apply_grants.sql", + "unique_id": "macro.dbt_snowflake.snowflake__copy_grants", + "macro_sql": "{% macro snowflake__copy_grants() %}\n {% set copy_grants = config.get('copy_grants', False) %}\n {{ return(copy_grants) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3241541, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement": { + "name": "snowflake__support_multiple_grantees_per_dcl_statement", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/apply_grants.sql", + "original_file_path": "macros/apply_grants.sql", + "unique_id": "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement", + "macro_sql": "\n\n{%- macro snowflake__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(False) }}\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.324267, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_relation_last_modified": { + "name": "snowflake__get_relation_last_modified", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/metadata.sql", + "original_file_path": "macros/metadata.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_relation_last_modified", + "macro_sql": "{% macro snowflake__get_relation_last_modified(information_schema, relations) -%}\n\n {%- call statement('last_modified', fetch_result=True) -%}\n select table_schema as schema,\n table_name as identifier,\n last_altered as last_modified,\n {{ current_timestamp() }} as snapshotted_at\n from {{ information_schema }}.tables\n where (\n {%- for relation in relations -%}\n (upper(table_schema) = upper('{{ relation.schema }}') and\n upper(table_name) = upper('{{ relation.identifier }}')){%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n {%- endcall -%}\n\n {{ return(load_result('last_modified')) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.dbt.current_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.324942, + "supported_languages": null + }, + "macro.dbt_snowflake.materialization_test_snowflake": { + "name": "materialization_test_snowflake", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/test.sql", + "original_file_path": "macros/materializations/test.sql", + "unique_id": "macro.dbt_snowflake.materialization_test_snowflake", + "macro_sql": "{%- materialization test, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set relations = materialization_test_default() %}\n {% do unset_query_tag(original_query_tag) %}\n {{ return(relations) }}\n\n{%- endmaterialization -%}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.set_query_tag", + "macro.elementary.materialization_test_default", + "macro.dbt_snowflake.unset_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.325289, + "supported_languages": [ + "sql" + ] + }, + "macro.dbt_snowflake.snowflake__get_merge_sql": { + "name": "snowflake__get_merge_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/merge.sql", + "original_file_path": "macros/materializations/merge.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_merge_sql", + "macro_sql": "{% macro snowflake__get_merge_sql(target, source_sql, unique_key, dest_columns, incremental_predicates) -%}\n\n {#\n Workaround for Snowflake not being happy with a merge on a constant-false predicate.\n When no unique_key is provided, this macro will do a regular insert. If a unique_key\n is provided, then this macro will do a proper merge instead.\n #}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute='name')) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {%- set dml -%}\n {%- if unique_key is none -%}\n\n {{ sql_header if sql_header is not none }}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source_sql }}\n )\n\n {%- else -%}\n\n {{ default__get_merge_sql(target, source_sql, unique_key, dest_columns, incremental_predicates) }}\n\n {%- endif -%}\n {%- endset -%}\n\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_quoted_csv", + "macro.dbt.default__get_merge_sql", + "macro.dbt_snowflake.snowflake_dml_explicit_transaction" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.326667, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql": { + "name": "snowflake__get_delete_insert_merge_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/merge.sql", + "original_file_path": "macros/materializations/merge.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql", + "macro_sql": "{% macro snowflake__get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) %}\n {% set dml = default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_delete_insert_merge_sql", + "macro.dbt_snowflake.snowflake_dml_explicit_transaction" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3270478, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__snapshot_merge_sql": { + "name": "snowflake__snapshot_merge_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/merge.sql", + "original_file_path": "macros/materializations/merge.sql", + "unique_id": "macro.dbt_snowflake.snowflake__snapshot_merge_sql", + "macro_sql": "{% macro snowflake__snapshot_merge_sql(target, source, insert_cols) %}\n {% set dml = default__snapshot_merge_sql(target, source, insert_cols) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__snapshot_merge_sql", + "macro.dbt_snowflake.snowflake_dml_explicit_transaction" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3272982, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_incremental_append_sql": { + "name": "snowflake__get_incremental_append_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/merge.sql", + "original_file_path": "macros/materializations/merge.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_incremental_append_sql", + "macro_sql": "{% macro snowflake__get_incremental_append_sql(get_incremental_append_sql) %}\n {% set dml = default__get_incremental_append_sql(get_incremental_append_sql) %}\n {% do return(snowflake_dml_explicit_transaction(dml)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_incremental_append_sql", + "macro.dbt_snowflake.snowflake_dml_explicit_transaction" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3275032, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__load_csv_rows": { + "name": "snowflake__load_csv_rows", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/seed.sql", + "original_file_path": "macros/materializations/seed.sql", + "unique_id": "macro.dbt_snowflake.snowflake__load_csv_rows", + "macro_sql": "{% macro snowflake__load_csv_rows(model, agate_table) %}\n {% set batch_size = get_batch_size() %}\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n %s\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query('BEGIN', auto_begin=False) %}\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n {% do adapter.add_query('COMMIT', auto_begin=False) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_batch_size", + "macro.dbt.get_seed_column_quoted_csv" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.329648, + "supported_languages": null + }, + "macro.dbt_snowflake.materialization_seed_snowflake": { + "name": "materialization_seed_snowflake", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/seed.sql", + "original_file_path": "macros/materializations/seed.sql", + "unique_id": "macro.dbt_snowflake.materialization_seed_snowflake", + "macro_sql": "{% materialization seed, adapter='snowflake' %}\n {% set original_query_tag = set_query_tag() %}\n\n {% set relations = materialization_seed_default() %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return(relations) }}\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.set_query_tag", + "macro.dbt.materialization_seed_default", + "macro.dbt_snowflake.unset_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.329943, + "supported_languages": [ + "sql" + ] + }, + "macro.dbt_snowflake.materialization_view_snowflake": { + "name": "materialization_view_snowflake", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/view.sql", + "original_file_path": "macros/materializations/view.sql", + "unique_id": "macro.dbt_snowflake.materialization_view_snowflake", + "macro_sql": "{% materialization view, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set to_return = snowflake__create_or_replace_view() %}\n\n {% set target_relation = this.incorporate(type='view') %}\n\n {% do persist_docs(target_relation, model, for_columns=false) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {% do return(to_return) %}\n\n{%- endmaterialization %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.set_query_tag", + "macro.dbt_snowflake.snowflake__create_or_replace_view", + "macro.dbt.persist_docs", + "macro.dbt_snowflake.unset_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.330504, + "supported_languages": [ + "sql" + ] + }, + "macro.dbt_snowflake.materialization_table_snowflake": { + "name": "materialization_table_snowflake", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/table.sql", + "original_file_path": "macros/materializations/table.sql", + "unique_id": "macro.dbt_snowflake.materialization_table_snowflake", + "macro_sql": "{% materialization table, adapter='snowflake', supported_languages=['sql', 'python']%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {%- set identifier = model['alias'] -%}\n {%- set language = model['language'] -%}\n\n {% set grant_config = config.get('grants') %}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set target_relation = api.Relation.create(identifier=identifier,\n schema=schema,\n database=database, type='table') -%}\n\n {{ run_hooks(pre_hooks) }}\n\n {#-- Drop the relation if it was a view to \"convert\" it in a table. This may lead to\n -- downtime, but it should be a relatively infrequent occurrence #}\n {% if old_relation is not none and not old_relation.is_table %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ drop_relation_if_exists(old_relation) }}\n {% endif %}\n\n {% call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall %}\n\n {{ run_hooks(post_hooks) }}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.set_query_tag", + "macro.dbt.run_hooks", + "macro.dbt.drop_relation_if_exists", + "macro.dbt.statement", + "macro.dbt.create_table_as", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs", + "macro.dbt_snowflake.unset_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.332719, + "supported_languages": [ + "sql", + "python" + ] + }, + "macro.dbt_snowflake.py_write_table": { + "name": "py_write_table", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/table.sql", + "original_file_path": "macros/materializations/table.sql", + "unique_id": "macro.dbt_snowflake.py_write_table", + "macro_sql": "{% macro py_write_table(compiled_code, target_relation, temporary=False, table_type=none) %}\n{#- The following logic is only for backwards-compatiblity with deprecated `temporary` parameter -#}\n{% if table_type is not none %}\n {#- Just use the table_type as-is -#}\n{% elif temporary -%}\n {#- Case 1 when the deprecated `temporary` parameter is used without the replacement `table_type` parameter -#}\n {%- set table_type = \"temporary\" -%}\n{% else %}\n {#- Case 2 when the deprecated `temporary` parameter is used without the replacement `table_type` parameter -#}\n {#- Snowflake treats \"\" as meaning \"permanent\" -#}\n {%- set table_type = \"\" -%}\n{%- endif %}\n{{ compiled_code }}\ndef materialize(session, df, target_relation):\n # make sure pandas exists\n import importlib.util\n package_name = 'pandas'\n if importlib.util.find_spec(package_name):\n import pandas\n if isinstance(df, pandas.core.frame.DataFrame):\n session.use_database(target_relation.database)\n session.use_schema(target_relation.schema)\n # session.write_pandas does not have overwrite function\n df = session.createDataFrame(df)\n {% set target_relation_name = resolve_model_name(target_relation) %}\n df.write.mode(\"overwrite\").save_as_table('{{ target_relation_name }}', table_type='{{table_type}}')\n\ndef main(session):\n dbt = dbtObj(session.table)\n df = model(dbt, session)\n materialize(session, df, dbt.this)\n return \"OK\"\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.resolve_model_name" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.333212, + "supported_languages": null + }, + "macro.dbt_snowflake.py_script_comment": { + "name": "py_script_comment", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/table.sql", + "original_file_path": "macros/materializations/table.sql", + "unique_id": "macro.dbt_snowflake.py_script_comment", + "macro_sql": "{% macro py_script_comment()%}\n# To run this in snowsight, you need to select entry point to be main\n# And you may have to modify the return type to text to get the result back\n# def main(session):\n# dbt = dbtObj(session.table)\n# df = model(dbt, session)\n# return df.collect()\n\n# to run this in local notebook, you need to create a session following examples https://github.com/Snowflake-Labs/sfguide-getting-started-snowpark-python\n# then you can do the following to run model\n# dbt = dbtObj(session.table)\n# df = model(dbt, session)\n{%endmacro%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.333316, + "supported_languages": null + }, + "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type": { + "name": "dbt_snowflake_get_tmp_relation_type", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/incremental.sql", + "original_file_path": "macros/materializations/incremental.sql", + "unique_id": "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type", + "macro_sql": "{% macro dbt_snowflake_get_tmp_relation_type(strategy, unique_key, language) %}\n{%- set tmp_relation_type = config.get('tmp_relation_type') -%}\n /* {#\n High-level principles:\n If we are running multiple statements (DELETE + INSERT),\n and we want to guarantee identical inputs to both statements,\n then we must first save the model query results as a temporary table\n (which presumably comes with a performance cost).\n If we are running a single statement (MERGE or INSERT alone),\n we _may_ save the model query definition as a view instead,\n for (presumably) faster overall incremental processing.\n\n Low-level specifics:\n If an invalid option is specified, then we will raise an\n excpetion with corresponding message.\n\n Languages other than SQL (like Python) will use a temporary table.\n With the default strategy of merge, the user may choose between a temporary\n table and view (defaulting to view).\n\n The append strategy can use a view because it will run a single INSERT statement.\n\n When unique_key is none, the delete+insert strategy can use a view beacuse a\n single INSERT statement is run with no DELETES as part of the statement.\n Otherwise, play it safe by using a temporary table.\n #} */\n\n {% if language == \"python\" and tmp_relation_type is not none %}\n {% do exceptions.raise_compiler_error(\n \"Python models currently only support 'table' for tmp_relation_type but \"\n ~ tmp_relation_type ~ \" was specified.\"\n ) %}\n {% endif %}\n\n {% if strategy == \"delete+insert\" and tmp_relation_type is not none and tmp_relation_type != \"table\" and unique_key is not none %}\n {% do exceptions.raise_compiler_error(\n \"In order to maintain consistent results when `unique_key` is not none,\n the `delete+insert` strategy only supports `table` for `tmp_relation_type` but \"\n ~ tmp_relation_type ~ \" was specified.\"\n )\n %}\n {% endif %}\n\n {% if language != \"sql\" %}\n {{ return(\"table\") }}\n {% elif tmp_relation_type == \"table\" %}\n {{ return(\"table\") }}\n {% elif tmp_relation_type == \"view\" %}\n {{ return(\"view\") }}\n {% elif strategy in (\"default\", \"merge\", \"append\") %}\n {{ return(\"view\") }}\n {% elif strategy == \"delete+insert\" and unique_key is none %}\n {{ return(\"view\") }}\n {% else %}\n {{ return(\"table\") }}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.335839, + "supported_languages": null + }, + "macro.dbt_snowflake.materialization_incremental_snowflake": { + "name": "materialization_incremental_snowflake", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/incremental.sql", + "original_file_path": "macros/materializations/incremental.sql", + "unique_id": "macro.dbt_snowflake.materialization_incremental_snowflake", + "macro_sql": "{% materialization incremental, adapter='snowflake', supported_languages=['sql', 'python'] -%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {#-- Set vars --#}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n {%- set language = model['language'] -%}\n {% set target_relation = this %}\n {% set existing_relation = load_relation(this) %}\n\n {#-- The temp relation will be a view (faster) or temp table, depending on upsert/merge strategy --#}\n {%- set unique_key = config.get('unique_key') -%}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set tmp_relation_type = dbt_snowflake_get_tmp_relation_type(incremental_strategy, unique_key, language) %}\n {% set tmp_relation = make_temp_relation(this).incorporate(type=tmp_relation_type) %}\n\n {% set grant_config = config.get('grants') %}\n\n {% set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') %}\n\n {{ run_hooks(pre_hooks) }}\n\n {% if existing_relation is none %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n\n {% elif existing_relation.is_view %}\n {#-- Can't overwrite a view with a table - we must drop --#}\n {{ log(\"Dropping relation \" ~ target_relation ~ \" because it is a view and this model is a table.\") }}\n {% do adapter.drop_relation(existing_relation) %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n {% elif full_refresh_mode %}\n {%- call statement('main', language=language) -%}\n {{ create_table_as(False, target_relation, compiled_code, language) }}\n {%- endcall -%}\n\n {% else %}\n {#-- Create the temp relation, either as a view or as a temp table --#}\n {% if tmp_relation_type == 'view' %}\n {%- call statement('create_tmp_relation') -%}\n {{ snowflake__create_view_as_with_temp_flag(tmp_relation, compiled_code, True) }}\n {%- endcall -%}\n {% else %}\n {%- call statement('create_tmp_relation', language=language) -%}\n {{ create_table_as(True, tmp_relation, compiled_code, language) }}\n {%- endcall -%}\n {% endif %}\n\n {% do adapter.expand_target_column_types(\n from_relation=tmp_relation,\n to_relation=target_relation) %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, tmp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': tmp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'incremental_predicates': incremental_predicates }) %}\n\n {%- call statement('main') -%}\n {{ strategy_sql_macro_func(strategy_arg_dict) }}\n {%- endcall -%}\n {% endif %}\n\n {% do drop_relation_if_exists(tmp_relation) %}\n\n {{ run_hooks(post_hooks) }}\n\n {% set target_relation = target_relation.incorporate(type='table') %}\n\n {% set should_revoke =\n should_revoke(existing_relation.is_table, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.set_query_tag", + "macro.dbt.should_full_refresh", + "macro.dbt.load_relation", + "macro.dbt_snowflake.dbt_snowflake_get_tmp_relation_type", + "macro.dbt.make_temp_relation", + "macro.dbt.incremental_validate_on_schema_change", + "macro.dbt.run_hooks", + "macro.dbt.statement", + "macro.dbt.create_table_as", + "macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag", + "macro.dbt.process_schema_changes", + "macro.dbt.drop_relation_if_exists", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs", + "macro.dbt_snowflake.unset_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.339092, + "supported_languages": [ + "sql", + "python" + ] + }, + "macro.dbt_snowflake.snowflake__get_incremental_default_sql": { + "name": "snowflake__get_incremental_default_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/incremental.sql", + "original_file_path": "macros/materializations/incremental.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_incremental_default_sql", + "macro_sql": "{% macro snowflake__get_incremental_default_sql(arg_dict) %}\n {{ return(get_incremental_merge_sql(arg_dict)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_incremental_merge_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3392582, + "supported_languages": null + }, + "macro.dbt_snowflake.materialization_snapshot_snowflake": { + "name": "materialization_snapshot_snowflake", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/snapshot.sql", + "original_file_path": "macros/materializations/snapshot.sql", + "unique_id": "macro.dbt_snowflake.materialization_snapshot_snowflake", + "macro_sql": "{% materialization snapshot, adapter='snowflake' %}\n {% set original_query_tag = set_query_tag() %}\n {% set relations = materialization_snapshot_default() %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return(relations) }}\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.set_query_tag", + "macro.dbt.materialization_snapshot_default", + "macro.dbt_snowflake.unset_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.339606, + "supported_languages": [ + "sql" + ] + }, + "macro.dbt_snowflake.materialization_dynamic_table_snowflake": { + "name": "materialization_dynamic_table_snowflake", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/dynamic_table.sql", + "original_file_path": "macros/materializations/dynamic_table.sql", + "unique_id": "macro.dbt_snowflake.materialization_dynamic_table_snowflake", + "macro_sql": "{% materialization dynamic_table, adapter='snowflake' %}\n\n {% set query_tag = set_query_tag() %}\n\n {% set existing_relation = load_cached_relation(this) %}\n {% set target_relation = this.incorporate(type=this.DynamicTable) %}\n\n {{ run_hooks(pre_hooks) }}\n\n {% set build_sql = dynamic_table_get_build_sql(existing_relation, target_relation) %}\n\n {% if build_sql == '' %}\n {{ dynamic_table_execute_no_op(target_relation) }}\n {% else %}\n {{ dynamic_table_execute_build_sql(build_sql, existing_relation, target_relation) }}\n {% endif %}\n\n {{ run_hooks(post_hooks) }}\n\n {% do unset_query_tag(query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.set_query_tag", + "macro.dbt.load_cached_relation", + "macro.dbt.run_hooks", + "macro.dbt_snowflake.dynamic_table_get_build_sql", + "macro.dbt_snowflake.dynamic_table_execute_no_op", + "macro.dbt_snowflake.dynamic_table_execute_build_sql", + "macro.dbt_snowflake.unset_query_tag" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.343224, + "supported_languages": [ + "sql" + ] + }, + "macro.dbt_snowflake.dynamic_table_get_build_sql": { + "name": "dynamic_table_get_build_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/dynamic_table.sql", + "original_file_path": "macros/materializations/dynamic_table.sql", + "unique_id": "macro.dbt_snowflake.dynamic_table_get_build_sql", + "macro_sql": "{% macro dynamic_table_get_build_sql(existing_relation, target_relation) %}\n\n {% set full_refresh_mode = should_full_refresh() %}\n\n -- determine the scenario we're in: create, full_refresh, alter, refresh data\n {% if existing_relation is none %}\n {% set build_sql = get_create_sql(target_relation, sql) %}\n {% elif full_refresh_mode or not existing_relation.is_dynamic_table %}\n {% set build_sql = get_replace_sql(existing_relation, target_relation, sql) %}\n {% else %}\n\n -- get config options\n {% set on_configuration_change = config.get('on_configuration_change') %}\n {% set configuration_changes = snowflake__get_dynamic_table_configuration_changes(existing_relation, config) %}\n\n {% if configuration_changes is none %}\n {% set build_sql = '' %}\n {{ exceptions.warn(\"No configuration changes were identified on: `\" ~ target_relation ~ \"`. Continuing.\") }}\n\n {% elif on_configuration_change == 'apply' %}\n {% set build_sql = snowflake__get_alter_dynamic_table_as_sql(existing_relation, configuration_changes, target_relation, sql) %}\n {% elif on_configuration_change == 'continue' %}\n {% set build_sql = '' %}\n {{ exceptions.warn(\"Configuration changes were identified and `on_configuration_change` was set to `continue` for `\" ~ target_relation ~ \"`\") }}\n {% elif on_configuration_change == 'fail' %}\n {{ exceptions.raise_fail_fast_error(\"Configuration changes were identified and `on_configuration_change` was set to `fail` for `\" ~ target_relation ~ \"`\") }}\n\n {% else %}\n -- this only happens if the user provides a value other than `apply`, 'continue', 'fail'\n {{ exceptions.raise_compiler_error(\"Unexpected configuration scenario: `\" ~ on_configuration_change ~ \"`\") }}\n\n {% endif %}\n\n {% endif %}\n\n {% do return(build_sql) %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.should_full_refresh", + "macro.dbt.get_create_sql", + "macro.dbt.get_replace_sql", + "macro.dbt_snowflake.snowflake__get_dynamic_table_configuration_changes", + "macro.dbt_snowflake.snowflake__get_alter_dynamic_table_as_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.344521, + "supported_languages": null + }, + "macro.dbt_snowflake.dynamic_table_execute_no_op": { + "name": "dynamic_table_execute_no_op", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/dynamic_table.sql", + "original_file_path": "macros/materializations/dynamic_table.sql", + "unique_id": "macro.dbt_snowflake.dynamic_table_execute_no_op", + "macro_sql": "{% macro dynamic_table_execute_no_op(relation) %}\n {% do store_raw_result(\n name=\"main\",\n message=\"skip \" ~ relation,\n code=\"skip\",\n rows_affected=\"-1\"\n ) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.344747, + "supported_languages": null + }, + "macro.dbt_snowflake.dynamic_table_execute_build_sql": { + "name": "dynamic_table_execute_build_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/dynamic_table.sql", + "original_file_path": "macros/materializations/dynamic_table.sql", + "unique_id": "macro.dbt_snowflake.dynamic_table_execute_build_sql", + "macro_sql": "{% macro dynamic_table_execute_build_sql(build_sql, existing_relation, target_relation) %}\n\n {% set grant_config = config.get('grants') %}\n\n {% call statement(name=\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.345222, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_dynamic_table_configuration_changes": { + "name": "snowflake__get_dynamic_table_configuration_changes", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/dynamic_table.sql", + "original_file_path": "macros/materializations/dynamic_table.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_dynamic_table_configuration_changes", + "macro_sql": "{% macro snowflake__get_dynamic_table_configuration_changes(existing_relation, new_config) -%}\n {% set _existing_dynamic_table = snowflake__describe_dynamic_table(existing_relation) %}\n {% set _configuration_changes = existing_relation.dynamic_table_config_changeset(_existing_dynamic_table, new_config) %}\n {% do return(_configuration_changes) %}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__describe_dynamic_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.345491, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__can_clone_table": { + "name": "snowflake__can_clone_table", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/clone.sql", + "original_file_path": "macros/materializations/clone.sql", + "unique_id": "macro.dbt_snowflake.snowflake__can_clone_table", + "macro_sql": "{% macro snowflake__can_clone_table() %}\n {{ return(True) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3457348, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__create_or_replace_clone": { + "name": "snowflake__create_or_replace_clone", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/materializations/clone.sql", + "original_file_path": "macros/materializations/clone.sql", + "unique_id": "macro.dbt_snowflake.snowflake__create_or_replace_clone", + "macro_sql": "{% macro snowflake__create_or_replace_clone(this_relation, defer_relation) %}\n create or replace\n {{ \"transient\" if config.get(\"transient\", true) }}\n table {{ this_relation }}\n clone {{ defer_relation }}\n {{ \"copy grants\" if config.get(\"copy_grants\", false) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3460171, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_drop_sql": { + "name": "snowflake__get_drop_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/drop.sql", + "original_file_path": "macros/relations/drop.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_drop_sql", + "macro_sql": "{% macro snowflake__get_drop_sql(relation) %}\n\n {% if relation.is_dynamic_table %}\n {{ snowflake__get_drop_dynamic_table_sql(relation) }}\n\n {% else %}\n {{ default__get_drop_sql(relation) }}\n\n {% endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_drop_dynamic_table_sql", + "macro.dbt.default__get_drop_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.346325, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_replace_sql": { + "name": "snowflake__get_replace_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/replace.sql", + "original_file_path": "macros/relations/replace.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_replace_sql", + "macro_sql": "{% macro snowflake__get_replace_sql(existing_relation, target_relation, sql) %}\n\n {% if existing_relation.is_dynamic_table and target_relation.is_dynamic_table %}\n {{ snowflake__get_replace_dynamic_table_sql(target_relation, sql) }}\n\n {% else %}\n {{ default__get_replace_sql(existing_relation, target_relation, sql) }}\n\n {% endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_replace_dynamic_table_sql", + "macro.dbt.default__get_replace_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3467252, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__rename_relation": { + "name": "snowflake__rename_relation", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/rename.sql", + "original_file_path": "macros/relations/rename.sql", + "unique_id": "macro.dbt_snowflake.snowflake__rename_relation", + "macro_sql": "{% macro snowflake__rename_relation(from_relation, to_relation) -%}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ to_relation }}\n {%- endcall %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.346975, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_create_sql": { + "name": "snowflake__get_create_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/create.sql", + "original_file_path": "macros/relations/create.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_create_sql", + "macro_sql": "{% macro snowflake__get_create_sql(relation, sql) %}\n\n {% if relation.is_dynamic_table %}\n {{ snowflake__get_create_dynamic_table_as_sql(relation, sql) }}\n\n {% else %}\n {{ default__get_create_sql(relation, sql) }}\n\n {% endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_create_dynamic_table_as_sql", + "macro.dbt.default__get_create_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.347314, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_drop_table_sql": { + "name": "snowflake__get_drop_table_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/table/drop.sql", + "original_file_path": "macros/relations/table/drop.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_drop_table_sql", + "macro_sql": "{% macro snowflake__get_drop_table_sql(relation) %}\n drop table if exists {{ relation }} cascade\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.34745, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_replace_table_sql": { + "name": "snowflake__get_replace_table_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/table/replace.sql", + "original_file_path": "macros/relations/table/replace.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_replace_table_sql", + "macro_sql": "{% macro snowflake__get_replace_table_sql(relation, sql) %}\n {{ snowflake__create_table_as(False, relation, sql) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3476381, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_rename_table_sql": { + "name": "snowflake__get_rename_table_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/table/rename.sql", + "original_file_path": "macros/relations/table/rename.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_rename_table_sql", + "macro_sql": "{%- macro snowflake__get_rename_table_sql(relation, new_name) -%}\n alter table {{ relation }} rename to {{ new_name }}\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3478038, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__create_table_as": { + "name": "snowflake__create_table_as", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/table/create.sql", + "original_file_path": "macros/relations/table/create.sql", + "unique_id": "macro.dbt_snowflake.snowflake__create_table_as", + "macro_sql": "{% macro snowflake__create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {%- set transient = config.get('transient', default=true) -%}\n\n {% if temporary -%}\n {%- set table_type = \"temporary\" -%}\n {%- elif transient -%}\n {%- set table_type = \"transient\" -%}\n {%- else -%}\n {%- set table_type = \"\" -%}\n {%- endif %}\n\n {%- if language == 'sql' -%}\n {%- set cluster_by_keys = config.get('cluster_by', default=none) -%}\n {%- set enable_automatic_clustering = config.get('automatic_clustering', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n\n {%- if cluster_by_keys is not none and cluster_by_keys is string -%}\n {%- set cluster_by_keys = [cluster_by_keys] -%}\n {%- endif -%}\n {%- if cluster_by_keys is not none -%}\n {%- set cluster_by_string = cluster_by_keys|join(\", \")-%}\n {% else %}\n {%- set cluster_by_string = none -%}\n {%- endif -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create or replace {{ table_type }} table {{ relation }}\n {%- set contract_config = config.get('contract') -%}\n {%- if contract_config.enforced -%}\n {{ get_assert_columns_equivalent(sql) }}\n {{ get_table_columns_and_constraints() }}\n {% set compiled_code = get_select_subquery(compiled_code) %}\n {% endif %}\n {% if copy_grants and not temporary -%} copy grants {%- endif %} as\n (\n {%- if cluster_by_string is not none -%}\n select * from (\n {{ compiled_code }}\n ) order by ({{ cluster_by_string }})\n {%- else -%}\n {{ compiled_code }}\n {%- endif %}\n );\n {% if cluster_by_string is not none and not temporary -%}\n alter table {{relation}} cluster by ({{cluster_by_string}});\n {%- endif -%}\n {% if enable_automatic_clustering and cluster_by_string is not none and not temporary -%}\n alter table {{relation}} resume recluster;\n {%- endif -%}\n\n {%- elif language == 'python' -%}\n {{ py_write_table(compiled_code=compiled_code, target_relation=relation, table_type=table_type) }}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"snowflake__create_table_as macro didn't get supported language, it got %s\" % language) %}\n {%- endif -%}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_assert_columns_equivalent", + "macro.dbt.get_table_columns_and_constraints", + "macro.dbt.get_select_subquery", + "macro.dbt_snowflake.py_write_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3518012, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_drop_view_sql": { + "name": "snowflake__get_drop_view_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/view/drop.sql", + "original_file_path": "macros/relations/view/drop.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_drop_view_sql", + "macro_sql": "{% macro snowflake__get_drop_view_sql(relation) %}\n drop view if exists {{ relation }} cascade\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.351954, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_replace_view_sql": { + "name": "snowflake__get_replace_view_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/view/replace.sql", + "original_file_path": "macros/relations/view/replace.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_replace_view_sql", + "macro_sql": "{% macro snowflake__get_replace_view_sql(relation, sql) %}\n {{ snowflake__create_view_as(relation, sql) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__create_view_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3521311, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_rename_view_sql": { + "name": "snowflake__get_rename_view_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/view/rename.sql", + "original_file_path": "macros/relations/view/rename.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_rename_view_sql", + "macro_sql": "{%- macro snowflake__get_rename_view_sql(relation, new_name) -%}\n alter view {{ relation }} rename to {{ new_name }}\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.352297, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag": { + "name": "snowflake__create_view_as_with_temp_flag", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/view/create.sql", + "original_file_path": "macros/relations/view/create.sql", + "unique_id": "macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag", + "macro_sql": "{% macro snowflake__create_view_as_with_temp_flag(relation, sql, is_temporary=False) -%}\n {%- set secure = config.get('secure', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create or replace {% if secure -%}\n secure\n {%- endif %} {% if is_temporary -%}\n temporary\n {%- endif %} view {{ relation }}\n {% if config.persist_column_docs() -%}\n {% set model_columns = model.columns %}\n {% set query_columns = get_columns_in_query(sql) %}\n {{ get_persist_docs_column_list(model_columns, query_columns) }}\n\n {%- endif %}\n {%- set contract_config = config.get('contract') -%}\n {%- if contract_config.enforced -%}\n {{ get_assert_columns_equivalent(sql) }}\n {%- endif %}\n {% if copy_grants -%} copy grants {%- endif %} as (\n {{ sql }}\n );\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_columns_in_query", + "macro.dbt_snowflake.get_persist_docs_column_list", + "macro.dbt.get_assert_columns_equivalent" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.354018, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__create_view_as": { + "name": "snowflake__create_view_as", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/view/create.sql", + "original_file_path": "macros/relations/view/create.sql", + "unique_id": "macro.dbt_snowflake.snowflake__create_view_as", + "macro_sql": "{% macro snowflake__create_view_as(relation, sql) -%}\n {{ snowflake__create_view_as_with_temp_flag(relation, sql) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__create_view_as_with_temp_flag" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.354173, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__create_or_replace_view": { + "name": "snowflake__create_or_replace_view", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/view/create.sql", + "original_file_path": "macros/relations/view/create.sql", + "unique_id": "macro.dbt_snowflake.snowflake__create_or_replace_view", + "macro_sql": "{% macro snowflake__create_or_replace_view() %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database,\n type='view') -%}\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks) }}\n\n -- If there's a table with the same name and we weren't told to full refresh,\n -- that's an error. If we were told to full refresh, drop it. This behavior differs\n -- for Snowflake and BigQuery, so multiple dispatch is used.\n {%- if old_relation is not none and not old_relation.is_view -%}\n {{ handle_existing_table(should_full_refresh(), old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n\n {% set should_revoke = should_revoke(exists_as_view, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {{ run_hooks(post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.run_hooks", + "macro.dbt.handle_existing_table", + "macro.dbt.should_full_refresh", + "macro.dbt.statement", + "macro.dbt.get_create_view_as_sql", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.355262, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_drop_dynamic_table_sql": { + "name": "snowflake__get_drop_dynamic_table_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/dynamic_table/drop.sql", + "original_file_path": "macros/relations/dynamic_table/drop.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_drop_dynamic_table_sql", + "macro_sql": "{% macro snowflake__get_drop_dynamic_table_sql(relation) %}\n drop dynamic table if exists {{ relation }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.355407, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_replace_dynamic_table_sql": { + "name": "snowflake__get_replace_dynamic_table_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/dynamic_table/replace.sql", + "original_file_path": "macros/relations/dynamic_table/replace.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_replace_dynamic_table_sql", + "macro_sql": "{% macro snowflake__get_replace_dynamic_table_sql(relation, sql) %}\n\n create or replace dynamic table {{ relation }}\n target_lag = '{{ config.get(\"target_lag\") }}'\n warehouse = {{ config.get(\"snowflake_warehouse\") }}\n as (\n {{ sql }}\n )\n ;\n {{ snowflake__refresh_dynamic_table(relation) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__refresh_dynamic_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.355789, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__describe_dynamic_table": { + "name": "snowflake__describe_dynamic_table", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/dynamic_table/describe.sql", + "original_file_path": "macros/relations/dynamic_table/describe.sql", + "unique_id": "macro.dbt_snowflake.snowflake__describe_dynamic_table", + "macro_sql": "{% macro snowflake__describe_dynamic_table(relation) %}\n {%- set _dynamic_table_sql -%}\n show dynamic tables\n like '{{ relation.identifier }}'\n in schema {{ relation.database }}.{{ relation.schema }}\n ;\n select\n \"name\",\n \"schema_name\",\n \"database_name\",\n \"text\",\n \"target_lag\",\n \"warehouse\"\n from table(result_scan(last_query_id()))\n {%- endset %}\n {% set _dynamic_table = run_query(_dynamic_table_sql) %}\n\n {% do return({'dynamic_table': _dynamic_table}) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.356344, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__refresh_dynamic_table": { + "name": "snowflake__refresh_dynamic_table", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/dynamic_table/refresh.sql", + "original_file_path": "macros/relations/dynamic_table/refresh.sql", + "unique_id": "macro.dbt_snowflake.snowflake__refresh_dynamic_table", + "macro_sql": "{% macro snowflake__refresh_dynamic_table(relation) -%}\n {{- log('Applying REFRESH to: ' ~ relation) -}}\n\n alter dynamic table {{ relation }} refresh\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.356545, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_alter_dynamic_table_as_sql": { + "name": "snowflake__get_alter_dynamic_table_as_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/dynamic_table/alter.sql", + "original_file_path": "macros/relations/dynamic_table/alter.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_alter_dynamic_table_as_sql", + "macro_sql": "{% macro snowflake__get_alter_dynamic_table_as_sql(\n existing_relation,\n configuration_changes,\n target_relation,\n sql\n) -%}\n {{- log('Applying ALTER to: ' ~ existing_relation) -}}\n\n {% if configuration_changes.requires_full_refresh %}\n {{- get_replace_sql(existing_relation, target_relation, sql) -}}\n\n {% else %}\n\n {%- set target_lag = configuration_changes.target_lag -%}\n {%- if target_lag -%}{{- log('Applying UPDATE TARGET_LAG to: ' ~ existing_relation) -}}{%- endif -%}\n {%- set snowflake_warehouse = configuration_changes.snowflake_warehouse -%}\n {%- if snowflake_warehouse -%}{{- log('Applying UPDATE WAREHOUSE to: ' ~ existing_relation) -}}{%- endif -%}\n\n alter dynamic table {{ existing_relation }} set\n {% if target_lag %}target_lag = '{{ target_lag.context }}'{% endif %}\n {% if snowflake_warehouse %}warehouse = {{ snowflake_warehouse.context }}{% endif %}\n\n {%- endif -%}\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_replace_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.357595, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__get_create_dynamic_table_as_sql": { + "name": "snowflake__get_create_dynamic_table_as_sql", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/relations/dynamic_table/create.sql", + "original_file_path": "macros/relations/dynamic_table/create.sql", + "unique_id": "macro.dbt_snowflake.snowflake__get_create_dynamic_table_as_sql", + "macro_sql": "{% macro snowflake__get_create_dynamic_table_as_sql(relation, sql) -%}\n\n create dynamic table {{ relation }}\n target_lag = '{{ config.get(\"target_lag\") }}'\n warehouse = {{ config.get(\"snowflake_warehouse\") }}\n as (\n {{ sql }}\n )\n ;\n\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3579252, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__current_timestamp": { + "name": "snowflake__current_timestamp", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/utils/timestamps.sql", + "original_file_path": "macros/utils/timestamps.sql", + "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp", + "macro_sql": "{% macro snowflake__current_timestamp() -%}\n convert_timezone('UTC', current_timestamp())\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.358212, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__snapshot_string_as_time": { + "name": "snowflake__snapshot_string_as_time", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/utils/timestamps.sql", + "original_file_path": "macros/utils/timestamps.sql", + "unique_id": "macro.dbt_snowflake.snowflake__snapshot_string_as_time", + "macro_sql": "{% macro snowflake__snapshot_string_as_time(timestamp) -%}\n {%- set result = \"to_timestamp_ntz('\" ~ timestamp ~ \"')\" -%}\n {{ return(result) }}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3583858, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__snapshot_get_time": { + "name": "snowflake__snapshot_get_time", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/utils/timestamps.sql", + "original_file_path": "macros/utils/timestamps.sql", + "unique_id": "macro.dbt_snowflake.snowflake__snapshot_get_time", + "macro_sql": "{% macro snowflake__snapshot_get_time() -%}\n to_timestamp_ntz({{ current_timestamp() }})\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.current_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3584871, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__current_timestamp_backcompat": { + "name": "snowflake__current_timestamp_backcompat", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/utils/timestamps.sql", + "original_file_path": "macros/utils/timestamps.sql", + "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp_backcompat", + "macro_sql": "{% macro snowflake__current_timestamp_backcompat() %}\n current_timestamp::{{ type_timestamp() }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.type_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3585868, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat": { + "name": "snowflake__current_timestamp_in_utc_backcompat", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/utils/timestamps.sql", + "original_file_path": "macros/utils/timestamps.sql", + "unique_id": "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat", + "macro_sql": "{% macro snowflake__current_timestamp_in_utc_backcompat() %}\n convert_timezone('UTC', {{ snowflake__current_timestamp_backcompat() }})::{{ type_timestamp() }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__current_timestamp_backcompat", + "macro.dbt.type_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3587132, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__escape_single_quotes": { + "name": "snowflake__escape_single_quotes", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/utils/escape_single_quotes.sql", + "original_file_path": "macros/utils/escape_single_quotes.sql", + "unique_id": "macro.dbt_snowflake.snowflake__escape_single_quotes", + "macro_sql": "{% macro snowflake__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\", \"\\\\'\") }}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.358895, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__right": { + "name": "snowflake__right", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/utils/right.sql", + "original_file_path": "macros/utils/right.sql", + "unique_id": "macro.dbt_snowflake.snowflake__right", + "macro_sql": "{% macro snowflake__right(string_text, length_expression) %}\n\n case when {{ length_expression }} = 0\n then ''\n else\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n end\n\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.359125, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__safe_cast": { + "name": "snowflake__safe_cast", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/utils/safe_cast.sql", + "original_file_path": "macros/utils/safe_cast.sql", + "unique_id": "macro.dbt_snowflake.snowflake__safe_cast", + "macro_sql": "{% macro snowflake__safe_cast(field, type) %}\n try_cast({{field}} as {{type}})\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.359283, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__bool_or": { + "name": "snowflake__bool_or", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/utils/bool_or.sql", + "original_file_path": "macros/utils/bool_or.sql", + "unique_id": "macro.dbt_snowflake.snowflake__bool_or", + "macro_sql": "{% macro snowflake__bool_or(expression) -%}\n\n boolor_agg({{ expression }})\n\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.35954, + "supported_languages": null + }, + "macro.dbt_snowflake.snowflake__array_construct": { + "name": "snowflake__array_construct", + "resource_type": "macro", + "package_name": "dbt_snowflake", + "path": "macros/utils/array_construct.sql", + "original_file_path": "macros/utils/array_construct.sql", + "unique_id": "macro.dbt_snowflake.snowflake__array_construct", + "macro_sql": "{% macro snowflake__array_construct(inputs, data_type) -%}\n array_construct( {{ inputs|join(' , ') }} )\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.359711, + "supported_languages": null + }, + "macro.dbt.run_hooks": { + "name": "run_hooks", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/hooks.sql", + "original_file_path": "macros/materializations/hooks.sql", + "unique_id": "macro.dbt.run_hooks", + "macro_sql": "{% macro run_hooks(hooks, inside_transaction=True) %}\n {% for hook in hooks | selectattr('transaction', 'equalto', inside_transaction) %}\n {% if not inside_transaction and loop.first %}\n {% call statement(auto_begin=inside_transaction) %}\n commit;\n {% endcall %}\n {% endif %}\n {% set rendered = render(hook.get('sql')) | trim %}\n {% if (rendered | length) > 0 %}\n {% call statement(auto_begin=inside_transaction) %}\n {{ rendered }}\n {% endcall %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3607821, + "supported_languages": null + }, + "macro.dbt.make_hook_config": { + "name": "make_hook_config", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/hooks.sql", + "original_file_path": "macros/materializations/hooks.sql", + "unique_id": "macro.dbt.make_hook_config", + "macro_sql": "{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({\"sql\": sql, \"transaction\": inside_transaction}) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.360974, + "supported_languages": null + }, + "macro.dbt.before_begin": { + "name": "before_begin", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/hooks.sql", + "original_file_path": "macros/materializations/hooks.sql", + "unique_id": "macro.dbt.before_begin", + "macro_sql": "{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.make_hook_config" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.361113, + "supported_languages": null + }, + "macro.dbt.in_transaction": { + "name": "in_transaction", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/hooks.sql", + "original_file_path": "macros/materializations/hooks.sql", + "unique_id": "macro.dbt.in_transaction", + "macro_sql": "{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.make_hook_config" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.361251, + "supported_languages": null + }, + "macro.dbt.after_commit": { + "name": "after_commit", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/hooks.sql", + "original_file_path": "macros/materializations/hooks.sql", + "unique_id": "macro.dbt.after_commit", + "macro_sql": "{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.make_hook_config" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.361387, + "supported_languages": null + }, + "macro.dbt.set_sql_header": { + "name": "set_sql_header", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/configs.sql", + "original_file_path": "macros/materializations/configs.sql", + "unique_id": "macro.dbt.set_sql_header", + "macro_sql": "{% macro set_sql_header(config) -%}\n {{ config.set('sql_header', caller()) }}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.361753, + "supported_languages": null + }, + "macro.dbt.should_full_refresh": { + "name": "should_full_refresh", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/configs.sql", + "original_file_path": "macros/materializations/configs.sql", + "unique_id": "macro.dbt.should_full_refresh", + "macro_sql": "{% macro should_full_refresh() %}\n {% set config_full_refresh = config.get('full_refresh') %}\n {% if config_full_refresh is none %}\n {% set config_full_refresh = flags.FULL_REFRESH %}\n {% endif %}\n {% do return(config_full_refresh) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.362047, + "supported_languages": null + }, + "macro.dbt.should_store_failures": { + "name": "should_store_failures", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/configs.sql", + "original_file_path": "macros/materializations/configs.sql", + "unique_id": "macro.dbt.should_store_failures", + "macro_sql": "{% macro should_store_failures() %}\n {% set config_store_failures = config.get('store_failures') %}\n {% if config_store_failures is none %}\n {% set config_store_failures = flags.STORE_FAILURES %}\n {% endif %}\n {% do return(config_store_failures) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3623412, + "supported_languages": null + }, + "macro.dbt.snapshot_merge_sql": { + "name": "snapshot_merge_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/snapshot_merge.sql", + "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", + "unique_id": "macro.dbt.snapshot_merge_sql", + "macro_sql": "{% macro snapshot_merge_sql(target, source, insert_cols) -%}\n {{ adapter.dispatch('snapshot_merge_sql', 'dbt')(target, source, insert_cols) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__snapshot_merge_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.362777, + "supported_languages": null + }, + "macro.dbt.default__snapshot_merge_sql": { + "name": "default__snapshot_merge_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/snapshot_merge.sql", + "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", + "unique_id": "macro.dbt.default__snapshot_merge_sql", + "macro_sql": "{% macro default__snapshot_merge_sql(target, source, insert_cols) -%}\n {%- set insert_cols_csv = insert_cols | join(', ') -%}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id\n\n when matched\n and DBT_INTERNAL_DEST.dbt_valid_to is null\n and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')\n then update\n set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to\n\n when not matched\n and DBT_INTERNAL_SOURCE.dbt_change_type = 'insert'\n then insert ({{ insert_cols_csv }})\n values ({{ insert_cols_csv }})\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.363044, + "supported_languages": null + }, + "macro.dbt.strategy_dispatch": { + "name": "strategy_dispatch", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "unique_id": "macro.dbt.strategy_dispatch", + "macro_sql": "{% macro strategy_dispatch(name) -%}\n{% set original_name = name %}\n {% if '.' in name %}\n {% set package_name, name = name.split(\".\", 1) %}\n {% else %}\n {% set package_name = none %}\n {% endif %}\n\n {% if package_name is none %}\n {% set package_context = context %}\n {% elif package_name in context %}\n {% set package_context = context[package_name] %}\n {% else %}\n {% set error_msg %}\n Could not find package '{{package_name}}', called with '{{original_name}}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n\n {%- set search_name = 'snapshot_' ~ name ~ '_strategy' -%}\n\n {% if search_name not in package_context %}\n {% set error_msg %}\n The specified strategy macro '{{name}}' was not found in package '{{ package_name }}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n {{ return(package_context[search_name]) }}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.366595, + "supported_languages": null + }, + "macro.dbt.snapshot_hash_arguments": { + "name": "snapshot_hash_arguments", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "unique_id": "macro.dbt.snapshot_hash_arguments", + "macro_sql": "{% macro snapshot_hash_arguments(args) -%}\n {{ adapter.dispatch('snapshot_hash_arguments', 'dbt')(args) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__snapshot_hash_arguments" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.366761, + "supported_languages": null + }, + "macro.dbt.default__snapshot_hash_arguments": { + "name": "default__snapshot_hash_arguments", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "unique_id": "macro.dbt.default__snapshot_hash_arguments", + "macro_sql": "{% macro default__snapshot_hash_arguments(args) -%}\n md5({%- for arg in args -%}\n coalesce(cast({{ arg }} as varchar ), '')\n {% if not loop.last %} || '|' || {% endif %}\n {%- endfor -%})\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3669739, + "supported_languages": null + }, + "macro.dbt.snapshot_timestamp_strategy": { + "name": "snapshot_timestamp_strategy", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "unique_id": "macro.dbt.snapshot_timestamp_strategy", + "macro_sql": "{% macro snapshot_timestamp_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set primary_key = config['unique_key'] %}\n {% set updated_at = config['updated_at'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n\n {#/*\n The snapshot relation might not have an {{ updated_at }} value if the\n snapshot strategy is changed from `check` to `timestamp`. We\n should use a dbt-created column for the comparison in the snapshot\n table instead of assuming that the user-supplied {{ updated_at }}\n will be present in the historical data.\n\n See https://github.com/dbt-labs/dbt-core/issues/2350\n */ #}\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.dbt_valid_from < {{ current_rel }}.{{ updated_at }})\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.snapshot_hash_arguments" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3677282, + "supported_languages": null + }, + "macro.dbt.snapshot_string_as_time": { + "name": "snapshot_string_as_time", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "unique_id": "macro.dbt.snapshot_string_as_time", + "macro_sql": "{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter.dispatch('snapshot_string_as_time', 'dbt')(timestamp) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__snapshot_string_as_time" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3678908, + "supported_languages": null + }, + "macro.dbt.default__snapshot_string_as_time": { + "name": "default__snapshot_string_as_time", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "unique_id": "macro.dbt.default__snapshot_string_as_time", + "macro_sql": "{% macro default__snapshot_string_as_time(timestamp) %}\n {% do exceptions.raise_not_implemented(\n 'snapshot_string_as_time macro not implemented for adapter '+adapter.type()\n ) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.368059, + "supported_languages": null + }, + "macro.dbt.snapshot_check_all_get_existing_columns": { + "name": "snapshot_check_all_get_existing_columns", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "unique_id": "macro.dbt.snapshot_check_all_get_existing_columns", + "macro_sql": "{% macro snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) -%}\n {%- if not target_exists -%}\n {#-- no table yet -> return whatever the query does --#}\n {{ return((false, query_columns)) }}\n {%- endif -%}\n\n {#-- handle any schema changes --#}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=node.alias) -%}\n\n {% if check_cols_config == 'all' %}\n {%- set query_columns = get_columns_in_query(node['compiled_code']) -%}\n\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {#-- query for proper casing/quoting, to support comparison below --#}\n {%- set select_check_cols_from_target -%}\n {#-- N.B. The whitespace below is necessary to avoid edge case issue with comments --#}\n {#-- See: https://github.com/dbt-labs/dbt-core/issues/6781 --#}\n select {{ check_cols_config | join(', ') }} from (\n {{ node['compiled_code'] }}\n ) subq\n {%- endset -%}\n {% set query_columns = get_columns_in_query(select_check_cols_from_target) %}\n\n {% else %}\n {% do exceptions.raise_compiler_error(\"Invalid value for 'check_cols': \" ~ check_cols_config) %}\n {% endif %}\n\n {%- set existing_cols = adapter.get_columns_in_relation(target_relation) | map(attribute = 'name') | list -%}\n {%- set ns = namespace() -%} {#-- handle for-loop scoping with a namespace --#}\n {%- set ns.column_added = false -%}\n\n {%- set intersection = [] -%}\n {%- for col in query_columns -%}\n {%- if col in existing_cols -%}\n {%- do intersection.append(adapter.quote(col)) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return((ns.column_added, intersection)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_columns_in_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.369421, + "supported_languages": null + }, + "macro.dbt.snapshot_check_strategy": { + "name": "snapshot_check_strategy", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/strategies.sql", + "original_file_path": "macros/materializations/snapshots/strategies.sql", + "unique_id": "macro.dbt.snapshot_check_strategy", + "macro_sql": "{% macro snapshot_check_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set check_cols_config = config['check_cols'] %}\n {% set primary_key = config['unique_key'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n {% set updated_at = config.get('updated_at', snapshot_get_time()) %}\n\n {% set column_added = false %}\n\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n {{ get_true_sql() }}\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n (\n (({{ snapshotted_rel }}.{{ col }} is null) and not ({{ current_rel }}.{{ col }} is null))\n or\n ((not {{ snapshotted_rel }}.{{ col }} is null) and ({{ current_rel }}.{{ col }} is null))\n )\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n {%- endif -%}\n )\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.snapshot_get_time", + "macro.dbt.snapshot_check_all_get_existing_columns", + "macro.dbt.get_true_sql", + "macro.dbt.snapshot_hash_arguments" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.37068, + "supported_languages": null + }, + "macro.dbt.create_columns": { + "name": "create_columns", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "unique_id": "macro.dbt.create_columns", + "macro_sql": "{% macro create_columns(relation, columns) %}\n {{ adapter.dispatch('create_columns', 'dbt')(relation, columns) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__create_columns" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.374971, + "supported_languages": null + }, + "macro.dbt.default__create_columns": { + "name": "default__create_columns", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "unique_id": "macro.dbt.default__create_columns", + "macro_sql": "{% macro default__create_columns(relation, columns) %}\n {% for column in columns %}\n {% call statement() %}\n alter table {{ relation }} add column \"{{ column.name }}\" {{ column.data_type }};\n {% endcall %}\n {% endfor %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.375247, + "supported_languages": null + }, + "macro.dbt.post_snapshot": { + "name": "post_snapshot", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "unique_id": "macro.dbt.post_snapshot", + "macro_sql": "{% macro post_snapshot(staging_relation) %}\n {{ adapter.dispatch('post_snapshot', 'dbt')(staging_relation) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__post_snapshot" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3754098, + "supported_languages": null + }, + "macro.dbt.default__post_snapshot": { + "name": "default__post_snapshot", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "unique_id": "macro.dbt.default__post_snapshot", + "macro_sql": "{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.375494, + "supported_languages": null + }, + "macro.dbt.get_true_sql": { + "name": "get_true_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "unique_id": "macro.dbt.get_true_sql", + "macro_sql": "{% macro get_true_sql() %}\n {{ adapter.dispatch('get_true_sql', 'dbt')() }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_true_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3756318, + "supported_languages": null + }, + "macro.dbt.default__get_true_sql": { + "name": "default__get_true_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "unique_id": "macro.dbt.default__get_true_sql", + "macro_sql": "{% macro default__get_true_sql() %}\n {{ return('TRUE') }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.375743, + "supported_languages": null + }, + "macro.dbt.snapshot_staging_table": { + "name": "snapshot_staging_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "unique_id": "macro.dbt.snapshot_staging_table", + "macro_sql": "{% macro snapshot_staging_table(strategy, source_sql, target_relation) -%}\n {{ adapter.dispatch('snapshot_staging_table', 'dbt')(strategy, source_sql, target_relation) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__snapshot_staging_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.375947, + "supported_languages": null + }, + "macro.dbt.default__snapshot_staging_table": { + "name": "default__snapshot_staging_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "unique_id": "macro.dbt.default__snapshot_staging_table", + "macro_sql": "{% macro default__snapshot_staging_table(strategy, source_sql, target_relation) -%}\n\n with snapshot_query as (\n\n {{ source_sql }}\n\n ),\n\n snapshotted_data as (\n\n select *,\n {{ strategy.unique_key }} as dbt_unique_key\n\n from {{ target_relation }}\n where dbt_valid_to is null\n\n ),\n\n insertions_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to,\n {{ strategy.scd_id }} as dbt_scd_id\n\n from snapshot_query\n ),\n\n updates_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n {{ strategy.updated_at }} as dbt_valid_to\n\n from snapshot_query\n ),\n\n {%- if strategy.invalidate_hard_deletes %}\n\n deletes_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key\n from snapshot_query\n ),\n {% endif %}\n\n insertions as (\n\n select\n 'insert' as dbt_change_type,\n source_data.*\n\n from insertions_source_data as source_data\n left outer join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_unique_key is null\n or (\n snapshotted_data.dbt_unique_key is not null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n ),\n\n updates as (\n\n select\n 'update' as dbt_change_type,\n source_data.*,\n snapshotted_data.dbt_scd_id\n\n from updates_source_data as source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where (\n {{ strategy.row_changed }}\n )\n )\n\n {%- if strategy.invalidate_hard_deletes -%}\n ,\n\n deletes as (\n\n select\n 'delete' as dbt_change_type,\n source_data.*,\n {{ snapshot_get_time() }} as dbt_valid_from,\n {{ snapshot_get_time() }} as dbt_updated_at,\n {{ snapshot_get_time() }} as dbt_valid_to,\n snapshotted_data.dbt_scd_id\n\n from snapshotted_data\n left join deletes_source_data as source_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where source_data.dbt_unique_key is null\n )\n {%- endif %}\n\n select * from insertions\n union all\n select * from updates\n {%- if strategy.invalidate_hard_deletes %}\n union all\n select * from deletes\n {%- endif %}\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.snapshot_get_time" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.376811, + "supported_languages": null + }, + "macro.dbt.build_snapshot_table": { + "name": "build_snapshot_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "unique_id": "macro.dbt.build_snapshot_table", + "macro_sql": "{% macro build_snapshot_table(strategy, sql) -%}\n {{ adapter.dispatch('build_snapshot_table', 'dbt')(strategy, sql) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__build_snapshot_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.376995, + "supported_languages": null + }, + "macro.dbt.default__build_snapshot_table": { + "name": "default__build_snapshot_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "unique_id": "macro.dbt.default__build_snapshot_table", + "macro_sql": "{% macro default__build_snapshot_table(strategy, sql) %}\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to\n from (\n {{ sql }}\n ) sbq\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3772411, + "supported_languages": null + }, + "macro.dbt.build_snapshot_staging_table": { + "name": "build_snapshot_staging_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/helpers.sql", + "original_file_path": "macros/materializations/snapshots/helpers.sql", + "unique_id": "macro.dbt.build_snapshot_staging_table", + "macro_sql": "{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set temp_relation = make_temp_relation(target_relation) %}\n\n {% set select = snapshot_staging_table(strategy, sql, target_relation) %}\n\n {% call statement('build_snapshot_staging_relation') %}\n {{ create_table_as(True, temp_relation, select) }}\n {% endcall %}\n\n {% do return(temp_relation) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.make_temp_relation", + "macro.dbt.snapshot_staging_table", + "macro.dbt.statement", + "macro.dbt.create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3776581, + "supported_languages": null + }, + "macro.dbt.materialization_snapshot_default": { + "name": "materialization_snapshot_default", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/snapshots/snapshot.sql", + "original_file_path": "macros/materializations/snapshots/snapshot.sql", + "unique_id": "macro.dbt.materialization_snapshot_default", + "macro_sql": "{% materialization snapshot, default %}\n {%- set config = model['config'] -%}\n\n {%- set target_table = model.get('alias', model.get('name')) -%}\n\n {%- set strategy_name = config.get('strategy') -%}\n {%- set unique_key = config.get('unique_key') %}\n -- grab current tables grants config for comparision later on\n {%- set grant_config = config.get('grants') -%}\n\n {% set target_relation_exists, target_relation = get_or_create_relation(\n database=model.database,\n schema=model.schema,\n identifier=target_table,\n type='table') -%}\n\n {%- if not target_relation.is_table -%}\n {% do exceptions.relation_wrong_type(target_relation, 'table') %}\n {%- endif -%}\n\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set strategy_macro = strategy_dispatch(strategy_name) %}\n {% set strategy = strategy_macro(model, \"snapshotted_data\", \"source_data\", config, target_relation_exists) %}\n\n {% if not target_relation_exists %}\n\n {% set build_sql = build_snapshot_table(strategy, model['compiled_code']) %}\n {% set final_sql = create_table_as(False, target_relation, build_sql) %}\n\n {% else %}\n\n {{ adapter.valid_snapshot_target(target_relation) }}\n\n {% set staging_table = build_snapshot_staging_table(strategy, sql, target_relation) %}\n\n -- this may no-op if the database does not require column expansion\n {% do adapter.expand_target_column_types(from_relation=staging_table,\n to_relation=target_relation) %}\n\n {% set missing_columns = adapter.get_missing_columns(staging_table, target_relation)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% do create_columns(target_relation, missing_columns) %}\n\n {% set source_columns = adapter.get_columns_in_relation(staging_table)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% set quoted_source_columns = [] %}\n {% for column in source_columns %}\n {% do quoted_source_columns.append(adapter.quote(column.name)) %}\n {% endfor %}\n\n {% set final_sql = snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n %}\n\n {% endif %}\n\n {% call statement('main') %}\n {{ final_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(target_relation_exists, full_refresh_mode=False) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if not target_relation_exists %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if staging_table is defined %}\n {% do post_snapshot(staging_table) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.dbt.get_or_create_relation", + "macro.dbt.run_hooks", + "macro.dbt.strategy_dispatch", + "macro.dbt.build_snapshot_table", + "macro.dbt.create_table_as", + "macro.dbt.build_snapshot_staging_table", + "macro.dbt.create_columns", + "macro.dbt.snapshot_merge_sql", + "macro.dbt.statement", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs", + "macro.dbt.create_indexes", + "macro.dbt.post_snapshot" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.383877, + "supported_languages": [ + "sql" + ] + }, + "macro.dbt.materialization_test_default": { + "name": "materialization_test_default", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/tests/test.sql", + "original_file_path": "macros/materializations/tests/test.sql", + "unique_id": "macro.dbt.materialization_test_default", + "macro_sql": "{%- materialization test, default -%}\n\n {% set relations = [] %}\n\n {% if should_store_failures() %}\n\n {% set identifier = model['alias'] %}\n {% set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% set store_failures_as = config.get('store_failures_as') %}\n -- if `--store-failures` is invoked via command line and `store_failures_as` is not set,\n -- config.get('store_failures_as', 'table') returns None, not 'table'\n {% if store_failures_as == none %}{% set store_failures_as = 'table' %}{% endif %}\n {% if store_failures_as not in ['table', 'view'] %}\n {{ exceptions.raise_compiler_error(\n \"'\" ~ store_failures_as ~ \"' is not a valid value for `store_failures_as`. \"\n \"Accepted values are: ['ephemeral', 'table', 'view']\"\n ) }}\n {% endif %}\n\n {% set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database, type=store_failures_as) -%} %}\n\n {% if old_relation %}\n {% do adapter.drop_relation(old_relation) %}\n {% endif %}\n\n {% call statement(auto_begin=True) %}\n {{ get_create_sql(target_relation, sql) }}\n {% endcall %}\n\n {% do relations.append(target_relation) %}\n\n {% set main_sql %}\n select *\n from {{ target_relation }}\n {% endset %}\n\n {{ adapter.commit() }}\n\n {% else %}\n\n {% set main_sql = sql %}\n\n {% endif %}\n\n {% set limit = config.get('limit') %}\n {% set fail_calc = config.get('fail_calc') %}\n {% set warn_if = config.get('warn_if') %}\n {% set error_if = config.get('error_if') %}\n\n {% call statement('main', fetch_result=True) -%}\n\n {{ get_test_sql(main_sql, fail_calc, warn_if, error_if, limit)}}\n\n {%- endcall %}\n\n {{ return({'relations': relations}) }}\n\n{%- endmaterialization -%}", + "depends_on": { + "macros": [ + "macro.dbt.should_store_failures", + "macro.dbt.statement", + "macro.dbt.get_create_sql", + "macro.dbt.get_test_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3865652, + "supported_languages": [ + "sql" + ] + }, + "macro.dbt.get_test_sql": { + "name": "get_test_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/tests/helpers.sql", + "original_file_path": "macros/materializations/tests/helpers.sql", + "unique_id": "macro.dbt.get_test_sql", + "macro_sql": "{% macro get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n {{ adapter.dispatch('get_test_sql', 'dbt')(main_sql, fail_calc, warn_if, error_if, limit) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_test_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.387011, + "supported_languages": null + }, + "macro.dbt.default__get_test_sql": { + "name": "default__get_test_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/tests/helpers.sql", + "original_file_path": "macros/materializations/tests/helpers.sql", + "unique_id": "macro.dbt.default__get_test_sql", + "macro_sql": "{% macro default__get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n select\n {{ fail_calc }} as failures,\n {{ fail_calc }} {{ warn_if }} as should_warn,\n {{ fail_calc }} {{ error_if }} as should_error\n from (\n {{ main_sql }}\n {{ \"limit \" ~ limit if limit != none }}\n ) dbt_internal_test\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3873112, + "supported_languages": null + }, + "macro.dbt.get_where_subquery": { + "name": "get_where_subquery", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/tests/where_subquery.sql", + "original_file_path": "macros/materializations/tests/where_subquery.sql", + "unique_id": "macro.dbt.get_where_subquery", + "macro_sql": "{% macro get_where_subquery(relation) -%}\n {% do return(adapter.dispatch('get_where_subquery', 'dbt')(relation)) %}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_where_subquery" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.387681, + "supported_languages": null + }, + "macro.dbt.default__get_where_subquery": { + "name": "default__get_where_subquery", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/tests/where_subquery.sql", + "original_file_path": "macros/materializations/tests/where_subquery.sql", + "unique_id": "macro.dbt.default__get_where_subquery", + "macro_sql": "{% macro default__get_where_subquery(relation) -%}\n {% set where = config.get('where', '') %}\n {% if where %}\n {%- set filtered -%}\n (select * from {{ relation }} where {{ where }}) dbt_subquery\n {%- endset -%}\n {% do return(filtered) %}\n {%- else -%}\n {% do return(relation) %}\n {%- endif -%}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.388044, + "supported_languages": null + }, + "macro.dbt.materialization_materialized_view_default": { + "name": "materialization_materialized_view_default", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/materialized_view.sql", + "original_file_path": "macros/materializations/models/materialized_view.sql", + "unique_id": "macro.dbt.materialization_materialized_view_default", + "macro_sql": "{% materialization materialized_view, default %}\n {% set existing_relation = load_cached_relation(this) %}\n {% set target_relation = this.incorporate(type=this.MaterializedView) %}\n {% set intermediate_relation = make_intermediate_relation(target_relation) %}\n {% set backup_relation_type = target_relation.MaterializedView if existing_relation is none else existing_relation.type %}\n {% set backup_relation = make_backup_relation(target_relation, backup_relation_type) %}\n\n {{ materialized_view_setup(backup_relation, intermediate_relation, pre_hooks) }}\n\n {% set build_sql = materialized_view_get_build_sql(existing_relation, target_relation, backup_relation, intermediate_relation) %}\n\n {% if build_sql == '' %}\n {{ materialized_view_execute_no_op(target_relation) }}\n {% else %}\n {{ materialized_view_execute_build_sql(build_sql, existing_relation, target_relation, post_hooks) }}\n {% endif %}\n\n {{ materialized_view_teardown(backup_relation, intermediate_relation, post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.dbt.load_cached_relation", + "macro.dbt.make_intermediate_relation", + "macro.dbt.make_backup_relation", + "macro.dbt.materialized_view_setup", + "macro.dbt.materialized_view_get_build_sql", + "macro.dbt.materialized_view_execute_no_op", + "macro.dbt.materialized_view_execute_build_sql", + "macro.dbt.materialized_view_teardown" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.393088, + "supported_languages": [ + "sql" + ] + }, + "macro.dbt.materialized_view_setup": { + "name": "materialized_view_setup", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/materialized_view.sql", + "original_file_path": "macros/materializations/models/materialized_view.sql", + "unique_id": "macro.dbt.materialized_view_setup", + "macro_sql": "{% macro materialized_view_setup(backup_relation, intermediate_relation, pre_hooks) %}\n\n -- backup_relation and intermediate_relation should not already exist in the database\n -- it's possible these exist because of a previous run that exited unexpectedly\n {% set preexisting_backup_relation = load_cached_relation(backup_relation) %}\n {% set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.load_cached_relation", + "macro.dbt.drop_relation_if_exists", + "macro.dbt.run_hooks" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.393465, + "supported_languages": null + }, + "macro.dbt.materialized_view_teardown": { + "name": "materialized_view_teardown", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/materialized_view.sql", + "original_file_path": "macros/materializations/models/materialized_view.sql", + "unique_id": "macro.dbt.materialized_view_teardown", + "macro_sql": "{% macro materialized_view_teardown(backup_relation, intermediate_relation, post_hooks) %}\n\n -- drop the temp relations if they exist to leave the database clean for the next run\n {{ drop_relation_if_exists(backup_relation) }}\n {{ drop_relation_if_exists(intermediate_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.drop_relation_if_exists", + "macro.dbt.run_hooks" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.393711, + "supported_languages": null + }, + "macro.dbt.materialized_view_get_build_sql": { + "name": "materialized_view_get_build_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/materialized_view.sql", + "original_file_path": "macros/materializations/models/materialized_view.sql", + "unique_id": "macro.dbt.materialized_view_get_build_sql", + "macro_sql": "{% macro materialized_view_get_build_sql(existing_relation, target_relation, backup_relation, intermediate_relation) %}\n\n {% set full_refresh_mode = should_full_refresh() %}\n\n -- determine the scenario we're in: create, full_refresh, alter, refresh data\n {% if existing_relation is none %}\n {% set build_sql = get_create_materialized_view_as_sql(target_relation, sql) %}\n {% elif full_refresh_mode or not existing_relation.is_materialized_view %}\n {% set build_sql = get_replace_sql(existing_relation, target_relation, sql) %}\n {% else %}\n\n -- get config options\n {% set on_configuration_change = config.get('on_configuration_change') %}\n {% set configuration_changes = get_materialized_view_configuration_changes(existing_relation, config) %}\n\n {% if configuration_changes is none %}\n {% set build_sql = refresh_materialized_view(target_relation) %}\n\n {% elif on_configuration_change == 'apply' %}\n {% set build_sql = get_alter_materialized_view_as_sql(target_relation, configuration_changes, sql, existing_relation, backup_relation, intermediate_relation) %}\n {% elif on_configuration_change == 'continue' %}\n {% set build_sql = '' %}\n {{ exceptions.warn(\"Configuration changes were identified and `on_configuration_change` was set to `continue` for `\" ~ target_relation ~ \"`\") }}\n {% elif on_configuration_change == 'fail' %}\n {{ exceptions.raise_fail_fast_error(\"Configuration changes were identified and `on_configuration_change` was set to `fail` for `\" ~ target_relation ~ \"`\") }}\n\n {% else %}\n -- this only happens if the user provides a value other than `apply`, 'skip', 'fail'\n {{ exceptions.raise_compiler_error(\"Unexpected configuration scenario\") }}\n\n {% endif %}\n\n {% endif %}\n\n {% do return(build_sql) %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.should_full_refresh", + "macro.dbt.get_create_materialized_view_as_sql", + "macro.dbt.get_replace_sql", + "macro.dbt.get_materialized_view_configuration_changes", + "macro.dbt.refresh_materialized_view", + "macro.dbt.get_alter_materialized_view_as_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.39496, + "supported_languages": null + }, + "macro.dbt.materialized_view_execute_no_op": { + "name": "materialized_view_execute_no_op", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/materialized_view.sql", + "original_file_path": "macros/materializations/models/materialized_view.sql", + "unique_id": "macro.dbt.materialized_view_execute_no_op", + "macro_sql": "{% macro materialized_view_execute_no_op(target_relation) %}\n {% do store_raw_result(\n name=\"main\",\n message=\"skip \" ~ target_relation,\n code=\"skip\",\n rows_affected=\"-1\"\n ) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.395185, + "supported_languages": null + }, + "macro.dbt.materialized_view_execute_build_sql": { + "name": "materialized_view_execute_build_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/materialized_view.sql", + "original_file_path": "macros/materializations/models/materialized_view.sql", + "unique_id": "macro.dbt.materialized_view_execute_build_sql", + "macro_sql": "{% macro materialized_view_execute_build_sql(build_sql, existing_relation, target_relation, post_hooks) %}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set grant_config = config.get('grants') %}\n\n {% call statement(name=\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.run_hooks", + "macro.dbt.statement", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.395825, + "supported_languages": null + }, + "macro.dbt.materialization_view_default": { + "name": "materialization_view_default", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/view.sql", + "original_file_path": "macros/materializations/models/view.sql", + "unique_id": "macro.dbt.materialization_view_default", + "macro_sql": "{%- materialization view, default -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='view') -%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n This relation (probably) doesn't exist yet. If it does exist, it's a leftover from\n a previous run, and we're going to try to drop it immediately. At the end of this\n materialization, we're going to rename the \"existing_relation\" to this identifier,\n and then we're going to drop it. In order to make sure we run the correct one of:\n - drop view ...\n - drop table ...\n\n We need to set the type of this relation to be the type of the existing_relation, if it exists,\n or else \"view\" as a sane default if it does not. Note that if the existing_relation does not\n exist, then there is nothing to move out of the way and subsequentally drop. In that case,\n this relation will be effectively unused.\n */\n {%- set backup_relation_type = 'view' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n -- move the existing view out of the way\n {% if existing_relation is not none %}\n /* Do the equivalent of rename_if_exists. 'existing_relation' could have been dropped\n since the variable was first set. */\n {% set existing_relation = load_cached_relation(existing_relation) %}\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {% endif %}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization -%}", + "depends_on": { + "macros": [ + "macro.dbt.load_cached_relation", + "macro.dbt.make_intermediate_relation", + "macro.dbt.make_backup_relation", + "macro.dbt.run_hooks", + "macro.dbt.drop_relation_if_exists", + "macro.dbt.statement", + "macro.dbt.get_create_view_as_sql", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.3987021, + "supported_languages": [ + "sql" + ] + }, + "macro.dbt.materialization_table_default": { + "name": "materialization_table_default", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/table.sql", + "original_file_path": "macros/materializations/models/table.sql", + "unique_id": "macro.dbt.materialization_table_default", + "macro_sql": "{% materialization table, default %}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n See ../view/view.sql for more information about this relation.\n */\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n {% if existing_relation is not none %}\n /* Do the equivalent of rename_if_exists. 'existing_relation' could have been dropped\n since the variable was first set. */\n {% set existing_relation = load_cached_relation(existing_relation) %}\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {% endif %}\n\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% do create_indexes(target_relation) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n -- finally, drop the existing/backup relation after the commit\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.dbt.load_cached_relation", + "macro.dbt.make_intermediate_relation", + "macro.dbt.make_backup_relation", + "macro.dbt.drop_relation_if_exists", + "macro.dbt.run_hooks", + "macro.dbt.statement", + "macro.dbt.get_create_table_as_sql", + "macro.dbt.create_indexes", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.401531, + "supported_languages": [ + "sql" + ] + }, + "macro.dbt.get_quoted_csv": { + "name": "get_quoted_csv", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/column_helpers.sql", + "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", + "unique_id": "macro.dbt.get_quoted_csv", + "macro_sql": "{% macro get_quoted_csv(column_names) %}\n\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote(col)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.403145, + "supported_languages": null + }, + "macro.dbt.diff_columns": { + "name": "diff_columns", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/column_helpers.sql", + "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", + "unique_id": "macro.dbt.diff_columns", + "macro_sql": "{% macro diff_columns(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% set source_names = source_columns | map(attribute = 'column') | list %}\n {% set target_names = target_columns | map(attribute = 'column') | list %}\n\n {# --check whether the name attribute exists in the target - this does not perform a data type check #}\n {% for sc in source_columns %}\n {% if sc.name not in target_names %}\n {{ result.append(sc) }}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.403685, + "supported_languages": null + }, + "macro.dbt.diff_column_data_types": { + "name": "diff_column_data_types", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/column_helpers.sql", + "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", + "unique_id": "macro.dbt.diff_column_data_types", + "macro_sql": "{% macro diff_column_data_types(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% for sc in source_columns %}\n {% set tc = target_columns | selectattr(\"name\", \"equalto\", sc.name) | list | first %}\n {% if tc %}\n {% if sc.data_type != tc.data_type and not sc.can_expand_to(other_column=tc) %}\n {{ result.append( { 'column_name': tc.name, 'new_type': sc.data_type } ) }}\n {% endif %}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.40433, + "supported_languages": null + }, + "macro.dbt.get_merge_update_columns": { + "name": "get_merge_update_columns", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/column_helpers.sql", + "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", + "unique_id": "macro.dbt.get_merge_update_columns", + "macro_sql": "{% macro get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {{ return(adapter.dispatch('get_merge_update_columns', 'dbt')(merge_update_columns, merge_exclude_columns, dest_columns)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_merge_update_columns" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4045599, + "supported_languages": null + }, + "macro.dbt.default__get_merge_update_columns": { + "name": "default__get_merge_update_columns", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/column_helpers.sql", + "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", + "unique_id": "macro.dbt.default__get_merge_update_columns", + "macro_sql": "{% macro default__get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {%- set default_cols = dest_columns | map(attribute=\"quoted\") | list -%}\n\n {%- if merge_update_columns and merge_exclude_columns -%}\n {{ exceptions.raise_compiler_error(\n 'Model cannot specify merge_update_columns and merge_exclude_columns. Please update model to use only one config'\n )}}\n {%- elif merge_update_columns -%}\n {%- set update_columns = merge_update_columns -%}\n {%- elif merge_exclude_columns -%}\n {%- set update_columns = [] -%}\n {%- for column in dest_columns -%}\n {% if column.column | lower not in merge_exclude_columns | map(\"lower\") | list %}\n {%- do update_columns.append(column.quoted) -%}\n {% endif %}\n {%- endfor -%}\n {%- else -%}\n {%- set update_columns = default_cols -%}\n {%- endif -%}\n\n {{ return(update_columns) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.405252, + "supported_languages": null + }, + "macro.dbt.get_merge_sql": { + "name": "get_merge_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/merge.sql", + "original_file_path": "macros/materializations/models/incremental/merge.sql", + "unique_id": "macro.dbt.get_merge_sql", + "macro_sql": "{% macro get_merge_sql(target, source, unique_key, dest_columns, incremental_predicates=none) -%}\n -- back compat for old kwarg name\n {% set incremental_predicates = kwargs.get('predicates', incremental_predicates) %}\n {{ adapter.dispatch('get_merge_sql', 'dbt')(target, source, unique_key, dest_columns, incremental_predicates) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_merge_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.411934, + "supported_languages": null + }, + "macro.dbt.default__get_merge_sql": { + "name": "default__get_merge_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/merge.sql", + "original_file_path": "macros/materializations/models/incremental/merge.sql", + "unique_id": "macro.dbt.default__get_merge_sql", + "macro_sql": "{% macro default__get_merge_sql(target, source, unique_key, dest_columns, incremental_predicates=none) -%}\n {%- set predicates = [] if incremental_predicates is none else [] + incremental_predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set merge_update_columns = config.get('merge_update_columns') -%}\n {%- set merge_exclude_columns = config.get('merge_exclude_columns') -%}\n {%- set update_columns = get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not mapping and unique_key is not string %}\n {% for key in unique_key %}\n {% set this_key_match %}\n DBT_INTERNAL_SOURCE.{{ key }} = DBT_INTERNAL_DEST.{{ key }}\n {% endset %}\n {% do predicates.append(this_key_match) %}\n {% endfor %}\n {% else %}\n {% set unique_key_match %}\n DBT_INTERNAL_SOURCE.{{ unique_key }} = DBT_INTERNAL_DEST.{{ unique_key }}\n {% endset %}\n {% do predicates.append(unique_key_match) %}\n {% endif %}\n {% else %}\n {% do predicates.append('FALSE') %}\n {% endif %}\n\n {{ sql_header if sql_header is not none }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on {{\"(\" ~ predicates | join(\") and (\") ~ \")\"}}\n\n {% if unique_key %}\n when matched then update set\n {% for column_name in update_columns -%}\n {{ column_name }} = DBT_INTERNAL_SOURCE.{{ column_name }}\n {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n {% endif %}\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_quoted_csv", + "macro.dbt.get_merge_update_columns" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.413478, + "supported_languages": null + }, + "macro.dbt.get_delete_insert_merge_sql": { + "name": "get_delete_insert_merge_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/merge.sql", + "original_file_path": "macros/materializations/models/incremental/merge.sql", + "unique_id": "macro.dbt.get_delete_insert_merge_sql", + "macro_sql": "{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) -%}\n {{ adapter.dispatch('get_delete_insert_merge_sql', 'dbt')(target, source, unique_key, dest_columns, incremental_predicates) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_delete_insert_merge_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4137301, + "supported_languages": null + }, + "macro.dbt.default__get_delete_insert_merge_sql": { + "name": "default__get_delete_insert_merge_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/merge.sql", + "original_file_path": "macros/materializations/models/incremental/merge.sql", + "unique_id": "macro.dbt.default__get_delete_insert_merge_sql", + "macro_sql": "{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) -%}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not string %}\n delete from {{target }}\n using {{ source }}\n where (\n {% for key in unique_key %}\n {{ source }}.{{ key }} = {{ target }}.{{ key }}\n {{ \"and \" if not loop.last}}\n {% endfor %}\n {% if incremental_predicates %}\n {% for predicate in incremental_predicates %}\n and {{ predicate }}\n {% endfor %}\n {% endif %}\n );\n {% else %}\n delete from {{ target }}\n where (\n {{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n )\n {%- if incremental_predicates %}\n {% for predicate in incremental_predicates %}\n and {{ predicate }}\n {% endfor %}\n {%- endif -%};\n\n {% endif %}\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n )\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_quoted_csv" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4147031, + "supported_languages": null + }, + "macro.dbt.get_insert_overwrite_merge_sql": { + "name": "get_insert_overwrite_merge_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/merge.sql", + "original_file_path": "macros/materializations/models/incremental/merge.sql", + "unique_id": "macro.dbt.get_insert_overwrite_merge_sql", + "macro_sql": "{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header=false) -%}\n {{ adapter.dispatch('get_insert_overwrite_merge_sql', 'dbt')(target, source, dest_columns, predicates, include_sql_header) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_insert_overwrite_merge_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4149618, + "supported_languages": null + }, + "macro.dbt.default__get_insert_overwrite_merge_sql": { + "name": "default__get_insert_overwrite_merge_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/merge.sql", + "original_file_path": "macros/materializations/models/incremental/merge.sql", + "unique_id": "macro.dbt.default__get_insert_overwrite_merge_sql", + "macro_sql": "{% macro default__get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header) -%}\n {#-- The only time include_sql_header is True: --#}\n {#-- BigQuery + insert_overwrite strategy + \"static\" partitions config --#}\n {#-- We should consider including the sql header at the materialization level instead --#}\n\n {%- set predicates = [] if predicates is none else [] + predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none and include_sql_header }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on FALSE\n\n when not matched by source\n {% if predicates %} and {{ predicates | join(' and ') }} {% endif %}\n then delete\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_quoted_csv" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4155881, + "supported_languages": null + }, + "macro.dbt.is_incremental": { + "name": "is_incremental", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/is_incremental.sql", + "original_file_path": "macros/materializations/models/incremental/is_incremental.sql", + "unique_id": "macro.dbt.is_incremental", + "macro_sql": "{% macro is_incremental() %}\n {#-- do not run introspective queries in parsing #}\n {% if not execute %}\n {{ return(False) }}\n {% else %}\n {% set relation = adapter.get_relation(this.database, this.schema, this.table) %}\n {{ return(relation is not none\n and relation.type == 'table'\n and model.config.materialized == 'incremental'\n and not should_full_refresh()) }}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.should_full_refresh" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.416214, + "supported_languages": null + }, + "macro.dbt.get_incremental_append_sql": { + "name": "get_incremental_append_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "unique_id": "macro.dbt.get_incremental_append_sql", + "macro_sql": "{% macro get_incremental_append_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_append_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_incremental_append_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.417095, + "supported_languages": null + }, + "macro.dbt.default__get_incremental_append_sql": { + "name": "default__get_incremental_append_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "unique_id": "macro.dbt.default__get_incremental_append_sql", + "macro_sql": "{% macro default__get_incremental_append_sql(arg_dict) %}\n\n {% do return(get_insert_into_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_insert_into_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4173272, + "supported_languages": null + }, + "macro.dbt.get_incremental_delete_insert_sql": { + "name": "get_incremental_delete_insert_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "unique_id": "macro.dbt.get_incremental_delete_insert_sql", + "macro_sql": "{% macro get_incremental_delete_insert_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_delete_insert_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_incremental_delete_insert_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.417511, + "supported_languages": null + }, + "macro.dbt.default__get_incremental_delete_insert_sql": { + "name": "default__get_incremental_delete_insert_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "unique_id": "macro.dbt.default__get_incremental_delete_insert_sql", + "macro_sql": "{% macro default__get_incremental_delete_insert_sql(arg_dict) %}\n\n {% do return(get_delete_insert_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_delete_insert_merge_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4177952, + "supported_languages": null + }, + "macro.dbt.get_incremental_merge_sql": { + "name": "get_incremental_merge_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "unique_id": "macro.dbt.get_incremental_merge_sql", + "macro_sql": "{% macro get_incremental_merge_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_merge_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_incremental_merge_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.418036, + "supported_languages": null + }, + "macro.dbt.default__get_incremental_merge_sql": { + "name": "default__get_incremental_merge_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "unique_id": "macro.dbt.default__get_incremental_merge_sql", + "macro_sql": "{% macro default__get_incremental_merge_sql(arg_dict) %}\n\n {% do return(get_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_merge_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.418324, + "supported_languages": null + }, + "macro.dbt.get_incremental_insert_overwrite_sql": { + "name": "get_incremental_insert_overwrite_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "unique_id": "macro.dbt.get_incremental_insert_overwrite_sql", + "macro_sql": "{% macro get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_insert_overwrite_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_incremental_insert_overwrite_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4185028, + "supported_languages": null + }, + "macro.dbt.default__get_incremental_insert_overwrite_sql": { + "name": "default__get_incremental_insert_overwrite_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "unique_id": "macro.dbt.default__get_incremental_insert_overwrite_sql", + "macro_sql": "{% macro default__get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {% do return(get_insert_overwrite_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_insert_overwrite_merge_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4187589, + "supported_languages": null + }, + "macro.dbt.get_incremental_default_sql": { + "name": "get_incremental_default_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "unique_id": "macro.dbt.get_incremental_default_sql", + "macro_sql": "{% macro get_incremental_default_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_default_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_incremental_default_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.418941, + "supported_languages": null + }, + "macro.dbt.default__get_incremental_default_sql": { + "name": "default__get_incremental_default_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "unique_id": "macro.dbt.default__get_incremental_default_sql", + "macro_sql": "{% macro default__get_incremental_default_sql(arg_dict) %}\n\n {% do return(get_incremental_append_sql(arg_dict)) %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_incremental_append_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.419083, + "supported_languages": null + }, + "macro.dbt.get_insert_into_sql": { + "name": "get_insert_into_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/strategies.sql", + "original_file_path": "macros/materializations/models/incremental/strategies.sql", + "unique_id": "macro.dbt.get_insert_into_sql", + "macro_sql": "{% macro get_insert_into_sql(target_relation, temp_relation, dest_columns) %}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n insert into {{ target_relation }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ temp_relation }}\n )\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_quoted_csv" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.419352, + "supported_languages": null + }, + "macro.dbt.materialization_incremental_default": { + "name": "materialization_incremental_default", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/incremental.sql", + "original_file_path": "macros/materializations/models/incremental/incremental.sql", + "unique_id": "macro.dbt.materialization_incremental_default", + "macro_sql": "{% materialization incremental, default -%}\n\n -- relations\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set temp_relation = make_temp_relation(target_relation)-%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation)-%}\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n\n -- configs\n {%- set unique_key = config.get('unique_key') -%}\n {%- set full_refresh_mode = (should_full_refresh() or existing_relation.is_view) -%}\n {%- set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') -%}\n\n -- the temp_ and backup_ relations should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation. This has to happen before\n -- BEGIN, in a separate transaction\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation)-%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set to_drop = [] %}\n\n {% if existing_relation is none %}\n {% set build_sql = get_create_table_as_sql(False, target_relation, sql) %}\n {% elif full_refresh_mode %}\n {% set build_sql = get_create_table_as_sql(False, intermediate_relation, sql) %}\n {% set need_swap = true %}\n {% else %}\n {% do run_query(get_create_table_as_sql(True, temp_relation, sql)) %}\n {% do adapter.expand_target_column_types(\n from_relation=temp_relation,\n to_relation=target_relation) %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, temp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': temp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'incremental_predicates': incremental_predicates }) %}\n {% set build_sql = strategy_sql_macro_func(strategy_arg_dict) %}\n\n {% endif %}\n\n {% call statement(\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% if need_swap %}\n {% do adapter.rename_relation(target_relation, backup_relation) %}\n {% do adapter.rename_relation(intermediate_relation, target_relation) %}\n {% do to_drop.append(backup_relation) %}\n {% endif %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if existing_relation is none or existing_relation.is_view or should_full_refresh() %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {% do adapter.commit() %}\n\n {% for rel in to_drop %}\n {% do adapter.drop_relation(rel) %}\n {% endfor %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", + "depends_on": { + "macros": [ + "macro.dbt.load_cached_relation", + "macro.dbt.make_temp_relation", + "macro.dbt.make_intermediate_relation", + "macro.dbt.make_backup_relation", + "macro.dbt.should_full_refresh", + "macro.dbt.incremental_validate_on_schema_change", + "macro.dbt.drop_relation_if_exists", + "macro.dbt.run_hooks", + "macro.dbt.get_create_table_as_sql", + "macro.dbt.run_query", + "macro.dbt.process_schema_changes", + "macro.dbt.statement", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs", + "macro.dbt.create_indexes" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4242508, + "supported_languages": [ + "sql" + ] + }, + "macro.dbt.incremental_validate_on_schema_change": { + "name": "incremental_validate_on_schema_change", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/on_schema_change.sql", + "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", + "unique_id": "macro.dbt.incremental_validate_on_schema_change", + "macro_sql": "{% macro incremental_validate_on_schema_change(on_schema_change, default='ignore') %}\n\n {% if on_schema_change not in ['sync_all_columns', 'append_new_columns', 'fail', 'ignore'] %}\n\n {% set log_message = 'Invalid value for on_schema_change (%s) specified. Setting default value of %s.' % (on_schema_change, default) %}\n {% do log(log_message) %}\n\n {{ return(default) }}\n\n {% else %}\n\n {{ return(on_schema_change) }}\n\n {% endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.430052, + "supported_languages": null + }, + "macro.dbt.check_for_schema_changes": { + "name": "check_for_schema_changes", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/on_schema_change.sql", + "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", + "unique_id": "macro.dbt.check_for_schema_changes", + "macro_sql": "{% macro check_for_schema_changes(source_relation, target_relation) %}\n\n {% set schema_changed = False %}\n\n {%- set source_columns = adapter.get_columns_in_relation(source_relation) -%}\n {%- set target_columns = adapter.get_columns_in_relation(target_relation) -%}\n {%- set source_not_in_target = diff_columns(source_columns, target_columns) -%}\n {%- set target_not_in_source = diff_columns(target_columns, source_columns) -%}\n\n {% set new_target_types = diff_column_data_types(source_columns, target_columns) %}\n\n {% if source_not_in_target != [] %}\n {% set schema_changed = True %}\n {% elif target_not_in_source != [] or new_target_types != [] %}\n {% set schema_changed = True %}\n {% elif new_target_types != [] %}\n {% set schema_changed = True %}\n {% endif %}\n\n {% set changes_dict = {\n 'schema_changed': schema_changed,\n 'source_not_in_target': source_not_in_target,\n 'target_not_in_source': target_not_in_source,\n 'source_columns': source_columns,\n 'target_columns': target_columns,\n 'new_target_types': new_target_types\n } %}\n\n {% set msg %}\n In {{ target_relation }}:\n Schema changed: {{ schema_changed }}\n Source columns not in target: {{ source_not_in_target }}\n Target columns not in source: {{ target_not_in_source }}\n New column types: {{ new_target_types }}\n {% endset %}\n\n {% do log(msg) %}\n\n {{ return(changes_dict) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.diff_columns", + "macro.dbt.diff_column_data_types" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.431238, + "supported_languages": null + }, + "macro.dbt.sync_column_schemas": { + "name": "sync_column_schemas", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/on_schema_change.sql", + "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", + "unique_id": "macro.dbt.sync_column_schemas", + "macro_sql": "{% macro sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {%- set add_to_target_arr = schema_changes_dict['source_not_in_target'] -%}\n\n {%- if on_schema_change == 'append_new_columns'-%}\n {%- if add_to_target_arr | length > 0 -%}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, none) -%}\n {%- endif -%}\n\n {% elif on_schema_change == 'sync_all_columns' %}\n {%- set remove_from_target_arr = schema_changes_dict['target_not_in_source'] -%}\n {%- set new_target_types = schema_changes_dict['new_target_types'] -%}\n\n {% if add_to_target_arr | length > 0 or remove_from_target_arr | length > 0 %}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, remove_from_target_arr) -%}\n {% endif %}\n\n {% if new_target_types != [] %}\n {% for ntt in new_target_types %}\n {% set column_name = ntt['column_name'] %}\n {% set new_type = ntt['new_type'] %}\n {% do alter_column_type(target_relation, column_name, new_type) %}\n {% endfor %}\n {% endif %}\n\n {% endif %}\n\n {% set schema_change_message %}\n In {{ target_relation }}:\n Schema change approach: {{ on_schema_change }}\n Columns added: {{ add_to_target_arr }}\n Columns removed: {{ remove_from_target_arr }}\n Data types changed: {{ new_target_types }}\n {% endset %}\n\n {% do log(schema_change_message) %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.alter_relation_add_remove_columns", + "macro.dbt.alter_column_type" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.432394, + "supported_languages": null + }, + "macro.dbt.process_schema_changes": { + "name": "process_schema_changes", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/incremental/on_schema_change.sql", + "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", + "unique_id": "macro.dbt.process_schema_changes", + "macro_sql": "{% macro process_schema_changes(on_schema_change, source_relation, target_relation) %}\n\n {% if on_schema_change == 'ignore' %}\n\n {{ return({}) }}\n\n {% else %}\n\n {% set schema_changes_dict = check_for_schema_changes(source_relation, target_relation) %}\n\n {% if schema_changes_dict['schema_changed'] %}\n\n {% if on_schema_change == 'fail' %}\n\n {% set fail_msg %}\n The source and target schemas on this incremental model are out of sync!\n They can be reconciled in several ways:\n - set the `on_schema_change` config to either append_new_columns or sync_all_columns, depending on your situation.\n - Re-run the incremental model with `full_refresh: True` to update the target schema.\n - update the schema manually and re-run the process.\n\n Additional troubleshooting context:\n Source columns not in target: {{ schema_changes_dict['source_not_in_target'] }}\n Target columns not in source: {{ schema_changes_dict['target_not_in_source'] }}\n New column types: {{ schema_changes_dict['new_target_types'] }}\n {% endset %}\n\n {% do exceptions.raise_compiler_error(fail_msg) %}\n\n {# -- unless we ignore, run the sync operation per the config #}\n {% else %}\n\n {% do sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {% endif %}\n\n {% endif %}\n\n {{ return(schema_changes_dict['source_columns']) }}\n\n {% endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.check_for_schema_changes", + "macro.dbt.sync_column_schemas" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.433219, + "supported_languages": null + }, + "macro.dbt.can_clone_table": { + "name": "can_clone_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/clone/can_clone_table.sql", + "original_file_path": "macros/materializations/models/clone/can_clone_table.sql", + "unique_id": "macro.dbt.can_clone_table", + "macro_sql": "{% macro can_clone_table() %}\n {{ return(adapter.dispatch('can_clone_table', 'dbt')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__can_clone_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.433453, + "supported_languages": null + }, + "macro.dbt.default__can_clone_table": { + "name": "default__can_clone_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/clone/can_clone_table.sql", + "original_file_path": "macros/materializations/models/clone/can_clone_table.sql", + "unique_id": "macro.dbt.default__can_clone_table", + "macro_sql": "{% macro default__can_clone_table() %}\n {{ return(False) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.433567, + "supported_languages": null + }, + "macro.dbt.create_or_replace_clone": { + "name": "create_or_replace_clone", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/clone/create_or_replace_clone.sql", + "original_file_path": "macros/materializations/models/clone/create_or_replace_clone.sql", + "unique_id": "macro.dbt.create_or_replace_clone", + "macro_sql": "{% macro create_or_replace_clone(this_relation, defer_relation) %}\n {{ return(adapter.dispatch('create_or_replace_clone', 'dbt')(this_relation, defer_relation)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__create_or_replace_clone" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4338508, + "supported_languages": null + }, + "macro.dbt.default__create_or_replace_clone": { + "name": "default__create_or_replace_clone", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/clone/create_or_replace_clone.sql", + "original_file_path": "macros/materializations/models/clone/create_or_replace_clone.sql", + "unique_id": "macro.dbt.default__create_or_replace_clone", + "macro_sql": "{% macro default__create_or_replace_clone(this_relation, defer_relation) %}\n create or replace table {{ this_relation }} clone {{ defer_relation }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.433982, + "supported_languages": null + }, + "macro.dbt.materialization_clone_default": { + "name": "materialization_clone_default", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/models/clone/clone.sql", + "original_file_path": "macros/materializations/models/clone/clone.sql", + "unique_id": "macro.dbt.materialization_clone_default", + "macro_sql": "{%- materialization clone, default -%}\n\n {%- set relations = {'relations': []} -%}\n\n {%- if not defer_relation -%}\n -- nothing to do\n {{ log(\"No relation found in state manifest for \" ~ model.unique_id, info=True) }}\n {{ return(relations) }}\n {%- endif -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n\n {%- if existing_relation and not flags.FULL_REFRESH -%}\n -- noop!\n {{ log(\"Relation \" ~ existing_relation ~ \" already exists\", info=True) }}\n {{ return(relations) }}\n {%- endif -%}\n\n {%- set other_existing_relation = load_cached_relation(defer_relation) -%}\n\n -- If this is a database that can do zero-copy cloning of tables, and the other relation is a table, then this will be a table\n -- Otherwise, this will be a view\n\n {% set can_clone_table = can_clone_table() %}\n\n {%- if other_existing_relation and other_existing_relation.type == 'table' and can_clone_table -%}\n\n {%- set target_relation = this.incorporate(type='table') -%}\n {% if existing_relation is not none and not existing_relation.is_table %}\n {{ log(\"Dropping relation \" ~ existing_relation ~ \" because it is of type \" ~ existing_relation.type) }}\n {{ drop_relation_if_exists(existing_relation) }}\n {% endif %}\n\n -- as a general rule, data platforms that can clone tables can also do atomic 'create or replace'\n {% call statement('main') %}\n {% if target_relation and defer_relation and target_relation == defer_relation %}\n {{ log(\"Target relation and defer relation are the same, skipping clone for relation: \" ~ target_relation) }}\n {% else %}\n {{ create_or_replace_clone(target_relation, defer_relation) }}\n {% endif %}\n\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n {% do persist_docs(target_relation, model) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n {%- else -%}\n\n {%- set target_relation = this.incorporate(type='view') -%}\n\n -- reuse the view materialization\n -- TODO: support actual dispatch for materialization macros\n -- Tracking ticket: https://github.com/dbt-labs/dbt-core/issues/7799\n {% set search_name = \"materialization_view_\" ~ adapter.type() %}\n {% if not search_name in context %}\n {% set search_name = \"materialization_view_default\" %}\n {% endif %}\n {% set materialization_macro = context[search_name] %}\n {% set relations = materialization_macro() %}\n {{ return(relations) }}\n\n {%- endif -%}\n\n{%- endmaterialization -%}", + "depends_on": { + "macros": [ + "macro.dbt.load_cached_relation", + "macro.dbt.can_clone_table", + "macro.dbt.drop_relation_if_exists", + "macro.dbt.statement", + "macro.dbt.create_or_replace_clone", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.437597, + "supported_languages": [ + "sql" + ] + }, + "macro.dbt.materialization_seed_default": { + "name": "materialization_seed_default", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/seeds/seed.sql", + "original_file_path": "macros/materializations/seeds/seed.sql", + "unique_id": "macro.dbt.materialization_seed_default", + "macro_sql": "{% materialization seed, default %}\n\n {%- set identifier = model['alias'] -%}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\n {%- set exists_as_table = (old_relation is not none and old_relation.is_table) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set grant_config = config.get('grants') -%}\n {%- set agate_table = load_agate_table() -%}\n -- grab current tables grants config for comparison later on\n\n {%- do store_result('agate_table', response='OK', agate_table=agate_table) -%}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% set create_table_sql = \"\" %}\n {% if exists_as_view %}\n {{ exceptions.raise_compiler_error(\"Cannot seed to '{}', it is a view\".format(old_relation)) }}\n {% elif exists_as_table %}\n {% set create_table_sql = reset_csv_table(model, full_refresh_mode, old_relation, agate_table) %}\n {% else %}\n {% set create_table_sql = create_csv_table(model, agate_table) %}\n {% endif %}\n\n {% set code = 'CREATE' if full_refresh_mode else 'INSERT' %}\n {% set rows_affected = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement('main', code ~ ' ' ~ rows_affected, code, rows_affected) %}\n {{ get_csv_sql(create_table_sql, sql) }};\n {% endcall %}\n\n {% set target_relation = this.incorporate(type='table') %}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if full_refresh_mode or not exists_as_table %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.dbt.should_full_refresh", + "macro.dbt.run_hooks", + "macro.dbt.reset_csv_table", + "macro.dbt.create_csv_table", + "macro.dbt.load_csv_rows", + "macro.dbt.noop_statement", + "macro.dbt.get_csv_sql", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants", + "macro.dbt.persist_docs", + "macro.dbt.create_indexes" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.440757, + "supported_languages": [ + "sql" + ] + }, + "macro.dbt.create_csv_table": { + "name": "create_csv_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "unique_id": "macro.dbt.create_csv_table", + "macro_sql": "{% macro create_csv_table(model, agate_table) -%}\n {{ adapter.dispatch('create_csv_table', 'dbt')(model, agate_table) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__create_csv_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.445956, + "supported_languages": null + }, + "macro.dbt.default__create_csv_table": { + "name": "default__create_csv_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "unique_id": "macro.dbt.default__create_csv_table", + "macro_sql": "{% macro default__create_csv_table(model, agate_table) %}\n {%- set column_override = model['config'].get('column_types', {}) -%}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n\n {% set sql %}\n create table {{ this.render() }} (\n {%- for col_name in agate_table.column_names -%}\n {%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}\n {%- set type = column_override.get(col_name, inferred_type) -%}\n {%- set column_name = (col_name | string) -%}\n {{ adapter.quote_seed_column(column_name, quote_seed_column) }} {{ type }} {%- if not loop.last -%}, {%- endif -%}\n {%- endfor -%}\n )\n {% endset %}\n\n {% call statement('_') -%}\n {{ sql }}\n {%- endcall %}\n\n {{ return(sql) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.446827, + "supported_languages": null + }, + "macro.dbt.reset_csv_table": { + "name": "reset_csv_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "unique_id": "macro.dbt.reset_csv_table", + "macro_sql": "{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter.dispatch('reset_csv_table', 'dbt')(model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__reset_csv_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.447059, + "supported_languages": null + }, + "macro.dbt.default__reset_csv_table": { + "name": "default__reset_csv_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "unique_id": "macro.dbt.default__reset_csv_table", + "macro_sql": "{% macro default__reset_csv_table(model, full_refresh, old_relation, agate_table) %}\n {% set sql = \"\" %}\n {% if full_refresh %}\n {{ adapter.drop_relation(old_relation) }}\n {% set sql = create_csv_table(model, agate_table) %}\n {% else %}\n {{ adapter.truncate_relation(old_relation) }}\n {% set sql = \"truncate table \" ~ old_relation %}\n {% endif %}\n\n {{ return(sql) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.create_csv_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.447526, + "supported_languages": null + }, + "macro.dbt.get_csv_sql": { + "name": "get_csv_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "unique_id": "macro.dbt.get_csv_sql", + "macro_sql": "{% macro get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ adapter.dispatch('get_csv_sql', 'dbt')(create_or_truncate_sql, insert_sql) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_csv_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4477131, + "supported_languages": null + }, + "macro.dbt.default__get_csv_sql": { + "name": "default__get_csv_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "unique_id": "macro.dbt.default__get_csv_sql", + "macro_sql": "{% macro default__get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ create_or_truncate_sql }};\n -- dbt seed --\n {{ insert_sql }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.447843, + "supported_languages": null + }, + "macro.dbt.get_binding_char": { + "name": "get_binding_char", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "unique_id": "macro.dbt.get_binding_char", + "macro_sql": "{% macro get_binding_char() -%}\n {{ adapter.dispatch('get_binding_char', 'dbt')() }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_binding_char" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.447978, + "supported_languages": null + }, + "macro.dbt.default__get_binding_char": { + "name": "default__get_binding_char", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "unique_id": "macro.dbt.default__get_binding_char", + "macro_sql": "{% macro default__get_binding_char() %}\n {{ return('%s') }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.448087, + "supported_languages": null + }, + "macro.dbt.get_batch_size": { + "name": "get_batch_size", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "unique_id": "macro.dbt.get_batch_size", + "macro_sql": "{% macro get_batch_size() -%}\n {{ return(adapter.dispatch('get_batch_size', 'dbt')()) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_batch_size" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4482381, + "supported_languages": null + }, + "macro.dbt.default__get_batch_size": { + "name": "default__get_batch_size", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "unique_id": "macro.dbt.default__get_batch_size", + "macro_sql": "{% macro default__get_batch_size() %}\n {{ return(10000) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.448352, + "supported_languages": null + }, + "macro.dbt.get_seed_column_quoted_csv": { + "name": "get_seed_column_quoted_csv", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "unique_id": "macro.dbt.get_seed_column_quoted_csv", + "macro_sql": "{% macro get_seed_column_quoted_csv(model, column_names) %}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote_seed_column(col, quote_seed_column)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.448809, + "supported_languages": null + }, + "macro.dbt.load_csv_rows": { + "name": "load_csv_rows", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "unique_id": "macro.dbt.load_csv_rows", + "macro_sql": "{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter.dispatch('load_csv_rows', 'dbt')(model, agate_table) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__load_csv_rows" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4489868, + "supported_languages": null + }, + "macro.dbt.default__load_csv_rows": { + "name": "default__load_csv_rows", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/materializations/seeds/helpers.sql", + "original_file_path": "macros/materializations/seeds/helpers.sql", + "unique_id": "macro.dbt.default__load_csv_rows", + "macro_sql": "{% macro default__load_csv_rows(model, agate_table) %}\n\n {% set batch_size = get_batch_size() %}\n\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n {{ get_binding_char() }}\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_batch_size", + "macro.dbt.get_seed_column_quoted_csv", + "macro.dbt.get_binding_char" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.450216, + "supported_languages": null + }, + "macro.dbt.generate_alias_name": { + "name": "generate_alias_name", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/get_custom_name/get_custom_alias.sql", + "original_file_path": "macros/get_custom_name/get_custom_alias.sql", + "unique_id": "macro.dbt.generate_alias_name", + "macro_sql": "{% macro generate_alias_name(custom_alias_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_alias_name', 'dbt')(custom_alias_name, node)) %}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__generate_alias_name" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4506319, + "supported_languages": null + }, + "macro.dbt.default__generate_alias_name": { + "name": "default__generate_alias_name", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/get_custom_name/get_custom_alias.sql", + "original_file_path": "macros/get_custom_name/get_custom_alias.sql", + "unique_id": "macro.dbt.default__generate_alias_name", + "macro_sql": "{% macro default__generate_alias_name(custom_alias_name=none, node=none) -%}\n\n {%- if custom_alias_name -%}\n\n {{ custom_alias_name | trim }}\n\n {%- elif node.version -%}\n\n {{ return(node.name ~ \"_v\" ~ (node.version | replace(\".\", \"_\"))) }}\n\n {%- else -%}\n\n {{ node.name }}\n\n {%- endif -%}\n\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4510021, + "supported_languages": null + }, + "macro.dbt.generate_schema_name": { + "name": "generate_schema_name", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/get_custom_name/get_custom_schema.sql", + "original_file_path": "macros/get_custom_name/get_custom_schema.sql", + "unique_id": "macro.dbt.generate_schema_name", + "macro_sql": "{% macro generate_schema_name(custom_schema_name=none, node=none) -%}\n {{ return(adapter.dispatch('generate_schema_name', 'dbt')(custom_schema_name, node)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__generate_schema_name" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.451512, + "supported_languages": null + }, + "macro.dbt.default__generate_schema_name": { + "name": "default__generate_schema_name", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/get_custom_name/get_custom_schema.sql", + "original_file_path": "macros/get_custom_name/get_custom_schema.sql", + "unique_id": "macro.dbt.default__generate_schema_name", + "macro_sql": "{% macro default__generate_schema_name(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if custom_schema_name is none -%}\n\n {{ default_schema }}\n\n {%- else -%}\n\n {{ default_schema }}_{{ custom_schema_name | trim }}\n\n {%- endif -%}\n\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.451765, + "supported_languages": null + }, + "macro.dbt.generate_schema_name_for_env": { + "name": "generate_schema_name_for_env", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/get_custom_name/get_custom_schema.sql", + "original_file_path": "macros/get_custom_name/get_custom_schema.sql", + "unique_id": "macro.dbt.generate_schema_name_for_env", + "macro_sql": "{% macro generate_schema_name_for_env(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if target.name == 'prod' and custom_schema_name is not none -%}\n\n {{ custom_schema_name | trim }}\n\n {%- else -%}\n\n {{ default_schema }}\n\n {%- endif -%}\n\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.452042, + "supported_languages": null + }, + "macro.dbt.generate_database_name": { + "name": "generate_database_name", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/get_custom_name/get_custom_database.sql", + "original_file_path": "macros/get_custom_name/get_custom_database.sql", + "unique_id": "macro.dbt.generate_database_name", + "macro_sql": "{% macro generate_database_name(custom_database_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_database_name', 'dbt')(custom_database_name, node)) %}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__generate_database_name" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.452428, + "supported_languages": null + }, + "macro.dbt.default__generate_database_name": { + "name": "default__generate_database_name", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/get_custom_name/get_custom_database.sql", + "original_file_path": "macros/get_custom_name/get_custom_database.sql", + "unique_id": "macro.dbt.default__generate_database_name", + "macro_sql": "{% macro default__generate_database_name(custom_database_name=none, node=none) -%}\n {%- set default_database = target.database -%}\n {%- if custom_database_name is none -%}\n\n {{ default_database }}\n\n {%- else -%}\n\n {{ custom_database_name }}\n\n {%- endif -%}\n\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4526742, + "supported_languages": null + }, + "macro.dbt.get_drop_sql": { + "name": "get_drop_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/drop.sql", + "original_file_path": "macros/relations/drop.sql", + "unique_id": "macro.dbt.get_drop_sql", + "macro_sql": "{%- macro get_drop_sql(relation) -%}\n {{- log('Applying DROP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_drop_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_drop_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.453381, + "supported_languages": null + }, + "macro.dbt.default__get_drop_sql": { + "name": "default__get_drop_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/drop.sql", + "original_file_path": "macros/relations/drop.sql", + "unique_id": "macro.dbt.default__get_drop_sql", + "macro_sql": "{%- macro default__get_drop_sql(relation) -%}\n\n {%- if relation.is_view -%}\n {{ drop_view(relation) }}\n\n {%- elif relation.is_table -%}\n {{ drop_table(relation) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ drop_materialized_view(relation) }}\n\n {%- else -%}\n drop {{ relation.type }} if exists {{ relation }} cascade\n\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [ + "macro.dbt.drop_view", + "macro.dbt.drop_table", + "macro.dbt.drop_materialized_view" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.453742, + "supported_languages": null + }, + "macro.dbt.drop_relation": { + "name": "drop_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/drop.sql", + "original_file_path": "macros/relations/drop.sql", + "unique_id": "macro.dbt.drop_relation", + "macro_sql": "{% macro drop_relation(relation) -%}\n {{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__drop_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.453919, + "supported_languages": null + }, + "macro.dbt.default__drop_relation": { + "name": "default__drop_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/drop.sql", + "original_file_path": "macros/relations/drop.sql", + "unique_id": "macro.dbt.default__drop_relation", + "macro_sql": "{% macro default__drop_relation(relation) -%}\n {% call statement('drop_relation', auto_begin=False) -%}\n {{ get_drop_sql(relation) }}\n {%- endcall %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.dbt.get_drop_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.454109, + "supported_languages": null + }, + "macro.dbt.drop_relation_if_exists": { + "name": "drop_relation_if_exists", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/drop.sql", + "original_file_path": "macros/relations/drop.sql", + "unique_id": "macro.dbt.drop_relation_if_exists", + "macro_sql": "{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.454297, + "supported_languages": null + }, + "macro.dbt.get_replace_sql": { + "name": "get_replace_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/replace.sql", + "original_file_path": "macros/relations/replace.sql", + "unique_id": "macro.dbt.get_replace_sql", + "macro_sql": "{% macro get_replace_sql(existing_relation, target_relation, sql) %}\n {{- log('Applying REPLACE to: ' ~ existing_relation) -}}\n {{- adapter.dispatch('get_replace_sql', 'dbt')(existing_relation, target_relation, sql) -}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_replace_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.45507, + "supported_languages": null + }, + "macro.dbt.default__get_replace_sql": { + "name": "default__get_replace_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/replace.sql", + "original_file_path": "macros/relations/replace.sql", + "unique_id": "macro.dbt.default__get_replace_sql", + "macro_sql": "{% macro default__get_replace_sql(existing_relation, target_relation, sql) %}\n\n {# /* use a create or replace statement if possible */ #}\n\n {% set is_replaceable = existing_relation.type == target_relation_type and existing_relation.can_be_replaced %}\n\n {% if is_replaceable and existing_relation.is_view %}\n {{ get_replace_view_sql(target_relation, sql) }}\n\n {% elif is_replaceable and existing_relation.is_table %}\n {{ get_replace_table_sql(target_relation, sql) }}\n\n {% elif is_replaceable and existing_relation.is_materialized_view %}\n {{ get_replace_materialized_view_sql(target_relation, sql) }}\n\n {# /* a create or replace statement is not possible, so try to stage and/or backup to be safe */ #}\n\n {# /* create target_relation as an intermediate relation, then swap it out with the existing one using a backup */ #}\n {%- elif target_relation.can_be_renamed and existing_relation.can_be_renamed -%}\n {{ get_create_intermediate_sql(target_relation, sql) }};\n {{ get_create_backup_sql(existing_relation) }};\n {{ get_rename_intermediate_sql(target_relation) }};\n {{ get_drop_backup_sql(existing_relation) }}\n\n {# /* create target_relation as an intermediate relation, then swap it out with the existing one without using a backup */ #}\n {%- elif target_relation.can_be_renamed -%}\n {{ get_create_intermediate_sql(target_relation, sql) }};\n {{ get_drop_sql(existing_relation) }};\n {{ get_rename_intermediate_sql(target_relation) }}\n\n {# /* create target_relation in place by first backing up the existing relation */ #}\n {%- elif existing_relation.can_be_renamed -%}\n {{ get_create_backup_sql(existing_relation) }};\n {{ get_create_sql(target_relation, sql) }};\n {{ get_drop_backup_sql(existing_relation) }}\n\n {# /* no renaming is allowed, so just drop and create */ #}\n {%- else -%}\n {{ get_drop_sql(existing_relation) }};\n {{ get_create_sql(target_relation, sql) }}\n\n {%- endif -%}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_replace_view_sql", + "macro.dbt.get_replace_table_sql", + "macro.dbt.get_replace_materialized_view_sql", + "macro.dbt.get_create_intermediate_sql", + "macro.dbt.get_create_backup_sql", + "macro.dbt.get_rename_intermediate_sql", + "macro.dbt.get_drop_backup_sql", + "macro.dbt.get_drop_sql", + "macro.dbt.get_create_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4563022, + "supported_languages": null + }, + "macro.dbt.get_create_intermediate_sql": { + "name": "get_create_intermediate_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/create_intermediate.sql", + "original_file_path": "macros/relations/create_intermediate.sql", + "unique_id": "macro.dbt.get_create_intermediate_sql", + "macro_sql": "{%- macro get_create_intermediate_sql(relation, sql) -%}\n {{- log('Applying CREATE INTERMEDIATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_intermediate_sql', 'dbt')(relation, sql) -}}\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__get_create_intermediate_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.456673, + "supported_languages": null + }, + "macro.dbt.default__get_create_intermediate_sql": { + "name": "default__get_create_intermediate_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/create_intermediate.sql", + "original_file_path": "macros/relations/create_intermediate.sql", + "unique_id": "macro.dbt.default__get_create_intermediate_sql", + "macro_sql": "{%- macro default__get_create_intermediate_sql(relation, sql) -%}\n\n -- get the standard intermediate name\n {% set intermediate_relation = make_intermediate_relation(relation) %}\n\n -- drop any pre-existing intermediate\n {{ get_drop_sql(intermediate_relation) }};\n\n {{ get_create_sql(intermediate_relation, sql) }}\n\n{%- endmacro -%}", + "depends_on": { + "macros": [ + "macro.dbt.make_intermediate_relation", + "macro.dbt.get_drop_sql", + "macro.dbt.get_create_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.456917, + "supported_languages": null + }, + "macro.dbt.get_drop_backup_sql": { + "name": "get_drop_backup_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/drop_backup.sql", + "original_file_path": "macros/relations/drop_backup.sql", + "unique_id": "macro.dbt.get_drop_backup_sql", + "macro_sql": "{%- macro get_drop_backup_sql(relation) -%}\n {{- log('Applying DROP BACKUP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_drop_backup_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__get_drop_backup_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.457226, + "supported_languages": null + }, + "macro.dbt.default__get_drop_backup_sql": { + "name": "default__get_drop_backup_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/drop_backup.sql", + "original_file_path": "macros/relations/drop_backup.sql", + "unique_id": "macro.dbt.default__get_drop_backup_sql", + "macro_sql": "{%- macro default__get_drop_backup_sql(relation) -%}\n\n -- get the standard backup name\n {% set backup_relation = make_backup_relation(relation, relation.type) %}\n\n {{ get_drop_sql(backup_relation) }}\n\n{%- endmacro -%}", + "depends_on": { + "macros": [ + "macro.dbt.make_backup_relation", + "macro.dbt.get_drop_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.457428, + "supported_languages": null + }, + "macro.dbt.get_rename_sql": { + "name": "get_rename_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/rename.sql", + "original_file_path": "macros/relations/rename.sql", + "unique_id": "macro.dbt.get_rename_sql", + "macro_sql": "{%- macro get_rename_sql(relation, new_name) -%}\n {{- log('Applying RENAME to: ' ~ relation) -}}\n {{- adapter.dispatch('get_rename_sql', 'dbt')(relation, new_name) -}}\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__get_rename_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.458123, + "supported_languages": null + }, + "macro.dbt.default__get_rename_sql": { + "name": "default__get_rename_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/rename.sql", + "original_file_path": "macros/relations/rename.sql", + "unique_id": "macro.dbt.default__get_rename_sql", + "macro_sql": "{%- macro default__get_rename_sql(relation, new_name) -%}\n\n {%- if relation.is_view -%}\n {{ get_rename_view_sql(relation, new_name) }}\n\n {%- elif relation.is_table -%}\n {{ get_rename_table_sql(relation, new_name) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ get_rename_materialized_view_sql(relation, new_name) }}\n\n {%- else -%}\n {{- exceptions.raise_compiler_error(\"`get_rename_sql` has not been implemented for: \" ~ relation.type ) -}}\n\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [ + "macro.dbt.get_rename_view_sql", + "macro.dbt.get_rename_table_sql", + "macro.dbt.get_rename_materialized_view_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.458544, + "supported_languages": null + }, + "macro.dbt.rename_relation": { + "name": "rename_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/rename.sql", + "original_file_path": "macros/relations/rename.sql", + "unique_id": "macro.dbt.rename_relation", + "macro_sql": "{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter.dispatch('rename_relation', 'dbt')(from_relation, to_relation)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__rename_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.458745, + "supported_languages": null + }, + "macro.dbt.default__rename_relation": { + "name": "default__rename_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/rename.sql", + "original_file_path": "macros/relations/rename.sql", + "unique_id": "macro.dbt.default__rename_relation", + "macro_sql": "{% macro default__rename_relation(from_relation, to_relation) -%}\n {% set target_name = adapter.quote_as_configured(to_relation.identifier, 'identifier') %}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ target_name }}\n {%- endcall %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.459019, + "supported_languages": null + }, + "macro.dbt.get_create_backup_sql": { + "name": "get_create_backup_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/create_backup.sql", + "original_file_path": "macros/relations/create_backup.sql", + "unique_id": "macro.dbt.get_create_backup_sql", + "macro_sql": "{%- macro get_create_backup_sql(relation) -%}\n {{- log('Applying CREATE BACKUP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_backup_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__get_create_backup_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.459359, + "supported_languages": null + }, + "macro.dbt.default__get_create_backup_sql": { + "name": "default__get_create_backup_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/create_backup.sql", + "original_file_path": "macros/relations/create_backup.sql", + "unique_id": "macro.dbt.default__get_create_backup_sql", + "macro_sql": "{%- macro default__get_create_backup_sql(relation) -%}\n\n -- get the standard backup name\n {% set backup_relation = make_backup_relation(relation, relation.type) %}\n\n -- drop any pre-existing backup\n {{ get_drop_sql(backup_relation) }};\n\n {{ get_rename_sql(relation, backup_relation.identifier) }}\n\n{%- endmacro -%}", + "depends_on": { + "macros": [ + "macro.dbt.make_backup_relation", + "macro.dbt.get_drop_sql", + "macro.dbt.get_rename_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4596229, + "supported_languages": null + }, + "macro.dbt.get_create_sql": { + "name": "get_create_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/create.sql", + "original_file_path": "macros/relations/create.sql", + "unique_id": "macro.dbt.get_create_sql", + "macro_sql": "{%- macro get_create_sql(relation, sql) -%}\n {{- log('Applying CREATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_sql', 'dbt')(relation, sql) -}}\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_create_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.460084, + "supported_languages": null + }, + "macro.dbt.default__get_create_sql": { + "name": "default__get_create_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/create.sql", + "original_file_path": "macros/relations/create.sql", + "unique_id": "macro.dbt.default__get_create_sql", + "macro_sql": "{%- macro default__get_create_sql(relation, sql) -%}\n\n {%- if relation.is_view -%}\n {{ get_create_view_as_sql(relation, sql) }}\n\n {%- elif relation.is_table -%}\n {{ get_create_table_as_sql(False, relation, sql) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ get_create_materialized_view_as_sql(relation, sql) }}\n\n {%- else -%}\n {{- exceptions.raise_compiler_error(\"`get_create_sql` has not been implemented for: \" ~ relation.type ) -}}\n\n {%- endif -%}\n\n{%- endmacro -%}", + "depends_on": { + "macros": [ + "macro.dbt.get_create_view_as_sql", + "macro.dbt.get_create_table_as_sql", + "macro.dbt.get_create_materialized_view_as_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.460514, + "supported_languages": null + }, + "macro.dbt.get_rename_intermediate_sql": { + "name": "get_rename_intermediate_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/rename_intermediate.sql", + "original_file_path": "macros/relations/rename_intermediate.sql", + "unique_id": "macro.dbt.get_rename_intermediate_sql", + "macro_sql": "{%- macro get_rename_intermediate_sql(relation) -%}\n {{- log('Applying RENAME INTERMEDIATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_rename_intermediate_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__get_rename_intermediate_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.460831, + "supported_languages": null + }, + "macro.dbt.default__get_rename_intermediate_sql": { + "name": "default__get_rename_intermediate_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/rename_intermediate.sql", + "original_file_path": "macros/relations/rename_intermediate.sql", + "unique_id": "macro.dbt.default__get_rename_intermediate_sql", + "macro_sql": "{%- macro default__get_rename_intermediate_sql(relation) -%}\n\n -- get the standard intermediate name\n {% set intermediate_relation = make_intermediate_relation(relation) %}\n\n {{ get_rename_sql(intermediate_relation, relation.identifier) }}\n\n{%- endmacro -%}", + "depends_on": { + "macros": [ + "macro.dbt.make_intermediate_relation", + "macro.dbt.get_rename_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4610372, + "supported_languages": null + }, + "macro.dbt.drop_materialized_view": { + "name": "drop_materialized_view", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/materialized_view/drop.sql", + "original_file_path": "macros/relations/materialized_view/drop.sql", + "unique_id": "macro.dbt.drop_materialized_view", + "macro_sql": "{% macro drop_materialized_view(relation) -%}\n {{ return(adapter.dispatch('drop_materialized_view', 'dbt')(relation)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__drop_materialized_view" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4612968, + "supported_languages": null + }, + "macro.dbt.default__drop_materialized_view": { + "name": "default__drop_materialized_view", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/materialized_view/drop.sql", + "original_file_path": "macros/relations/materialized_view/drop.sql", + "unique_id": "macro.dbt.default__drop_materialized_view", + "macro_sql": "{% macro default__drop_materialized_view(relation) -%}\n drop materialized view if exists {{ relation }} cascade\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.461403, + "supported_languages": null + }, + "macro.dbt.get_replace_materialized_view_sql": { + "name": "get_replace_materialized_view_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/materialized_view/replace.sql", + "original_file_path": "macros/relations/materialized_view/replace.sql", + "unique_id": "macro.dbt.get_replace_materialized_view_sql", + "macro_sql": "{% macro get_replace_materialized_view_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_materialized_view_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_replace_materialized_view_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.461666, + "supported_languages": null + }, + "macro.dbt.default__get_replace_materialized_view_sql": { + "name": "default__get_replace_materialized_view_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/materialized_view/replace.sql", + "original_file_path": "macros/relations/materialized_view/replace.sql", + "unique_id": "macro.dbt.default__get_replace_materialized_view_sql", + "macro_sql": "{% macro default__get_replace_materialized_view_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_materialized_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.461812, + "supported_languages": null + }, + "macro.dbt.refresh_materialized_view": { + "name": "refresh_materialized_view", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/materialized_view/refresh.sql", + "original_file_path": "macros/relations/materialized_view/refresh.sql", + "unique_id": "macro.dbt.refresh_materialized_view", + "macro_sql": "{% macro refresh_materialized_view(relation) %}\n {{- log('Applying REFRESH to: ' ~ relation) -}}\n {{- adapter.dispatch('refresh_materialized_view', 'dbt')(relation) -}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__refresh_materialized_view" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.46211, + "supported_languages": null + }, + "macro.dbt.default__refresh_materialized_view": { + "name": "default__refresh_materialized_view", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/materialized_view/refresh.sql", + "original_file_path": "macros/relations/materialized_view/refresh.sql", + "unique_id": "macro.dbt.default__refresh_materialized_view", + "macro_sql": "{% macro default__refresh_materialized_view(relation) %}\n {{ exceptions.raise_compiler_error(\"`refresh_materialized_view` has not been implemented for this adapter.\") }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.462303, + "supported_languages": null + }, + "macro.dbt.get_rename_materialized_view_sql": { + "name": "get_rename_materialized_view_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/materialized_view/rename.sql", + "original_file_path": "macros/relations/materialized_view/rename.sql", + "unique_id": "macro.dbt.get_rename_materialized_view_sql", + "macro_sql": "{% macro get_rename_materialized_view_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_materialized_view_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_rename_materialized_view_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.462569, + "supported_languages": null + }, + "macro.dbt.default__get_rename_materialized_view_sql": { + "name": "default__get_rename_materialized_view_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/materialized_view/rename.sql", + "original_file_path": "macros/relations/materialized_view/rename.sql", + "unique_id": "macro.dbt.default__get_rename_materialized_view_sql", + "macro_sql": "{% macro default__get_rename_materialized_view_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_materialized_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.462712, + "supported_languages": null + }, + "macro.dbt.get_alter_materialized_view_as_sql": { + "name": "get_alter_materialized_view_as_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/materialized_view/alter.sql", + "original_file_path": "macros/relations/materialized_view/alter.sql", + "unique_id": "macro.dbt.get_alter_materialized_view_as_sql", + "macro_sql": "{% macro get_alter_materialized_view_as_sql(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n) %}\n {{- log('Applying ALTER to: ' ~ relation) -}}\n {{- adapter.dispatch('get_alter_materialized_view_as_sql', 'dbt')(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n ) -}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_alter_materialized_view_as_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4633129, + "supported_languages": null + }, + "macro.dbt.default__get_alter_materialized_view_as_sql": { + "name": "default__get_alter_materialized_view_as_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/materialized_view/alter.sql", + "original_file_path": "macros/relations/materialized_view/alter.sql", + "unique_id": "macro.dbt.default__get_alter_materialized_view_as_sql", + "macro_sql": "{% macro default__get_alter_materialized_view_as_sql(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n) %}\n {{ exceptions.raise_compiler_error(\"Materialized views have not been implemented for this adapter.\") }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.463499, + "supported_languages": null + }, + "macro.dbt.get_materialized_view_configuration_changes": { + "name": "get_materialized_view_configuration_changes", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/materialized_view/alter.sql", + "original_file_path": "macros/relations/materialized_view/alter.sql", + "unique_id": "macro.dbt.get_materialized_view_configuration_changes", + "macro_sql": "{% macro get_materialized_view_configuration_changes(existing_relation, new_config) %}\n /* {#\n It's recommended that configuration changes be formatted as follows:\n {\"\": [{\"action\": \"\", \"context\": ...}]}\n\n For example:\n {\n \"indexes\": [\n {\"action\": \"drop\", \"context\": \"index_abc\"},\n {\"action\": \"create\", \"context\": {\"columns\": [\"column_1\", \"column_2\"], \"type\": \"hash\", \"unique\": True}},\n ],\n }\n\n Either way, `get_materialized_view_configuration_changes` needs to align with `get_alter_materialized_view_as_sql`.\n #} */\n {{- log('Determining configuration changes on: ' ~ existing_relation) -}}\n {%- do return(adapter.dispatch('get_materialized_view_configuration_changes', 'dbt')(existing_relation, new_config)) -%}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_materialized_view_configuration_changes" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4637718, + "supported_languages": null + }, + "macro.dbt.default__get_materialized_view_configuration_changes": { + "name": "default__get_materialized_view_configuration_changes", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/materialized_view/alter.sql", + "original_file_path": "macros/relations/materialized_view/alter.sql", + "unique_id": "macro.dbt.default__get_materialized_view_configuration_changes", + "macro_sql": "{% macro default__get_materialized_view_configuration_changes(existing_relation, new_config) %}\n {{ exceptions.raise_compiler_error(\"Materialized views have not been implemented for this adapter.\") }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.463912, + "supported_languages": null + }, + "macro.dbt.get_create_materialized_view_as_sql": { + "name": "get_create_materialized_view_as_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/materialized_view/create.sql", + "original_file_path": "macros/relations/materialized_view/create.sql", + "unique_id": "macro.dbt.get_create_materialized_view_as_sql", + "macro_sql": "{% macro get_create_materialized_view_as_sql(relation, sql) -%}\n {{- adapter.dispatch('get_create_materialized_view_as_sql', 'dbt')(relation, sql) -}}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_create_materialized_view_as_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.46418, + "supported_languages": null + }, + "macro.dbt.default__get_create_materialized_view_as_sql": { + "name": "default__get_create_materialized_view_as_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/materialized_view/create.sql", + "original_file_path": "macros/relations/materialized_view/create.sql", + "unique_id": "macro.dbt.default__get_create_materialized_view_as_sql", + "macro_sql": "{% macro default__get_create_materialized_view_as_sql(relation, sql) -%}\n {{ exceptions.raise_compiler_error(\n \"`get_create_materialized_view_as_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4643211, + "supported_languages": null + }, + "macro.dbt.get_table_columns_and_constraints": { + "name": "get_table_columns_and_constraints", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/column/columns_spec_ddl.sql", + "original_file_path": "macros/relations/column/columns_spec_ddl.sql", + "unique_id": "macro.dbt.get_table_columns_and_constraints", + "macro_sql": "{%- macro get_table_columns_and_constraints() -%}\n {{ adapter.dispatch('get_table_columns_and_constraints', 'dbt')() }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__get_table_columns_and_constraints" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.465307, + "supported_languages": null + }, + "macro.dbt.default__get_table_columns_and_constraints": { + "name": "default__get_table_columns_and_constraints", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/column/columns_spec_ddl.sql", + "original_file_path": "macros/relations/column/columns_spec_ddl.sql", + "unique_id": "macro.dbt.default__get_table_columns_and_constraints", + "macro_sql": "{% macro default__get_table_columns_and_constraints() -%}\n {{ return(table_columns_and_constraints()) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.table_columns_and_constraints" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.465425, + "supported_languages": null + }, + "macro.dbt.table_columns_and_constraints": { + "name": "table_columns_and_constraints", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/column/columns_spec_ddl.sql", + "original_file_path": "macros/relations/column/columns_spec_ddl.sql", + "unique_id": "macro.dbt.table_columns_and_constraints", + "macro_sql": "{% macro table_columns_and_constraints() %}\n {# loop through user_provided_columns to create DDL with data types and constraints #}\n {%- set raw_column_constraints = adapter.render_raw_columns_constraints(raw_columns=model['columns']) -%}\n {%- set raw_model_constraints = adapter.render_raw_model_constraints(raw_constraints=model['constraints']) -%}\n (\n {% for c in raw_column_constraints -%}\n {{ c }}{{ \",\" if not loop.last or raw_model_constraints }}\n {% endfor %}\n {% for c in raw_model_constraints -%}\n {{ c }}{{ \",\" if not loop.last }}\n {% endfor -%}\n )\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4659379, + "supported_languages": null + }, + "macro.dbt.get_assert_columns_equivalent": { + "name": "get_assert_columns_equivalent", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/column/columns_spec_ddl.sql", + "original_file_path": "macros/relations/column/columns_spec_ddl.sql", + "unique_id": "macro.dbt.get_assert_columns_equivalent", + "macro_sql": "\n\n{%- macro get_assert_columns_equivalent(sql) -%}\n {{ adapter.dispatch('get_assert_columns_equivalent', 'dbt')(sql) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__get_assert_columns_equivalent" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4661, + "supported_languages": null + }, + "macro.dbt.default__get_assert_columns_equivalent": { + "name": "default__get_assert_columns_equivalent", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/column/columns_spec_ddl.sql", + "original_file_path": "macros/relations/column/columns_spec_ddl.sql", + "unique_id": "macro.dbt.default__get_assert_columns_equivalent", + "macro_sql": "{% macro default__get_assert_columns_equivalent(sql) -%}\n {{ return(assert_columns_equivalent(sql)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.assert_columns_equivalent" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.466229, + "supported_languages": null + }, + "macro.dbt.assert_columns_equivalent": { + "name": "assert_columns_equivalent", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/column/columns_spec_ddl.sql", + "original_file_path": "macros/relations/column/columns_spec_ddl.sql", + "unique_id": "macro.dbt.assert_columns_equivalent", + "macro_sql": "{% macro assert_columns_equivalent(sql) %}\n\n {#-- First ensure the user has defined 'columns' in yaml specification --#}\n {%- set user_defined_columns = model['columns'] -%}\n {%- if not user_defined_columns -%}\n {{ exceptions.raise_contract_error([], []) }}\n {%- endif -%}\n\n {#-- Obtain the column schema provided by sql file. #}\n {%- set sql_file_provided_columns = get_column_schema_from_query(sql, config.get('sql_header', none)) -%}\n {#--Obtain the column schema provided by the schema file by generating an 'empty schema' query from the model's columns. #}\n {%- set schema_file_provided_columns = get_column_schema_from_query(get_empty_schema_sql(user_defined_columns)) -%}\n\n {#-- create dictionaries with name and formatted data type and strings for exception #}\n {%- set sql_columns = format_columns(sql_file_provided_columns) -%}\n {%- set yaml_columns = format_columns(schema_file_provided_columns) -%}\n\n {%- if sql_columns|length != yaml_columns|length -%}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n\n {%- for sql_col in sql_columns -%}\n {%- set yaml_col = [] -%}\n {%- for this_col in yaml_columns -%}\n {%- if this_col['name'] == sql_col['name'] -%}\n {%- do yaml_col.append(this_col) -%}\n {%- break -%}\n {%- endif -%}\n {%- endfor -%}\n {%- if not yaml_col -%}\n {#-- Column with name not found in yaml #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- if sql_col['formatted'] != yaml_col[0]['formatted'] -%}\n {#-- Column data types don't match #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- endfor -%}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_column_schema_from_query", + "macro.dbt.get_empty_schema_sql", + "macro.dbt.format_columns" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.467505, + "supported_languages": null + }, + "macro.dbt.format_columns": { + "name": "format_columns", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/column/columns_spec_ddl.sql", + "original_file_path": "macros/relations/column/columns_spec_ddl.sql", + "unique_id": "macro.dbt.format_columns", + "macro_sql": "{% macro format_columns(columns) %}\n {% set formatted_columns = [] %}\n {% for column in columns %}\n {%- set formatted_column = adapter.dispatch('format_column', 'dbt')(column) -%}\n {%- do formatted_columns.append(formatted_column) -%}\n {% endfor %}\n {{ return(formatted_columns) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__format_column" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.467874, + "supported_languages": null + }, + "macro.dbt.default__format_column": { + "name": "default__format_column", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/column/columns_spec_ddl.sql", + "original_file_path": "macros/relations/column/columns_spec_ddl.sql", + "unique_id": "macro.dbt.default__format_column", + "macro_sql": "{% macro default__format_column(column) -%}\n {% set data_type = column.dtype %}\n {% set formatted = column.column.lower() ~ \" \" ~ data_type %}\n {{ return({'name': column.name, 'data_type': data_type, 'formatted': formatted}) }}\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.468208, + "supported_languages": null + }, + "macro.dbt.drop_table": { + "name": "drop_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/table/drop.sql", + "original_file_path": "macros/relations/table/drop.sql", + "unique_id": "macro.dbt.drop_table", + "macro_sql": "{% macro drop_table(relation) -%}\n {{ return(adapter.dispatch('drop_table', 'dbt')(relation)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__drop_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.468469, + "supported_languages": null + }, + "macro.dbt.default__drop_table": { + "name": "default__drop_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/table/drop.sql", + "original_file_path": "macros/relations/table/drop.sql", + "unique_id": "macro.dbt.default__drop_table", + "macro_sql": "{% macro default__drop_table(relation) -%}\n drop table if exists {{ relation }} cascade\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.468571, + "supported_languages": null + }, + "macro.dbt.get_replace_table_sql": { + "name": "get_replace_table_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/table/replace.sql", + "original_file_path": "macros/relations/table/replace.sql", + "unique_id": "macro.dbt.get_replace_table_sql", + "macro_sql": "{% macro get_replace_table_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_table_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_replace_table_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.468835, + "supported_languages": null + }, + "macro.dbt.default__get_replace_table_sql": { + "name": "default__get_replace_table_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/table/replace.sql", + "original_file_path": "macros/relations/table/replace.sql", + "unique_id": "macro.dbt.default__get_replace_table_sql", + "macro_sql": "{% macro default__get_replace_table_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_table_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.468978, + "supported_languages": null + }, + "macro.dbt.get_rename_table_sql": { + "name": "get_rename_table_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/table/rename.sql", + "original_file_path": "macros/relations/table/rename.sql", + "unique_id": "macro.dbt.get_rename_table_sql", + "macro_sql": "{% macro get_rename_table_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_table_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_rename_table_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4692411, + "supported_languages": null + }, + "macro.dbt.default__get_rename_table_sql": { + "name": "default__get_rename_table_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/table/rename.sql", + "original_file_path": "macros/relations/table/rename.sql", + "unique_id": "macro.dbt.default__get_rename_table_sql", + "macro_sql": "{% macro default__get_rename_table_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_table_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.469383, + "supported_languages": null + }, + "macro.dbt.get_create_table_as_sql": { + "name": "get_create_table_as_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/table/create.sql", + "original_file_path": "macros/relations/table/create.sql", + "unique_id": "macro.dbt.get_create_table_as_sql", + "macro_sql": "{% macro get_create_table_as_sql(temporary, relation, sql) -%}\n {{ adapter.dispatch('get_create_table_as_sql', 'dbt')(temporary, relation, sql) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_create_table_as_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.470224, + "supported_languages": null + }, + "macro.dbt.default__get_create_table_as_sql": { + "name": "default__get_create_table_as_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/table/create.sql", + "original_file_path": "macros/relations/table/create.sql", + "unique_id": "macro.dbt.default__get_create_table_as_sql", + "macro_sql": "{% macro default__get_create_table_as_sql(temporary, relation, sql) -%}\n {{ return(create_table_as(temporary, relation, sql)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.470407, + "supported_languages": null + }, + "macro.dbt.create_table_as": { + "name": "create_table_as", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/table/create.sql", + "original_file_path": "macros/relations/table/create.sql", + "unique_id": "macro.dbt.create_table_as", + "macro_sql": "{% macro create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {# backward compatibility for create_table_as that does not support language #}\n {% if language == \"sql\" %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code)}}\n {% else %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code, language) }}\n {% endif %}\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.470825, + "supported_languages": null + }, + "macro.dbt.default__create_table_as": { + "name": "default__create_table_as", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/table/create.sql", + "original_file_path": "macros/relations/table/create.sql", + "unique_id": "macro.dbt.default__create_table_as", + "macro_sql": "{% macro default__create_table_as(temporary, relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary: -%}temporary{%- endif %} table\n {{ relation.include(database=(not temporary), schema=(not temporary)) }}\n {% set contract_config = config.get('contract') %}\n {% if contract_config.enforced and (not temporary) %}\n {{ get_assert_columns_equivalent(sql) }}\n {{ get_table_columns_and_constraints() }}\n {%- set sql = get_select_subquery(sql) %}\n {% endif %}\n as (\n {{ sql }}\n );\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_assert_columns_equivalent", + "macro.dbt.get_table_columns_and_constraints", + "macro.dbt.get_select_subquery" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.471487, + "supported_languages": null + }, + "macro.dbt.default__get_column_names": { + "name": "default__get_column_names", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/table/create.sql", + "original_file_path": "macros/relations/table/create.sql", + "unique_id": "macro.dbt.default__get_column_names", + "macro_sql": "{% macro default__get_column_names() %}\n {#- loop through user_provided_columns to get column names -#}\n {%- set user_provided_columns = model['columns'] -%}\n {%- for i in user_provided_columns %}\n {%- set col = user_provided_columns[i] -%}\n {%- set col_name = adapter.quote(col['name']) if col.get('quote') else col['name'] -%}\n {{ col_name }}{{ \", \" if not loop.last }}\n {%- endfor -%}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.471931, + "supported_languages": null + }, + "macro.dbt.get_select_subquery": { + "name": "get_select_subquery", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/table/create.sql", + "original_file_path": "macros/relations/table/create.sql", + "unique_id": "macro.dbt.get_select_subquery", + "macro_sql": "{% macro get_select_subquery(sql) %}\n {{ return(adapter.dispatch('get_select_subquery', 'dbt')(sql)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_select_subquery" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.472111, + "supported_languages": null + }, + "macro.dbt.default__get_select_subquery": { + "name": "default__get_select_subquery", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/table/create.sql", + "original_file_path": "macros/relations/table/create.sql", + "unique_id": "macro.dbt.default__get_select_subquery", + "macro_sql": "{% macro default__get_select_subquery(sql) %}\n select {{ adapter.dispatch('get_column_names', 'dbt')() }}\n from (\n {{ sql }}\n ) as model_subq\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_column_names" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.472279, + "supported_languages": null + }, + "macro.dbt.drop_view": { + "name": "drop_view", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/view/drop.sql", + "original_file_path": "macros/relations/view/drop.sql", + "unique_id": "macro.dbt.drop_view", + "macro_sql": "{% macro drop_view(relation) -%}\n {{ return(adapter.dispatch('drop_view', 'dbt')(relation)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__drop_view" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.472536, + "supported_languages": null + }, + "macro.dbt.default__drop_view": { + "name": "default__drop_view", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/view/drop.sql", + "original_file_path": "macros/relations/view/drop.sql", + "unique_id": "macro.dbt.default__drop_view", + "macro_sql": "{% macro default__drop_view(relation) -%}\n drop view if exists {{ relation }} cascade\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.47264, + "supported_languages": null + }, + "macro.dbt.get_replace_view_sql": { + "name": "get_replace_view_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/view/replace.sql", + "original_file_path": "macros/relations/view/replace.sql", + "unique_id": "macro.dbt.get_replace_view_sql", + "macro_sql": "{% macro get_replace_view_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_view_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_replace_view_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.473496, + "supported_languages": null + }, + "macro.dbt.default__get_replace_view_sql": { + "name": "default__get_replace_view_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/view/replace.sql", + "original_file_path": "macros/relations/view/replace.sql", + "unique_id": "macro.dbt.default__get_replace_view_sql", + "macro_sql": "{% macro default__get_replace_view_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.473639, + "supported_languages": null + }, + "macro.dbt.create_or_replace_view": { + "name": "create_or_replace_view", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/view/replace.sql", + "original_file_path": "macros/relations/view/replace.sql", + "unique_id": "macro.dbt.create_or_replace_view", + "macro_sql": "{% macro create_or_replace_view() %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database,\n type='view') -%}\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks) }}\n\n -- If there's a table with the same name and we weren't told to full refresh,\n -- that's an error. If we were told to full refresh, drop it. This behavior differs\n -- for Snowflake and BigQuery, so multiple dispatch is used.\n {%- if old_relation is not none and old_relation.is_table -%}\n {{ handle_existing_table(should_full_refresh(), old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n\n {% set should_revoke = should_revoke(exists_as_view, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {{ run_hooks(post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.run_hooks", + "macro.dbt.handle_existing_table", + "macro.dbt.should_full_refresh", + "macro.dbt.statement", + "macro.dbt.get_create_view_as_sql", + "macro.dbt.should_revoke", + "macro.dbt.apply_grants" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4747882, + "supported_languages": null + }, + "macro.dbt.handle_existing_table": { + "name": "handle_existing_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/view/replace.sql", + "original_file_path": "macros/relations/view/replace.sql", + "unique_id": "macro.dbt.handle_existing_table", + "macro_sql": "{% macro handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.dispatch('handle_existing_table', 'dbt')(full_refresh, old_relation) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__handle_existing_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.474981, + "supported_languages": null + }, + "macro.dbt.default__handle_existing_table": { + "name": "default__handle_existing_table", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/view/replace.sql", + "original_file_path": "macros/relations/view/replace.sql", + "unique_id": "macro.dbt.default__handle_existing_table", + "macro_sql": "{% macro default__handle_existing_table(full_refresh, old_relation) %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ adapter.drop_relation(old_relation) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.475191, + "supported_languages": null + }, + "macro.dbt.get_rename_view_sql": { + "name": "get_rename_view_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/view/rename.sql", + "original_file_path": "macros/relations/view/rename.sql", + "unique_id": "macro.dbt.get_rename_view_sql", + "macro_sql": "{% macro get_rename_view_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_view_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_rename_view_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.475456, + "supported_languages": null + }, + "macro.dbt.default__get_rename_view_sql": { + "name": "default__get_rename_view_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/view/rename.sql", + "original_file_path": "macros/relations/view/rename.sql", + "unique_id": "macro.dbt.default__get_rename_view_sql", + "macro_sql": "{% macro default__get_rename_view_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.475596, + "supported_languages": null + }, + "macro.dbt.get_create_view_as_sql": { + "name": "get_create_view_as_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/view/create.sql", + "original_file_path": "macros/relations/view/create.sql", + "unique_id": "macro.dbt.get_create_view_as_sql", + "macro_sql": "{% macro get_create_view_as_sql(relation, sql) -%}\n {{ adapter.dispatch('get_create_view_as_sql', 'dbt')(relation, sql) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_create_view_as_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.475997, + "supported_languages": null + }, + "macro.dbt.default__get_create_view_as_sql": { + "name": "default__get_create_view_as_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/view/create.sql", + "original_file_path": "macros/relations/view/create.sql", + "unique_id": "macro.dbt.default__get_create_view_as_sql", + "macro_sql": "{% macro default__get_create_view_as_sql(relation, sql) -%}\n {{ return(create_view_as(relation, sql)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.create_view_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.476158, + "supported_languages": null + }, + "macro.dbt.create_view_as": { + "name": "create_view_as", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/view/create.sql", + "original_file_path": "macros/relations/view/create.sql", + "unique_id": "macro.dbt.create_view_as", + "macro_sql": "{% macro create_view_as(relation, sql) -%}\n {{ adapter.dispatch('create_view_as', 'dbt')(relation, sql) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__create_view_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.476331, + "supported_languages": null + }, + "macro.dbt.default__create_view_as": { + "name": "default__create_view_as", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/relations/view/create.sql", + "original_file_path": "macros/relations/view/create.sql", + "unique_id": "macro.dbt.default__create_view_as", + "macro_sql": "{% macro default__create_view_as(relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create view {{ relation }}\n {% set contract_config = config.get('contract') %}\n {% if contract_config.enforced %}\n {{ get_assert_columns_equivalent(sql) }}\n {%- endif %}\n as (\n {{ sql }}\n );\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_assert_columns_equivalent" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.476738, + "supported_languages": null + }, + "macro.dbt.default__test_relationships": { + "name": "default__test_relationships", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/generic_test_sql/relationships.sql", + "original_file_path": "macros/generic_test_sql/relationships.sql", + "unique_id": "macro.dbt.default__test_relationships", + "macro_sql": "{% macro default__test_relationships(model, column_name, to, field) %}\n\nwith child as (\n select {{ column_name }} as from_field\n from {{ model }}\n where {{ column_name }} is not null\n),\n\nparent as (\n select {{ field }} as to_field\n from {{ to }}\n)\n\nselect\n from_field\n\nfrom child\nleft join parent\n on child.from_field = parent.to_field\n\nwhere parent.to_field is null\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4770849, + "supported_languages": null + }, + "macro.dbt.default__test_not_null": { + "name": "default__test_not_null", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/generic_test_sql/not_null.sql", + "original_file_path": "macros/generic_test_sql/not_null.sql", + "unique_id": "macro.dbt.default__test_not_null", + "macro_sql": "{% macro default__test_not_null(model, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else column_name %}\n\nselect {{ column_list }}\nfrom {{ model }}\nwhere {{ column_name }} is null\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.should_store_failures" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.477377, + "supported_languages": null + }, + "macro.dbt.default__test_unique": { + "name": "default__test_unique", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/generic_test_sql/unique.sql", + "original_file_path": "macros/generic_test_sql/unique.sql", + "unique_id": "macro.dbt.default__test_unique", + "macro_sql": "{% macro default__test_unique(model, column_name) %}\n\nselect\n {{ column_name }} as unique_field,\n count(*) as n_records\n\nfrom {{ model }}\nwhere {{ column_name }} is not null\ngroup by {{ column_name }}\nhaving count(*) > 1\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.477619, + "supported_languages": null + }, + "macro.dbt.default__test_accepted_values": { + "name": "default__test_accepted_values", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/generic_test_sql/accepted_values.sql", + "original_file_path": "macros/generic_test_sql/accepted_values.sql", + "unique_id": "macro.dbt.default__test_accepted_values", + "macro_sql": "{% macro default__test_accepted_values(model, column_name, values, quote=True) %}\n\nwith all_values as (\n\n select\n {{ column_name }} as value_field,\n count(*) as n_records\n\n from {{ model }}\n group by {{ column_name }}\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n)\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.478173, + "supported_languages": null + }, + "macro.dbt.statement": { + "name": "statement", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/etc/statement.sql", + "original_file_path": "macros/etc/statement.sql", + "unique_id": "macro.dbt.statement", + "macro_sql": "\n{%- macro statement(name=None, fetch_result=False, auto_begin=True, language='sql') -%}\n {%- if execute: -%}\n {%- set compiled_code = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime {} for node \"{}\"'.format(language, model['unique_id'])) }}\n {{ write(compiled_code) }}\n {%- endif -%}\n {%- if language == 'sql'-%}\n {%- set res, table = adapter.execute(compiled_code, auto_begin=auto_begin, fetch=fetch_result) -%}\n {%- elif language == 'python' -%}\n {%- set res = submit_python_job(model, compiled_code) -%}\n {#-- TODO: What should table be for python models? --#}\n {%- set table = None -%}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"statement macro didn't get supported language\") %}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_result(name, response=res, agate_table=table) }}\n {%- endif -%}\n\n {%- endif -%}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.479598, + "supported_languages": null + }, + "macro.dbt.noop_statement": { + "name": "noop_statement", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/etc/statement.sql", + "original_file_path": "macros/etc/statement.sql", + "unique_id": "macro.dbt.noop_statement", + "macro_sql": "{% macro noop_statement(name=None, message=None, code=None, rows_affected=None, res=None) -%}\n {%- set sql = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime SQL for node \"{}\"'.format(model['unique_id'])) }}\n {{ write(sql) }}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_raw_result(name, message=message, code=code, rows_affected=rows_affected, agate_table=res) }}\n {%- endif -%}\n\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4801579, + "supported_languages": null + }, + "macro.dbt.run_query": { + "name": "run_query", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/etc/statement.sql", + "original_file_path": "macros/etc/statement.sql", + "unique_id": "macro.dbt.run_query", + "macro_sql": "{% macro run_query(sql) %}\n {% call statement(\"run_query_statement\", fetch_result=true, auto_begin=false) %}\n {{ sql }}\n {% endcall %}\n\n {% do return(load_result(\"run_query_statement\").table) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.480442, + "supported_languages": null + }, + "macro.dbt.convert_datetime": { + "name": "convert_datetime", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/etc/datetime.sql", + "original_file_path": "macros/etc/datetime.sql", + "unique_id": "macro.dbt.convert_datetime", + "macro_sql": "{% macro convert_datetime(date_str, date_fmt) %}\n\n {% set error_msg -%}\n The provided partition date '{{ date_str }}' does not match the expected format '{{ date_fmt }}'\n {%- endset %}\n\n {% set res = try_or_compiler_error(error_msg, modules.datetime.datetime.strptime, date_str.strip(), date_fmt) %}\n {{ return(res) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.482307, + "supported_languages": null + }, + "macro.dbt.dates_in_range": { + "name": "dates_in_range", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/etc/datetime.sql", + "original_file_path": "macros/etc/datetime.sql", + "unique_id": "macro.dbt.dates_in_range", + "macro_sql": "{% macro dates_in_range(start_date_str, end_date_str=none, in_fmt=\"%Y%m%d\", out_fmt=\"%Y%m%d\") %}\n {% set end_date_str = start_date_str if end_date_str is none else end_date_str %}\n\n {% set start_date = convert_datetime(start_date_str, in_fmt) %}\n {% set end_date = convert_datetime(end_date_str, in_fmt) %}\n\n {% set day_count = (end_date - start_date).days %}\n {% if day_count < 0 %}\n {% set msg -%}\n Partition start date is after the end date ({{ start_date }}, {{ end_date }})\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg, model) }}\n {% endif %}\n\n {% set date_list = [] %}\n {% for i in range(0, day_count + 1) %}\n {% set the_date = (modules.datetime.timedelta(days=i) + start_date) %}\n {% if not out_fmt %}\n {% set _ = date_list.append(the_date) %}\n {% else %}\n {% set _ = date_list.append(the_date.strftime(out_fmt)) %}\n {% endif %}\n {% endfor %}\n\n {{ return(date_list) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.convert_datetime" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.483666, + "supported_languages": null + }, + "macro.dbt.partition_range": { + "name": "partition_range", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/etc/datetime.sql", + "original_file_path": "macros/etc/datetime.sql", + "unique_id": "macro.dbt.partition_range", + "macro_sql": "{% macro partition_range(raw_partition_date, date_fmt='%Y%m%d') %}\n {% set partition_range = (raw_partition_date | string).split(\",\") %}\n\n {% if (partition_range | length) == 1 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = none %}\n {% elif (partition_range | length) == 2 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = partition_range[1] %}\n {% else %}\n {{ exceptions.raise_compiler_error(\"Invalid partition time. Expected format: {Start Date}[,{End Date}]. Got: \" ~ raw_partition_date) }}\n {% endif %}\n\n {{ return(dates_in_range(start_date, end_date, in_fmt=date_fmt)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.dates_in_range" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.484442, + "supported_languages": null + }, + "macro.dbt.py_current_timestring": { + "name": "py_current_timestring", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/etc/datetime.sql", + "original_file_path": "macros/etc/datetime.sql", + "unique_id": "macro.dbt.py_current_timestring", + "macro_sql": "{% macro py_current_timestring() %}\n {% set dt = modules.datetime.datetime.now() %}\n {% do return(dt.strftime(\"%Y%m%d%H%M%S%f\")) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.484682, + "supported_languages": null + }, + "macro.dbt.except": { + "name": "except", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/except.sql", + "original_file_path": "macros/utils/except.sql", + "unique_id": "macro.dbt.except", + "macro_sql": "{% macro except() %}\n {{ return(adapter.dispatch('except', 'dbt')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__except" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.484919, + "supported_languages": null + }, + "macro.dbt.default__except": { + "name": "default__except", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/except.sql", + "original_file_path": "macros/utils/except.sql", + "unique_id": "macro.dbt.default__except", + "macro_sql": "{% macro default__except() %}\n\n except\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.485, + "supported_languages": null + }, + "macro.dbt.get_intervals_between": { + "name": "get_intervals_between", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/date_spine.sql", + "original_file_path": "macros/utils/date_spine.sql", + "unique_id": "macro.dbt.get_intervals_between", + "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt')(start_date, end_date, datepart)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_intervals_between" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4857779, + "supported_languages": null + }, + "macro.dbt.default__get_intervals_between": { + "name": "default__get_intervals_between", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/date_spine.sql", + "original_file_path": "macros/utils/date_spine.sql", + "unique_id": "macro.dbt.default__get_intervals_between", + "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.dbt.datediff" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.486412, + "supported_languages": null + }, + "macro.dbt.date_spine": { + "name": "date_spine", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/date_spine.sql", + "original_file_path": "macros/utils/date_spine.sql", + "unique_id": "macro.dbt.date_spine", + "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt')(datepart, start_date, end_date)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__date_spine" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.486658, + "supported_languages": null + }, + "macro.dbt.default__date_spine": { + "name": "default__date_spine", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/date_spine.sql", + "original_file_path": "macros/utils/date_spine.sql", + "unique_id": "macro.dbt.default__date_spine", + "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n {# call as follows:\n\n date_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n ) #}\n\n\n with rawdata as (\n\n {{dbt.generate_series(\n dbt.get_intervals_between(start_date, end_date, datepart)\n )}}\n\n ),\n\n all_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n ),\n\n filtered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n )\n\n select * from filtered\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.generate_series", + "macro.dbt.get_intervals_between", + "macro.dbt.dateadd" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.48704, + "supported_languages": null + }, + "macro.dbt.replace": { + "name": "replace", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/replace.sql", + "original_file_path": "macros/utils/replace.sql", + "unique_id": "macro.dbt.replace", + "macro_sql": "{% macro replace(field, old_chars, new_chars) -%}\n {{ return(adapter.dispatch('replace', 'dbt') (field, old_chars, new_chars)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__replace" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.487387, + "supported_languages": null + }, + "macro.dbt.default__replace": { + "name": "default__replace", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/replace.sql", + "original_file_path": "macros/utils/replace.sql", + "unique_id": "macro.dbt.default__replace", + "macro_sql": "{% macro default__replace(field, old_chars, new_chars) %}\n\n replace(\n {{ field }},\n {{ old_chars }},\n {{ new_chars }}\n )\n\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.487554, + "supported_languages": null + }, + "macro.dbt.concat": { + "name": "concat", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/concat.sql", + "original_file_path": "macros/utils/concat.sql", + "unique_id": "macro.dbt.concat", + "macro_sql": "{% macro concat(fields) -%}\n {{ return(adapter.dispatch('concat', 'dbt')(fields)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__concat" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.487807, + "supported_languages": null + }, + "macro.dbt.default__concat": { + "name": "default__concat", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/concat.sql", + "original_file_path": "macros/utils/concat.sql", + "unique_id": "macro.dbt.default__concat", + "macro_sql": "{% macro default__concat(fields) -%}\n {{ fields|join(' || ') }}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.487932, + "supported_languages": null + }, + "macro.dbt.get_powers_of_two": { + "name": "get_powers_of_two", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/generate_series.sql", + "original_file_path": "macros/utils/generate_series.sql", + "unique_id": "macro.dbt.get_powers_of_two", + "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt')(upper_bound)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_powers_of_two" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.488794, + "supported_languages": null + }, + "macro.dbt.default__get_powers_of_two": { + "name": "default__get_powers_of_two", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/generate_series.sql", + "original_file_path": "macros/utils/generate_series.sql", + "unique_id": "macro.dbt.default__get_powers_of_two", + "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.489224, + "supported_languages": null + }, + "macro.dbt.generate_series": { + "name": "generate_series", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/generate_series.sql", + "original_file_path": "macros/utils/generate_series.sql", + "unique_id": "macro.dbt.generate_series", + "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt')(upper_bound)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__generate_series" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.48942, + "supported_languages": null + }, + "macro.dbt.default__generate_series": { + "name": "default__generate_series", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/generate_series.sql", + "original_file_path": "macros/utils/generate_series.sql", + "unique_id": "macro.dbt.default__generate_series", + "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_powers_of_two" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.489943, + "supported_languages": null + }, + "macro.dbt.length": { + "name": "length", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/length.sql", + "original_file_path": "macros/utils/length.sql", + "unique_id": "macro.dbt.length", + "macro_sql": "{% macro length(expression) -%}\n {{ return(adapter.dispatch('length', 'dbt') (expression)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__length" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.490208, + "supported_languages": null + }, + "macro.dbt.default__length": { + "name": "default__length", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/length.sql", + "original_file_path": "macros/utils/length.sql", + "unique_id": "macro.dbt.default__length", + "macro_sql": "{% macro default__length(expression) %}\n\n length(\n {{ expression }}\n )\n\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.490317, + "supported_languages": null + }, + "macro.dbt.dateadd": { + "name": "dateadd", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/dateadd.sql", + "original_file_path": "macros/utils/dateadd.sql", + "unique_id": "macro.dbt.dateadd", + "macro_sql": "{% macro dateadd(datepart, interval, from_date_or_timestamp) %}\n {{ return(adapter.dispatch('dateadd', 'dbt')(datepart, interval, from_date_or_timestamp)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__dateadd" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4906611, + "supported_languages": null + }, + "macro.dbt.default__dateadd": { + "name": "default__dateadd", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/dateadd.sql", + "original_file_path": "macros/utils/dateadd.sql", + "unique_id": "macro.dbt.default__dateadd", + "macro_sql": "{% macro default__dateadd(datepart, interval, from_date_or_timestamp) %}\n\n dateadd(\n {{ datepart }},\n {{ interval }},\n {{ from_date_or_timestamp }}\n )\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.490828, + "supported_languages": null + }, + "macro.dbt.intersect": { + "name": "intersect", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/intersect.sql", + "original_file_path": "macros/utils/intersect.sql", + "unique_id": "macro.dbt.intersect", + "macro_sql": "{% macro intersect() %}\n {{ return(adapter.dispatch('intersect', 'dbt')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__intersect" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4910579, + "supported_languages": null + }, + "macro.dbt.default__intersect": { + "name": "default__intersect", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/intersect.sql", + "original_file_path": "macros/utils/intersect.sql", + "unique_id": "macro.dbt.default__intersect", + "macro_sql": "{% macro default__intersect() %}\n\n intersect\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4912279, + "supported_languages": null + }, + "macro.dbt.escape_single_quotes": { + "name": "escape_single_quotes", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/escape_single_quotes.sql", + "original_file_path": "macros/utils/escape_single_quotes.sql", + "unique_id": "macro.dbt.escape_single_quotes", + "macro_sql": "{% macro escape_single_quotes(expression) %}\n {{ return(adapter.dispatch('escape_single_quotes', 'dbt') (expression)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__escape_single_quotes" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4914932, + "supported_languages": null + }, + "macro.dbt.default__escape_single_quotes": { + "name": "default__escape_single_quotes", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/escape_single_quotes.sql", + "original_file_path": "macros/utils/escape_single_quotes.sql", + "unique_id": "macro.dbt.default__escape_single_quotes", + "macro_sql": "{% macro default__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\",\"''\") }}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4916348, + "supported_languages": null + }, + "macro.dbt.right": { + "name": "right", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/right.sql", + "original_file_path": "macros/utils/right.sql", + "unique_id": "macro.dbt.right", + "macro_sql": "{% macro right(string_text, length_expression) -%}\n {{ return(adapter.dispatch('right', 'dbt') (string_text, length_expression)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__right" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.491935, + "supported_languages": null + }, + "macro.dbt.default__right": { + "name": "default__right", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/right.sql", + "original_file_path": "macros/utils/right.sql", + "unique_id": "macro.dbt.default__right", + "macro_sql": "{% macro default__right(string_text, length_expression) %}\n\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4920719, + "supported_languages": null + }, + "macro.dbt.listagg": { + "name": "listagg", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/listagg.sql", + "original_file_path": "macros/utils/listagg.sql", + "unique_id": "macro.dbt.listagg", + "macro_sql": "{% macro listagg(measure, delimiter_text=\"','\", order_by_clause=none, limit_num=none) -%}\n {{ return(adapter.dispatch('listagg', 'dbt') (measure, delimiter_text, order_by_clause, limit_num)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__listagg" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.492737, + "supported_languages": null + }, + "macro.dbt.default__listagg": { + "name": "default__listagg", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/listagg.sql", + "original_file_path": "macros/utils/listagg.sql", + "unique_id": "macro.dbt.default__listagg", + "macro_sql": "{% macro default__listagg(measure, delimiter_text, order_by_clause, limit_num) -%}\n\n {% if limit_num -%}\n array_to_string(\n array_slice(\n array_agg(\n {{ measure }}\n ){% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n ,0\n ,{{ limit_num }}\n ),\n {{ delimiter_text }}\n )\n {%- else %}\n listagg(\n {{ measure }},\n {{ delimiter_text }}\n )\n {% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n {%- endif %}\n\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.493143, + "supported_languages": null + }, + "macro.dbt.datediff": { + "name": "datediff", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/datediff.sql", + "original_file_path": "macros/utils/datediff.sql", + "unique_id": "macro.dbt.datediff", + "macro_sql": "{% macro datediff(first_date, second_date, datepart) %}\n {{ return(adapter.dispatch('datediff', 'dbt')(first_date, second_date, datepart)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__datediff" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.493494, + "supported_languages": null + }, + "macro.dbt.default__datediff": { + "name": "default__datediff", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/datediff.sql", + "original_file_path": "macros/utils/datediff.sql", + "unique_id": "macro.dbt.default__datediff", + "macro_sql": "{% macro default__datediff(first_date, second_date, datepart) -%}\n\n datediff(\n {{ datepart }},\n {{ first_date }},\n {{ second_date }}\n )\n\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.493661, + "supported_languages": null + }, + "macro.dbt.safe_cast": { + "name": "safe_cast", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/safe_cast.sql", + "original_file_path": "macros/utils/safe_cast.sql", + "unique_id": "macro.dbt.safe_cast", + "macro_sql": "{% macro safe_cast(field, type) %}\n {{ return(adapter.dispatch('safe_cast', 'dbt') (field, type)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__safe_cast" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.493953, + "supported_languages": null + }, + "macro.dbt.default__safe_cast": { + "name": "default__safe_cast", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/safe_cast.sql", + "original_file_path": "macros/utils/safe_cast.sql", + "unique_id": "macro.dbt.default__safe_cast", + "macro_sql": "{% macro default__safe_cast(field, type) %}\n {# most databases don't support this function yet\n so we just need to use cast #}\n cast({{field}} as {{type}})\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4940999, + "supported_languages": null + }, + "macro.dbt.hash": { + "name": "hash", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/hash.sql", + "original_file_path": "macros/utils/hash.sql", + "unique_id": "macro.dbt.hash", + "macro_sql": "{% macro hash(field) -%}\n {{ return(adapter.dispatch('hash', 'dbt') (field)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__hash" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.494368, + "supported_languages": null + }, + "macro.dbt.default__hash": { + "name": "default__hash", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/hash.sql", + "original_file_path": "macros/utils/hash.sql", + "unique_id": "macro.dbt.default__hash", + "macro_sql": "{% macro default__hash(field) -%}\n md5(cast({{ field }} as {{ api.Column.translate_type('string') }}))\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4945312, + "supported_languages": null + }, + "macro.dbt.cast_bool_to_text": { + "name": "cast_bool_to_text", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/cast_bool_to_text.sql", + "original_file_path": "macros/utils/cast_bool_to_text.sql", + "unique_id": "macro.dbt.cast_bool_to_text", + "macro_sql": "{% macro cast_bool_to_text(field) %}\n {{ adapter.dispatch('cast_bool_to_text', 'dbt') (field) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__cast_bool_to_text" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4947882, + "supported_languages": null + }, + "macro.dbt.default__cast_bool_to_text": { + "name": "default__cast_bool_to_text", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/cast_bool_to_text.sql", + "original_file_path": "macros/utils/cast_bool_to_text.sql", + "unique_id": "macro.dbt.default__cast_bool_to_text", + "macro_sql": "{% macro default__cast_bool_to_text(field) %}\n cast({{ field }} as {{ api.Column.translate_type('string') }})\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.495135, + "supported_languages": null + }, + "macro.dbt.any_value": { + "name": "any_value", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/any_value.sql", + "original_file_path": "macros/utils/any_value.sql", + "unique_id": "macro.dbt.any_value", + "macro_sql": "{% macro any_value(expression) -%}\n {{ return(adapter.dispatch('any_value', 'dbt') (expression)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__any_value" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.495466, + "supported_languages": null + }, + "macro.dbt.default__any_value": { + "name": "default__any_value", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/any_value.sql", + "original_file_path": "macros/utils/any_value.sql", + "unique_id": "macro.dbt.default__any_value", + "macro_sql": "{% macro default__any_value(expression) -%}\n\n any_value({{ expression }})\n\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.495596, + "supported_languages": null + }, + "macro.dbt.position": { + "name": "position", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/position.sql", + "original_file_path": "macros/utils/position.sql", + "unique_id": "macro.dbt.position", + "macro_sql": "{% macro position(substring_text, string_text) -%}\n {{ return(adapter.dispatch('position', 'dbt') (substring_text, string_text)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__position" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.495906, + "supported_languages": null + }, + "macro.dbt.default__position": { + "name": "default__position", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/position.sql", + "original_file_path": "macros/utils/position.sql", + "unique_id": "macro.dbt.default__position", + "macro_sql": "{% macro default__position(substring_text, string_text) %}\n\n position(\n {{ substring_text }} in {{ string_text }}\n )\n\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4960551, + "supported_languages": null + }, + "macro.dbt.string_literal": { + "name": "string_literal", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/literal.sql", + "original_file_path": "macros/utils/literal.sql", + "unique_id": "macro.dbt.string_literal", + "macro_sql": "{%- macro string_literal(value) -%}\n {{ return(adapter.dispatch('string_literal', 'dbt') (value)) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__string_literal" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.496455, + "supported_languages": null + }, + "macro.dbt.default__string_literal": { + "name": "default__string_literal", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/literal.sql", + "original_file_path": "macros/utils/literal.sql", + "unique_id": "macro.dbt.default__string_literal", + "macro_sql": "{% macro default__string_literal(value) -%}\n '{{ value }}'\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4966662, + "supported_languages": null + }, + "macro.dbt.type_string": { + "name": "type_string", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "unique_id": "macro.dbt.type_string", + "macro_sql": "\n\n{%- macro type_string() -%}\n {{ return(adapter.dispatch('type_string', 'dbt')()) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4976041, + "supported_languages": null + }, + "macro.dbt.default__type_string": { + "name": "default__type_string", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "unique_id": "macro.dbt.default__type_string", + "macro_sql": "{% macro default__type_string() %}\n {{ return(api.Column.translate_type(\"string\")) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.497757, + "supported_languages": null + }, + "macro.dbt.type_timestamp": { + "name": "type_timestamp", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "unique_id": "macro.dbt.type_timestamp", + "macro_sql": "\n\n{%- macro type_timestamp() -%}\n {{ return(adapter.dispatch('type_timestamp', 'dbt')()) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__type_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.497925, + "supported_languages": null + }, + "macro.dbt.default__type_timestamp": { + "name": "default__type_timestamp", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "unique_id": "macro.dbt.default__type_timestamp", + "macro_sql": "{% macro default__type_timestamp() %}\n {{ return(api.Column.translate_type(\"timestamp\")) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.498081, + "supported_languages": null + }, + "macro.dbt.type_float": { + "name": "type_float", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "unique_id": "macro.dbt.type_float", + "macro_sql": "\n\n{%- macro type_float() -%}\n {{ return(adapter.dispatch('type_float', 'dbt')()) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__type_float" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.498245, + "supported_languages": null + }, + "macro.dbt.default__type_float": { + "name": "default__type_float", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "unique_id": "macro.dbt.default__type_float", + "macro_sql": "{% macro default__type_float() %}\n {{ return(api.Column.translate_type(\"float\")) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.498398, + "supported_languages": null + }, + "macro.dbt.type_numeric": { + "name": "type_numeric", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "unique_id": "macro.dbt.type_numeric", + "macro_sql": "\n\n{%- macro type_numeric() -%}\n {{ return(adapter.dispatch('type_numeric', 'dbt')()) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__type_numeric" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.49857, + "supported_languages": null + }, + "macro.dbt.default__type_numeric": { + "name": "default__type_numeric", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "unique_id": "macro.dbt.default__type_numeric", + "macro_sql": "{% macro default__type_numeric() %}\n {{ return(api.Column.numeric_type(\"numeric\", 28, 6)) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.498765, + "supported_languages": null + }, + "macro.dbt.type_bigint": { + "name": "type_bigint", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "unique_id": "macro.dbt.type_bigint", + "macro_sql": "\n\n{%- macro type_bigint() -%}\n {{ return(adapter.dispatch('type_bigint', 'dbt')()) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__type_bigint" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.498932, + "supported_languages": null + }, + "macro.dbt.default__type_bigint": { + "name": "default__type_bigint", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "unique_id": "macro.dbt.default__type_bigint", + "macro_sql": "{% macro default__type_bigint() %}\n {{ return(api.Column.translate_type(\"bigint\")) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.499091, + "supported_languages": null + }, + "macro.dbt.type_int": { + "name": "type_int", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "unique_id": "macro.dbt.type_int", + "macro_sql": "\n\n{%- macro type_int() -%}\n {{ return(adapter.dispatch('type_int', 'dbt')()) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__type_int" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.49926, + "supported_languages": null + }, + "macro.dbt.default__type_int": { + "name": "default__type_int", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "unique_id": "macro.dbt.default__type_int", + "macro_sql": "{%- macro default__type_int() -%}\n {{ return(api.Column.translate_type(\"integer\")) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.499407, + "supported_languages": null + }, + "macro.dbt.type_boolean": { + "name": "type_boolean", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "unique_id": "macro.dbt.type_boolean", + "macro_sql": "\n\n{%- macro type_boolean() -%}\n {{ return(adapter.dispatch('type_boolean', 'dbt')()) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.dbt.default__type_boolean" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.4995708, + "supported_languages": null + }, + "macro.dbt.default__type_boolean": { + "name": "default__type_boolean", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/data_types.sql", + "original_file_path": "macros/utils/data_types.sql", + "unique_id": "macro.dbt.default__type_boolean", + "macro_sql": "{%- macro default__type_boolean() -%}\n {{ return(api.Column.translate_type(\"boolean\")) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.499727, + "supported_languages": null + }, + "macro.dbt.array_concat": { + "name": "array_concat", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/array_concat.sql", + "original_file_path": "macros/utils/array_concat.sql", + "unique_id": "macro.dbt.array_concat", + "macro_sql": "{% macro array_concat(array_1, array_2) -%}\n {{ return(adapter.dispatch('array_concat', 'dbt')(array_1, array_2)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__array_concat" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.500011, + "supported_languages": null + }, + "macro.dbt.default__array_concat": { + "name": "default__array_concat", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/array_concat.sql", + "original_file_path": "macros/utils/array_concat.sql", + "unique_id": "macro.dbt.default__array_concat", + "macro_sql": "{% macro default__array_concat(array_1, array_2) -%}\n array_cat({{ array_1 }}, {{ array_2 }})\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5001442, + "supported_languages": null + }, + "macro.dbt.bool_or": { + "name": "bool_or", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/bool_or.sql", + "original_file_path": "macros/utils/bool_or.sql", + "unique_id": "macro.dbt.bool_or", + "macro_sql": "{% macro bool_or(expression) -%}\n {{ return(adapter.dispatch('bool_or', 'dbt') (expression)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__bool_or" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5004008, + "supported_languages": null + }, + "macro.dbt.default__bool_or": { + "name": "default__bool_or", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/bool_or.sql", + "original_file_path": "macros/utils/bool_or.sql", + "unique_id": "macro.dbt.default__bool_or", + "macro_sql": "{% macro default__bool_or(expression) -%}\n\n bool_or({{ expression }})\n\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.500515, + "supported_languages": null + }, + "macro.dbt.last_day": { + "name": "last_day", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/last_day.sql", + "original_file_path": "macros/utils/last_day.sql", + "unique_id": "macro.dbt.last_day", + "macro_sql": "{% macro last_day(date, datepart) %}\n {{ return(adapter.dispatch('last_day', 'dbt') (date, datepart)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__last_day" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5008771, + "supported_languages": null + }, + "macro.dbt.default_last_day": { + "name": "default_last_day", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/last_day.sql", + "original_file_path": "macros/utils/last_day.sql", + "unique_id": "macro.dbt.default_last_day", + "macro_sql": "\n\n{%- macro default_last_day(date, datepart) -%}\n cast(\n {{dbt.dateadd('day', '-1',\n dbt.dateadd(datepart, '1', dbt.date_trunc(datepart, date))\n )}}\n as date)\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.dbt.dateadd", + "macro.dbt.date_trunc" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.501323, + "supported_languages": null + }, + "macro.dbt.default__last_day": { + "name": "default__last_day", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/last_day.sql", + "original_file_path": "macros/utils/last_day.sql", + "unique_id": "macro.dbt.default__last_day", + "macro_sql": "{% macro default__last_day(date, datepart) -%}\n {{dbt.default_last_day(date, datepart)}}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default_last_day" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.501508, + "supported_languages": null + }, + "macro.dbt.split_part": { + "name": "split_part", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/split_part.sql", + "original_file_path": "macros/utils/split_part.sql", + "unique_id": "macro.dbt.split_part", + "macro_sql": "{% macro split_part(string_text, delimiter_text, part_number) %}\n {{ return(adapter.dispatch('split_part', 'dbt') (string_text, delimiter_text, part_number)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__split_part" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.502149, + "supported_languages": null + }, + "macro.dbt.default__split_part": { + "name": "default__split_part", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/split_part.sql", + "original_file_path": "macros/utils/split_part.sql", + "unique_id": "macro.dbt.default__split_part", + "macro_sql": "{% macro default__split_part(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n {{ part_number }}\n )\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5023339, + "supported_languages": null + }, + "macro.dbt._split_part_negative": { + "name": "_split_part_negative", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/split_part.sql", + "original_file_path": "macros/utils/split_part.sql", + "unique_id": "macro.dbt._split_part_negative", + "macro_sql": "{% macro _split_part_negative(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n length({{ string_text }})\n - length(\n replace({{ string_text }}, {{ delimiter_text }}, '')\n ) + 2 + {{ part_number }}\n )\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5025768, + "supported_languages": null + }, + "macro.dbt.date_trunc": { + "name": "date_trunc", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/date_trunc.sql", + "original_file_path": "macros/utils/date_trunc.sql", + "unique_id": "macro.dbt.date_trunc", + "macro_sql": "{% macro date_trunc(datepart, date) -%}\n {{ return(adapter.dispatch('date_trunc', 'dbt') (datepart, date)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__date_trunc" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5028749, + "supported_languages": null + }, + "macro.dbt.default__date_trunc": { + "name": "default__date_trunc", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/date_trunc.sql", + "original_file_path": "macros/utils/date_trunc.sql", + "unique_id": "macro.dbt.default__date_trunc", + "macro_sql": "{% macro default__date_trunc(datepart, date) -%}\n date_trunc('{{datepart}}', {{date}})\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5030122, + "supported_languages": null + }, + "macro.dbt.array_construct": { + "name": "array_construct", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/array_construct.sql", + "original_file_path": "macros/utils/array_construct.sql", + "unique_id": "macro.dbt.array_construct", + "macro_sql": "{% macro array_construct(inputs=[], data_type=api.Column.translate_type('integer')) -%}\n {{ return(adapter.dispatch('array_construct', 'dbt')(inputs, data_type)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__array_construct" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5036569, + "supported_languages": null + }, + "macro.dbt.default__array_construct": { + "name": "default__array_construct", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/array_construct.sql", + "original_file_path": "macros/utils/array_construct.sql", + "unique_id": "macro.dbt.default__array_construct", + "macro_sql": "{% macro default__array_construct(inputs, data_type) -%}\n {% if inputs|length > 0 %}\n array[ {{ inputs|join(' , ') }} ]\n {% else %}\n array[]::{{data_type}}[]\n {% endif %}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.503927, + "supported_languages": null + }, + "macro.dbt.array_append": { + "name": "array_append", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/array_append.sql", + "original_file_path": "macros/utils/array_append.sql", + "unique_id": "macro.dbt.array_append", + "macro_sql": "{% macro array_append(array, new_element) -%}\n {{ return(adapter.dispatch('array_append', 'dbt')(array, new_element)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__array_append" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.504218, + "supported_languages": null + }, + "macro.dbt.default__array_append": { + "name": "default__array_append", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/utils/array_append.sql", + "original_file_path": "macros/utils/array_append.sql", + "unique_id": "macro.dbt.default__array_append", + "macro_sql": "{% macro default__array_append(array, new_element) -%}\n array_append({{ array }}, {{ new_element }})\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.504352, + "supported_languages": null + }, + "macro.dbt.create_schema": { + "name": "create_schema", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/schema.sql", + "original_file_path": "macros/adapters/schema.sql", + "unique_id": "macro.dbt.create_schema", + "macro_sql": "{% macro create_schema(relation) -%}\n {{ adapter.dispatch('create_schema', 'dbt')(relation) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__create_schema" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.504724, + "supported_languages": null + }, + "macro.dbt.default__create_schema": { + "name": "default__create_schema", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/schema.sql", + "original_file_path": "macros/adapters/schema.sql", + "unique_id": "macro.dbt.default__create_schema", + "macro_sql": "{% macro default__create_schema(relation) -%}\n {%- call statement('create_schema') -%}\n create schema if not exists {{ relation.without_identifier() }}\n {% endcall %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.504906, + "supported_languages": null + }, + "macro.dbt.drop_schema": { + "name": "drop_schema", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/schema.sql", + "original_file_path": "macros/adapters/schema.sql", + "unique_id": "macro.dbt.drop_schema", + "macro_sql": "{% macro drop_schema(relation) -%}\n {{ adapter.dispatch('drop_schema', 'dbt')(relation) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__drop_schema" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.505065, + "supported_languages": null + }, + "macro.dbt.default__drop_schema": { + "name": "default__drop_schema", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/schema.sql", + "original_file_path": "macros/adapters/schema.sql", + "unique_id": "macro.dbt.default__drop_schema", + "macro_sql": "{% macro default__drop_schema(relation) -%}\n {%- call statement('drop_schema') -%}\n drop schema if exists {{ relation.without_identifier() }} cascade\n {% endcall %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.505245, + "supported_languages": null + }, + "macro.dbt.current_timestamp": { + "name": "current_timestamp", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "unique_id": "macro.dbt.current_timestamp", + "macro_sql": "{%- macro current_timestamp() -%}\n {{ adapter.dispatch('current_timestamp', 'dbt')() }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__current_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.505728, + "supported_languages": null + }, + "macro.dbt.default__current_timestamp": { + "name": "default__current_timestamp", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "unique_id": "macro.dbt.default__current_timestamp", + "macro_sql": "{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n 'current_timestamp macro not implemented for adapter ' + adapter.type()) }}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.50588, + "supported_languages": null + }, + "macro.dbt.snapshot_get_time": { + "name": "snapshot_get_time", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "unique_id": "macro.dbt.snapshot_get_time", + "macro_sql": "\n\n{%- macro snapshot_get_time() -%}\n {{ adapter.dispatch('snapshot_get_time', 'dbt')() }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__snapshot_get_time" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.506019, + "supported_languages": null + }, + "macro.dbt.default__snapshot_get_time": { + "name": "default__snapshot_get_time", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "unique_id": "macro.dbt.default__snapshot_get_time", + "macro_sql": "{% macro default__snapshot_get_time() %}\n {{ current_timestamp() }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.current_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.506125, + "supported_languages": null + }, + "macro.dbt.current_timestamp_backcompat": { + "name": "current_timestamp_backcompat", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "unique_id": "macro.dbt.current_timestamp_backcompat", + "macro_sql": "{% macro current_timestamp_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__current_timestamp_backcompat" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.506363, + "supported_languages": null + }, + "macro.dbt.default__current_timestamp_backcompat": { + "name": "default__current_timestamp_backcompat", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "unique_id": "macro.dbt.default__current_timestamp_backcompat", + "macro_sql": "{% macro default__current_timestamp_backcompat() %}\n current_timestamp::timestamp\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.506471, + "supported_languages": null + }, + "macro.dbt.current_timestamp_in_utc_backcompat": { + "name": "current_timestamp_in_utc_backcompat", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "unique_id": "macro.dbt.current_timestamp_in_utc_backcompat", + "macro_sql": "{% macro current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_in_utc_backcompat', 'dbt')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__current_timestamp_in_utc_backcompat" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.506788, + "supported_languages": null + }, + "macro.dbt.default__current_timestamp_in_utc_backcompat": { + "name": "default__current_timestamp_in_utc_backcompat", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/timestamps.sql", + "original_file_path": "macros/adapters/timestamps.sql", + "unique_id": "macro.dbt.default__current_timestamp_in_utc_backcompat", + "macro_sql": "{% macro default__current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.current_timestamp_backcompat", + "macro.dbt_snowflake.snowflake__current_timestamp_backcompat" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.506967, + "supported_languages": null + }, + "macro.dbt.get_create_index_sql": { + "name": "get_create_index_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/indexes.sql", + "original_file_path": "macros/adapters/indexes.sql", + "unique_id": "macro.dbt.get_create_index_sql", + "macro_sql": "{% macro get_create_index_sql(relation, index_dict) -%}\n {{ return(adapter.dispatch('get_create_index_sql', 'dbt')(relation, index_dict)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_create_index_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5078778, + "supported_languages": null + }, + "macro.dbt.default__get_create_index_sql": { + "name": "default__get_create_index_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/indexes.sql", + "original_file_path": "macros/adapters/indexes.sql", + "unique_id": "macro.dbt.default__get_create_index_sql", + "macro_sql": "{% macro default__get_create_index_sql(relation, index_dict) -%}\n {% do return(None) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.508022, + "supported_languages": null + }, + "macro.dbt.create_indexes": { + "name": "create_indexes", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/indexes.sql", + "original_file_path": "macros/adapters/indexes.sql", + "unique_id": "macro.dbt.create_indexes", + "macro_sql": "{% macro create_indexes(relation) -%}\n {{ adapter.dispatch('create_indexes', 'dbt')(relation) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__create_indexes" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.508182, + "supported_languages": null + }, + "macro.dbt.default__create_indexes": { + "name": "default__create_indexes", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/indexes.sql", + "original_file_path": "macros/adapters/indexes.sql", + "unique_id": "macro.dbt.default__create_indexes", + "macro_sql": "{% macro default__create_indexes(relation) -%}\n {%- set _indexes = config.get('indexes', default=[]) -%}\n\n {% for _index_dict in _indexes %}\n {% set create_index_sql = get_create_index_sql(relation, _index_dict) %}\n {% if create_index_sql %}\n {% do run_query(create_index_sql) %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_create_index_sql", + "macro.dbt.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.508617, + "supported_languages": null + }, + "macro.dbt.get_drop_index_sql": { + "name": "get_drop_index_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/indexes.sql", + "original_file_path": "macros/adapters/indexes.sql", + "unique_id": "macro.dbt.get_drop_index_sql", + "macro_sql": "{% macro get_drop_index_sql(relation, index_name) -%}\n {{ adapter.dispatch('get_drop_index_sql', 'dbt')(relation, index_name) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_drop_index_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.508798, + "supported_languages": null + }, + "macro.dbt.default__get_drop_index_sql": { + "name": "default__get_drop_index_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/indexes.sql", + "original_file_path": "macros/adapters/indexes.sql", + "unique_id": "macro.dbt.default__get_drop_index_sql", + "macro_sql": "{% macro default__get_drop_index_sql(relation, index_name) -%}\n {{ exceptions.raise_compiler_error(\"`get_drop_index_sql has not been implemented for this adapter.\") }}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5089412, + "supported_languages": null + }, + "macro.dbt.get_show_indexes_sql": { + "name": "get_show_indexes_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/indexes.sql", + "original_file_path": "macros/adapters/indexes.sql", + "unique_id": "macro.dbt.get_show_indexes_sql", + "macro_sql": "{% macro get_show_indexes_sql(relation) -%}\n {{ adapter.dispatch('get_show_indexes_sql', 'dbt')(relation) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_show_indexes_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.509096, + "supported_languages": null + }, + "macro.dbt.default__get_show_indexes_sql": { + "name": "default__get_show_indexes_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/indexes.sql", + "original_file_path": "macros/adapters/indexes.sql", + "unique_id": "macro.dbt.default__get_show_indexes_sql", + "macro_sql": "{% macro default__get_show_indexes_sql(relation) -%}\n {{ exceptions.raise_compiler_error(\"`get_show_indexes_sql has not been implemented for this adapter.\") }}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.509221, + "supported_languages": null + }, + "macro.dbt.make_intermediate_relation": { + "name": "make_intermediate_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "unique_id": "macro.dbt.make_intermediate_relation", + "macro_sql": "{% macro make_intermediate_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_intermediate_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__make_intermediate_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5112991, + "supported_languages": null + }, + "macro.dbt.default__make_intermediate_relation": { + "name": "default__make_intermediate_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "unique_id": "macro.dbt.default__make_intermediate_relation", + "macro_sql": "{% macro default__make_intermediate_relation(base_relation, suffix) %}\n {{ return(default__make_temp_relation(base_relation, suffix)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__make_temp_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.511572, + "supported_languages": null + }, + "macro.dbt.make_temp_relation": { + "name": "make_temp_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "unique_id": "macro.dbt.make_temp_relation", + "macro_sql": "{% macro make_temp_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_temp_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__make_temp_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.511826, + "supported_languages": null + }, + "macro.dbt.default__make_temp_relation": { + "name": "default__make_temp_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "unique_id": "macro.dbt.default__make_temp_relation", + "macro_sql": "{% macro default__make_temp_relation(base_relation, suffix) %}\n {%- set temp_identifier = base_relation.identifier ~ suffix -%}\n {%- set temp_relation = base_relation.incorporate(\n path={\"identifier\": temp_identifier}) -%}\n\n {{ return(temp_relation) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.512125, + "supported_languages": null + }, + "macro.dbt.make_backup_relation": { + "name": "make_backup_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "unique_id": "macro.dbt.make_backup_relation", + "macro_sql": "{% macro make_backup_relation(base_relation, backup_relation_type, suffix='__dbt_backup') %}\n {{ return(adapter.dispatch('make_backup_relation', 'dbt')(base_relation, backup_relation_type, suffix)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__make_backup_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.512372, + "supported_languages": null + }, + "macro.dbt.default__make_backup_relation": { + "name": "default__make_backup_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "unique_id": "macro.dbt.default__make_backup_relation", + "macro_sql": "{% macro default__make_backup_relation(base_relation, backup_relation_type, suffix) %}\n {%- set backup_identifier = base_relation.identifier ~ suffix -%}\n {%- set backup_relation = base_relation.incorporate(\n path={\"identifier\": backup_identifier},\n type=backup_relation_type\n ) -%}\n {{ return(backup_relation) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.512684, + "supported_languages": null + }, + "macro.dbt.truncate_relation": { + "name": "truncate_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "unique_id": "macro.dbt.truncate_relation", + "macro_sql": "{% macro truncate_relation(relation) -%}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__truncate_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.512863, + "supported_languages": null + }, + "macro.dbt.default__truncate_relation": { + "name": "default__truncate_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "unique_id": "macro.dbt.default__truncate_relation", + "macro_sql": "{% macro default__truncate_relation(relation) -%}\n {% call statement('truncate_relation') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.513025, + "supported_languages": null + }, + "macro.dbt.get_or_create_relation": { + "name": "get_or_create_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "unique_id": "macro.dbt.get_or_create_relation", + "macro_sql": "{% macro get_or_create_relation(database, schema, identifier, type) -%}\n {{ return(adapter.dispatch('get_or_create_relation', 'dbt')(database, schema, identifier, type)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_or_create_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.513267, + "supported_languages": null + }, + "macro.dbt.default__get_or_create_relation": { + "name": "default__get_or_create_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "unique_id": "macro.dbt.default__get_or_create_relation", + "macro_sql": "{% macro default__get_or_create_relation(database, schema, identifier, type) %}\n {%- set target_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% if target_relation %}\n {% do return([true, target_relation]) %}\n {% endif %}\n\n {%- set new_relation = api.Relation.create(\n database=database,\n schema=schema,\n identifier=identifier,\n type=type\n ) -%}\n {% do return([false, new_relation]) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5139031, + "supported_languages": null + }, + "macro.dbt.load_cached_relation": { + "name": "load_cached_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "unique_id": "macro.dbt.load_cached_relation", + "macro_sql": "{% macro load_cached_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5141351, + "supported_languages": null + }, + "macro.dbt.load_relation": { + "name": "load_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/relation.sql", + "original_file_path": "macros/adapters/relation.sql", + "unique_id": "macro.dbt.load_relation", + "macro_sql": "{% macro load_relation(relation) %}\n {{ return(load_cached_relation(relation)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.load_cached_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.514273, + "supported_languages": null + }, + "macro.dbt.collect_freshness": { + "name": "collect_freshness", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/freshness.sql", + "original_file_path": "macros/adapters/freshness.sql", + "unique_id": "macro.dbt.collect_freshness", + "macro_sql": "{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter.dispatch('collect_freshness', 'dbt')(source, loaded_at_field, filter))}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__collect_freshness" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.514698, + "supported_languages": null + }, + "macro.dbt.default__collect_freshness": { + "name": "default__collect_freshness", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/freshness.sql", + "original_file_path": "macros/adapters/freshness.sql", + "unique_id": "macro.dbt.default__collect_freshness", + "macro_sql": "{% macro default__collect_freshness(source, loaded_at_field, filter) %}\n {% call statement('collect_freshness', fetch_result=True, auto_begin=False) -%}\n select\n max({{ loaded_at_field }}) as max_loaded_at,\n {{ current_timestamp() }} as snapshotted_at\n from {{ source }}\n {% if filter %}\n where {{ filter }}\n {% endif %}\n {% endcall %}\n {{ return(load_result('collect_freshness')) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.dbt.current_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5151098, + "supported_languages": null + }, + "macro.dbt.validate_sql": { + "name": "validate_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/validate_sql.sql", + "original_file_path": "macros/adapters/validate_sql.sql", + "unique_id": "macro.dbt.validate_sql", + "macro_sql": "{% macro validate_sql(sql) -%}\n {{ return(adapter.dispatch('validate_sql', 'dbt')(sql)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__validate_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.515396, + "supported_languages": null + }, + "macro.dbt.default__validate_sql": { + "name": "default__validate_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/validate_sql.sql", + "original_file_path": "macros/adapters/validate_sql.sql", + "unique_id": "macro.dbt.default__validate_sql", + "macro_sql": "{% macro default__validate_sql(sql) -%}\n {% call statement('validate_sql') -%}\n explain {{ sql }}\n {% endcall %}\n {{ return(load_result('validate_sql')) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.51562, + "supported_languages": null + }, + "macro.dbt.copy_grants": { + "name": "copy_grants", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.copy_grants", + "macro_sql": "{% macro copy_grants() %}\n {{ return(adapter.dispatch('copy_grants', 'dbt')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__copy_grants" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.517545, + "supported_languages": null + }, + "macro.dbt.default__copy_grants": { + "name": "default__copy_grants", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.default__copy_grants", + "macro_sql": "{% macro default__copy_grants() %}\n {{ return(True) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.517683, + "supported_languages": null + }, + "macro.dbt.support_multiple_grantees_per_dcl_statement": { + "name": "support_multiple_grantees_per_dcl_statement", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.support_multiple_grantees_per_dcl_statement", + "macro_sql": "{% macro support_multiple_grantees_per_dcl_statement() %}\n {{ return(adapter.dispatch('support_multiple_grantees_per_dcl_statement', 'dbt')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__support_multiple_grantees_per_dcl_statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5178509, + "supported_languages": null + }, + "macro.dbt.default__support_multiple_grantees_per_dcl_statement": { + "name": "default__support_multiple_grantees_per_dcl_statement", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.default__support_multiple_grantees_per_dcl_statement", + "macro_sql": "\n\n{%- macro default__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(True) }}\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.517975, + "supported_languages": null + }, + "macro.dbt.should_revoke": { + "name": "should_revoke", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.should_revoke", + "macro_sql": "{% macro should_revoke(existing_relation, full_refresh_mode=True) %}\n\n {% if not existing_relation %}\n {#-- The table doesn't already exist, so no grants to copy over --#}\n {{ return(False) }}\n {% elif full_refresh_mode %}\n {#-- The object is being REPLACED -- whether grants are copied over depends on the value of user config --#}\n {{ return(copy_grants()) }}\n {% else %}\n {#-- The table is being merged/upserted/inserted -- grants will be carried over --#}\n {{ return(True) }}\n {% endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.copy_grants" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5183349, + "supported_languages": null + }, + "macro.dbt.get_show_grant_sql": { + "name": "get_show_grant_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.get_show_grant_sql", + "macro_sql": "{% macro get_show_grant_sql(relation) %}\n {{ return(adapter.dispatch(\"get_show_grant_sql\", \"dbt\")(relation)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_show_grant_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.518518, + "supported_languages": null + }, + "macro.dbt.default__get_show_grant_sql": { + "name": "default__get_show_grant_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.default__get_show_grant_sql", + "macro_sql": "{% macro default__get_show_grant_sql(relation) %}\n show grants on {{ relation }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.518624, + "supported_languages": null + }, + "macro.dbt.get_grant_sql": { + "name": "get_grant_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.get_grant_sql", + "macro_sql": "{% macro get_grant_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_grant_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_grant_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5188448, + "supported_languages": null + }, + "macro.dbt.default__get_grant_sql": { + "name": "default__get_grant_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.default__get_grant_sql", + "macro_sql": "\n\n{%- macro default__get_grant_sql(relation, privilege, grantees) -%}\n grant {{ privilege }} on {{ relation }} to {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.519032, + "supported_languages": null + }, + "macro.dbt.get_revoke_sql": { + "name": "get_revoke_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.get_revoke_sql", + "macro_sql": "{% macro get_revoke_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_revoke_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_revoke_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.51927, + "supported_languages": null + }, + "macro.dbt.default__get_revoke_sql": { + "name": "default__get_revoke_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.default__get_revoke_sql", + "macro_sql": "\n\n{%- macro default__get_revoke_sql(relation, privilege, grantees) -%}\n revoke {{ privilege }} on {{ relation }} from {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.519456, + "supported_languages": null + }, + "macro.dbt.get_dcl_statement_list": { + "name": "get_dcl_statement_list", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.get_dcl_statement_list", + "macro_sql": "{% macro get_dcl_statement_list(relation, grant_config, get_dcl_macro) %}\n {{ return(adapter.dispatch('get_dcl_statement_list', 'dbt')(relation, grant_config, get_dcl_macro)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_dcl_statement_list" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.519727, + "supported_languages": null + }, + "macro.dbt.default__get_dcl_statement_list": { + "name": "default__get_dcl_statement_list", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.default__get_dcl_statement_list", + "macro_sql": "\n\n{%- macro default__get_dcl_statement_list(relation, grant_config, get_dcl_macro) -%}\n {#\n -- Unpack grant_config into specific privileges and the set of users who need them granted/revoked.\n -- Depending on whether this database supports multiple grantees per statement, pass in the list of\n -- all grantees per privilege, or (if not) template one statement per privilege-grantee pair.\n -- `get_dcl_macro` will be either `get_grant_sql` or `get_revoke_sql`\n #}\n {%- set dcl_statements = [] -%}\n {%- for privilege, grantees in grant_config.items() %}\n {%- if support_multiple_grantees_per_dcl_statement() and grantees -%}\n {%- set dcl = get_dcl_macro(relation, privilege, grantees) -%}\n {%- do dcl_statements.append(dcl) -%}\n {%- else -%}\n {%- for grantee in grantees -%}\n {% set dcl = get_dcl_macro(relation, privilege, [grantee]) %}\n {%- do dcl_statements.append(dcl) -%}\n {% endfor -%}\n {%- endif -%}\n {%- endfor -%}\n {{ return(dcl_statements) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.support_multiple_grantees_per_dcl_statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.520511, + "supported_languages": null + }, + "macro.dbt.call_dcl_statements": { + "name": "call_dcl_statements", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.call_dcl_statements", + "macro_sql": "{% macro call_dcl_statements(dcl_statement_list) %}\n {{ return(adapter.dispatch(\"call_dcl_statements\", \"dbt\")(dcl_statement_list)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__call_dcl_statements" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.520698, + "supported_languages": null + }, + "macro.dbt.default__call_dcl_statements": { + "name": "default__call_dcl_statements", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.default__call_dcl_statements", + "macro_sql": "{% macro default__call_dcl_statements(dcl_statement_list) %}\n {#\n -- By default, supply all grant + revoke statements in a single semicolon-separated block,\n -- so that they're all processed together.\n\n -- Some databases do not support this. Those adapters will need to override this macro\n -- to run each statement individually.\n #}\n {% call statement('grants') %}\n {% for dcl_statement in dcl_statement_list %}\n {{ dcl_statement }};\n {% endfor %}\n {% endcall %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.520941, + "supported_languages": null + }, + "macro.dbt.apply_grants": { + "name": "apply_grants", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.apply_grants", + "macro_sql": "{% macro apply_grants(relation, grant_config, should_revoke) %}\n {{ return(adapter.dispatch(\"apply_grants\", \"dbt\")(relation, grant_config, should_revoke)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__apply_grants" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.521177, + "supported_languages": null + }, + "macro.dbt.default__apply_grants": { + "name": "default__apply_grants", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/apply_grants.sql", + "original_file_path": "macros/adapters/apply_grants.sql", + "unique_id": "macro.dbt.default__apply_grants", + "macro_sql": "{% macro default__apply_grants(relation, grant_config, should_revoke=True) %}\n {#-- If grant_config is {} or None, this is a no-op --#}\n {% if grant_config %}\n {% if should_revoke %}\n {#-- We think previous grants may have carried over --#}\n {#-- Show current grants and calculate diffs --#}\n {% set current_grants_table = run_query(get_show_grant_sql(relation)) %}\n {% set current_grants_dict = adapter.standardize_grants_dict(current_grants_table) %}\n {% set needs_granting = diff_of_two_dicts(grant_config, current_grants_dict) %}\n {% set needs_revoking = diff_of_two_dicts(current_grants_dict, grant_config) %}\n {% if not (needs_granting or needs_revoking) %}\n {{ log('On ' ~ relation ~': All grants are in place, no revocation or granting needed.')}}\n {% endif %}\n {% else %}\n {#-- We don't think there's any chance of previous grants having carried over. --#}\n {#-- Jump straight to granting what the user has configured. --#}\n {% set needs_revoking = {} %}\n {% set needs_granting = grant_config %}\n {% endif %}\n {% if needs_granting or needs_revoking %}\n {% set revoke_statement_list = get_dcl_statement_list(relation, needs_revoking, get_revoke_sql) %}\n {% set grant_statement_list = get_dcl_statement_list(relation, needs_granting, get_grant_sql) %}\n {% set dcl_statement_list = revoke_statement_list + grant_statement_list %}\n {% if dcl_statement_list %}\n {{ call_dcl_statements(dcl_statement_list) }}\n {% endif %}\n {% endif %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.run_query", + "macro.dbt.get_show_grant_sql", + "macro.dbt.get_dcl_statement_list", + "macro.dbt.call_dcl_statements" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5223181, + "supported_languages": null + }, + "macro.dbt.get_show_sql": { + "name": "get_show_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/show.sql", + "original_file_path": "macros/adapters/show.sql", + "unique_id": "macro.dbt.get_show_sql", + "macro_sql": "{% macro get_show_sql(compiled_code, sql_header, limit) -%}\n {%- if sql_header -%}\n {{ sql_header }}\n {%- endif -%}\n {%- if limit is not none -%}\n {{ get_limit_subquery_sql(compiled_code, limit) }}\n {%- else -%}\n {{ compiled_code }}\n {%- endif -%}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_limit_subquery_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.522868, + "supported_languages": null + }, + "macro.dbt.get_limit_subquery_sql": { + "name": "get_limit_subquery_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/show.sql", + "original_file_path": "macros/adapters/show.sql", + "unique_id": "macro.dbt.get_limit_subquery_sql", + "macro_sql": "{% macro get_limit_subquery_sql(sql, limit) %}\n {{ adapter.dispatch('get_limit_subquery_sql', 'dbt')(sql, limit) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_limit_subquery_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.523055, + "supported_languages": null + }, + "macro.dbt.default__get_limit_subquery_sql": { + "name": "default__get_limit_subquery_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/show.sql", + "original_file_path": "macros/adapters/show.sql", + "unique_id": "macro.dbt.default__get_limit_subquery_sql", + "macro_sql": "{% macro default__get_limit_subquery_sql(sql, limit) %}\n select *\n from (\n {{ sql }}\n ) as model_limit_subq\n limit {{ limit }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.523187, + "supported_languages": null + }, + "macro.dbt.alter_column_comment": { + "name": "alter_column_comment", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/persist_docs.sql", + "original_file_path": "macros/adapters/persist_docs.sql", + "unique_id": "macro.dbt.alter_column_comment", + "macro_sql": "{% macro alter_column_comment(relation, column_dict) -%}\n {{ return(adapter.dispatch('alter_column_comment', 'dbt')(relation, column_dict)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__alter_column_comment" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.523856, + "supported_languages": null + }, + "macro.dbt.default__alter_column_comment": { + "name": "default__alter_column_comment", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/persist_docs.sql", + "original_file_path": "macros/adapters/persist_docs.sql", + "unique_id": "macro.dbt.default__alter_column_comment", + "macro_sql": "{% macro default__alter_column_comment(relation, column_dict) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_column_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.52402, + "supported_languages": null + }, + "macro.dbt.alter_relation_comment": { + "name": "alter_relation_comment", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/persist_docs.sql", + "original_file_path": "macros/adapters/persist_docs.sql", + "unique_id": "macro.dbt.alter_relation_comment", + "macro_sql": "{% macro alter_relation_comment(relation, relation_comment) -%}\n {{ return(adapter.dispatch('alter_relation_comment', 'dbt')(relation, relation_comment)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__alter_relation_comment" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.524222, + "supported_languages": null + }, + "macro.dbt.default__alter_relation_comment": { + "name": "default__alter_relation_comment", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/persist_docs.sql", + "original_file_path": "macros/adapters/persist_docs.sql", + "unique_id": "macro.dbt.default__alter_relation_comment", + "macro_sql": "{% macro default__alter_relation_comment(relation, relation_comment) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_relation_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.524385, + "supported_languages": null + }, + "macro.dbt.persist_docs": { + "name": "persist_docs", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/persist_docs.sql", + "original_file_path": "macros/adapters/persist_docs.sql", + "unique_id": "macro.dbt.persist_docs", + "macro_sql": "{% macro persist_docs(relation, model, for_relation=true, for_columns=true) -%}\n {{ return(adapter.dispatch('persist_docs', 'dbt')(relation, model, for_relation, for_columns)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__persist_docs" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.524649, + "supported_languages": null + }, + "macro.dbt.default__persist_docs": { + "name": "default__persist_docs", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/persist_docs.sql", + "original_file_path": "macros/adapters/persist_docs.sql", + "unique_id": "macro.dbt.default__persist_docs", + "macro_sql": "{% macro default__persist_docs(relation, model, for_relation, for_columns) -%}\n {% if for_relation and config.persist_relation_docs() and model.description %}\n {% do run_query(alter_relation_comment(relation, model.description)) %}\n {% endif %}\n\n {% if for_columns and config.persist_column_docs() and model.columns %}\n {% do run_query(alter_column_comment(relation, model.columns)) %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.run_query", + "macro.dbt.alter_relation_comment", + "macro.dbt.alter_column_comment" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5251148, + "supported_languages": null + }, + "macro.dbt.get_catalog_relations": { + "name": "get_catalog_relations", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.get_catalog_relations", + "macro_sql": "{% macro get_catalog_relations(information_schema, relations) -%}\n {{ return(adapter.dispatch('get_catalog_relations', 'dbt')(information_schema, relations)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_catalog_relations" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.52829, + "supported_languages": null + }, + "macro.dbt.default__get_catalog_relations": { + "name": "default__get_catalog_relations", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.default__get_catalog_relations", + "macro_sql": "{% macro default__get_catalog_relations(information_schema, relations) -%}\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog_relations not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.528616, + "supported_languages": null + }, + "macro.dbt.get_catalog": { + "name": "get_catalog", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.get_catalog", + "macro_sql": "{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter.dispatch('get_catalog', 'dbt')(information_schema, schemas)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_catalog" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.528841, + "supported_languages": null + }, + "macro.dbt.default__get_catalog": { + "name": "default__get_catalog", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.default__get_catalog", + "macro_sql": "{% macro default__get_catalog(information_schema, schemas) -%}\n\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5291278, + "supported_languages": null + }, + "macro.dbt.information_schema_name": { + "name": "information_schema_name", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.information_schema_name", + "macro_sql": "{% macro information_schema_name(database) %}\n {{ return(adapter.dispatch('information_schema_name', 'dbt')(database)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__information_schema_name" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.529328, + "supported_languages": null + }, + "macro.dbt.default__information_schema_name": { + "name": "default__information_schema_name", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.default__information_schema_name", + "macro_sql": "{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ database }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.529492, + "supported_languages": null + }, + "macro.dbt.list_schemas": { + "name": "list_schemas", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.list_schemas", + "macro_sql": "{% macro list_schemas(database) -%}\n {{ return(adapter.dispatch('list_schemas', 'dbt')(database)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__list_schemas" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.529669, + "supported_languages": null + }, + "macro.dbt.default__list_schemas": { + "name": "default__list_schemas", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.default__list_schemas", + "macro_sql": "{% macro default__list_schemas(database) -%}\n {% set sql %}\n select distinct schema_name\n from {{ information_schema_name(database) }}.SCHEMATA\n where catalog_name ilike '{{ database }}'\n {% endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.information_schema_name", + "macro.dbt.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.530029, + "supported_languages": null + }, + "macro.dbt.check_schema_exists": { + "name": "check_schema_exists", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.check_schema_exists", + "macro_sql": "{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter.dispatch('check_schema_exists', 'dbt')(information_schema, schema)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__check_schema_exists" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.530261, + "supported_languages": null + }, + "macro.dbt.default__check_schema_exists": { + "name": "default__check_schema_exists", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.default__check_schema_exists", + "macro_sql": "{% macro default__check_schema_exists(information_schema, schema) -%}\n {% set sql -%}\n select count(*)\n from {{ information_schema.replace(information_schema_view='SCHEMATA') }}\n where catalog_name='{{ information_schema.database }}'\n and schema_name='{{ schema }}'\n {%- endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.replace", + "macro.dbt.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.530569, + "supported_languages": null + }, + "macro.dbt.list_relations_without_caching": { + "name": "list_relations_without_caching", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.list_relations_without_caching", + "macro_sql": "{% macro list_relations_without_caching(schema_relation) %}\n {{ return(adapter.dispatch('list_relations_without_caching', 'dbt')(schema_relation)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__list_relations_without_caching" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.530765, + "supported_languages": null + }, + "macro.dbt.default__list_relations_without_caching": { + "name": "default__list_relations_without_caching", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.default__list_relations_without_caching", + "macro_sql": "{% macro default__list_relations_without_caching(schema_relation) %}\n {{ exceptions.raise_not_implemented(\n 'list_relations_without_caching macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.530933, + "supported_languages": null + }, + "macro.dbt.get_relations": { + "name": "get_relations", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.get_relations", + "macro_sql": "{% macro get_relations() %}\n {{ return(adapter.dispatch('get_relations', 'dbt')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_relations" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.531112, + "supported_languages": null + }, + "macro.dbt.default__get_relations": { + "name": "default__get_relations", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.default__get_relations", + "macro_sql": "{% macro default__get_relations() %}\n {{ exceptions.raise_not_implemented(\n 'get_relations macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5312672, + "supported_languages": null + }, + "macro.dbt.get_relation_last_modified": { + "name": "get_relation_last_modified", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.get_relation_last_modified", + "macro_sql": "{% macro get_relation_last_modified(information_schema, relations) %}\n {{ return(adapter.dispatch('get_relation_last_modified', 'dbt')(information_schema, relations)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_relation_last_modified" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.531483, + "supported_languages": null + }, + "macro.dbt.default__get_relation_last_modified": { + "name": "default__get_relation_last_modified", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/metadata.sql", + "original_file_path": "macros/adapters/metadata.sql", + "unique_id": "macro.dbt.default__get_relation_last_modified", + "macro_sql": "{% macro default__get_relation_last_modified(information_schema, relations) %}\n {{ exceptions.raise_not_implemented(\n 'get_relation_last_modified macro not implemented for adapter ' + adapter.type()) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5316632, + "supported_languages": null + }, + "macro.dbt.get_columns_in_relation": { + "name": "get_columns_in_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "unique_id": "macro.dbt.get_columns_in_relation", + "macro_sql": "{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter.dispatch('get_columns_in_relation', 'dbt')(relation)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__get_columns_in_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5340831, + "supported_languages": null + }, + "macro.dbt.default__get_columns_in_relation": { + "name": "default__get_columns_in_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "unique_id": "macro.dbt.default__get_columns_in_relation", + "macro_sql": "{% macro default__get_columns_in_relation(relation) -%}\n {{ exceptions.raise_not_implemented(\n 'get_columns_in_relation macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5342479, + "supported_languages": null + }, + "macro.dbt.sql_convert_columns_in_relation": { + "name": "sql_convert_columns_in_relation", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "unique_id": "macro.dbt.sql_convert_columns_in_relation", + "macro_sql": "{% macro sql_convert_columns_in_relation(table) -%}\n {% set columns = [] %}\n {% for row in table %}\n {% do columns.append(api.Column(*row)) %}\n {% endfor %}\n {{ return(columns) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.534564, + "supported_languages": null + }, + "macro.dbt.get_empty_subquery_sql": { + "name": "get_empty_subquery_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "unique_id": "macro.dbt.get_empty_subquery_sql", + "macro_sql": "{% macro get_empty_subquery_sql(select_sql, select_sql_header=none) -%}\n {{ return(adapter.dispatch('get_empty_subquery_sql', 'dbt')(select_sql, select_sql_header)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_empty_subquery_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.534792, + "supported_languages": null + }, + "macro.dbt.default__get_empty_subquery_sql": { + "name": "default__get_empty_subquery_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "unique_id": "macro.dbt.default__get_empty_subquery_sql", + "macro_sql": "{% macro default__get_empty_subquery_sql(select_sql, select_sql_header=none) %}\n {%- if select_sql_header is not none -%}\n {{ select_sql_header }}\n {%- endif -%}\n select * from (\n {{ select_sql }}\n ) as __dbt_sbq\n where false\n limit 0\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5350158, + "supported_languages": null + }, + "macro.dbt.get_empty_schema_sql": { + "name": "get_empty_schema_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "unique_id": "macro.dbt.get_empty_schema_sql", + "macro_sql": "{% macro get_empty_schema_sql(columns) -%}\n {{ return(adapter.dispatch('get_empty_schema_sql', 'dbt')(columns)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_empty_schema_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.535209, + "supported_languages": null + }, + "macro.dbt.default__get_empty_schema_sql": { + "name": "default__get_empty_schema_sql", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "unique_id": "macro.dbt.default__get_empty_schema_sql", + "macro_sql": "{% macro default__get_empty_schema_sql(columns) %}\n {%- set col_err = [] -%}\n {%- set col_naked_numeric = [] -%}\n select\n {% for i in columns %}\n {%- set col = columns[i] -%}\n {%- if col['data_type'] is not defined -%}\n {%- do col_err.append(col['name']) -%}\n {#-- If this column's type is just 'numeric' then it is missing precision/scale, raise a warning --#}\n {%- elif col['data_type'].strip().lower() in ('numeric', 'decimal', 'number') -%}\n {%- do col_naked_numeric.append(col['name']) -%}\n {%- endif -%}\n {% set col_name = adapter.quote(col['name']) if col.get('quote') else col['name'] %}\n cast(null as {{ col['data_type'] }}) as {{ col_name }}{{ \", \" if not loop.last }}\n {%- endfor -%}\n {%- if (col_err | length) > 0 -%}\n {{ exceptions.column_type_missing(column_names=col_err) }}\n {%- elif (col_naked_numeric | length) > 0 -%}\n {{ exceptions.warn(\"Detected columns with numeric type and unspecified precision/scale, this can lead to unintended rounding: \" ~ col_naked_numeric ~ \"`\") }}\n {%- endif -%}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.536476, + "supported_languages": null + }, + "macro.dbt.get_column_schema_from_query": { + "name": "get_column_schema_from_query", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "unique_id": "macro.dbt.get_column_schema_from_query", + "macro_sql": "{% macro get_column_schema_from_query(select_sql, select_sql_header=none) -%}\n {% set columns = [] %}\n {# -- Using an 'empty subquery' here to get the same schema as the given select_sql statement, without necessitating a data scan.#}\n {% set sql = get_empty_subquery_sql(select_sql, select_sql_header) %}\n {% set column_schema = adapter.get_column_schema_from_query(sql) %}\n {{ return(column_schema) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_empty_subquery_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.536832, + "supported_languages": null + }, + "macro.dbt.get_columns_in_query": { + "name": "get_columns_in_query", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "unique_id": "macro.dbt.get_columns_in_query", + "macro_sql": "{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter.dispatch('get_columns_in_query', 'dbt')(select_sql)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__get_columns_in_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5370119, + "supported_languages": null + }, + "macro.dbt.default__get_columns_in_query": { + "name": "default__get_columns_in_query", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "unique_id": "macro.dbt.default__get_columns_in_query", + "macro_sql": "{% macro default__get_columns_in_query(select_sql) %}\n {% call statement('get_columns_in_query', fetch_result=True, auto_begin=False) -%}\n {{ get_empty_subquery_sql(select_sql) }}\n {% endcall %}\n {{ return(load_result('get_columns_in_query').table.columns | map(attribute='name') | list) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.dbt.get_empty_subquery_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.537375, + "supported_languages": null + }, + "macro.dbt.alter_column_type": { + "name": "alter_column_type", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "unique_id": "macro.dbt.alter_column_type", + "macro_sql": "{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter.dispatch('alter_column_type', 'dbt')(relation, column_name, new_column_type)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__alter_column_type" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.537594, + "supported_languages": null + }, + "macro.dbt.default__alter_column_type": { + "name": "default__alter_column_type", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "unique_id": "macro.dbt.default__alter_column_type", + "macro_sql": "{% macro default__alter_column_type(relation, column_name, new_column_type) -%}\n {#\n 1. Create a new column (w/ temp name and correct type)\n 2. Copy data over to it\n 3. Drop the existing column (cascade!)\n 4. Rename the new column to existing column\n #}\n {%- set tmp_column = column_name + \"__dbt_alter\" -%}\n\n {% call statement('alter_column_type') %}\n alter table {{ relation }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};\n update {{ relation }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};\n alter table {{ relation }} drop column {{ adapter.quote(column_name) }} cascade;\n alter table {{ relation }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}\n {% endcall %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.538181, + "supported_languages": null + }, + "macro.dbt.alter_relation_add_remove_columns": { + "name": "alter_relation_add_remove_columns", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "unique_id": "macro.dbt.alter_relation_add_remove_columns", + "macro_sql": "{% macro alter_relation_add_remove_columns(relation, add_columns = none, remove_columns = none) -%}\n {{ return(adapter.dispatch('alter_relation_add_remove_columns', 'dbt')(relation, add_columns, remove_columns)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_snowflake.snowflake__alter_relation_add_remove_columns" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.53844, + "supported_languages": null + }, + "macro.dbt.default__alter_relation_add_remove_columns": { + "name": "default__alter_relation_add_remove_columns", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/adapters/columns.sql", + "original_file_path": "macros/adapters/columns.sql", + "unique_id": "macro.dbt.default__alter_relation_add_remove_columns", + "macro_sql": "{% macro default__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if add_columns is none %}\n {% set add_columns = [] %}\n {% endif %}\n {% if remove_columns is none %}\n {% set remove_columns = [] %}\n {% endif %}\n\n {% set sql -%}\n\n alter {{ relation.type }} {{ relation }}\n\n {% for column in add_columns %}\n add column {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}{{ ',' if add_columns and remove_columns }}\n\n {% for column in remove_columns %}\n drop column {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5392041, + "supported_languages": null + }, + "macro.dbt.resolve_model_name": { + "name": "resolve_model_name", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/python_model/python.sql", + "original_file_path": "macros/python_model/python.sql", + "unique_id": "macro.dbt.resolve_model_name", + "macro_sql": "{% macro resolve_model_name(input_model_name) %}\n {{ return(adapter.dispatch('resolve_model_name', 'dbt')(input_model_name)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.default__resolve_model_name" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.540909, + "supported_languages": null + }, + "macro.dbt.default__resolve_model_name": { + "name": "default__resolve_model_name", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/python_model/python.sql", + "original_file_path": "macros/python_model/python.sql", + "unique_id": "macro.dbt.default__resolve_model_name", + "macro_sql": "\n\n{%- macro default__resolve_model_name(input_model_name) -%}\n {{ input_model_name | string | replace('\"', '\\\"') }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.541065, + "supported_languages": null + }, + "macro.dbt.build_ref_function": { + "name": "build_ref_function", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/python_model/python.sql", + "original_file_path": "macros/python_model/python.sql", + "unique_id": "macro.dbt.build_ref_function", + "macro_sql": "{% macro build_ref_function(model) %}\n\n {%- set ref_dict = {} -%}\n {%- for _ref in model.refs -%}\n {% set _ref_args = [_ref.get('package'), _ref['name']] if _ref.get('package') else [_ref['name'],] %}\n {%- set resolved = ref(*_ref_args, v=_ref.get('version')) -%}\n {%- if _ref.get('version') -%}\n {% do _ref_args.extend([\"v\" ~ _ref['version']]) %}\n {%- endif -%}\n {%- do ref_dict.update({_ref_args | join('.'): resolve_model_name(resolved)}) -%}\n {%- endfor -%}\n\ndef ref(*args, **kwargs):\n refs = {{ ref_dict | tojson }}\n key = '.'.join(args)\n version = kwargs.get(\"v\") or kwargs.get(\"version\")\n if version:\n key += f\".v{version}\"\n dbt_load_df_function = kwargs.get(\"dbt_load_df_function\")\n return dbt_load_df_function(refs[key])\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.resolve_model_name" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5418649, + "supported_languages": null + }, + "macro.dbt.build_source_function": { + "name": "build_source_function", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/python_model/python.sql", + "original_file_path": "macros/python_model/python.sql", + "unique_id": "macro.dbt.build_source_function", + "macro_sql": "{% macro build_source_function(model) %}\n\n {%- set source_dict = {} -%}\n {%- for _source in model.sources -%}\n {%- set resolved = source(*_source) -%}\n {%- do source_dict.update({_source | join('.'): resolve_model_name(resolved)}) -%}\n {%- endfor -%}\n\ndef source(*args, dbt_load_df_function):\n sources = {{ source_dict | tojson }}\n key = '.'.join(args)\n return dbt_load_df_function(sources[key])\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.resolve_model_name" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5422778, + "supported_languages": null + }, + "macro.dbt.build_config_dict": { + "name": "build_config_dict", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/python_model/python.sql", + "original_file_path": "macros/python_model/python.sql", + "unique_id": "macro.dbt.build_config_dict", + "macro_sql": "{% macro build_config_dict(model) %}\n {%- set config_dict = {} -%}\n {% set config_dbt_used = zip(model.config.config_keys_used, model.config.config_keys_defaults) | list %}\n {%- for key, default in config_dbt_used -%}\n {# weird type testing with enum, would be much easier to write this logic in Python! #}\n {%- if key == \"language\" -%}\n {%- set value = \"python\" -%}\n {%- endif -%}\n {%- set value = model.config.get(key, default) -%}\n {%- do config_dict.update({key: value}) -%}\n {%- endfor -%}\nconfig_dict = {{ config_dict }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.54284, + "supported_languages": null + }, + "macro.dbt.py_script_postfix": { + "name": "py_script_postfix", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/python_model/python.sql", + "original_file_path": "macros/python_model/python.sql", + "unique_id": "macro.dbt.py_script_postfix", + "macro_sql": "{% macro py_script_postfix(model) %}\n# This part is user provided model code\n# you will need to copy the next section to run the code\n# COMMAND ----------\n# this part is dbt logic for get ref work, do not modify\n\n{{ build_ref_function(model ) }}\n{{ build_source_function(model ) }}\n{{ build_config_dict(model) }}\n\nclass config:\n def __init__(self, *args, **kwargs):\n pass\n\n @staticmethod\n def get(key, default=None):\n return config_dict.get(key, default)\n\nclass this:\n \"\"\"dbt.this() or dbt.this.identifier\"\"\"\n database = \"{{ this.database }}\"\n schema = \"{{ this.schema }}\"\n identifier = \"{{ this.identifier }}\"\n {% set this_relation_name = resolve_model_name(this) %}\n def __repr__(self):\n return '{{ this_relation_name }}'\n\n\nclass dbtObj:\n def __init__(self, load_df_function) -> None:\n self.source = lambda *args: source(*args, dbt_load_df_function=load_df_function)\n self.ref = lambda *args, **kwargs: ref(*args, **kwargs, dbt_load_df_function=load_df_function)\n self.config = config\n self.this = this()\n self.is_incremental = {{ is_incremental() }}\n\n# COMMAND ----------\n{{py_script_comment()}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.build_ref_function", + "macro.dbt.build_source_function", + "macro.dbt.build_config_dict", + "macro.dbt.resolve_model_name", + "macro.dbt.is_incremental", + "macro.dbt.py_script_comment" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.543297, + "supported_languages": null + }, + "macro.dbt.py_script_comment": { + "name": "py_script_comment", + "resource_type": "macro", + "package_name": "dbt", + "path": "macros/python_model/python.sql", + "original_file_path": "macros/python_model/python.sql", + "unique_id": "macro.dbt.py_script_comment", + "macro_sql": "{%macro py_script_comment()%}\n{%endmacro%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.543377, + "supported_languages": null + }, + "macro.dbt.test_unique": { + "name": "test_unique", + "resource_type": "macro", + "package_name": "dbt", + "path": "tests/generic/builtin.sql", + "original_file_path": "tests/generic/builtin.sql", + "unique_id": "macro.dbt.test_unique", + "macro_sql": "{% test unique(model, column_name) %}\n {% set macro = adapter.dispatch('test_unique', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt.default__test_unique" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.54388, + "supported_languages": null + }, + "macro.dbt.test_not_null": { + "name": "test_not_null", + "resource_type": "macro", + "package_name": "dbt", + "path": "tests/generic/builtin.sql", + "original_file_path": "tests/generic/builtin.sql", + "unique_id": "macro.dbt.test_not_null", + "macro_sql": "{% test not_null(model, column_name) %}\n {% set macro = adapter.dispatch('test_not_null', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt.default__test_not_null" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.54411, + "supported_languages": null + }, + "macro.dbt.test_accepted_values": { + "name": "test_accepted_values", + "resource_type": "macro", + "package_name": "dbt", + "path": "tests/generic/builtin.sql", + "original_file_path": "tests/generic/builtin.sql", + "unique_id": "macro.dbt.test_accepted_values", + "macro_sql": "{% test accepted_values(model, column_name, values, quote=True) %}\n {% set macro = adapter.dispatch('test_accepted_values', 'dbt') %}\n {{ macro(model, column_name, values, quote) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt.default__test_accepted_values" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.544391, + "supported_languages": null + }, + "macro.dbt.test_relationships": { + "name": "test_relationships", + "resource_type": "macro", + "package_name": "dbt", + "path": "tests/generic/builtin.sql", + "original_file_path": "tests/generic/builtin.sql", + "unique_id": "macro.dbt.test_relationships", + "macro_sql": "{% test relationships(model, column_name, to, field) %}\n {% set macro = adapter.dispatch('test_relationships', 'dbt') %}\n {{ macro(model, column_name, to, field) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt.default__test_relationships" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.544682, + "supported_languages": null + }, + "macro.dbt_utils.get_url_host": { + "name": "get_url_host", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/web/get_url_host.sql", + "original_file_path": "macros/web/get_url_host.sql", + "unique_id": "macro.dbt_utils.get_url_host", + "macro_sql": "{% macro get_url_host(field) -%}\n {{ return(adapter.dispatch('get_url_host', 'dbt_utils')(field)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__get_url_host" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5450501, + "supported_languages": null + }, + "macro.dbt_utils.default__get_url_host": { + "name": "default__get_url_host", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/web/get_url_host.sql", + "original_file_path": "macros/web/get_url_host.sql", + "unique_id": "macro.dbt_utils.default__get_url_host", + "macro_sql": "{% macro default__get_url_host(field) -%}\n\n{%- set parsed =\n dbt.split_part(\n dbt.split_part(\n dbt.replace(\n dbt.replace(\n dbt.replace(field, \"'android-app://'\", \"''\"\n ), \"'http://'\", \"''\"\n ), \"'https://'\", \"''\"\n ), \"'/'\", 1\n ), \"'?'\", 1\n )\n\n-%}\n\n\n {{ dbt.safe_cast(\n parsed,\n dbt.type_string()\n )}}\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.split_part", + "macro.dbt.replace", + "macro.dbt.safe_cast", + "macro.dbt.type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.545595, + "supported_languages": null + }, + "macro.dbt_utils.get_url_path": { + "name": "get_url_path", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/web/get_url_path.sql", + "original_file_path": "macros/web/get_url_path.sql", + "unique_id": "macro.dbt_utils.get_url_path", + "macro_sql": "{% macro get_url_path(field) -%}\n {{ return(adapter.dispatch('get_url_path', 'dbt_utils')(field)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__get_url_path" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5460858, + "supported_languages": null + }, + "macro.dbt_utils.default__get_url_path": { + "name": "default__get_url_path", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/web/get_url_path.sql", + "original_file_path": "macros/web/get_url_path.sql", + "unique_id": "macro.dbt_utils.default__get_url_path", + "macro_sql": "{% macro default__get_url_path(field) -%}\n\n {%- set stripped_url =\n dbt.replace(\n dbt.replace(field, \"'http://'\", \"''\"), \"'https://'\", \"''\")\n -%}\n\n {%- set first_slash_pos -%}\n coalesce(\n nullif({{ dbt.position(\"'/'\", stripped_url) }}, 0),\n {{ dbt.position(\"'?'\", stripped_url) }} - 1\n )\n {%- endset -%}\n\n {%- set parsed_path =\n dbt.split_part(\n dbt.right(\n stripped_url,\n dbt.length(stripped_url) ~ \"-\" ~ first_slash_pos\n ),\n \"'?'\", 1\n )\n -%}\n\n {{ dbt.safe_cast(\n parsed_path,\n dbt.type_string()\n )}}\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.replace", + "macro.dbt.position", + "macro.dbt.split_part", + "macro.dbt.right", + "macro.dbt.length", + "macro.dbt.safe_cast", + "macro.dbt.type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.546731, + "supported_languages": null + }, + "macro.dbt_utils.get_url_parameter": { + "name": "get_url_parameter", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/web/get_url_parameter.sql", + "original_file_path": "macros/web/get_url_parameter.sql", + "unique_id": "macro.dbt_utils.get_url_parameter", + "macro_sql": "{% macro get_url_parameter(field, url_parameter) -%}\n {{ return(adapter.dispatch('get_url_parameter', 'dbt_utils')(field, url_parameter)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__get_url_parameter" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.547104, + "supported_languages": null + }, + "macro.dbt_utils.default__get_url_parameter": { + "name": "default__get_url_parameter", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/web/get_url_parameter.sql", + "original_file_path": "macros/web/get_url_parameter.sql", + "unique_id": "macro.dbt_utils.default__get_url_parameter", + "macro_sql": "{% macro default__get_url_parameter(field, url_parameter) -%}\n\n{%- set formatted_url_parameter = \"'\" + url_parameter + \"='\" -%}\n\n{%- set split = dbt.split_part(dbt.split_part(field, formatted_url_parameter, 2), \"'&'\", 1) -%}\n\nnullif({{ split }},'')\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.split_part" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.547462, + "supported_languages": null + }, + "macro.dbt_utils.test_fewer_rows_than": { + "name": "test_fewer_rows_than", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/fewer_rows_than.sql", + "original_file_path": "macros/generic_tests/fewer_rows_than.sql", + "unique_id": "macro.dbt_utils.test_fewer_rows_than", + "macro_sql": "{% test fewer_rows_than(model, compare_model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_fewer_rows_than', 'dbt_utils')(model, compare_model, group_by_columns)) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_fewer_rows_than" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5486689, + "supported_languages": null + }, + "macro.dbt_utils.default__test_fewer_rows_than": { + "name": "default__test_fewer_rows_than", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/fewer_rows_than.sql", + "original_file_path": "macros/generic_tests/fewer_rows_than.sql", + "unique_id": "macro.dbt_utils.default__test_fewer_rows_than", + "macro_sql": "{% macro default__test_fewer_rows_than(model, compare_model, group_by_columns) %}\n\n{{ config(fail_calc = 'sum(coalesce(row_count_delta, 0))') }}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set join_gb_cols %}\n {% for c in group_by_columns %}\n and a.{{c}} = b.{{c}}\n {% endfor %}\n {% endset %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n{#-- We must add a fake join key in case additional grouping variables are not provided --#}\n{#-- Redshift does not allow for dynamically created join conditions (e.g. full join on 1 = 1 --#}\n{#-- The same logic is used in equal_rowcount. In case of changes, maintain consistent logic --#}\n{% set group_by_columns = ['id_dbtutils_test_fewer_rows_than'] + group_by_columns %}\n{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n\n\nwith a as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_fewer_rows_than,\n count(*) as count_our_model \n from {{ model }}\n {{ groupby_gb_cols }}\n\n),\nb as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_fewer_rows_than,\n count(*) as count_comparison_model \n from {{ compare_model }}\n {{ groupby_gb_cols }}\n\n),\ncounts as (\n\n select\n\n {% for c in group_by_columns -%}\n a.{{c}} as {{c}}_a,\n b.{{c}} as {{c}}_b,\n {% endfor %}\n\n count_our_model,\n count_comparison_model\n from a\n full join b on \n a.id_dbtutils_test_fewer_rows_than = b.id_dbtutils_test_fewer_rows_than\n {{ join_gb_cols }}\n\n),\nfinal as (\n\n select *,\n case\n -- fail the test if we have more rows than the reference model and return the row count delta\n when count_our_model > count_comparison_model then (count_our_model - count_comparison_model)\n -- fail the test if they are the same number\n when count_our_model = count_comparison_model then 1\n -- pass the test if the delta is positive (i.e. return the number 0)\n else 0\n end as row_count_delta\n from counts\n\n)\n\nselect * from final\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5498161, + "supported_languages": null + }, + "macro.dbt_utils.test_equal_rowcount": { + "name": "test_equal_rowcount", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/equal_rowcount.sql", + "original_file_path": "macros/generic_tests/equal_rowcount.sql", + "unique_id": "macro.dbt_utils.test_equal_rowcount", + "macro_sql": "{% test equal_rowcount(model, compare_model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_equal_rowcount', 'dbt_utils')(model, compare_model, group_by_columns)) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_equal_rowcount" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5507379, + "supported_languages": null + }, + "macro.dbt_utils.default__test_equal_rowcount": { + "name": "default__test_equal_rowcount", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/equal_rowcount.sql", + "original_file_path": "macros/generic_tests/equal_rowcount.sql", + "unique_id": "macro.dbt_utils.default__test_equal_rowcount", + "macro_sql": "{% macro default__test_equal_rowcount(model, compare_model, group_by_columns) %}\n\n{#-- Needs to be set at parse time, before we return '' below --#}\n{{ config(fail_calc = 'sum(coalesce(diff_count, 0))') }}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(', ') + ', ' %}\n {% set join_gb_cols %}\n {% for c in group_by_columns %}\n and a.{{c}} = b.{{c}}\n {% endfor %}\n {% endset %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n{#-- We must add a fake join key in case additional grouping variables are not provided --#}\n{#-- Redshift does not allow for dynamically created join conditions (e.g. full join on 1 = 1 --#}\n{#-- The same logic is used in fewer_rows_than. In case of changes, maintain consistent logic --#}\n{% set group_by_columns = ['id_dbtutils_test_equal_rowcount'] + group_by_columns %}\n{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n\nwith a as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_equal_rowcount,\n count(*) as count_a \n from {{ model }}\n {{groupby_gb_cols}}\n\n\n),\nb as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_equal_rowcount,\n count(*) as count_b \n from {{ compare_model }}\n {{groupby_gb_cols}}\n\n),\nfinal as (\n\n select\n \n {% for c in group_by_columns -%}\n a.{{c}} as {{c}}_a,\n b.{{c}} as {{c}}_b,\n {% endfor %}\n\n count_a,\n count_b,\n abs(count_a - count_b) as diff_count\n\n from a\n full join b\n on\n a.id_dbtutils_test_equal_rowcount = b.id_dbtutils_test_equal_rowcount\n {{join_gb_cols}}\n\n\n)\n\nselect * from final\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5518, + "supported_languages": null + }, + "macro.dbt_utils.test_relationships_where": { + "name": "test_relationships_where", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/relationships_where.sql", + "original_file_path": "macros/generic_tests/relationships_where.sql", + "unique_id": "macro.dbt_utils.test_relationships_where", + "macro_sql": "{% test relationships_where(model, column_name, to, field, from_condition=\"1=1\", to_condition=\"1=1\") %}\n {{ return(adapter.dispatch('test_relationships_where', 'dbt_utils')(model, column_name, to, field, from_condition, to_condition)) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_relationships_where" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.552477, + "supported_languages": null + }, + "macro.dbt_utils.default__test_relationships_where": { + "name": "default__test_relationships_where", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/relationships_where.sql", + "original_file_path": "macros/generic_tests/relationships_where.sql", + "unique_id": "macro.dbt_utils.default__test_relationships_where", + "macro_sql": "{% macro default__test_relationships_where(model, column_name, to, field, from_condition=\"1=1\", to_condition=\"1=1\") %}\n\n{# T-SQL has no boolean data type so we use 1=1 which returns TRUE #}\n{# ref https://stackoverflow.com/a/7170753/3842610 #}\n\nwith left_table as (\n\n select\n {{column_name}} as id\n\n from {{model}}\n\n where {{column_name}} is not null\n and {{from_condition}}\n\n),\n\nright_table as (\n\n select\n {{field}} as id\n\n from {{to}}\n\n where {{field}} is not null\n and {{to_condition}}\n\n),\n\nexceptions as (\n\n select\n left_table.id,\n right_table.id as right_id\n\n from left_table\n\n left join right_table\n on left_table.id = right_table.id\n\n where right_table.id is null\n\n)\n\nselect * from exceptions\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.552814, + "supported_languages": null + }, + "macro.dbt_utils.test_recency": { + "name": "test_recency", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/recency.sql", + "original_file_path": "macros/generic_tests/recency.sql", + "unique_id": "macro.dbt_utils.test_recency", + "macro_sql": "{% test recency(model, field, datepart, interval, ignore_time_component=False, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_recency', 'dbt_utils')(model, field, datepart, interval, ignore_time_component, group_by_columns)) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_recency" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.553538, + "supported_languages": null + }, + "macro.dbt_utils.default__test_recency": { + "name": "default__test_recency", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/recency.sql", + "original_file_path": "macros/generic_tests/recency.sql", + "unique_id": "macro.dbt_utils.default__test_recency", + "macro_sql": "{% macro default__test_recency(model, field, datepart, interval, ignore_time_component, group_by_columns) %}\n\n{% set threshold = 'cast(' ~ dbt.dateadd(datepart, interval * -1, dbt.current_timestamp()) ~ ' as ' ~ ('date' if ignore_time_component else dbt.type_timestamp()) ~ ')' %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n\nwith recency as (\n\n select \n\n {{ select_gb_cols }}\n {% if ignore_time_component %}\n cast(max({{ field }}) as date) as most_recent\n {%- else %}\n max({{ field }}) as most_recent\n {%- endif %}\n\n from {{ model }}\n\n {{ groupby_gb_cols }}\n\n)\n\nselect\n\n {{ select_gb_cols }}\n most_recent,\n {{ threshold }} as threshold\n\nfrom recency\nwhere most_recent < {{ threshold }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.dateadd", + "macro.dbt.current_timestamp", + "macro.dbt.type_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.554357, + "supported_languages": null + }, + "macro.dbt_utils.test_not_constant": { + "name": "test_not_constant", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/not_constant.sql", + "original_file_path": "macros/generic_tests/not_constant.sql", + "unique_id": "macro.dbt_utils.test_not_constant", + "macro_sql": "{% test not_constant(model, column_name, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_not_constant', 'dbt_utils')(model, column_name, group_by_columns)) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_not_constant" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.554822, + "supported_languages": null + }, + "macro.dbt_utils.default__test_not_constant": { + "name": "default__test_not_constant", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/not_constant.sql", + "original_file_path": "macros/generic_tests/not_constant.sql", + "unique_id": "macro.dbt_utils.default__test_not_constant", + "macro_sql": "{% macro default__test_not_constant(model, column_name, group_by_columns) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n\nselect\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n {{select_gb_cols}}\n count(distinct {{ column_name }}) as filler_column\n\nfrom {{ model }}\n\n {{groupby_gb_cols}}\n\nhaving count(distinct {{ column_name }}) = 1\n\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.555277, + "supported_languages": null + }, + "macro.dbt_utils.test_accepted_range": { + "name": "test_accepted_range", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/accepted_range.sql", + "original_file_path": "macros/generic_tests/accepted_range.sql", + "unique_id": "macro.dbt_utils.test_accepted_range", + "macro_sql": "{% test accepted_range(model, column_name, min_value=none, max_value=none, inclusive=true) %}\n {{ return(adapter.dispatch('test_accepted_range', 'dbt_utils')(model, column_name, min_value, max_value, inclusive)) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_accepted_range" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.555885, + "supported_languages": null + }, + "macro.dbt_utils.default__test_accepted_range": { + "name": "default__test_accepted_range", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/accepted_range.sql", + "original_file_path": "macros/generic_tests/accepted_range.sql", + "unique_id": "macro.dbt_utils.default__test_accepted_range", + "macro_sql": "{% macro default__test_accepted_range(model, column_name, min_value=none, max_value=none, inclusive=true) %}\n\nwith meet_condition as(\n select *\n from {{ model }}\n),\n\nvalidation_errors as (\n select *\n from meet_condition\n where\n -- never true, defaults to an empty result set. Exists to ensure any combo of the `or` clauses below succeeds\n 1 = 2\n\n {%- if min_value is not none %}\n -- records with a value >= min_value are permitted. The `not` flips this to find records that don't meet the rule.\n or not {{ column_name }} > {{- \"=\" if inclusive }} {{ min_value }}\n {%- endif %}\n\n {%- if max_value is not none %}\n -- records with a value <= max_value are permitted. The `not` flips this to find records that don't meet the rule.\n or not {{ column_name }} < {{- \"=\" if inclusive }} {{ max_value }}\n {%- endif %}\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.556352, + "supported_languages": null + }, + "macro.dbt_utils.test_not_accepted_values": { + "name": "test_not_accepted_values", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/not_accepted_values.sql", + "original_file_path": "macros/generic_tests/not_accepted_values.sql", + "unique_id": "macro.dbt_utils.test_not_accepted_values", + "macro_sql": "{% test not_accepted_values(model, column_name, values, quote=True) %}\n {{ return(adapter.dispatch('test_not_accepted_values', 'dbt_utils')(model, column_name, values, quote)) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_not_accepted_values" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.556898, + "supported_languages": null + }, + "macro.dbt_utils.default__test_not_accepted_values": { + "name": "default__test_not_accepted_values", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/not_accepted_values.sql", + "original_file_path": "macros/generic_tests/not_accepted_values.sql", + "unique_id": "macro.dbt_utils.default__test_not_accepted_values", + "macro_sql": "{% macro default__test_not_accepted_values(model, column_name, values, quote=True) %}\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 in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n )\n\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.557535, + "supported_languages": null + }, + "macro.dbt_utils.test_at_least_one": { + "name": "test_at_least_one", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/at_least_one.sql", + "original_file_path": "macros/generic_tests/at_least_one.sql", + "unique_id": "macro.dbt_utils.test_at_least_one", + "macro_sql": "{% test at_least_one(model, column_name, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_at_least_one', 'dbt_utils')(model, column_name, group_by_columns)) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_at_least_one" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.558272, + "supported_languages": null + }, + "macro.dbt_utils.default__test_at_least_one": { + "name": "default__test_at_least_one", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/at_least_one.sql", + "original_file_path": "macros/generic_tests/at_least_one.sql", + "unique_id": "macro.dbt_utils.default__test_at_least_one", + "macro_sql": "{% macro default__test_at_least_one(model, column_name, group_by_columns) %}\n\n{% set pruned_cols = [column_name] %}\n\n{% if group_by_columns|length() > 0 %}\n\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n {% set pruned_cols = group_by_columns %}\n\n {% if column_name not in pruned_cols %}\n {% do pruned_cols.append(column_name) %}\n {% endif %}\n\n{% endif %}\n\n{% set select_pruned_cols = pruned_cols|join(' ,') %}\n\nselect *\nfrom (\n with pruned_rows as (\n select\n {{ select_pruned_cols }}\n from {{ model }}\n where {{ column_name }} is not null\n limit 1\n )\n select\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n {{select_gb_cols}}\n count({{ column_name }}) as filler_column\n\n from pruned_rows\n\n {{groupby_gb_cols}}\n\n having count({{ column_name }}) = 0\n\n) validation_errors\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.55909, + "supported_languages": null + }, + "macro.dbt_utils.test_unique_combination_of_columns": { + "name": "test_unique_combination_of_columns", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/unique_combination_of_columns.sql", + "original_file_path": "macros/generic_tests/unique_combination_of_columns.sql", + "unique_id": "macro.dbt_utils.test_unique_combination_of_columns", + "macro_sql": "{% test unique_combination_of_columns(model, combination_of_columns, quote_columns=false) %}\n {{ return(adapter.dispatch('test_unique_combination_of_columns', 'dbt_utils')(model, combination_of_columns, quote_columns)) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_unique_combination_of_columns" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.559743, + "supported_languages": null + }, + "macro.dbt_utils.default__test_unique_combination_of_columns": { + "name": "default__test_unique_combination_of_columns", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/unique_combination_of_columns.sql", + "original_file_path": "macros/generic_tests/unique_combination_of_columns.sql", + "unique_id": "macro.dbt_utils.default__test_unique_combination_of_columns", + "macro_sql": "{% macro default__test_unique_combination_of_columns(model, combination_of_columns, quote_columns=false) %}\n\n{% if not quote_columns %}\n {%- set column_list=combination_of_columns %}\n{% elif quote_columns %}\n {%- set column_list=[] %}\n {% for column in combination_of_columns -%}\n {% set column_list = column_list.append( adapter.quote(column) ) %}\n {%- endfor %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`quote_columns` argument for unique_combination_of_columns test must be one of [True, False] Got: '\" ~ quote ~\"'.'\"\n ) }}\n{% endif %}\n\n{%- set columns_csv=column_list | join(', ') %}\n\n\nwith validation_errors as (\n\n select\n {{ columns_csv }}\n from {{ model }}\n group by {{ columns_csv }}\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.560419, + "supported_languages": null + }, + "macro.dbt_utils.test_cardinality_equality": { + "name": "test_cardinality_equality", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/cardinality_equality.sql", + "original_file_path": "macros/generic_tests/cardinality_equality.sql", + "unique_id": "macro.dbt_utils.test_cardinality_equality", + "macro_sql": "{% test cardinality_equality(model, column_name, to, field) %}\n {{ return(adapter.dispatch('test_cardinality_equality', 'dbt_utils')(model, column_name, to, field)) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_cardinality_equality" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.560989, + "supported_languages": null + }, + "macro.dbt_utils.default__test_cardinality_equality": { + "name": "default__test_cardinality_equality", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/cardinality_equality.sql", + "original_file_path": "macros/generic_tests/cardinality_equality.sql", + "unique_id": "macro.dbt_utils.default__test_cardinality_equality", + "macro_sql": "{% macro default__test_cardinality_equality(model, column_name, to, field) %}\n\n{# T-SQL does not let you use numbers as aliases for columns #}\n{# Thus, no \"GROUP BY 1\" #}\n\nwith table_a as (\nselect\n {{ column_name }},\n count(*) as num_rows\nfrom {{ model }}\ngroup by {{ column_name }}\n),\n\ntable_b as (\nselect\n {{ field }},\n count(*) as num_rows\nfrom {{ to }}\ngroup by {{ field }}\n),\n\nexcept_a as (\n select *\n from table_a\n {{ dbt.except() }}\n select *\n from table_b\n),\n\nexcept_b as (\n select *\n from table_b\n {{ dbt.except() }}\n select *\n from table_a\n),\n\nunioned as (\n select *\n from except_a\n union all\n select *\n from except_b\n)\n\nselect *\nfrom unioned\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.except" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.561419, + "supported_languages": null + }, + "macro.dbt_utils.test_expression_is_true": { + "name": "test_expression_is_true", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/expression_is_true.sql", + "original_file_path": "macros/generic_tests/expression_is_true.sql", + "unique_id": "macro.dbt_utils.test_expression_is_true", + "macro_sql": "{% test expression_is_true(model, expression, column_name=None) %}\n {{ return(adapter.dispatch('test_expression_is_true', 'dbt_utils')(model, expression, column_name)) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_expression_is_true" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.561843, + "supported_languages": null + }, + "macro.dbt_utils.default__test_expression_is_true": { + "name": "default__test_expression_is_true", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/expression_is_true.sql", + "original_file_path": "macros/generic_tests/expression_is_true.sql", + "unique_id": "macro.dbt_utils.default__test_expression_is_true", + "macro_sql": "{% macro default__test_expression_is_true(model, expression, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else \"1\" %}\n\nselect\n {{ column_list }}\nfrom {{ model }}\n{% if column_name is none %}\nwhere not({{ expression }})\n{%- else %}\nwhere not({{ column_name }} {{ expression }})\n{%- endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.should_store_failures" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.562217, + "supported_languages": null + }, + "macro.dbt_utils.test_not_null_proportion": { + "name": "test_not_null_proportion", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/not_null_proportion.sql", + "original_file_path": "macros/generic_tests/not_null_proportion.sql", + "unique_id": "macro.dbt_utils.test_not_null_proportion", + "macro_sql": "{% macro test_not_null_proportion(model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_not_null_proportion', 'dbt_utils')(model, group_by_columns, **kwargs)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_not_null_proportion" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.562869, + "supported_languages": null + }, + "macro.dbt_utils.default__test_not_null_proportion": { + "name": "default__test_not_null_proportion", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/not_null_proportion.sql", + "original_file_path": "macros/generic_tests/not_null_proportion.sql", + "unique_id": "macro.dbt_utils.default__test_not_null_proportion", + "macro_sql": "{% macro default__test_not_null_proportion(model, group_by_columns) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n{% set at_least = kwargs.get('at_least', kwargs.get('arg')) %}\n{% set at_most = kwargs.get('at_most', kwargs.get('arg', 1)) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\nwith validation as (\n select\n {{select_gb_cols}}\n sum(case when {{ column_name }} is null then 0 else 1 end) / cast(count(*) as numeric) as not_null_proportion\n from {{ model }}\n {{groupby_gb_cols}}\n),\nvalidation_errors as (\n select\n {{select_gb_cols}}\n not_null_proportion\n from validation\n where not_null_proportion < {{ at_least }} or not_null_proportion > {{ at_most }}\n)\nselect\n *\nfrom validation_errors\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.56372, + "supported_languages": null + }, + "macro.dbt_utils.test_sequential_values": { + "name": "test_sequential_values", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/sequential_values.sql", + "original_file_path": "macros/generic_tests/sequential_values.sql", + "unique_id": "macro.dbt_utils.test_sequential_values", + "macro_sql": "{% test sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}\n\n {{ return(adapter.dispatch('test_sequential_values', 'dbt_utils')(model, column_name, interval, datepart, group_by_columns)) }}\n\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_sequential_values" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.564728, + "supported_languages": null + }, + "macro.dbt_utils.default__test_sequential_values": { + "name": "default__test_sequential_values", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/sequential_values.sql", + "original_file_path": "macros/generic_tests/sequential_values.sql", + "unique_id": "macro.dbt_utils.default__test_sequential_values", + "macro_sql": "{% macro default__test_sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}\n\n{% set previous_column_name = \"previous_\" ~ dbt_utils.slugify(column_name) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(',') + ', ' %}\n {% set partition_gb_cols = 'partition by ' + group_by_columns|join(',') %}\n{% endif %}\n\nwith windowed as (\n\n select\n {{ select_gb_cols }}\n {{ column_name }},\n lag({{ column_name }}) over (\n {{partition_gb_cols}}\n order by {{ column_name }}\n ) as {{ previous_column_name }}\n from {{ model }}\n),\n\nvalidation_errors as (\n select\n *\n from windowed\n {% if datepart %}\n where not(cast({{ column_name }} as {{ dbt.type_timestamp() }})= cast({{ dbt.dateadd(datepart, interval, previous_column_name) }} as {{ dbt.type_timestamp() }}))\n {% else %}\n where not({{ column_name }} = {{ previous_column_name }} + {{ interval }})\n {% endif %}\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.slugify", + "macro.dbt.type_timestamp", + "macro.dbt.dateadd" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.565711, + "supported_languages": null + }, + "macro.dbt_utils.test_equality": { + "name": "test_equality", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/equality.sql", + "original_file_path": "macros/generic_tests/equality.sql", + "unique_id": "macro.dbt_utils.test_equality", + "macro_sql": "{% test equality(model, compare_model, compare_columns=None) %}\n {{ return(adapter.dispatch('test_equality', 'dbt_utils')(model, compare_model, compare_columns)) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_equality" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.56647, + "supported_languages": null + }, + "macro.dbt_utils.default__test_equality": { + "name": "default__test_equality", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/equality.sql", + "original_file_path": "macros/generic_tests/equality.sql", + "unique_id": "macro.dbt_utils.default__test_equality", + "macro_sql": "{% macro default__test_equality(model, compare_model, compare_columns=None) %}\n\n{% set set_diff %}\n count(*) + coalesce(abs(\n sum(case when which_diff = 'a_minus_b' then 1 else 0 end) -\n sum(case when which_diff = 'b_minus_a' then 1 else 0 end)\n ), 0)\n{% endset %}\n\n{#-- Needs to be set at parse time, before we return '' below --#}\n{{ config(fail_calc = set_diff) }}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n-- setup\n{%- do dbt_utils._is_relation(model, 'test_equality') -%}\n\n{#-\nIf the compare_cols arg is provided, we can run this test without querying the\ninformation schema\u00a0\u2014 this allows the model to be an ephemeral model\n-#}\n\n{%- if not compare_columns -%}\n {%- do dbt_utils._is_ephemeral(model, 'test_equality') -%}\n {%- set compare_columns = adapter.get_columns_in_relation(model) | map(attribute='quoted') -%}\n{%- endif -%}\n\n{% set compare_cols_csv = compare_columns | join(', ') %}\n\nwith a as (\n\n select * from {{ model }}\n\n),\n\nb as (\n\n select * from {{ compare_model }}\n\n),\n\na_minus_b as (\n\n select {{compare_cols_csv}} from a\n {{ dbt.except() }}\n select {{compare_cols_csv}} from b\n\n),\n\nb_minus_a as (\n\n select {{compare_cols_csv}} from b\n {{ dbt.except() }}\n select {{compare_cols_csv}} from a\n\n),\n\nunioned as (\n\n select 'a_minus_b' as which_diff, a_minus_b.* from a_minus_b\n union all\n select 'b_minus_a' as which_diff, b_minus_a.* from b_minus_a\n\n)\n\nselect * from unioned\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils._is_relation", + "macro.dbt_utils._is_ephemeral", + "macro.dbt.except" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.567372, + "supported_languages": null + }, + "macro.dbt_utils.test_not_empty_string": { + "name": "test_not_empty_string", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/not_empty_string.sql", + "original_file_path": "macros/generic_tests/not_empty_string.sql", + "unique_id": "macro.dbt_utils.test_not_empty_string", + "macro_sql": "{% test not_empty_string(model, column_name, trim_whitespace=true) %}\n\n {{ return(adapter.dispatch('test_not_empty_string', 'dbt_utils')(model, column_name, trim_whitespace)) }}\n\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_not_empty_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5679061, + "supported_languages": null + }, + "macro.dbt_utils.default__test_not_empty_string": { + "name": "default__test_not_empty_string", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/not_empty_string.sql", + "original_file_path": "macros/generic_tests/not_empty_string.sql", + "unique_id": "macro.dbt_utils.default__test_not_empty_string", + "macro_sql": "{% macro default__test_not_empty_string(model, column_name, trim_whitespace=true) %}\n\n with\n \n all_values as (\n\n select \n\n\n {% if trim_whitespace == true -%}\n\n trim({{ column_name }}) as {{ column_name }}\n\n {%- else -%}\n\n {{ column_name }}\n\n {%- endif %}\n \n from {{ model }}\n\n ),\n\n errors as (\n\n select * from all_values\n where {{ column_name }} = ''\n\n )\n\n select * from errors\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.568205, + "supported_languages": null + }, + "macro.dbt_utils.test_mutually_exclusive_ranges": { + "name": "test_mutually_exclusive_ranges", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/mutually_exclusive_ranges.sql", + "original_file_path": "macros/generic_tests/mutually_exclusive_ranges.sql", + "unique_id": "macro.dbt_utils.test_mutually_exclusive_ranges", + "macro_sql": "{% test mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}\n {{ return(adapter.dispatch('test_mutually_exclusive_ranges', 'dbt_utils')(model, lower_bound_column, upper_bound_column, partition_by, gaps, zero_length_range_allowed)) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__test_mutually_exclusive_ranges" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5719092, + "supported_languages": null + }, + "macro.dbt_utils.default__test_mutually_exclusive_ranges": { + "name": "default__test_mutually_exclusive_ranges", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/generic_tests/mutually_exclusive_ranges.sql", + "original_file_path": "macros/generic_tests/mutually_exclusive_ranges.sql", + "unique_id": "macro.dbt_utils.default__test_mutually_exclusive_ranges", + "macro_sql": "{% macro default__test_mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}\n{% if gaps == 'not_allowed' %}\n {% set allow_gaps_operator='=' %}\n {% set allow_gaps_operator_in_words='equal_to' %}\n{% elif gaps == 'allowed' %}\n {% set allow_gaps_operator='<=' %}\n {% set allow_gaps_operator_in_words='less_than_or_equal_to' %}\n{% elif gaps == 'required' %}\n {% set allow_gaps_operator='<' %}\n {% set allow_gaps_operator_in_words='less_than' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`gaps` argument for mutually_exclusive_ranges test must be one of ['not_allowed', 'allowed', 'required'] Got: '\" ~ gaps ~\"'.'\"\n ) }}\n{% endif %}\n{% if not zero_length_range_allowed %}\n {% set allow_zero_length_operator='<' %}\n {% set allow_zero_length_operator_in_words='less_than' %}\n{% elif zero_length_range_allowed %}\n {% set allow_zero_length_operator='<=' %}\n {% set allow_zero_length_operator_in_words='less_than_or_equal_to' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`zero_length_range_allowed` argument for mutually_exclusive_ranges test must be one of [true, false] Got: '\" ~ zero_length_range_allowed ~\"'.'\"\n ) }}\n{% endif %}\n\n{% set partition_clause=\"partition by \" ~ partition_by if partition_by else '' %}\n\nwith window_functions as (\n\n select\n {% if partition_by %}\n {{ partition_by }} as partition_by_col,\n {% endif %}\n {{ lower_bound_column }} as lower_bound,\n {{ upper_bound_column }} as upper_bound,\n\n lead({{ lower_bound_column }}) over (\n {{ partition_clause }}\n order by {{ lower_bound_column }}, {{ upper_bound_column }}\n ) as next_lower_bound,\n\n row_number() over (\n {{ partition_clause }}\n order by {{ lower_bound_column }} desc, {{ upper_bound_column }} desc\n ) = 1 as is_last_record\n\n from {{ model }}\n\n),\n\ncalc as (\n -- We want to return records where one of our assumptions fails, so we'll use\n -- the `not` function with `and` statements so we can write our assumptions more cleanly\n select\n *,\n\n -- For each record: lower_bound should be < upper_bound.\n -- Coalesce it to return an error on the null case (implicit assumption\n -- these columns are not_null)\n coalesce(\n lower_bound {{ allow_zero_length_operator }} upper_bound,\n false\n ) as lower_bound_{{ allow_zero_length_operator_in_words }}_upper_bound,\n\n -- For each record: upper_bound {{ allow_gaps_operator }} the next lower_bound.\n -- Coalesce it to handle null cases for the last record.\n coalesce(\n upper_bound {{ allow_gaps_operator }} next_lower_bound,\n is_last_record,\n false\n ) as upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n\n from window_functions\n\n),\n\nvalidation_errors as (\n\n select\n *\n from calc\n\n where not(\n -- THE FOLLOWING SHOULD BE TRUE --\n lower_bound_{{ allow_zero_length_operator_in_words }}_upper_bound\n and upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n )\n)\n\nselect * from validation_errors\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.573513, + "supported_languages": null + }, + "macro.dbt_utils.pretty_log_format": { + "name": "pretty_log_format", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/jinja_helpers/pretty_log_format.sql", + "original_file_path": "macros/jinja_helpers/pretty_log_format.sql", + "unique_id": "macro.dbt_utils.pretty_log_format", + "macro_sql": "{% macro pretty_log_format(message) %}\n {{ return(adapter.dispatch('pretty_log_format', 'dbt_utils')(message)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__pretty_log_format" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5737941, + "supported_languages": null + }, + "macro.dbt_utils.default__pretty_log_format": { + "name": "default__pretty_log_format", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/jinja_helpers/pretty_log_format.sql", + "original_file_path": "macros/jinja_helpers/pretty_log_format.sql", + "unique_id": "macro.dbt_utils.default__pretty_log_format", + "macro_sql": "{% macro default__pretty_log_format(message) %}\n {{ return( dbt_utils.pretty_time() ~ ' + ' ~ message) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.pretty_time" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5739589, + "supported_languages": null + }, + "macro.dbt_utils._is_relation": { + "name": "_is_relation", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/jinja_helpers/_is_relation.sql", + "original_file_path": "macros/jinja_helpers/_is_relation.sql", + "unique_id": "macro.dbt_utils._is_relation", + "macro_sql": "{% macro _is_relation(obj, macro) %}\n {%- if not (obj is mapping and obj.get('metadata', {}).get('type', '').endswith('Relation')) -%}\n {%- do exceptions.raise_compiler_error(\"Macro \" ~ macro ~ \" expected a Relation but received the value: \" ~ obj) -%}\n {%- endif -%}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.574403, + "supported_languages": null + }, + "macro.dbt_utils.pretty_time": { + "name": "pretty_time", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/jinja_helpers/pretty_time.sql", + "original_file_path": "macros/jinja_helpers/pretty_time.sql", + "unique_id": "macro.dbt_utils.pretty_time", + "macro_sql": "{% macro pretty_time(format='%H:%M:%S') %}\n {{ return(adapter.dispatch('pretty_time', 'dbt_utils')(format)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__pretty_time" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5746748, + "supported_languages": null + }, + "macro.dbt_utils.default__pretty_time": { + "name": "default__pretty_time", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/jinja_helpers/pretty_time.sql", + "original_file_path": "macros/jinja_helpers/pretty_time.sql", + "unique_id": "macro.dbt_utils.default__pretty_time", + "macro_sql": "{% macro default__pretty_time(format='%H:%M:%S') %}\n {{ return(modules.datetime.datetime.now().strftime(format)) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.574867, + "supported_languages": null + }, + "macro.dbt_utils.log_info": { + "name": "log_info", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/jinja_helpers/log_info.sql", + "original_file_path": "macros/jinja_helpers/log_info.sql", + "unique_id": "macro.dbt_utils.log_info", + "macro_sql": "{% macro log_info(message) %}\n {{ return(adapter.dispatch('log_info', 'dbt_utils')(message)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__log_info" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.575118, + "supported_languages": null + }, + "macro.dbt_utils.default__log_info": { + "name": "default__log_info", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/jinja_helpers/log_info.sql", + "original_file_path": "macros/jinja_helpers/log_info.sql", + "unique_id": "macro.dbt_utils.default__log_info", + "macro_sql": "{% macro default__log_info(message) %}\n {{ log(dbt_utils.pretty_log_format(message), info=True) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.pretty_log_format" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.575287, + "supported_languages": null + }, + "macro.dbt_utils.slugify": { + "name": "slugify", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/jinja_helpers/slugify.sql", + "original_file_path": "macros/jinja_helpers/slugify.sql", + "unique_id": "macro.dbt_utils.slugify", + "macro_sql": "{% macro slugify(string) %}\n\n{#- Lower case the string -#}\n{% set string = string | lower %}\n{#- Replace spaces and dashes with underscores -#}\n{% set string = modules.re.sub('[ -]+', '_', string) %}\n{#- Only take letters, numbers, and underscores -#}\n{% set string = modules.re.sub('[^a-z0-9_]+', '', string) %}\n{#- Prepends \"_\" if string begins with a number -#}\n{% set string = modules.re.sub('^[0-9]', '_' + string[0], string) %}\n\n{{ return(string) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.575888, + "supported_languages": null + }, + "macro.dbt_utils._is_ephemeral": { + "name": "_is_ephemeral", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/jinja_helpers/_is_ephemeral.sql", + "original_file_path": "macros/jinja_helpers/_is_ephemeral.sql", + "unique_id": "macro.dbt_utils._is_ephemeral", + "macro_sql": "{% macro _is_ephemeral(obj, macro) %}\n {%- if obj.is_cte -%}\n {% set ephemeral_prefix = api.Relation.add_ephemeral_prefix('') %}\n {% if obj.name.startswith(ephemeral_prefix) %}\n {% set model_name = obj.name[(ephemeral_prefix|length):] %}\n {% else %}\n {% set model_name = obj.name %}\n {%- endif -%}\n {% set error_message %}\nThe `{{ macro }}` macro cannot be used with ephemeral models, as it relies on the information schema.\n\n`{{ model_name }}` is an ephemeral model. Consider making it a view or table instead.\n {% endset %}\n {%- do exceptions.raise_compiler_error(error_message) -%}\n {%- endif -%}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.576704, + "supported_languages": null + }, + "macro.dbt_utils.get_intervals_between": { + "name": "get_intervals_between", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/date_spine.sql", + "original_file_path": "macros/sql/date_spine.sql", + "unique_id": "macro.dbt_utils.get_intervals_between", + "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt_utils')(start_date, end_date, datepart)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__get_intervals_between" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.577426, + "supported_languages": null + }, + "macro.dbt_utils.default__get_intervals_between": { + "name": "default__get_intervals_between", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/date_spine.sql", + "original_file_path": "macros/sql/date_spine.sql", + "unique_id": "macro.dbt_utils.default__get_intervals_between", + "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.dbt.datediff" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.578007, + "supported_languages": null + }, + "macro.dbt_utils.date_spine": { + "name": "date_spine", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/date_spine.sql", + "original_file_path": "macros/sql/date_spine.sql", + "unique_id": "macro.dbt_utils.date_spine", + "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt_utils')(datepart, start_date, end_date)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__date_spine" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5782368, + "supported_languages": null + }, + "macro.dbt_utils.default__date_spine": { + "name": "default__date_spine", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/date_spine.sql", + "original_file_path": "macros/sql/date_spine.sql", + "unique_id": "macro.dbt_utils.default__date_spine", + "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n{# call as follows:\n\ndate_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n) #}\n\n\nwith rawdata as (\n\n {{dbt_utils.generate_series(\n dbt_utils.get_intervals_between(start_date, end_date, datepart)\n )}}\n\n),\n\nall_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n),\n\nfiltered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n)\n\nselect * from filtered\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.generate_series", + "macro.dbt_utils.get_intervals_between", + "macro.dbt.dateadd" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.578592, + "supported_languages": null + }, + "macro.dbt_utils.safe_subtract": { + "name": "safe_subtract", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/safe_subtract.sql", + "original_file_path": "macros/sql/safe_subtract.sql", + "unique_id": "macro.dbt_utils.safe_subtract", + "macro_sql": "{%- macro safe_subtract(field_list) -%}\n {{ return(adapter.dispatch('safe_subtract', 'dbt_utils')(field_list)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__safe_subtract" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5789719, + "supported_languages": null + }, + "macro.dbt_utils.default__safe_subtract": { + "name": "default__safe_subtract", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/safe_subtract.sql", + "original_file_path": "macros/sql/safe_subtract.sql", + "unique_id": "macro.dbt_utils.default__safe_subtract", + "macro_sql": "\n\n{%- macro default__safe_subtract(field_list) -%}\n\n{%- if field_list is not iterable or field_list is string or field_list is mapping -%}\n\n{%- set error_message = '\nWarning: the `safe_subtract` macro takes a single list argument instead of \\\nstring arguments. The {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.raise_compiler_error(error_message) -%}\n\n{%- endif -%}\n\n{% set fields = [] %}\n\n{%- for field in field_list -%}\n\n {% do fields.append(\"coalesce(\" ~ field ~ \", 0)\") %}\n\n{%- endfor -%}\n\n{{ fields|join(' -\\n ') }}\n\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.579511, + "supported_languages": null + }, + "macro.dbt_utils.nullcheck_table": { + "name": "nullcheck_table", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/nullcheck_table.sql", + "original_file_path": "macros/sql/nullcheck_table.sql", + "unique_id": "macro.dbt_utils.nullcheck_table", + "macro_sql": "{% macro nullcheck_table(relation) %}\n {{ return(adapter.dispatch('nullcheck_table', 'dbt_utils')(relation)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__nullcheck_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.579821, + "supported_languages": null + }, + "macro.dbt_utils.default__nullcheck_table": { + "name": "default__nullcheck_table", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/nullcheck_table.sql", + "original_file_path": "macros/sql/nullcheck_table.sql", + "unique_id": "macro.dbt_utils.default__nullcheck_table", + "macro_sql": "{% macro default__nullcheck_table(relation) %}\n\n {%- do dbt_utils._is_relation(relation, 'nullcheck_table') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'nullcheck_table') -%}\n {% set cols = adapter.get_columns_in_relation(relation) %}\n\n select {{ dbt_utils.nullcheck(cols) }}\n from {{relation}}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils._is_relation", + "macro.dbt_utils._is_ephemeral", + "macro.dbt_utils.nullcheck" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.580159, + "supported_languages": null + }, + "macro.dbt_utils.get_relations_by_pattern": { + "name": "get_relations_by_pattern", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_relations_by_pattern.sql", + "original_file_path": "macros/sql/get_relations_by_pattern.sql", + "unique_id": "macro.dbt_utils.get_relations_by_pattern", + "macro_sql": "{% macro get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_pattern', 'dbt_utils')(schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__get_relations_by_pattern" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.580889, + "supported_languages": null + }, + "macro.dbt_utils.default__get_relations_by_pattern": { + "name": "default__get_relations_by_pattern", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_relations_by_pattern.sql", + "original_file_path": "macros/sql/get_relations_by_pattern.sql", + "unique_id": "macro.dbt_utils.default__get_relations_by_pattern", + "macro_sql": "{% macro default__get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.dbt_utils.get_tables_by_pattern_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5820632, + "supported_languages": null + }, + "macro.dbt_utils.get_powers_of_two": { + "name": "get_powers_of_two", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/generate_series.sql", + "original_file_path": "macros/sql/generate_series.sql", + "unique_id": "macro.dbt_utils.get_powers_of_two", + "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt_utils')(upper_bound)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__get_powers_of_two" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.582935, + "supported_languages": null + }, + "macro.dbt_utils.default__get_powers_of_two": { + "name": "default__get_powers_of_two", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/generate_series.sql", + "original_file_path": "macros/sql/generate_series.sql", + "unique_id": "macro.dbt_utils.default__get_powers_of_two", + "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.58334, + "supported_languages": null + }, + "macro.dbt_utils.generate_series": { + "name": "generate_series", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/generate_series.sql", + "original_file_path": "macros/sql/generate_series.sql", + "unique_id": "macro.dbt_utils.generate_series", + "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt_utils')(upper_bound)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__generate_series" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.583524, + "supported_languages": null + }, + "macro.dbt_utils.default__generate_series": { + "name": "default__generate_series", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/generate_series.sql", + "original_file_path": "macros/sql/generate_series.sql", + "unique_id": "macro.dbt_utils.default__generate_series", + "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt_utils.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.get_powers_of_two" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.584024, + "supported_languages": null + }, + "macro.dbt_utils.get_relations_by_prefix": { + "name": "get_relations_by_prefix", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_relations_by_prefix.sql", + "original_file_path": "macros/sql/get_relations_by_prefix.sql", + "unique_id": "macro.dbt_utils.get_relations_by_prefix", + "macro_sql": "{% macro get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_prefix', 'dbt_utils')(schema, prefix, exclude, database)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__get_relations_by_prefix" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.584712, + "supported_languages": null + }, + "macro.dbt_utils.default__get_relations_by_prefix": { + "name": "default__get_relations_by_prefix", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_relations_by_prefix.sql", + "original_file_path": "macros/sql/get_relations_by_prefix.sql", + "unique_id": "macro.dbt_utils.default__get_relations_by_prefix", + "macro_sql": "{% macro default__get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_prefix_sql(schema, prefix, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.dbt_utils.get_tables_by_prefix_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.58553, + "supported_languages": null + }, + "macro.dbt_utils.get_tables_by_prefix_sql": { + "name": "get_tables_by_prefix_sql", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_tables_by_prefix_sql.sql", + "original_file_path": "macros/sql/get_tables_by_prefix_sql.sql", + "unique_id": "macro.dbt_utils.get_tables_by_prefix_sql", + "macro_sql": "{% macro get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_prefix_sql', 'dbt_utils')(schema, prefix, exclude, database)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__get_tables_by_prefix_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.585927, + "supported_languages": null + }, + "macro.dbt_utils.default__get_tables_by_prefix_sql": { + "name": "default__get_tables_by_prefix_sql", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_tables_by_prefix_sql.sql", + "original_file_path": "macros/sql/get_tables_by_prefix_sql.sql", + "unique_id": "macro.dbt_utils.default__get_tables_by_prefix_sql", + "macro_sql": "{% macro default__get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(\n schema_pattern = schema,\n table_pattern = prefix ~ '%',\n exclude = exclude,\n database = database\n ) }}\n \n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.get_tables_by_pattern_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5862029, + "supported_languages": null + }, + "macro.dbt_utils.star": { + "name": "star", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/star.sql", + "original_file_path": "macros/sql/star.sql", + "unique_id": "macro.dbt_utils.star", + "macro_sql": "{% macro star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%}\r\n {{ return(adapter.dispatch('star', 'dbt_utils')(from, relation_alias, except, prefix, suffix, quote_identifiers)) }}\r\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__star" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.587486, + "supported_languages": null + }, + "macro.dbt_utils.default__star": { + "name": "default__star", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/star.sql", + "original_file_path": "macros/sql/star.sql", + "unique_id": "macro.dbt_utils.default__star", + "macro_sql": "{% macro default__star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%}\r\n {%- do dbt_utils._is_relation(from, 'star') -%}\r\n {%- do dbt_utils._is_ephemeral(from, 'star') -%}\r\n\r\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\r\n {%- if not execute -%}\r\n {% do return('*') %}\r\n {%- endif -%}\r\n\r\n {% set cols = dbt_utils.get_filtered_columns_in_relation(from, except) %}\r\n\r\n {%- if cols|length <= 0 -%}\r\n {% if flags.WHICH == 'compile' %}\r\n {% set response %}\r\n*\r\n/* No columns were returned. Maybe the relation doesn't exist yet \r\nor all columns were excluded. This star is only output during \r\ndbt compile, and exists to keep SQLFluff happy. */\r\n {% endset %}\r\n {% do return(response) %}\r\n {% else %}\r\n {% do return(\"/* no columns returned from star() macro */\") %}\r\n {% endif %}\r\n {%- else -%}\r\n {%- for col in cols %}\r\n {%- if relation_alias %}{{ relation_alias }}.{% else %}{%- endif -%}\r\n {%- if quote_identifiers -%}\r\n {{ adapter.quote(col)|trim }} {%- if prefix!='' or suffix!='' %} as {{ adapter.quote(prefix ~ col ~ suffix)|trim }} {%- endif -%}\r\n {%- else -%}\r\n {{ col|trim }} {%- if prefix!='' or suffix!='' %} as {{ (prefix ~ col ~ suffix)|trim }} {%- endif -%}\r\n {% endif %}\r\n {%- if not loop.last %},{{ '\\n ' }}{%- endif -%}\r\n {%- endfor -%}\r\n {% endif %}\r\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils._is_relation", + "macro.dbt_utils._is_ephemeral", + "macro.dbt_utils.get_filtered_columns_in_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.588871, + "supported_languages": null + }, + "macro.dbt_utils.unpivot": { + "name": "unpivot", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/unpivot.sql", + "original_file_path": "macros/sql/unpivot.sql", + "unique_id": "macro.dbt_utils.unpivot", + "macro_sql": "{% macro unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value') -%}\n {{ return(adapter.dispatch('unpivot', 'dbt_utils')(relation, cast_to, exclude, remove, field_name, value_name)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__unpivot" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.590247, + "supported_languages": null + }, + "macro.dbt_utils.default__unpivot": { + "name": "default__unpivot", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/unpivot.sql", + "original_file_path": "macros/sql/unpivot.sql", + "unique_id": "macro.dbt_utils.default__unpivot", + "macro_sql": "{% macro default__unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value') -%}\n\n {% if not relation %}\n {{ exceptions.raise_compiler_error(\"Error: argument `relation` is required for `unpivot` macro.\") }}\n {% endif %}\n\n {%- set exclude = exclude if exclude is not none else [] %}\n {%- set remove = remove if remove is not none else [] %}\n\n {%- set include_cols = [] %}\n\n {%- set table_columns = {} %}\n\n {%- do table_columns.update({relation: []}) %}\n\n {%- do dbt_utils._is_relation(relation, 'unpivot') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'unpivot') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) %}\n\n {%- for col in cols -%}\n {%- if col.column.lower() not in remove|map('lower') and col.column.lower() not in exclude|map('lower') -%}\n {% do include_cols.append(col) %}\n {%- endif %}\n {%- endfor %}\n\n\n {%- for col in include_cols -%}\n select\n {%- for exclude_col in exclude %}\n {{ exclude_col }},\n {%- endfor %}\n\n cast('{{ col.column }}' as {{ dbt.type_string() }}) as {{ field_name }},\n cast( {% if col.data_type == 'boolean' %}\n {{ dbt.cast_bool_to_text(col.column) }}\n {% else %}\n {{ col.column }}\n {% endif %}\n as {{ cast_to }}) as {{ value_name }}\n\n from {{ relation }}\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n {%- endfor -%}\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils._is_relation", + "macro.dbt_utils._is_ephemeral", + "macro.dbt.type_string", + "macro.dbt.cast_bool_to_text" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5918741, + "supported_languages": null + }, + "macro.dbt_utils.safe_divide": { + "name": "safe_divide", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/safe_divide.sql", + "original_file_path": "macros/sql/safe_divide.sql", + "unique_id": "macro.dbt_utils.safe_divide", + "macro_sql": "{% macro safe_divide(numerator, denominator) -%}\n {{ return(adapter.dispatch('safe_divide', 'dbt_utils')(numerator, denominator)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__safe_divide" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.592161, + "supported_languages": null + }, + "macro.dbt_utils.default__safe_divide": { + "name": "default__safe_divide", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/safe_divide.sql", + "original_file_path": "macros/sql/safe_divide.sql", + "unique_id": "macro.dbt_utils.default__safe_divide", + "macro_sql": "{% macro default__safe_divide(numerator, denominator) %}\n ( {{ numerator }} ) / nullif( ( {{ denominator }} ), 0)\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.592292, + "supported_languages": null + }, + "macro.dbt_utils.union_relations": { + "name": "union_relations", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/union.sql", + "original_file_path": "macros/sql/union.sql", + "unique_id": "macro.dbt_utils.union_relations", + "macro_sql": "{%- macro union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation', where=none) -%}\n {{ return(adapter.dispatch('union_relations', 'dbt_utils')(relations, column_override, include, exclude, source_column_name, where)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__union_relations" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.5956411, + "supported_languages": null + }, + "macro.dbt_utils.default__union_relations": { + "name": "default__union_relations", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/union.sql", + "original_file_path": "macros/sql/union.sql", + "unique_id": "macro.dbt_utils.default__union_relations", + "macro_sql": "\n\n{%- macro default__union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation', where=none) -%}\n\n {%- if exclude and include -%}\n {{ exceptions.raise_compiler_error(\"Both an exclude and include list were provided to the `union` macro. Only one is allowed\") }}\n {%- endif -%}\n\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. -#}\n {%- if not execute %}\n {{ return('') }}\n {% endif -%}\n\n {%- set column_override = column_override if column_override is not none else {} -%}\n\n {%- set relation_columns = {} -%}\n {%- set column_superset = {} -%}\n {%- set all_excludes = [] -%}\n {%- set all_includes = [] -%}\n\n {%- if exclude -%}\n {%- for exc in exclude -%}\n {%- do all_excludes.append(exc | lower) -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- if include -%}\n {%- for inc in include -%}\n {%- do all_includes.append(inc | lower) -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- for relation in relations -%}\n\n {%- do relation_columns.update({relation: []}) -%}\n\n {%- do dbt_utils._is_relation(relation, 'union_relations') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'union_relations') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) -%}\n {%- for col in cols -%}\n\n {#- If an exclude list was provided and the column is in the list, do nothing -#}\n {%- if exclude and col.column | lower in all_excludes -%}\n\n {#- If an include list was provided and the column is not in the list, do nothing -#}\n {%- elif include and col.column | lower not in all_includes -%}\n\n {#- Otherwise add the column to the column superset -#}\n {%- else -%}\n\n {#- update the list of columns in this relation -#}\n {%- do relation_columns[relation].append(col.column) -%}\n\n {%- if col.column in column_superset -%}\n\n {%- set stored = column_superset[col.column] -%}\n {%- if col.is_string() and stored.is_string() and col.string_size() > stored.string_size() -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif %}\n\n {%- else -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif -%}\n\n {%- endif -%}\n\n {%- endfor -%}\n {%- endfor -%}\n\n {%- set ordered_column_names = column_superset.keys() -%}\n {%- set dbt_command = flags.WHICH -%}\n\n\n {% if dbt_command in ['run', 'build'] %}\n {% if (include | length > 0 or exclude | length > 0) and not column_superset.keys() %}\n {%- set relations_string -%}\n {%- for relation in relations -%}\n {{ relation.name }}\n {%- if not loop.last %}, {% endif -%}\n {%- endfor -%}\n {%- endset -%}\n\n {%- set error_message -%}\n There were no columns found to union for relations {{ relations_string }}\n {%- endset -%}\n\n {{ exceptions.raise_compiler_error(error_message) }}\n {%- endif -%}\n {%- endif -%}\n\n {%- for relation in relations %}\n\n (\n select\n\n {%- if source_column_name is not none %}\n cast({{ dbt.string_literal(relation) }} as {{ dbt.type_string() }}) as {{ source_column_name }},\n {%- endif %}\n\n {% for col_name in ordered_column_names -%}\n\n {%- set col = column_superset[col_name] %}\n {%- set col_type = column_override.get(col.column, col.data_type) %}\n {%- set col_name = adapter.quote(col_name) if col_name in relation_columns[relation] else 'null' %}\n cast({{ col_name }} as {{ col_type }}) as {{ col.quoted }} {% if not loop.last %},{% endif -%}\n\n {%- endfor %}\n\n from {{ relation }}\n\n {% if where -%}\n where {{ where }}\n {%- endif %}\n )\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n\n {%- endfor -%}\n\n{%- endmacro -%}", + "depends_on": { + "macros": [ + "macro.dbt_utils._is_relation", + "macro.dbt_utils._is_ephemeral", + "macro.dbt.string_literal", + "macro.dbt.type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.599113, + "supported_languages": null + }, + "macro.dbt_utils.group_by": { + "name": "group_by", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/groupby.sql", + "original_file_path": "macros/sql/groupby.sql", + "unique_id": "macro.dbt_utils.group_by", + "macro_sql": "{%- macro group_by(n) -%}\n {{ return(adapter.dispatch('group_by', 'dbt_utils')(n)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__group_by" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.599421, + "supported_languages": null + }, + "macro.dbt_utils.default__group_by": { + "name": "default__group_by", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/groupby.sql", + "original_file_path": "macros/sql/groupby.sql", + "unique_id": "macro.dbt_utils.default__group_by", + "macro_sql": "\n\n{%- macro default__group_by(n) -%}\n\n group by {% for i in range(1, n + 1) -%}\n {{ i }}{{ ',' if not loop.last }} \n {%- endfor -%}\n\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.599668, + "supported_languages": null + }, + "macro.dbt_utils.deduplicate": { + "name": "deduplicate", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/deduplicate.sql", + "original_file_path": "macros/sql/deduplicate.sql", + "unique_id": "macro.dbt_utils.deduplicate", + "macro_sql": "{%- macro deduplicate(relation, partition_by, order_by) -%}\n {{ return(adapter.dispatch('deduplicate', 'dbt_utils')(relation, partition_by, order_by)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.snowflake__deduplicate" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6004329, + "supported_languages": null + }, + "macro.dbt_utils.default__deduplicate": { + "name": "default__deduplicate", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/deduplicate.sql", + "original_file_path": "macros/sql/deduplicate.sql", + "unique_id": "macro.dbt_utils.default__deduplicate", + "macro_sql": "\n\n{%- macro default__deduplicate(relation, partition_by, order_by) -%}\n\n with row_numbered as (\n select\n _inner.*,\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) as rn\n from {{ relation }} as _inner\n )\n\n select\n distinct data.*\n from {{ relation }} as data\n {#\n -- Not all DBs will support natural joins but the ones that do include:\n -- Oracle, MySQL, SQLite, Redshift, Teradata, Materialize, Databricks\n -- Apache Spark, SingleStore, Vertica\n -- Those that do not appear to support natural joins include:\n -- SQLServer, Trino, Presto, Rockset, Athena\n #}\n natural join row_numbered\n where row_numbered.rn = 1\n\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6006489, + "supported_languages": null + }, + "macro.dbt_utils.redshift__deduplicate": { + "name": "redshift__deduplicate", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/deduplicate.sql", + "original_file_path": "macros/sql/deduplicate.sql", + "unique_id": "macro.dbt_utils.redshift__deduplicate", + "macro_sql": "{% macro redshift__deduplicate(relation, partition_by, order_by) -%}\n\n {{ return(dbt_utils.default__deduplicate(relation, partition_by, order_by=order_by)) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__deduplicate" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6008441, + "supported_languages": null + }, + "macro.dbt_utils.postgres__deduplicate": { + "name": "postgres__deduplicate", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/deduplicate.sql", + "original_file_path": "macros/sql/deduplicate.sql", + "unique_id": "macro.dbt_utils.postgres__deduplicate", + "macro_sql": "\n{%- macro postgres__deduplicate(relation, partition_by, order_by) -%}\n\n select\n distinct on ({{ partition_by }}) *\n from {{ relation }}\n order by {{ partition_by }}{{ ',' ~ order_by }}\n\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6010308, + "supported_languages": null + }, + "macro.dbt_utils.snowflake__deduplicate": { + "name": "snowflake__deduplicate", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/deduplicate.sql", + "original_file_path": "macros/sql/deduplicate.sql", + "unique_id": "macro.dbt_utils.snowflake__deduplicate", + "macro_sql": "\n{%- macro snowflake__deduplicate(relation, partition_by, order_by) -%}\n\n select *\n from {{ relation }}\n qualify\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) = 1\n\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.601196, + "supported_languages": null + }, + "macro.dbt_utils.bigquery__deduplicate": { + "name": "bigquery__deduplicate", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/deduplicate.sql", + "original_file_path": "macros/sql/deduplicate.sql", + "unique_id": "macro.dbt_utils.bigquery__deduplicate", + "macro_sql": "\n{%- macro bigquery__deduplicate(relation, partition_by, order_by) -%}\n\n select unique.*\n from (\n select\n array_agg (\n original\n order by {{ order_by }}\n limit 1\n )[offset(0)] unique\n from {{ relation }} original\n group by {{ partition_by }}\n )\n\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.601364, + "supported_languages": null + }, + "macro.dbt_utils.surrogate_key": { + "name": "surrogate_key", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/surrogate_key.sql", + "original_file_path": "macros/sql/surrogate_key.sql", + "unique_id": "macro.dbt_utils.surrogate_key", + "macro_sql": "{%- macro surrogate_key(field_list) -%}\n {% set frustrating_jinja_feature = varargs %}\n {{ return(adapter.dispatch('surrogate_key', 'dbt_utils')(field_list, *varargs)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__surrogate_key" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6017568, + "supported_languages": null + }, + "macro.dbt_utils.default__surrogate_key": { + "name": "default__surrogate_key", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/surrogate_key.sql", + "original_file_path": "macros/sql/surrogate_key.sql", + "unique_id": "macro.dbt_utils.default__surrogate_key", + "macro_sql": "\n\n{%- macro default__surrogate_key(field_list) -%}\n\n{%- set error_message = '\nWarning: `dbt_utils.surrogate_key` has been replaced by \\\n`dbt_utils.generate_surrogate_key`. The new macro treats null values \\\ndifferently to empty strings. To restore the behaviour of the original \\\nmacro, add a global variable in dbt_project.yml called \\\n`surrogate_key_treat_nulls_as_empty_strings` to your \\\ndbt_project.yml file with a value of True. \\\nThe {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.raise_compiler_error(error_message) -%}\n\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.601988, + "supported_languages": null + }, + "macro.dbt_utils.safe_add": { + "name": "safe_add", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/safe_add.sql", + "original_file_path": "macros/sql/safe_add.sql", + "unique_id": "macro.dbt_utils.safe_add", + "macro_sql": "{%- macro safe_add(field_list) -%}\n {{ return(adapter.dispatch('safe_add', 'dbt_utils')(field_list)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__safe_add" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6023622, + "supported_languages": null + }, + "macro.dbt_utils.default__safe_add": { + "name": "default__safe_add", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/safe_add.sql", + "original_file_path": "macros/sql/safe_add.sql", + "unique_id": "macro.dbt_utils.default__safe_add", + "macro_sql": "\n\n{%- macro default__safe_add(field_list) -%}\n\n{%- if field_list is not iterable or field_list is string or field_list is mapping -%}\n\n{%- set error_message = '\nWarning: the `safe_add` macro now takes a single list argument instead of \\\nstring arguments. The {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.warn(error_message) -%}\n\n{%- endif -%}\n\n{% set fields = [] %}\n\n{%- for field in field_list -%}\n\n {% do fields.append(\"coalesce(\" ~ field ~ \", 0)\") %}\n\n{%- endfor -%}\n\n{{ fields|join(' +\\n ') }}\n\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.602886, + "supported_languages": null + }, + "macro.dbt_utils.nullcheck": { + "name": "nullcheck", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/nullcheck.sql", + "original_file_path": "macros/sql/nullcheck.sql", + "unique_id": "macro.dbt_utils.nullcheck", + "macro_sql": "{% macro nullcheck(cols) %}\n {{ return(adapter.dispatch('nullcheck', 'dbt_utils')(cols)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__nullcheck" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.603224, + "supported_languages": null + }, + "macro.dbt_utils.default__nullcheck": { + "name": "default__nullcheck", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/nullcheck.sql", + "original_file_path": "macros/sql/nullcheck.sql", + "unique_id": "macro.dbt_utils.default__nullcheck", + "macro_sql": "{% macro default__nullcheck(cols) %}\n{%- for col in cols %}\n\n {% if col.is_string() -%}\n\n nullif({{col.name}},'') as {{col.name}}\n\n {%- else -%}\n\n {{col.name}}\n\n {%- endif -%}\n\n{%- if not loop.last -%} , {%- endif -%}\n\n{%- endfor -%}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6035469, + "supported_languages": null + }, + "macro.dbt_utils.get_tables_by_pattern_sql": { + "name": "get_tables_by_pattern_sql", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_tables_by_pattern_sql.sql", + "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", + "unique_id": "macro.dbt_utils.get_tables_by_pattern_sql", + "macro_sql": "{% macro get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_pattern_sql', 'dbt_utils')\n (schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__get_tables_by_pattern_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.60533, + "supported_languages": null + }, + "macro.dbt_utils.default__get_tables_by_pattern_sql": { + "name": "default__get_tables_by_pattern_sql", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_tables_by_pattern_sql.sql", + "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", + "unique_id": "macro.dbt_utils.default__get_tables_by_pattern_sql", + "macro_sql": "{% macro default__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n select distinct\n table_schema as {{ adapter.quote('table_schema') }},\n table_name as {{ adapter.quote('table_name') }},\n {{ dbt_utils.get_table_types_sql() }}\n from {{ database }}.information_schema.tables\n where table_schema ilike '{{ schema_pattern }}'\n and table_name ilike '{{ table_pattern }}'\n and table_name not ilike '{{ exclude }}'\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.get_table_types_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6056929, + "supported_languages": null + }, + "macro.dbt_utils.bigquery__get_tables_by_pattern_sql": { + "name": "bigquery__get_tables_by_pattern_sql", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_tables_by_pattern_sql.sql", + "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", + "unique_id": "macro.dbt_utils.bigquery__get_tables_by_pattern_sql", + "macro_sql": "{% macro bigquery__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {% if '%' in schema_pattern %}\n {% set schemata=dbt_utils._bigquery__get_matching_schemata(schema_pattern, database) %}\n {% else %}\n {% set schemata=[schema_pattern] %}\n {% endif %}\n\n {% set sql %}\n {% for schema in schemata %}\n select distinct\n table_schema,\n table_name,\n {{ dbt_utils.get_table_types_sql() }}\n\n from {{ adapter.quote(database) }}.{{ schema }}.INFORMATION_SCHEMA.TABLES\n where lower(table_name) like lower ('{{ table_pattern }}')\n and lower(table_name) not like lower ('{{ exclude }}')\n\n {% if not loop.last %} union all {% endif %}\n\n {% endfor %}\n {% endset %}\n\n {{ return(sql) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils._bigquery__get_matching_schemata", + "macro.dbt_utils.get_table_types_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.606455, + "supported_languages": null + }, + "macro.dbt_utils._bigquery__get_matching_schemata": { + "name": "_bigquery__get_matching_schemata", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_tables_by_pattern_sql.sql", + "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", + "unique_id": "macro.dbt_utils._bigquery__get_matching_schemata", + "macro_sql": "{% macro _bigquery__get_matching_schemata(schema_pattern, database) %}\n {% if execute %}\n\n {% set sql %}\n select schema_name from {{ adapter.quote(database) }}.INFORMATION_SCHEMA.SCHEMATA\n where lower(schema_name) like lower('{{ schema_pattern }}')\n {% endset %}\n\n {% set results=run_query(sql) %}\n\n {% set schemata=results.columns['schema_name'].values() %}\n\n {{ return(schemata) }}\n\n {% else %}\n\n {{ return([]) }}\n\n {% endif %}\n\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.606949, + "supported_languages": null + }, + "macro.dbt_utils.get_column_values": { + "name": "get_column_values", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_column_values.sql", + "original_file_path": "macros/sql/get_column_values.sql", + "unique_id": "macro.dbt_utils.get_column_values", + "macro_sql": "{% macro get_column_values(table, column, order_by='count(*) desc', max_records=none, default=none, where=none) -%}\n {{ return(adapter.dispatch('get_column_values', 'dbt_utils')(table, column, order_by, max_records, default, where)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__get_column_values" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.608096, + "supported_languages": null + }, + "macro.dbt_utils.default__get_column_values": { + "name": "default__get_column_values", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_column_values.sql", + "original_file_path": "macros/sql/get_column_values.sql", + "unique_id": "macro.dbt_utils.default__get_column_values", + "macro_sql": "{% macro default__get_column_values(table, column, order_by='count(*) desc', max_records=none, default=none, where=none) -%}\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {% set default = [] if not default %}\n {{ return(default) }}\n {% endif %}\n\n {%- do dbt_utils._is_ephemeral(table, 'get_column_values') -%}\n\n {# Not all relations are tables. Renaming for internal clarity without breaking functionality for anyone using named arguments #}\n {# TODO: Change the method signature in a future 0.x.0 release #}\n {%- set target_relation = table -%}\n\n {# adapter.load_relation is a convenience wrapper to avoid building a Relation when we already have one #}\n {% set relation_exists = (load_relation(target_relation)) is not none %}\n\n {%- call statement('get_column_values', fetch_result=true) %}\n\n {%- if not relation_exists and default is none -%}\n\n {{ exceptions.raise_compiler_error(\"In get_column_values(): relation \" ~ target_relation ~ \" does not exist and no default value was provided.\") }}\n\n {%- elif not relation_exists and default is not none -%}\n\n {{ log(\"Relation \" ~ target_relation ~ \" does not exist. Returning the default value: \" ~ default) }}\n\n {{ return(default) }}\n\n {%- else -%}\n\n\n select\n {{ column }} as value\n\n from {{ target_relation }}\n\n {% if where is not none %}\n where {{ where }}\n {% endif %}\n\n group by {{ column }}\n order by {{ order_by }}\n\n {% if max_records is not none %}\n limit {{ max_records }}\n {% endif %}\n\n {% endif %}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_column_values') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values) }}\n {%- else -%}\n {{ return(default) }}\n {%- endif -%}\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils._is_ephemeral", + "macro.dbt.load_relation", + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.609567, + "supported_languages": null + }, + "macro.dbt_utils.pivot": { + "name": "pivot", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/pivot.sql", + "original_file_path": "macros/sql/pivot.sql", + "unique_id": "macro.dbt_utils.pivot", + "macro_sql": "{% macro pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {{ return(adapter.dispatch('pivot', 'dbt_utils')(column, values, alias, agg, cmp, prefix, suffix, then_value, else_value, quote_identifiers, distinct)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__pivot" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6106381, + "supported_languages": null + }, + "macro.dbt_utils.default__pivot": { + "name": "default__pivot", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/pivot.sql", + "original_file_path": "macros/sql/pivot.sql", + "unique_id": "macro.dbt_utils.default__pivot", + "macro_sql": "{% macro default__pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {% for value in values %}\n {{ agg }}(\n {% if distinct %} distinct {% endif %}\n case\n when {{ column }} {{ cmp }} '{{ dbt.escape_single_quotes(value) }}'\n then {{ then_value }}\n else {{ else_value }}\n end\n )\n {% if alias %}\n {% if quote_identifiers %}\n as {{ adapter.quote(prefix ~ value ~ suffix) }}\n {% else %}\n as {{ dbt_utils.slugify(prefix ~ value ~ suffix) }}\n {% endif %}\n {% endif %}\n {% if not loop.last %},{% endif %}\n {% endfor %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.escape_single_quotes", + "macro.dbt_utils.slugify" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6114602, + "supported_languages": null + }, + "macro.dbt_utils.get_filtered_columns_in_relation": { + "name": "get_filtered_columns_in_relation", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_filtered_columns_in_relation.sql", + "original_file_path": "macros/sql/get_filtered_columns_in_relation.sql", + "unique_id": "macro.dbt_utils.get_filtered_columns_in_relation", + "macro_sql": "{% macro get_filtered_columns_in_relation(from, except=[]) -%}\n {{ return(adapter.dispatch('get_filtered_columns_in_relation', 'dbt_utils')(from, except)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__get_filtered_columns_in_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6119208, + "supported_languages": null + }, + "macro.dbt_utils.default__get_filtered_columns_in_relation": { + "name": "default__get_filtered_columns_in_relation", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_filtered_columns_in_relation.sql", + "original_file_path": "macros/sql/get_filtered_columns_in_relation.sql", + "unique_id": "macro.dbt_utils.default__get_filtered_columns_in_relation", + "macro_sql": "{% macro default__get_filtered_columns_in_relation(from, except=[]) -%}\n {%- do dbt_utils._is_relation(from, 'get_filtered_columns_in_relation') -%}\n {%- do dbt_utils._is_ephemeral(from, 'get_filtered_columns_in_relation') -%}\n\n {# -- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {{ return('') }}\n {% endif %}\n\n {%- set include_cols = [] %}\n {%- set cols = adapter.get_columns_in_relation(from) -%}\n {%- set except = except | map(\"lower\") | list %}\n {%- for col in cols -%}\n {%- if col.column|lower not in except -%}\n {% do include_cols.append(col.column) %}\n {%- endif %}\n {%- endfor %}\n\n {{ return(include_cols) }}\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils._is_relation", + "macro.dbt_utils._is_ephemeral" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6126258, + "supported_languages": null + }, + "macro.dbt_utils.width_bucket": { + "name": "width_bucket", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/width_bucket.sql", + "original_file_path": "macros/sql/width_bucket.sql", + "unique_id": "macro.dbt_utils.width_bucket", + "macro_sql": "{% macro width_bucket(expr, min_value, max_value, num_buckets) %}\n {{ return(adapter.dispatch('width_bucket', 'dbt_utils') (expr, min_value, max_value, num_buckets)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.snowflake__width_bucket" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.613423, + "supported_languages": null + }, + "macro.dbt_utils.default__width_bucket": { + "name": "default__width_bucket", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/width_bucket.sql", + "original_file_path": "macros/sql/width_bucket.sql", + "unique_id": "macro.dbt_utils.default__width_bucket", + "macro_sql": "{% macro default__width_bucket(expr, min_value, max_value, num_buckets) -%}\n\n {% set bin_size -%}\n (( {{ max_value }} - {{ min_value }} ) / {{ num_buckets }} )\n {%- endset %}\n (\n -- to break ties when the amount is eaxtly at the bucket egde\n case\n when\n mod(\n {{ dbt.safe_cast(expr, dbt.type_numeric() ) }},\n {{ dbt.safe_cast(bin_size, dbt.type_numeric() ) }}\n ) = 0\n then 1\n else 0\n end\n ) +\n -- Anything over max_value goes the N+1 bucket\n least(\n ceil(\n ({{ expr }} - {{ min_value }})/{{ bin_size }}\n ),\n {{ num_buckets }} + 1\n )\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.safe_cast", + "macro.dbt.type_numeric" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6139379, + "supported_languages": null + }, + "macro.dbt_utils.snowflake__width_bucket": { + "name": "snowflake__width_bucket", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/width_bucket.sql", + "original_file_path": "macros/sql/width_bucket.sql", + "unique_id": "macro.dbt_utils.snowflake__width_bucket", + "macro_sql": "{% macro snowflake__width_bucket(expr, min_value, max_value, num_buckets) %}\n width_bucket({{ expr }}, {{ min_value }}, {{ max_value }}, {{ num_buckets }} )\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.614134, + "supported_languages": null + }, + "macro.dbt_utils.get_query_results_as_dict": { + "name": "get_query_results_as_dict", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_query_results_as_dict.sql", + "original_file_path": "macros/sql/get_query_results_as_dict.sql", + "unique_id": "macro.dbt_utils.get_query_results_as_dict", + "macro_sql": "{% macro get_query_results_as_dict(query) %}\n {{ return(adapter.dispatch('get_query_results_as_dict', 'dbt_utils')(query)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__get_query_results_as_dict" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6145349, + "supported_languages": null + }, + "macro.dbt_utils.default__get_query_results_as_dict": { + "name": "default__get_query_results_as_dict", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_query_results_as_dict.sql", + "original_file_path": "macros/sql/get_query_results_as_dict.sql", + "unique_id": "macro.dbt_utils.default__get_query_results_as_dict", + "macro_sql": "{% macro default__get_query_results_as_dict(query) %}\n\n{# This macro returns a dictionary of the form {column_name: (tuple_of_results)} #}\n\n {%- call statement('get_query_results', fetch_result=True,auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {% set sql_results={} %}\n\n {%- if execute -%}\n {% set sql_results_table = load_result('get_query_results').table.columns %}\n {% for column_name, column in sql_results_table.items() %}\n {% do sql_results.update({column_name: column.values()}) %}\n {% endfor %}\n {%- endif -%}\n\n {{ return(sql_results) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6151612, + "supported_languages": null + }, + "macro.dbt_utils.generate_surrogate_key": { + "name": "generate_surrogate_key", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/generate_surrogate_key.sql", + "original_file_path": "macros/sql/generate_surrogate_key.sql", + "unique_id": "macro.dbt_utils.generate_surrogate_key", + "macro_sql": "{%- macro generate_surrogate_key(field_list) -%}\n {{ return(adapter.dispatch('generate_surrogate_key', 'dbt_utils')(field_list)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__generate_surrogate_key" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.615631, + "supported_languages": null + }, + "macro.dbt_utils.default__generate_surrogate_key": { + "name": "default__generate_surrogate_key", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/generate_surrogate_key.sql", + "original_file_path": "macros/sql/generate_surrogate_key.sql", + "unique_id": "macro.dbt_utils.default__generate_surrogate_key", + "macro_sql": "\n\n{%- macro default__generate_surrogate_key(field_list) -%}\n\n{%- if var('surrogate_key_treat_nulls_as_empty_strings', False) -%}\n {%- set default_null_value = \"\" -%}\n{%- else -%}\n {%- set default_null_value = '_dbt_utils_surrogate_key_null_' -%}\n{%- endif -%}\n\n{%- set fields = [] -%}\n\n{%- for field in field_list -%}\n\n {%- do fields.append(\n \"coalesce(cast(\" ~ field ~ \" as \" ~ dbt.type_string() ~ \"), '\" ~ default_null_value ~\"')\"\n ) -%}\n\n {%- if not loop.last %}\n {%- do fields.append(\"'-'\") -%}\n {%- endif -%}\n\n{%- endfor -%}\n\n{{ dbt.hash(dbt.concat(fields)) }}\n\n{%- endmacro -%}", + "depends_on": { + "macros": [ + "macro.dbt.type_string", + "macro.dbt.hash", + "macro.dbt.concat" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.616253, + "supported_languages": null + }, + "macro.dbt_utils.get_table_types_sql": { + "name": "get_table_types_sql", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_table_types_sql.sql", + "original_file_path": "macros/sql/get_table_types_sql.sql", + "unique_id": "macro.dbt_utils.get_table_types_sql", + "macro_sql": "{%- macro get_table_types_sql() -%}\n {{ return(adapter.dispatch('get_table_types_sql', 'dbt_utils')()) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__get_table_types_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.616812, + "supported_languages": null + }, + "macro.dbt_utils.default__get_table_types_sql": { + "name": "default__get_table_types_sql", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_table_types_sql.sql", + "original_file_path": "macros/sql/get_table_types_sql.sql", + "unique_id": "macro.dbt_utils.default__get_table_types_sql", + "macro_sql": "{% macro default__get_table_types_sql() %}\n case table_type\n when 'BASE TABLE' then 'table'\n when 'EXTERNAL TABLE' then 'external'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6169531, + "supported_languages": null + }, + "macro.dbt_utils.postgres__get_table_types_sql": { + "name": "postgres__get_table_types_sql", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_table_types_sql.sql", + "original_file_path": "macros/sql/get_table_types_sql.sql", + "unique_id": "macro.dbt_utils.postgres__get_table_types_sql", + "macro_sql": "{% macro postgres__get_table_types_sql() %}\n case table_type\n when 'BASE TABLE' then 'table'\n when 'FOREIGN' then 'external'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.617098, + "supported_languages": null + }, + "macro.dbt_utils.databricks__get_table_types_sql": { + "name": "databricks__get_table_types_sql", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_table_types_sql.sql", + "original_file_path": "macros/sql/get_table_types_sql.sql", + "unique_id": "macro.dbt_utils.databricks__get_table_types_sql", + "macro_sql": "{% macro databricks__get_table_types_sql() %}\n case table_type\n when 'MANAGED' then 'table'\n when 'BASE TABLE' then 'table'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.617234, + "supported_languages": null + }, + "macro.dbt_utils.get_single_value": { + "name": "get_single_value", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_single_value.sql", + "original_file_path": "macros/sql/get_single_value.sql", + "unique_id": "macro.dbt_utils.get_single_value", + "macro_sql": "{% macro get_single_value(query, default=none) %}\n {{ return(adapter.dispatch('get_single_value', 'dbt_utils')(query, default)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__get_single_value" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.617755, + "supported_languages": null + }, + "macro.dbt_utils.default__get_single_value": { + "name": "default__get_single_value", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/get_single_value.sql", + "original_file_path": "macros/sql/get_single_value.sql", + "unique_id": "macro.dbt_utils.default__get_single_value", + "macro_sql": "{% macro default__get_single_value(query, default) %}\n\n{# This macro returns the (0, 0) record in a query, i.e. the first row of the first column #}\n\n {%- call statement('get_query_result', fetch_result=True, auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {%- if execute -%}\n\n {% set r = load_result('get_query_result').table.columns[0].values() %}\n {% if r | length == 0 %}\n {% do print('Query `' ~ query ~ '` returned no rows. Using the default value: ' ~ default) %}\n {% set sql_result = default %}\n {% else %}\n {% set sql_result = r[0] %}\n {% endif %}\n \n {%- else -%}\n \n {% set sql_result = default %}\n \n {%- endif -%}\n\n {% do return(sql_result) %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.618552, + "supported_languages": null + }, + "macro.dbt_utils.degrees_to_radians": { + "name": "degrees_to_radians", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/haversine_distance.sql", + "original_file_path": "macros/sql/haversine_distance.sql", + "unique_id": "macro.dbt_utils.degrees_to_radians", + "macro_sql": "{% macro degrees_to_radians(degrees) -%}\n acos(-1) * {{degrees}} / 180\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6196449, + "supported_languages": null + }, + "macro.dbt_utils.haversine_distance": { + "name": "haversine_distance", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/haversine_distance.sql", + "original_file_path": "macros/sql/haversine_distance.sql", + "unique_id": "macro.dbt_utils.haversine_distance", + "macro_sql": "{% macro haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n {{ return(adapter.dispatch('haversine_distance', 'dbt_utils')(lat1,lon1,lat2,lon2,unit)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.default__haversine_distance" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.619919, + "supported_languages": null + }, + "macro.dbt_utils.default__haversine_distance": { + "name": "default__haversine_distance", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/haversine_distance.sql", + "original_file_path": "macros/sql/haversine_distance.sql", + "unique_id": "macro.dbt_utils.default__haversine_distance", + "macro_sql": "{% macro default__haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n{%- if unit == 'mi' %}\n {% set conversion_rate = 1 %}\n{% elif unit == 'km' %}\n {% set conversion_rate = 1.60934 %}\n{% else %}\n {{ exceptions.raise_compiler_error(\"unit input must be one of 'mi' or 'km'. Got \" ~ unit) }}\n{% endif %}\n\n 2 * 3961 * asin(sqrt(power((sin(radians(({{ lat2 }} - {{ lat1 }}) / 2))), 2) +\n cos(radians({{lat1}})) * cos(radians({{lat2}})) *\n power((sin(radians(({{ lon2 }} - {{ lon1 }}) / 2))), 2))) * {{ conversion_rate }}\n\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.620467, + "supported_languages": null + }, + "macro.dbt_utils.bigquery__haversine_distance": { + "name": "bigquery__haversine_distance", + "resource_type": "macro", + "package_name": "dbt_utils", + "path": "macros/sql/haversine_distance.sql", + "original_file_path": "macros/sql/haversine_distance.sql", + "unique_id": "macro.dbt_utils.bigquery__haversine_distance", + "macro_sql": "{% macro bigquery__haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n{% set radians_lat1 = dbt_utils.degrees_to_radians(lat1) %}\n{% set radians_lat2 = dbt_utils.degrees_to_radians(lat2) %}\n{% set radians_lon1 = dbt_utils.degrees_to_radians(lon1) %}\n{% set radians_lon2 = dbt_utils.degrees_to_radians(lon2) %}\n{%- if unit == 'mi' %}\n {% set conversion_rate = 1 %}\n{% elif unit == 'km' %}\n {% set conversion_rate = 1.60934 %}\n{% else %}\n {{ exceptions.raise_compiler_error(\"unit input must be one of 'mi' or 'km'. Got \" ~ unit) }}\n{% endif %}\n 2 * 3961 * asin(sqrt(power(sin(({{ radians_lat2 }} - {{ radians_lat1 }}) / 2), 2) +\n cos({{ radians_lat1 }}) * cos({{ radians_lat2 }}) *\n power(sin(({{ radians_lon2 }} - {{ radians_lon1 }}) / 2), 2))) * {{ conversion_rate }}\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt_utils.degrees_to_radians" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.621247, + "supported_languages": null + }, + "macro.elementary.create_test_result_temp_table": { + "name": "create_test_result_temp_table", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test.sql", + "original_file_path": "macros/edr/materializations/test/test.sql", + "unique_id": "macro.elementary.create_test_result_temp_table", + "macro_sql": "{% macro create_test_result_temp_table() %}\n {% set database, schema = elementary.get_package_database_and_schema() %}\n {% set test_id = model[\"alias\"] %}\n {% set relation = elementary.create_temp_table(database, schema, test_id, sql) %}\n {% set new_sql %}\n select * from {{ relation }}\n {% endset %}\n {% do return(new_sql) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_package_database_and_schema", + "macro.elementary.create_temp_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.647382, + "supported_languages": null + }, + "macro.elementary.query_test_result_rows": { + "name": "query_test_result_rows", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test.sql", + "original_file_path": "macros/edr/materializations/test/test.sql", + "unique_id": "macro.elementary.query_test_result_rows", + "macro_sql": "{% macro query_test_result_rows(sample_limit=none, ignore_passed_tests=false) %}\n {% if sample_limit == 0 %} {# performance: no need to run a sql query that we know returns an empty list #}\n {% do return([]) %}\n {% endif %}\n {% if ignore_passed_tests and elementary.did_test_pass() %}\n {% do elementary.debug_log(\"Skipping sample query because the test passed.\") %}\n {% do return([]) %}\n {% endif %}\n {% set query %}\n with test_results as (\n {{ sql }}\n )\n select * from test_results {% if sample_limit is not none %} limit {{ sample_limit }} {% endif %}\n {% endset %}\n {% do return(elementary.agate_to_dicts(elementary.run_query(query))) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.did_test_pass", + "macro.elementary.debug_log", + "macro.elementary.agate_to_dicts", + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.648038, + "supported_languages": null + }, + "macro.elementary.cache_elementary_test_results_rows": { + "name": "cache_elementary_test_results_rows", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test.sql", + "original_file_path": "macros/edr/materializations/test/test.sql", + "unique_id": "macro.elementary.cache_elementary_test_results_rows", + "macro_sql": "{% macro cache_elementary_test_results_rows(elementary_test_results_rows) %}\n {% do elementary.get_cache(\"elementary_test_results\").update({model.unique_id: elementary_test_results_rows}) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_cache" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.648244, + "supported_languages": null + }, + "macro.elementary.handle_anomaly_test": { + "name": "handle_anomaly_test", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test.sql", + "original_file_path": "macros/edr/materializations/test/test.sql", + "unique_id": "macro.elementary.handle_anomaly_test", + "macro_sql": "{% macro handle_anomaly_test(flattened_test, materialization_macro) %}\n {% set metrics_tables_cache = elementary.get_cache(\"tables\").get(\"metrics\").get(\"relations\") %}\n {% set metrics_table = elementary.get_elementary_test_table(elementary.get_elementary_test_table_name(), 'metrics') %}\n {% if metrics_table %}\n {% do metrics_tables_cache.append(metrics_table) %}\n {% endif %}\n\n {% set anomaly_scores_groups_rows = {} %}\n {% set anomaly_scores_rows = elementary.query_test_result_rows() %}\n {% for anomaly_scores_row in anomaly_scores_rows %}\n {% set anomaly_scores_group = (anomaly_scores_row.full_table_name, anomaly_scores_row.column_name, anomaly_scores_row.metric_name) %}\n {% do anomaly_scores_groups_rows.setdefault(anomaly_scores_group, []) %}\n {% do anomaly_scores_groups_rows[anomaly_scores_group].append(anomaly_scores_row) %}\n {% endfor %}\n\n {% set elementary_test_results_rows = [] %}\n {% for anomaly_scores_group, anomaly_scores_rows in anomaly_scores_groups_rows.items() %}\n {% do elementary.debug_log(\"Found {} anomaly scores for group {}.\".format(anomaly_scores_rows | length, anomaly_scores_group)) %}\n {% do elementary_test_results_rows.append(elementary.get_anomaly_test_result_row(flattened_test, anomaly_scores_rows)) %}\n {% endfor %}\n {% do elementary.cache_elementary_test_results_rows(elementary_test_results_rows) %}\n\n {% do context.update({\"sql\": elementary.get_anomaly_query(flattened_test)}) %}\n {% do return(materialization_macro()) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_cache", + "macro.elementary.get_elementary_test_table", + "macro.elementary.get_elementary_test_table_name", + "macro.elementary.query_test_result_rows", + "macro.elementary.debug_log", + "macro.elementary.get_anomaly_test_result_row", + "macro.elementary.cache_elementary_test_results_rows", + "macro.elementary.get_anomaly_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.64957, + "supported_languages": null + }, + "macro.elementary.handle_schema_changes_test": { + "name": "handle_schema_changes_test", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test.sql", + "original_file_path": "macros/edr/materializations/test/test.sql", + "unique_id": "macro.elementary.handle_schema_changes_test", + "macro_sql": "{% macro handle_schema_changes_test(flattened_test, materialization_macro) %}\n {% set schema_snapshots_tables_cache = elementary.get_cache(\"tables\").get(\"schema_snapshots\") %}\n {% set schema_snapshots_table = elementary.get_elementary_test_table(elementary.get_elementary_test_table_name(), 'schema_changes') %}\n {% if schema_snapshots_table %}\n {% do schema_snapshots_tables_cache.append(schema_snapshots_table) %}\n {% endif %}\n\n {% set elementary_test_results_rows = [] %}\n {% set schema_changes_rows = elementary.query_test_result_rows() %}\n {% for schema_changes_row in schema_changes_rows %}\n {% do elementary_test_results_rows.append(elementary.get_schema_changes_test_result_row(flattened_test, schema_changes_row, schema_changes_rows)) %}\n {% endfor %}\n {% do elementary.cache_elementary_test_results_rows(elementary_test_results_rows) %}\n {% do return(materialization_macro()) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_cache", + "macro.elementary.get_elementary_test_table", + "macro.elementary.get_elementary_test_table_name", + "macro.elementary.query_test_result_rows", + "macro.elementary.get_schema_changes_test_result_row", + "macro.elementary.cache_elementary_test_results_rows" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6504362, + "supported_languages": null + }, + "macro.elementary.handle_dbt_test": { + "name": "handle_dbt_test", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test.sql", + "original_file_path": "macros/edr/materializations/test/test.sql", + "unique_id": "macro.elementary.handle_dbt_test", + "macro_sql": "{% macro handle_dbt_test(flattened_test, materialization_macro) %}\n {% set result = materialization_macro() %}\n {% set result_rows = elementary.query_test_result_rows(sample_limit=elementary.get_config_var('test_sample_row_count'),\n ignore_passed_tests=true) %}\n {% set elementary_test_results_row = elementary.get_dbt_test_result_row(flattened_test, result_rows) %}\n {% do elementary.cache_elementary_test_results_rows([elementary_test_results_row]) %}\n {% do return(result) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.query_test_result_rows", + "macro.elementary.get_config_var", + "macro.elementary.get_dbt_test_result_row", + "macro.elementary.cache_elementary_test_results_rows" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6509051, + "supported_languages": null + }, + "macro.elementary.get_test_type_handler": { + "name": "get_test_type_handler", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test.sql", + "original_file_path": "macros/edr/materializations/test/test.sql", + "unique_id": "macro.elementary.get_test_type_handler", + "macro_sql": "{% macro get_test_type_handler(flattened_test) %}\n {% set test_type = elementary.get_test_type(flattened_test) %}\n {% set test_type_handler_map = {\n \"anomaly_detection\": elementary.handle_anomaly_test,\n \"schema_change\": elementary.handle_schema_changes_test,\n \"dbt_test\": elementary.handle_dbt_test,\n \"integrity\": elementary.handle_dbt_test\n } %}\n {% set test_type_handler = test_type_handler_map.get(test_type) %}\n {% if not test_type_handler %}\n {% do exceptions.raise_compiler_error(\"Unknown test type: {}\".format(test_type)) %}\n {% endif %}\n {% do return(test_type_handler) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_test_type" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.65148, + "supported_languages": null + }, + "macro.elementary.materialize_test": { + "name": "materialize_test", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test.sql", + "original_file_path": "macros/edr/materializations/test/test.sql", + "unique_id": "macro.elementary.materialize_test", + "macro_sql": "{% macro materialize_test(materialization_macro) %}\n {% if not elementary.is_elementary_enabled() %}\n {% do return(materialization_macro()) %}\n {% endif %}\n\n {% set test_unique_id = model.get('unique_id') %}\n {% do elementary.debug_log(test_unique_id ~ \": starting test materialization hook\") %}\n {% if elementary.get_config_var(\"tests_use_temp_tables\") %}\n {% set temp_table_sql = elementary.create_test_result_temp_table() %}\n {% do context.update({\"sql\": temp_table_sql}) %}\n {% do elementary.debug_log(test_unique_id ~ \": created test temp table\") %}\n {% endif %}\n\n {% set flattened_test = elementary.flatten_test(model) %}\n {% do elementary.debug_log(test_unique_id ~ \": flattened test node\") %}\n {% set test_type_handler = elementary.get_test_type_handler(flattened_test) %}\n {% set result = test_type_handler(flattened_test, materialization_macro) %}\n {% do elementary.debug_log(test_unique_id ~ \": handler called by test type - \" ~ elementary.get_test_type(flattened_test)) %}\n {% if elementary.get_config_var(\"calculate_failed_count\") %}\n {% set failed_row_count = elementary.get_failed_row_count(flattened_test) %}\n {% if failed_row_count is not none %}\n {% do elementary.get_cache(\"elementary_test_failed_row_counts\").update({model.unique_id: failed_row_count}) %}\n {% do elementary.debug_log(test_unique_id ~ \": calculated failed row count\") %}\n {% endif %}\n {% endif %}\n {% do elementary.debug_log(test_unique_id ~ \": finished test materialization hook\") %}\n {% do return(result) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.is_elementary_enabled", + "macro.elementary.debug_log", + "macro.elementary.get_config_var", + "macro.elementary.create_test_result_temp_table", + "macro.elementary.flatten_test", + "macro.elementary.get_test_type_handler", + "macro.elementary.get_test_type", + "macro.elementary.get_failed_row_count", + "macro.elementary.get_cache" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6529322, + "supported_languages": null + }, + "macro.elementary.materialization_test_default": { + "name": "materialization_test_default", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test.sql", + "original_file_path": "macros/edr/materializations/test/test.sql", + "unique_id": "macro.elementary.materialization_test_default", + "macro_sql": "{% materialization test, default %}\n {% set result = elementary.materialize_test(dbt.materialization_test_default) %}\n {% do return(result) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.elementary.materialize_test" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.653153, + "supported_languages": [ + "sql" + ] + }, + "macro.elementary.materialization_test_snowflake": { + "name": "materialization_test_snowflake", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test.sql", + "original_file_path": "macros/edr/materializations/test/test.sql", + "unique_id": "macro.elementary.materialization_test_snowflake", + "macro_sql": "{% materialization test, adapter=\"snowflake\" %}\n {%- if dbt.materialization_test_snowflake -%}\n {% set materialization_macro = dbt.materialization_test_snowflake %}\n {%- else -%}\n {% set materialization_macro = dbt.materialization_test_default %}\n {%- endif -%}\n {% set result = elementary.materialize_test(materialization_macro) %}\n {% do return(result) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.elementary.materialize_test" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.653503, + "supported_languages": [ + "sql" + ] + }, + "macro.elementary.get_anomaly_test_result_row": { + "name": "get_anomaly_test_result_row", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test.sql", + "original_file_path": "macros/edr/materializations/test/test.sql", + "unique_id": "macro.elementary.get_anomaly_test_result_row", + "macro_sql": "{% macro get_anomaly_test_result_row(flattened_test, anomaly_scores_rows) %}\n {%- set latest_row = anomaly_scores_rows[-1] %}\n {%- set full_table_name = elementary.insensitive_get_dict_value(latest_row, 'full_table_name') %}\n {%- set test_unique_id = flattened_test.unique_id %}\n {%- set test_configuration = elementary.get_cache(test_unique_id) %}\n {%- set test_params = elementary.insensitive_get_dict_value(flattened_test, 'test_params') %}\n {%- do test_params.update(test_configuration) %}\n {%- set parent_model_unique_id = elementary.insensitive_get_dict_value(flattened_test, 'parent_model_unique_id') %}\n {%- set column_name = elementary.insensitive_get_dict_value(latest_row, 'column_name') %}\n {%- set metric_name = elementary.insensitive_get_dict_value(latest_row, 'metric_name') %}\n {%- set test_unique_id = elementary.insensitive_get_dict_value(latest_row, 'test_unique_id') %}\n {%- set has_anomaly_score = elementary.insensitive_get_dict_value(latest_row, 'anomaly_score') is not none %}\n {%- if not has_anomaly_score %}\n {% do elementary.edr_log(\"Not enough data to calculate anomaly scores on `{}`\".format(test_unique_id)) %}\n {% endif %}\n {%- set test_results_query -%}\n select * from ({{ sql }}) results\n where\n anomaly_score is not null and\n upper(full_table_name) = upper({{ elementary.const_as_string(full_table_name) }}) and\n metric_name = {{ elementary.const_as_string(metric_name) }}\n {%- if column_name %}\n and upper(column_name) = upper({{ elementary.const_as_string(column_name) }})\n {%- endif %}\n {%- endset -%}\n {% set test_results_description %}\n {% if has_anomaly_score %}\n {{ elementary.insensitive_get_dict_value(latest_row, 'anomaly_description') }}\n {% else %}\n Not enough data to calculate anomaly score.\n {% endif %}\n {% endset %}\n {% set failures = namespace(data=0) %}\n {% set filtered_anomaly_scores_rows = [] %}\n {% for row in anomaly_scores_rows %}\n {% if row.anomaly_score is not none %}\n {% do filtered_anomaly_scores_rows.append(row) %}\n {% if row.is_anomalous %}\n {% set failures.data = failures.data + 1 %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% set test_result_dict = {\n 'id': elementary.insensitive_get_dict_value(latest_row, 'id'),\n 'data_issue_id': elementary.insensitive_get_dict_value(latest_row, 'metric_id'),\n 'model_unique_id': parent_model_unique_id,\n 'column_name': column_name,\n 'test_type': 'anomaly_detection',\n 'test_sub_type': metric_name,\n 'test_results_description': test_results_description,\n 'other': elementary.insensitive_get_dict_value(latest_row, 'anomalous_value'),\n 'test_results_query': test_results_query,\n 'test_params': test_params,\n 'result_rows': filtered_anomaly_scores_rows,\n 'failures': failures.data\n } %}\n {% set elementary_test_row = elementary.get_dbt_test_result_row(flattened_test) %}\n {% do elementary_test_row.update(test_result_dict) %}\n {% do return(elementary_test_row) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.insensitive_get_dict_value", + "macro.elementary.get_cache", + "macro.elementary.edr_log", + "macro.elementary.const_as_string", + "macro.elementary.get_dbt_test_result_row" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6559, + "supported_languages": null + }, + "macro.elementary.get_schema_changes_test_result_row": { + "name": "get_schema_changes_test_result_row", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test.sql", + "original_file_path": "macros/edr/materializations/test/test.sql", + "unique_id": "macro.elementary.get_schema_changes_test_result_row", + "macro_sql": "{% macro get_schema_changes_test_result_row(flattened_test, schema_changes_row, schema_changes_rows) %}\n {% set elementary_test_row = elementary.get_dbt_test_result_row(flattened_test, schema_changes_rows) %}\n {% do elementary_test_row.update(schema_changes_row) %}\n {% do return(elementary_test_row) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_dbt_test_result_row" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.656194, + "supported_languages": null + }, + "macro.elementary.get_dbt_test_result_row": { + "name": "get_dbt_test_result_row", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test.sql", + "original_file_path": "macros/edr/materializations/test/test.sql", + "unique_id": "macro.elementary.get_dbt_test_result_row", + "macro_sql": "{% macro get_dbt_test_result_row(flattened_test, result_rows=none) %}\n {% if not result_rows %}\n {% set result_rows = [] %}\n {% endif %}\n\n {% set test_execution_id = elementary.get_node_execution_id(flattened_test) %}\n {% set parent_model_unique_id = elementary.insensitive_get_dict_value(flattened_test, 'parent_model_unique_id') %}\n {% set parent_model = elementary.get_node(parent_model_unique_id) %}\n {% set parent_model_name = elementary.get_table_name_from_node(parent_model) %}\n {% set test_result_dict = {\n 'id': test_execution_id,\n 'data_issue_id': none,\n 'test_execution_id': test_execution_id,\n 'test_unique_id': elementary.insensitive_get_dict_value(flattened_test, 'unique_id'),\n 'model_unique_id': parent_model_unique_id,\n 'detected_at': elementary.insensitive_get_dict_value(flattened_test, 'generated_at'),\n 'database_name': elementary.insensitive_get_dict_value(flattened_test, 'database_name'),\n 'schema_name': elementary.insensitive_get_dict_value(flattened_test, 'schema_name'),\n 'table_name': parent_model_name,\n 'column_name': elementary.insensitive_get_dict_value(flattened_test, 'test_column_name'),\n 'test_type': elementary.get_test_type(flattened_test),\n 'test_sub_type': elementary.insensitive_get_dict_value(flattened_test, 'type'),\n 'other': none,\n 'owners': elementary.insensitive_get_dict_value(flattened_test, 'model_owners'),\n 'tags': elementary.insensitive_get_dict_value(flattened_test, 'model_tags') + elementary.insensitive_get_dict_value(flattened_test, 'tags'),\n 'test_results_query': elementary.get_compiled_code(flattened_test),\n 'test_name': elementary.insensitive_get_dict_value(flattened_test, 'name'),\n 'test_params': elementary.insensitive_get_dict_value(flattened_test, 'test_params'),\n 'severity': elementary.insensitive_get_dict_value(flattened_test, 'severity'),\n 'test_short_name': elementary.insensitive_get_dict_value(flattened_test, 'short_name'),\n 'test_alias': elementary.insensitive_get_dict_value(flattened_test, 'alias'),\n 'result_rows': result_rows\n }%}\n {% do return(test_result_dict) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_node_execution_id", + "macro.elementary.insensitive_get_dict_value", + "macro.elementary.get_node", + "macro.elementary.get_table_name_from_node", + "macro.elementary.get_test_type", + "macro.elementary.get_compiled_code" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.657928, + "supported_languages": null + }, + "macro.elementary.get_failed_row_count": { + "name": "get_failed_row_count", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/failed_row_count.sql", + "original_file_path": "macros/edr/materializations/test/failed_row_count.sql", + "unique_id": "macro.elementary.get_failed_row_count", + "macro_sql": "{% macro get_failed_row_count(flattened_test) %}\n {% set test_result = elementary.get_test_result() %}\n {% if config.get(\"fail_calc\").strip() == elementary.get_failed_row_count_calc(flattened_test) %}\n {% do elementary.debug_log(\"Using test failures as failed_rows value.\") %}\n {% do return(test_result.failures|int) %}\n {% endif %}\n {% if elementary.did_test_pass(test_result) %}\n {% do return(none) %}\n {% endif %}\n {% set failed_row_count_query = elementary.get_failed_row_count_query(flattened_test) %}\n {% if failed_row_count_query %}\n {% set result_count = elementary.result_value(failed_row_count_query) %}\n {% do return(result_count) %}\n {% endif %}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_test_result", + "macro.elementary.get_failed_row_count_calc", + "macro.elementary.debug_log", + "macro.elementary.did_test_pass", + "macro.elementary.get_failed_row_count_query", + "macro.elementary.result_value" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6595998, + "supported_languages": null + }, + "macro.elementary.get_failed_row_count_query": { + "name": "get_failed_row_count_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/failed_row_count.sql", + "original_file_path": "macros/edr/materializations/test/failed_row_count.sql", + "unique_id": "macro.elementary.get_failed_row_count_query", + "macro_sql": "{% macro get_failed_row_count_query(flattened_test) %}\n {% set failed_row_count_calc = elementary.get_failed_row_count_calc(flattened_test) %}\n {% if failed_row_count_calc %}\n {% set failed_row_count_query = elementary.get_failed_row_count_calc_query(failed_row_count_calc) %}\n {% do return(failed_row_count_query) %}\n {% endif %}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_failed_row_count_calc", + "macro.elementary.get_failed_row_count_calc_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.659957, + "supported_languages": null + }, + "macro.elementary.get_failed_row_count_calc": { + "name": "get_failed_row_count_calc", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/failed_row_count.sql", + "original_file_path": "macros/edr/materializations/test/failed_row_count.sql", + "unique_id": "macro.elementary.get_failed_row_count_calc", + "macro_sql": "{% macro get_failed_row_count_calc(flattened_test) %}\n {% if \"failed_row_count_calc\" in flattened_test[\"meta\"] %}\n {% do return(flattened_test[\"meta\"][\"failed_row_count_calc\"]) %}\n {% endif %}\n {% set common_test_config = elementary.get_common_test_config(flattened_test) %}\n {% if common_test_config %}\n {% do return(common_test_config.get(\"failed_row_count_calc\")) %}\n {% endif %}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_common_test_config" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.660435, + "supported_languages": null + }, + "macro.elementary.get_failed_row_count_calc_query": { + "name": "get_failed_row_count_calc_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/failed_row_count.sql", + "original_file_path": "macros/edr/materializations/test/failed_row_count.sql", + "unique_id": "macro.elementary.get_failed_row_count_calc_query", + "macro_sql": "{% macro get_failed_row_count_calc_query(failed_row_count_calc) %}\n with results as (\n {{ sql }}\n )\n select {{ failed_row_count_calc }} as count from results\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.660564, + "supported_languages": null + }, + "macro.elementary.get_test_result": { + "name": "get_test_result", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test_result.sql", + "original_file_path": "macros/edr/materializations/test/test_result.sql", + "unique_id": "macro.elementary.get_test_result", + "macro_sql": "{% macro get_test_result() %}\n{#\n This macro should return a dictionary with the following keys:\n - failures - the result of dbts fail_calc\n - should_warn\n - should_error\n#}\n {% set result = load_result('main') %}\n {% set rows = elementary.agate_to_dicts(result.table) %}\n {% do return(rows[0]) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.agate_to_dicts" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6609762, + "supported_languages": null + }, + "macro.elementary.did_test_pass": { + "name": "did_test_pass", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/test/test_result.sql", + "original_file_path": "macros/edr/materializations/test/test_result.sql", + "unique_id": "macro.elementary.did_test_pass", + "macro_sql": "{% macro did_test_pass(test_result=none) %}\n {% if test_result is none %}\n {% set test_result = elementary.get_test_result() %}\n {% endif %}\n {% do return(not test_result.should_warn and not test_result.should_error) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_test_result" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.661271, + "supported_languages": null + }, + "macro.elementary.query_table_metrics": { + "name": "query_table_metrics", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/metrics.sql", + "original_file_path": "macros/edr/materializations/model/metrics.sql", + "unique_id": "macro.elementary.query_table_metrics", + "macro_sql": "{% macro query_table_metrics() %}\n {% set query %}\n select\n {{ modules.datetime.datetime.utcnow().timestamp() }} as build_timestamp,\n count(*) as row_count\n from {{ this }}\n {% endset %}\n\n {% set metrics = [] %}\n {% for metric_column in elementary.run_query(query).columns %}\n {% set metric_name = metric_column.name %}\n {% set metric_value = metric_column[0] %}\n {% do metrics.append({\n \"id\": \"{}.{}\".format(invocation_id, this),\n \"full_table_name\": elementary.relation_to_full_name(this),\n \"column_name\": none,\n \"metric_name\": metric_name,\n \"metric_value\": metric_value,\n \"updated_at\": elementary.datetime_now_utc_as_string()\n }) %}\n {% endfor %}\n {% do return(metrics) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query", + "macro.elementary.relation_to_full_name", + "macro.elementary.datetime_now_utc_as_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.662666, + "supported_languages": null + }, + "macro.elementary.can_query_metrics": { + "name": "can_query_metrics", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/metrics.sql", + "original_file_path": "macros/edr/materializations/model/metrics.sql", + "unique_id": "macro.elementary.can_query_metrics", + "macro_sql": "{% macro can_query_metrics() %}\n {% if not elementary.get_config_var('collect_metrics') %}\n {% do return(false) %}\n {% endif %}\n\n {% if model.config.require_partition_filter %}\n {% do return(false) %}\n {% endif %}\n\n {% do return(true) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_config_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.663021, + "supported_languages": null + }, + "macro.elementary.query_metrics": { + "name": "query_metrics", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/metrics.sql", + "original_file_path": "macros/edr/materializations/model/metrics.sql", + "unique_id": "macro.elementary.query_metrics", + "macro_sql": "{% macro query_metrics() %}\n {% if not elementary.can_query_metrics() %}\n {% do return([]) %}\n {% endif %}\n\n {% do return(elementary.query_table_metrics()) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.can_query_metrics", + "macro.elementary.query_table_metrics" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.663278, + "supported_languages": null + }, + "macro.elementary.cache_metrics": { + "name": "cache_metrics", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/metrics.sql", + "original_file_path": "macros/edr/materializations/model/metrics.sql", + "unique_id": "macro.elementary.cache_metrics", + "macro_sql": "{% macro cache_metrics(metrics) %}\n {% do elementary.get_cache(\"tables\").get(\"metrics\").get(\"rows\").extend(metrics) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_cache" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6634939, + "supported_languages": null + }, + "macro.elementary.materialize_table": { + "name": "materialize_table", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/table.sql", + "original_file_path": "macros/edr/materializations/model/table.sql", + "unique_id": "macro.elementary.materialize_table", + "macro_sql": "{% macro materialize_table(adapter_name) %}\n {% set original_name = 'materialization_table_' ~ adapter_name %}\n {% set original = dbt.get(original_name, dbt.materialization_table_default) %}\n {% set relations = original.call_macro() %}\n {% if not elementary.is_elementary_enabled() %}\n {% do return(relations) %}\n {% endif %}\n\n {% set metrics = elementary.query_metrics() %}\n {% do elementary.cache_metrics(metrics) %}\n {% do return(relations) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.is_elementary_enabled", + "macro.elementary.query_metrics", + "macro.elementary.cache_metrics" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.665032, + "supported_languages": null + }, + "macro.elementary.materialization_table_default": { + "name": "materialization_table_default", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/table.sql", + "original_file_path": "macros/edr/materializations/model/table.sql", + "unique_id": "macro.elementary.materialization_table_default", + "macro_sql": "{% materialization table, default %}\n {% do return(elementary.materialize_table.call_macro('default')) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.665204, + "supported_languages": [ + "sql" + ] + }, + "macro.elementary.materialization_table_snowflake": { + "name": "materialization_table_snowflake", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/table.sql", + "original_file_path": "macros/edr/materializations/model/table.sql", + "unique_id": "macro.elementary.materialization_table_snowflake", + "macro_sql": "{% materialization table, adapter=\"snowflake\", supported_languages=[\"sql\", \"python\"] %}\n {% do return(elementary.materialize_table.call_macro('snowflake')) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6654239, + "supported_languages": [ + "sql", + "python" + ] + }, + "macro.elementary.materialization_table_bigquery": { + "name": "materialization_table_bigquery", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/table.sql", + "original_file_path": "macros/edr/materializations/model/table.sql", + "unique_id": "macro.elementary.materialization_table_bigquery", + "macro_sql": "{% materialization table, adapter=\"bigquery\", supported_languages=[\"sql\", \"python\"] %}\n {% do return(elementary.materialize_table.call_macro('bigquery')) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6656508, + "supported_languages": [ + "sql", + "python" + ] + }, + "macro.elementary.materialization_table_spark": { + "name": "materialization_table_spark", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/table.sql", + "original_file_path": "macros/edr/materializations/model/table.sql", + "unique_id": "macro.elementary.materialization_table_spark", + "macro_sql": "{% materialization table, adapter=\"spark\", supported_languages=[\"sql\", \"python\"] %}\n {% do return(elementary.materialize_table.call_macro('spark')) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.665947, + "supported_languages": [ + "sql", + "python" + ] + }, + "macro.elementary.materialization_table_databricks": { + "name": "materialization_table_databricks", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/table.sql", + "original_file_path": "macros/edr/materializations/model/table.sql", + "unique_id": "macro.elementary.materialization_table_databricks", + "macro_sql": "{% materialization table, adapter=\"databricks\", supported_languages=[\"sql\", \"python\"] %}\n {% do return(elementary.materialize_table.call_macro('databricks')) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6661708, + "supported_languages": [ + "sql", + "python" + ] + }, + "macro.elementary.materialization_table_redshift": { + "name": "materialization_table_redshift", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/table.sql", + "original_file_path": "macros/edr/materializations/model/table.sql", + "unique_id": "macro.elementary.materialization_table_redshift", + "macro_sql": "{% materialization table, adapter=\"redshift\", supported_languages=[\"sql\", \"python\"] %}\n {% do return(elementary.materialize_table.call_macro('redshift')) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6663911, + "supported_languages": [ + "sql", + "python" + ] + }, + "macro.elementary.materialization_table_athena": { + "name": "materialization_table_athena", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/table.sql", + "original_file_path": "macros/edr/materializations/model/table.sql", + "unique_id": "macro.elementary.materialization_table_athena", + "macro_sql": "{% materialization table, adapter=\"athena\", supported_languages=[\"sql\"] %}\n {% set relations = dbt.materialization_table_athena.call_macro() %}\n {% if not elementary.is_elementary_enabled() %}\n {% do return(relations) %}\n {% endif %}\n\n {% set metrics = elementary.query_metrics() %}\n {% do elementary.cache_metrics(metrics) %}\n {% do return(relations) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.elementary.is_elementary_enabled", + "macro.elementary.query_metrics", + "macro.elementary.cache_metrics" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.666852, + "supported_languages": [ + "sql" + ] + }, + "macro.elementary.materialization_incremental_default": { + "name": "materialization_incremental_default", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/incremental.sql", + "original_file_path": "macros/edr/materializations/model/incremental.sql", + "unique_id": "macro.elementary.materialization_incremental_default", + "macro_sql": "{% materialization incremental, default %}\n {% set relations = dbt.materialization_incremental_default.call_macro() %}\n {% if not elementary.is_elementary_enabled() %}\n {% do return(relations) %}\n {% endif %}\n\n {% set metrics = elementary.query_metrics() %}\n {% do elementary.cache_metrics(metrics) %}\n {% do return(relations) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.elementary.is_elementary_enabled", + "macro.elementary.query_metrics", + "macro.elementary.cache_metrics" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.668909, + "supported_languages": [ + "sql" + ] + }, + "macro.elementary.materialization_incremental_snowflake": { + "name": "materialization_incremental_snowflake", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/incremental.sql", + "original_file_path": "macros/edr/materializations/model/incremental.sql", + "unique_id": "macro.elementary.materialization_incremental_snowflake", + "macro_sql": "{% materialization incremental, adapter=\"snowflake\", supported_languages=[\"sql\", \"python\"] %}\n {% set relations = dbt.materialization_incremental_snowflake.call_macro() %}\n {% if not elementary.is_elementary_enabled() %}\n {% do return(relations) %}\n {% endif %}\n\n {% set metrics = elementary.query_metrics() %}\n {% do elementary.cache_metrics(metrics) %}\n {% do return(relations) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.elementary.is_elementary_enabled", + "macro.elementary.query_metrics", + "macro.elementary.cache_metrics" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.669379, + "supported_languages": [ + "sql", + "python" + ] + }, + "macro.elementary.materialization_incremental_bigquery": { + "name": "materialization_incremental_bigquery", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/incremental.sql", + "original_file_path": "macros/edr/materializations/model/incremental.sql", + "unique_id": "macro.elementary.materialization_incremental_bigquery", + "macro_sql": "{% materialization incremental, adapter=\"bigquery\", supported_languages=[\"sql\", \"python\"] %}\n {% set relations = dbt.materialization_incremental_bigquery.call_macro() %}\n {% if not elementary.is_elementary_enabled() %}\n {% do return(relations) %}\n {% endif %}\n\n {% set metrics = elementary.query_metrics() %}\n {% do elementary.cache_metrics(metrics) %}\n {% do return(relations) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.elementary.is_elementary_enabled", + "macro.elementary.query_metrics", + "macro.elementary.cache_metrics" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.66985, + "supported_languages": [ + "sql", + "python" + ] + }, + "macro.elementary.materialization_incremental_spark": { + "name": "materialization_incremental_spark", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/incremental.sql", + "original_file_path": "macros/edr/materializations/model/incremental.sql", + "unique_id": "macro.elementary.materialization_incremental_spark", + "macro_sql": "{% materialization incremental, adapter=\"spark\", supported_languages=[\"sql\", \"python\"] %}\n {% set relations = dbt.materialization_incremental_spark.call_macro() %}\n {% if not elementary.is_elementary_enabled() %}\n {% do return(relations) %}\n {% endif %}\n\n {% set metrics = elementary.query_metrics() %}\n {% do elementary.cache_metrics(metrics) %}\n {% do return(relations) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.elementary.is_elementary_enabled", + "macro.elementary.query_metrics", + "macro.elementary.cache_metrics" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.670324, + "supported_languages": [ + "sql", + "python" + ] + }, + "macro.elementary.materialization_incremental_databricks": { + "name": "materialization_incremental_databricks", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/incremental.sql", + "original_file_path": "macros/edr/materializations/model/incremental.sql", + "unique_id": "macro.elementary.materialization_incremental_databricks", + "macro_sql": "{% materialization incremental, adapter=\"databricks\", supported_languages=[\"sql\", \"python\"] %}\n {% set relations = dbt.materialization_incremental_databricks.call_macro() %}\n {% if not elementary.is_elementary_enabled() %}\n {% do return(relations) %}\n {% endif %}\n\n {% set metrics = elementary.query_metrics() %}\n {% do elementary.cache_metrics(metrics) %}\n {% do return(relations) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.elementary.is_elementary_enabled", + "macro.elementary.query_metrics", + "macro.elementary.cache_metrics" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.670793, + "supported_languages": [ + "sql", + "python" + ] + }, + "macro.elementary.materialization_incremental_athena": { + "name": "materialization_incremental_athena", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/materializations/model/incremental.sql", + "original_file_path": "macros/edr/materializations/model/incremental.sql", + "unique_id": "macro.elementary.materialization_incremental_athena", + "macro_sql": "{% materialization incremental, adapter=\"athena\", supported_languages=[\"sql\"] %}\n {% set relations = dbt.materialization_incremental_athena.call_macro() %}\n {% if not elementary.is_elementary_enabled() %}\n {% do return(relations) %}\n {% endif %}\n\n {% set metrics = elementary.query_metrics() %}\n {% do elementary.cache_metrics(metrics) %}\n {% do return(relations) %}\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.elementary.is_elementary_enabled", + "macro.elementary.query_metrics", + "macro.elementary.cache_metrics" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.671251, + "supported_languages": [ + "sql" + ] + }, + "macro.elementary.test_schema_changes_from_baseline": { + "name": "test_schema_changes_from_baseline", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_schema_changes_from_baseline.sql", + "original_file_path": "macros/edr/tests/test_schema_changes_from_baseline.sql", + "unique_id": "macro.elementary.test_schema_changes_from_baseline", + "macro_sql": "{% test schema_changes_from_baseline(model, fail_on_added=False, enforce_types=False) %}\n -- depends_on: {{ ref('schema_columns_snapshot') }}\n\n {%- if execute and elementary.is_test_command() %}\n {% set model_relation = elementary.get_model_relation_for_test(model, context[\"model\"]) %}\n {% if not model_relation %}\n {{ exceptions.raise_compiler_error(\"Unsupported model: \" ~ model ~ \" (this might happen if you override 'ref' or 'source)\") }}\n {% endif %}\n\n {%- if elementary.is_ephemeral_model(model_relation) %}\n {{ exceptions.raise_compiler_error(\"The test is not supported for ephemeral models, model name: {}\".format(model_relation.identifier)) }}\n {%- endif %}\n\n {% set test_table_name = elementary.get_elementary_test_table_name() %}\n {% set database_name, schema_name = elementary.get_package_database_and_schema('elementary') %}\n {% set tests_schema_name = elementary.get_elementary_tests_schema(database_name, schema_name) %}\n\n {# Get baseline and store it in a table #}\n {% set baseline_columns = elementary.get_model_baseline_columns(model_relation, enforce_types=enforce_types) %}\n {% set baseline_table_relation = elementary.create_model_baseline_table(baseline_columns, database_name, schema_name, test_table_name) %}\n\n {% set full_table_name = elementary.relation_to_full_name(model_relation) %}\n {% set changes_from_baseline_query = elementary.get_column_changes_from_baseline_query(model_relation, full_table_name, baseline_table_relation, include_added=fail_on_added) %}\n {{ changes_from_baseline_query }}\n {% else %}\n {# test must run an sql query #}\n {{ elementary.no_results_query() }}\n {% endif %}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.elementary.is_test_command", + "macro.elementary.get_model_relation_for_test", + "macro.elementary.is_ephemeral_model", + "macro.elementary.get_elementary_test_table_name", + "macro.elementary.get_package_database_and_schema", + "macro.elementary.get_elementary_tests_schema", + "macro.elementary.get_model_baseline_columns", + "macro.elementary.create_model_baseline_table", + "macro.elementary.relation_to_full_name", + "macro.elementary.get_column_changes_from_baseline_query", + "macro.elementary.no_results_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6729422, + "supported_languages": null + }, + "macro.elementary.test_freshness_anomalies": { + "name": "test_freshness_anomalies", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_freshness_anomalies.sql", + "original_file_path": "macros/edr/tests/test_freshness_anomalies.sql", + "unique_id": "macro.elementary.test_freshness_anomalies", + "macro_sql": "{% test freshness_anomalies(model, timestamp_column, where_expression, anomaly_sensitivity, anomaly_direction, min_training_set_size, time_bucket, days_back, backfill_days, seasonality, sensitivity, detection_delay, anomaly_exclude_metrics, detection_period, training_period) %}\n -- depends_on: {{ ref('monitors_runs') }}\n -- depends_on: {{ ref('data_monitoring_metrics') }}\n -- depends_on: {{ ref('dbt_run_results') }}\n\n {{ elementary.test_table_anomalies(\n model=model,\n table_anomalies=[\"freshness\"],\n freshness_column=none,\n timestamp_column=timestamp_column,\n where_expression=where_expression,\n anomaly_sensitivity=anomaly_sensitivity,\n min_training_set_size=min_training_set_size,\n time_bucket=time_bucket,\n days_back=days_back,\n backfill_days=backfill_days,\n mandatory_params=['timestamp_column'],\n seasonality=seasonality,\n sensitivity=sensitivity,\n detection_delay=detection_delay,\n anomaly_exclude_metrics=anomaly_exclude_metrics,\n detection_period=detection_period,\n training_period=training_period\n )\n }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.elementary.test_table_anomalies" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6739461, + "supported_languages": null + }, + "macro.elementary.test_all_columns_anomalies": { + "name": "test_all_columns_anomalies", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_all_columns_anomalies.sql", + "original_file_path": "macros/edr/tests/test_all_columns_anomalies.sql", + "unique_id": "macro.elementary.test_all_columns_anomalies", + "macro_sql": "{% test all_columns_anomalies(model, column_anomalies, exclude_prefix, exclude_regexp, timestamp_column, where_expression, anomaly_sensitivity, anomaly_direction, min_training_set_size, time_bucket, days_back, backfill_days, seasonality, sensitivity, detection_delay, anomaly_exclude_metrics, detection_period, training_period) %}\n -- depends_on: {{ ref('monitors_runs') }}\n -- depends_on: {{ ref('data_monitoring_metrics') }}\n -- depends_on: {{ ref('dbt_run_results') }}\n\n {%- if execute and elementary.is_test_command() %}\n {% set model_relation = elementary.get_model_relation_for_test(model, context[\"model\"]) %}\n {% if not model_relation %}\n {{ exceptions.raise_compiler_error(\"Unsupported model: \" ~ model ~ \" (this might happen if you override 'ref' or 'source')\") }}\n {% endif %}\n\n {%- if elementary.is_ephemeral_model(model_relation) %}\n {{ exceptions.raise_compiler_error(\"The test is not supported for ephemeral models, model name: {}\".format(model_relation.identifier)) }}\n {%- endif %}\n\n {%- set test_table_name = elementary.get_elementary_test_table_name() %}\n {{- elementary.debug_log('collecting metrics for test: ' ~ test_table_name) }}\n {#- creates temp relation for test metrics -#}\n {%- set database_name, schema_name = elementary.get_package_database_and_schema('elementary') %}\n {% set tests_schema_name = elementary.get_elementary_tests_schema(database_name, schema_name) %}\n {%- set empty_table_query = elementary.empty_data_monitoring_metrics(with_created_at=false) %}\n {% set temp_table_relation = elementary.create_elementary_test_table(database_name, tests_schema_name, test_table_name, 'metrics', empty_table_query) %}\n\n {#- get table configuration -#}\n {%- set full_table_name = elementary.relation_to_full_name(model_relation) %}\n\n {%- set test_configuration, metric_properties = elementary.get_anomalies_test_configuration(model_relation=model_relation,\n timestamp_column=timestamp_column,\n where_expression=where_expression,\n anomaly_sensitivity=anomaly_sensitivity,\n anomaly_direction=anomaly_direction,\n min_training_set_size=min_training_set_size,\n time_bucket=time_bucket,\n days_back=days_back,\n backfill_days=backfill_days,\n seasonality=seasonality,\n sensitivity=sensitivity,\n detection_delay=detection_delay,\n anomaly_exclude_metrics=anomaly_exclude_metrics,\n detection_period=detection_period,\n training_period=training_period) %}\n\n {%- if not test_configuration %}\n {{ exceptions.raise_compiler_error(\"Failed to create test configuration dict for test `{}`\".format(test_table_name)) }}\n {%- endif %}\n {{ elementary.debug_log('test configuration - ' ~ test_configuration) }}\n\n {%- set column_objs_and_monitors = elementary.get_all_column_obj_and_monitors(model_relation, column_anomalies) -%}\n {#- execute table monitors and write to temp test table -#}\n {%- set monitors = [] %}\n {%- if column_objs_and_monitors | length > 0 %}\n {{- elementary.test_log('start', full_table_name, 'all columns') }}\n {%- for column_obj_and_monitors in column_objs_and_monitors %}\n {%- set column_obj = column_obj_and_monitors['column'] %}\n {%- set column_monitors = column_obj_and_monitors['monitors'] %}\n {%- set column_name = column_obj.name -%}\n {%- set ignore_column = elementary.should_ignore_column(column_name, exclude_regexp, exclude_prefix) -%}\n {%- if not ignore_column -%}\n {%- do monitors.extend(column_monitors) -%}\n {% if test_configuration.timestamp_column %}\n {%- set min_bucket_start, max_bucket_end = elementary.get_test_buckets_min_and_max(model_relation=model_relation,\n backfill_days=test_configuration.backfill_days,\n days_back=test_configuration.days_back,\n detection_delay=test_configuration.detection_delay,\n monitors=column_monitors,\n column_name=column_name,\n metric_properties=metric_properties) %}\n {%- endif %}\n {{ elementary.debug_log('min_bucket_start - ' ~ min_bucket_start) }}\n {{ elementary.test_log('start', full_table_name, column_name) }}\n {%- set column_monitoring_query = elementary.column_monitoring_query(model, model_relation, min_bucket_start, max_bucket_end, test_configuration.days_back, column_obj, column_monitors, metric_properties) %}\n {%- do elementary.run_query(elementary.insert_as_select(temp_table_relation, column_monitoring_query)) -%}\n {%- else -%}\n {{ elementary.debug_log('column ' ~ column_name ~ ' is excluded') }}\n {%- endif -%}\n {%- endfor %}\n {%- endif %}\n {%- set all_columns_monitors = monitors | unique | list %}\n {#- query if there is an anomaly in recent metrics -#}\n {%- set anomaly_scores_query = elementary.get_anomaly_scores_query(test_metrics_table_relation=temp_table_relation,\n model_relation=model_relation,\n test_configuration=test_configuration,\n monitors=all_columns_monitors,\n columns_only=true,\n metric_properties=metric_properties) %}\n\n {% set anomaly_scores_test_table_relation = elementary.create_elementary_test_table(database_name, tests_schema_name, test_table_name, 'anomaly_scores', anomaly_scores_query) %}\n\n {{- elementary.test_log('end', full_table_name, 'all columns') }}\n\n {{ elementary.get_read_anomaly_scores_query() }}\n\n {%- else %}\n\n {#- test must run an sql query -#}\n {{- elementary.no_results_query() }}\n\n {%- endif %}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.elementary.is_test_command", + "macro.elementary.get_model_relation_for_test", + "macro.elementary.is_ephemeral_model", + "macro.elementary.get_elementary_test_table_name", + "macro.elementary.debug_log", + "macro.elementary.get_package_database_and_schema", + "macro.elementary.get_elementary_tests_schema", + "macro.elementary.empty_data_monitoring_metrics", + "macro.elementary.create_elementary_test_table", + "macro.elementary.relation_to_full_name", + "macro.elementary.get_anomalies_test_configuration", + "macro.elementary.get_all_column_obj_and_monitors", + "macro.elementary.test_log", + "macro.elementary.should_ignore_column", + "macro.elementary.get_test_buckets_min_and_max", + "macro.elementary.column_monitoring_query", + "macro.elementary.run_query", + "macro.elementary.insert_as_select", + "macro.elementary.get_anomaly_scores_query", + "macro.elementary.get_read_anomaly_scores_query", + "macro.elementary.no_results_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.682369, + "supported_languages": null + }, + "macro.elementary.should_ignore_column": { + "name": "should_ignore_column", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_all_columns_anomalies.sql", + "original_file_path": "macros/edr/tests/test_all_columns_anomalies.sql", + "unique_id": "macro.elementary.should_ignore_column", + "macro_sql": "\n\n{%- macro should_ignore_column(column_name, exclude_regexp, exclude_prefix) -%}\n {%- set regex_module = modules.re -%}\n {%- if exclude_regexp -%}\n {%- set is_match = regex_module.match(exclude_regexp, column_name, regex_module.IGNORECASE) %}\n {%- if is_match -%}\n {{ return(True) }}\n {%- endif -%}\n {%- endif -%}\n {% if exclude_prefix %}\n {%- set exclude_regexp = '^' ~ exclude_prefix ~ '.*' %}\n {%- set is_match = regex_module.match(exclude_regexp, column_name, regex_module.IGNORECASE) %}\n {%- if is_match -%}\n {{ return(True) }}\n {%- endif -%}\n {%- endif -%}\n {{ return(False) }}\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6830301, + "supported_languages": null + }, + "macro.elementary.test_json_schema": { + "name": "test_json_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_json_schema.sql", + "original_file_path": "macros/edr/tests/test_json_schema.sql", + "unique_id": "macro.elementary.test_json_schema", + "macro_sql": "{% test json_schema(model, column_name, where_expression) %}\n {{ config(fail_calc = 'fail_count') }}\n\n {% if not execute or not elementary.is_test_command() %}\n {% do return(none) %}\n {% endif %}\n\n {% if model is string %}\n {{ exceptions.raise_compiler_error(\"Unsupported model: \" ~ model ~ \" (this might happen if you provide a 'where' parameter to the test or override 'ref' or 'source')\") }}\n {% endif %}\n\n {% if not elementary.column_exists_in_relation(model, column_name) %}\n {% do exceptions.raise_compiler_error(\"Column '{}' does not exist in node '{}'!\".format(column_name, model.name)) %}\n {% endif %}\n {% if not kwargs %}\n {% do exceptions.raise_compiler_error(\"A json schema must be supplied as a part of the test!\") %}\n {% endif %}\n\n {{ elementary.test_python(model, elementary.json_schema_python_test, {'column_name': column_name, 'json_schema': kwargs}, where_expression,\n packages=['jsonschema']) }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.elementary.is_test_command", + "macro.elementary.column_exists_in_relation", + "macro.elementary.test_python" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.684814, + "supported_languages": null + }, + "macro.elementary.json_schema_python_test": { + "name": "json_schema_python_test", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_json_schema.sql", + "original_file_path": "macros/edr/tests/test_json_schema.sql", + "unique_id": "macro.elementary.json_schema_python_test", + "macro_sql": "{% macro json_schema_python_test(args) %}\nimport json\nimport jsonschema\n\ndef is_valid_json(val, json_schema):\n try:\n jsonschema.validate(json.loads(val), json_schema)\n return True\n except (json.JSONDecodeError, jsonschema.ValidationError):\n return False\n\ndef get_column_name_in_df(df, column_name):\n matching = [col for col in df.columns if col.lower() == column_name.lower()]\n if len(matching) > 1:\n # Case matters, switch to case-sensitive match\n matching = [col for col in df.columns if col == column_name]\n\n if len(matching) == 0:\n raise Exception(\"No column with the name: {}\".format(col))\n return matching[0]\n\ndef test(model_df, ref, session):\n raw_json_schema = r\"\"\"{{ args.json_schema if args.json_schema is string else tojson(args.json_schema) }}\"\"\"\n json_schema = json.loads(raw_json_schema)\n\n model_df = model_df.toPandas()\n column_name = get_column_name_in_df(model_df, \"{{ args.column_name }}\")\n model_df[\"is_valid_json\"] = model_df[column_name].apply(lambda val: is_valid_json(val, json_schema))\n\n return model_df[model_df.is_valid_json == False]\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6850939, + "supported_languages": null + }, + "macro.elementary.test_volume_anomalies": { + "name": "test_volume_anomalies", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_volume_anomalies.sql", + "original_file_path": "macros/edr/tests/test_volume_anomalies.sql", + "unique_id": "macro.elementary.test_volume_anomalies", + "macro_sql": "{% test volume_anomalies(model, timestamp_column, where_expression, anomaly_sensitivity, anomaly_direction, min_training_set_size, time_bucket, days_back, backfill_days, seasonality, sensitivity, ignore_small_changes, fail_on_zero, detection_delay, anomaly_exclude_metrics, detection_period, training_period) %}\n -- depends_on: {{ ref('monitors_runs') }}\n -- depends_on: {{ ref('data_monitoring_metrics') }}\n -- depends_on: {{ ref('dbt_run_results') }}\n\n {{ elementary.test_table_anomalies(\n model=model,\n table_anomalies=[\"row_count\"],\n freshness_column=none,\n timestamp_column=timestamp_column,\n where_expression=where_expression,\n anomaly_sensitivity=anomaly_sensitivity,\n anomaly_direction=anomaly_direction,\n min_training_set_size=min_training_set_size,\n time_bucket=time_bucket,\n days_back=days_back,\n backfill_days=backfill_days,\n seasonality=seasonality,\n sensitivity=sensitivity,\n ignore_small_changes=ignore_small_changes,\n fail_on_zero=fail_on_zero,\n detection_delay=detection_delay,\n anomaly_exclude_metrics=anomaly_exclude_metrics,\n detection_period=detection_period,\n training_period=training_period\n )\n }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.elementary.test_table_anomalies" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6861382, + "supported_languages": null + }, + "macro.elementary.test_dimension_anomalies": { + "name": "test_dimension_anomalies", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_dimension_anomalies.sql", + "original_file_path": "macros/edr/tests/test_dimension_anomalies.sql", + "unique_id": "macro.elementary.test_dimension_anomalies", + "macro_sql": "{% test dimension_anomalies(model, dimensions, timestamp_column, where_expression, anomaly_sensitivity, anomaly_direction, min_training_set_size, time_bucket, days_back, backfill_days, seasonality, sensitivity, detection_delay, anomaly_exclude_metrics, detection_period, training_period) %}\n -- depends_on: {{ ref('monitors_runs') }}\n -- depends_on: {{ ref('data_monitoring_metrics') }}\n -- depends_on: {{ ref('dbt_run_results') }}\n\n {%- if execute and elementary.is_test_command() %}\n {% set model_relation = elementary.get_model_relation_for_test(model, context[\"model\"]) %}\n {% if not model_relation %}\n {{ exceptions.raise_compiler_error(\"Unsupported model: \" ~ model ~ \" (this might happen if you override 'ref' or 'source')\") }}\n {% endif %}\n\n {%- if elementary.is_ephemeral_model(model_relation) %}\n {{ exceptions.raise_compiler_error(\"The test is not supported for ephemeral models, model name: {}\".format(model_relation.identifier)) }}\n {%- endif %}\n {%- set mandatory_params = ['dimensions'] %}\n\n {% set test_table_name = elementary.get_elementary_test_table_name() %}\n {{ elementary.debug_log('collecting metrics for test: ' ~ test_table_name) }}\n {#- creates temp relation for test metrics -#}\n {% set database_name, schema_name = elementary.get_package_database_and_schema('elementary') %}\n {% set tests_schema_name = elementary.get_elementary_tests_schema(database_name, schema_name) %}\n\n {#- get table configuration -#}\n {%- set full_table_name = elementary.relation_to_full_name(model_relation) %}\n\n {%- set test_configuration, metric_properties = elementary.get_anomalies_test_configuration(model_relation=model_relation,\n mandatory_params=mandatory_params,\n timestamp_column=timestamp_column,\n where_expression=where_expression,\n anomaly_sensitivity=anomaly_sensitivity,\n anomaly_direction=anomaly_direction,\n min_training_set_size=min_training_set_size,\n time_bucket=time_bucket,\n days_back=days_back,\n backfill_days=backfill_days,\n seasonality=seasonality,\n dimensions=dimensions,\n sensitivity=sensitivity,\n detection_delay=detection_delay,\n anomaly_exclude_metrics=anomaly_exclude_metrics,\n detection_period=detection_period,\n training_period=training_period) %}\n \n {%- if not test_configuration %}\n {{ exceptions.raise_compiler_error(\"Failed to create test configuration dict for test `{}`\".format(test_table_name)) }}\n {%- endif %}\n {{ elementary.debug_log('test configuration - ' ~ test_configuration) }}\n\n {%- set min_bucket_start, max_bucket_end = elementary.get_test_buckets_min_and_max(model_relation=model_relation,\n backfill_days=test_configuration.backfill_days,\n days_back=test_configuration.days_back,\n detection_delay=test_configuration.detection_delay,\n metric_properties=metric_properties) %}\n\n {{ elementary.debug_log('min_bucket_start - ' ~ min_bucket_start) }}\n {#- execute table monitors and write to temp test table -#}\n {{ elementary.test_log('start', full_table_name) }}\n\n {%- set dimension_monitoring_query = elementary.dimension_monitoring_query(model, model_relation, metric_properties.dimensions, min_bucket_start, max_bucket_end, test_configuration, metric_properties) %}\n {{ elementary.debug_log('dimension_monitoring_query - \\n' ~ dimension_monitoring_query) }}\n\n {% set temp_table_relation = elementary.create_elementary_test_table(database_name, tests_schema_name, test_table_name, 'metrics', dimension_monitoring_query) %}\n\n {#- calculate anomaly scores for metrics -#}\n {% set anomaly_scores_query = elementary.get_anomaly_scores_query(test_metrics_table_relation=temp_table_relation,\n model_relation=model_relation,\n test_configuration=test_configuration,\n monitors=['dimension'],\n metric_properties=metric_properties) %}\n\n {{ elementary.debug_log('dimension monitors anomaly scores query - \\n' ~ anomaly_scores_query) }}\n {% set anomaly_scores_test_table_relation = elementary.create_elementary_test_table(database_name, tests_schema_name, test_table_name, 'anomaly_scores', anomaly_scores_query) %}\n {{ elementary.test_log('end', full_table_name) }}\n\n {{ elementary.get_anomaly_query() }}\n\n {% else %}\n\n {# test must run an sql query #}\n {{ elementary.no_results_query() }}\n\n {% endif %}\n\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.elementary.is_test_command", + "macro.elementary.get_model_relation_for_test", + "macro.elementary.is_ephemeral_model", + "macro.elementary.get_elementary_test_table_name", + "macro.elementary.debug_log", + "macro.elementary.get_package_database_and_schema", + "macro.elementary.get_elementary_tests_schema", + "macro.elementary.relation_to_full_name", + "macro.elementary.get_anomalies_test_configuration", + "macro.elementary.get_test_buckets_min_and_max", + "macro.elementary.test_log", + "macro.elementary.dimension_monitoring_query", + "macro.elementary.create_elementary_test_table", + "macro.elementary.get_anomaly_scores_query", + "macro.elementary.get_anomaly_query", + "macro.elementary.no_results_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6913338, + "supported_languages": null + }, + "macro.elementary.test_python": { + "name": "test_python", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/python.sql", + "original_file_path": "macros/edr/tests/python.sql", + "unique_id": "macro.elementary.test_python", + "macro_sql": "{% test python(model, code_macro, macro_args, where_expression) %}\n {{ config(fail_calc = 'fail_count') }}\n\n {% if not execute %}\n {% do return(none) %}\n {% endif %}\n\n {% if model is string %}\n {{ exceptions.raise_compiler_error(\"Unsupported model: \" ~ model ~ \" (this might happen if you provide a 'where' parameter to the test or override 'ref' or 'source')\") }}\n {% endif %}\n\n {% if not code_macro %}\n {% do exceptions.raise_compiler_error('A `code_macro` must be provided to a Python test.') %}\n {% endif %}\n {% if not macro_args %}\n {% set macro_args = {} %}\n {% endif %}\n\n {% set test_args = kwargs %}\n {% set test_node = context.model %}\n {% set model_relation = model.quote(false, false, false) %}\n {% set elementary_database_name, elementary_schema_name = elementary.get_package_database_and_schema() %}\n {% set output_table = api.Relation.create(database=elementary_database_name, schema=elementary_schema_name,\n identifier='pytest_tmp__' ~ test_node.alias).quote(false, false, false) %}\n\n {# This affects where resources needed for python execution (e.g. stored procedures) are created.\n By default, dbt uses the audit schema (adds _dbt__test_audit to the model's schema).\n We prefer to change this behavior and use Elementary's database and schema instead (this also guarantees the test\n will work for sources).\n #}\n {% do test_node.update({'database': elementary_database_name, 'schema': elementary_schema_name}) %}\n\n {% do test_node.config.update(test_args) %}\n\n {% if code_macro is string %}\n {% set user_py_code_macro = context[code_macro] %}\n {% else %}\n {% set user_py_code_macro = code_macro %}\n {% endif %}\n\n {% if not user_py_code_macro %}\n {% do exceptions.raise_compiler_error('Unable to find the macro `' ~ code_macro ~ '`.') %}\n {% endif %}\n {% set user_py_code = user_py_code_macro(macro_args) %}\n {% set compiled_py_code = adapter.dispatch('compile_py_code', 'elementary')(model_relation, user_py_code,\n output_table, where_expression, code_type='test') %}\n\n {% do elementary.run_python(test_node, compiled_py_code) %}\n select fail_count from {{ output_table }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.elementary.get_package_database_and_schema", + "macro.elementary.snowflake__compile_py_code", + "macro.elementary.run_python" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.693962, + "supported_languages": null + }, + "macro.elementary.test_schema_changes": { + "name": "test_schema_changes", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_schema_changes.sql", + "original_file_path": "macros/edr/tests/test_schema_changes.sql", + "unique_id": "macro.elementary.test_schema_changes", + "macro_sql": "{% test schema_changes(model) %}\n -- depends_on: {{ ref('schema_columns_snapshot') }}\n\n {%- if execute and elementary.is_test_command() %}\n {% set model_relation = elementary.get_model_relation_for_test(model, context[\"model\"]) %}\n {% if not model_relation %}\n {{ exceptions.raise_compiler_error(\"Unsupported model: \" ~ model ~ \" (this might happen if you override 'ref' or 'source')\") }}\n {% endif %}\n\n {%- if elementary.is_ephemeral_model(model_relation) %}\n {{ exceptions.raise_compiler_error(\"The test is not supported for ephemeral models, model name: {}\".format(model_relation.identifier)) }}\n {%- endif %}\n {% set test_table_name = elementary.get_elementary_test_table_name() %}\n {{ elementary.debug_log('collecting metrics for test: ' ~ test_table_name) }}\n {# creates temp relation for schema columns info #}\n {% set database_name, schema_name = elementary.get_package_database_and_schema('elementary') %}\n {% set tests_schema_name = elementary.get_elementary_tests_schema(database_name, schema_name) %}\n\n {#- get table configuration -#}\n {%- set full_table_name = elementary.relation_to_full_name(model_relation) %}\n\n {#- query current schema and write to temp test table -#}\n {{ elementary.edr_log('Started testing schema changes on:' ~ full_table_name) }}\n {%- set column_snapshot_query = elementary.get_columns_snapshot_query(model_relation, full_table_name) %}\n {{ elementary.debug_log('column_snapshot_query - \\n' ~ column_snapshot_query) }}\n\n {% set temp_table_relation = elementary.create_elementary_test_table(database_name, tests_schema_name, test_table_name, 'schema_changes', column_snapshot_query) %}\n\n {# query if there were schema changes since last execution #}\n {% set schema_changes_alert_query = elementary.get_columns_changes_from_last_run_query(full_table_name, temp_table_relation) %}\n {{ elementary.debug_log('schema_changes_alert_query - \\n' ~ schema_changes_alert_query) }}\n {% set alerts_temp_table_relation = elementary.create_elementary_test_table(database_name, tests_schema_name, test_table_name, 'schema_changes_alerts', schema_changes_alert_query) %}\n {# return schema changes query as standard test query #}\n select * from {{ alerts_temp_table_relation }}\n\n {% else %}\n\n {# test must run an sql query #}\n {{ elementary.no_results_query() }}\n\n {% endif %}\n\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.elementary.is_test_command", + "macro.elementary.get_model_relation_for_test", + "macro.elementary.is_ephemeral_model", + "macro.elementary.get_elementary_test_table_name", + "macro.elementary.debug_log", + "macro.elementary.get_package_database_and_schema", + "macro.elementary.get_elementary_tests_schema", + "macro.elementary.relation_to_full_name", + "macro.elementary.edr_log", + "macro.elementary.get_columns_snapshot_query", + "macro.elementary.create_elementary_test_table", + "macro.elementary.get_columns_changes_from_last_run_query", + "macro.elementary.no_results_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.6960058, + "supported_languages": null + }, + "macro.elementary.test_column_anomalies": { + "name": "test_column_anomalies", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_column_anomalies.sql", + "original_file_path": "macros/edr/tests/test_column_anomalies.sql", + "unique_id": "macro.elementary.test_column_anomalies", + "macro_sql": "{% test column_anomalies(model, column_name, column_anomalies, timestamp_column, where_expression, anomaly_sensitivity, anomaly_direction, min_training_set_size, time_bucket, days_back, backfill_days, seasonality, sensitivity, detection_delay, anomaly_exclude_metrics, detection_period, training_period) %}\n -- depends_on: {{ ref('monitors_runs') }}\n -- depends_on: {{ ref('data_monitoring_metrics') }}\n -- depends_on: {{ ref('dbt_run_results') }}\n\n {%- if execute and elementary.is_test_command() %}\n {% set model_relation = elementary.get_model_relation_for_test(model, context[\"model\"]) %}\n {% if not model_relation %}\n {{ exceptions.raise_compiler_error(\"Unsupported model: \" ~ model ~ \" (this might happen if you override 'ref' or 'source')\") }}\n {% endif %}\n\n {%- if elementary.is_ephemeral_model(model_relation) %}\n {{ exceptions.raise_compiler_error(\"The test is not supported for ephemeral models, model name: {}\".format(model_relation.identifier)) }}\n {%- endif %}\n\n {% set test_table_name = elementary.get_elementary_test_table_name() %}\n {{ elementary.debug_log('collecting metrics for test: ' ~ test_table_name) }}\n {#- creates temp relation for test metrics -#}\n {% set database_name, schema_name = elementary.get_package_database_and_schema('elementary') %}\n {% set tests_schema_name = elementary.get_elementary_tests_schema(database_name, schema_name) %}\n\n {#- get table configuration -#}\n {%- set full_table_name = elementary.relation_to_full_name(model_relation) %}\n\n {%- set test_configuration, metric_properties = elementary.get_anomalies_test_configuration(model_relation=model_relation,\n timestamp_column=timestamp_column,\n where_expression=where_expression,\n anomaly_sensitivity=anomaly_sensitivity,\n anomaly_direction=anomaly_direction,\n min_training_set_size=min_training_set_size,\n time_bucket=time_bucket,\n days_back=days_back,\n backfill_days=backfill_days,\n seasonality=seasonality,\n sensitivity=sensitivity,\n detection_delay=detection_delay,\n anomaly_exclude_metrics=anomaly_exclude_metrics,\n detection_period=detection_period,\n training_period=training_period) %}\n\n {%- if not test_configuration %}\n {{ exceptions.raise_compiler_error(\"Failed to create test configuration dict for test `{}`\".format(test_table_name)) }}\n {%- endif %}\n {{ elementary.debug_log('test configuration - ' ~ test_configuration) }}\n\n {%- set column_obj_and_monitors = elementary.get_column_obj_and_monitors(model_relation, column_name, column_anomalies) -%}\n {%- if not column_obj_and_monitors -%}\n {{ exceptions.raise_compiler_error(\"Unable to find column `{}` in `{}`\".format(column_name, full_table_name)) }}\n {%- endif -%}\n {%- set column_monitors = column_obj_and_monitors['monitors'] -%}\n {%- set column_obj = column_obj_and_monitors['column'] -%}\n {{ elementary.debug_log('column_monitors - ' ~ column_monitors) }}\n\n {% if test_configuration.timestamp_column %}\n {%- set min_bucket_start, max_bucket_end = elementary.get_test_buckets_min_and_max(model_relation=model_relation,\n backfill_days=test_configuration.backfill_days,\n days_back=test_configuration.days_back,\n detection_delay=test_configuration.detection_delay,\n monitors=column_monitors,\n column_name=column_name,\n metric_properties=metric_properties) %}\n {%- endif %}\n {{ elementary.debug_log('min_bucket_start - ' ~ min_bucket_start) }}\n {#- execute table monitors and write to temp test table -#}\n {{ elementary.test_log('start', full_table_name, column_name) }}\n {%- set column_monitoring_query = elementary.column_monitoring_query(model,\n model_relation,\n min_bucket_start,\n max_bucket_end,\n test_configuration.days_back,\n column_obj,\n column_monitors,\n metric_properties) %}\n {{ elementary.debug_log('column_monitoring_query - \\n' ~ column_monitoring_query) }}\n {% set temp_table_relation = elementary.create_elementary_test_table(database_name, tests_schema_name, test_table_name, 'metrics', column_monitoring_query) %}\n\n {#- calculate anomaly scores for metrics -#}\n {%- set temp_table_name = elementary.relation_to_full_name(temp_table_relation) %}\n {% set anomaly_scores_query = elementary.get_anomaly_scores_query(test_metrics_table_relation=temp_table_relation,\n model_relation=model_relation,\n test_configuration=test_configuration,\n monitors=column_monitors,\n column_name=column_name,\n metric_properties=metric_properties\n ) %}\n\n {{ elementary.debug_log('anomaly_score_query - \\n' ~ anomaly_scores_query) }}\n {% set anomaly_scores_test_table_relation = elementary.create_elementary_test_table(database_name, tests_schema_name, test_table_name, 'anomaly_scores', anomaly_scores_query) %}\n {{ elementary.test_log('end', full_table_name, column_name) }}\n\n {{ elementary.get_read_anomaly_scores_query() }}\n\n {%- else %}\n\n {#- test must run an sql query -#}\n {{ elementary.no_results_query() }}\n\n {%- endif %}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.elementary.is_test_command", + "macro.elementary.get_model_relation_for_test", + "macro.elementary.is_ephemeral_model", + "macro.elementary.get_elementary_test_table_name", + "macro.elementary.debug_log", + "macro.elementary.get_package_database_and_schema", + "macro.elementary.get_elementary_tests_schema", + "macro.elementary.relation_to_full_name", + "macro.elementary.get_anomalies_test_configuration", + "macro.elementary.get_column_obj_and_monitors", + "macro.elementary.get_test_buckets_min_and_max", + "macro.elementary.test_log", + "macro.elementary.column_monitoring_query", + "macro.elementary.create_elementary_test_table", + "macro.elementary.get_anomaly_scores_query", + "macro.elementary.get_read_anomaly_scores_query", + "macro.elementary.no_results_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7035599, + "supported_languages": null + }, + "macro.elementary.test_exposure_schema_validity": { + "name": "test_exposure_schema_validity", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_exposure_schema_validity.sql", + "original_file_path": "macros/edr/tests/test_exposure_schema_validity.sql", + "unique_id": "macro.elementary.test_exposure_schema_validity", + "macro_sql": "{% test exposure_schema_validity(model, exposures, node, columns) %}\n {%- if not execute or not elementary.is_test_command() -%}\n {%- do return(none) -%}\n {%- endif -%}\n\n {%- if dbt_version <= '1.3.0' -%}\n {# attached_node is only available on newer dbt versions #}\n {%- set base_node = context['model']['depends_on']['nodes'][0] -%}\n {%- else -%}\n {%- set base_node = context['model']['attached_node'] -%}\n {%- endif -%}\n\n {# Parameters used only for dependency injection in integration tests #}\n {%- set node = node or base_node -%}\n {%- set exposures = (exposures or graph.exposures).values() -%}\n {%- set columns = columns or adapter.get_columns_in_relation(model) -%}\n\n {%- set model_relation = elementary.get_model_relation_for_test(model, context[\"model\"]) -%}\n {%- set full_table_name = elementary.relation_to_full_name(model_relation) -%}\n {{- elementary.test_log('start', full_table_name, 'exposure validation') -}}\n\n {%- set matching_exposures = [] -%}\n\n {%- for exposure in exposures -%}\n {#\n\n We need the 'meta' property to be defined in the exposure, since column level info is not available on exposures.\n The 'meta' property needs to have a 'referenced_columns' array (see properties in the next comment)\n\n #}\n {%- if node in exposure.depends_on.nodes and (exposure['meta'] or none) is not none -%}\n {%- do matching_exposures.append(exposure) -%}\n {%- endif -%}\n {%- endfor -%}\n {%- if matching_exposures | length > 0 -%}\n {%- set columns_dict = {} -%}\n {%- for column in columns -%}\n {%- do columns_dict.update({ column['name'].strip('\"').strip(\"'\") | upper : elementary.normalize_data_type(elementary.get_column_data_type(column)) }) -%}\n {%- endfor -%}\n {%- set invalid_exposures = [] -%}\n {%- for exposure in matching_exposures -%}\n {%- set meta = exposure['meta'] or none -%}\n {%- if meta != none and (meta['referenced_columns'] or none) is iterable -%}\n {%- for exposure_column in meta['referenced_columns'] -%}\n {#\n Each column in 'referenced_columns' has the following property:\n\n 'column_name'\n\n Optionally, you can specify the following properties:\n\n 'data_type' - the specific data type of the column\n\n 'node' - the ref to the source node of the specific column used in the exposure\n\n #}\n {%- if matching_exposures | length > 1 and 'node' not in exposure_column -%}\n {%- do elementary.edr_log_warning(\"missing node property for the exposure: \" ~ exposure['name'] ~ \" which not the only exposure depending on \" ~ model ~ \", We're not able to verify the column level dependencies of this exposure\") -%}\n {%- elif matching_exposures | length == 1 or (context['render'](elementary.get_rendered_ref((exposure_column['node'] or ''))) == context['render'](model | lower)) -%}\n {%- if exposure_column['column_name'] | upper not in columns_dict.keys() -%}\n {%- do invalid_exposures.append({\n 'exposure': exposure['name'],\n 'url': exposure['url'],\n 'error': exposure_column['column_name'] ~ ' column missing in the model'\n })\n -%}\n {%- elif (exposure_column['data_type'] or '') != '' and exposure_column['data_type'] != columns_dict[exposure_column['column_name'] | upper] -%}\n {%- do invalid_exposures.append({\n 'exposure': exposure['name'],\n 'url': exposure['url'],\n 'error': 'different data type for the column ' ~ exposure_column['column_name'] ~ ' ' ~ exposure_column['data_type'] ~ ' vs ' ~ columns_dict[exposure_column['name'] | upper]\n })\n -%}\n {%- endif -%}\n {%- endif -%}\n {%- endfor -%}\n {%- else -%}\n {%- do elementary.edr_log_warning(\"missing meta property for the exposure: \" ~ exposure['name'] ~ \", We're not able to verify the column level dependencies of this exposure\") -%}\n {%- endif -%}\n {%- endfor -%}\n {%- if invalid_exposures | length > 0 -%}\n {%- for invalid_exposure in invalid_exposures %}\n {{ 'UNION ALL ' if not loop.first }}SELECT '{{ invalid_exposure['exposure'] }}' as exposure, '{{ invalid_exposure['url'] }}' as url, '{{ invalid_exposure['error'] }}' as error\n {%- endfor -%}\n {%- else -%}\n {{ elementary.no_results_query() }}\n {%- endif -%}\n {%- else -%}\n {{ elementary.no_results_query() }}\n\n {%- endif -%}\n {{ elementary.test_log('end', full_table_name, 'exposure validation') }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.elementary.is_test_command", + "macro.elementary.get_model_relation_for_test", + "macro.elementary.relation_to_full_name", + "macro.elementary.test_log", + "macro.elementary.normalize_data_type", + "macro.elementary.get_column_data_type", + "macro.elementary.edr_log_warning", + "macro.elementary.get_rendered_ref", + "macro.elementary.no_results_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.708949, + "supported_languages": null + }, + "macro.elementary.test_event_freshness_anomalies": { + "name": "test_event_freshness_anomalies", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_event_freshness_anomalies.sql", + "original_file_path": "macros/edr/tests/test_event_freshness_anomalies.sql", + "unique_id": "macro.elementary.test_event_freshness_anomalies", + "macro_sql": "{% test event_freshness_anomalies(model, event_timestamp_column, update_timestamp_column, where_expression, anomaly_sensitivity, anomaly_direction, min_training_set_size, time_bucket, days_back, backfill_days, sensitivity, detection_delay, anomaly_exclude_metrics) %}\n -- depends_on: {{ ref('monitors_runs') }}\n -- depends_on: {{ ref('data_monitoring_metrics') }}\n -- depends_on: {{ ref('dbt_run_results') }}\n\n {% if execute and elementary.is_test_command() %}\n {% set model_relation = elementary.get_model_relation_for_test(model, context[\"model\"]) %}\n {% if not model_relation %}\n {{ exceptions.raise_compiler_error(\"Unsupported model: \" ~ model ~ \" (this might happen if you override 'ref' or 'source')\") }}\n {% endif %}\n\n {%- if not event_timestamp_column -%}\n {%- do exceptions.raise_compiler_error('event_timestamp_column must be specified for the event freshness test!') -%}\n {%- endif -%}\n {%- set event_timestamp_column_data_type = elementary.find_normalized_data_type_for_column(model_relation, event_timestamp_column) -%}\n {%- if not elementary.is_column_timestamp(model_relation, event_timestamp_column, event_timestamp_column_data_type) -%}\n {% do exceptions.raise_compiler_error(\"Column `{}` is not a timestamp.\".format(event_timestamp_column)) %}\n {%- endif -%}\n {% endif %}\n {{ elementary.test_table_anomalies(\n model=model,\n table_anomalies=[\"event_freshness\"],\n timestamp_column=update_timestamp_column,\n where_expression=where_expression,\n anomaly_sensitivity=anomaly_sensitivity,\n min_training_set_size=min_training_set_size,\n time_bucket=time_bucket,\n days_back=days_back,\n backfill_days=backfill_days,\n event_timestamp_column=event_timestamp_column,\n mandatory_params=['event_timestamp_column'],\n sensitivity=sensitivity,\n detection_delay=detection_delay,\n anomaly_exclude_metrics=anomaly_exclude_metrics\n )\n }}\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.elementary.is_test_command", + "macro.elementary.get_model_relation_for_test", + "macro.elementary.find_normalized_data_type_for_column", + "macro.elementary.is_column_timestamp", + "macro.elementary.test_table_anomalies" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.710891, + "supported_languages": null + }, + "macro.elementary.test_table_anomalies": { + "name": "test_table_anomalies", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_table_anomalies.sql", + "original_file_path": "macros/edr/tests/test_table_anomalies.sql", + "unique_id": "macro.elementary.test_table_anomalies", + "macro_sql": "{% test table_anomalies(model, table_anomalies, timestamp_column, where_expression, anomaly_sensitivity, anomaly_direction, min_training_set_size, time_bucket, days_back, backfill_days, seasonality, mandatory_params=none, event_timestamp_column=none, freshness_column=none, sensitivity=none, ignore_small_changes={\"spike_failure_percent_threshold\": none, \"drop_failure_percent_threshold\": none}, fail_on_zero=false, detection_delay=none, anomaly_exclude_metrics=none, detection_period=none, training_period=none) %}\n -- depends_on: {{ ref('monitors_runs') }}\n -- depends_on: {{ ref('data_monitoring_metrics') }}\n -- depends_on: {{ ref('dbt_run_results') }}\n\n {%- if execute and elementary.is_test_command() %}\n {% set model_relation = elementary.get_model_relation_for_test(model, context[\"model\"]) %}\n {% if not model_relation %}\n {{ exceptions.raise_compiler_error(\"The test has unsupported configuration, please contact Elementary support\") }}\n {% endif %}\n\n {%- if elementary.is_ephemeral_model(model_relation) %}\n {{ exceptions.raise_compiler_error(\"The test is not supported for ephemeral models, model name: {}\".format(model_relation.identifier)) }}\n {%- endif %}\n\n {% set test_table_name = elementary.get_elementary_test_table_name() %}\n {{ elementary.debug_log('collecting metrics for test: ' ~ test_table_name) }}\n {#- creates temp relation for test metrics -#}\n {% set database_name, schema_name = elementary.get_package_database_and_schema('elementary') %}\n {% set tests_schema_name = elementary.get_elementary_tests_schema(database_name, schema_name) %}\n\n {#- get table configuration -#}\n {%- set full_table_name = elementary.relation_to_full_name(model_relation) %}\n\n {% set test_configuration, metric_properties = elementary.get_anomalies_test_configuration(model_relation=model_relation,\n mandatory_params=mandatory_params,\n timestamp_column=timestamp_column,\n where_expression=where_expression,\n anomaly_sensitivity=anomaly_sensitivity,\n anomaly_direction=anomaly_direction,\n min_training_set_size=min_training_set_size,\n time_bucket=time_bucket,\n days_back=days_back,\n backfill_days=backfill_days,\n seasonality=seasonality,\n event_timestamp_column=event_timestamp_column,\n sensitivity=sensitivity,\n ignore_small_changes=ignore_small_changes,\n fail_on_zero=fail_on_zero,\n detection_delay=detection_delay,\n anomaly_exclude_metrics=anomaly_exclude_metrics,\n detection_period=detection_period,\n training_period=training_period) %}\n\n {% if not test_configuration %}\n {{ exceptions.raise_compiler_error(\"Failed to create test configuration dict for test `{}`\".format(test_table_name)) }}\n {% endif %}\n {{ elementary.debug_log('test configuration - ' ~ test_configuration) }}\n {%- set table_monitors = elementary.get_final_table_monitors(table_anomalies) %}\n {{ elementary.debug_log('table_monitors - ' ~ table_monitors) }}\n {% if test_configuration.timestamp_column %}\n {%- set min_bucket_start, max_bucket_end = elementary.get_test_buckets_min_and_max(model_relation=model_relation,\n backfill_days=test_configuration.backfill_days,\n days_back=test_configuration.days_back,\n detection_delay=test_configuration.detection_delay,\n monitors=table_monitors,\n metric_properties=metric_properties) %}\n {%- endif %}\n {{ elementary.debug_log('min_bucket_start: ' ~ min_bucket_start ~ ' | max_bucket_end: ' ~ max_bucket_end ) }}\n\n {#- execute table monitors and write to temp test table -#}\n {{ elementary.test_log('start', full_table_name) }}\n {%- set table_monitoring_query = elementary.table_monitoring_query(model,\n model_relation,\n min_bucket_start,\n max_bucket_end,\n table_monitors,\n metric_properties=metric_properties) %}\n {{ elementary.debug_log('table_monitoring_query - \\n' ~ table_monitoring_query) }}\n {% set temp_table_relation = elementary.create_elementary_test_table(database_name, tests_schema_name, test_table_name, 'metrics', table_monitoring_query) %}\n\n {#- calculate anomaly scores for metrics -#}\n {% set anomaly_scores_query = elementary.get_anomaly_scores_query(temp_table_relation,\n model_relation,\n test_configuration=test_configuration,\n metric_properties=metric_properties,\n monitors=table_monitors) %}\n {{ elementary.debug_log('table monitors anomaly scores query - \\n' ~ anomaly_scores_query) }}\n \n {% set anomaly_scores_test_table_relation = elementary.create_elementary_test_table(database_name, tests_schema_name, test_table_name, 'anomaly_scores', anomaly_scores_query) %}\n {{ elementary.test_log('end', full_table_name) }}\n {{ elementary.get_read_anomaly_scores_query() }}\n {% else %}\n\n {# test must run an sql query #}\n {{ elementary.no_results_query() }}\n\n {% endif %}\n\n{% endtest %}", + "depends_on": { + "macros": [ + "macro.elementary.is_test_command", + "macro.elementary.get_model_relation_for_test", + "macro.elementary.is_ephemeral_model", + "macro.elementary.get_elementary_test_table_name", + "macro.elementary.debug_log", + "macro.elementary.get_package_database_and_schema", + "macro.elementary.get_elementary_tests_schema", + "macro.elementary.relation_to_full_name", + "macro.elementary.get_anomalies_test_configuration", + "macro.elementary.get_final_table_monitors", + "macro.elementary.get_test_buckets_min_and_max", + "macro.elementary.test_log", + "macro.elementary.table_monitoring_query", + "macro.elementary.create_elementary_test_table", + "macro.elementary.get_anomaly_scores_query", + "macro.elementary.get_read_anomaly_scores_query", + "macro.elementary.no_results_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.717525, + "supported_languages": null + }, + "macro.elementary.get_test_unique_id": { + "name": "get_test_unique_id", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_test_unique_id.sql", + "original_file_path": "macros/edr/tests/test_utils/get_test_unique_id.sql", + "unique_id": "macro.elementary.get_test_unique_id", + "macro_sql": "{% macro get_test_unique_id() %}\n {% set test_unique_id = model.get('unique_id') %}\n {{ return(test_unique_id) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.717769, + "supported_languages": null + }, + "macro.elementary.find_normalized_data_type_for_column": { + "name": "find_normalized_data_type_for_column", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/find_normalized_data_type_for_column.sql", + "original_file_path": "macros/edr/tests/test_utils/find_normalized_data_type_for_column.sql", + "unique_id": "macro.elementary.find_normalized_data_type_for_column", + "macro_sql": "{% macro find_normalized_data_type_for_column(model_relation, column_name) %}\n\n{% set columns_from_relation = adapter.get_columns_in_relation(model_relation) %}\n{% if column_name and columns_from_relation and columns_from_relation is iterable %}\n {% for column_obj in columns_from_relation %}\n {% if column_obj.column | lower == column_name | trim('\\'\\\"\\`') | lower %}\n {{ return(elementary.normalize_data_type(elementary.get_column_data_type(column_obj))) }}\n {% endif %}\n {% endfor %}\n {% do exceptions.raise_compiler_error(\"Column `{}` was not found in `{}`.\".format(column_name, model_relation.name)) %}\n{% endif %}\n{{ return(none) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.normalize_data_type", + "macro.elementary.get_column_data_type" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.718654, + "supported_languages": null + }, + "macro.elementary.create_elementary_test_table": { + "name": "create_elementary_test_table", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/create_elementary_test_table.sql", + "original_file_path": "macros/edr/tests/test_utils/create_elementary_test_table.sql", + "unique_id": "macro.elementary.create_elementary_test_table", + "macro_sql": "{% macro create_elementary_test_table(database_name, schema_name, test_name, table_type, sql_query) %}\n {% if execute %}\n {% set temp_table_name = elementary.table_name_with_suffix(test_name, \"__\" ~ table_type ~ elementary.get_timestamped_table_suffix()).replace(\"*\", \"\") %}\n \n {% set default_identifier_quoting = api.Relation.get_default_quote_policy().get_part(\"identifier\") %} \n {% if not adapter.config.quoting.get(\"identifier\", default_identifier_quoting) %}\n {% set temp_table_name = adapter.quote(temp_table_name) %}\n {% endif %}\n\n {{ elementary.debug_log(table_type ~ ' table: ' ~ database_name ~ '.' ~ schema_name ~ '.' ~ temp_table_name) }}\n\n {% set _, temp_table_relation = dbt.get_or_create_relation(database=database_name,\n schema=schema_name,\n identifier=temp_table_name,\n type='table') -%}\n\n {# Create the table if it doesn't exist #}\n {%- do elementary.create_or_replace(false, temp_table_relation, sql_query) %}\n\n {# Cache the test table for easy access later #}\n {% set test_entry = elementary.get_cache(\"temp_test_table_relations_map\").setdefault(test_name, {}) %}\n {% do test_entry.update({table_type: temp_table_relation}) %}\n {{ return(temp_table_relation) }}\n {% endif %}\n {{ return(none) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.table_name_with_suffix", + "macro.elementary.get_timestamped_table_suffix", + "macro.elementary.debug_log", + "macro.dbt.get_or_create_relation", + "macro.elementary.create_or_replace", + "macro.elementary.get_cache" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.720524, + "supported_languages": null + }, + "macro.elementary.create_model_baseline_table": { + "name": "create_model_baseline_table", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/create_model_baseline_table.sql", + "original_file_path": "macros/edr/tests/test_utils/create_model_baseline_table.sql", + "unique_id": "macro.elementary.create_model_baseline_table", + "macro_sql": "{% macro create_model_baseline_table(baseline_columns, database_name, schema_name, test_name) %}\n {% set empty_table_query = elementary.empty_table([('column_name','string'),('data_type','string')]) %}\n {% set baseline_table_relation = elementary.create_elementary_test_table(database_name, schema_name,\n test_name | lower, 'schema_baseline',\n empty_table_query) %}\n {% do elementary.insert_rows(baseline_table_relation, baseline_columns, should_commit=True) %}\n {% do return(baseline_table_relation) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table", + "macro.elementary.create_elementary_test_table", + "macro.elementary.insert_rows" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.721235, + "supported_languages": null + }, + "macro.elementary.get_model_graph_node": { + "name": "get_model_graph_node", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_model_graph_node.sql", + "original_file_path": "macros/edr/tests/test_utils/get_model_graph_node.sql", + "unique_id": "macro.elementary.get_model_graph_node", + "macro_sql": "{% macro get_model_graph_node(model_relation) %}\n {% if execute %}\n {# model here is actually the test node in the graph #}\n {% set test_graph_node = model %}\n {% set test_depends_on_unique_ids = test_graph_node.depends_on.nodes %}\n {# model relation is the relation object of the model where the test is defined #}\n {% set relation_name = model_relation.name | lower %}\n {% set depends_on_nodes = elementary.get_nodes_by_unique_ids(test_depends_on_unique_ids) %}\n {% if depends_on_nodes %}\n {% for node in depends_on_nodes %}\n {% set node_name = node.name | lower %}\n {% set node_alias = node.get('alias', '') | lower %}\n {% set node_identifier = node.get('identifier', '') | lower %}\n {% if node_name == relation_name or node_alias == relation_name or node_identifier == relation_name %}\n {{ return(node) }}\n {% endif %}\n {% endfor %}\n {% endif %}\n {% endif %}\n {{ return(none) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_nodes_by_unique_ids" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.722462, + "supported_languages": null + }, + "macro.elementary.get_test_execution_id": { + "name": "get_test_execution_id", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_test_execution_id.sql", + "original_file_path": "macros/edr/tests/test_utils/get_test_execution_id.sql", + "unique_id": "macro.elementary.get_test_execution_id", + "macro_sql": "{% macro get_test_execution_id() %}\n {{ return(elementary.get_node_execution_id(model)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_node_execution_id" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.722641, + "supported_languages": null + }, + "macro.elementary.get_test_type": { + "name": "get_test_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_test_type.sql", + "original_file_path": "macros/edr/tests/test_utils/get_test_type.sql", + "unique_id": "macro.elementary.get_test_type", + "macro_sql": "{% macro get_test_type(flattened_test) %}\n {% if flattened_test.test_namespace == \"elementary\" %}\n {%- set elementary_test_type = elementary.get_elementary_test_type(flattened_test) %}\n {% endif %}\n {% do return(elementary_test_type or \"dbt_test\") %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_elementary_test_type" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.723239, + "supported_languages": null + }, + "macro.elementary.get_elementary_test_type": { + "name": "get_elementary_test_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_test_type.sql", + "original_file_path": "macros/edr/tests/test_utils/get_test_type.sql", + "unique_id": "macro.elementary.get_elementary_test_type", + "macro_sql": "{% macro get_elementary_test_type(flattened_test) %}\n {%- set anomaly_detection_tests = [\n 'volume_anomalies',\n 'freshness_anomalies',\n 'event_freshness_anomalies',\n 'table_anomalies',\n 'dimension_anomalies',\n 'column_anomalies',\n 'all_columns_anomalies'\n ] %}\n {%- set schema_changes_tests = [\n 'schema_changes',\n 'schema_changes_from_baseline',\n 'json_schema',\n ] %}\n\n {% if flattened_test.short_name | lower in anomaly_detection_tests %}\n {% do return(\"anomaly_detection\") %}\n {% elif flattened_test.short_name | lower in schema_changes_tests %}\n {% do return(\"schema_change\") %}\n {% endif %}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.723815, + "supported_languages": null + }, + "macro.elementary.get_model_relation_for_test": { + "name": "get_model_relation_for_test", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_model_relation_for_test.sql", + "original_file_path": "macros/edr/tests/test_utils/get_model_relation_for_test.sql", + "unique_id": "macro.elementary.get_model_relation_for_test", + "macro_sql": "{% macro get_model_relation_for_test(test_model, test_node) %}\n {# If the test model is not a string, then return as-is #}\n {% if test_model is not string %}\n {% do return(test_model) %}\n {% endif %}\n\n {# Test model is a string, this might mean that a \"where\" parameter was passed to the test.\n In the heuristic below we rely on the fact that in this case the model jinja will have\n a very specific structure (see the \"build_model_str\" function in dbt-core) #}\n\n {% set test_metadata = elementary.safe_get_with_default(test_node, 'test_metadata', {}) %}\n {% set test_kwargs = elementary.safe_get_with_default(test_metadata, 'kwargs', {}) %}\n {% set test_model_jinja = test_kwargs.get('model') %}\n\n {% if not test_model_jinja %}\n {% do return(none) %}\n {% endif %}\n\n {# Try to match ref #}\n {% set match = modules.re.match(\n \"{{ get_where_subquery\\(ref\\('(?P.+)'\\)\\) }}\",\n test_model_jinja\n ) %}\n {% if match %}\n {% set group_dict = match.groupdict() %}\n {% set model_name = group_dict[\"model_name\"] %}\n {% do return(ref(model_name)) %}\n {% endif %}\n\n {# Try to match source #}\n {% set match = modules.re.match(\n \"{{ get_where_subquery\\(source\\('(?P.+)', '(?P.+)'\\)\\) }}\",\n test_model_jinja\n ) %}\n {% if match %}\n {% set group_dict = match.groupdict() %}\n {% set source_name = group_dict[\"source_name\"] %}\n {% set table_name = group_dict[\"table_name\"] %}\n {% do return(source(source_name, table_name)) %}\n {% endif %}\n\n {# If we got here, then probably \"ref\" or \"source\" have been overridden with a string query,\n which right now we cannot handle #}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.safe_get_with_default" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.725468, + "supported_languages": null + }, + "macro.elementary.clean_elementary_test_tables": { + "name": "clean_elementary_test_tables", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "original_file_path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "unique_id": "macro.elementary.clean_elementary_test_tables", + "macro_sql": "{% macro clean_elementary_test_tables() %}\n {% set test_table_relations = [] %}\n {% set temp_test_table_relations_map = elementary.get_cache(\"temp_test_table_relations_map\") %}\n {% for test_entry in temp_test_table_relations_map.values() %}\n {% for test_relation in test_entry.values() %}\n {% do test_table_relations.append(test_relation) %}\n {% endfor %}\n {% endfor %}\n\n {% do elementary.file_log(\"Deleting temporary Elementary test tables: {}\".format(test_table_relations)) %}\n {% set queries = elementary.get_clean_elementary_test_tables_queries(test_table_relations) %}\n {% for query in queries %}\n {% do elementary.run_query(query) %}\n {% endfor %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_cache", + "macro.elementary.file_log", + "macro.elementary.get_clean_elementary_test_tables_queries", + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.727672, + "supported_languages": null + }, + "macro.elementary.get_clean_elementary_test_tables_queries": { + "name": "get_clean_elementary_test_tables_queries", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "original_file_path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "unique_id": "macro.elementary.get_clean_elementary_test_tables_queries", + "macro_sql": "{% macro get_clean_elementary_test_tables_queries(test_table_relations) %}\n {% do return(adapter.dispatch(\"get_clean_elementary_test_tables_queries\", \"elementary\")(test_table_relations)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__get_clean_elementary_test_tables_queries" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.727867, + "supported_languages": null + }, + "macro.elementary.default__get_clean_elementary_test_tables_queries": { + "name": "default__get_clean_elementary_test_tables_queries", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "original_file_path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "unique_id": "macro.elementary.default__get_clean_elementary_test_tables_queries", + "macro_sql": "{% macro default__get_clean_elementary_test_tables_queries(test_table_relations) %}\n {% do return(elementary.get_transaction_clean_elementary_test_tables_queries(test_table_relations)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_transaction_clean_elementary_test_tables_queries" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.728024, + "supported_languages": null + }, + "macro.elementary.bigquery__get_clean_elementary_test_tables_queries": { + "name": "bigquery__get_clean_elementary_test_tables_queries", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "original_file_path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "unique_id": "macro.elementary.bigquery__get_clean_elementary_test_tables_queries", + "macro_sql": "{% macro bigquery__get_clean_elementary_test_tables_queries(test_table_relations) %}\n {% do return(elementary.get_transactionless_clean_elementary_test_tables_queries(test_table_relations)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_transactionless_clean_elementary_test_tables_queries" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.728176, + "supported_languages": null + }, + "macro.elementary.spark__get_clean_elementary_test_tables_queries": { + "name": "spark__get_clean_elementary_test_tables_queries", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "original_file_path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "unique_id": "macro.elementary.spark__get_clean_elementary_test_tables_queries", + "macro_sql": "{% macro spark__get_clean_elementary_test_tables_queries(test_table_relations) %}\n {% do return(elementary.get_transactionless_clean_elementary_test_tables_queries(test_table_relations)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_transactionless_clean_elementary_test_tables_queries" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.728329, + "supported_languages": null + }, + "macro.elementary.athena__get_clean_elementary_test_tables_queries": { + "name": "athena__get_clean_elementary_test_tables_queries", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "original_file_path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "unique_id": "macro.elementary.athena__get_clean_elementary_test_tables_queries", + "macro_sql": "{% macro athena__get_clean_elementary_test_tables_queries(test_table_relations) %}\n {% set queries = [] %}\n {% for test_relation in test_table_relations %}\n {% do queries.append(\"DROP TABLE IF EXISTS {}\".format(test_relation.render_pure())) %}\n {% endfor %}\n {% do return(queries) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.728657, + "supported_languages": null + }, + "macro.elementary.get_transaction_clean_elementary_test_tables_queries": { + "name": "get_transaction_clean_elementary_test_tables_queries", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "original_file_path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "unique_id": "macro.elementary.get_transaction_clean_elementary_test_tables_queries", + "macro_sql": "{% macro get_transaction_clean_elementary_test_tables_queries(test_table_relations) %}\n {% set query %}\n BEGIN TRANSACTION;\n {% for test_relation in test_table_relations %}\n DROP TABLE IF EXISTS {{ test_relation }};\n {% endfor %}\n COMMIT;\n {% endset %}\n {% do return([query]) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.728918, + "supported_languages": null + }, + "macro.elementary.get_transactionless_clean_elementary_test_tables_queries": { + "name": "get_transactionless_clean_elementary_test_tables_queries", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "original_file_path": "macros/edr/tests/test_utils/clean_elementary_test_tables.sql", + "unique_id": "macro.elementary.get_transactionless_clean_elementary_test_tables_queries", + "macro_sql": "{% macro get_transactionless_clean_elementary_test_tables_queries(test_table_relations) %}\n {% set queries = [] %}\n {% for test_relation in test_table_relations %}\n {% do queries.append(\"DROP TABLE IF EXISTS {}\".format(test_relation)) %}\n {% endfor %}\n {% do return(queries) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.729394, + "supported_languages": null + }, + "macro.elementary.run_python": { + "name": "run_python", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/run_python.sql", + "original_file_path": "macros/edr/tests/test_utils/run_python.sql", + "unique_id": "macro.elementary.run_python", + "macro_sql": "{% macro run_python(graph_node, code) %}\n {% set macro_stack = context_macro_stack.call_stack %}\n {% set macro_stack_copy = macro_stack.copy() %}\n {% do macro_stack.clear() %}\n {% do macro_stack.extend([[\"materialization\"], \"macro.dbt.statement\"]) %}\n {% do submit_python_job(graph_node, code) %}\n {% do macro_stack.clear() %}\n {% do macro_stack.extend(macro_stack_copy) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.729971, + "supported_languages": null + }, + "macro.elementary.get_elementary_test_table_name": { + "name": "get_elementary_test_table_name", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_elementary_test_table_name.sql", + "original_file_path": "macros/edr/tests/test_utils/get_elementary_test_table_name.sql", + "unique_id": "macro.elementary.get_elementary_test_table_name", + "macro_sql": "{% macro get_elementary_test_table_name() %}\n {% set test_node = model %}\n {% set test_hash = test_node.unique_id.split(\".\")[-1] %}\n {% set test_name = test_node.name %}\n {% do return(\"test_{}_{}\".format(test_hash, test_name)) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.730381, + "supported_languages": null + }, + "macro.elementary.get_elementary_test_table": { + "name": "get_elementary_test_table", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_elementary_test_table.sql", + "original_file_path": "macros/edr/tests/test_utils/get_elementary_test_table.sql", + "unique_id": "macro.elementary.get_elementary_test_table", + "macro_sql": "{% macro get_elementary_test_table(test_name, table_type) %}\n {% if execute %}\n {% set test_entry = elementary.get_cache(\"temp_test_table_relations_map\").setdefault(test_name, {}) %}\n {% do return(test_entry.get(table_type)) %}\n {% endif %}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_cache" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.730818, + "supported_languages": null + }, + "macro.elementary.get_anomaly_query": { + "name": "get_anomaly_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_anomaly_query.sql", + "original_file_path": "macros/edr/tests/test_utils/get_anomaly_query.sql", + "unique_id": "macro.elementary.get_anomaly_query", + "macro_sql": "{%- macro get_anomaly_query(flattened_test=none) -%}\n {%- set query -%}\n select * from ({{ elementary.get_read_anomaly_scores_query(flattened_test) }}) results\n where is_anomalous = true\n {%- endset -%}\n {{- return(query) -}}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.get_read_anomaly_scores_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.735167, + "supported_languages": null + }, + "macro.elementary.get_read_anomaly_scores_query": { + "name": "get_read_anomaly_scores_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_anomaly_query.sql", + "original_file_path": "macros/edr/tests/test_utils/get_anomaly_query.sql", + "unique_id": "macro.elementary.get_read_anomaly_scores_query", + "macro_sql": "{% macro get_read_anomaly_scores_query(flattened_test=none) %}\n {% if not flattened_test %}\n {% set flattened_test = elementary.flatten_test(model) %}\n {% endif %}\n {%- set test_unique_id = flattened_test.unique_id %}\n {%- set test_configuration = elementary.get_cache(test_unique_id) %}\n {%- if not test_configuration %}\n {{ exceptions.raise_compiler_error(\"Failed to load configuration dict from cache for test `{}`\".format(test_unique_id)) }}\n {%- endif %}\n {%- set backfill_period = \"'-\" ~ test_configuration.backfill_days ~ \"'\" %}\n\n {%- set anomaly_query -%}\n with anomaly_scores as (\n select\n id,\n metric_id,\n test_execution_id,\n test_unique_id,\n detected_at,\n full_table_name,\n column_name,\n metric_name,\n anomaly_score,\n anomaly_score_threshold,\n anomalous_value,\n bucket_start,\n bucket_end,\n bucket_seasonality,\n metric_value,\n min_metric_value,\n max_metric_value,\n training_avg,\n training_stddev,\n training_set_size,\n training_start,\n training_end,\n dimension,\n dimension_value,\n {{ elementary.anomaly_detection_description() }},\n max(bucket_end) over (partition by test_execution_id) as max_bucket_end\n from {{ elementary.get_elementary_test_table(elementary.get_elementary_test_table_name(), 'anomaly_scores') }}\n ),\n anomaly_scores_with_is_anomalous as (\n select\n *,\ncase when\n anomaly_score is not null and\n (\n {{ elementary.fail_on_zero(test_configuration.fail_on_zero) }} or\n (\n {{ elementary.is_score_anomalous_condition(test_configuration.anomaly_sensitivity, test_configuration.anomaly_direction) }} and\n {{ elementary.avg_percent_anomalous_condition(\n test_configuration.ignore_small_changes.spike_failure_percent_threshold,\n test_configuration.ignore_small_changes.drop_failure_percent_threshold,\n test_configuration.anomaly_direction\n ) \n }}\n )\n ) and\n bucket_end >= {{ elementary.edr_timeadd('day', backfill_period, 'max_bucket_end') }}\n then TRUE else FALSE end as is_anomalous\n from anomaly_scores\n )\n\n select\n metric_value as value,\n training_avg as average,\n {# when there is an anomaly we would want to use the last value of the metric (lag), otherwise visually the expectations would look out of bounds #}\n case\n when is_anomalous = TRUE and '{{ test_configuration.anomaly_direction }}' = 'spike' then\n lag(metric_value) over (partition by full_table_name, column_name, metric_name, dimension, dimension_value, bucket_seasonality order by bucket_end)\n when is_anomalous = TRUE and '{{ test_configuration.anomaly_direction }}' != 'spike' then\n lag(min_metric_value) over (partition by full_table_name, column_name, metric_name, dimension, dimension_value, bucket_seasonality order by bucket_end)\n when '{{ test_configuration.anomaly_direction }}' = 'spike' then metric_value\n else min_metric_value end as min_value,\n case\n when is_anomalous = TRUE and '{{ test_configuration.anomaly_direction }}' = 'drop' then\n lag(metric_value) over (partition by full_table_name, column_name, metric_name, dimension, dimension_value, bucket_seasonality order by bucket_end)\n when is_anomalous = TRUE and '{{ test_configuration.anomaly_direction }}' != 'drop' then\n lag(max_metric_value) over (partition by full_table_name, column_name, metric_name, dimension, dimension_value, bucket_seasonality order by bucket_end)\n when '{{ test_configuration.anomaly_direction }}' = 'drop' then metric_value\n else max_metric_value end as max_value,\n bucket_start as start_time,\n bucket_end as end_time,\n *\n from anomaly_scores_with_is_anomalous\n order by bucket_end, dimension_value\n {%- endset -%}\n {{- return(anomaly_query) -}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.flatten_test", + "macro.elementary.get_cache", + "macro.elementary.anomaly_detection_description", + "macro.elementary.get_elementary_test_table", + "macro.elementary.get_elementary_test_table_name", + "macro.elementary.fail_on_zero", + "macro.elementary.is_score_anomalous_condition", + "macro.elementary.avg_percent_anomalous_condition", + "macro.elementary.edr_timeadd" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7364538, + "supported_languages": null + }, + "macro.elementary.set_directional_anomaly": { + "name": "set_directional_anomaly", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_anomaly_query.sql", + "original_file_path": "macros/edr/tests/test_utils/get_anomaly_query.sql", + "unique_id": "macro.elementary.set_directional_anomaly", + "macro_sql": "\n\n\n{%- macro set_directional_anomaly(anomaly_direction, anomaly_score, sensitivity) -%}\n {% if anomaly_direction | lower == 'spike' %}\n anomaly_score > {{ sensitivity }}\n {% elif anomaly_direction | lower == 'drop' %}\n anomaly_score < {{ sensitivity * -1 }}\n {% else %}\n abs(anomaly_score) > {{ sensitivity }}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.736786, + "supported_languages": null + }, + "macro.elementary.is_score_anomalous_condition": { + "name": "is_score_anomalous_condition", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_anomaly_query.sql", + "original_file_path": "macros/edr/tests/test_utils/get_anomaly_query.sql", + "unique_id": "macro.elementary.is_score_anomalous_condition", + "macro_sql": "\n\n{%- macro is_score_anomalous_condition(sensitivity, anomaly_direction) -%}\n {%- set spikes_only_metrics = ['freshness', 'event_freshness'] -%}\n case when metric_name IN {{ elementary.strings_list_to_tuple(spikes_only_metrics) }} then\n anomaly_score > {{ sensitivity }}\n else\n {{ elementary.set_directional_anomaly(anomaly_direction, anomaly_score, sensitivity) }}\n end\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.strings_list_to_tuple", + "macro.elementary.set_directional_anomaly" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.737088, + "supported_languages": null + }, + "macro.elementary.avg_percent_anomalous_condition": { + "name": "avg_percent_anomalous_condition", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_anomaly_query.sql", + "original_file_path": "macros/edr/tests/test_utils/get_anomaly_query.sql", + "unique_id": "macro.elementary.avg_percent_anomalous_condition", + "macro_sql": "{%- macro avg_percent_anomalous_condition(spike_failure_percent_threshold, drop_failure_percent_threshold, anomaly_direction) -%}\n {% set spike_filter %}\n (metric_value > ((1 + {{ spike_failure_percent_threshold }}/100.0) * training_avg))\n {% endset %}\n {% set drop_filter %}\n (metric_value < ((1 - {{ drop_failure_percent_threshold }}/100.0) * training_avg))\n {% endset %}\n \n {% if spike_failure_percent_threshold and drop_failure_percent_threshold and (anomaly_direction | lower) == 'both' %}\n {{ spike_filter }} or {{ drop_filter }}\n {% else %}\n {% if spike_failure_percent_threshold and anomaly_direction | lower in ['spike', 'both'] %}\n {{ spike_filter }}\n {% else %}\n (1 = 1)\n {% endif %}\n\n and\n\n {% if drop_failure_percent_threshold and anomaly_direction | lower in ['drop', 'both'] %}\n {{ drop_filter }}\n {% else %}\n (1 = 1)\n {% endif %}\n {% endif %}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.737757, + "supported_languages": null + }, + "macro.elementary.fail_on_zero": { + "name": "fail_on_zero", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_anomaly_query.sql", + "original_file_path": "macros/edr/tests/test_utils/get_anomaly_query.sql", + "unique_id": "macro.elementary.fail_on_zero", + "macro_sql": "{% macro fail_on_zero(fail_on_zero) %}\n (\n metric_value = 0 and \n {% if fail_on_zero %}\n 1 = 1\n {% else %}\n 1 = 2\n {% endif %}\n )\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.737901, + "supported_languages": null + }, + "macro.elementary.backfill_result_rows": { + "name": "backfill_result_rows", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/backfill_result_rows.sql", + "original_file_path": "macros/edr/tests/test_utils/backfill_result_rows.sql", + "unique_id": "macro.elementary.backfill_result_rows", + "macro_sql": "{% macro backfill_result_rows() %}\n -- depends_on: {{ ref('elementary_test_results') }}\n {% if is_incremental() %}\n {% do return('') %}\n {% endif %}\n\n {% set elementary_test_results_relation = ref(\"elementary_test_results\") %}\n {% set result_row_exists = elementary.get_column_in_relation(elementary_test_results_relation, \"result_rows\") is not none %}\n {% if not result_row_exists %}\n {% do return('') %}\n {% endif %}\n\n {% set test_result_rows_rows = [] %}\n {% set backfill_query %}\n select\n id,\n detected_at,\n result_rows\n from {{ elementary_test_results_relation }}\n where {{ elementary.edr_datediff(elementary.edr_cast_as_timestamp('detected_at'), elementary.edr_current_timestamp(), 'day') }} < {{ elementary.get_config_var(\"days_back\") }}\n and result_rows is not null\n {% endset %}\n {% set test_results_with_result_rows = elementary.run_query(backfill_query) %}\n {% for elementary_test_results_row in test_results_with_result_rows %}\n {% set result_rows = fromjson(elementary_test_results_row.result_rows) %}\n {% for result_row in result_rows %}\n {% do test_result_rows_rows.append({\n \"elementary_test_results_id\": elementary_test_results_row.id,\n \"detected_at\": elementary_test_results_row.detected_at.strftime(elementary.get_time_format()),\n \"result_row\": result_row\n }) %}\n {% endfor %}\n {% endfor %}\n {% do elementary.insert_rows(this, test_result_rows_rows) %}\n {% do return('') %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.is_incremental", + "macro.elementary.get_column_in_relation", + "macro.elementary.edr_datediff", + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.edr_current_timestamp", + "macro.elementary.get_config_var", + "macro.elementary.run_query", + "macro.elementary.get_time_format", + "macro.elementary.insert_rows" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.739975, + "supported_languages": null + }, + "macro.elementary.snowflake__compile_py_code": { + "name": "snowflake__compile_py_code", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/compile_py_code.sql", + "original_file_path": "macros/edr/tests/test_utils/compile_py_code.sql", + "unique_id": "macro.elementary.snowflake__compile_py_code", + "macro_sql": "{% macro snowflake__compile_py_code(model, py_code, output_table, where_expression, code_type) %}\nimport pandas\nimport snowflake.snowpark\n\n{{ py_code }}\n\ndef write_output_table(session, output_df, target_relation):\n output_df.write.mode('overwrite').save_as_table(target_relation, table_type='temporary')\n\ndef get_fail_count(test_output):\n if isinstance(test_output, int):\n return test_output\n if isinstance(test_output, bool):\n return 0 if test_output else 1\n if isinstance(test_output, snowflake.snowpark.DataFrame):\n return test_output.count()\n if isinstance(test_output, pandas.DataFrame):\n return len(test_output)\n raise ValueError('Received invalid return value, expected either DataFrame or a boolean.')\n\ndef get_output_df(model_df, code_type, ref, session):\n if code_type == \"test\":\n test_output = test(model_df, ref, session)\n fail_count = get_fail_count(test_output)\n return session.createDataFrame([[fail_count]], ['fail_count'])\n elif code_type == \"function\":\n res = func(model_df, ref, session)\n return session.createDataFrame([[res]], ['result'])\n\n raise Exception(\"Unsupported code type: {}\".format(code_type))\n\ndef main(session):\n ref = session.table\n model_df = ref('{{ model }}')\n\n {% if where_expression %}\n model_df = model_df.filter(\"\"\"{{ where_expression }}\"\"\")\n {% endif %}\n\n output_df = get_output_df(model_df, '{{ code_type }}', ref, session)\n write_output_table(session, output_df, '{{ output_table }}')\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.741311, + "supported_languages": null + }, + "macro.elementary.bigquery__compile_py_code": { + "name": "bigquery__compile_py_code", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/compile_py_code.sql", + "original_file_path": "macros/edr/tests/test_utils/compile_py_code.sql", + "unique_id": "macro.elementary.bigquery__compile_py_code", + "macro_sql": "{% macro bigquery__compile_py_code(model, py_code, output_table, where_expression, code_type) %}\nimport pandas\nimport pyspark.sql\n\n{{ py_code }}\n\ndef write_output_table(session, output_df, target_relation):\n output_df.write.mode('overwrite').format('bigquery').option('writeMethod', 'direct').option('writeDisposition', 'WRITE_TRUNCATE').save(target_relation)\n\ndef get_fail_count(test_output):\n if isinstance(test_output, int):\n return test_output\n if isinstance(test_output, bool):\n return 0 if test_output else 1\n if isinstance(test_output, pyspark.sql.DataFrame):\n return test_output.count()\n if isinstance(test_output, pandas.DataFrame):\n return len(test_output)\n raise ValueError('Received invalid return value, expected either DataFrame or a boolean.')\n\ndef get_session():\n session = pyspark.sql.SparkSession.builder.appName('Elementary').getOrCreate()\n session.conf.set('viewsEnabled', 'true')\n session.conf.set('temporaryGcsBucket', '{{ target.gcs_bucket }}')\n return session\n\ndef get_output_df(model_df, code_type, ref, session):\n if code_type == \"test\":\n test_output = test(model_df, ref, session)\n fail_count = get_fail_count(test_output)\n return session.createDataFrame([[fail_count]], ['fail_count'])\n elif code_type == \"function\":\n res = func(model_df, ref, session)\n return session.createDataFrame([[res]], ['result'])\n\n raise Exception(\"Unsupported code type: {}\".format(code_type))\n\ndef main():\n session = get_session()\n ref = session.read.format('bigquery').load\n model_df = ref('{{ model }}')\n\n {% if where_expression %}\n model_df = model_df.filter(\"\"\"{{ where_expression }}\"\"\")\n {% endif %}\n\n output_df = get_output_df(model_df, '{{ code_type }}', ref, session)\n write_output_table(session, output_df, '{{ output_table }}')\n\nmain()\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.741687, + "supported_languages": null + }, + "macro.elementary.default__compile_py_code": { + "name": "default__compile_py_code", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/compile_py_code.sql", + "original_file_path": "macros/edr/tests/test_utils/compile_py_code.sql", + "unique_id": "macro.elementary.default__compile_py_code", + "macro_sql": "{% macro default__compile_py_code(model, py_code, output_table, where_expression, code_type) %}\n {{ exceptions.raise_compiler_error(\"Elementary's Python tests are not yet supported on %s.\" % target.type) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.741875, + "supported_languages": null + }, + "macro.elementary.get_elementary_tests_schema": { + "name": "get_elementary_tests_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_utils/get_elementary_tests_schema.sql", + "original_file_path": "macros/edr/tests/test_utils/get_elementary_tests_schema.sql", + "unique_id": "macro.elementary.get_elementary_tests_schema", + "macro_sql": "{% macro get_elementary_tests_schema(elementary_database, elementary_schema) %}\n {% set LEGACY_TESTS_SCHEMA_SUFFIX = \"__tests\" %}\n\n {% set cached_tests_schema_name = elementary.get_cache(\"tests_schema_name\") %}\n {% if cached_tests_schema_name is not none %}\n {{ return(cached_tests_schema_name) }}\n {% endif %}\n\n {% set tests_schema_suffix = elementary.get_config_var('tests_schema_name') %}\n {% set tests_schema_name = elementary_schema ~ tests_schema_suffix %}\n\n {# Backward compatibility - if a tests schema suffix is not defined, but the legacy tests schema exists in the DB,\n then use it #}\n {% if not tests_schema_suffix %}\n {% set legacy_tests_schema_name = elementary_schema ~ LEGACY_TESTS_SCHEMA_SUFFIX %}\n {% if adapter.check_schema_exists(elementary_database, legacy_tests_schema_name) %}\n {% set tests_schema_name = legacy_tests_schema_name %}\n {% endif %}\n {% endif %}\n\n {% do elementary.set_cache(\"tests_schema_name\", tests_schema_name) %}\n\n {{ return(tests_schema_name) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_cache", + "macro.elementary.get_config_var", + "macro.elementary.set_cache" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.742857, + "supported_languages": null + }, + "macro.elementary.union_metrics_query": { + "name": "union_metrics_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/on_run_end/union_metrics_query.sql", + "original_file_path": "macros/edr/tests/on_run_end/union_metrics_query.sql", + "unique_id": "macro.elementary.union_metrics_query", + "macro_sql": "{% macro union_metrics_query(temp_metrics_tables) %}\n {%- if temp_metrics_tables | length > 0 %}\n {%- set union_temp_query -%}\n with union_temps_metrics as (\n {%- for temp_table in temp_metrics_tables -%}\n select * from {{ temp_table }}\n {%- if not loop.last %} union all {% endif %}\n {%- endfor %}\n ),\n metrics_with_duplicates as (\n select *,\n row_number() over (partition by id order by updated_at desc) as row_number\n from union_temps_metrics\n )\n select\n id,\n full_table_name,\n column_name,\n metric_name,\n metric_value,\n source_value,\n bucket_start,\n bucket_end,\n bucket_duration_hours,\n updated_at,\n dimension,\n dimension_value,\n metric_properties\n from metrics_with_duplicates\n where row_number = 1\n {%- endset %}\n {{ return(union_temp_query) }}\n {%- endif %}\n {{ return(none) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.743813, + "supported_languages": null + }, + "macro.elementary.insert_metrics": { + "name": "insert_metrics", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/on_run_end/insert_metrics.sql", + "original_file_path": "macros/edr/tests/on_run_end/insert_metrics.sql", + "unique_id": "macro.elementary.insert_metrics", + "macro_sql": "{% macro insert_metrics() %}\n {% set metrics = elementary.get_cache(\"tables\").get(\"metrics\").get(\"rows\") %}\n {%- set target_relation = elementary.get_elementary_relation('data_monitoring_metrics') -%}\n {% if not target_relation %}\n {% do exceptions.warn(\"Couldn't find Elementary's models in `\" ~ elementary.target_database() ~ \".\" ~ target.schema ~ \"`. Please run `dbt run -s elementary --target \" ~ target.name ~ \"`.\") %}\n {% do return(none) %}\n {% endif %}\n\n {{ elementary.file_log(\"Inserting {} metrics into {}.\".format(metrics | length, target_relation)) }}\n {% do elementary.insert_rows(target_relation, metrics, should_commit=true) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_cache", + "macro.elementary.get_elementary_relation", + "macro.elementary.target_database", + "macro.elementary.file_log", + "macro.elementary.insert_rows" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7446558, + "supported_languages": null + }, + "macro.elementary.union_columns_snapshot_query": { + "name": "union_columns_snapshot_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/on_run_end/union_columns_snapshot_query.sql", + "original_file_path": "macros/edr/tests/on_run_end/union_columns_snapshot_query.sql", + "unique_id": "macro.elementary.union_columns_snapshot_query", + "macro_sql": "{% macro union_columns_snapshot_query(temp_columns_snapshot_tables) %}\n {%- if temp_columns_snapshot_tables | length > 0 %}\n {%- set union_temp_query -%}\n with union_temp_columns_snapshot as (\n {%- for temp_table in temp_columns_snapshot_tables -%}\n select * from {{ temp_table }}\n {%- if not loop.last %} union all {% endif %}\n {%- endfor %}\n ),\n columns_snapshot_with_duplicates as (\n select *,\n row_number() over (partition by column_state_id order by detected_at desc) as row_number\n from union_temp_columns_snapshot\n )\n select\n column_state_id,\n full_column_name,\n full_table_name,\n column_name,\n data_type,\n is_new,\n detected_at\n from columns_snapshot_with_duplicates\n where row_number = 1\n {%- endset %}\n {{ return(union_temp_query) }}\n {%- endif %}\n {{ return(none) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.745527, + "supported_languages": null + }, + "macro.elementary.handle_tests_results": { + "name": "handle_tests_results", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/on_run_end/handle_tests_results.sql", + "original_file_path": "macros/edr/tests/on_run_end/handle_tests_results.sql", + "unique_id": "macro.elementary.handle_tests_results", + "macro_sql": "{% macro handle_tests_results() %}\n {{ elementary.file_log(\"Handling test results.\") }}\n {% set cached_elementary_test_results = elementary.get_cache(\"elementary_test_results\") %}\n {% set cached_elementary_test_failed_row_counts = elementary.get_cache(\"elementary_test_failed_row_counts\") %}\n {% set store_result_rows_in_own_table = elementary.get_config_var(\"store_result_rows_in_own_table\") %}\n {% set elementary_test_results = elementary.get_result_enriched_elementary_test_results(cached_elementary_test_results, cached_elementary_test_failed_row_counts, render_result_rows=(not store_result_rows_in_own_table)) %}\n {% if store_result_rows_in_own_table %}\n {% set test_result_rows = elementary.pop_test_result_rows(elementary_test_results) %}\n {% endif %}\n {% set tables_cache = elementary.get_cache(\"tables\") %}\n {% set test_metrics_tables = tables_cache.get(\"metrics\").get(\"relations\") %}\n {% set test_columns_snapshot_tables = tables_cache.get(\"schema_snapshots\") %}\n {% set database_name, schema_name = elementary.get_package_database_and_schema('elementary') %}\n {% do elementary.insert_data_monitoring_metrics(database_name, schema_name, test_metrics_tables) %}\n {% do elementary.insert_schema_columns_snapshot(database_name, schema_name, test_columns_snapshot_tables) %}\n {% if elementary.get_config_var(\"clean_elementary_temp_tables\") %}\n {% do elementary.clean_elementary_test_tables() %}\n {% endif %}\n {% if test_result_rows %}\n {% set test_result_rows_relation = elementary.get_elementary_relation('test_result_rows') %}\n {% do elementary.insert_rows(test_result_rows_relation, test_result_rows, should_commit=True) %}\n {% endif %}\n {% if elementary_test_results %}\n {% set elementary_test_results_relation = elementary.get_elementary_relation('elementary_test_results') %}\n {% do elementary.insert_rows(elementary_test_results_relation, elementary_test_results, should_commit=True) %}\n {% endif %}\n {% do elementary.file_log(\"Handled test results successfully.\") %}\n {% do return('') %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.file_log", + "macro.elementary.get_cache", + "macro.elementary.get_config_var", + "macro.elementary.get_result_enriched_elementary_test_results", + "macro.elementary.pop_test_result_rows", + "macro.elementary.get_package_database_and_schema", + "macro.elementary.insert_data_monitoring_metrics", + "macro.elementary.insert_schema_columns_snapshot", + "macro.elementary.clean_elementary_test_tables", + "macro.elementary.get_elementary_relation", + "macro.elementary.insert_rows" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.753529, + "supported_languages": null + }, + "macro.elementary.get_result_enriched_elementary_test_results": { + "name": "get_result_enriched_elementary_test_results", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/on_run_end/handle_tests_results.sql", + "original_file_path": "macros/edr/tests/on_run_end/handle_tests_results.sql", + "unique_id": "macro.elementary.get_result_enriched_elementary_test_results", + "macro_sql": "{% macro get_result_enriched_elementary_test_results(cached_elementary_test_results, cached_elementary_test_failed_row_counts, render_result_rows=false) %}\n {% set elementary_test_results = [] %}\n\n {% for result in results | selectattr('node.resource_type', '==', 'test') %}\n {% set result = result.to_dict() %}\n {% set elementary_test_results_rows = cached_elementary_test_results.get(result.node.unique_id) %}\n {% set elementary_test_failed_row_count = cached_elementary_test_failed_row_counts.get(result.node.unique_id) %}\n\n {# Materializing the test failed and therefore was not added to the cache. #}\n {% if not elementary_test_results_rows %}\n {% set flattened_test = elementary.flatten_test(result.node) %}\n {% set elementary_test_results_rows = [elementary.get_dbt_test_result_row(flattened_test)] %}\n {% endif %}\n\n {% for elementary_test_results_row in elementary_test_results_rows %}\n {% set failures = elementary_test_results_row.get(\"failures\", result.failures) %}\n {% set status = \"pass\" if failures == 0 else result.status %}\n {% do elementary_test_results_row.update({'status': status, 'failures': failures, 'invocation_id': invocation_id, \n 'failed_row_count': elementary_test_failed_row_count}) %}\n {% do elementary_test_results_row.setdefault('test_results_description', result.message) %}\n {% if render_result_rows %}\n {% do elementary_test_results_row.update({\"result_rows\": elementary.render_result_rows(elementary_test_results_row.result_rows)}) %}\n {% endif %}\n {% do elementary_test_results.append(elementary_test_results_row) %}\n {% endfor %}\n {% endfor %}\n\n {% do return(elementary_test_results) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.flatten_test", + "macro.elementary.get_dbt_test_result_row", + "macro.elementary.render_result_rows" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.755, + "supported_languages": null + }, + "macro.elementary.insert_data_monitoring_metrics": { + "name": "insert_data_monitoring_metrics", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/on_run_end/handle_tests_results.sql", + "original_file_path": "macros/edr/tests/on_run_end/handle_tests_results.sql", + "unique_id": "macro.elementary.insert_data_monitoring_metrics", + "macro_sql": "{% macro insert_data_monitoring_metrics(database_name, schema_name, test_metrics_tables) %}\n {%- if not test_metrics_tables %}\n {% do return(none) %}\n {% endif %}\n\n {%- set test_tables_union_query = elementary.union_metrics_query(test_metrics_tables) -%}\n {% if not test_tables_union_query %}\n {% do return(none) %}\n {% endif %}\n\n {%- set target_relation = elementary.get_elementary_relation('data_monitoring_metrics') -%}\n {% if not target_relation %}\n {% do exceptions.raise_compiler_error(\"Couldn't find Elementary's models in `\" ~ elementary.target_database() ~ \".\" ~ target.schema ~ \"`. Please run `dbt run -s elementary --target \" ~ target.name ~ \"`.\") %}\n {% endif %}\n\n {%- set temp_relation = elementary.make_temp_view_relation(target_relation) -%}\n {% set insert_query %}\n INSERT INTO {{ target_relation }} (\n id,\n full_table_name,\n column_name,\n metric_name,\n metric_value,\n source_value,\n bucket_start,\n bucket_end,\n bucket_duration_hours,\n updated_at,\n dimension,\n dimension_value,\n metric_properties,\n created_at\n )\n SELECT\n id,\n full_table_name,\n column_name,\n metric_name,\n metric_value,\n source_value,\n bucket_start,\n bucket_end,\n bucket_duration_hours,\n updated_at,\n dimension,\n dimension_value,\n metric_properties,\n {{ elementary.edr_current_timestamp() }} as created_at\n FROM {{ temp_relation }}\n {% endset %}\n\n {{ elementary.file_log(\"Inserting metrics into {}.\".format(target_relation)) }}\n {%- do elementary.run_query(dbt.create_table_as(True, temp_relation, test_tables_union_query)) %}\n {% do elementary.run_query(insert_query) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.union_metrics_query", + "macro.elementary.get_elementary_relation", + "macro.elementary.target_database", + "macro.elementary.make_temp_view_relation", + "macro.elementary.edr_current_timestamp", + "macro.elementary.file_log", + "macro.elementary.run_query", + "macro.dbt.create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.756059, + "supported_languages": null + }, + "macro.elementary.insert_schema_columns_snapshot": { + "name": "insert_schema_columns_snapshot", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/on_run_end/handle_tests_results.sql", + "original_file_path": "macros/edr/tests/on_run_end/handle_tests_results.sql", + "unique_id": "macro.elementary.insert_schema_columns_snapshot", + "macro_sql": "{% macro insert_schema_columns_snapshot(database_name, schema_name, test_columns_snapshot_tables) %}\n {%- if not test_columns_snapshot_tables %}\n {% do return(none) %}\n {% endif %}\n\n {%- set test_tables_union_query = elementary.union_columns_snapshot_query(test_columns_snapshot_tables) -%}\n {% if not test_tables_union_query %}\n {% do return(none) %}\n {% endif %}\n\n {%- set target_relation = elementary.get_elementary_relation('schema_columns_snapshot') -%}\n {% if not target_relation %}\n {% do exceptions.raise_compiler_error(\"Couldn't find Elementary's models in `\" ~ elementary.target_database() ~ \".\" ~ target.schema ~ \"`. Please run `dbt run -s elementary --target \" ~ target.name ~ \"`.\") %}\n {% endif %}\n\n {%- set temp_relation = elementary.make_temp_view_relation(target_relation) -%}\n {% set insert_query %}\n INSERT INTO {{ target_relation }} (\n column_state_id,\n full_column_name,\n full_table_name,\n column_name,\n data_type,\n is_new,\n detected_at,\n created_at\n )\n SELECT\n column_state_id,\n full_column_name,\n full_table_name,\n column_name,\n data_type,\n is_new,\n detected_at,\n {{ elementary.edr_current_timestamp() }} as created_at\n FROM {{ temp_relation }}\n {% endset %}\n\n {{ elementary.file_log(\"Inserting schema columns snapshot into {}.\".format(target_relation)) }}\n {%- do elementary.run_query(dbt.create_table_as(True, temp_relation, test_tables_union_query)) %}\n {% do elementary.run_query(insert_query) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.union_columns_snapshot_query", + "macro.elementary.get_elementary_relation", + "macro.elementary.target_database", + "macro.elementary.make_temp_view_relation", + "macro.elementary.edr_current_timestamp", + "macro.elementary.file_log", + "macro.elementary.run_query", + "macro.dbt.create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.757091, + "supported_languages": null + }, + "macro.elementary.pop_test_result_rows": { + "name": "pop_test_result_rows", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/on_run_end/handle_tests_results.sql", + "original_file_path": "macros/edr/tests/on_run_end/handle_tests_results.sql", + "unique_id": "macro.elementary.pop_test_result_rows", + "macro_sql": "{% macro pop_test_result_rows(elementary_test_results) %}\n {% set result_rows = [] %}\n {% for test_result in elementary_test_results %}\n {% for result_row in test_result.pop('result_rows', []) %}\n {% do result_rows.append({\n \"elementary_test_results_id\": test_result.id,\n \"detected_at\": test_result.detected_at,\n \"result_row\": result_row\n }) %}\n {% endfor %}\n {% endfor %}\n {% do return(result_rows) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.757579, + "supported_languages": null + }, + "macro.elementary.render_result_rows": { + "name": "render_result_rows", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/on_run_end/handle_tests_results.sql", + "original_file_path": "macros/edr/tests/on_run_end/handle_tests_results.sql", + "unique_id": "macro.elementary.render_result_rows", + "macro_sql": "{% macro render_result_rows(test_result_rows) %}\n {% set column_size = elementary.get_column_size() %}\n {% if not column_size or (tojson(test_result_rows) | length) < column_size %}\n {% do return(test_result_rows) %}\n {% endif %}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_column_size" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.757932, + "supported_languages": null + }, + "macro.elementary.init_elementary_graph": { + "name": "init_elementary_graph", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/on_run_start/init_elementary_graph.sql", + "original_file_path": "macros/edr/tests/on_run_start/init_elementary_graph.sql", + "unique_id": "macro.elementary.init_elementary_graph", + "macro_sql": "{% macro init_elementary_graph() %}\n {% do graph.setdefault(\"elementary\", {\n \"elementary_test_results\": {},\n \"elementary_test_failed_row_counts\": {},\n \"tests_schema_name\": none,\n \"tables\": {\n \"metrics\": {\n \"relations\": [],\n \"rows\": []\n },\n \"schema_snapshots\": []\n },\n \"temp_test_table_relations_map\": {},\n }) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.758425, + "supported_languages": null + }, + "macro.elementary.recommend_dbt_core_artifacts_upgrade": { + "name": "recommend_dbt_core_artifacts_upgrade", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/on_run_start/recommend_dbt_core_artifacts_upgrade.sql", + "original_file_path": "macros/edr/tests/on_run_start/recommend_dbt_core_artifacts_upgrade.sql", + "unique_id": "macro.elementary.recommend_dbt_core_artifacts_upgrade", + "macro_sql": "{% macro recommend_dbt_core_artifacts_upgrade() %}\n {% if elementary.get_config_var(\"mute_dbt_upgrade_recommendation\") %}\n {% do return(none) %}\n {% endif %}\n\n {% set major, minor, revision = dbt_version.split(\".\") %}\n {% set major = major | int %}\n {% set minor = minor | int %}\n {% if major < 1 or major == 1 and minor < 4 %}\n {%- set msg %}\nYou are using dbt version {{ dbt_version }}.\nElementary introduced major performance improvements for dbt version 1.4.0 or later.\nMore information on the performance impact can be found here: https://docs.elementary-data.com/dbt/on-run-end_hooks#performance-impact-of-on-run-end-hooks\nThis message can be muted by setting the 'mute_dbt_upgrade_recommendation' var to true.\n {% endset %}\n {% do log(msg, info=true) %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_config_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7593422, + "supported_languages": null + }, + "macro.elementary.create_elementary_tests_schema": { + "name": "create_elementary_tests_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/on_run_start/create_elementary_tests_schema.sql", + "original_file_path": "macros/edr/tests/on_run_start/create_elementary_tests_schema.sql", + "unique_id": "macro.elementary.create_elementary_tests_schema", + "macro_sql": "{% macro create_elementary_tests_schema() %}\n {% if execute and elementary.is_test_command() %}\n {% set database_name, schema_name = elementary.get_package_database_and_schema('elementary') %}\n {% set tests_schema_name = elementary.get_elementary_tests_schema(database_name, schema_name) %}\n {%- if tests_schema_name != schema_name and not adapter.check_schema_exists(database_name, tests_schema_name) %}\n {{ elementary.edr_log(\"Creating Elementary's tests schema.\") }}\n {% set schema_relation = api.Relation.create(database=database_name, schema=tests_schema_name).without_identifier() %}\n {%- do dbt.create_schema(schema_relation) %}\n {% do adapter.commit() %}\n {%- endif %}\n {% endif %}\n {{ return('') }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.is_test_command", + "macro.elementary.get_package_database_and_schema", + "macro.elementary.get_elementary_tests_schema", + "macro.elementary.edr_log", + "macro.dbt.create_schema" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.760271, + "supported_languages": null + }, + "macro.elementary.get_no_detection_delay": { + "name": "get_no_detection_delay", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_detection_delay.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_detection_delay.sql", + "unique_id": "macro.elementary.get_no_detection_delay", + "macro_sql": "{% macro get_no_detection_delay() %}\n {% do return({\"period\": \"hour\", \"count\": 0}) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.763407, + "supported_languages": null + }, + "macro.elementary.get_default_detection_delay": { + "name": "get_default_detection_delay", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_detection_delay.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_detection_delay.sql", + "unique_id": "macro.elementary.get_default_detection_delay", + "macro_sql": "{% macro get_default_detection_delay() %}\n {% do return(elementary.get_no_detection_delay()) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_no_detection_delay" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.763545, + "supported_languages": null + }, + "macro.elementary.get_detection_delay_supported_periods": { + "name": "get_detection_delay_supported_periods", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_detection_delay.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_detection_delay.sql", + "unique_id": "macro.elementary.get_detection_delay_supported_periods", + "macro_sql": "{% macro get_detection_delay_supported_periods() %}\n {% do return([\"hour\", \"day\", \"week\"]) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.763707, + "supported_languages": null + }, + "macro.elementary.get_detection_delay": { + "name": "get_detection_delay", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_detection_delay.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_detection_delay.sql", + "unique_id": "macro.elementary.get_detection_delay", + "macro_sql": "{% macro get_detection_delay(detection_delay, model_graph_node) %}\n {%- set configured_detection_delay = elementary.get_test_argument('detection_delay', detection_delay, model_graph_node) %}\n {%- do elementary.validate_detection_delay(configured_detection_delay) %}\n {%- set default_detection_delay = elementary.get_default_detection_delay() %}\n\n {%- if not configured_detection_delay %}\n {{ return(default_detection_delay) }}\n {%- else %}\n {%- set detection_delay = default_detection_delay.copy() %}\n {%- do detection_delay.update(configured_detection_delay) %}\n {{ return(detection_delay) }}\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_test_argument", + "macro.elementary.validate_detection_delay", + "macro.elementary.get_default_detection_delay" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7642188, + "supported_languages": null + }, + "macro.elementary.validate_detection_delay": { + "name": "validate_detection_delay", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_detection_delay.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_detection_delay.sql", + "unique_id": "macro.elementary.validate_detection_delay", + "macro_sql": "{% macro validate_detection_delay(detection_delay) %}\n {% if detection_delay %}\n {%- if detection_delay is not mapping %}\n {% do exceptions.raise_compiler_error(\n \"\n Invalid detection_delay format. Expected format:\n\n detection_delay:\n count: int\n period: string\n \") %}\n {%- endif %}\n {%- if detection_delay is mapping %}\n {%- set invalid_keys = [] %}\n {%- set valid_keys = ['period', 'count'] %}\n {%- for key, value in detection_delay.items() %}\n {%- if key not in valid_keys %}\n {%- do invalid_keys.append(key) -%}\n {%- endif %}\n {%- endfor %}\n {%- if invalid_keys | length > 0 %}\n {% do exceptions.raise_compiler_error(\n (\"\n Found invalid keys in detection_delay: {0}.\n Supported keys: {1}.\n Expected format:\n\n detection_delay:\n count: int\n period: string\n \").format(invalid_keys, valid_keys)) %}\n {%- endif %}\n {%- endif %}\n\n {% if detection_delay.count and detection_delay.count is not integer %}\n {% do exceptions.raise_compiler_error(\"detection_delay.count expects valid integer, got: {} (If it's an integer, try to remove quotes)\".format(detection_delay.count)) %}\n {% endif %}\n {% if detection_delay.count < 0 %}\n {% do exceptions.raise_compiler_error(\"detection_delay.count can't be negative, got: {})\".format(detection_delay.count)) %}\n {% endif %}\n {% set supported_periods = elementary.get_detection_delay_supported_periods() %}\n {% if detection_delay.period and detection_delay.period not in supported_periods %}\n {% do exceptions.raise_compiler_error(\"detection_delay.period value should be one of {0}, got: {1}\".format(supported_periods, detection_delay.period)) %}\n {% endif %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_detection_delay_supported_periods" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.765549, + "supported_languages": null + }, + "macro.elementary.get_days_back": { + "name": "get_days_back", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_days_back.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_days_back.sql", + "unique_id": "macro.elementary.get_days_back", + "macro_sql": "{% macro get_days_back(days_back, model_graph_node, seasonality=none) %}\n {% set days_back = elementary.get_test_argument('days_back', days_back, model_graph_node) %}\n {% if seasonality in [\"day_of_week\", \"hour_of_week\"] %}\n {% do return(days_back * 7) %}\n {% endif %}\n {% do return(days_back) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_test_argument" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.766032, + "supported_languages": null + }, + "macro.elementary.get_daily_time_bucket": { + "name": "get_daily_time_bucket", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_time_bucket.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_time_bucket.sql", + "unique_id": "macro.elementary.get_daily_time_bucket", + "macro_sql": "{% macro get_daily_time_bucket() %}\n {% do return({\"period\": \"day\", \"count\": 1}) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.769082, + "supported_languages": null + }, + "macro.elementary.get_default_time_bucket": { + "name": "get_default_time_bucket", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_time_bucket.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_time_bucket.sql", + "unique_id": "macro.elementary.get_default_time_bucket", + "macro_sql": "{% macro get_default_time_bucket() %}\n {% do return(elementary.get_daily_time_bucket()) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_daily_time_bucket" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7692192, + "supported_languages": null + }, + "macro.elementary.get_time_bucket": { + "name": "get_time_bucket", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_time_bucket.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_time_bucket.sql", + "unique_id": "macro.elementary.get_time_bucket", + "macro_sql": "{% macro get_time_bucket(time_bucket, model_graph_node) %}\n {%- set configured_time_bucket = elementary.get_test_argument('time_bucket', time_bucket, model_graph_node) %}\n {%- do elementary.validate_time_bucket(configured_time_bucket) %}\n {%- set default_time_bucket = elementary.get_default_time_bucket() %}\n\n {%- if not configured_time_bucket %}\n {{ return(default_time_bucket) }}\n {%- else %}\n {%- set time_bucket = default_time_bucket.copy() %}\n {%- do time_bucket.update(configured_time_bucket) %}\n {{ return(time_bucket) }}\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_test_argument", + "macro.elementary.validate_time_bucket", + "macro.elementary.get_default_time_bucket" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.769732, + "supported_languages": null + }, + "macro.elementary.validate_time_bucket": { + "name": "validate_time_bucket", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_time_bucket.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_time_bucket.sql", + "unique_id": "macro.elementary.validate_time_bucket", + "macro_sql": "{% macro validate_time_bucket(time_bucket) %}\n {% if time_bucket %}\n {%- if time_bucket is not mapping %}\n {% do exceptions.raise_compiler_error(\n \"\n Invalid time_bucket format. Expected format:\n\n time_bucket:\n count: int\n period: string\n \") %}\n {%- endif %}\n {%- if time_bucket is mapping %}\n {%- set invalid_keys = [] %}\n {%- set valid_keys = ['period', 'count'] %}\n {%- for key, value in time_bucket.items() %}\n {%- if key not in valid_keys %}\n {%- do invalid_keys.append(key) -%}\n {%- endif %}\n {%- endfor %}\n {%- if invalid_keys | length > 0 %}\n {% do exceptions.raise_compiler_error(\n (\"\n Found invalid keys in time_bucket: {0}.\n Supported keys: {1}.\n Expected format:\n\n time_bucket:\n count: int\n period: string\n \").format(invalid_keys, valid_keys)) %}\n {%- endif %}\n {%- endif %}\n\n {% if time_bucket.count and time_bucket.count is not integer %}\n {% do exceptions.raise_compiler_error(\"time_bucket.count expects valid integer, got: {} (If it's an integer, try to remove quotes)\".format(time_bucket.count)) %}\n {% endif %}\n {% if time_bucket.count <= 0 %}\n {% do exceptions.raise_compiler_error(\"time_bucket.count has to be larger than 0, got: {})\".format(time_bucket.count)) %}\n {% endif %}\n {% set supported_periods = adapter.dispatch(\"supported_periods\", \"elementary\")() %}\n {% if time_bucket.period and time_bucket.period not in supported_periods %}\n {% do exceptions.raise_compiler_error(\"time_bucket.period value should be one of {0}, got: {1}\".format(supported_periods, time_bucket.period)) %}\n {% endif %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__supported_periods" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.771172, + "supported_languages": null + }, + "macro.elementary.default__supported_periods": { + "name": "default__supported_periods", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_time_bucket.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_time_bucket.sql", + "unique_id": "macro.elementary.default__supported_periods", + "macro_sql": "{% macro default__supported_periods() %}\n {% do return([\"hour\", \"day\", \"week\", \"month\"]) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7713559, + "supported_languages": null + }, + "macro.elementary.redshift__supported_periods": { + "name": "redshift__supported_periods", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_time_bucket.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_time_bucket.sql", + "unique_id": "macro.elementary.redshift__supported_periods", + "macro_sql": "{% macro redshift__supported_periods() %}\n {% do return([\"hour\", \"day\", \"week\"]) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7715158, + "supported_languages": null + }, + "macro.elementary.get_anomalies_test_configuration": { + "name": "get_anomalies_test_configuration", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_anomalies_test_configuration.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_anomalies_test_configuration.sql", + "unique_id": "macro.elementary.get_anomalies_test_configuration", + "macro_sql": "{% macro get_anomalies_test_configuration(model_relation,\n mandatory_params,\n timestamp_column,\n where_expression,\n anomaly_sensitivity,\n anomaly_direction,\n min_training_set_size,\n time_bucket,\n days_back,\n backfill_days,\n seasonality,\n freshness_column,\n event_timestamp_column,\n dimensions,\n sensitivity,\n ignore_small_changes,\n fail_on_zero,\n detection_delay,\n anomaly_exclude_metrics,\n detection_period,\n training_period) %}\n\n {%- set model_graph_node = elementary.get_model_graph_node(model_relation) %}\n\n {# All anomaly detection tests #}\n {%- set timestamp_column = elementary.get_test_argument('timestamp_column', timestamp_column, model_graph_node) %}\n {%- set where_expression = elementary.get_test_argument('where_expression', where_expression, model_graph_node) %}\n {# We had a names mix in sensitivity/anomaly_sensitivity, this keeps backwards competability #}\n {%- set anomaly_sensitivity = sensitivity if sensitivity else elementary.get_test_argument('anomaly_sensitivity', anomaly_sensitivity, model_graph_node) %}\n {%- set anomaly_direction = elementary.get_anomaly_direction(anomaly_direction, model_graph_node) %}\n {%- set backfill_days = elementary.detection_period_to_backfill_days(detection_period, backfill_days, model_graph_node) -%}\n {%- set fail_on_zero = elementary.get_test_argument('fail_on_zero', fail_on_zero, model_graph_node) %}\n \n\n {# timestamp_column anomaly detection tests #}\n {%- set time_bucket = elementary.get_time_bucket(time_bucket, model_graph_node) %}\n {%- set days_back = elementary.training_period_to_days_back(training_period, days_back, model_graph_node) -%}\n {%- set days_back = elementary.get_days_back(days_back, model_graph_node, seasonality) %}\n {%- set seasonality = elementary.get_seasonality(seasonality, model_graph_node, time_bucket, timestamp_column) %}\n {%- set detection_delay = elementary.get_detection_delay(detection_delay, model_graph_node) %}\n\n {%- set ignore_small_changes = elementary.get_test_argument('ignore_small_changes', ignore_small_changes, model_graph_node) %}\n {# Validate ignore_small_changes #}\n\n {% set anomaly_exclude_metrics = elementary.get_test_argument('anomaly_exclude_metrics', anomaly_exclude_metrics, model_graph_node) %}\n\n {% set test_configuration =\n {'timestamp_column': timestamp_column,\n 'where_expression': where_expression,\n 'anomaly_sensitivity': anomaly_sensitivity,\n 'anomaly_direction': anomaly_direction,\n 'time_bucket': time_bucket,\n 'days_back': days_back,\n 'backfill_days': backfill_days,\n 'seasonality': seasonality,\n 'freshness_column': freshness_column,\n 'event_timestamp_column': event_timestamp_column,\n 'dimensions': dimensions,\n 'ignore_small_changes': ignore_small_changes,\n 'fail_on_zero': fail_on_zero,\n 'detection_delay': detection_delay,\n 'anomaly_exclude_metrics': anomaly_exclude_metrics\n } %}\n {%- set test_configuration = elementary.undefined_dict_keys_to_none(test_configuration) -%}\n {%- do elementary.validate_mandatory_configuration(test_configuration, mandatory_params) -%}\n {%- do elementary.validate_ignore_small_changes(test_configuration) -%}\n\n {# Changes in these configs impact the metric id of the test. #}\n {# If these configs change, we ignore the old metrics and recalculate. #}\n {% set metric_properties =\n {'timestamp_column': timestamp_column,\n 'where_expression': where_expression,\n 'time_bucket': time_bucket,\n 'freshness_column': freshness_column,\n 'event_timestamp_column': event_timestamp_column,\n 'dimensions': dimensions\n } %}\n {%- set metric_properties = elementary.undefined_dict_keys_to_none(metric_properties) -%}\n\n {# Adding to cache so test configuration will be available outside the test context #}\n {%- set test_unique_id = elementary.get_test_unique_id() %}\n {%- do elementary.set_cache(test_unique_id, test_configuration) -%}\n\n {{ return([test_configuration, metric_properties]) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_model_graph_node", + "macro.elementary.get_test_argument", + "macro.elementary.get_anomaly_direction", + "macro.elementary.detection_period_to_backfill_days", + "macro.elementary.get_time_bucket", + "macro.elementary.training_period_to_days_back", + "macro.elementary.get_days_back", + "macro.elementary.get_seasonality", + "macro.elementary.get_detection_delay", + "macro.elementary.undefined_dict_keys_to_none", + "macro.elementary.validate_mandatory_configuration", + "macro.elementary.validate_ignore_small_changes", + "macro.elementary.get_test_unique_id", + "macro.elementary.set_cache" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.775711, + "supported_languages": null + }, + "macro.elementary.validate_mandatory_configuration": { + "name": "validate_mandatory_configuration", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_anomalies_test_configuration.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_anomalies_test_configuration.sql", + "unique_id": "macro.elementary.validate_mandatory_configuration", + "macro_sql": "{% macro validate_mandatory_configuration(test_configuration, mandatory_params) %}\n {%- set mandatory_configuration = ['anomaly_sensitivity', 'anomaly_direction', 'backfill_days'] %}\n {%- set with_timestamp_mandatory_configuration = ['time_bucket', 'days_back'] %}\n {%- set missing_mandatory_params = [] %}\n\n {%- if mandatory_params and mandatory_params is iterable %}\n {%- set mandatory_configuration = elementary.union_lists(mandatory_configuration, mandatory_params) %}\n {%- endif %}\n {%- if test_configuration.timestamp_column %}\n {%- set mandatory_configuration = elementary.union_lists(mandatory_configuration, with_timestamp_mandatory_configuration) %}\n {%- endif %}\n\n {%- for mandatory_param in mandatory_configuration %}\n {%- if not test_configuration.get(mandatory_param) %}\n {%- do missing_mandatory_params.append(mandatory_param) -%}\n {%- endif %}\n {%- endfor %}\n {%- if missing_mandatory_params | length > 0 %}\n {% do exceptions.raise_compiler_error('Missing mandatory configuration: {}'.format(missing_mandatory_params)) %}\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.union_lists" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.776602, + "supported_languages": null + }, + "macro.elementary.validate_ignore_small_changes": { + "name": "validate_ignore_small_changes", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_anomalies_test_configuration.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_anomalies_test_configuration.sql", + "unique_id": "macro.elementary.validate_ignore_small_changes", + "macro_sql": "{% macro validate_ignore_small_changes(test_configuration) %}\n {% for key, value in test_configuration.ignore_small_changes.items() %}\n {% if key not in ['spike_failure_percent_threshold', 'drop_failure_percent_threshold'] %}\n {% do exceptions.raise_compiler_error('Illegal configuration key: {}'.format(key)) %}\n {% endif %}\n\n {% if (value is not none) and (value | int) and (value >= 0) %}\n {% if (value | int) == 0 or value < 0 %}\n {% do exceptions.raise_compiler_error('Illegal value for ignore_small_changes config: {}'.format(value)) %}\n {% endif %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7772958, + "supported_languages": null + }, + "macro.elementary.get_anomaly_direction": { + "name": "get_anomaly_direction", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_anomaly_direction.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_anomaly_direction.sql", + "unique_id": "macro.elementary.get_anomaly_direction", + "macro_sql": "{% macro get_anomaly_direction(anomaly_direction, model_graph_node) %}\n {%- set anomaly_direction = elementary.get_test_argument('anomaly_direction', anomaly_direction, model_graph_node) | lower %}\n {%- do elementary.validate_anomaly_direction(anomaly_direction) -%}\n {{ return(anomaly_direction) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_test_argument", + "macro.elementary.validate_anomaly_direction" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.777828, + "supported_languages": null + }, + "macro.elementary.validate_anomaly_direction": { + "name": "validate_anomaly_direction", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_anomaly_direction.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_anomaly_direction.sql", + "unique_id": "macro.elementary.validate_anomaly_direction", + "macro_sql": "{% macro validate_anomaly_direction(anomaly_direction) %}\n {% if anomaly_direction %}\n {% set direction_case_insensitive = anomaly_direction %}\n {% if direction_case_insensitive not in ['drop','spike','both'] %}\n {% do exceptions.raise_compiler_error('Supported anomaly directions are: both, drop, spike. received anomaly_direction: {}'.format(anomaly_direction)) %}\n {% endif %}\n {% else %}\n {% do exceptions.raise_compiler_error('anomaly_direction can\\'t be empty. Supported anomaly directions are: both, drop, spike') %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.778263, + "supported_languages": null + }, + "macro.elementary.get_seasonality": { + "name": "get_seasonality", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_seasonality.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_seasonality.sql", + "unique_id": "macro.elementary.get_seasonality", + "macro_sql": "{% macro get_seasonality(seasonality, model_graph_node, time_bucket, timestamp_column) %}\n {%- set seasonality = elementary.get_test_argument('seasonality', seasonality, model_graph_node) %}\n {%- do elementary.validate_seasonality(seasonality, time_bucket, timestamp_column) -%}\n {%- if seasonality %}\n {{ return(seasonality) }}\n {%- endif %}\n {{ return(none)}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_test_argument", + "macro.elementary.validate_seasonality" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7793741, + "supported_languages": null + }, + "macro.elementary.validate_seasonality": { + "name": "validate_seasonality", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_seasonality.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_seasonality.sql", + "unique_id": "macro.elementary.validate_seasonality", + "macro_sql": "{% macro validate_seasonality(seasonality, time_bucket, timestamp_column) %}\n {% if seasonality %}\n {% if not timestamp_column %}\n {% do exceptions.raise_compiler_error('Test with seasonality must have a timestamp_column, but none was provided') %}\n {% endif %}\n {% set supported_seasonality_values = ['day_of_week', 'hour_of_day', 'hour_of_week'] %}\n {%- set seasonality = seasonality | lower %}\n {% if seasonality not in supported_seasonality_values %}\n {% do exceptions.raise_compiler_error('Seasonality value should be one of' ~ supported_seasonality_values ~ ', got ' ~ seasonality ~ ' instead') %}\n {% endif %}\n {% if seasonality == 'day_of_week' and ((time_bucket.count != 1) or (time_bucket.period != 'day')) %}\n {% do exceptions.raise_compiler_error('Daily seasonality is supported only with time_bucket 1 day, got period: ' ~ time_bucket.period ~ ' and count: ' ~ time_bucket.count ~ ' instead') %}\n {% elif seasonality in ['hour_of_day', 'hour_of_week'] and ((time_bucket.count != 1) or (time_bucket.period != 'hour')) %}\n {% do exceptions.raise_compiler_error('Hourly seasonality is supported only with time_bucket 1 hour, got period: ' ~ time_bucket.period ~ ' and count: ' ~ time_bucket.count ~ ' instead') %}\n {% endif %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.780472, + "supported_languages": null + }, + "macro.elementary.detection_period_to_backfill_days": { + "name": "detection_period_to_backfill_days", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_period_vars.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_period_vars.sql", + "unique_id": "macro.elementary.detection_period_to_backfill_days", + "macro_sql": "{% macro detection_period_to_backfill_days(detection_period, backfill_days, model_graph_node) %}\n {% if detection_period %}\n {% if elementary.get_count_of_period(detection_period) != (elementary.get_count_of_period(detection_period) | int) %}\n {%- do elementary.edr_log_warning(\"Got a float number value in detection_period count. Rounding it down...\") -%}\n {% endif %}\n\n {% if not detection_period.period %}\n {{ return(detection_period.count) }}\n {% endif %}\n\n {{ return(elementary.convert_period(detection_period, \"day\").count) }}\n {% endif %}\n\n {{ return(elementary.get_test_argument('backfill_days', backfill_days, model_graph_node)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_count_of_period", + "macro.elementary.edr_log_warning", + "macro.elementary.convert_period", + "macro.elementary.get_test_argument" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7838871, + "supported_languages": null + }, + "macro.elementary.training_period_to_days_back": { + "name": "training_period_to_days_back", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_period_vars.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_period_vars.sql", + "unique_id": "macro.elementary.training_period_to_days_back", + "macro_sql": "{% macro training_period_to_days_back(training_period, days_back, model_graph_node) %}\n {% if training_period %}\n {% if elementary.get_count_of_period(training_period) != (elementary.get_count_of_period(training_period) | int) %}\n {%- do elementary.edr_log_warning(\"Got a float number value in training_period count. Rounding it down...\") -%}\n {% endif %}\n\n {% if not training_period.period %}\n {{ return(training_period.count) }}\n {% endif %}\n\n {{ return(elementary.convert_period(training_period, \"day\").count) }}\n {% endif %}\n\n {{ return(elementary.get_test_argument('days_back', days_back, model_graph_node)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_count_of_period", + "macro.elementary.edr_log_warning", + "macro.elementary.convert_period", + "macro.elementary.get_test_argument" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7845, + "supported_languages": null + }, + "macro.elementary.get_period_default_var": { + "name": "get_period_default_var", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_period_vars.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_period_vars.sql", + "unique_id": "macro.elementary.get_period_default_var", + "macro_sql": "{% macro get_period_default_var(period, count) %}\n {{ return({'period': period, 'count': count}) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7846882, + "supported_languages": null + }, + "macro.elementary.get_unit_of_period": { + "name": "get_unit_of_period", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_period_vars.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_period_vars.sql", + "unique_id": "macro.elementary.get_unit_of_period", + "macro_sql": "{% macro get_unit_of_period(period_dict) %}\n {{ return(period_dict.period) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.784816, + "supported_languages": null + }, + "macro.elementary.get_count_of_period": { + "name": "get_count_of_period", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_period_vars.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_period_vars.sql", + "unique_id": "macro.elementary.get_count_of_period", + "macro_sql": "{% macro get_count_of_period(period_dict) %}\n {{ return(period_dict.count) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.784943, + "supported_languages": null + }, + "macro.elementary.convert_period": { + "name": "convert_period", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_period_vars.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_period_vars.sql", + "unique_id": "macro.elementary.convert_period", + "macro_sql": "{% macro convert_period(period_dict, convert_to) %}\n {% set convert_from = elementary.get_unit_of_period(period_dict) %}\n {% set period_count = elementary.get_count_of_period(period_dict) %}\n \n {% if convert_from == 'week' %}\n {% if convert_to == 'day' %}\n {% set period_count = period_count * 7 %}\n {% elif convert_to == 'hour' %}\n {% set period_count = period_count * 7 * 24 %}\n {% elif convert_to == 'month' %}\n {% set period_count = (period_count * 7) / 30 %}\n {% endif %}\n \n {% elif convert_from == 'day' %}\n {% if convert_to == 'hour' %}\n {% set period_count = period_count * 24 %}\n {% elif convert_to == 'week '%}\n {% set period_count = period_count / 7 %}\n {% elif convert_to == 'month' %}\n {% set period_count = period_count / 30 %}\n {% endif %}\n\n {% elif convert_from == 'hour' %}\n {% if convert_to == 'day' %}\n {% set period_count = period_count / 24 %}\n {% elif convert_to == 'week' %}\n {% set period_count = period_count / (7 * 24) %}\n {% elif convert_to == 'month' %}\n {% set period_count = period_count / (24 * 30) %}\n {% endif %}\n\n {% elif convert_from == 'month' %}\n {% if convert_to == 'day' %}\n {% set period_count = period_count * 30 %}\n {% elif convert_to == 'week' %}\n {% set period_count = (period_count * 30) / 7 %}\n {% elif convert_to == 'hour' %}\n {% set period_count = period_count * 30 * 24 %}\n {% endif %}\n {% endif %}\n\n {% set period_count = period_count | int %}\n {{ return({'period': convert_to, 'count': period_count}) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_unit_of_period", + "macro.elementary.get_count_of_period" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.78685, + "supported_languages": null + }, + "macro.elementary.get_model_baseline_columns": { + "name": "get_model_baseline_columns", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/tests/test_configuration/get_model_baseline_columns.sql", + "original_file_path": "macros/edr/tests/test_configuration/get_model_baseline_columns.sql", + "unique_id": "macro.elementary.get_model_baseline_columns", + "macro_sql": "{% macro get_model_baseline_columns(model, enforce_types=False) %}\n {# Get baseline columns #}\n {% set model_relation = dbt.load_relation(model) %}\n {% set model_graph_node = elementary.get_model_graph_node(model_relation) %}\n\n {% set baseline = [] %}\n {% set columns_without_types = [] %}\n {% for column in model_graph_node[\"columns\"].values() %}\n {% if \"data_type\" in column %}\n {% set info_schema_data_type = elementary.get_normalized_data_type(column[\"data_type\"]) %}\n {% else %}\n {% set info_schema_data_type = none %}\n {% endif %}\n {% set column_info = {\"column_name\": column[\"name\"], \"data_type\": info_schema_data_type } %}\n {% if column_info[\"data_type\"] is none %}\n {% do columns_without_types.append(column_info[\"column_name\"]) %}\n {% endif %}\n {% do baseline.append(column_info) %}\n {% endfor %}\n \n {% if columns_without_types %}\n {% if enforce_types %}\n {% do exceptions.raise_compiler_error(\"Data type not defined for columns `{}` on model `{}` for schema change from baseline test\".format(columns_without_types, model)) %}\n {% else %}\n {% do elementary.edr_log_warning(\"missing data types for columns: \" ~ columns_without_types) %}\n {% endif %}\n {% endif %}\n\n {% do return(baseline) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.load_relation", + "macro.elementary.get_model_graph_node", + "macro.elementary.get_normalized_data_type", + "macro.elementary.edr_log_warning" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.788692, + "supported_languages": null + }, + "macro.elementary.dbt_model_run_result_description": { + "name": "dbt_model_run_result_description", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/alerts/dbt_run_results_description.sql", + "original_file_path": "macros/edr/alerts/dbt_run_results_description.sql", + "unique_id": "macro.elementary.dbt_model_run_result_description", + "macro_sql": "{% macro dbt_model_run_result_description() %}\n 'The model ' || name || ' returned ' || status || ' at ' || generated_at || ' on run ' || invocation_id\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.788813, + "supported_languages": null + }, + "macro.elementary.anomaly_detection_description": { + "name": "anomaly_detection_description", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/alerts/anomaly_detection_description.sql", + "original_file_path": "macros/edr/alerts/anomaly_detection_description.sql", + "unique_id": "macro.elementary.anomaly_detection_description", + "macro_sql": "{% macro anomaly_detection_description() %}\n case\n when dimension is not null then {{ elementary.dimension_metric_description() }}\n when metric_name = 'freshness' then {{ elementary.freshness_description() }}\n when column_name is null then {{ elementary.table_metric_description() }}\n when column_name is not null then {{ elementary.column_metric_description() }}\n else null\n end as anomaly_description\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.dimension_metric_description", + "macro.elementary.freshness_description", + "macro.elementary.table_metric_description", + "macro.elementary.column_metric_description" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7898188, + "supported_languages": null + }, + "macro.elementary.freshness_description": { + "name": "freshness_description", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/alerts/anomaly_detection_description.sql", + "original_file_path": "macros/edr/alerts/anomaly_detection_description.sql", + "unique_id": "macro.elementary.freshness_description", + "macro_sql": "{% macro freshness_description() %}\n 'Last update was at ' || anomalous_value || ', ' || {{ elementary.edr_cast_as_string('abs(round(' ~ elementary.edr_cast_as_numeric('metric_value/3600') ~ ', 2))') }} || ' hours ago. Usually the table is updated within ' || {{ elementary.edr_cast_as_string('abs(round(' ~ elementary.edr_cast_as_numeric('training_avg/3600') ~ ', 2))') }} || ' hours.'\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_string", + "macro.elementary.edr_cast_as_numeric" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.79009, + "supported_languages": null + }, + "macro.elementary.table_metric_description": { + "name": "table_metric_description", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/alerts/anomaly_detection_description.sql", + "original_file_path": "macros/edr/alerts/anomaly_detection_description.sql", + "unique_id": "macro.elementary.table_metric_description", + "macro_sql": "{% macro table_metric_description() %}\n 'The last ' || metric_name || ' value is ' || {{ elementary.edr_cast_as_string('round(' ~ elementary.edr_cast_as_numeric('metric_value') ~ ', 3)') }} ||\n '. The average for this metric is ' || {{ elementary.edr_cast_as_string('round(' ~ elementary.edr_cast_as_numeric('training_avg') ~ ', 3)') }} || '.'\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_string", + "macro.elementary.edr_cast_as_numeric" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.790359, + "supported_languages": null + }, + "macro.elementary.column_metric_description": { + "name": "column_metric_description", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/alerts/anomaly_detection_description.sql", + "original_file_path": "macros/edr/alerts/anomaly_detection_description.sql", + "unique_id": "macro.elementary.column_metric_description", + "macro_sql": "{% macro column_metric_description() %}\n 'In column ' || column_name || ', the last ' || metric_name || ' value is ' || {{ elementary.edr_cast_as_string('round(' ~ elementary.edr_cast_as_numeric('metric_value') ~ ', 3)') }} ||\n '. The average for this metric is ' || {{ elementary.edr_cast_as_string('round(' ~ elementary.edr_cast_as_numeric('training_avg') ~ ', 3)') }} || '.'\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_string", + "macro.elementary.edr_cast_as_numeric" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7906308, + "supported_languages": null + }, + "macro.elementary.dimension_metric_description": { + "name": "dimension_metric_description", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/alerts/anomaly_detection_description.sql", + "original_file_path": "macros/edr/alerts/anomaly_detection_description.sql", + "unique_id": "macro.elementary.dimension_metric_description", + "macro_sql": "{% macro dimension_metric_description() %}\n 'The last ' || metric_name || ' value for dimension ' || dimension || ' - ' ||\n case when dimension_value is null then 'NULL' else dimension_value end || ' is ' || {{ elementary.edr_cast_as_string('round(' ~ elementary.edr_cast_as_numeric('metric_value') ~ ', 3)') }} ||\n '. The average for this metric is ' || {{ elementary.edr_cast_as_string('round(' ~ elementary.edr_cast_as_numeric('training_avg') ~ ', 3)') }} || '.'\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_string", + "macro.elementary.edr_cast_as_numeric" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.790903, + "supported_languages": null + }, + "macro.elementary.get_configured_schemas_from_graph": { + "name": "get_configured_schemas_from_graph", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/configuration/get_configured_schemas_from_graph.sql", + "original_file_path": "macros/edr/system/configuration/get_configured_schemas_from_graph.sql", + "unique_id": "macro.elementary.get_configured_schemas_from_graph", + "macro_sql": "{% macro get_configured_schemas_from_graph() %}\n {% set configured_schemas = [] %}\n {% set existing_schemas = [] %}\n {% if execute %}\n {% set root_project = context[\"project_name\"] %}\n {% set nodes = elementary.get_nodes_from_graph() %}\n {% for node in nodes %}\n {% if node.resource_type in ['model', 'source', 'snapshot', 'seed'] and node.package_name == root_project %}\n {% set schema_tuple = (node.database, node.schema) %}\n {% if schema_tuple not in configured_schemas %}\n {% do configured_schemas.append(schema_tuple) %}\n {% endif %}\n {% endif %}\n {% endfor %}\n\n {% for schema_tuple in configured_schemas %}\n {% set database_name = schema_tuple[0] %}\n {% set schema_name = schema_tuple[1] %}\n {% if elementary.schema_exists(database_name, schema_name) %}\n {% do existing_schemas.append(schema_tuple) %}\n {% endif %}\n {% endfor %}\n {% endif %}\n {{ return(existing_schemas) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_nodes_from_graph", + "macro.elementary.schema_exists" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7925591, + "supported_languages": null + }, + "macro.elementary.get_configured_databases_from_graph": { + "name": "get_configured_databases_from_graph", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/configuration/get_configured_databases_from_graph.sql", + "original_file_path": "macros/edr/system/configuration/get_configured_databases_from_graph.sql", + "unique_id": "macro.elementary.get_configured_databases_from_graph", + "macro_sql": "{% macro get_configured_databases_from_graph() %}\n {% set schema_tuples = elementary.get_configured_schemas_from_graph() %}\n {% do return(schema_tuples | map(attribute=0) | unique) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_configured_schemas_from_graph" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.792834, + "supported_languages": null + }, + "macro.elementary.is_elementary_enabled": { + "name": "is_elementary_enabled", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/configuration/is_elementary_enabled.sql", + "original_file_path": "macros/edr/system/configuration/is_elementary_enabled.sql", + "unique_id": "macro.elementary.is_elementary_enabled", + "macro_sql": "{% macro is_elementary_enabled() %}\n {% do return(\"elementary\" in graph) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.79301, + "supported_languages": null + }, + "macro.elementary.on_run_start": { + "name": "on_run_start", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/hooks/on_run_start.sql", + "original_file_path": "macros/edr/system/hooks/on_run_start.sql", + "unique_id": "macro.elementary.on_run_start", + "macro_sql": "{% macro on_run_start() %}\n {% set edr_cli_run = elementary.get_config_var('edr_cli_run') %}\n {% if not execute or edr_cli_run %}\n {{ return('') }}\n {% endif %}\n\n {% do recommend_dbt_core_artifacts_upgrade() %}\n {% do elementary.init_elementary_graph() %}\n\n {% if elementary.is_test_command() %}\n {{ elementary.create_elementary_tests_schema() }}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.recommend_dbt_core_artifacts_upgrade", + "macro.elementary.init_elementary_graph", + "macro.elementary.is_test_command", + "macro.elementary.create_elementary_tests_schema" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.793549, + "supported_languages": null + }, + "macro.elementary.on_run_end": { + "name": "on_run_end", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/hooks/on_run_end.sql", + "original_file_path": "macros/edr/system/hooks/on_run_end.sql", + "unique_id": "macro.elementary.on_run_end", + "macro_sql": "{% macro on_run_end() %}\n {%- if execute and not elementary.is_docs_command() %}\n {% set edr_cli_run = elementary.get_config_var('edr_cli_run') %}\n {% if not execute or edr_cli_run %}\n {% do return(\"\") %}\n {% endif %}\n\n {% if elementary.is_run_command() %}\n {% do elementary.insert_metrics() %}\n {% endif %}\n\n {% if not elementary.get_config_var('disable_dbt_artifacts_autoupload') %}\n {% do elementary.upload_dbt_artifacts() %}\n {% endif %}\n\n {% if not elementary.get_config_var('disable_run_results') %}\n {% do elementary.upload_run_results() %}\n {% endif %}\n\n {% if elementary.is_test_command() and not elementary.get_config_var('disable_tests_results') %}\n {% do elementary.handle_tests_results() %}\n {% endif %}\n\n {% if not elementary.get_config_var('disable_dbt_invocation_autoupload') %}\n {% do elementary.upload_dbt_invocation() %}\n {% endif %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.is_docs_command", + "macro.elementary.get_config_var", + "macro.elementary.is_run_command", + "macro.elementary.insert_metrics", + "macro.elementary.upload_dbt_artifacts", + "macro.elementary.upload_run_results", + "macro.elementary.is_test_command", + "macro.elementary.handle_tests_results", + "macro.elementary.upload_dbt_invocation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7949162, + "supported_languages": null + }, + "macro.elementary.get_time_format": { + "name": "get_time_format", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/times.sql", + "original_file_path": "macros/edr/system/system_utils/times.sql", + "unique_id": "macro.elementary.get_time_format", + "macro_sql": "{% macro get_time_format() %}\n {% do return(\"%Y-%m-%d %H:%M:%S\") %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.79528, + "supported_languages": null + }, + "macro.elementary.run_started_at_as_string": { + "name": "run_started_at_as_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/times.sql", + "original_file_path": "macros/edr/system/system_utils/times.sql", + "unique_id": "macro.elementary.run_started_at_as_string", + "macro_sql": "{% macro run_started_at_as_string() %}\n {% do return(elementary.get_run_started_at().strftime(elementary.get_time_format())) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_run_started_at", + "macro.elementary.get_time_format" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.7954571, + "supported_languages": null + }, + "macro.elementary.datetime_now_utc_as_string": { + "name": "datetime_now_utc_as_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/times.sql", + "original_file_path": "macros/edr/system/system_utils/times.sql", + "unique_id": "macro.elementary.datetime_now_utc_as_string", + "macro_sql": "{% macro datetime_now_utc_as_string() %}\n {% do return(modules.datetime.datetime.utcnow().strftime(elementary.get_time_format())) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_time_format" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.795655, + "supported_languages": null + }, + "macro.elementary.current_timestamp_column": { + "name": "current_timestamp_column", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/times.sql", + "original_file_path": "macros/edr/system/system_utils/times.sql", + "unique_id": "macro.elementary.current_timestamp_column", + "macro_sql": "{% macro current_timestamp_column() %}\n cast ({{elementary.edr_current_timestamp_in_utc()}} as {{ elementary.edr_type_timestamp() }})\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_current_timestamp_in_utc", + "macro.elementary.edr_type_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.795797, + "supported_languages": null + }, + "macro.elementary.datetime_now_utc_as_timestamp_column": { + "name": "datetime_now_utc_as_timestamp_column", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/times.sql", + "original_file_path": "macros/edr/system/system_utils/times.sql", + "unique_id": "macro.elementary.datetime_now_utc_as_timestamp_column", + "macro_sql": "{% macro datetime_now_utc_as_timestamp_column() %}\n cast ('{{ elementary.datetime_now_utc_as_string() }}' as {{ elementary.edr_type_timestamp() }})\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.datetime_now_utc_as_string", + "macro.elementary.edr_type_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.795941, + "supported_languages": null + }, + "macro.elementary.no_results_query": { + "name": "no_results_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/no_results_query.sql", + "original_file_path": "macros/edr/system/system_utils/no_results_query.sql", + "unique_id": "macro.elementary.no_results_query", + "macro_sql": "{% macro no_results_query() %}\n with nothing as (select 1 as num)\n select * from nothing where num = 2\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.796043, + "supported_languages": null + }, + "macro.elementary.get_run_started_at": { + "name": "get_run_started_at", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/get_run_started_at.sql", + "original_file_path": "macros/edr/system/system_utils/get_run_started_at.sql", + "unique_id": "macro.elementary.get_run_started_at", + "macro_sql": "{% macro get_run_started_at() %}\n {% set custom_run_started_at = elementary.get_config_var('custom_run_started_at') %}\n {% if custom_run_started_at %}\n {# dbt run_started_at is fromtype datetime, so we convert the given custom time to be datetime as well. #}\n {{ return(modules.datetime.datetime.fromisoformat(custom_run_started_at)) }}\n {% else %}\n {{ return(run_started_at) }}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_config_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.796538, + "supported_languages": null + }, + "macro.elementary.complete_buckets_cte": { + "name": "complete_buckets_cte", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/buckets_cte.sql", + "original_file_path": "macros/edr/system/system_utils/buckets_cte.sql", + "unique_id": "macro.elementary.complete_buckets_cte", + "macro_sql": "{% macro complete_buckets_cte(metric_properties, min_bucket_start, max_bucket_end) %}\n {%- set time_bucket = metric_properties.time_bucket %}\n {%- set bucket_end_expr = elementary.edr_timeadd(time_bucket.period, time_bucket.count, 'edr_bucket_start') %}\n {%- set min_bucket_start_expr = elementary.edr_cast_as_timestamp(min_bucket_start) %}\n {%- set max_bucket_end_expr = elementary.edr_cast_as_timestamp(max_bucket_end) %}\n {{ adapter.dispatch('complete_buckets_cte','elementary')(time_bucket, bucket_end_expr, min_bucket_start_expr, max_bucket_end_expr) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_timeadd", + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.snowflake__complete_buckets_cte" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8045409, + "supported_languages": null + }, + "macro.elementary.default__complete_buckets_cte": { + "name": "default__complete_buckets_cte", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/buckets_cte.sql", + "original_file_path": "macros/edr/system/system_utils/buckets_cte.sql", + "unique_id": "macro.elementary.default__complete_buckets_cte", + "macro_sql": "{% macro default__complete_buckets_cte(time_bucket, bucket_end_expr, min_bucket_start_expr, max_bucket_end_expr) %}\n {{ exceptions.raise_compiler_error(\"The adapter does not have an implementation for macro 'complete_buckets_cte'\") }}\n {{ return('') }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.804756, + "supported_languages": null + }, + "macro.elementary.spark__complete_buckets_cte": { + "name": "spark__complete_buckets_cte", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/buckets_cte.sql", + "original_file_path": "macros/edr/system/system_utils/buckets_cte.sql", + "unique_id": "macro.elementary.spark__complete_buckets_cte", + "macro_sql": "{% macro spark__complete_buckets_cte(time_bucket, bucket_end_expr, min_bucket_start_expr, max_bucket_end_expr) %}\n {%- set complete_buckets_cte %}\n select\n edr_bucket_start,\n {{ bucket_end_expr }} as edr_bucket_end\n from (select explode(sequence({{ min_bucket_start_expr }}, {{ max_bucket_end_expr }}, interval {{ time_bucket.count }} {{ time_bucket.period }})) as edr_bucket_start)\n where {{ bucket_end_expr }} <= {{ max_bucket_end_expr }}\n {%- endset %}\n {{ return(complete_buckets_cte) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8050911, + "supported_languages": null + }, + "macro.elementary.snowflake__complete_buckets_cte": { + "name": "snowflake__complete_buckets_cte", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/buckets_cte.sql", + "original_file_path": "macros/edr/system/system_utils/buckets_cte.sql", + "unique_id": "macro.elementary.snowflake__complete_buckets_cte", + "macro_sql": "{% macro snowflake__complete_buckets_cte(time_bucket, bucket_end_expr, min_bucket_start_expr, max_bucket_end_expr) -%}\n {%- set complete_buckets_cte %}\n with timestamps as (\n select {{ min_bucket_start_expr }} as edr_bucket_start\n union all\n select {{ bucket_end_expr }} as next_bucket\n from timestamps\n where next_bucket < {{ max_bucket_end_expr }}\n )\n select\n edr_bucket_start,\n {{ bucket_end_expr }} as edr_bucket_end\n from timestamps\n where {{ bucket_end_expr }} <= {{ max_bucket_end_expr }}\n {%- endset %}\n {{ return(complete_buckets_cte) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8054059, + "supported_languages": null + }, + "macro.elementary.bigquery__complete_buckets_cte": { + "name": "bigquery__complete_buckets_cte", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/buckets_cte.sql", + "original_file_path": "macros/edr/system/system_utils/buckets_cte.sql", + "unique_id": "macro.elementary.bigquery__complete_buckets_cte", + "macro_sql": "{% macro bigquery__complete_buckets_cte(time_bucket, bucket_end_expr, min_bucket_start_expr, max_bucket_end_expr) %}\n\n {%- if time_bucket.period | lower in ['second', 'minute', 'hour', 'day'] %}\n {%- set complete_buckets_cte %}\n select\n edr_bucket_start,\n {{ bucket_end_expr }} as edr_bucket_end\n from unnest(generate_timestamp_array({{ min_bucket_start_expr }}, {{ max_bucket_end_expr }}, interval {{ time_bucket.count }} {{ time_bucket.period }})) as edr_bucket_start\n where {{ bucket_end_expr }} <= {{ max_bucket_end_expr }}\n {%- endset %}\n {%- elif time_bucket.period | lower in ['week', 'month', 'quarter', 'year'] %}\n {%- set complete_buckets_cte %}\n select\n {{ elementary.edr_cast_as_timestamp('edr_bucket_start') }} as edr_bucket_start,\n {{ elementary.edr_cast_as_timestamp(bucket_end_expr) }} as edr_bucket_end\n from unnest(generate_date_array({{ elementary.edr_cast_as_date(min_bucket_start_expr) }}, {{ elementary.edr_cast_as_date(max_bucket_end_expr) }}, interval {{ time_bucket.count }} {{ time_bucket.period }})) as edr_bucket_start\n where {{ elementary.edr_cast_as_timestamp(bucket_end_expr) }} <= {{ max_bucket_end_expr }}\n {%- endset %}\n {%- else %}\n {{ exceptions.raise_compiler_error(\"Unsupported time bucket period: \".format(time_bucket.period)) }}\n {%- endif %}\n\n {{ return(complete_buckets_cte) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.edr_cast_as_date" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.806411, + "supported_languages": null + }, + "macro.elementary.redshift__complete_buckets_cte": { + "name": "redshift__complete_buckets_cte", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/buckets_cte.sql", + "original_file_path": "macros/edr/system/system_utils/buckets_cte.sql", + "unique_id": "macro.elementary.redshift__complete_buckets_cte", + "macro_sql": "{% macro redshift__complete_buckets_cte(time_bucket, bucket_end_expr, min_bucket_start_expr, max_bucket_end_expr) %}\n {%- set complete_buckets_cte %}\n with integers as (\n select (row_number() over (order by 1)) - 1 as num\n from pg_catalog.pg_class\n limit {{ elementary.edr_datediff(min_bucket_start_expr, max_bucket_end_expr, time_bucket.period) }} / {{ time_bucket.count }} + 1\n )\n select\n {{ min_bucket_start_expr }} + (num * interval '{{ time_bucket.count }} {{ time_bucket.period }}') as edr_bucket_start,\n {{ min_bucket_start_expr }} + ((num + 1) * interval '{{ time_bucket.count }} {{ time_bucket.period }}') as edr_bucket_end\n from integers\n where edr_bucket_end <= {{ max_bucket_end_expr }}\n {%- endset %}\n {{ return(complete_buckets_cte) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_datediff" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.806885, + "supported_languages": null + }, + "macro.elementary.postgres__complete_buckets_cte": { + "name": "postgres__complete_buckets_cte", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/buckets_cte.sql", + "original_file_path": "macros/edr/system/system_utils/buckets_cte.sql", + "unique_id": "macro.elementary.postgres__complete_buckets_cte", + "macro_sql": "{% macro postgres__complete_buckets_cte(time_bucket, bucket_end_expr, min_bucket_start_expr, max_bucket_end_expr) %}\n {%- set complete_buckets_cte %}\n select\n edr_bucket_start,\n {{ bucket_end_expr }} as edr_bucket_end\n from generate_series({{ min_bucket_start_expr }}, {{ max_bucket_end_expr }}, interval '{{ time_bucket.count }} {{ time_bucket.period }}') edr_bucket_start\n where {{ bucket_end_expr }} <= {{ max_bucket_end_expr }}\n {%- endset %}\n {{ return(complete_buckets_cte) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.807224, + "supported_languages": null + }, + "macro.elementary.athena__complete_buckets_cte": { + "name": "athena__complete_buckets_cte", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/buckets_cte.sql", + "original_file_path": "macros/edr/system/system_utils/buckets_cte.sql", + "unique_id": "macro.elementary.athena__complete_buckets_cte", + "macro_sql": "{% macro athena__complete_buckets_cte(time_bucket, bucket_end_expr, min_bucket_start_expr, max_bucket_end_expr) %}\n {%- set complete_buckets_cte %}\n select\n edr_bucket_start,\n {{ bucket_end_expr }} as edr_bucket_end\n from unnest(sequence(\n {{ min_bucket_start_expr }},\n {{ max_bucket_end_expr }},\n {%- if time_bucket.period | lower == 'week' %}\n interval '{{ time_bucket.count * 7 }}' day\n {%- else %}\n interval '{{ time_bucket.count }}' {{ time_bucket.period }}\n {%- endif %}\n )) as t(edr_bucket_start)\n where {{ bucket_end_expr }} <= {{ max_bucket_end_expr }}\n {%- endset %}\n {{ return(complete_buckets_cte) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.807703, + "supported_languages": null + }, + "macro.elementary.get_test_argument": { + "name": "get_test_argument", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/get_test_argument.sql", + "original_file_path": "macros/edr/system/system_utils/get_test_argument.sql", + "unique_id": "macro.elementary.get_test_argument", + "macro_sql": "{% macro get_test_argument(argument_name, value, model_graph_node) %}\n {% if value %}\n {{ return(value) }}\n {%- endif %}\n {%- if model_graph_node %}\n {% set elementary_config = elementary.get_elementary_config_from_node(model_graph_node) %}\n {% if elementary_config and elementary_config is mapping %}\n {%- set model_config_value = elementary_config.get(argument_name) %}\n {%- if model_config_value %}\n {{ return(model_config_value) }}\n {%- endif %}\n {% endif %}\n {% endif %}\n {% set config_value = elementary.get_config_var(argument_name) %}\n {% if config_value is defined %}\n {% do return(config_value) %}\n {% endif %}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_elementary_config_from_node", + "macro.elementary.get_config_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.808685, + "supported_languages": null + }, + "macro.elementary.get_var": { + "name": "get_var", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/get_var.sql", + "original_file_path": "macros/edr/system/system_utils/get_var.sql", + "unique_id": "macro.elementary.get_var", + "macro_sql": "{% macro get_var(config_var_name, env_vars_names) %}\n {% do return(elementary.get_config_var(config_var_name) or elementary.get_first_env_var(env_vars_names)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_first_env_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.808931, + "supported_languages": null + }, + "macro.elementary.get_config_var": { + "name": "get_config_var", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/get_config_var.sql", + "original_file_path": "macros/edr/system/system_utils/get_config_var.sql", + "unique_id": "macro.elementary.get_config_var", + "macro_sql": "{% macro get_config_var(var_name) %}\n {% set default_config = elementary.get_default_config() %}\n {% set var_value = var(var_name, default_config.get(var_name)) %}\n {% if var_value is string %}\n {% if var_value.lower() == \"true\" %}\n {% do return(true) %}\n {% elif var_value.lower() == \"false\" %}\n {% do return(false) %}\n {% endif %}\n {% endif %}\n {% do return(var_value) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_default_config" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.810252, + "supported_languages": null + }, + "macro.elementary.get_default_config": { + "name": "get_default_config", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/get_config_var.sql", + "original_file_path": "macros/edr/system/system_utils/get_config_var.sql", + "unique_id": "macro.elementary.get_default_config", + "macro_sql": "{% macro get_default_config(var_name) %}\n {{ return(adapter.dispatch('get_default_config', 'elementary')()) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.default__get_default_config" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8104289, + "supported_languages": null + }, + "macro.elementary.default__get_default_config": { + "name": "default__get_default_config", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/get_config_var.sql", + "original_file_path": "macros/edr/system/system_utils/get_config_var.sql", + "unique_id": "macro.elementary.default__get_default_config", + "macro_sql": "{%- macro default__get_default_config() -%}\n{# We use this macro to define and call vars, as the global vars defined in dbt_project.yml\n of the package are not accessible at on-run-start and on-run-end #}\n {% set default_config = {\n 'detection_period': elementary.get_period_default_var(period='day', count=2),\n 'training_period': elementary.get_period_default_var(period='day', count=14),\n 'days_back': 14,\n 'anomaly_sensitivity': 3,\n 'backfill_days': 2,\n 'tests_schema_name': '',\n 'debug_logs': false,\n 'disable_warn_alerts': false,\n 'disable_model_alerts': false,\n 'disable_test_alerts': false,\n 'disable_source_freshness_alerts': false,\n 'disable_run_results': false,\n 'disable_tests_results': false,\n 'disable_dbt_artifacts_autoupload': false,\n 'disable_dbt_columns_autoupload': false,\n 'upload_only_columns_with_descriptions': false,\n 'disable_dbt_invocation_autoupload': false,\n 'disable_skipped_model_alerts': true,\n 'disable_skipped_test_alerts': true,\n 'dbt_artifacts_chunk_size': 5000,\n 'test_sample_row_count': 5,\n 'edr_cli_run': false,\n 'max_int': 2147483647,\n 'custom_run_started_at': none,\n 'edr_monitors': elementary.get_default_monitors(),\n 'long_string_size': 65535,\n 'collect_model_sql': true,\n 'query_max_size': 1000000,\n 'insert_rows_method': 'max_query_size',\n 'upload_artifacts_method': 'diff',\n 'project_name': none,\n 'elementary_full_refresh': false,\n 'min_training_set_size': 7,\n 'cache_artifacts': true,\n 'anomaly_direction': 'both',\n 'store_result_rows_in_own_table': true,\n 'mute_dbt_upgrade_recommendation': false,\n 'calculate_failed_count': true,\n 'tests_use_temp_tables': false,\n 'collect_metrics': true,\n 'clean_elementary_temp_tables': true,\n 'force_metrics_backfill': false,\n 'ignore_small_changes': {\n 'spike_failure_percent_threshold': none,\n 'drop_failure_percent_threshold': none\n },\n 'include_other_warehouse_specific_columns': false,\n 'fail_on_zero': false,\n 'anomaly_exclude_metrics': none\n } %}\n {{- return(default_config) -}}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.get_period_default_var", + "macro.elementary.get_default_monitors" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.812021, + "supported_languages": null + }, + "macro.elementary.bigquery__get_default_config": { + "name": "bigquery__get_default_config", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/get_config_var.sql", + "original_file_path": "macros/edr/system/system_utils/get_config_var.sql", + "unique_id": "macro.elementary.bigquery__get_default_config", + "macro_sql": "{%- macro bigquery__get_default_config() -%}\n {% set default_config = elementary.default__get_default_config() %}\n {% do default_config.update({'query_max_size': 250000}) %}\n {{- return(default_config) -}}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.default__get_default_config" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.812277, + "supported_languages": null + }, + "macro.elementary.athena__get_default_config": { + "name": "athena__get_default_config", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/get_config_var.sql", + "original_file_path": "macros/edr/system/system_utils/get_config_var.sql", + "unique_id": "macro.elementary.athena__get_default_config", + "macro_sql": "{%- macro athena__get_default_config() -%}\n {% set default_config = elementary.default__get_default_config() %}\n {% do default_config.update({'query_max_size': 250000}) %}\n {{- return(default_config) -}}\n{%- endmacro -%}", + "depends_on": { + "macros": [ + "macro.elementary.default__get_default_config" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.812522, + "supported_languages": null + }, + "macro.elementary.get_elementary_package_version": { + "name": "get_elementary_package_version", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/get_elementary_package_version.sql", + "original_file_path": "macros/edr/system/system_utils/get_elementary_package_version.sql", + "unique_id": "macro.elementary.get_elementary_package_version", + "macro_sql": "{% macro get_elementary_package_version() %}\n {% set conf = elementary.get_runtime_config() %}\n {% do return(conf.dependencies[\"elementary\"].version) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_runtime_config" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.812781, + "supported_languages": null + }, + "macro.elementary.get_runtime_config": { + "name": "get_runtime_config", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/get_runtime_config.sql", + "original_file_path": "macros/edr/system/system_utils/get_runtime_config.sql", + "unique_id": "macro.elementary.get_runtime_config", + "macro_sql": "{% macro get_runtime_config() %}\n {{ return(builtins.ref.config) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.812939, + "supported_languages": null + }, + "macro.elementary.get_first_env_var": { + "name": "get_first_env_var", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/get_first_env_var.sql", + "original_file_path": "macros/edr/system/system_utils/get_first_env_var.sql", + "unique_id": "macro.elementary.get_first_env_var", + "macro_sql": "{% macro get_first_env_var(var_names) %}\n {% for var_name in var_names %}\n {% set value = env_var(var_name, \"\") %}\n {% if value %}\n {{ return(value) }}\n {% endif %}\n {% endfor %}\n {{ return(none) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.813365, + "supported_languages": null + }, + "macro.elementary.empty_elementary_test_results": { + "name": "empty_elementary_test_results", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/empty_table.sql", + "original_file_path": "macros/edr/system/system_utils/empty_table.sql", + "unique_id": "macro.elementary.empty_elementary_test_results", + "macro_sql": "{% macro empty_elementary_test_results() %}\n {{ elementary.empty_table([\n ('id','long_string'),\n ('data_issue_id','string'),\n ('test_execution_id','long_string'),\n ('test_unique_id','long_string'),\n ('model_unique_id','long_string'),\n ('invocation_id', 'string'),\n ('detected_at','timestamp'),\n ('created_at','timestamp'),\n ('database_name','string'),\n ('schema_name','string'),\n ('table_name','string'),\n ('column_name','string'),\n ('test_type','string'),\n ('test_sub_type','string'),\n ('test_results_description','long_string'),\n ('owners','string'),\n ('tags','string'),\n ('test_results_query','long_string'),\n ('other','string'),\n ('test_name','long_string'),\n ('test_params','long_string'),\n ('severity','string'),\n ('status','string'),\n ('failures', 'bigint'),\n ('test_short_name', 'string'),\n ('test_alias', 'string'),\n ('result_rows', 'long_string'),\n ('failed_row_count', 'bigint')\n ]) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.818766, + "supported_languages": null + }, + "macro.elementary.empty_dbt_source_freshness_results": { + "name": "empty_dbt_source_freshness_results", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/empty_table.sql", + "original_file_path": "macros/edr/system/system_utils/empty_table.sql", + "unique_id": "macro.elementary.empty_dbt_source_freshness_results", + "macro_sql": "{% macro empty_dbt_source_freshness_results() %}\n {{ elementary.empty_table([\n ('source_freshness_execution_id','string'),\n ('unique_id','string'),\n ('max_loaded_at','string'),\n ('snapshotted_at','string'),\n ('generated_at', 'string'),\n ('created_at', 'timestamp'),\n ('max_loaded_at_time_ago_in_s','float'),\n ('status','string'),\n ('error','string'),\n ('compile_started_at', 'string'),\n ('compile_completed_at', 'string'),\n ('execute_started_at', 'string'),\n ('execute_completed_at', 'string'),\n ('invocation_id', 'string'),\n ('warn_after', 'string'),\n ('error_after', 'string'),\n ('filter', 'long_string')\n ]) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.819521, + "supported_languages": null + }, + "macro.elementary.empty_data_monitoring_metrics": { + "name": "empty_data_monitoring_metrics", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/empty_table.sql", + "original_file_path": "macros/edr/system/system_utils/empty_table.sql", + "unique_id": "macro.elementary.empty_data_monitoring_metrics", + "macro_sql": "{% macro empty_data_monitoring_metrics(with_created_at=true) %}\n {% set columns = [('id','string'),\n ('full_table_name','string'),\n ('column_name','string'),\n ('metric_name','string'),\n ('metric_value','float'),\n ('source_value','string'),\n ('bucket_start','timestamp'),\n ('bucket_end','timestamp'),\n ('bucket_duration_hours','int'),\n ('updated_at','timestamp'),\n ('dimension','string'),\n ('dimension_value','string'),\n ('metric_properties','string')]\n %}\n {% if with_created_at %}\n {% do columns.append(('created_at','timestamp')) %}\n {% endif %}\n {{ elementary.empty_table(columns) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.820304, + "supported_languages": null + }, + "macro.elementary.empty_schema_columns_snapshot": { + "name": "empty_schema_columns_snapshot", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/empty_table.sql", + "original_file_path": "macros/edr/system/system_utils/empty_table.sql", + "unique_id": "macro.elementary.empty_schema_columns_snapshot", + "macro_sql": "{% macro empty_schema_columns_snapshot() %}\n {{ elementary.empty_table([('column_state_id','string'),('full_column_name','string'),('full_table_name','string'),('column_name','string'),('data_type','string'),('is_new','boolean'),('detected_at','timestamp'),('created_at','timestamp')]) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.820707, + "supported_languages": null + }, + "macro.elementary.empty_column_monitors_cte": { + "name": "empty_column_monitors_cte", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/empty_table.sql", + "original_file_path": "macros/edr/system/system_utils/empty_table.sql", + "unique_id": "macro.elementary.empty_column_monitors_cte", + "macro_sql": "{% macro empty_column_monitors_cte() %}\n {%- set column_monitors_list = elementary.get_agg_column_monitors() %}\n {%- set columns_definition = [('column_name', 'string'), ('bucket', 'timestamp')] %}\n {%- for monitor in column_monitors_list %}\n {%- do columns_definition.append((monitor,'int'))-%}\n {%- endfor %}\n {{ elementary.empty_table(columns_definition) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_agg_column_monitors", + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.82111, + "supported_languages": null + }, + "macro.elementary.empty_table": { + "name": "empty_table", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/empty_table.sql", + "original_file_path": "macros/edr/system/system_utils/empty_table.sql", + "unique_id": "macro.elementary.empty_table", + "macro_sql": "{% macro empty_table(column_name_and_type_list) %}\n\n {%- set empty_table_query -%}\n select * from (\n select\n {% for column in column_name_and_type_list %}\n {{ elementary.empty_column(column[0], column[1]) }} {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n ) as empty_table\n where 1 = 0\n {%- endset -%}\n\n {{- return(empty_table_query)-}}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_column" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.821475, + "supported_languages": null + }, + "macro.elementary.empty_column": { + "name": "empty_column", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/empty_table.sql", + "original_file_path": "macros/edr/system/system_utils/empty_table.sql", + "unique_id": "macro.elementary.empty_column", + "macro_sql": "{% macro empty_column(column_name, data_type) %}\n\n {%- set dummy_values = elementary.dummy_values() %}\n\n {%- if data_type == 'boolean' %}\n cast ({{ dummy_values['boolean'] }} as {{ elementary.edr_type_bool()}}) as {{ column_name }}\n {%- elif data_type == 'timestamp' -%}\n cast('{{ dummy_values['timestamp'] }}' as {{ elementary.edr_type_timestamp() }}) as {{ column_name }}\n {%- elif data_type == 'int' %}\n cast({{ dummy_values['int'] }} as {{ elementary.edr_type_int() }}) as {{ column_name }}\n {%- elif data_type == 'bigint' %}\n cast({{ dummy_values['bigint'] }} as {{ elementary.edr_type_bigint() }}) as {{ column_name }}\n {%- elif data_type == 'float' %}\n cast({{ dummy_values['float'] }} as {{ elementary.edr_type_float() }}) as {{ column_name }}\n {%- elif data_type == 'long_string' %}\n cast('{{ dummy_values['long_string'] }}' as {{ elementary.edr_type_long_string() }}) as {{ column_name }}\n {%- else %}\n cast('{{ dummy_values['string'] }}' as {{ elementary.edr_type_string() }}) as {{ column_name }}\n {%- endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.dummy_values", + "macro.elementary.edr_type_bool", + "macro.elementary.edr_type_timestamp", + "macro.elementary.edr_type_int", + "macro.elementary.edr_type_bigint", + "macro.elementary.edr_type_float", + "macro.elementary.edr_type_long_string", + "macro.elementary.edr_type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.822518, + "supported_languages": null + }, + "macro.elementary.dummy_values": { + "name": "dummy_values", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/empty_table.sql", + "original_file_path": "macros/edr/system/system_utils/empty_table.sql", + "unique_id": "macro.elementary.dummy_values", + "macro_sql": "{% macro dummy_values() %}\n\n {%- set dummy_values = {\n 'string': \"dummy_string\",\n 'long_string': \"this_is_just_a_long_dummy_string\",\n 'boolean': 'True',\n 'int': 123456789,\n 'bigint': 31474836478,\n 'float': 123456789.99,\n 'timestamp': \"2091-02-17\"\n } %}\n\n {{ return(dummy_values) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.82288, + "supported_languages": null + }, + "macro.elementary.edr_log": { + "name": "edr_log", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/logs.sql", + "original_file_path": "macros/edr/system/system_utils/logs.sql", + "unique_id": "macro.elementary.edr_log", + "macro_sql": "{% macro edr_log(msg, info=True) %}\n {%- if execute %}\n {% do log('Elementary: ' ~ msg, info=info) %}\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.824044, + "supported_languages": null + }, + "macro.elementary.edr_log_warning": { + "name": "edr_log_warning", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/logs.sql", + "original_file_path": "macros/edr/system/system_utils/logs.sql", + "unique_id": "macro.elementary.edr_log_warning", + "macro_sql": "{% macro edr_log_warning(msg, info=True) %}\n {%- if execute %}\n {% do elementary.edr_log(\"Warning - \" ~ msg, info=info) %}\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_log" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8242729, + "supported_languages": null + }, + "macro.elementary.file_log": { + "name": "file_log", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/logs.sql", + "original_file_path": "macros/edr/system/system_utils/logs.sql", + "unique_id": "macro.elementary.file_log", + "macro_sql": "{% macro file_log(msg) %}\n {% if execute %}\n {% do elementary.edr_log(msg, info=false) %}\n {% do elementary.debug_log(msg) %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_log", + "macro.elementary.debug_log" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.824529, + "supported_languages": null + }, + "macro.elementary.debug_log": { + "name": "debug_log", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/logs.sql", + "original_file_path": "macros/edr/system/system_utils/logs.sql", + "unique_id": "macro.elementary.debug_log", + "macro_sql": "{% macro debug_log(msg) %}\n {%- if execute %}\n {% set debug_logs_enabled = elementary.get_config_var('debug_logs') %}\n {% if debug_logs_enabled %}\n {{ elementary.edr_log(msg) }}\n {% endif %}\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.edr_log" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.824807, + "supported_languages": null + }, + "macro.elementary.test_log": { + "name": "test_log", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/logs.sql", + "original_file_path": "macros/edr/system/system_utils/logs.sql", + "unique_id": "macro.elementary.test_log", + "macro_sql": "{% macro test_log(msg_type, table_name, column_name=none) %}\n {%- if column_name %}\n {%- set start = 'Started running data monitors on: ' ~ table_name ~ ' ' ~ column_name %}\n {%- set end = 'Finished running data monitors on: ' ~ table_name ~ ' ' ~ column_name %}\n {%- else %}\n {%- set start = 'Started running data monitors on: ' ~ table_name %}\n {%- set end = 'Finished running data monitors on: ' ~ table_name %}\n {%- endif %}\n\n {%- if msg_type == 'start' %}\n {% do elementary.edr_log(start) %}\n {%- elif msg_type == 'end' %}\n {% do elementary.edr_log(end) %}\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_log" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.825453, + "supported_languages": null + }, + "macro.elementary.full_table_name": { + "name": "full_table_name", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/full_names.sql", + "original_file_path": "macros/edr/system/system_utils/full_names.sql", + "unique_id": "macro.elementary.full_table_name", + "macro_sql": "{% macro full_table_name(alias) -%}\n {% if alias is defined %}{%- set alias_dot = alias ~ '.' %}{% endif %}\n upper({{ alias_dot }}database_name || '.' || {{ alias_dot }}schema_name || '.' || {{ alias_dot }}table_name)\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.828384, + "supported_languages": null + }, + "macro.elementary.full_schema_name": { + "name": "full_schema_name", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/full_names.sql", + "original_file_path": "macros/edr/system/system_utils/full_names.sql", + "unique_id": "macro.elementary.full_schema_name", + "macro_sql": "{% macro full_schema_name() -%}\n upper(database_name || '.' || schema_name)\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8284612, + "supported_languages": null + }, + "macro.elementary.full_column_name": { + "name": "full_column_name", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/full_names.sql", + "original_file_path": "macros/edr/system/system_utils/full_names.sql", + "unique_id": "macro.elementary.full_column_name", + "macro_sql": "{% macro full_column_name() -%}\n upper(database_name || '.' || schema_name || '.' || table_name || '.' || column_name)\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.828532, + "supported_languages": null + }, + "macro.elementary.full_name_split": { + "name": "full_name_split", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/full_names.sql", + "original_file_path": "macros/edr/system/system_utils/full_names.sql", + "unique_id": "macro.elementary.full_name_split", + "macro_sql": "{% macro full_name_split(part_name) %}\n {{ adapter.dispatch('full_name_split','elementary')(part_name) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__full_name_split" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8286898, + "supported_languages": null + }, + "macro.elementary.default__full_name_split": { + "name": "default__full_name_split", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/full_names.sql", + "original_file_path": "macros/edr/system/system_utils/full_names.sql", + "unique_id": "macro.elementary.default__full_name_split", + "macro_sql": "{% macro default__full_name_split(part_name) %}\n {%- if part_name == 'database_name' -%}\n {%- set part_index = 0 -%}\n {%- elif part_name == 'schema_name' -%}\n {%- set part_index = 1 -%}\n {%- elif part_name == 'table_name' -%}\n {%- set part_index = 2 -%}\n {%- else -%}\n {{ return('') }}\n {%- endif -%}\n trim(split(full_table_name,'.')[{{ part_index }}],'\"') as {{ part_name }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8290958, + "supported_languages": null + }, + "macro.elementary.bigquery__full_name_split": { + "name": "bigquery__full_name_split", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/full_names.sql", + "original_file_path": "macros/edr/system/system_utils/full_names.sql", + "unique_id": "macro.elementary.bigquery__full_name_split", + "macro_sql": "{% macro bigquery__full_name_split(part_name) %}\n {%- if part_name == 'database_name' -%}\n {%- set part_index = 0 %}\n {%- elif part_name == 'schema_name' -%}\n {%- set part_index = 1 %}\n {%- elif part_name == 'table_name' -%}\n {%- set part_index = 2 -%}\n {%- else -%}\n {{ return('') }}\n {%- endif -%}\n trim(split(full_table_name,'.')[OFFSET({{ part_index }})],'\"') as {{ part_name }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.829507, + "supported_languages": null + }, + "macro.elementary.postgres__full_name_split": { + "name": "postgres__full_name_split", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/full_names.sql", + "original_file_path": "macros/edr/system/system_utils/full_names.sql", + "unique_id": "macro.elementary.postgres__full_name_split", + "macro_sql": "{% macro postgres__full_name_split(part_name) %}\n {%- if part_name == 'database_name' -%}\n {%- set part_index = 1 -%}\n {%- elif part_name == 'schema_name' -%}\n {%- set part_index = 2 -%}\n {%- elif part_name == 'table_name' -%}\n {%- set part_index = 3 -%}\n {%- else -%}\n {{ return('') }}\n {%- endif -%}\n trim(split_part(full_table_name,'.',{{ part_index }}),'\"') as {{ part_name }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.829914, + "supported_languages": null + }, + "macro.elementary.databricks__full_name_split": { + "name": "databricks__full_name_split", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/full_names.sql", + "original_file_path": "macros/edr/system/system_utils/full_names.sql", + "unique_id": "macro.elementary.databricks__full_name_split", + "macro_sql": "{% macro databricks__full_name_split(part_name) %}\n {%- if part_name == 'database_name' -%}\n {%- set part_index = 0 -%}\n {%- elif part_name == 'schema_name' -%}\n {%- set part_index = 1 -%}\n {%- elif part_name == 'table_name' -%}\n {%- set part_index = 2 -%}\n {%- else -%}\n {{ return('') }}\n {%- endif -%}\n trim('\"' from split(full_table_name,'[.]')[{{ part_index }}]) as {{ part_name }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.830315, + "supported_languages": null + }, + "macro.elementary.relation_to_full_name": { + "name": "relation_to_full_name", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/full_names.sql", + "original_file_path": "macros/edr/system/system_utils/full_names.sql", + "unique_id": "macro.elementary.relation_to_full_name", + "macro_sql": "{% macro relation_to_full_name(relation) %}\n {%- if relation.is_cte %}\n {# Ephemeral models don't have db and schema #}\n {%- set full_table_name = relation.identifier | upper %}\n {%- elif relation.database %}\n {%- set full_table_name = relation.database | upper ~'.'~ relation.schema | upper ~'.'~ relation.identifier | upper %}\n {%- else %}\n {# Databricks doesn't always have a database #}\n {%- set full_table_name = relation.schema | upper ~'.'~ relation.identifier | upper %}\n {%- endif %}\n {{ return(full_table_name) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.830814, + "supported_languages": null + }, + "macro.elementary.model_node_to_full_name": { + "name": "model_node_to_full_name", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/full_names.sql", + "original_file_path": "macros/edr/system/system_utils/full_names.sql", + "unique_id": "macro.elementary.model_node_to_full_name", + "macro_sql": "{% macro model_node_to_full_name(model_node) %}\n {% set identifier = model_node.identifier or model_node.alias %}\n {%- if model_node.database %}\n {%- set full_table_name = model_node.database | upper ~'.'~ model_node.schema | upper ~'.'~ identifier | upper %}\n {%- else %}\n {# Databricks doesn't always have a database #}\n {%- set full_table_name = model_node.schema | upper ~'.'~ identifier | upper %}\n {%- endif %}\n {{ return(full_table_name) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.831269, + "supported_languages": null + }, + "macro.elementary.configured_schemas_from_graph_as_tuple": { + "name": "configured_schemas_from_graph_as_tuple", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/system/system_utils/full_names.sql", + "original_file_path": "macros/edr/system/system_utils/full_names.sql", + "unique_id": "macro.elementary.configured_schemas_from_graph_as_tuple", + "macro_sql": "{% macro configured_schemas_from_graph_as_tuple() %}\n\n {%- set configured_schema_tuples = elementary.get_configured_schemas_from_graph() %}\n {%- set schemas_list = [] %}\n\n {%- for configured_schema_tuple in configured_schema_tuples %}\n {%- set database_name, schema_name = configured_schema_tuple %}\n {%- set full_schema_name = database_name | upper ~ '.' ~ schema_name | upper %}\n {%- do schemas_list.append(full_schema_name) -%}\n {%- endfor %}\n\n {% set schemas_tuple = elementary.strings_list_to_tuple(schemas_list) %}\n {{ return(schemas_tuple) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_configured_schemas_from_graph", + "macro.elementary.strings_list_to_tuple" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8317661, + "supported_languages": null + }, + "macro.elementary.get_columns_by_schemas": { + "name": "get_columns_by_schemas", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_columns_by_schemas.sql", + "original_file_path": "macros/edr/metadata_collection/get_columns_by_schemas.sql", + "unique_id": "macro.elementary.get_columns_by_schemas", + "macro_sql": "{% macro get_columns_by_schemas(configured_schemas) %}\n {%- if configured_schemas | length > 0 -%}\n {{ elementary.union_macro_queries(configured_schemas, elementary.get_columns_from_information_schema) }}\n {%- else %}\n {{ elementary.get_empty_columns_from_information_schema_table() }}\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.union_macro_queries", + "macro.elementary.get_empty_columns_from_information_schema_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.832108, + "supported_languages": null + }, + "macro.elementary.get_columns_from_information_schema": { + "name": "get_columns_from_information_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "unique_id": "macro.elementary.get_columns_from_information_schema", + "macro_sql": "{% macro get_columns_from_information_schema(schema_tuple, table_name = none) %}\n {%- set database_name, schema_name = schema_tuple %}\n {{ return(adapter.dispatch('get_columns_from_information_schema', 'elementary')(database_name, schema_name, table_name)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__get_columns_from_information_schema" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.834068, + "supported_languages": null + }, + "macro.elementary.default__get_columns_from_information_schema": { + "name": "default__get_columns_from_information_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "unique_id": "macro.elementary.default__get_columns_from_information_schema", + "macro_sql": "{% macro default__get_columns_from_information_schema(database_name, schema_name, table_name = none) %}\n {% set schema_relation = api.Relation.create(database=database_name, schema=schema_name).without_identifier() %}\n {% set column_relation = schema_relation.information_schema('COLUMNS') %}\n select\n upper(table_catalog || '.' || table_schema || '.' || table_name) as full_table_name,\n upper(table_catalog) as database_name,\n upper(table_schema) as schema_name,\n upper(table_name) as table_name,\n upper(column_name) as column_name,\n data_type\n from {{ column_relation }}\n where upper(table_schema) = upper('{{ schema_name }}')\n {% if table_name %}\n and upper(table_name) = upper('{{ table_name }}')\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.834492, + "supported_languages": null + }, + "macro.elementary.bigquery__get_columns_from_information_schema": { + "name": "bigquery__get_columns_from_information_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "unique_id": "macro.elementary.bigquery__get_columns_from_information_schema", + "macro_sql": "{% macro bigquery__get_columns_from_information_schema(database_name, schema_name, table_name = none) %}\n {% set schema_relation = api.Relation.create(database=database_name, schema=schema_name).without_identifier() %}\n {% set columns_schema = schema_relation.information_schema('COLUMNS') %}\n {% if elementary.can_query_relation(columns_schema) %}\n {{ elementary.default__get_columns_from_information_schema(database_name, schema_name, table_name) }}\n {% else %}\n {{ elementary.get_empty_columns_from_information_schema_table() }}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.can_query_relation", + "macro.elementary.default__get_columns_from_information_schema", + "macro.elementary.get_empty_columns_from_information_schema_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.835043, + "supported_languages": null + }, + "macro.elementary.redshift__get_columns_from_information_schema": { + "name": "redshift__get_columns_from_information_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "unique_id": "macro.elementary.redshift__get_columns_from_information_schema", + "macro_sql": "{% macro redshift__get_columns_from_information_schema(database_name, schema_name, table_name = none) %}\n select\n upper(table_catalog || '.' || table_schema || '.' || table_name) as full_table_name,\n upper(table_catalog) as database_name,\n upper(table_schema) as schema_name,\n upper(table_name) as table_name,\n upper(column_name) as column_name,\n data_type\n from pg_catalog.svv_columns\n where upper(table_schema) = upper('{{ schema_name }}')\n {% if table_name %}\n and upper(table_name) = upper('{{ table_name }}')\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.835265, + "supported_languages": null + }, + "macro.elementary.postgres__get_columns_from_information_schema": { + "name": "postgres__get_columns_from_information_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "unique_id": "macro.elementary.postgres__get_columns_from_information_schema", + "macro_sql": "{% macro postgres__get_columns_from_information_schema(database_name, schema_name, table_name = none) %}\n select\n upper(table_catalog || '.' || table_schema || '.' || table_name) as full_table_name,\n upper(table_catalog) as database_name,\n upper(table_schema) as schema_name,\n upper(table_name) as table_name,\n upper(column_name) as column_name,\n data_type\n from information_schema.columns\n where upper(table_schema) = upper('{{ schema_name }}')\n {% if table_name %}\n and upper(table_name) = upper('{{ table_name }}')\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.83548, + "supported_languages": null + }, + "macro.elementary.databricks__get_columns_from_information_schema": { + "name": "databricks__get_columns_from_information_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "unique_id": "macro.elementary.databricks__get_columns_from_information_schema", + "macro_sql": "{% macro databricks__get_columns_from_information_schema(database_name, schema_name, table_name = none) %}\n {% if target.catalog is none %}\n {# Information schema is only available when using Unity Catalog. #}\n {% do return(elementary.get_empty_columns_from_information_schema_table()) %}\n {% endif %}\n {% set column_relation = api.Relation.create('system', 'information_schema', 'columns') %}\n select\n upper(table_catalog || '.' || table_schema || '.' || table_name) as full_table_name,\n upper(table_catalog) as database_name,\n upper(table_schema) as schema_name,\n upper(table_name) as table_name,\n upper(column_name) as column_name,\n data_type\n from {{ column_relation }}\n where upper(table_schema) = upper('{{ schema_name }}')\n {% if table_name %}\n and upper(table_name) = upper('{{ table_name }}')\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_empty_columns_from_information_schema_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.835953, + "supported_languages": null + }, + "macro.elementary.spark__get_columns_from_information_schema": { + "name": "spark__get_columns_from_information_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "unique_id": "macro.elementary.spark__get_columns_from_information_schema", + "macro_sql": "{% macro spark__get_columns_from_information_schema(database_name, schema_name, table_name = none) %}\n {{ elementary.get_empty_columns_from_information_schema_table() }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_empty_columns_from_information_schema_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.836107, + "supported_languages": null + }, + "macro.elementary.get_empty_columns_from_information_schema_table": { + "name": "get_empty_columns_from_information_schema_table", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "unique_id": "macro.elementary.get_empty_columns_from_information_schema_table", + "macro_sql": "{% macro get_empty_columns_from_information_schema_table() %}\n {{ elementary.empty_table([('full_table_name', 'string'), ('database_name', 'string'), ('schema_name', 'string'), ('table_name', 'string'), ('column_name', 'string'), ('data_type', 'string')]) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.836449, + "supported_languages": null + }, + "macro.elementary.athena__get_columns_from_information_schema": { + "name": "athena__get_columns_from_information_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_columns_from_information_schema.sql", + "unique_id": "macro.elementary.athena__get_columns_from_information_schema", + "macro_sql": "{% macro athena__get_columns_from_information_schema(database_name, schema_name, table_name = none) %}\n {{ elementary.empty_table([('full_table_name', 'string'), ('database_name', 'string'), ('schema_name', 'string'), ('table_name', 'string'), ('column_name', 'string'), ('data_type', 'string')]) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8368268, + "supported_languages": null + }, + "macro.elementary.get_columns_in_project": { + "name": "get_columns_in_project", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_columns_in_project.sql", + "original_file_path": "macros/edr/metadata_collection/get_columns_in_project.sql", + "unique_id": "macro.elementary.get_columns_in_project", + "macro_sql": "{% macro get_columns_in_project() %}\n {% set configured_schemas = elementary.get_configured_schemas_from_graph() %}\n {{ elementary.get_columns_by_schemas(configured_schemas) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_configured_schemas_from_graph", + "macro.elementary.get_columns_by_schemas" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8370528, + "supported_languages": null + }, + "macro.elementary.get_tables_from_information_schema": { + "name": "get_tables_from_information_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_tables_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_tables_from_information_schema.sql", + "unique_id": "macro.elementary.get_tables_from_information_schema", + "macro_sql": "{% macro get_tables_from_information_schema(schema_tuple) %}\n {{ return(adapter.dispatch('get_tables_from_information_schema','elementary')(schema_tuple)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__get_tables_from_information_schema" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.839197, + "supported_languages": null + }, + "macro.elementary.default__get_tables_from_information_schema": { + "name": "default__get_tables_from_information_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_tables_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_tables_from_information_schema.sql", + "unique_id": "macro.elementary.default__get_tables_from_information_schema", + "macro_sql": "{% macro default__get_tables_from_information_schema(schema_tuple) %}\n {%- set database_name, schema_name = schema_tuple %}\n {% set schema_relation = api.Relation.create(database=database_name, schema=schema_name).without_identifier() %}\n\n with information_schema_tables as (\n\n select\n upper(table_catalog) as database_name,\n upper(table_schema) as schema_name,\n upper(table_name) as table_name\n from {{ schema_relation.information_schema('TABLES') }}\n where upper(table_schema) = upper('{{ schema_name }}')\n\n ),\n\n information_schema_schemata as (\n\n select\n upper(catalog_name) as database_name,\n upper(schema_name) as schema_name\n from {{ schema_relation.information_schema('SCHEMATA') }}\n where upper(schema_name) = upper('{{ schema_name }}')\n\n )\n\n select\n case when tables.table_name is not null\n then {{ elementary.full_table_name('TABLES') }}\n else null end as full_table_name,\n upper(schemas.database_name || '.' || schemas.schema_name) as full_schema_name,\n schemas.database_name as database_name,\n schemas.schema_name as schema_name,\n tables.table_name\n from information_schema_tables as tables\n full outer join information_schema_schemata as schemas\n on (tables.database_name = schemas.database_name and tables.schema_name = schemas.schema_name)\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.full_table_name" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.839684, + "supported_languages": null + }, + "macro.elementary.redshift__get_tables_from_information_schema": { + "name": "redshift__get_tables_from_information_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_tables_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_tables_from_information_schema.sql", + "unique_id": "macro.elementary.redshift__get_tables_from_information_schema", + "macro_sql": "{% macro redshift__get_tables_from_information_schema(schema_tuple) %}\n {%- set database_name, schema_name = schema_tuple %}\n\n with information_schema_tables as (\n\n select\n upper(table_catalog) as database_name,\n upper(table_schema) as schema_name,\n upper(table_name) as table_name\n from pg_catalog.svv_tables\n where upper(table_schema) = upper('{{ schema_name }}') and upper(table_catalog) = upper('{{ database_name }}')\n\n )\n\n select\n {{ elementary.full_table_name() }} as full_table_name,\n upper(database_name || '.' || schema_name) as full_schema_name,\n database_name,\n schema_name,\n table_name\n from information_schema_tables\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.full_table_name" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.839921, + "supported_languages": null + }, + "macro.elementary.postgres__get_tables_from_information_schema": { + "name": "postgres__get_tables_from_information_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_tables_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_tables_from_information_schema.sql", + "unique_id": "macro.elementary.postgres__get_tables_from_information_schema", + "macro_sql": "{% macro postgres__get_tables_from_information_schema(schema_tuple) %}\n {%- set database_name, schema_name = schema_tuple %}\n\n with information_schema_tables as (\n\n select\n upper(table_catalog) as database_name,\n upper(table_schema) as schema_name,\n upper(table_name) as table_name\n from information_schema.tables\n where upper(table_schema) = upper('{{ schema_name }}') and upper(table_catalog) = upper('{{ database_name }}')\n\n )\n\n select\n {{ elementary.full_table_name() }} as full_table_name,\n upper(database_name || '.' || schema_name) as full_schema_name,\n database_name,\n schema_name,\n table_name\n from information_schema_tables\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.full_table_name" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.840152, + "supported_languages": null + }, + "macro.elementary.databricks__get_tables_from_information_schema": { + "name": "databricks__get_tables_from_information_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_tables_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_tables_from_information_schema.sql", + "unique_id": "macro.elementary.databricks__get_tables_from_information_schema", + "macro_sql": "{% macro databricks__get_tables_from_information_schema(schema_tuple) %}\n {%- set database_name, schema_name = schema_tuple %}\n {% set schema_relation = api.Relation.create(database=database_name, schema=schema_name).without_identifier() %}\n\n {#\n Database only exists when using databricks with catalog (it is the catalog).\n When using databricks without catalog, it is none.\n #}\n {% set is_catalog = schema_relation.database is not none %}\n\n {# Information schema only exists on databricks with catalog #}\n {% if is_catalog %}\n with information_schema_tables as (\n\n select\n upper(table_catalog) as database_name,\n upper(table_schema) as schema_name,\n upper(table_name) as table_name\n from {{ schema_relation.information_schema('TABLES') }}\n where upper(table_schema) = upper('{{ schema_name }}')\n\n ),\n\n information_schema_schemata as (\n\n select\n upper(catalog_name) as database_name,\n upper(schema_name) as schema_name\n from {{ schema_relation.information_schema('SCHEMATA') }}\n where upper(schema_name) = upper('{{ schema_name }}')\n\n )\n\n select\n case when tables.table_name is not null\n then {{ elementary.full_table_name('TABLES') }}\n else null end as full_table_name,\n upper(schemas.database_name || '.' || schemas.schema_name) as full_schema_name,\n schemas.database_name as database_name,\n schemas.schema_name as schema_name,\n tables.table_name\n from information_schema_tables as tables\n full outer join information_schema_schemata as schemas\n on (tables.database_name = schemas.database_name and tables.schema_name = schemas.schema_name)\n {% else %}\n {{ elementary.get_empty_tables_from_information_schema_table() }}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.full_table_name", + "macro.elementary.get_empty_tables_from_information_schema_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.84081, + "supported_languages": null + }, + "macro.elementary.get_empty_tables_from_information_schema_table": { + "name": "get_empty_tables_from_information_schema_table", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/metadata_collection/get_tables_from_information_schema.sql", + "original_file_path": "macros/edr/metadata_collection/get_tables_from_information_schema.sql", + "unique_id": "macro.elementary.get_empty_tables_from_information_schema_table", + "macro_sql": "{% macro get_empty_tables_from_information_schema_table() %}\n {{ elementary.empty_table([\n ('full_table_name', 'string'),\n ('full_schema_name', 'string'),\n ('database_name', 'string'),\n ('schema_name', 'string'),\n ('table_name', 'string'),\n ]) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.841133, + "supported_languages": null + }, + "macro.elementary.upload_dbt_snapshots": { + "name": "upload_dbt_snapshots", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_snapshots.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_snapshots.sql", + "unique_id": "macro.elementary.upload_dbt_snapshots", + "macro_sql": "{%- macro upload_dbt_snapshots(should_commit=false, metadata_hashes=none) -%}\n {% set relation = elementary.get_elementary_relation('dbt_snapshots') %}\n {% if execute and relation %}\n {% set snapshots = graph.nodes.values() | selectattr('resource_type', '==', 'snapshot') %}\n {% do elementary.upload_artifacts_to_table(relation, snapshots, elementary.flatten_model, should_commit=should_commit, metadata_hashes=metadata_hashes) %}\n {%- endif -%}\n {{- return('') -}}\n{%- endmacro -%}", + "depends_on": { + "macros": [ + "macro.elementary.get_elementary_relation", + "macro.elementary.upload_artifacts_to_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.841748, + "supported_languages": null + }, + "macro.elementary.upload_dbt_sources": { + "name": "upload_dbt_sources", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_sources.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_sources.sql", + "unique_id": "macro.elementary.upload_dbt_sources", + "macro_sql": "{%- macro upload_dbt_sources(should_commit=false, metadata_hashes=none) -%}\n {% set relation = elementary.get_elementary_relation('dbt_sources') %}\n {% if execute and relation %}\n {% set sources = graph.sources.values() | selectattr('resource_type', '==', 'source') %}\n {% do elementary.upload_artifacts_to_table(relation, sources, elementary.flatten_source, should_commit=should_commit, metadata_hashes=metadata_hashes) %}\n {%- endif -%}\n {{- return('') -}}\n{%- endmacro -%}\n\n\n\n", + "depends_on": { + "macros": [ + "macro.elementary.get_elementary_relation", + "macro.elementary.upload_artifacts_to_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.848222, + "supported_languages": null + }, + "macro.elementary.get_dbt_sources_empty_table_query": { + "name": "get_dbt_sources_empty_table_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_sources.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_sources.sql", + "unique_id": "macro.elementary.get_dbt_sources_empty_table_query", + "macro_sql": "{% macro get_dbt_sources_empty_table_query() %}\n {% set dbt_sources_empty_table_query = elementary.empty_table([('unique_id', 'string'),\n ('database_name', 'string'),\n ('schema_name', 'string'),\n ('source_name', 'string'),\n ('name', 'string'),\n ('identifier', 'string'),\n ('loaded_at_field', 'string'),\n ('freshness_warn_after', 'string'),\n ('freshness_error_after', 'string'),\n ('freshness_filter', 'long_string'),\n ('freshness_description', 'long_string'),\n ('relation_name', 'string'),\n ('tags', 'long_string'),\n ('meta', 'long_string'),\n ('owner', 'string'),\n ('package_name', 'string'),\n ('original_path', 'long_string'),\n ('path', 'string'),\n ('source_description', 'long_string'),\n ('description', 'long_string'),\n ('generated_at', 'string'),\n ('metadata_hash', 'string'),\n ]) %}\n {{ return(dbt_sources_empty_table_query) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8492959, + "supported_languages": null + }, + "macro.elementary.flatten_source": { + "name": "flatten_source", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_sources.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_sources.sql", + "unique_id": "macro.elementary.flatten_source", + "macro_sql": "{% macro flatten_source(node_dict) %}\n {% set freshness_dict = elementary.safe_get_with_default(node_dict, 'freshness', {}) %}\n {% set config_dict = elementary.safe_get_with_default(node_dict, 'config', {}) %}\n {% set config_meta_dict = elementary.safe_get_with_default(config_dict, 'meta', {}) %}\n {% set source_meta_dict = elementary.safe_get_with_default(node_dict, 'source_meta', {}) %}\n {% set meta_dict = elementary.safe_get_with_default(node_dict, 'meta', {}) %}\n {% do meta_dict.update(source_meta_dict) %}\n {% do meta_dict.update(config_meta_dict) %}\n {% set formatted_owner = [] %}\n {% set raw_owner = meta_dict.get('owner') or config_dict.get('owner') %}\n {% if raw_owner is string %}\n {% set owners = raw_owner.split(',') %}\n {% for owner in owners %}\n {% do formatted_owner.append(owner | trim) %} \n {% endfor %}\n {% elif raw_owner is iterable %}\n {% do formatted_owner.extend(raw_owner) %}\n {% endif %}\n {% set config_tags = elementary.safe_get_with_default(config_dict, 'tags', []) %}\n {% set global_tags = elementary.safe_get_with_default(node_dict, 'tags', []) %}\n {% set meta_tags = elementary.safe_get_with_default(meta_dict, 'tags', []) %}\n {% set tags = elementary.union_lists(config_tags, global_tags) %}\n {% set tags = elementary.union_lists(tags, meta_tags) %}\n {% set flatten_source_metadata_dict = {\n 'unique_id': node_dict.get('unique_id'),\n 'database_name': node_dict.get('database'),\n 'schema_name': node_dict.get('schema'),\n 'source_name': node_dict.get('source_name'),\n 'name': node_dict.get('name'),\n 'identifier': node_dict.get('identifier'),\n 'loaded_at_field': node_dict.get('loaded_at_field'),\n 'freshness_warn_after': freshness_dict.get('warn_after', {}),\n 'freshness_error_after': freshness_dict.get('error_after', {}),\n 'freshness_filter': freshness_dict.get('filter'),\n 'freshness_description': elementary.get_source_freshness_description(),\n 'relation_name': node_dict.get('relation_name'),\n 'tags': elementary.filter_none_and_sort(tags),\n 'meta': meta_dict,\n 'owner': formatted_owner,\n 'package_name': node_dict.get('package_name'),\n 'original_path': node_dict.get('original_file_path'),\n 'path': node_dict.get('path'),\n 'source_description': node_dict.get('source_description'),\n 'description': node_dict.get('description'),\n 'generated_at': elementary.datetime_now_utc_as_string()\n }%}\n {% do flatten_source_metadata_dict.update({\"metadata_hash\": elementary.get_artifact_metadata_hash(flatten_source_metadata_dict)}) %}\n {{ return(flatten_source_metadata_dict) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.safe_get_with_default", + "macro.elementary.union_lists", + "macro.elementary.get_source_freshness_description", + "macro.elementary.filter_none_and_sort", + "macro.elementary.datetime_now_utc_as_string", + "macro.elementary.get_artifact_metadata_hash" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.852149, + "supported_languages": null + }, + "macro.elementary.get_source_freshness_description": { + "name": "get_source_freshness_description", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_sources.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_sources.sql", + "unique_id": "macro.elementary.get_source_freshness_description", + "macro_sql": "{% macro get_source_freshness_description() %}\n {% do return(\"Source freshness validates if the time elapsed between the test execution to the latest record is above an acceptable SLA threshold.\") %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.852288, + "supported_languages": null + }, + "macro.elementary.upload_dbt_models": { + "name": "upload_dbt_models", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_models.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_models.sql", + "unique_id": "macro.elementary.upload_dbt_models", + "macro_sql": "{%- macro upload_dbt_models(should_commit=false, metadata_hashes=none) -%}\n {% set relation = elementary.get_elementary_relation('dbt_models') %}\n {% if execute and relation %}\n {% set models = graph.nodes.values() | selectattr('resource_type', '==', 'model') %}\n {% do elementary.upload_artifacts_to_table(relation, models, elementary.flatten_model, should_commit=should_commit, metadata_hashes=metadata_hashes) %}\n {%- endif -%}\n {{- return('') -}}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.get_elementary_relation", + "macro.elementary.upload_artifacts_to_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.855576, + "supported_languages": null + }, + "macro.elementary.get_dbt_models_empty_table_query": { + "name": "get_dbt_models_empty_table_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_models.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_models.sql", + "unique_id": "macro.elementary.get_dbt_models_empty_table_query", + "macro_sql": "{% macro get_dbt_models_empty_table_query() %}\n {% set columns = [\n ('unique_id', 'string'),\n ('alias', 'string'),\n ('checksum', 'string'),\n ('materialization', 'string'),\n ('tags', 'long_string'),\n ('meta', 'long_string'),\n ('owner', 'string'),\n ('database_name', 'string'),\n ('schema_name', 'string'),\n ('depends_on_macros', 'long_string'),\n ('depends_on_nodes', 'long_string'),\n ('description', 'long_string'),\n ('name', 'string'),\n ('package_name', 'string'),\n ('original_path', 'long_string'),\n ('path', 'string'),\n ('patch_path', 'string'),\n ('generated_at', 'string'),\n ('metadata_hash', 'string'),\n ] %}\n {% if target.type == \"bigquery\" or elementary.get_config_var(\"include_other_warehouse_specific_columns\") %}\n {% do columns.extend([('bigquery_partition_by', 'string')]) %}\n {% endif %}\n\n {% set dbt_models_empty_table_query = elementary.empty_table(columns) %}\n {{ return(dbt_models_empty_table_query) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.856708, + "supported_languages": null + }, + "macro.elementary.flatten_model": { + "name": "flatten_model", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_models.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_models.sql", + "unique_id": "macro.elementary.flatten_model", + "macro_sql": "{% macro flatten_model(node_dict) %}\n {% set checksum_dict = elementary.safe_get_with_default(node_dict, 'checksum', {}) %}\n {% set config_dict = elementary.safe_get_with_default(node_dict, 'config', {}) %}\n {% set depends_on_dict = elementary.safe_get_with_default(node_dict, 'depends_on', {}) %}\n\n {% set config_meta_dict = elementary.safe_get_with_default(config_dict, 'meta', {}) %}\n {% set meta_dict = elementary.safe_get_with_default(node_dict, 'meta', {}) %}\n {% do meta_dict.update(config_meta_dict) %}\n {% set formatted_owner = [] %}\n {% set raw_owner = meta_dict.get('owner') or config_dict.get('owner') %}\n {% if raw_owner is string %}\n {% set owners = raw_owner.split(',') %}\n {% for owner in owners %}\n {% do formatted_owner.append(owner | trim) %} \n {% endfor %}\n {% elif raw_owner is iterable %}\n {% do formatted_owner.extend(raw_owner) %}\n {% endif %}\n {% set config_tags = elementary.safe_get_with_default(config_dict, 'tags', []) %}\n {% set global_tags = elementary.safe_get_with_default(node_dict, 'tags', []) %}\n {% set meta_tags = elementary.safe_get_with_default(meta_dict, 'tags', []) %}\n {% set tags = elementary.union_lists(config_tags, global_tags) %}\n {% set tags = elementary.union_lists(tags, meta_tags) %}\n\n {% set flatten_model_metadata_dict = {\n 'unique_id': node_dict.get('unique_id'),\n 'alias': node_dict.get('alias'),\n 'checksum': checksum_dict.get('checksum'),\n 'materialization': config_dict.get('materialized'),\n 'tags': elementary.filter_none_and_sort(tags),\n 'meta': meta_dict,\n 'owner': elementary.filter_none_and_sort(formatted_owner),\n 'database_name': node_dict.get('database'),\n 'schema_name': node_dict.get('schema'),\n 'depends_on_macros': elementary.filter_none_and_sort(depends_on_dict.get('macros', [])),\n 'depends_on_nodes': elementary.filter_none_and_sort(depends_on_dict.get('nodes', [])),\n 'description': node_dict.get('description'),\n 'name': node_dict.get('name'),\n 'package_name': node_dict.get('package_name'),\n 'original_path': node_dict.get('original_file_path'),\n 'path': node_dict.get('path'),\n 'patch_path': node_dict.get('patch_path'),\n 'generated_at': elementary.datetime_now_utc_as_string(),\n 'bigquery_partition_by': config_dict.get(\"partition_by\"),\n } %}\n {% do flatten_model_metadata_dict.update({\"metadata_hash\": elementary.get_artifact_metadata_hash(flatten_model_metadata_dict)}) %}\n {{ return(flatten_model_metadata_dict) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.safe_get_with_default", + "macro.elementary.union_lists", + "macro.elementary.filter_none_and_sort", + "macro.elementary.datetime_now_utc_as_string", + "macro.elementary.get_artifact_metadata_hash" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8595781, + "supported_languages": null + }, + "macro.elementary.upload_dbt_seeds": { + "name": "upload_dbt_seeds", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_seeds.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_seeds.sql", + "unique_id": "macro.elementary.upload_dbt_seeds", + "macro_sql": "{%- macro upload_dbt_seeds(should_commit=false, metadata_hashes=none) -%}\n {% set relation = elementary.get_elementary_relation('dbt_seeds') %}\n {% if execute and relation %}\n {% set seeds = graph.nodes.values() | selectattr('resource_type', '==', 'seed') %}\n {% do elementary.upload_artifacts_to_table(relation, seeds, elementary.flatten_seed, should_commit=should_commit, metadata_hashes=metadata_hashes) %}\n {%- endif -%}\n {{- return('') -}}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.get_elementary_relation", + "macro.elementary.upload_artifacts_to_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8641, + "supported_languages": null + }, + "macro.elementary.get_dbt_seeds_empty_table_query": { + "name": "get_dbt_seeds_empty_table_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_seeds.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_seeds.sql", + "unique_id": "macro.elementary.get_dbt_seeds_empty_table_query", + "macro_sql": "{% macro get_dbt_seeds_empty_table_query() %}\n {% set dbt_seeds_empty_table_query = elementary.empty_table([('unique_id', 'string'),\n ('alias', 'string'),\n ('checksum', 'string'),\n ('tags', 'long_string'),\n ('meta', 'long_string'),\n ('owner', 'string'),\n ('database_name', 'string'),\n ('schema_name', 'string'),\n ('description', 'long_string'),\n ('name', 'string'),\n ('package_name', 'string'),\n ('original_path', 'long_string'),\n ('path', 'string'),\n ('generated_at', 'string'),\n ('metadata_hash', 'string'),\n ]) %}\n {{ return(dbt_seeds_empty_table_query) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.864851, + "supported_languages": null + }, + "macro.elementary.flatten_seed": { + "name": "flatten_seed", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_seeds.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_seeds.sql", + "unique_id": "macro.elementary.flatten_seed", + "macro_sql": "{% macro flatten_seed(node_dict) %}\n {% set checksum_dict = elementary.safe_get_with_default(node_dict, 'checksum', {}) %}\n {% set config_dict = elementary.safe_get_with_default(node_dict, 'config', {}) %}\n {% set depends_on_dict = elementary.safe_get_with_default(node_dict, 'depends_on', {}) %}\n\n {% set config_meta_dict = elementary.safe_get_with_default(config_dict, 'meta', {}) %}\n {% set meta_dict = elementary.safe_get_with_default(node_dict, 'meta', {}) %}\n {% do meta_dict.update(config_meta_dict) %}\n {% set formatted_owner = [] %}\n {% set raw_owner = meta_dict.get('owner') or config_dict.get('owner') %}\n {% if raw_owner is string %}\n {% set owners = raw_owner.split(',') %}\n {% for owner in owners %}\n {% do formatted_owner.append(owner | trim) %}\n {% endfor %}\n {% elif raw_owner is iterable %}\n {% do formatted_owner.extend(raw_owner) %}\n {% endif %}\n {% set config_tags = elementary.safe_get_with_default(config_dict, 'tags', []) %}\n {% set global_tags = elementary.safe_get_with_default(node_dict, 'tags', []) %}\n {% set meta_tags = elementary.safe_get_with_default(meta_dict, 'tags', []) %}\n {% set tags = elementary.union_lists(config_tags, global_tags) %}\n {% set tags = elementary.union_lists(tags, meta_tags) %}\n\n {% set flatten_seed_metadata_dict = {\n 'unique_id': node_dict.get('unique_id'),\n 'alias': node_dict.get('alias'),\n 'checksum': checksum_dict.get('checksum'),\n 'tags': elementary.filter_none_and_sort(tags),\n 'meta': meta_dict,\n 'owner': elementary.filter_none_and_sort(formatted_owner),\n 'database_name': node_dict.get('database'),\n 'schema_name': node_dict.get('schema'),\n 'description': node_dict.get('description'),\n 'name': node_dict.get('name'),\n 'package_name': node_dict.get('package_name'),\n 'original_path': node_dict.get('original_file_path'),\n 'path': node_dict.get('path'),\n 'generated_at': elementary.datetime_now_utc_as_string()\n }%}\n {% do flatten_seed_metadata_dict.update({\"metadata_hash\": elementary.get_artifact_metadata_hash(flatten_seed_metadata_dict)}) %}\n {{ return(flatten_seed_metadata_dict) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.safe_get_with_default", + "macro.elementary.union_lists", + "macro.elementary.filter_none_and_sort", + "macro.elementary.datetime_now_utc_as_string", + "macro.elementary.get_artifact_metadata_hash" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.867274, + "supported_languages": null + }, + "macro.elementary.upload_dbt_invocation": { + "name": "upload_dbt_invocation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.upload_dbt_invocation", + "macro_sql": "{% macro upload_dbt_invocation() %}\n {% set relation = elementary.get_elementary_relation('dbt_invocations') %}\n {% if not execute or not relation %}\n {{ return('') }}\n {% endif %}\n\n {% do elementary.file_log(\"Uploading dbt invocation.\") %}\n {% set now_str = elementary.datetime_now_utc_as_string() %}\n {% set orchestrator = elementary.get_orchestrator() %}\n {% set job_id = elementary.get_var(\"job_id\", [\"JOB_ID\", \"DBT_JOB_ID\", \"DBT_CLOUD_JOB_ID\"]) %}\n {% set job_run_id = elementary.get_var(\"job_run_id\", [\"DBT_JOB_RUN_ID\", \"DBT_CLOUD_RUN_ID\", \"GITHUB_RUN_ID\"]) %}\n {% set dbt_invocation = {\n 'invocation_id': invocation_id,\n 'run_started_at': elementary.run_started_at_as_string(),\n 'run_completed_at': now_str,\n 'generated_at': now_str,\n 'command': flags.WHICH,\n 'dbt_version': dbt_version,\n 'elementary_version': elementary.get_elementary_package_version(),\n 'full_refresh': flags.FULL_REFRESH,\n 'invocation_vars': elementary.get_invocation_vars(),\n 'vars': elementary.get_all_vars(),\n 'target_name': target.name,\n 'target_database': elementary.target_database(),\n 'target_schema': target.schema,\n 'target_profile_name': target.profile_name,\n 'threads': target.threads,\n 'selected': elementary.get_invocation_select_filter(),\n 'yaml_selector': elementary.get_invocation_yaml_selector(),\n 'project_name': elementary.get_project_name(),\n 'job_id': job_id,\n 'job_run_id': job_run_id,\n 'job_name': elementary.get_var(\"job_name\", [\"JOB_NAME\", \"DBT_JOB_NAME\"]),\n 'env': elementary.get_first_env_var([\"DBT_ENV\"]),\n 'env_id': elementary.get_first_env_var([\"DBT_ENV_ID\"]),\n 'project_id': elementary.get_first_env_var([\"DBT_PROJECT_ID\", \"DBT_CLOUD_PROJECT_ID\", \"GITHUB_REPOSITORY\"]),\n 'cause_category': elementary.get_first_env_var([\"DBT_CAUSE_CATEGORY\", \"DBT_CLOUD_RUN_REASON_CATEGORY\", \"GITHUB_EVENT_NAME\"]),\n 'cause': elementary.get_first_env_var([\"DBT_CAUSE\", \"DBT_CLOUD_RUN_REASON\"]),\n 'pull_request_id': elementary.get_first_env_var([\"DBT_PULL_REQUEST_ID\", \"DBT_CLOUD_PR_ID\", \"GITHUB_HEAD_REF\"]),\n 'git_sha': elementary.get_first_env_var([\"DBT_GIT_SHA\", \"DBT_CLOUD_GIT_SHA\", \"GITHUB_SHA\"]),\n 'orchestrator': orchestrator,\n 'dbt_user': elementary.get_first_env_var([\"DBT_USER\"]),\n 'job_url': elementary.get_job_url(orchestrator, job_id),\n 'job_run_url': elementary.get_job_run_url(orchestrator, job_id, job_run_id),\n 'account_id': elementary.get_var(\"account_id\", [\"DBT_ACCOUNT_ID\"]),\n 'target_adapter_specific_fields': elementary.get_target_adapter_specific_fields()\n } %}\n {% do elementary.insert_rows(relation, [dbt_invocation], should_commit=true) %}\n {% do elementary.file_log(\"Uploaded dbt invocation successfully.\") %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_elementary_relation", + "macro.elementary.file_log", + "macro.elementary.datetime_now_utc_as_string", + "macro.elementary.get_orchestrator", + "macro.elementary.get_var", + "macro.elementary.run_started_at_as_string", + "macro.elementary.get_elementary_package_version", + "macro.elementary.get_invocation_vars", + "macro.elementary.get_all_vars", + "macro.elementary.target_database", + "macro.elementary.get_invocation_select_filter", + "macro.elementary.get_invocation_yaml_selector", + "macro.elementary.get_project_name", + "macro.elementary.get_first_env_var", + "macro.elementary.get_job_url", + "macro.elementary.get_job_run_url", + "macro.elementary.get_target_adapter_specific_fields", + "macro.elementary.insert_rows" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.887626, + "supported_languages": null + }, + "macro.elementary.get_target_adapter_specific_fields": { + "name": "get_target_adapter_specific_fields", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.get_target_adapter_specific_fields", + "macro_sql": "{% macro get_target_adapter_specific_fields() %}\n {{ return(adapter.dispatch('get_target_adapter_specific_fields', 'elementary')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.snowflake__get_target_adapter_specific_fields" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8878112, + "supported_languages": null + }, + "macro.elementary.default__get_target_adapter_specific_fields": { + "name": "default__get_target_adapter_specific_fields", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.default__get_target_adapter_specific_fields", + "macro_sql": "{% macro default__get_target_adapter_specific_fields() %}\n {{ return('') }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.887926, + "supported_languages": null + }, + "macro.elementary.databricks__get_target_adapter_specific_fields": { + "name": "databricks__get_target_adapter_specific_fields", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.databricks__get_target_adapter_specific_fields", + "macro_sql": "{% macro databricks__get_target_adapter_specific_fields() %}\n {{ return({\"http_path\": target.http_path}) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.888072, + "supported_languages": null + }, + "macro.elementary.snowflake__get_target_adapter_specific_fields": { + "name": "snowflake__get_target_adapter_specific_fields", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.snowflake__get_target_adapter_specific_fields", + "macro_sql": "{% macro snowflake__get_target_adapter_specific_fields() %}\n {{ return({\"warehouse\": target.warehouse, \"user\": target.user, \"role\": target.role}) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8882828, + "supported_languages": null + }, + "macro.elementary.postgres__get_target_adapter_specific_fields": { + "name": "postgres__get_target_adapter_specific_fields", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.postgres__get_target_adapter_specific_fields", + "macro_sql": "{% macro postgres__get_target_adapter_specific_fields() %}\n {{ return({\"user\": target.user}) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.888428, + "supported_languages": null + }, + "macro.elementary.get_project_name": { + "name": "get_project_name", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.get_project_name", + "macro_sql": "{% macro get_project_name() %}\n {% set project_name = elementary.get_config_var(\"project_name\") %}\n {% if project_name %}\n {{ return(project_name) }}\n {% endif %}\n\n {% set config = elementary.get_runtime_config() %}\n {% do return(config.project_name) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_runtime_config" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.888758, + "supported_languages": null + }, + "macro.elementary.get_invocation_select_filter": { + "name": "get_invocation_select_filter", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.get_invocation_select_filter", + "macro_sql": "\n\n{%- macro get_invocation_select_filter() -%}\n {% set config = elementary.get_runtime_config() %}\n {%- if invocation_args_dict and invocation_args_dict.select -%}\n {{- return(invocation_args_dict.select) -}}\n {%- elif config.args and config.args.select -%}\n {{- return(config.args.select) -}}\n {%- else -%}\n {{- return([]) -}}\n {%- endif -%}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.get_runtime_config" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8891442, + "supported_languages": null + }, + "macro.elementary.get_invocation_yaml_selector": { + "name": "get_invocation_yaml_selector", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.get_invocation_yaml_selector", + "macro_sql": "{% macro get_invocation_yaml_selector() %}\n {% set config = elementary.get_runtime_config() %}\n {% if invocation_args_dict and invocation_args_dict.selector %}\n {% do return(invocation_args_dict.selector) %}\n {% elif invocation_args_dict and invocation_args_dict.selector_name %}\n {% do return(invocation_args_dict.selector_name) %}\n {% elif config.args and config.args.selector_name %}\n {% do return(config.args.selector_name) %}\n {% else %}\n {% do return(none) %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_runtime_config" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.889684, + "supported_languages": null + }, + "macro.elementary.get_invocation_vars": { + "name": "get_invocation_vars", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.get_invocation_vars", + "macro_sql": "{% macro get_invocation_vars() %}\n {% set config = elementary.get_runtime_config() %}\n {% set invocation_vars = {} %}\n {% if invocation_args_dict and invocation_args_dict.vars %}\n {% if invocation_args_dict.vars is mapping %}\n {% set invocation_vars = invocation_args_dict.vars %}\n {% else %}\n {% set invocation_vars = fromyaml(invocation_args_dict.vars) %}\n {% endif %}\n {% elif config.cli_vars %}\n {% set invocation_vars = config.cli_vars %}\n {% endif %}\n {{ return(elementary.to_primitive(invocation_vars)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_runtime_config", + "macro.elementary.to_primitive" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8902621, + "supported_languages": null + }, + "macro.elementary.get_all_vars": { + "name": "get_all_vars", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.get_all_vars", + "macro_sql": "\n\n{%- macro get_all_vars() -%}\n {% set all_vars = {} %}\n {% set config = elementary.get_runtime_config() %}\n {%- if config.vars -%}\n {% do all_vars.update(config.vars.to_dict()) %}\n {%- endif -%}\n {% do all_vars.update(elementary.get_invocation_vars()) %}\n {{- return(all_vars) -}}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.get_runtime_config", + "macro.elementary.get_invocation_vars" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.890649, + "supported_languages": null + }, + "macro.elementary.get_orchestrator": { + "name": "get_orchestrator", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.get_orchestrator", + "macro_sql": "{% macro get_orchestrator() %}\n {% set var_value = elementary.get_var(\"orchestrator\", [\"ORCHESTRATOR\", \"DBT_ORCHESTRATOR\"])%}\n {% if var_value %}\n {% do return(var_value) %}\n {% endif %}\n {% set orchestrator_env_map = {\n \"airflow\": [\"AIRFLOW_HOME\"],\n \"dbt_cloud\": [\"DBT_CLOUD_PROJECT_ID\"],\n \"github_actions\": [\"GITHUB_ACTIONS\"],\n } %}\n {% for orchestrator, env_vars in orchestrator_env_map.items() %}\n {% if elementary.get_first_env_var(env_vars) %}\n {% do return(orchestrator) %}\n {% endif %}\n {% endfor %}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_var", + "macro.elementary.get_first_env_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8913321, + "supported_languages": null + }, + "macro.elementary.get_job_url": { + "name": "get_job_url", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.get_job_url", + "macro_sql": "{% macro get_job_url(orchestrator, job_id) %}\n {% set var_value = elementary.get_var(\"job_url\", [\"JOB_URL\", \"DBT_JOB_URL\"]) %}\n {% if var_value %}\n {% do return(var_value) %}\n {% endif %}\n {% if orchestrator == 'airflow' %}\n {% set server_url = elementary.get_var('airflow_url', [\"AIRFLOW_URL\"]) %}\n {% set airflow_job_url = server_url ~ \"/dags/\" ~ job_id ~ \"/grid\" %}\n {% do return(airflow_job_url) %}\n {% elif orchestrator == 'dbt_cloud' %}\n {% set account_id = elementary.get_var('account_id', ['DBT_ACCOUNT_ID']) %}\n {% set dbt_cloud_project_id = elementary.get_first_env_var(['DBT_CLOUD_PROJECT_ID']) %}\n {% set dbt_cloud_job_id = elementary.get_first_env_var(['DBT_CLOUD_JOB_ID']) %}\n\n {% set dbt_cloud_job_url = \"https://cloud.getdbt.com/deploy/\" ~ account_id ~ \"/projects/\" ~ dbt_cloud_project_id ~ \"/jobs/\" ~ dbt_cloud_job_id %}\n {% do return(dbt_cloud_job_url) %}\n {% elif orchestrator == 'github_actions' %}\n {% set server_url = elementary.get_first_env_var([\"GITHUB_SERVER_URL\"]) %}\n {% set repository = elementary.get_first_env_var([\"GITHUB_REPOSITORY\"]) %}\n {% set run_id = elementary.get_first_env_var([\"GITHUB_RUN_ID\"]) %}\n\n {% set github_job_url = server_url ~ \"/\" ~ repository ~ \"/actions/runs/\" ~ run_id %}\n {% do return(github_job_url) %}\n {% endif %}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_var", + "macro.elementary.get_first_env_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.892819, + "supported_languages": null + }, + "macro.elementary.get_job_run_url": { + "name": "get_job_run_url", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.get_job_run_url", + "macro_sql": "{% macro get_job_run_url(orchestrator, job_id, job_run_id) %}\n {% set var_value = elementary.get_var(\"job_run_url\", [\"JOB_RUN_URL\", \"DBT_JOB_RUN_URL\"]) %}\n {% if var_value %}\n {% do return(var_value) %}\n {% endif %}\n {% if orchestrator == 'airflow' %}\n {% set server_url = elementary.get_var('airflow_url', [\"AIRFLOW_URL\"]) %}\n {% set airflow_job_url = server_url ~ \"/dags/\" ~ job_id ~ \"/grid?dag_run_id=\" ~ job_run_id %}\n {% do return(airflow_job_url) %}\n {% elif orchestrator == 'dbt_cloud' %}\n {% set account_id = elementary.get_var('account_id', ['DBT_ACCOUNT_ID']) %}\n {% set dbt_cloud_project_id = elementary.get_first_env_var(['DBT_CLOUD_PROJECT_ID']) %}\n {% set dbt_cloud_run_id = elementary.get_first_env_var(['DBT_CLOUD_RUN_ID']) %}\n\n {% set dbt_cloud_job_url = \"https://cloud.getdbt.com/deploy/\" ~ account_id ~ \"/projects/\" ~ dbt_cloud_project_id ~ \"/runs/\" ~ dbt_cloud_run_id %}\n {% do return(dbt_cloud_job_url) %}\n {% elif orchestrator == 'github_actions' %}\n {% set server_url = elementary.get_first_env_var([\"GITHUB_SERVER_URL\"]) %}\n {% set repository = elementary.get_first_env_var([\"GITHUB_REPOSITORY\"]) %}\n {% set run_id = elementary.get_first_env_var([\"GITHUB_RUN_ID\"]) %}\n\n {% set github_job_url = server_url ~ \"/\" ~ repository ~ \"/actions/runs/\" ~ run_id %}\n {% do return(github_job_url) %}\n {% endif %}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_var", + "macro.elementary.get_first_env_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.894258, + "supported_languages": null + }, + "macro.elementary.get_dbt_invocations_empty_table_query": { + "name": "get_dbt_invocations_empty_table_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_invocation.sql", + "unique_id": "macro.elementary.get_dbt_invocations_empty_table_query", + "macro_sql": "{% macro get_dbt_invocations_empty_table_query() %}\n {{ return(elementary.empty_table([\n ('invocation_id', 'long_string'),\n ('job_id', 'long_string'),\n ('job_name', 'long_string'),\n ('job_run_id', 'long_string'),\n ('run_started_at', 'string'),\n ('run_completed_at', 'string'),\n ('generated_at', 'string'),\n ('created_at', 'timestamp'),\n ('command', 'string'),\n ('dbt_version', 'string'),\n ('elementary_version', 'string'),\n ('full_refresh', 'boolean'),\n ('invocation_vars', 'long_string'),\n ('vars', 'long_string'),\n ('target_name', 'string'),\n ('target_database', 'string'),\n ('target_schema', 'string'),\n ('target_profile_name', 'string'),\n ('threads', 'int'),\n ('selected', 'long_string'),\n ('yaml_selector', 'long_string'),\n ('project_id', 'string'),\n ('project_name', 'string'),\n ('env', 'string'),\n ('env_id', 'string'),\n ('cause_category', 'string'),\n ('cause', 'long_string'),\n ('pull_request_id', 'string'),\n ('git_sha', 'string'),\n ('orchestrator', 'string'),\n ('dbt_user', 'string'),\n ('job_url', 'string'),\n ('job_run_url', 'string'),\n ('account_id', 'string'),\n ('target_adapter_specific_fields', 'long_string')\n ])) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.895703, + "supported_languages": null + }, + "macro.elementary.upload_source_freshness": { + "name": "upload_source_freshness", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_source_freshness.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_source_freshness.sql", + "unique_id": "macro.elementary.upload_source_freshness", + "macro_sql": "{% macro upload_source_freshness() %}\n {% if not flags.Path %}\n {% do exceptions.raise_compiler_error(\"Unable to upload source freshness using this operation on dbt 1.3.2 onwards.\") %}\n {% endif %}\n\n {% set source_freshness_results_relation = ref('dbt_source_freshness_results') %}\n {% set sources_json_path = flags.Path(elementary.get_runtime_config().target_path).joinpath('sources.json') %}\n {% if not sources_json_path.exists() %}\n {% do exceptions.raise_compiler_error('Source freshness artifact (sources.json) does not exist, please run `dbt source freshness`.') %}\n {% endif %}\n {% set source_freshness_results_dicts = fromjson(sources_json_path.read_text())['results'] %}\n {% do elementary.upload_artifacts_to_table(source_freshness_results_relation, source_freshness_results_dicts, elementary.flatten_source_freshness, append=True, should_commit=True) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_runtime_config", + "macro.elementary.upload_artifacts_to_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.897702, + "supported_languages": null + }, + "macro.elementary.flatten_source_freshness": { + "name": "flatten_source_freshness", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_source_freshness.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_source_freshness.sql", + "unique_id": "macro.elementary.flatten_source_freshness", + "macro_sql": "{% macro flatten_source_freshness(node_dict) %}\n {% set compile_timing = {} %}\n {% set execute_timing = {} %}\n {% for timing in node_dict['timing'] %}\n {% if timing['name'] == 'compile' %}\n {% do compile_timing.update(timing) %}\n {% elif timing['name'] == 'execute' %}\n {% do execute_timing.update(timing) %}\n {% endif %}\n {% endfor %}\n {% set metadata_dict = elementary.safe_get_with_default(node_dict, 'metadata', {}) %}\n {% set criteria_dict = elementary.safe_get_with_default(node_dict, 'criteria', {}) %}\n {% set source_freshness_invocation_id = metadata_dict.get('invocation_id', invocation_id) %}\n {% set flatten_source_freshness_dict = {\n 'source_freshness_execution_id': [source_freshness_invocation_id, node_dict.get('unique_id')] | join('.'),\n 'unique_id': node_dict.get('unique_id'),\n 'max_loaded_at': node_dict.get('max_loaded_at'),\n 'snapshotted_at': node_dict.get('snapshotted_at'),\n 'max_loaded_at_time_ago_in_s': node_dict.get('max_loaded_at_time_ago_in_s'),\n 'status': node_dict.get('status'),\n 'error': node_dict.get('error'),\n 'warn_after': criteria_dict.get('warn_after'),\n 'error_after': criteria_dict.get('error_after'),\n 'filter': criteria_dict.get('filter'),\n 'generated_at': elementary.datetime_now_utc_as_string(),\n 'invocation_id': source_freshness_invocation_id,\n 'compile_started_at': compile_timing.get('started_at'),\n 'compile_completed_at': compile_timing.get('completed_at'),\n 'execute_started_at': execute_timing.get('started_at'),\n 'execute_completed_at': execute_timing.get('completed_at'),\n } %}\n {{ return(flatten_source_freshness_dict) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.safe_get_with_default", + "macro.elementary.datetime_now_utc_as_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.8993988, + "supported_languages": null + }, + "macro.elementary.get_artifact_metadata_hash": { + "name": "get_artifact_metadata_hash", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/get_artifact_metadata_hash.sql", + "original_file_path": "macros/edr/dbt_artifacts/get_artifact_metadata_hash.sql", + "unique_id": "macro.elementary.get_artifact_metadata_hash", + "macro_sql": "{% macro get_artifact_metadata_hash(artifact) %}\n {% if not local_md5 %}\n {% do return(none) %}\n {% endif %}\n\n {% set time_excluded_artifact = artifact.copy() %}\n {% do time_excluded_artifact.pop(\"generated_at\") %}\n {% do return(local_md5(tojson(time_excluded_artifact, sort_keys=true))) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.899889, + "supported_languages": null + }, + "macro.elementary.upload_dbt_columns": { + "name": "upload_dbt_columns", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_columns.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_columns.sql", + "unique_id": "macro.elementary.upload_dbt_columns", + "macro_sql": "{%- macro upload_dbt_columns(should_commit=false, metadata_hashes=none) -%}\n {% set relation = elementary.get_elementary_relation('dbt_columns') %}\n {% if execute and relation %}\n {% set tables = graph.nodes.values() | list + graph.sources.values() | list %}\n {% do elementary.upload_artifacts_to_table(relation, tables, elementary.flatten_table_columns, should_commit=should_commit, metadata_hashes=metadata_hashes) %}\n {%- endif -%}\n {{- return('') -}}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.get_elementary_relation", + "macro.elementary.upload_artifacts_to_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.902563, + "supported_languages": null + }, + "macro.elementary.get_dbt_columns_empty_table_query": { + "name": "get_dbt_columns_empty_table_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_columns.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_columns.sql", + "unique_id": "macro.elementary.get_dbt_columns_empty_table_query", + "macro_sql": "{% macro get_dbt_columns_empty_table_query() %}\n {% set columns = [\n ('unique_id', 'string'),\n ('parent_unique_id', 'string'),\n ('name', 'string'),\n ('data_type', 'string'),\n ('tags', 'long_string'),\n ('meta', 'long_string'),\n ('database_name', 'string'),\n ('schema_name', 'string'),\n ('table_name', 'string'),\n ('description', 'long_string'),\n ('resource_type', 'string'),\n ('generated_at', 'string'),\n ('metadata_hash', 'string'),\n ] %}\n {% set dbt_columns_empty_table_query = elementary.empty_table(columns) %}\n {{ return(dbt_columns_empty_table_query) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.903279, + "supported_languages": null + }, + "macro.elementary.flatten_table_columns": { + "name": "flatten_table_columns", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_columns.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_columns.sql", + "unique_id": "macro.elementary.flatten_table_columns", + "macro_sql": "{% macro flatten_table_columns(table_node) %}\n {% set column_nodes = table_node.get(\"columns\") %}\n {% if not column_nodes %}\n {% do return(none) %}\n {% endif %}\n\n {% set flattened_columns = [] %}\n {% for column_node in column_nodes.values() %}\n {% set flat_column = elementary.flatten_column(table_node, column_node) %}\n {% if not elementary.get_config_var('upload_only_columns_with_descriptions') or flat_column['description'] %}\n {% do flattened_columns.append(flat_column) %}\n {% endif %}\n {% endfor %}\n {% do return(flattened_columns) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.flatten_column", + "macro.elementary.get_config_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.903931, + "supported_languages": null + }, + "macro.elementary.flatten_column": { + "name": "flatten_column", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_columns.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_columns.sql", + "unique_id": "macro.elementary.flatten_column", + "macro_sql": "{% macro flatten_column(table_node, column_node) %}\n {% set config_dict = elementary.safe_get_with_default(column_node, 'config', {}) %}\n {% set config_meta_dict = elementary.safe_get_with_default(config_dict, 'meta', {}) %}\n {% set meta_dict = elementary.safe_get_with_default(column_node, 'meta', {}) %}\n {% do meta_dict.update(config_meta_dict) %}\n {% set config_tags = elementary.safe_get_with_default(config_dict, 'tags', []) %}\n {% set global_tags = elementary.safe_get_with_default(column_node, 'tags', []) %}\n {% set meta_tags = elementary.safe_get_with_default(meta_dict, 'tags', []) %}\n {% set tags = elementary.union_lists(config_tags, global_tags) %}\n {% set tags = elementary.union_lists(tags, meta_tags) %}\n {% set flatten_column_metadata_dict = {\n 'parent_unique_id': table_node.get('unique_id'),\n 'unique_id': \"column.{}.{}\".format(table_node.get('unique_id'), column_node.get('name')),\n 'name': column_node.get('name'),\n 'data_type': column_node.get('data_type'),\n 'tags': elementary.filter_none_and_sort(tags),\n 'meta': meta_dict,\n 'description': column_node.get('description') or none,\n 'database_name': table_node.get('database'),\n 'schema_name': table_node.get('schema'),\n 'table_name': table_node.get('alias'),\n 'resource_type': table_node.get('resource_type'),\n 'generated_at': elementary.datetime_now_utc_as_string(),\n } %}\n {% do flatten_column_metadata_dict.update({\"metadata_hash\": elementary.get_artifact_metadata_hash(flatten_column_metadata_dict)}) %}\n {% do return(flatten_column_metadata_dict) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.safe_get_with_default", + "macro.elementary.union_lists", + "macro.elementary.filter_none_and_sort", + "macro.elementary.datetime_now_utc_as_string", + "macro.elementary.get_artifact_metadata_hash" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9057112, + "supported_languages": null + }, + "macro.elementary.upload_dbt_artifacts": { + "name": "upload_dbt_artifacts", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_artifacts.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_artifacts.sql", + "unique_id": "macro.elementary.upload_dbt_artifacts", + "macro_sql": "{% macro upload_dbt_artifacts() %}\n {% if execute and results %}\n {% set model_upload_func_map = {\n \"dbt_models\": elementary.upload_dbt_models,\n \"dbt_tests\": elementary.upload_dbt_tests,\n \"dbt_sources\": elementary.upload_dbt_sources,\n \"dbt_snapshots\": elementary.upload_dbt_snapshots,\n \"dbt_metrics\": elementary.upload_dbt_metrics,\n \"dbt_exposures\": elementary.upload_dbt_exposures,\n \"dbt_seeds\": elementary.upload_dbt_seeds,\n }\n %}\n\n {% if not elementary.get_config_var('disable_dbt_columns_autoupload') %}\n {% do model_upload_func_map.update({\"dbt_columns\": elementary.upload_dbt_columns}) %}\n {% endif %}\n\n {% set artifacts_hashes = elementary.get_artifacts_hashes() %}\n {% do elementary.file_log(\"Uploading dbt artifacts.\") %}\n {% for artifacts_model, upload_artifacts_func in model_upload_func_map.items() %}\n {% if not elementary.get_result_node(artifacts_model) %}\n {% if elementary.get_elementary_relation(artifacts_model) %}\n {% if artifacts_hashes is not none %}\n {% do upload_artifacts_func(should_commit=true, metadata_hashes=artifacts_hashes.get(artifacts_model, [])) %}\n {% else %}\n {% do upload_artifacts_func(should_commit=true) %}\n {% endif %}\n {% endif %}\n {% else %}\n {% do elementary.file_log('[{}] Artifacts already ran.'.format(artifacts_model)) %}\n {% endif %}\n {% endfor %}\n {% do elementary.file_log(\"Uploaded dbt artifacts.\") %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.get_artifacts_hashes", + "macro.elementary.file_log", + "macro.elementary.get_result_node", + "macro.elementary.get_elementary_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9079108, + "supported_languages": null + }, + "macro.elementary.get_artifacts_hashes": { + "name": "get_artifacts_hashes", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_artifacts.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_artifacts.sql", + "unique_id": "macro.elementary.get_artifacts_hashes", + "macro_sql": "{% macro get_artifacts_hashes() %}\n {# The stored hashes are only needed if it can be compared later to the local hashes. #}\n {% if not local_md5 %}\n {% do return(none) %}\n {% endif %}\n\n {% set artifacts_hash_relation = elementary.get_elementary_relation('dbt_artifacts_hashes') %}\n {% if not artifacts_hash_relation %}\n {% do return(none) %}\n {% endif %}\n\n {% set stored_artifacts_query %}\n select artifacts_model, metadata_hash from {{ artifacts_hash_relation }}\n order by metadata_hash\n {% endset %}\n {% set artifacts_hashes_results = elementary.run_query(stored_artifacts_query) %}\n {% set artifact_agate_hashes = artifacts_hashes_results.group_by(\"artifacts_model\") %}\n {% set artifacts_hashes = {} %}\n {% for artifacts_model, metadata_hashes in artifact_agate_hashes.items() %}\n {% do artifacts_hashes.update({artifacts_model: metadata_hashes.columns[\"metadata_hash\"]}) %}\n {% endfor %}\n {% do return(artifacts_hashes) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_elementary_relation", + "macro.elementary.run_query", + "macro.dbt_utils.group_by" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.908747, + "supported_languages": null + }, + "macro.elementary.upload_run_results": { + "name": "upload_run_results", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_run_results.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_run_results.sql", + "unique_id": "macro.elementary.upload_run_results", + "macro_sql": "{% macro upload_run_results() %}\n {% set relation = elementary.get_elementary_relation('dbt_run_results') %}\n {% if execute and relation %}\n {{ elementary.file_log(\"Uploading run results.\") }}\n {% do elementary.upload_artifacts_to_table(relation, results, elementary.flatten_run_result, append=True, should_commit=True, on_query_exceed=elementary.on_run_result_query_exceed) %}\n {{ elementary.file_log(\"Uploaded run results successfully.\") }}\n {% endif %}\n {{ return ('') }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_elementary_relation", + "macro.elementary.file_log", + "macro.elementary.upload_artifacts_to_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.91504, + "supported_languages": null + }, + "macro.elementary.get_dbt_run_results_empty_table_query": { + "name": "get_dbt_run_results_empty_table_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_run_results.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_run_results.sql", + "unique_id": "macro.elementary.get_dbt_run_results_empty_table_query", + "macro_sql": "{% macro get_dbt_run_results_empty_table_query() %}\n {% set dbt_run_results_empty_table_query = elementary.empty_table([('model_execution_id', 'long_string'),\n ('unique_id', 'long_string'),\n ('invocation_id', 'string'),\n ('generated_at', 'string'),\n ('created_at', 'timestamp'),\n ('name', 'long_string'),\n ('message', 'long_string'),\n ('status', 'string'),\n ('resource_type', 'string'),\n ('execution_time', 'float'),\n ('execute_started_at', 'string'),\n ('execute_completed_at', 'string'),\n ('compile_started_at', 'string'),\n ('compile_completed_at', 'string'),\n ('rows_affected', 'bigint'),\n ('full_refresh', 'boolean'),\n ('compiled_code', 'long_string'),\n ('failures', 'bigint'),\n ('query_id', 'string'),\n ('thread_id', 'string'),\n ('materialization', 'string'),\n ('adapter_response', 'string')\n ]) %}\n {{ return(dbt_run_results_empty_table_query) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.916055, + "supported_languages": null + }, + "macro.elementary.flatten_run_result": { + "name": "flatten_run_result", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_run_results.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_run_results.sql", + "unique_id": "macro.elementary.flatten_run_result", + "macro_sql": "{% macro flatten_run_result(run_result) %}\n {% set run_result_dict = run_result.to_dict() %}\n {% set node = elementary.safe_get_with_default(run_result_dict, 'node', {}) %}\n {% set config_dict = elementary.safe_get_with_default(node, 'config', {}) %}\n {% set flatten_run_result_dict = {\n 'model_execution_id': elementary.get_node_execution_id(node),\n 'invocation_id': invocation_id,\n 'unique_id': node.get('unique_id'),\n 'name': node.get('name'),\n 'message': run_result_dict.get('message'),\n 'generated_at': elementary.datetime_now_utc_as_string(),\n 'rows_affected': run_result_dict.get('adapter_response', {}).get('rows_affected'),\n 'execution_time': run_result_dict.get('execution_time'),\n 'status': run_result_dict.get('status'),\n 'resource_type': node.get('resource_type'),\n 'execute_started_at': none,\n 'execute_completed_at': none,\n 'compile_started_at': none,\n 'compile_completed_at': none,\n 'full_refresh': flags.FULL_REFRESH,\n 'compiled_code': elementary.get_compiled_code(node, as_column_value=true),\n 'failures': run_result_dict.get('failures'),\n 'query_id': run_result_dict.get('adapter_response', {}).get('query_id'),\n 'thread_id': run_result_dict.get('thread_id'),\n 'materialization': config_dict.get('materialized'),\n 'adapter_response': run_result_dict.get('adapter_response', {})\n } %}\n\n {% set timings = elementary.safe_get_with_default(run_result_dict, 'timing', []) %}\n {% if timings %}\n {% for timing in timings %}\n {% if timing is mapping %}\n {% if timing.get('name') == 'execute' %}\n {% do flatten_run_result_dict.update({'execute_started_at': timing.get('started_at'), 'execute_completed_at': timing.get('completed_at')}) %}\n {% elif timing.get('name') == 'compile' %}\n {% do flatten_run_result_dict.update({'compile_started_at': timing.get('started_at'), 'compile_completed_at': timing.get('completed_at')}) %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% endif %}\n {{ return(flatten_run_result_dict) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.safe_get_with_default", + "macro.elementary.get_node_execution_id", + "macro.elementary.datetime_now_utc_as_string", + "macro.elementary.get_compiled_code" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.918298, + "supported_languages": null + }, + "macro.elementary.on_run_result_query_exceed": { + "name": "on_run_result_query_exceed", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_run_results.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_run_results.sql", + "unique_id": "macro.elementary.on_run_result_query_exceed", + "macro_sql": "{% macro on_run_result_query_exceed(flattened_node) %}\n {% do flattened_node.update({\"compiled_code\": elementary.get_compiled_code_too_long_err_msg()}) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_compiled_code_too_long_err_msg" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.918493, + "supported_languages": null + }, + "macro.elementary.upload_artifacts_to_table": { + "name": "upload_artifacts_to_table", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_artifacts_to_table.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_artifacts_to_table.sql", + "unique_id": "macro.elementary.upload_artifacts_to_table", + "macro_sql": "{% macro upload_artifacts_to_table(table_relation, artifacts, flatten_artifact_callback, append=False, should_commit=False, metadata_hashes=None, on_query_exceed=none) %}\n {% set flatten_artifact_dicts = [] %}\n {% do elementary.file_log(\"[{}] Flattening the artifacts.\".format(table_relation.identifier)) %}\n {% for artifact in artifacts %}\n {% set flatten_artifact = flatten_artifact_callback(artifact) %}\n {% if flatten_artifact is mapping %}\n {% do flatten_artifact_dicts.append(flatten_artifact) %}\n {% elif flatten_artifact is iterable %}\n {% do flatten_artifact_dicts.extend(flatten_artifact) %}\n {% endif %}\n {% endfor %}\n {% do elementary.file_log(\"[{}] Flattened {} artifacts.\".format(table_relation.identifier, flatten_artifact_dicts | length)) %}\n\n {% if append %}\n {# In append mode, just insert, and no need to be atomic #}\n {% do elementary.insert_rows(table_relation, flatten_artifact_dicts, should_commit, elementary.get_config_var('dbt_artifacts_chunk_size'), on_query_exceed) %}\n {% else %}\n {% if metadata_hashes is not none and elementary.get_config_var(\"cache_artifacts\") %}\n {% do elementary.file_log(\"[{}] Comparing the artifacts state.\".format(table_relation.identifier)) %}\n {% set new_metadata_hashes = flatten_artifact_dicts | map(attribute=\"metadata_hash\") | sort %}\n {% if new_metadata_hashes == metadata_hashes %}\n {% do elementary.file_log(\"[{}] Artifacts did not change.\".format(table_relation.identifier)) %}\n {% else %}\n {% do elementary.file_log(\"[{}] Artifacts changed.\".format(table_relation.identifier)) %}\n {% set upload_artifacts_method = elementary.get_config_var(\"upload_artifacts_method\") %}\n {% if upload_artifacts_method == \"diff\" %}\n {% set added_artifacts = flatten_artifact_dicts | rejectattr(\"metadata_hash\", \"in\", metadata_hashes) | list %}\n {% set removed_artifact_hashes = metadata_hashes | reject(\"in\", new_metadata_hashes) | list %}\n {% do elementary.delete_and_insert(table_relation, insert_rows=added_artifacts, delete_values=removed_artifact_hashes, delete_column_key=\"metadata_hash\") %}\n {% elif upload_artifacts_method == \"replace\" %}\n {% do elementary.replace_table_data(table_relation, flatten_artifact_dicts) %}\n {% else %}\n {% do exceptions.raise_compiler_error(\"Invalid var('upload_artifacts_method') provided.\") %}\n {% endif %}\n {% endif %}\n {% else %}\n {% do elementary.replace_table_data(table_relation, flatten_artifact_dicts) %}\n {% endif %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.file_log", + "macro.elementary.insert_rows", + "macro.elementary.get_config_var", + "macro.elementary.delete_and_insert", + "macro.elementary.replace_table_data" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.921729, + "supported_languages": null + }, + "macro.elementary.upload_dbt_metrics": { + "name": "upload_dbt_metrics", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_metrics.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_metrics.sql", + "unique_id": "macro.elementary.upload_dbt_metrics", + "macro_sql": "{%- macro upload_dbt_metrics(should_commit=false, metadata_hashes=none) -%}\n {% set relation = elementary.get_elementary_relation('dbt_metrics') %}\n {% if execute and relation %}\n {% set metrics = graph.metrics.values() | selectattr('resource_type', '==', 'metric') %}\n {% do elementary.upload_artifacts_to_table(relation, metrics, elementary.flatten_metric, should_commit=should_commit, metadata_hashes=metadata_hashes) %}\n {%- endif -%}\n {{- return('') -}}\n{%- endmacro -%}\n\n\n\n", + "depends_on": { + "macros": [ + "macro.elementary.get_elementary_relation", + "macro.elementary.upload_artifacts_to_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.926374, + "supported_languages": null + }, + "macro.elementary.get_dbt_metrics_empty_table_query": { + "name": "get_dbt_metrics_empty_table_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_metrics.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_metrics.sql", + "unique_id": "macro.elementary.get_dbt_metrics_empty_table_query", + "macro_sql": "{% macro get_dbt_metrics_empty_table_query() %}\n {% set dbt_metrics_empty_table_query = elementary.empty_table([('unique_id', 'string'),\n ('name', 'string'),\n ('label', 'string'),\n ('model', 'string'),\n ('type', 'string'),\n ('sql', 'long_string'),\n ('timestamp', 'string'),\n ('filters', 'long_string'),\n ('time_grains', 'long_string'),\n ('dimensions', 'long_string'),\n ('depends_on_macros', 'long_string'),\n ('depends_on_nodes', 'long_string'),\n ('description', 'long_string'),\n ('tags', 'long_string'),\n ('meta', 'long_string'),\n ('package_name', 'string'),\n ('original_path', 'long_string'),\n ('path', 'string'),\n ('generated_at', 'string'),\n ('metadata_hash', 'string'),\n ]) %}\n {{ return(dbt_metrics_empty_table_query) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.927328, + "supported_languages": null + }, + "macro.elementary.flatten_metric": { + "name": "flatten_metric", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_metrics.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_metrics.sql", + "unique_id": "macro.elementary.flatten_metric", + "macro_sql": "{% macro flatten_metric(node_dict) %}\n {% set depends_on_dict = elementary.safe_get_with_default(node_dict, 'depends_on', {}) %}\n {% set meta_dict = elementary.safe_get_with_default(node_dict, 'meta', {}) %}\n {% set tags = elementary.safe_get_with_default(node_dict, 'tags', []) %}\n {% set flatten_metric_metadata_dict = {\n 'unique_id': node_dict.get('unique_id'),\n 'name': node_dict.get('name'),\n 'label': node_dict.get('label'),\n 'model': node_dict.get('model'),\n 'type': node_dict.get('type'),\n 'sql': node_dict.get('sql'),\n 'timestamp': node_dict.get('timestamp'),\n 'filters': node_dict.get('filters', {}),\n 'time_grains': elementary.filter_none_and_sort(node_dict.get('time_grains', [])),\n 'dimensions': elementary.filter_none_and_sort(node_dict.get('dimensions', [])),\n 'depends_on_macros': elementary.filter_none_and_sort(depends_on_dict.get('macros', [])),\n 'depends_on_nodes': elementary.filter_none_and_sort(depends_on_dict.get('nodes', [])),\n 'description': node_dict.get('description'),\n 'tags': elementary.filter_none_and_sort(tags),\n 'meta': meta_dict,\n 'package_name': node_dict.get('package_name'),\n 'original_path': node_dict.get('original_file_path'),\n 'path': node_dict.get('path'),\n 'generated_at': elementary.datetime_now_utc_as_string()\n }%}\n {% do flatten_metric_metadata_dict.update({\"metadata_hash\": elementary.get_artifact_metadata_hash(flatten_metric_metadata_dict)}) %}\n {{ return(flatten_metric_metadata_dict) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.safe_get_with_default", + "macro.elementary.filter_none_and_sort", + "macro.elementary.datetime_now_utc_as_string", + "macro.elementary.get_artifact_metadata_hash" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.929012, + "supported_languages": null + }, + "macro.elementary.upload_dbt_tests": { + "name": "upload_dbt_tests", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_tests.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_tests.sql", + "unique_id": "macro.elementary.upload_dbt_tests", + "macro_sql": "{%- macro upload_dbt_tests(should_commit=false, metadata_hashes=none) -%}\n {% set relation = elementary.get_elementary_relation('dbt_tests') %}\n {% if execute and relation %}\n {% set tests = graph.nodes.values() | selectattr('resource_type', '==', 'test') %}\n {% do elementary.upload_artifacts_to_table(relation, tests, elementary.flatten_test, should_commit=should_commit, metadata_hashes=metadata_hashes) %}\n {%- endif -%}\n {{- return('') -}}\n{%- endmacro -%}\n\n\n\n\n", + "depends_on": { + "macros": [ + "macro.elementary.get_elementary_relation", + "macro.elementary.upload_artifacts_to_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.938793, + "supported_languages": null + }, + "macro.elementary.get_dbt_tests_empty_table_query": { + "name": "get_dbt_tests_empty_table_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_tests.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_tests.sql", + "unique_id": "macro.elementary.get_dbt_tests_empty_table_query", + "macro_sql": "{% macro get_dbt_tests_empty_table_query() %}\n {% set dbt_tests_empty_table_query = elementary.empty_table([('unique_id', 'string'),\n ('database_name', 'string'),\n ('schema_name', 'string'),\n ('name', 'string'),\n ('short_name', 'string'),\n ('alias', 'string'),\n ('test_column_name', 'string'),\n ('severity', 'string'),\n ('warn_if', 'string'),\n ('error_if', 'string'),\n ('test_params', 'long_string'),\n ('test_namespace', 'string'),\n ('tags', 'long_string'),\n ('model_tags', 'long_string'),\n ('model_owners', 'long_string'),\n ('meta', 'long_string'),\n ('depends_on_macros', 'long_string'),\n ('depends_on_nodes', 'long_string'),\n ('parent_model_unique_id', 'string'),\n ('description', 'long_string'),\n ('package_name', 'string'),\n ('type', 'string'),\n ('original_path', 'long_string'),\n ('path', 'string'),\n ('generated_at', 'string'),\n ('metadata_hash', 'string'),\n ('quality_dimension', 'string')\n ]) %}\n {{ return(dbt_tests_empty_table_query) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.939994, + "supported_languages": null + }, + "macro.elementary.flatten_test": { + "name": "flatten_test", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_tests.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_tests.sql", + "unique_id": "macro.elementary.flatten_test", + "macro_sql": "{% macro flatten_test(node_dict) %}\n {% set config_dict = elementary.safe_get_with_default(node_dict, 'config', {}) %}\n {% set depends_on_dict = elementary.safe_get_with_default(node_dict, 'depends_on', {}) %}\n\n {% set test_metadata = elementary.safe_get_with_default(node_dict, 'test_metadata', {}) %}\n {% set test_namespace = test_metadata.get('namespace') %}\n {% set test_short_name = elementary.get_test_short_name(node_dict, test_metadata) %}\n\n {% set default_description = elementary.get_default_description(test_short_name, test_namespace) %}\n\n {% set config_meta_dict = elementary.safe_get_with_default(config_dict, 'meta', {}) %}\n {% set meta_dict = {} %}\n {% if default_description %}\n {% set meta_dict = {'description': default_description} %} \n {% endif %}\n {% do meta_dict.update(elementary.safe_get_with_default(node_dict, 'meta', {})) %}\n {% do meta_dict.update(config_meta_dict) %}\n\n {% set config_tags = elementary.safe_get_with_default(config_dict, 'tags', []) %}\n {% set global_tags = elementary.safe_get_with_default(node_dict, 'tags', []) %}\n {% set meta_tags = elementary.safe_get_with_default(meta_dict, 'tags', []) %}\n {% set tags = elementary.union_lists(config_tags, global_tags) %}\n {% set tags = elementary.union_lists(tags, meta_tags) %}\n\n {% set test_model_unique_ids = elementary.get_parent_model_unique_ids_from_test_node(node_dict) %}\n {% set test_model_nodes = elementary.get_nodes_by_unique_ids(test_model_unique_ids) %}\n {% set test_models_owners = [] %}\n {% set test_models_tags = [] %}\n {% for test_model_node in test_model_nodes %}\n {% set flatten_test_model_node = elementary.flatten_model(test_model_node) %}\n {% set test_model_owner = flatten_test_model_node.get('owner') %}\n {% if test_model_owner %}\n {% if test_model_owner is string %}\n {% set owners = test_model_owner.split(',') %}\n {% for owner in owners %}\n {% do test_models_owners.append(owner | trim) %} \n {% endfor %}\n {% elif test_model_owner is iterable %}\n {% do test_models_owners.extend(test_model_owner) %}\n {% endif %}\n {% endif %}\n {% set test_model_tags = flatten_test_model_node.get('tags') %}\n {% if test_model_tags and test_model_tags is sequence %}\n {% do test_models_tags.extend(test_model_tags) %}\n {% endif %}\n {% endfor %}\n {% set test_models_owners = test_models_owners | unique | list %}\n {% set test_models_tags = test_models_tags | unique | list %}\n\n {% set test_kwargs = elementary.safe_get_with_default(test_metadata, 'kwargs', {}) %}\n\n {% set primary_test_model_id = namespace(data=none) %}\n {% if test_model_unique_ids | length == 1 %}\n {# if only one parent model for this test, simply use this model #}\n {% set primary_test_model_id.data = test_model_unique_ids[0] %}\n {% else %}\n {% set test_model_jinja = test_kwargs.get('model') %}\n {% if test_model_jinja %}\n {% set test_model_name_matches =\n modules.re.findall(\"ref\\(['\\\"](\\w+)['\\\"]\\)\", test_model_jinja) +\n modules.re.findall(\"source\\(['\\\"]\\w+['\\\"], ['\\\"](\\w+)['\\\"]\\)\", test_model_jinja) %}\n {% if test_model_name_matches | length == 1 %}\n {% set test_model_name = test_model_name_matches[0] %}\n {% for test_model_unique_id in test_model_unique_ids %}\n {% set split_test_model_unique_id = test_model_unique_id.split('.') %}\n {% if split_test_model_unique_id and split_test_model_unique_id | length > 0 %}\n {% set test_node_model_name = split_test_model_unique_id[-1] %}\n {% if test_node_model_name == test_model_name %}\n {% set primary_test_model_id.data = test_model_unique_id %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% endif %}\n {% endif %}\n {% endif %}\n\n {% set primary_test_model_database = none %}\n {% set primary_test_model_schema = none %}\n {%- if primary_test_model_id.data is not none -%}\n {% set tested_model_node = elementary.get_node(primary_test_model_id.data) %}\n {%- if tested_model_node -%}\n {% set primary_test_model_database = tested_model_node.get('database') %}\n {% set primary_test_model_schema = tested_model_node.get('schema') %}\n {%- endif -%}\n {%- endif -%}\n\n {%- if primary_test_model_database is none or primary_test_model_schema is none -%}\n {# This is mainly here to support singular test cases with multiple referred models, in this case the tested node is being used to extract the db and schema #}\n {% set primary_test_model_database, primary_test_model_schema = elementary.get_model_database_and_schema_from_test_node(node_dict) %}\n {%- endif -%}\n\n {% set original_file_path = node_dict.get('original_file_path') %}\n {% set flatten_test_metadata_dict = {\n 'unique_id': node_dict.get('unique_id'),\n 'short_name': test_short_name,\n 'alias': node_dict.get('alias'),\n 'test_column_name': node_dict.get('column_name'),\n 'severity': config_dict.get('severity'),\n 'warn_if': config_dict.get('warn_if'),\n 'error_if': config_dict.get('error_if'),\n 'test_params': test_kwargs,\n 'test_namespace': test_namespace,\n 'tags': elementary.filter_none_and_sort(tags),\n 'model_tags': elementary.filter_none_and_sort(test_models_tags),\n 'model_owners': elementary.filter_none_and_sort(test_models_owners),\n 'meta': meta_dict,\n 'database_name': primary_test_model_database,\n 'schema_name': primary_test_model_schema,\n 'depends_on_macros': elementary.filter_none_and_sort(depends_on_dict.get('macros', [])),\n 'depends_on_nodes': elementary.filter_none_and_sort(depends_on_dict.get('nodes', [])),\n 'parent_model_unique_id': primary_test_model_id.data,\n 'description': meta_dict.get('description'),\n 'name': node_dict.get('name'),\n 'package_name': node_dict.get('package_name'),\n 'type': elementary.get_test_sub_type(original_file_path, test_namespace),\n 'original_path': original_file_path,\n 'compiled_code': elementary.get_compiled_code(node_dict),\n 'path': node_dict.get('path'),\n 'generated_at': elementary.datetime_now_utc_as_string(),\n 'quality_dimension': meta_dict.get('quality_dimension') or elementary.get_quality_dimension(test_short_name, test_namespace)\n }%}\n {% do flatten_test_metadata_dict.update({\"metadata_hash\": elementary.get_artifact_metadata_hash(flatten_test_metadata_dict)}) %}\n {{ return(flatten_test_metadata_dict) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.safe_get_with_default", + "macro.elementary.get_test_short_name", + "macro.elementary.get_default_description", + "macro.elementary.union_lists", + "macro.elementary.get_parent_model_unique_ids_from_test_node", + "macro.elementary.get_nodes_by_unique_ids", + "macro.elementary.flatten_model", + "macro.elementary.get_node", + "macro.elementary.get_model_database_and_schema_from_test_node", + "macro.elementary.filter_none_and_sort", + "macro.elementary.get_test_sub_type", + "macro.elementary.get_compiled_code", + "macro.elementary.datetime_now_utc_as_string", + "macro.elementary.get_quality_dimension", + "macro.elementary.get_artifact_metadata_hash" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.945856, + "supported_languages": null + }, + "macro.elementary.get_test_sub_type": { + "name": "get_test_sub_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_tests.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_tests.sql", + "unique_id": "macro.elementary.get_test_sub_type", + "macro_sql": "{% macro get_test_sub_type(test_path, test_namespace = none) %}\n {% set test_type = 'generic' %}\n {%- if test_namespace == 'dbt_expectations' -%}\n {% set test_type = 'expectation' %}\n {%- elif 'tests/generic' in test_path or 'macros/' in test_path -%}\n {% set test_type = 'generic' %}\n {%- elif 'tests/' in test_path -%}\n {% set test_type = 'singular' %}\n {%- endif -%}\n {{- return(test_type) -}}\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.946334, + "supported_languages": null + }, + "macro.elementary.get_test_short_name": { + "name": "get_test_short_name", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_tests.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_tests.sql", + "unique_id": "macro.elementary.get_test_short_name", + "macro_sql": "{% macro get_test_short_name(node_dict, test_metadata) %}\n {#\n If there is a custom name it overrides the dbt auto generated long name.\n This is a best effort to extract custom names.\n dbt automated name generation -\n - Generic test long name starts with the generic name or source_generic\n - Generic tests from packages long name starts with the package_generic or package_source_generic\n #}\n\n {% set generic_test_name = test_metadata.get('name') %} {# 'unique', 'relationships', 'volume_anomalies' etc #}\n {% set test_package_name = test_metadata.get('namespace') %}\n {% set test_instance_name = node_dict.get('name') %} {# Test custom name or dbt auto generated long name #}\n {%- if generic_test_name %}\n {%- if test_package_name == 'elementary' %}\n {{ return(generic_test_name) }}\n {%- elif test_package_name %}\n {% set test_short_name =\n generic_test_name if (test_instance_name.startswith(test_package_name + '_' + generic_test_name) or test_instance_name.startswith(test_package_name + '_source_' + generic_test_name))\n else test_instance_name\n %}\n {%- else %}\n {% set test_short_name =\n generic_test_name if (test_instance_name.startswith(generic_test_name) or test_instance_name.startswith('source_' + generic_test_name))\n else test_instance_name\n %}\n {%- endif %}\n {{ return(test_short_name) }}\n {%- else %}\n {{ return(test_instance_name) }}\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.947277, + "supported_languages": null + }, + "macro.elementary.get_default_description": { + "name": "get_default_description", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_tests.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_tests.sql", + "unique_id": "macro.elementary.get_default_description", + "macro_sql": "{% macro get_default_description(short_name, test_namespace = none) %}\n {% set description = none %}\n {% set common_test_config = elementary.get_common_test_config_by_namespace_and_name(test_namespace, short_name) %}\n {% if common_test_config %}\n {% set description = common_test_config.get(\"description\") %}\n {% endif %}\n {% do return(description) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_common_test_config_by_namespace_and_name" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.947666, + "supported_languages": null + }, + "macro.elementary.get_quality_dimension": { + "name": "get_quality_dimension", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_tests.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_tests.sql", + "unique_id": "macro.elementary.get_quality_dimension", + "macro_sql": "{% macro get_quality_dimension(short_name, test_namespace = none) %}\n {% set quality_dimension = none %}\n {% set common_test_config = elementary.get_common_test_config_by_namespace_and_name(test_namespace, short_name) %}\n {% if common_test_config %}\n {% set quality_dimension = common_test_config.get(\"quality_dimension\") %}\n {% endif %}\n {% do return(quality_dimension) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_common_test_config_by_namespace_and_name" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9480488, + "supported_languages": null + }, + "macro.elementary.upload_dbt_exposures": { + "name": "upload_dbt_exposures", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_exposures.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_exposures.sql", + "unique_id": "macro.elementary.upload_dbt_exposures", + "macro_sql": "{%- macro upload_dbt_exposures(should_commit=false, metadata_hashes=none) -%}\n {% set relation = elementary.get_elementary_relation('dbt_exposures') %}\n {% if execute and relation %}\n {% set exposures = graph.exposures.values() | selectattr('resource_type', '==', 'exposure') %}\n {% do elementary.upload_artifacts_to_table(relation, exposures, elementary.flatten_exposure, should_commit=should_commit, metadata_hashes=metadata_hashes) %}\n {%- endif -%}\n {{- return('') -}}\n{%- endmacro -%}\n\n\n\n", + "depends_on": { + "macros": [ + "macro.elementary.get_elementary_relation", + "macro.elementary.upload_artifacts_to_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.952543, + "supported_languages": null + }, + "macro.elementary.get_dbt_exposures_empty_table_query": { + "name": "get_dbt_exposures_empty_table_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_exposures.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_exposures.sql", + "unique_id": "macro.elementary.get_dbt_exposures_empty_table_query", + "macro_sql": "{% macro get_dbt_exposures_empty_table_query() %}\n {% set dbt_exposures_empty_table_query = elementary.empty_table([('unique_id', 'string'),\n ('name', 'string'),\n ('maturity', 'string'),\n ('type', 'string'),\n ('owner_email', 'string'),\n ('owner_name', 'string'),\n ('url', 'long_string'),\n ('depends_on_macros', 'long_string'),\n ('depends_on_nodes', 'long_string'),\n ('description', 'long_string'),\n ('tags', 'long_string'),\n ('meta', 'long_string'),\n ('package_name', 'string'),\n ('original_path', 'long_string'),\n ('path', 'string'),\n ('generated_at', 'string'),\n ('metadata_hash', 'string'),\n ('label', 'string'),\n ('raw_queries', 'long_string'),\n ]) %}\n {{ return(dbt_exposures_empty_table_query) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.953443, + "supported_languages": null + }, + "macro.elementary.flatten_exposure": { + "name": "flatten_exposure", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/upload_dbt_exposures.sql", + "original_file_path": "macros/edr/dbt_artifacts/upload_dbt_exposures.sql", + "unique_id": "macro.elementary.flatten_exposure", + "macro_sql": "{% macro flatten_exposure(node_dict) %}\n {% set owner_dict = elementary.safe_get_with_default(node_dict, 'owner', {}) %}\n {% set depends_on_dict = elementary.safe_get_with_default(node_dict, 'depends_on', {}) %}\n {% set meta_dict = elementary.safe_get_with_default(node_dict, 'meta', {}) %}\n {% set tags = elementary.safe_get_with_default(node_dict, 'tags', []) %}\n {% set flatten_exposure_metadata_dict = {\n 'unique_id': node_dict.get('unique_id'),\n 'name': node_dict.get('name'),\n 'label': node_dict.get('label'),\n 'maturity': node_dict.get('maturity'),\n 'type': node_dict.get('type'),\n 'owner_email': owner_dict.get('email'),\n 'owner_name': owner_dict.get('name'),\n 'url': node_dict.get('url'),\n 'depends_on_macros': elementary.filter_none_and_sort(depends_on_dict.get('macros', [])),\n 'depends_on_nodes': elementary.filter_none_and_sort(depends_on_dict.get('nodes', [])),\n 'description': node_dict.get('description'),\n 'tags': elementary.filter_none_and_sort(tags),\n 'meta': meta_dict,\n 'package_name': node_dict.get('package_name'),\n 'original_path': node_dict.get('original_file_path'),\n 'path': node_dict.get('path'),\n 'generated_at': elementary.datetime_now_utc_as_string()\n }%}\n {% do flatten_exposure_metadata_dict.update({\"metadata_hash\": elementary.get_artifact_metadata_hash(flatten_exposure_metadata_dict)}) %}\n {{ return(flatten_exposure_metadata_dict) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.safe_get_with_default", + "macro.elementary.filter_none_and_sort", + "macro.elementary.datetime_now_utc_as_string", + "macro.elementary.get_artifact_metadata_hash" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.955015, + "supported_languages": null + }, + "macro.elementary.get_information_schema_columns_materialized": { + "name": "get_information_schema_columns_materialized", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/dbt_columns/get_information_schema_columns_materialized.sql", + "original_file_path": "macros/edr/dbt_artifacts/dbt_columns/get_information_schema_columns_materialized.sql", + "unique_id": "macro.elementary.get_information_schema_columns_materialized", + "macro_sql": "{% macro get_information_schema_columns_materialized() %}\n {% if var(\"sync\", false) %}\n {% do return(\"table\") %}\n {% endif %}\n {% do return(\"view\") %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9553359, + "supported_languages": null + }, + "macro.elementary.get_information_schema_columns_query": { + "name": "get_information_schema_columns_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/dbt_artifacts/dbt_columns/get_information_schema_columns_query.sql", + "original_file_path": "macros/edr/dbt_artifacts/dbt_columns/get_information_schema_columns_query.sql", + "unique_id": "macro.elementary.get_information_schema_columns_query", + "macro_sql": "{% macro get_information_schema_columns_query(is_model_build_context=true) %}\n {% if is_model_build_context %}\n {% set get_relation = ref %}\n {% else %}\n {% set get_relation = elementary.get_elementary_relation %}\n {% endif %}\n\n with dbt_models_data as (\n select\n database_name,\n schema_name,\n alias as table_name\n from {{ get_relation('dbt_models') }}\n ),\n\n dbt_snapshots_data as (\n select\n database_name,\n schema_name,\n alias as table_name\n from {{ get_relation('dbt_snapshots') }}\n ),\n\n dbt_sources_data as (\n select\n database_name,\n schema_name,\n name as table_name\n from {{ get_relation('dbt_sources') }}\n ),\n\n dbt_seeds_data as (\n select\n database_name,\n schema_name,\n name as table_name\n from {{ get_relation('dbt_seeds') }}\n ),\n\n tables_information as (\n select * from dbt_models_data\n union all\n select * from dbt_sources_data\n union all\n select * from dbt_snapshots_data\n union all\n select * from dbt_seeds_data\n ),\n\n columns_information as (\n {{ elementary.get_columns_in_project() }}\n ),\n\n information_schema_columns as (\n select col_info.*\n from tables_information tbl_info\n join columns_information col_info\n on (lower(tbl_info.database_name) = lower(col_info.database_name) and\n lower(tbl_info.schema_name) = lower(col_info.schema_name) and\n lower(tbl_info.table_name) = lower(col_info.table_name)\n )\n )\n\n select *\n from information_schema_columns\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_columns_in_project" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.956513, + "supported_languages": null + }, + "macro.elementary.get_anomaly_scores_query": { + "name": "get_anomaly_scores_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/anomaly_detection/get_anomaly_scores_query.sql", + "original_file_path": "macros/edr/data_monitoring/anomaly_detection/get_anomaly_scores_query.sql", + "unique_id": "macro.elementary.get_anomaly_scores_query", + "macro_sql": "{% macro get_anomaly_scores_query(test_metrics_table_relation, model_relation, test_configuration, monitors, column_name = none, columns_only = false, metric_properties = none, data_monitoring_metrics_table=none) %}\n {%- set model_graph_node = elementary.get_model_graph_node(model_relation) %}\n {%- set full_table_name = elementary.model_node_to_full_name(model_graph_node) %}\n {%- set test_execution_id = elementary.get_test_execution_id() %}\n {%- set test_unique_id = elementary.get_test_unique_id() %}\n {%- if not data_monitoring_metrics_table %}\n {# data_monitoring_metrics_table is none except for integration-tests that test the get_anomaly_scores_query macro,\n and in which case it holds mock history metrics #}\n {%- set data_monitoring_metrics_table = ref('data_monitoring_metrics') %}\n {%- endif %}\n\n\n {%- if elementary.is_incremental_model(model_graph_node) %}\n {%- set latest_full_refresh = elementary.get_latest_full_refresh(model_graph_node) %}\n {%- else %}\n {%- set latest_full_refresh = none %}\n {%- endif %}\n\n {%- if test_configuration.seasonality == 'day_of_week' %}\n {%- set bucket_seasonality_expr = elementary.edr_day_of_week_expression('bucket_end') %}\n\n {%- elif test_configuration.seasonality == 'hour_of_day' %}\n {%- set bucket_seasonality_expr = elementary.edr_hour_of_day_expression('bucket_end') %}\n\n {%- elif test_configuration.seasonality == 'hour_of_week' %}\n {%- set bucket_seasonality_expr = elementary.edr_hour_of_week_expression('bucket_end') %}\n\n {%- else %}\n {%- set bucket_seasonality_expr = elementary.const_as_text('no_seasonality') %}\n {%- endif %}\n {%- set detection_end = elementary.get_detection_end(test_configuration.detection_delay) %}\n {%- set min_bucket_start_expr = elementary.get_trunc_min_bucket_start_expr(detection_end, metric_properties, test_configuration.days_back) %}\n\n {# For timestamped tests, this will be the bucket start, and for non-timestamped tests it will be the\n bucket end (which is the actual time of the test) #}\n {%- set metric_time_bucket_expr = 'case when bucket_start is not null then bucket_start else bucket_end end' %}\n\n {%- set anomaly_scores_query %}\n {% if test_configuration.timestamp_column %}\n with buckets as (\n select edr_bucket_start, edr_bucket_end\n from ({{ elementary.complete_buckets_cte(metric_properties, min_bucket_start_expr,\n elementary.edr_quote(detection_end)) }}) results\n where edr_bucket_start >= {{ elementary.edr_cast_as_timestamp(min_bucket_start_expr) }}\n and edr_bucket_end <= {{ elementary.edr_cast_as_timestamp(elementary.edr_quote(detection_end)) }}\n ),\n {% else %}\n with\n {% endif %}\n data_monitoring_metrics as (\n\n select\n id,\n full_table_name,\n column_name,\n metric_name,\n metric_value,\n source_value,\n bucket_start,\n bucket_end,\n bucket_duration_hours,\n updated_at,\n dimension,\n dimension_value,\n metric_properties\n from {{ data_monitoring_metrics_table }}\n -- We use bucket_end because non-timestamp tests have only bucket_end field.\n where\n bucket_end > {{ min_bucket_start_expr }}\n {% if test_configuration.timestamp_column %}\n -- For timestamped tests, verify that the bucket we got from the history is actually\n -- a valid one (this check is important for buckets that are not aligned with a day).\n and {{ elementary.edr_multi_value_in(\n [elementary.edr_cast_as_timestamp('bucket_start'), elementary.edr_cast_as_timestamp('bucket_end')],\n ['edr_bucket_start', 'edr_bucket_end'],\n 'buckets'\n ) }}\n {% endif %}\n and metric_properties = {{ elementary.dict_to_quoted_json(metric_properties) }}\n {% if latest_full_refresh %}\n and updated_at > {{ elementary.edr_cast_as_timestamp(elementary.edr_quote(latest_full_refresh)) }}\n {% endif %}\n and upper(full_table_name) = upper('{{ full_table_name }}')\n and metric_name in {{ elementary.strings_list_to_tuple(monitors) }}\n {%- if column_name %}\n and upper(column_name) = upper('{{ column_name }}')\n {%- endif %}\n {%- if columns_only %}\n and column_name is not null\n {%- endif %}\n {% if test_configuration.dimensions %}\n and dimension = {{ elementary.edr_quote(elementary.join_list(test_configuration.dimensions, '; ')) }}\n {% endif %}\n ),\n\n union_metrics as (\n\n select * from data_monitoring_metrics\n union all\n select * from {{ test_metrics_table_relation }}\n\n ),\n\n grouped_metrics_duplicates as (\n\n select\n id,\n full_table_name,\n column_name,\n metric_name,\n metric_value,\n source_value,\n bucket_start,\n bucket_end,\n bucket_duration_hours,\n updated_at,\n dimension,\n dimension_value,\n\n -- Fields added for the anomaly_exclude_metrics expression used below\n {{ metric_time_bucket_expr }} as metric_time_bucket,\n {{ elementary.edr_cast_as_date(elementary.edr_date_trunc('day', metric_time_bucket_expr))}} as metric_date,\n\n row_number() over (partition by id order by updated_at desc) as row_number\n from union_metrics\n\n ),\n\n grouped_metrics as (\n\n select\n id as metric_id,\n full_table_name,\n column_name,\n dimension,\n dimension_value,\n metric_name,\n metric_value,\n source_value,\n bucket_start,\n bucket_end,\n {{ bucket_seasonality_expr }} as bucket_seasonality,\n {{ test_configuration.anomaly_exclude_metrics or 'FALSE' }} as is_excluded,\n bucket_duration_hours,\n updated_at\n from grouped_metrics_duplicates\n where row_number = 1\n ),\n\n time_window_aggregation as (\n\n select\n metric_id,\n full_table_name,\n column_name,\n dimension,\n dimension_value,\n metric_name,\n metric_value,\n source_value,\n bucket_start,\n bucket_end,\n bucket_seasonality,\n bucket_duration_hours,\n updated_at,\n avg(metric_value) over (partition by metric_name, full_table_name, column_name, dimension, dimension_value, bucket_seasonality order by bucket_end asc rows between unbounded preceding and current row) as training_avg,\n stddev(metric_value) over (partition by metric_name, full_table_name, column_name, dimension, dimension_value, bucket_seasonality order by bucket_end asc rows between unbounded preceding and current row) as training_stddev,\n count(metric_value) over (partition by metric_name, full_table_name, column_name, dimension, dimension_value, bucket_seasonality order by bucket_end asc rows between unbounded preceding and current row) as training_set_size,\n last_value(bucket_end) over (partition by metric_name, full_table_name, column_name, dimension, dimension_value, bucket_seasonality order by bucket_end asc rows between unbounded preceding and current row) training_end,\n first_value(bucket_end) over (partition by metric_name, full_table_name, column_name, dimension, dimension_value, bucket_seasonality order by bucket_end asc rows between unbounded preceding and current row) as training_start\n from grouped_metrics\n where not is_excluded\n {{ dbt_utils.group_by(13) }}\n ),\n\n anomaly_scores as (\n\n select\n {{ elementary.generate_surrogate_key([\n 'metric_id',\n elementary.const_as_string(test_execution_id)\n ]) }} as id,\n metric_id,\n {{ elementary.const_as_string(test_execution_id) }} as test_execution_id,\n {{ elementary.const_as_string(test_unique_id) }} as test_unique_id,\n {{ elementary.current_timestamp_column() }} as detected_at,\n full_table_name,\n column_name,\n metric_name,\n case\n when training_stddev is null then null\n when training_stddev = 0 then 0\n else (metric_value - training_avg) / (training_stddev)\n end as anomaly_score,\n {{ test_configuration.anomaly_sensitivity }} as anomaly_score_threshold,\n source_value as anomalous_value,\n {{ elementary.edr_cast_as_timestamp('bucket_start') }} as bucket_start,\n {{ elementary.edr_cast_as_timestamp('bucket_end') }} as bucket_end,\n bucket_seasonality,\n metric_value,\n \n {% set limit_values = elementary.get_limit_metric_values(test_configuration) %}\n case\n when training_stddev is null then null\n when {{ limit_values.min_metric_value }} > 0 or metric_name in {{ elementary.to_sql_list(elementary.get_negative_value_supported_metrics()) }} then {{ limit_values.min_metric_value }}\n else 0\n end as min_metric_value,\n case \n when training_stddev is null then null\n else {{ limit_values.max_metric_value }}\n end as max_metric_value,\n training_avg,\n training_stddev,\n training_set_size,\n {{ elementary.edr_cast_as_timestamp('training_start') }} as training_start,\n {{ elementary.edr_cast_as_timestamp('training_end') }} as training_end,\n dimension,\n dimension_value\n from time_window_aggregation\n where\n metric_value is not null\n and training_avg is not null\n )\n\n select * from anomaly_scores\n\n {% endset %}\n {{ return(anomaly_scores_query) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_model_graph_node", + "macro.elementary.model_node_to_full_name", + "macro.elementary.get_test_execution_id", + "macro.elementary.get_test_unique_id", + "macro.elementary.is_incremental_model", + "macro.elementary.get_latest_full_refresh", + "macro.elementary.edr_day_of_week_expression", + "macro.elementary.edr_hour_of_day_expression", + "macro.elementary.edr_hour_of_week_expression", + "macro.elementary.const_as_text", + "macro.elementary.get_detection_end", + "macro.elementary.get_trunc_min_bucket_start_expr", + "macro.elementary.complete_buckets_cte", + "macro.elementary.edr_quote", + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.edr_multi_value_in", + "macro.elementary.dict_to_quoted_json", + "macro.elementary.strings_list_to_tuple", + "macro.elementary.join_list", + "macro.elementary.edr_cast_as_date", + "macro.elementary.edr_date_trunc", + "macro.dbt_utils.group_by", + "macro.elementary.generate_surrogate_key", + "macro.elementary.const_as_string", + "macro.elementary.current_timestamp_column", + "macro.elementary.get_limit_metric_values", + "macro.elementary.to_sql_list", + "macro.elementary.get_negative_value_supported_metrics" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.973761, + "supported_languages": null + }, + "macro.elementary.get_negative_value_supported_metrics": { + "name": "get_negative_value_supported_metrics", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/anomaly_detection/get_anomaly_scores_query.sql", + "original_file_path": "macros/edr/data_monitoring/anomaly_detection/get_anomaly_scores_query.sql", + "unique_id": "macro.elementary.get_negative_value_supported_metrics", + "macro_sql": "{% macro get_negative_value_supported_metrics() %}\n {% do return([\"min\", \"max\", \"average\", \"standard_deviation\", \"variance\", \"sum\"]) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9739819, + "supported_languages": null + }, + "macro.elementary.get_limit_metric_values": { + "name": "get_limit_metric_values", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/anomaly_detection/get_anomaly_scores_query.sql", + "original_file_path": "macros/edr/data_monitoring/anomaly_detection/get_anomaly_scores_query.sql", + "unique_id": "macro.elementary.get_limit_metric_values", + "macro_sql": "{% macro get_limit_metric_values(test_configuration) %}\n {%- set min_val -%}\n ((-1) * {{ test_configuration.anomaly_sensitivity }} * training_stddev + training_avg)\n {%- endset -%}\n\n {% if test_configuration.ignore_small_changes.drop_failure_percent_threshold %}\n {%- set drop_avg_threshold -%}\n ((1 + {{ test_configuration.ignore_small_changes.drop_failure_percent_threshold }}/100.0) * training_avg)\n {%- endset -%}\n {%- set min_val -%}\n {{ elementary.arithmetic_min(drop_avg_threshold, min_val) }}\n {%- endset -%}\n {% endif %}\n\n {%- set max_val -%}\n {{ test_configuration.anomaly_sensitivity }} * training_stddev + training_avg\n {%- endset -%}\n\n {% if test_configuration.ignore_small_changes.spike_failure_percent_threshold %}\n {%- set spike_avg_threshold -%}\n ((1 + {{ test_configuration.ignore_small_changes.spike_failure_percent_threshold }}/100.0) * training_avg)\n {%- endset -%}\n {%- set max_val -%}\n {{ elementary.arithmetic_max(spike_avg_threshold, max_val) }}\n {%- endset -%}\n {% endif %}\n\n {{ return({\"min_metric_value\": min_val, \"max_metric_value\": max_val}) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.arithmetic_min", + "macro.elementary.arithmetic_max" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.974716, + "supported_languages": null + }, + "macro.elementary.row_count": { + "name": "row_count", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/table_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/table_monitors.sql", + "unique_id": "macro.elementary.row_count", + "macro_sql": "{% macro row_count() -%}\n count(*)\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.974817, + "supported_languages": null + }, + "macro.elementary.max_length": { + "name": "max_length", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_string_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_string_monitors.sql", + "unique_id": "macro.elementary.max_length", + "macro_sql": "{% macro max_length(column_name) -%}\n max(length({{ column_name }}))\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9752278, + "supported_languages": null + }, + "macro.elementary.min_length": { + "name": "min_length", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_string_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_string_monitors.sql", + "unique_id": "macro.elementary.min_length", + "macro_sql": "{% macro min_length(column_name) -%}\n min(length({{ column_name }}))\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.975324, + "supported_languages": null + }, + "macro.elementary.average_length": { + "name": "average_length", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_string_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_string_monitors.sql", + "unique_id": "macro.elementary.average_length", + "macro_sql": "{% macro average_length(column_name) -%}\n avg(length({{ column_name }}))\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9754188, + "supported_languages": null + }, + "macro.elementary.missing_count": { + "name": "missing_count", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_string_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_string_monitors.sql", + "unique_id": "macro.elementary.missing_count", + "macro_sql": "{% macro missing_count(column_name) %}\n coalesce(sum(case when {{ column_name }} is null then 1 when trim({{ column_name }}) = '' then 1 when lower({{ column_name }}) = 'null' then 1 else 0 end), 0)\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.975554, + "supported_languages": null + }, + "macro.elementary.missing_percent": { + "name": "missing_percent", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_string_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_string_monitors.sql", + "unique_id": "macro.elementary.missing_percent", + "macro_sql": "{% macro missing_percent(column_name) %}\n {{ elementary.edr_percent(elementary.missing_count(column_name), elementary.row_count()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_percent", + "macro.elementary.missing_count", + "macro.elementary.row_count" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.975737, + "supported_languages": null + }, + "macro.elementary.not_missing_percent": { + "name": "not_missing_percent", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_string_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_string_monitors.sql", + "unique_id": "macro.elementary.not_missing_percent", + "macro_sql": "{% macro not_missing_percent(column_name) %}\n {{ elementary.edr_not_percent(elementary.missing_count(column_name), elementary.row_count()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_not_percent", + "macro.elementary.missing_count", + "macro.elementary.row_count" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.975914, + "supported_languages": null + }, + "macro.elementary.null_count": { + "name": "null_count", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_any_type_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_any_type_monitors.sql", + "unique_id": "macro.elementary.null_count", + "macro_sql": "{% macro null_count(column_name) %}\n coalesce(sum(case when {{ column_name }} is null then 1 else 0 end), 0)\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.976128, + "supported_languages": null + }, + "macro.elementary.null_percent": { + "name": "null_percent", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_any_type_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_any_type_monitors.sql", + "unique_id": "macro.elementary.null_percent", + "macro_sql": "{% macro null_percent(column_name) %}\n {{ elementary.edr_percent(elementary.null_count(column_name), elementary.row_count()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_percent", + "macro.elementary.null_count", + "macro.elementary.row_count" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.976305, + "supported_languages": null + }, + "macro.elementary.not_null_percent": { + "name": "not_null_percent", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_any_type_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_any_type_monitors.sql", + "unique_id": "macro.elementary.not_null_percent", + "macro_sql": "{% macro not_null_percent(column_name) %}\n {{ elementary.edr_not_percent(elementary.null_count(column_name), elementary.row_count()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_not_percent", + "macro.elementary.null_count", + "macro.elementary.row_count" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.976484, + "supported_languages": null + }, + "macro.elementary.get_available_monitors": { + "name": "get_available_monitors", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/monitors.sql", + "unique_id": "macro.elementary.get_available_monitors", + "macro_sql": "{% macro get_available_monitors() %}\n {% do return({\n 'table': ['row_count', 'freshness'],\n 'column_any_type': ['null_count', 'null_percent', 'not_null_percent'],\n 'column_string': ['min_length', 'max_length', 'average_length', 'missing_count', 'missing_percent', 'not_missing_percent'],\n 'column_numeric': ['min', 'max', 'zero_count', 'zero_percent', 'not_zero_percent', 'average', 'standard_deviation', 'variance', 'sum']\n }) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.977189, + "supported_languages": null + }, + "macro.elementary.get_default_monitors": { + "name": "get_default_monitors", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/monitors.sql", + "unique_id": "macro.elementary.get_default_monitors", + "macro_sql": "{% macro get_default_monitors() %}\n {% do return({\n 'table': ['row_count', 'freshness'],\n 'column_any_type': ['null_count', 'null_percent'],\n 'column_string': ['min_length', 'max_length', 'average_length', 'missing_count', 'missing_percent'],\n 'column_numeric': ['min', 'max', 'zero_count', 'zero_percent', 'average', 'standard_deviation', 'variance']\n }) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9776168, + "supported_languages": null + }, + "macro.elementary.max": { + "name": "max", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "unique_id": "macro.elementary.max", + "macro_sql": "{% macro max(column_name) -%}\n max(cast({{ column_name }} as {{ elementary.edr_type_float() }}))\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_float" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9784691, + "supported_languages": null + }, + "macro.elementary.min": { + "name": "min", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "unique_id": "macro.elementary.min", + "macro_sql": "{% macro min(column_name) -%}\n min(cast({{ column_name }} as {{ elementary.edr_type_float() }}))\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_float" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9786031, + "supported_languages": null + }, + "macro.elementary.average": { + "name": "average", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "unique_id": "macro.elementary.average", + "macro_sql": "{% macro average(column_name) -%}\n avg(cast({{ column_name }} as {{ elementary.edr_type_float() }}))\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_float" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9787378, + "supported_languages": null + }, + "macro.elementary.zero_count": { + "name": "zero_count", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "unique_id": "macro.elementary.zero_count", + "macro_sql": "{% macro zero_count(column_name) %}\n coalesce(sum(case when {{ column_name }} is null then 1 when cast({{ column_name }} as {{ elementary.edr_type_float() }}) = 0 then 1 else 0 end), 0)\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_float" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.978889, + "supported_languages": null + }, + "macro.elementary.zero_percent": { + "name": "zero_percent", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "unique_id": "macro.elementary.zero_percent", + "macro_sql": "{% macro zero_percent(column_name) %}\n {{ elementary.edr_percent(elementary.zero_count(column_name), elementary.row_count()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_percent", + "macro.elementary.zero_count", + "macro.elementary.row_count" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.97907, + "supported_languages": null + }, + "macro.elementary.not_zero_percent": { + "name": "not_zero_percent", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "unique_id": "macro.elementary.not_zero_percent", + "macro_sql": "{% macro not_zero_percent(column_name) %}\n {{ elementary.edr_not_percent(elementary.zero_count(column_name), elementary.row_count()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_not_percent", + "macro.elementary.zero_count", + "macro.elementary.row_count" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9792562, + "supported_languages": null + }, + "macro.elementary.standard_deviation": { + "name": "standard_deviation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "unique_id": "macro.elementary.standard_deviation", + "macro_sql": "{% macro standard_deviation(column_name) -%}\n stddev(cast({{ column_name }} as {{ elementary.edr_type_float() }}))\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_float" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9794612, + "supported_languages": null + }, + "macro.elementary.variance": { + "name": "variance", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "unique_id": "macro.elementary.variance", + "macro_sql": "{% macro variance(column_name) -%}\n variance(cast({{ column_name }} as {{ elementary.edr_type_float() }}))\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_float" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.979593, + "supported_languages": null + }, + "macro.elementary.sum": { + "name": "sum", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/monitors/column_numeric_monitors.sql", + "unique_id": "macro.elementary.sum", + "macro_sql": "{% macro sum(column_name) -%}\n sum(cast({{ column_name }} as {{ elementary.edr_type_float() }}))\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_float" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.979728, + "supported_languages": null + }, + "macro.elementary.get_last_schema_changes_time": { + "name": "get_last_schema_changes_time", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/schema_changes/get_last_schema_changes_time.sql", + "original_file_path": "macros/edr/data_monitoring/schema_changes/get_last_schema_changes_time.sql", + "unique_id": "macro.elementary.get_last_schema_changes_time", + "macro_sql": "{% macro get_last_schema_changes_time() %}\n -- depends_on: {{ ref('elementary_test_results') }}\n {%- if execute -%}\n {%- set last_schema_changes_time_query %}\n select max(detected_at) as last_alert_time\n from {{ ref('elementary_test_results') }}\n where test_type = 'schema_change' and test_sub_type != 'table_added'\n {%- endset %}\n\n {%- set last_schema_changes_query_result = elementary.result_value(last_schema_changes_time_query) %}\n\n {%- if last_schema_changes_query_result %}\n {{ return(last_schema_changes_query_result) }}\n {%- else %}\n {{ return(none) }}\n {%- endif %}\n {%- endif -%}\n {{- return(none) -}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.result_value" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.980433, + "supported_languages": null + }, + "macro.elementary.get_columns_snapshot_query": { + "name": "get_columns_snapshot_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/schema_changes/get_columns_snapshot_query.sql", + "original_file_path": "macros/edr/data_monitoring/schema_changes/get_columns_snapshot_query.sql", + "unique_id": "macro.elementary.get_columns_snapshot_query", + "macro_sql": "{% macro get_columns_snapshot_query(model_relation, full_table_name) %}\n\n {%- set known_columns_query %}\n select full_column_name from {{ ref('schema_columns_snapshot') }}\n where detected_at = (select max(detected_at) from {{ ref('schema_columns_snapshot') }} where lower(full_table_name) = lower('{{ full_table_name }}'))\n and lower(full_table_name) = lower('{{ full_table_name }}')\n {% endset %}\n\n {%- set known_tables_query %}\n select distinct full_table_name from {{ ref('schema_columns_snapshot') }}\n where detected_at = (select max(detected_at) from {{ ref('schema_columns_snapshot') }} where lower(full_table_name) = lower('{{ full_table_name }}'))\n and lower(full_table_name) = lower('{{ full_table_name }}')\n {% endset %}\n\n {% set columns = adapter.get_columns_in_relation(model_relation) %}\n\n with table_info as (\n select\n {{ elementary.edr_cast_as_string(elementary.edr_quote(full_table_name)) }} as full_table_name,\n {{ elementary.edr_cast_as_string(elementary.edr_quote(model_relation.database)) }} as database_name,\n {{ elementary.edr_cast_as_string(elementary.edr_quote(model_relation.schema)) }} as schema_name,\n {{ elementary.edr_cast_as_string(elementary.edr_quote(model_relation.identifier)) }} as table_name,\n {{ elementary.datetime_now_utc_as_timestamp_column() }} as detected_at\n ),\n\n columns_info as (\n select\n full_table_name,\n database_name,\n schema_name,\n table_name,\n column_name,\n data_type,\n detected_at\n from table_info\n cross join\n (\n {% for column in columns %}\n select\n {{ elementary.edr_cast_as_string(elementary.edr_quote(column.name)) }} as column_name,\n {{ elementary.edr_cast_as_string(elementary.edr_quote(elementary.get_normalized_data_type(elementary.get_column_data_type(column)))) }} as data_type\n {% if not loop.last %}\n union all\n {% endif %}\n {% endfor %}\n ) rt\n ),\n\n columns_snapshot as (\n select\n full_table_name,\n database_name,\n schema_name,\n table_name,\n column_name,\n data_type,\n detected_at,\n case when\n {{ elementary.full_column_name() }} not in ({{ known_columns_query }})\n and full_table_name in ({{ known_tables_query }})\n then true\n else false\n end as is_new\n from columns_info\n ),\n\n columns_snapshot_with_id as (\n select\n {{ elementary.generate_surrogate_key([\n 'full_table_name',\n 'column_name',\n 'data_type',\n ]) }} as column_state_id,\n {{ elementary.full_column_name() }} as full_column_name,\n full_table_name,\n column_name,\n data_type,\n is_new,\n detected_at\n from columns_snapshot\n group by 1,2,3,4,5,6,7\n )\n\n select\n {{ elementary.edr_cast_as_string('column_state_id') }} as column_state_id,\n {{ elementary.edr_cast_as_string('full_column_name') }} as full_column_name,\n {{ elementary.edr_cast_as_string('full_table_name') }} as full_table_name,\n {{ elementary.edr_cast_as_string('column_name') }} as column_name,\n {{ elementary.edr_cast_as_string('data_type') }} as data_type,\n {{ elementary.edr_cast_as_bool('is_new') }} as is_new,\n {{ elementary.edr_cast_as_timestamp('detected_at') }} as detected_at\n from columns_snapshot_with_id\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_string", + "macro.elementary.edr_quote", + "macro.elementary.datetime_now_utc_as_timestamp_column", + "macro.elementary.get_normalized_data_type", + "macro.elementary.get_column_data_type", + "macro.elementary.full_column_name", + "macro.elementary.generate_surrogate_key", + "macro.elementary.edr_cast_as_bool", + "macro.elementary.edr_cast_as_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9855921, + "supported_languages": null + }, + "macro.elementary.get_columns_changes_from_last_run_query": { + "name": "get_columns_changes_from_last_run_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/schema_changes/get_columns_changes_query.sql", + "original_file_path": "macros/edr/data_monitoring/schema_changes/get_columns_changes_query.sql", + "unique_id": "macro.elementary.get_columns_changes_from_last_run_query", + "macro_sql": "{% macro get_columns_changes_from_last_run_query(full_table_name, temp_columns_snapshot_relation) %}\n {%- set previous_schema_time_query -%}\n (select max(detected_at) from {{ ref('schema_columns_snapshot') }} where lower(full_table_name) = lower('{{ full_table_name }}'))\n {%- endset %}\n\n {% set cur %}\n {# This is the current snapshot of the columns. #}\n select full_table_name, column_name, data_type, is_new, detected_at\n from {{ temp_columns_snapshot_relation }}\n {% endset %}\n\n {% set pre %}\n {# This is the previous snapshot of the columns. #}\n select full_table_name, column_name, data_type, detected_at\n from {{ ref('schema_columns_snapshot') }}\n where lower(full_table_name) = lower('{{ full_table_name }}')\n and detected_at = {{ previous_schema_time_query }}\n order by detected_at desc\n {% endset %}\n\n {{ elementary.get_columns_changes_query_generic(full_table_name, cur, pre) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_columns_changes_query_generic" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.988301, + "supported_languages": null + }, + "macro.elementary.get_column_changes_from_baseline_query": { + "name": "get_column_changes_from_baseline_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/schema_changes/get_columns_changes_query.sql", + "original_file_path": "macros/edr/data_monitoring/schema_changes/get_columns_changes_query.sql", + "unique_id": "macro.elementary.get_column_changes_from_baseline_query", + "macro_sql": "{% macro get_column_changes_from_baseline_query(model_relation, full_table_name, model_baseline_relation, include_added=False) %}\n {% set cur %}\n with baseline as (\n select lower(column_name) as column_name, data_type\n from {{ model_baseline_relation }}\n )\n\n select\n columns_snapshot.full_table_name,\n lower(columns_snapshot.column_name) as column_name,\n columns_snapshot.data_type,\n (baseline.column_name IS NULL) as is_new,\n {{ elementary.datetime_now_utc_as_timestamp_column() }} as detected_at\n from ({{ elementary.get_columns_snapshot_query(model_relation, full_table_name) }}) columns_snapshot\n left join baseline on (\n lower(columns_snapshot.column_name) = lower(baseline.column_name)\n )\n where lower(columns_snapshot.full_table_name) = lower('{{ full_table_name }}')\n {% endset %}\n\n {% set pre %}\n select\n {{ elementary.const_as_string(full_table_name) }} as full_table_name,\n column_name,\n data_type,\n {{ elementary.datetime_now_utc_as_timestamp_column() }} as detected_at\n from {{ model_baseline_relation }}\n {% endset %}\n\n {{ elementary.get_columns_changes_query_generic(full_table_name, cur, pre, include_added=include_added) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.datetime_now_utc_as_timestamp_column", + "macro.elementary.get_columns_snapshot_query", + "macro.elementary.const_as_string", + "macro.elementary.get_columns_changes_query_generic" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.988878, + "supported_languages": null + }, + "macro.elementary.get_columns_changes_query_generic": { + "name": "get_columns_changes_query_generic", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/schema_changes/get_columns_changes_query.sql", + "original_file_path": "macros/edr/data_monitoring/schema_changes/get_columns_changes_query.sql", + "unique_id": "macro.elementary.get_columns_changes_query_generic", + "macro_sql": "{% macro get_columns_changes_query_generic(full_table_name, cur, pre, include_added=True) %}\n {%- set test_execution_id = elementary.get_test_execution_id() %}\n {%- set test_unique_id = elementary.get_test_unique_id() %}\n\n with cur as (\n {{ cur }}\n ),\n\n pre as (\n {{ pre }}\n ),\n\n type_changes as (\n\n {# Finding the columns that have changed type. #}\n select\n cur.full_table_name,\n 'type_changed' as change,\n cur.column_name,\n cur.data_type as data_type,\n pre.data_type as pre_data_type,\n pre.detected_at\n from cur inner join pre\n on (lower(cur.full_table_name) = lower(pre.full_table_name) and lower(cur.column_name) = lower(pre.column_name))\n where pre.data_type IS NOT NULL AND lower(cur.data_type) != lower(pre.data_type)\n\n ),\n\n {% if include_added %}\n columns_added as (\n\n {# This is the columns that have been added. #}\n select\n full_table_name,\n 'column_added' as change,\n column_name,\n data_type,\n {{ elementary.null_string() }} as pre_data_type,\n detected_at as detected_at\n from cur\n where is_new = true\n\n ),\n {% endif %}\n\n columns_removed as (\n\n {# This is finding the columns that have been removed. #}\n select\n pre.full_table_name,\n 'column_removed' as change,\n pre.column_name as column_name,\n {{ elementary.null_string() }} as data_type,\n pre.data_type as pre_data_type,\n pre.detected_at as detected_at\n from pre left join cur\n on (lower(cur.full_table_name) = lower(pre.full_table_name) and lower(cur.column_name) = lower(pre.column_name))\n where cur.full_table_name is null and cur.column_name is null\n\n ),\n\n columns_removed_filter_deleted_tables as (\n\n {# This is filtering out the columns of tables that have been deleted. #}\n select\n removed.full_table_name,\n removed.change,\n removed.column_name,\n removed.data_type,\n removed.pre_data_type,\n removed.detected_at\n from columns_removed as removed join cur\n on (lower(removed.full_table_name) = lower(cur.full_table_name))\n\n ),\n\n all_column_changes as (\n\n {# Combining the results of the three queries into one table. #}\n select * from type_changes\n union all\n select * from columns_removed_filter_deleted_tables\n {% if include_added %}\n union all\n select * from columns_added\n {% endif %}\n ),\n\n column_changes_test_results as (\n\n {# This is the query that is creating the test results table, by formatting a description and adding id + detection time #}\n select\n {{ elementary.generate_surrogate_key([\n 'full_table_name',\n 'column_name',\n 'change',\n 'detected_at',\n ]) }} as data_issue_id,\n {{ elementary.datetime_now_utc_as_timestamp_column() }} as detected_at,\n {{ elementary.full_name_split('database_name') }},\n {{ elementary.full_name_split('schema_name') }},\n {{ elementary.full_name_split('table_name') }},\n column_name,\n 'schema_change' as test_type,\n change as test_sub_type,\n case\n when change = 'column_added'\n then 'The column \"' || column_name || '\" was added'\n when change= 'column_removed'\n then 'The column \"' || column_name || '\" was removed'\n when change= 'type_changed'\n then 'The type of \"' || column_name || '\" was changed from ' || pre_data_type || ' to ' || data_type\n else NULL\n end as test_results_description\n from all_column_changes\n {{ dbt_utils.group_by(9) }}\n\n )\n\n {# Creating a unique id for each row in the table, and adding execution id #}\n select {{ elementary.generate_surrogate_key([\n 'data_issue_id',\n elementary.const_as_string(test_execution_id)\n ]) }} as id,\n {{ elementary.const_as_string(test_execution_id) }} as test_execution_id,\n {{ elementary.const_as_string(test_unique_id) }} as test_unique_id,\n *\n from column_changes_test_results\n\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_test_execution_id", + "macro.elementary.get_test_unique_id", + "macro.elementary.null_string", + "macro.elementary.generate_surrogate_key", + "macro.elementary.datetime_now_utc_as_timestamp_column", + "macro.elementary.full_name_split", + "macro.dbt_utils.group_by", + "macro.elementary.const_as_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031516.9900448, + "supported_languages": null + }, + "macro.elementary.column_monitoring_query": { + "name": "column_monitoring_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors_query/column_monitoring_query.sql", + "original_file_path": "macros/edr/data_monitoring/monitors_query/column_monitoring_query.sql", + "unique_id": "macro.elementary.column_monitoring_query", + "macro_sql": "{% macro column_monitoring_query(monitored_table, monitored_table_relation, min_bucket_start, max_bucket_end, days_back, column_obj, column_monitors, metric_properties) %}\n {%- set full_table_name_str = elementary.edr_quote(elementary.relation_to_full_name(monitored_table_relation)) %}\n {%- set timestamp_column = metric_properties.timestamp_column %}\n\n\n with monitored_table as (\n select * from {{ monitored_table }}\n {% if metric_properties.where_expression %} where {{ metric_properties.where_expression }} {% endif %}\n ),\n\n {% if timestamp_column -%}\n buckets as (\n select edr_bucket_start, edr_bucket_end\n from ({{ elementary.complete_buckets_cte(metric_properties, min_bucket_start, max_bucket_end) }}) results\n where edr_bucket_start >= {{ elementary.edr_cast_as_timestamp(min_bucket_start) }}\n and edr_bucket_end <= {{ elementary.edr_cast_as_timestamp(max_bucket_end) }}\n ),\n\n filtered_monitored_table as (\n select {{ column_obj.quoted }},\n {{ elementary.get_start_bucket_in_data(timestamp_column, min_bucket_start, metric_properties.time_bucket) }} as start_bucket_in_data\n from monitored_table\n where\n {{ elementary.edr_cast_as_timestamp(timestamp_column) }} >= (select min(edr_bucket_start) from buckets)\n and {{ elementary.edr_cast_as_timestamp(timestamp_column) }} < (select max(edr_bucket_end) from buckets)\n ),\n {%- else %}\n filtered_monitored_table as (\n select {{ column_obj.quoted }},\n {{ elementary.null_timestamp() }} as start_bucket_in_data\n from monitored_table\n ),\n {% endif %}\n\n column_monitors as (\n\n {%- if column_monitors %}\n {%- set column = column_obj.quoted -%}\n select\n {%- if timestamp_column %}\n edr_bucket_start as bucket_start,\n edr_bucket_end as bucket_end,\n {{ elementary.timediff(\"hour\", \"edr_bucket_start\", \"edr_bucket_end\") }} as bucket_duration_hours,\n {%- else %}\n {{ elementary.null_timestamp() }} as bucket_start,\n {{ elementary.edr_cast_as_timestamp(elementary.edr_quote(elementary.run_started_at_as_string())) }} as bucket_end,\n {{ elementary.null_int() }} as bucket_duration_hours,\n {%- endif %}\n {{ elementary.const_as_string(column_obj.name) }} as edr_column_name,\n {%- if 'null_count' in column_monitors -%} {{ elementary.null_count(column) }} {%- else -%} null {% endif %} as null_count,\n {%- if 'null_percent' in column_monitors -%} {{ elementary.null_percent(column) }} {%- else -%} null {% endif %} as null_percent,\n {%- if 'not_null_percent' in column_monitors -%} {{ elementary.not_null_percent(column) }} {%- else -%} null {% endif %} as not_null_percent,\n {%- if 'max' in column_monitors -%} {{ elementary.max(column) }} {%- else -%} null {% endif %} as max,\n {%- if 'min' in column_monitors -%} {{ elementary.min(column) }} {%- else -%} null {% endif %} as min,\n {%- if 'average' in column_monitors -%} {{ elementary.average(column) }} {%- else -%} null {% endif %} as average,\n {%- if 'zero_count' in column_monitors -%} {{ elementary.zero_count(column) }} {%- else -%} null {% endif %} as zero_count,\n {%- if 'zero_percent' in column_monitors -%} {{ elementary.zero_percent(column) }} {%- else -%} null {% endif %} as zero_percent,\n {%- if 'not_zero_percent' in column_monitors -%} {{ elementary.not_zero_percent(column) }} {%- else -%} null {% endif %} as not_zero_percent,\n {%- if 'standard_deviation' in column_monitors -%} {{ elementary.standard_deviation(column) }} {%- else -%} null {% endif %} as standard_deviation,\n {%- if 'variance' in column_monitors -%} {{ elementary.variance(column) }} {%- else -%} null {% endif %} as variance,\n {%- if 'max_length' in column_monitors -%} {{ elementary.max_length(column) }} {%- else -%} null {% endif %} as max_length,\n {%- if 'min_length' in column_monitors -%} {{ elementary.min_length(column) }} {%- else -%} null {% endif %} as min_length,\n {%- if 'average_length' in column_monitors -%} {{ elementary.average_length(column) }} {%- else -%} null {% endif %} as average_length,\n {%- if 'missing_count' in column_monitors -%} {{ elementary.missing_count(column) }} {%- else -%} null {% endif %} as missing_count,\n {%- if 'missing_percent' in column_monitors -%} {{ elementary.missing_percent(column) }} {%- else -%} null {% endif %} as missing_percent,\n {%- if 'not_missing_percent' in column_monitors -%} {{ elementary.not_missing_percent(column) }} {%- else -%} null {% endif %} as not_missing_percent,\n {%- if 'sum' in column_monitors -%} {{ elementary.sum(column) }} {%- else -%} null {% endif %} as sum\n from filtered_monitored_table\n {%- if timestamp_column %}\n left join buckets on (edr_bucket_start = start_bucket_in_data)\n {%- endif %}\n group by 1,2,3,4\n {%- else %}\n {{ elementary.empty_column_monitors_cte() }}\n {%- endif %}\n\n ),\n\n column_monitors_unpivot as (\n\n {%- if column_monitors %}\n {% for monitor in column_monitors %}\n select edr_column_name, bucket_start, bucket_end, bucket_duration_hours, {{ elementary.edr_cast_as_string(elementary.edr_quote(monitor)) }} as metric_name, {{ elementary.edr_cast_as_float(monitor) }} as metric_value from column_monitors where {{ monitor }} is not null\n {% if not loop.last %} union all {% endif %}\n {%- endfor %}\n {%- else %}\n {{ elementary.empty_table([('edr_column_name','string'),('bucket_start','timestamp'),('bucket_end','timestamp'),('bucket_duration_hours','int'),('metric_name','string'),('metric_value','float')]) }}\n {%- endif %}\n\n ),\n\n metrics_final as (\n\n select\n {{ elementary.edr_cast_as_string(full_table_name_str) }} as full_table_name,\n edr_column_name as column_name,\n metric_name,\n {{ elementary.edr_cast_as_float('metric_value') }} as metric_value,\n {{ elementary.null_string() }} as source_value,\n bucket_start,\n bucket_end,\n bucket_duration_hours,\n {{ elementary.null_string() }} as dimension,\n {{ elementary.null_string() }} as dimension_value,\n {{elementary.dict_to_quoted_json(metric_properties) }} as metric_properties\n from column_monitors_unpivot\n\n )\n\n select\n {{ elementary.generate_surrogate_key([\n 'full_table_name',\n 'column_name',\n 'metric_name',\n 'bucket_end',\n 'metric_properties'\n ]) }} as id,\n full_table_name,\n column_name,\n metric_name,\n metric_value,\n source_value,\n bucket_start,\n bucket_end,\n bucket_duration_hours,\n {{ elementary.edr_current_timestamp_in_utc() }} as updated_at,\n dimension,\n dimension_value,\n metric_properties\n from metrics_final\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_quote", + "macro.elementary.relation_to_full_name", + "macro.elementary.complete_buckets_cte", + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.get_start_bucket_in_data", + "macro.elementary.null_timestamp", + "macro.elementary.timediff", + "macro.elementary.run_started_at_as_string", + "macro.elementary.null_int", + "macro.elementary.const_as_string", + "macro.elementary.null_count", + "macro.elementary.null_percent", + "macro.elementary.not_null_percent", + "macro.elementary.max", + "macro.elementary.min", + "macro.elementary.average", + "macro.elementary.zero_count", + "macro.elementary.zero_percent", + "macro.elementary.not_zero_percent", + "macro.elementary.standard_deviation", + "macro.elementary.variance", + "macro.elementary.max_length", + "macro.elementary.min_length", + "macro.elementary.average_length", + "macro.elementary.missing_count", + "macro.elementary.missing_percent", + "macro.elementary.not_missing_percent", + "macro.elementary.sum", + "macro.elementary.empty_column_monitors_cte", + "macro.elementary.edr_cast_as_string", + "macro.elementary.edr_cast_as_float", + "macro.elementary.empty_table", + "macro.elementary.null_string", + "macro.elementary.dict_to_quoted_json", + "macro.elementary.generate_surrogate_key", + "macro.elementary.edr_current_timestamp_in_utc" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0103629, + "supported_languages": null + }, + "macro.elementary.get_latest_full_refresh": { + "name": "get_latest_full_refresh", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors_query/get_latest_full_refresh.sql", + "original_file_path": "macros/edr/data_monitoring/monitors_query/get_latest_full_refresh.sql", + "unique_id": "macro.elementary.get_latest_full_refresh", + "macro_sql": "{% macro get_latest_full_refresh(model_node) %}\n {% set query %}\n select generated_at from {{ ref('dbt_run_results') }}\n where\n unique_id = '{{ model_node.unique_id }}' and\n full_refresh = true\n order by generated_at desc\n limit 1\n {% endset %}\n {% do return(elementary.result_value(query)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.result_value" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.010766, + "supported_languages": null + }, + "macro.elementary.get_start_bucket_in_data": { + "name": "get_start_bucket_in_data", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors_query/get_start_bucket_in_data.sql", + "original_file_path": "macros/edr/data_monitoring/monitors_query/get_start_bucket_in_data.sql", + "unique_id": "macro.elementary.get_start_bucket_in_data", + "macro_sql": "{% macro get_start_bucket_in_data(timestamp_column, min_bucket_start, time_bucket) %}\n {% set bucket_start_datediff_expr %}\n floor({{ elementary.edr_datediff(min_bucket_start, elementary.edr_cast_as_timestamp(timestamp_column), time_bucket.period) }} / {{ time_bucket.count }}) * {{ time_bucket.count }}\n {% endset %}\n {% do return(elementary.edr_cast_as_timestamp(elementary.edr_timeadd(time_bucket.period, elementary.edr_cast_as_int(bucket_start_datediff_expr), min_bucket_start))) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_datediff", + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.edr_timeadd", + "macro.elementary.edr_cast_as_int" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.011331, + "supported_languages": null + }, + "macro.elementary.dimension_monitoring_query": { + "name": "dimension_monitoring_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors_query/dimension_monitoring_query.sql", + "original_file_path": "macros/edr/data_monitoring/monitors_query/dimension_monitoring_query.sql", + "unique_id": "macro.elementary.dimension_monitoring_query", + "macro_sql": "{% macro dimension_monitoring_query(monitored_table, monitored_table_relation, dimensions, min_bucket_start, max_bucket_end, test_configuration, metric_properties) %}\n {% set metric_name = 'dimension' %}\n {% set full_table_name_str = elementary.edr_quote(elementary.relation_to_full_name(monitored_table_relation)) %}\n {% set dimensions_string = elementary.join_list(dimensions, '; ') %}\n {% set concat_dimensions_sql_expression = elementary.list_concat_with_separator(dimensions, '; ') %}\n {% set timestamp_column = metric_properties.timestamp_column %}\n\n with filtered_monitored_table as (\n select *,\n {{ concat_dimensions_sql_expression }} as dimension_value\n from {{ monitored_table }}\n {% if metric_properties.where_expression %}\n where {{ metric_properties.where_expression }}\n {% endif %}\n ),\n\n {% if timestamp_column %}\n buckets as (\n select\n edr_bucket_start,\n edr_bucket_end,\n 1 as joiner\n from ({{ elementary.complete_buckets_cte(metric_properties, min_bucket_start, max_bucket_end) }}) results\n where edr_bucket_start >= {{ elementary.edr_cast_as_timestamp(min_bucket_start) }}\n and edr_bucket_end <= {{ elementary.edr_cast_as_timestamp(max_bucket_end) }}\n ),\n\n time_filtered_monitored_table as (\n select *,\n {{ elementary.get_start_bucket_in_data(timestamp_column, min_bucket_start, metric_properties.time_bucket) }} as start_bucket_in_data\n from filtered_monitored_table\n where\n {{ elementary.edr_cast_as_timestamp(timestamp_column) }} >= (select min(edr_bucket_start) from buckets)\n and {{ elementary.edr_cast_as_timestamp(timestamp_column) }} < (select max(edr_bucket_end) from buckets)\n ),\n\n all_dimension_metrics as (\n select\n bucket_end,\n dimension_value,\n metric_value,\n row_number () over (partition by dimension_value order by bucket_end desc) as row_number\n from {{ ref('data_monitoring_metrics') }}\n where full_table_name = {{ full_table_name_str }}\n and metric_name = {{ elementary.edr_quote(metric_name) }}\n and metric_properties = {{ elementary.dict_to_quoted_json(metric_properties) }}\n ),\n\n training_set_dimensions as (\n select distinct\n dimension_value,\n 1 as joiner,\n min(bucket_end) as dimension_min_bucket_end,\n sum(metric_value)\n from all_dimension_metrics\n group by 1,2\n {# Remove outdated dimension values (dimensions with all metrics of 0 in the range of the test time) #}\n having sum(metric_value) > 0\n ),\n\n {# Create buckets for each previous dimension value #}\n dimensions_buckets as (\n select edr_bucket_start, edr_bucket_end, dimension_value\n from training_set_dimensions left join buckets\n on (buckets.joiner = training_set_dimensions.joiner\n {# This makes sure we don't create empty buckets for dimensions before their first appearance #}\n and edr_bucket_end >= dimension_min_bucket_end)\n where dimension_value is not null\n ),\n\n {# Calculating the row count for the value of each dimension #}\n row_count_values as (\n select\n edr_bucket_start,\n edr_bucket_end,\n start_bucket_in_data,\n dimension_value,\n case when start_bucket_in_data is null then\n 0\n else {{ elementary.edr_cast_as_float(elementary.row_count()) }} end as row_count_value\n from buckets left join time_filtered_monitored_table on (edr_bucket_start = start_bucket_in_data)\n group by 1,2,3,4\n ),\n\n {# Merging between the row count and the dimensions buckets #}\n {# This way we make sure that if a dimension has no rows, it will get a metric with value 0 #}\n fill_empty_buckets_row_count_values as (\n select dimensions_buckets.edr_bucket_start,\n dimensions_buckets.edr_bucket_end,\n start_bucket_in_data,\n dimensions_buckets.dimension_value,\n case when start_bucket_in_data is null then\n 0\n else row_count_value end as row_count_value\n from dimensions_buckets left join row_count_values\n on (dimensions_buckets.edr_bucket_start = start_bucket_in_data and dimensions_buckets.dimension_value = row_count_values.dimension_value)\n ),\n\n {# We union so new buckets added in this run will be included (were filtered by the join we did on 'fill_empty_buckets_row_count_values') #}\n union_row_count_values as (\n select distinct *\n from\n (\n select * from row_count_values\n union all\n select * from fill_empty_buckets_row_count_values\n ) as results\n ),\n\n row_count as (\n select edr_bucket_start,\n edr_bucket_end,\n {{ elementary.const_as_string(metric_name) }} as metric_name,\n {{ elementary.null_string() }} as source_value,\n row_count_value as metric_value,\n {{ elementary.const_as_string(dimensions_string) }} as dimension,\n dimension_value,\n {{elementary.dict_to_quoted_json(metric_properties) }} as metric_properties\n from union_row_count_values\n ),\n\n metrics_final as (\n\n select\n {{ elementary.edr_cast_as_string(full_table_name_str) }} as full_table_name,\n {{ elementary.null_string() }} as column_name,\n metric_name,\n {{ elementary.edr_cast_as_float('metric_value') }} as metric_value,\n source_value,\n edr_bucket_start as bucket_start,\n edr_bucket_end as bucket_end,\n {{ elementary.timediff(\"hour\", \"edr_bucket_start\", \"edr_bucket_end\") }} as bucket_duration_hours,\n dimension,\n dimension_value,\n metric_properties\n from row_count\n where (metric_value is not null and cast(metric_value as {{ elementary.edr_type_int() }}) < {{ elementary.get_config_var('max_int') }}) or\n metric_value is null\n )\n\n {% else %}\n\n {# Get all of the dimension anomaly metrics that were created for the test until this run #}\n all_dimension_metrics as (\n select\n bucket_end,\n dimension_value,\n metric_value,\n row_number () over (partition by dimension_value order by bucket_end desc) as row_number\n from {{ ref('data_monitoring_metrics') }}\n where full_table_name = {{ full_table_name_str }}\n and metric_name = {{ elementary.edr_quote(metric_name) }}\n and metric_properties = {{ elementary.dict_to_quoted_json(metric_properties) }}\n ),\n\n training_set_dimensions as (\n select distinct\n dimension_value,\n sum(metric_value)\n from all_dimension_metrics\n group by 1\n {# Remove outdated dimension values (dimensions with all metrics of 0 in the range of the test time) #}\n having sum(metric_value) > 0\n ),\n\n {# Calculating the row count for the value of each dimension #}\n row_count_values as (\n select\n {{ elementary.edr_cast_as_timestamp(elementary.edr_quote(elementary.run_started_at_as_string())) }} as bucket_end,\n dimension_value,\n {{ elementary.edr_cast_as_float(elementary.row_count()) }} as row_count_value\n from filtered_monitored_table\n group by 1,2\n ),\n\n {# This way we make sure that if a dimension has no rows, it will get a metric with value 0 #}\n fill_empty_dimensions_row_count_values as (\n select {{ elementary.edr_cast_as_timestamp(elementary.edr_quote(elementary.run_started_at_as_string())) }} as bucket_end,\n dimension_value,\n 0 as row_count_value\n from training_set_dimensions\n where dimension_value not in (select distinct dimension_value from row_count_values)\n ),\n\n {# Union between current row count for each dimension, and the \"hydrated\" metrics of the test until this run #}\n row_count as (\n select * from row_count_values\n union all\n select * from fill_empty_dimensions_row_count_values\n ),\n\n metrics_final as (\n select\n {{ elementary.edr_cast_as_string(full_table_name_str) }} as full_table_name,\n {{ elementary.null_string() }} as column_name,\n {{ elementary.const_as_string(metric_name) }} as metric_name,\n {{ elementary.edr_cast_as_float('row_count_value') }} as metric_value,\n {{ elementary.null_string() }} as source_value,\n {{ elementary.null_timestamp() }} as bucket_start,\n bucket_end,\n {{ elementary.null_int() }} as bucket_duration_hours,\n {{ elementary.const_as_string(dimensions_string) }} as dimension,\n dimension_value,\n {{ elementary.dict_to_quoted_json(metric_properties) }} as metric_properties\n from row_count\n )\n {% endif %}\n\n select\n {{ elementary.generate_surrogate_key([\n 'full_table_name',\n 'column_name',\n 'metric_name',\n 'dimension',\n 'dimension_value',\n 'bucket_end',\n 'metric_properties']) }} as id,\n full_table_name,\n column_name,\n metric_name,\n metric_value,\n source_value,\n bucket_start,\n bucket_end,\n bucket_duration_hours,\n {{ elementary.edr_current_timestamp_in_utc() }} as updated_at,\n dimension,\n dimension_value,\n metric_properties\n from metrics_final\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_quote", + "macro.elementary.relation_to_full_name", + "macro.elementary.join_list", + "macro.elementary.list_concat_with_separator", + "macro.elementary.complete_buckets_cte", + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.get_start_bucket_in_data", + "macro.elementary.dict_to_quoted_json", + "macro.elementary.edr_cast_as_float", + "macro.elementary.row_count", + "macro.elementary.const_as_string", + "macro.elementary.null_string", + "macro.elementary.edr_cast_as_string", + "macro.elementary.timediff", + "macro.elementary.edr_type_int", + "macro.elementary.get_config_var", + "macro.elementary.run_started_at_as_string", + "macro.elementary.null_timestamp", + "macro.elementary.null_int", + "macro.elementary.generate_surrogate_key", + "macro.elementary.edr_current_timestamp_in_utc" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.021685, + "supported_languages": null + }, + "macro.elementary.table_monitoring_query": { + "name": "table_monitoring_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "original_file_path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "unique_id": "macro.elementary.table_monitoring_query", + "macro_sql": "{% macro table_monitoring_query(monitored_table, monitored_table_relation, min_bucket_start, max_bucket_end, table_monitors, metric_properties) %}\n\n {{ elementary.get_table_monitoring_query(monitored_table, monitored_table_relation, min_bucket_start, max_bucket_end, table_monitors, metric_properties) }}\n\n select\n {{ elementary.generate_surrogate_key([\n 'full_table_name',\n 'column_name',\n 'metric_name',\n 'bucket_end',\n 'metric_properties'\n ]) }} as id,\n full_table_name,\n column_name,\n metric_name,\n metric_value,\n source_value,\n bucket_start,\n bucket_end,\n bucket_duration_hours,\n {{ elementary.edr_current_timestamp_in_utc() }} as updated_at,\n dimension,\n dimension_value,\n metric_properties\n from metrics_final\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_table_monitoring_query", + "macro.elementary.generate_surrogate_key", + "macro.elementary.edr_current_timestamp_in_utc" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.039509, + "supported_languages": null + }, + "macro.elementary.get_table_monitoring_query": { + "name": "get_table_monitoring_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "original_file_path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "unique_id": "macro.elementary.get_table_monitoring_query", + "macro_sql": "{% macro get_table_monitoring_query(monitored_table, monitored_table_relation, min_bucket_start, max_bucket_end, table_monitors, metric_properties) %}\n {%- set full_table_name_str = elementary.edr_quote(elementary.relation_to_full_name(monitored_table_relation)) %}\n {%- set timestamp_column = metric_properties.timestamp_column %}\n\n {%- if timestamp_column %}\n {{ elementary.get_timestamp_table_query(monitored_table, metric_properties, timestamp_column, table_monitors, min_bucket_start, max_bucket_end, full_table_name_str) }}\n {%- elif table_monitors == [\"row_count\"] %}\n {{ elementary.get_no_timestamp_volume_query(monitored_table, metric_properties, full_table_name_str) }}\n {%- elif table_monitors == [\"event_freshness\"] %}\n {# Event freshness with only event_timestamp and not update_timestamp #}\n {{ elementary.get_no_timestamp_event_freshness_query(monitored_table, metric_properties, full_table_name_str) }}\n {%- else %}\n {% do exceptions.raise_compiler_error(\"freshness_anomalies test is not supported without timestamp_column.\") %}\n {# TODO: We can enhance this test for models to use model_run_results in case a timestamp column is not defined #}\n {% do return(none) %}\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_quote", + "macro.elementary.relation_to_full_name", + "macro.elementary.get_timestamp_table_query", + "macro.elementary.get_no_timestamp_volume_query", + "macro.elementary.get_no_timestamp_event_freshness_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.04033, + "supported_languages": null + }, + "macro.elementary.get_no_timestamp_volume_query": { + "name": "get_no_timestamp_volume_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "original_file_path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "unique_id": "macro.elementary.get_no_timestamp_volume_query", + "macro_sql": "{% macro get_no_timestamp_volume_query(monitored_table, metric_properties, full_table_name_str) %}\n with monitored_table_metrics as (\n select\n {{ elementary.const_as_string('row_count') }} as metric_name,\n {{ elementary.row_count() }} as metric_value\n from {{ monitored_table }}\n {% if metric_properties.where_expression %} where {{ metric_properties.where_expression }} {% endif %}\n group by 1\n ),\n metrics_final as (\n select\n {{ elementary.edr_cast_as_string(full_table_name_str) }} as full_table_name,\n {{ elementary.null_string() }} as column_name,\n metric_name,\n {{ elementary.edr_cast_as_float('metric_value') }} as metric_value,\n {{ elementary.null_string() }} as source_value,\n {{ elementary.null_timestamp() }} as bucket_start,\n {{ elementary.edr_cast_as_timestamp(elementary.edr_quote(elementary.run_started_at_as_string())) }} as bucket_end,\n {{ elementary.null_int() }} as bucket_duration_hours,\n {{ elementary.null_string() }} as dimension,\n {{ elementary.null_string() }} as dimension_value,\n {{elementary.dict_to_quoted_json(metric_properties) }} as metric_properties\n from monitored_table_metrics\n )\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.const_as_string", + "macro.elementary.row_count", + "macro.elementary.edr_cast_as_string", + "macro.elementary.null_string", + "macro.elementary.edr_cast_as_float", + "macro.elementary.null_timestamp", + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.edr_quote", + "macro.elementary.run_started_at_as_string", + "macro.elementary.null_int", + "macro.elementary.dict_to_quoted_json" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0410671, + "supported_languages": null + }, + "macro.elementary.get_timestamp_table_query": { + "name": "get_timestamp_table_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "original_file_path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "unique_id": "macro.elementary.get_timestamp_table_query", + "macro_sql": "{% macro get_timestamp_table_query(monitored_table, metric_properties, timestamp_column, table_monitors, min_bucket_start, max_bucket_end, full_table_name_str) %}\n with partially_time_filtered_monitored_table as (\n select\n {{ elementary.edr_cast_as_timestamp(timestamp_column) }} as {{ timestamp_column }}\n {%- if metric_properties.timestamp_column and metric_properties.event_timestamp_column %}\n , {{ elementary.edr_cast_as_timestamp(metric_properties.event_timestamp_column) }} as {{ metric_properties.event_timestamp_column }}\n {%- endif %}\n from {{ monitored_table }}\n -- Freshness metric calculated differences between consecutive buckets, thus the first diff\n -- is always null. Therefore we let few old buckets inside the query and filter them later, just for\n -- the first relevant diff not to be null\n where {{ elementary.edr_cast_as_timestamp(timestamp_column) }} >= {{ elementary.edr_timeadd(\"day\", -7, elementary.edr_cast_as_timestamp(min_bucket_start)) }}\n {% if metric_properties.where_expression %} and {{ metric_properties.where_expression }} {% endif %}\n ),\n monitored_table as (\n select\n *\n from partially_time_filtered_monitored_table\n where {{ timestamp_column }} >= {{ elementary.edr_cast_as_timestamp(min_bucket_start) }}\n ),\n buckets as (\n select edr_bucket_start, edr_bucket_end\n from ({{ elementary.complete_buckets_cte(metric_properties, min_bucket_start, max_bucket_end) }}) results\n where edr_bucket_start >= {{ elementary.edr_cast_as_timestamp(min_bucket_start) }}\n and edr_bucket_end <= {{ elementary.edr_cast_as_timestamp(max_bucket_end) }}\n ),\n\n time_filtered_monitored_table as (\n select *,\n {{ elementary.get_start_bucket_in_data(timestamp_column, min_bucket_start, metric_properties.time_bucket) }} as start_bucket_in_data\n from monitored_table\n where\n {{ timestamp_column }} >= (select min(edr_bucket_start) from buckets)\n and {{ timestamp_column }} < (select max(edr_bucket_end) from buckets)\n {# To avoid adding buckets before the table first timestamp #}\n and {{ timestamp_column }} >= (select min({{ timestamp_column }}) from monitored_table)\n ),\n\n metrics as (\n {{ elementary.get_unified_metrics_query(metrics=table_monitors,\n metric_properties=metric_properties) }}\n ),\n\n metrics_final as (\n select\n {{ elementary.edr_cast_as_string(full_table_name_str) }} as full_table_name,\n {{ elementary.null_string() }} as column_name,\n metric_name,\n {{ elementary.edr_cast_as_float('metric_value') }} as metric_value,\n source_value,\n edr_bucket_start as bucket_start,\n edr_bucket_end as bucket_end,\n {{ elementary.timediff(\"hour\", \"edr_bucket_start\", \"edr_bucket_end\") }} as bucket_duration_hours,\n {{ elementary.null_string() }} as dimension,\n {{ elementary.null_string() }} as dimension_value,\n {{elementary.dict_to_quoted_json(metric_properties) }} as metric_properties\n from\n metrics\n where (metric_value is not null and cast(metric_value as {{ elementary.edr_type_int() }}) < {{ elementary.get_config_var('max_int') }}) or\n metric_value is null\n )\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.edr_timeadd", + "macro.elementary.complete_buckets_cte", + "macro.elementary.get_start_bucket_in_data", + "macro.elementary.get_unified_metrics_query", + "macro.elementary.edr_cast_as_string", + "macro.elementary.null_string", + "macro.elementary.edr_cast_as_float", + "macro.elementary.timediff", + "macro.elementary.dict_to_quoted_json", + "macro.elementary.edr_type_int", + "macro.elementary.get_config_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.04258, + "supported_languages": null + }, + "macro.elementary.get_unified_metrics_query": { + "name": "get_unified_metrics_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "original_file_path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "unique_id": "macro.elementary.get_unified_metrics_query", + "macro_sql": "{% macro get_unified_metrics_query(metrics, metric_properties) %}\n {%- set included_monitors = {} %}\n {%- for metric_name in metrics %}\n {%- set metric_query = elementary.get_metric_query(metric_name, metric_properties) %}\n {%- if metric_query %}\n {% do included_monitors.update({metric_name: metric_query}) %}\n {%- endif %}\n {%- endfor %}\n\n {% if not included_monitors %}\n {% if metric_properties.timestamp_column %}\n {% do return(elementary.empty_table([('edr_bucket_start','timestamp'),('edr_bucket_end','timestamp'),('metric_name','string'),('source_value','string'),('metric_value','int')])) %}\n {% else %}\n {% do return(elementary.empty_table([('metric_name','string'),('metric_value','int')])) %}\n {% endif %}\n {% endif %}\n\n with\n {%- for metric_name, metric_query in included_monitors.items() %}\n {{ metric_name }} as (\n {{ metric_query }}\n ){% if not loop.last %},{% endif %}\n {%- endfor %}\n\n {%- for metric_name in included_monitors %}\n select * from {{ metric_name }}\n {% if not loop.last %} union all {% endif %}\n {%- endfor %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_metric_query", + "macro.elementary.empty_table" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.043829, + "supported_languages": null + }, + "macro.elementary.get_metric_query": { + "name": "get_metric_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "original_file_path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "unique_id": "macro.elementary.get_metric_query", + "macro_sql": "{% macro get_metric_query(metric_name, metric_properties) %}\n {%- set metrics_macro_mapping = {\n \"row_count\": elementary.row_count_metric_query,\n \"freshness\": elementary.freshness_metric_query,\n \"event_freshness\": elementary.event_freshness_metric_query\n } %}\n\n {%- set metric_macro = metrics_macro_mapping.get(metric_name) %}\n {%- if not metric_macro %}\n {%- do return(none) %}\n {%- endif %}\n\n {%- set metric_query = metric_macro(metric_properties) %}\n {%- if not metric_query %}\n {%- do return(none) %}\n {%- endif %}\n\n {{ metric_query }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.044367, + "supported_languages": null + }, + "macro.elementary.row_count_metric_query": { + "name": "row_count_metric_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "original_file_path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "unique_id": "macro.elementary.row_count_metric_query", + "macro_sql": "{% macro row_count_metric_query(metric_properties) %}\n with row_count_values as (\n select edr_bucket_start,\n edr_bucket_end,\n start_bucket_in_data,\n case when start_bucket_in_data is null then\n 0\n else {{ elementary.edr_cast_as_float(elementary.row_count()) }} end as row_count_value\n from buckets left join time_filtered_monitored_table on (edr_bucket_start = start_bucket_in_data)\n group by 1,2,3\n )\n\n select edr_bucket_start,\n edr_bucket_end,\n {{ elementary.const_as_string('row_count') }} as metric_name,\n {{ elementary.null_string() }} as source_value,\n row_count_value as metric_value\n from row_count_values\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_float", + "macro.elementary.row_count", + "macro.elementary.const_as_string", + "macro.elementary.null_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.044637, + "supported_languages": null + }, + "macro.elementary.freshness_metric_query": { + "name": "freshness_metric_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "original_file_path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "unique_id": "macro.elementary.freshness_metric_query", + "macro_sql": "{% macro freshness_metric_query(metric_properties) %}\n {%- set freshness_column = metric_properties.freshness_column %}\n {%- if not freshness_column %}\n {%- set freshness_column = metric_properties.timestamp_column %}\n {%- endif %}\n\n -- get ordered consecutive update timestamps in the source data\n with unique_timestamps as (\n select distinct {{ elementary.edr_cast_as_timestamp(freshness_column) }} as timestamp_val\n from partially_time_filtered_monitored_table\n order by 1\n ),\n\n -- compute freshness for every update as the time difference from the previous update\n consecutive_updates_freshness as (\n select\n timestamp_val as update_timestamp,\n {{ elementary.timediff('second', 'lag(timestamp_val) over (order by timestamp_val)', 'timestamp_val') }} as freshness\n from unique_timestamps\n ),\n time_filtered_consecutive_updates_freshness as (\n select\n *\n from consecutive_updates_freshness\n where update_timestamp >= (select min(edr_bucket_start) from buckets)\n ),\n -- divide the freshness metrics above to buckets\n bucketed_consecutive_updates_freshness as (\n select\n edr_bucket_start, edr_bucket_end, update_timestamp, freshness\n from buckets cross join time_filtered_consecutive_updates_freshness\n where update_timestamp >= edr_bucket_start AND update_timestamp < edr_bucket_end\n ),\n\n -- we also want to record the freshness at the end of each bucket as an additional point. By this we mean\n -- the time that passed since the last update in the bucket and the end of the bucket.\n bucket_end_freshness as (\n select\n edr_bucket_start,\n edr_bucket_end,\n max(timestamp_val) as update_timestamp,\n {{ elementary.timediff('second', elementary.edr_cast_as_timestamp('max(timestamp_val)'), \"least(edr_bucket_end, {})\".format(elementary.current_timestamp_column())) }} as freshness\n from buckets cross join unique_timestamps\n where timestamp_val < edr_bucket_end\n group by 1,2\n ),\n\n -- create a single table with all the freshness values\n bucket_all_freshness_metrics as (\n select * from bucketed_consecutive_updates_freshness\n union all\n select * from bucket_end_freshness\n ),\n\n -- get all the freshness values, ranked by size (we use partition by and not group by, because we also want to have\n -- the associated timestamp as source value)\n bucket_freshness_ranked as (\n select\n *,\n row_number () over (partition by edr_bucket_end order by freshness is null, freshness desc) as row_number\n from bucket_all_freshness_metrics\n )\n\n select\n edr_bucket_start,\n edr_bucket_end,\n {{ elementary.const_as_string('freshness') }} as metric_name,\n {{ elementary.edr_cast_as_string('update_timestamp') }} as source_value,\n freshness as metric_value\n from bucket_freshness_ranked\n where row_number = 1\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.timediff", + "macro.elementary.current_timestamp_column", + "macro.elementary.const_as_string", + "macro.elementary.edr_cast_as_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.045334, + "supported_languages": null + }, + "macro.elementary.event_freshness_metric_query": { + "name": "event_freshness_metric_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "original_file_path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "unique_id": "macro.elementary.event_freshness_metric_query", + "macro_sql": "{% macro event_freshness_metric_query(metric_properties) %}\n{% set event_timestamp_column = metric_properties.event_timestamp_column %}\n{% set update_timestamp_column = metric_properties.timestamp_column %}\n select\n edr_bucket_start,\n edr_bucket_end,\n {{ elementary.const_as_string('event_freshness') }} as metric_name,\n {{ elementary.edr_cast_as_string('max({})'.format(event_timestamp_column)) }} as source_value,\n {{ 'coalesce(max({}), {})'.format(\n elementary.timediff('second', elementary.edr_cast_as_timestamp(event_timestamp_column), elementary.edr_cast_as_timestamp(update_timestamp_column)),\n elementary.timediff('second', 'edr_bucket_start', 'edr_bucket_end')\n ) }} as metric_value\n from buckets left join time_filtered_monitored_table on (edr_bucket_start = start_bucket_in_data)\n group by 1,2\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.const_as_string", + "macro.elementary.edr_cast_as_string", + "macro.elementary.timediff", + "macro.elementary.edr_cast_as_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0458639, + "supported_languages": null + }, + "macro.elementary.get_no_timestamp_event_freshness_query": { + "name": "get_no_timestamp_event_freshness_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "original_file_path": "macros/edr/data_monitoring/monitors_query/table_monitoring_query.sql", + "unique_id": "macro.elementary.get_no_timestamp_event_freshness_query", + "macro_sql": "{% macro get_no_timestamp_event_freshness_query(monitored_table, metric_properties, full_table_name_str) %}\n with monitored_table_metrics as (\n select\n {{ elementary.const_as_string('event_freshness') }} as metric_name,\n {{ elementary.timediff('second', elementary.edr_cast_as_timestamp(\"max({})\".format(metric_properties.event_timestamp_column)), elementary.edr_quote(elementary.get_run_started_at())) }} as metric_value\n from {{ monitored_table }}\n {% if metric_properties.where_expression %} where {{ metric_properties.where_expression }} {% endif %}\n group by 1\n ),\n metrics_final as (\n select\n {{ elementary.edr_cast_as_string(full_table_name_str) }} as full_table_name,\n {{ elementary.null_string() }} as column_name,\n metric_name,\n {{ elementary.edr_cast_as_float('metric_value') }} as metric_value,\n {{ elementary.null_string() }} as source_value,\n {{ elementary.null_timestamp() }} as bucket_start,\n {{ elementary.edr_cast_as_timestamp(elementary.edr_quote(elementary.run_started_at_as_string())) }} as bucket_end,\n {{ elementary.null_int() }} as bucket_duration_hours,\n {{ elementary.null_string() }} as dimension,\n {{ elementary.null_string() }} as dimension_value,\n {{elementary.dict_to_quoted_json(metric_properties) }} as metric_properties\n from monitored_table_metrics\n )\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.const_as_string", + "macro.elementary.timediff", + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.edr_quote", + "macro.elementary.get_run_started_at", + "macro.elementary.edr_cast_as_string", + "macro.elementary.null_string", + "macro.elementary.edr_cast_as_float", + "macro.elementary.null_timestamp", + "macro.elementary.run_started_at_as_string", + "macro.elementary.null_int", + "macro.elementary.dict_to_quoted_json" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.046732, + "supported_languages": null + }, + "macro.elementary.get_column_obj_and_monitors": { + "name": "get_column_obj_and_monitors", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/data_monitors_configuration/get_column_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/data_monitors_configuration/get_column_monitors.sql", + "unique_id": "macro.elementary.get_column_obj_and_monitors", + "macro_sql": "{% macro get_column_obj_and_monitors(model_relation, column_name, column_tests=none) %}\n\n {% set column_obj_and_monitors = [] %}\n {% set column_objects = adapter.get_columns_in_relation(model_relation) %}\n {% for column_obj in column_objects %}\n {% if column_obj.name | lower == column_name | lower %}\n {% set column_monitors = elementary.column_monitors_by_type(elementary.get_column_data_type(column_obj), column_tests) %}\n {% set column_item = {'column': column_obj, 'monitors': column_monitors} %}\n {{ return(column_item) }}\n {% endif %}\n {% endfor %}\n\n {{ return(none) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.column_monitors_by_type", + "macro.elementary.get_column_data_type" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.04916, + "supported_languages": null + }, + "macro.elementary.get_all_column_obj_and_monitors": { + "name": "get_all_column_obj_and_monitors", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/data_monitors_configuration/get_column_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/data_monitors_configuration/get_column_monitors.sql", + "unique_id": "macro.elementary.get_all_column_obj_and_monitors", + "macro_sql": "{% macro get_all_column_obj_and_monitors(model_relation, column_tests=none) %}\n\n {% set column_obj_and_monitors = [] %}\n {% set column_objects = adapter.get_columns_in_relation(model_relation) %}\n\n {% for column_obj in column_objects %}\n {% set column_monitors = elementary.column_monitors_by_type(elementary.get_column_data_type(column_obj), column_tests) %}\n {% set column_item = {'column': column_obj, 'monitors': column_monitors} %}\n {% do column_obj_and_monitors.append(column_item) %}\n {% endfor %}\n\n {{ return(column_obj_and_monitors) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.column_monitors_by_type", + "macro.elementary.get_column_data_type" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0497222, + "supported_languages": null + }, + "macro.elementary.column_monitors_by_type": { + "name": "column_monitors_by_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/data_monitors_configuration/get_column_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/data_monitors_configuration/get_column_monitors.sql", + "unique_id": "macro.elementary.column_monitors_by_type", + "macro_sql": "{% macro column_monitors_by_type(data_type, column_tests=none) %}\n {% set normalized_data_type = elementary.normalize_data_type(data_type) %}\n {% set monitors = [] %}\n {% set chosen_monitors = column_tests or elementary.get_agg_column_monitors(only_defaults=true) %}\n {% set available_monitors = elementary.get_available_monitors() %}\n\n {% set any_type_monitors = elementary.lists_intersection(chosen_monitors, available_monitors[\"column_any_type\"]) %}\n {% do monitors.extend(any_type_monitors) %}\n {% if normalized_data_type == 'numeric' %}\n {% set numeric_monitors = elementary.lists_intersection(chosen_monitors, available_monitors[\"column_numeric\"]) %}\n {% do monitors.extend(numeric_monitors) %}\n {% elif normalized_data_type == 'string' %}\n {% set string_monitors = elementary.lists_intersection(chosen_monitors, available_monitors[\"column_string\"]) %}\n {% do monitors.extend(string_monitors) %}\n {% endif %}\n {{ return(monitors | unique | list) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.normalize_data_type", + "macro.elementary.get_agg_column_monitors", + "macro.elementary.get_available_monitors", + "macro.elementary.lists_intersection" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.05069, + "supported_languages": null + }, + "macro.elementary.get_agg_column_monitors": { + "name": "get_agg_column_monitors", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/data_monitors_configuration/get_column_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/data_monitors_configuration/get_column_monitors.sql", + "unique_id": "macro.elementary.get_agg_column_monitors", + "macro_sql": "{% macro get_agg_column_monitors(only_defaults=false) %}\n {% set agg_column_monitors = [] %}\n {% if only_defaults %}\n {% set monitors = elementary.get_default_monitors() %}\n {% else %}\n {% set monitors = elementary.get_available_monitors() %}\n {% endif %}\n {% do agg_column_monitors.extend(monitors['column_any_type']) %}\n {% do agg_column_monitors.extend(monitors['column_string']) %}\n {% do agg_column_monitors.extend(monitors['column_numeric']) %}\n {{ return(agg_column_monitors) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_default_monitors", + "macro.elementary.get_available_monitors" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0512571, + "supported_languages": null + }, + "macro.elementary.get_final_table_monitors": { + "name": "get_final_table_monitors", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/data_monitors_configuration/get_table_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/data_monitors_configuration/get_table_monitors.sql", + "unique_id": "macro.elementary.get_final_table_monitors", + "macro_sql": "{% macro get_final_table_monitors(table_anomalies) %}\n {%- set final_table_monitors = [] %}\n\n {%- if table_anomalies and table_anomalies | length > 0 %}\n {%- set allowed_table_monitors = elementary.get_allowed_table_monitors() %}\n {%- set final_table_monitors = elementary.lists_intersection(table_anomalies, allowed_table_monitors) %}\n {%- else %}\n {%- set final_table_monitors = elementary.get_default_table_monitors() %}\n {%- endif %}\n {{ return(final_table_monitors) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_allowed_table_monitors", + "macro.elementary.lists_intersection", + "macro.elementary.get_default_table_monitors" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.051959, + "supported_languages": null + }, + "macro.elementary.get_default_table_monitors": { + "name": "get_default_table_monitors", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/data_monitors_configuration/get_table_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/data_monitors_configuration/get_table_monitors.sql", + "unique_id": "macro.elementary.get_default_table_monitors", + "macro_sql": "{% macro get_default_table_monitors() %}\n {%- set default_table_monitors = elementary.get_config_var('edr_monitors')['table'] | list %}\n {{ return(default_table_monitors) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_config_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0521688, + "supported_languages": null + }, + "macro.elementary.get_allowed_table_monitors": { + "name": "get_allowed_table_monitors", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/data_monitors_configuration/get_table_monitors.sql", + "original_file_path": "macros/edr/data_monitoring/data_monitors_configuration/get_table_monitors.sql", + "unique_id": "macro.elementary.get_allowed_table_monitors", + "macro_sql": "{% macro get_allowed_table_monitors() %}\n {% do return([\"row_count\", \"freshness\", \"event_freshness\"]) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.052327, + "supported_languages": null + }, + "macro.elementary.get_detection_end": { + "name": "get_detection_end", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/data_monitors_configuration/get_buckets_configuration.sql", + "original_file_path": "macros/edr/data_monitoring/data_monitors_configuration/get_buckets_configuration.sql", + "unique_id": "macro.elementary.get_detection_end", + "macro_sql": "{% macro get_detection_end(detection_delay) %}\n {%- set kwargs = {detection_delay.period+'s': detection_delay.count} %}\n {%- set detection_end = elementary.get_run_started_at() - modules.datetime.timedelta(**kwargs) %}\n {{ return(detection_end) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_run_started_at" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0548851, + "supported_languages": null + }, + "macro.elementary.get_trunc_min_bucket_start_expr": { + "name": "get_trunc_min_bucket_start_expr", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/data_monitors_configuration/get_buckets_configuration.sql", + "original_file_path": "macros/edr/data_monitoring/data_monitors_configuration/get_buckets_configuration.sql", + "unique_id": "macro.elementary.get_trunc_min_bucket_start_expr", + "macro_sql": "{% macro get_trunc_min_bucket_start_expr(detection_end, metric_properties, days_back) %}\n {%- set untruncated_min = (detection_end - modules.datetime.timedelta(days_back | int)).strftime(\"%Y-%m-%d 00:00:00\") %}\n {%- set trunc_min_bucket_start_expr = elementary.edr_date_trunc(metric_properties.time_bucket.period, elementary.edr_cast_as_timestamp(elementary.edr_quote(untruncated_min)))%}\n {{ return(trunc_min_bucket_start_expr) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_date_trunc", + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.edr_quote" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.055295, + "supported_languages": null + }, + "macro.elementary.get_backfill_bucket_start": { + "name": "get_backfill_bucket_start", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/data_monitors_configuration/get_buckets_configuration.sql", + "original_file_path": "macros/edr/data_monitoring/data_monitors_configuration/get_buckets_configuration.sql", + "unique_id": "macro.elementary.get_backfill_bucket_start", + "macro_sql": "{% macro get_backfill_bucket_start(detection_end, backfill_days) %}\n {% do return((detection_end - modules.datetime.timedelta(backfill_days)).strftime(\"%Y-%m-%d 00:00:00\")) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.055518, + "supported_languages": null + }, + "macro.elementary.get_test_buckets_min_and_max": { + "name": "get_test_buckets_min_and_max", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/edr/data_monitoring/data_monitors_configuration/get_buckets_configuration.sql", + "original_file_path": "macros/edr/data_monitoring/data_monitors_configuration/get_buckets_configuration.sql", + "unique_id": "macro.elementary.get_test_buckets_min_and_max", + "macro_sql": "{% macro get_test_buckets_min_and_max(model_relation, backfill_days, days_back, detection_delay, monitors=none, column_name=none, metric_properties=none, unit_test=false, unit_test_relation=none) %}\n\n {%- set detection_end = elementary.get_detection_end(detection_delay) %}\n {%- set detection_end_expr = elementary.edr_cast_as_timestamp(elementary.edr_quote(detection_end)) %}\n {%- set trunc_min_bucket_start_expr = elementary.get_trunc_min_bucket_start_expr(detection_end, metric_properties, days_back) %}\n {%- set backfill_bucket_start = elementary.edr_cast_as_timestamp(elementary.edr_quote(elementary.get_backfill_bucket_start(detection_end, backfill_days))) %}\n {%- set full_table_name = elementary.relation_to_full_name(model_relation) %}\n {%- set force_metrics_backfill = elementary.get_config_var('force_metrics_backfill') %}\n\n {%- if monitors %}\n {%- set monitors_tuple = elementary.strings_list_to_tuple(monitors) %}\n {%- endif %}\n\n {%- if unit_test %}\n {%- set data_monitoring_metrics_relation = dbt.load_relation(unit_test_relation) %}\n {%- else %}\n {%- set data_monitoring_metrics_relation = ref('data_monitoring_metrics') %}\n {%- endif %}\n\n {%- set regular_bucket_times_query %}\n with bucket_times as (\n select\n {{ trunc_min_bucket_start_expr }} as days_back_start\n , {{ detection_end_expr }} as detection_end\n ),\n full_buckets_calc as (\n select *,\n floor({{ elementary.edr_datediff('days_back_start', 'detection_end', metric_properties.time_bucket.period) }} / {{ metric_properties.time_bucket.count }}) * {{ metric_properties.time_bucket.count }} as periods_until_max\n from bucket_times\n )\n select\n days_back_start as min_bucket_start,\n {{ elementary.edr_timeadd(metric_properties.time_bucket.period, 'periods_until_max', 'days_back_start') }} {# Add full buckets to last_max_bucket_end #}\n as max_bucket_end\n from full_buckets_calc\n {%- endset %}\n\n {%- set incremental_bucket_times_query %}\n with all_buckets as (\n select edr_bucket_start as bucket_start, edr_bucket_end as bucket_end\n from ({{ elementary.complete_buckets_cte(metric_properties, trunc_min_bucket_start_expr, detection_end_expr) }}) results\n where edr_bucket_start >= {{ trunc_min_bucket_start_expr }}\n and edr_bucket_end <= {{ detection_end_expr }}\n ),\n buckets_with_existing_metrics as (\n select distinct bucket_start, bucket_end\n from {{ data_monitoring_metrics_relation }}\n where bucket_start >= {{ trunc_min_bucket_start_expr }}\n and bucket_end <= {{ detection_end_expr }}\n and upper(full_table_name) = upper('{{ full_table_name }}')\n and metric_properties = {{ elementary.dict_to_quoted_json(metric_properties) }}\n {%- if monitors %}\n and metric_name in {{ monitors_tuple }}\n {%- endif %}\n {%- if column_name %}\n and upper(column_name) = upper('{{ column_name }}')\n {%- endif %}\n ),\n missing_bucket_starts as (\n select all_buckets.bucket_start\n from all_buckets\n left outer join buckets_with_existing_metrics existing on (\n existing.bucket_start = all_buckets.bucket_start and\n existing.bucket_end = all_buckets.bucket_end\n )\n where existing.bucket_start is NULL\n ),\n min_bucket_start_candidates as (\n select bucket_start from missing_bucket_starts\n union all\n select {{ backfill_bucket_start }} as bucket_start\n )\n select\n min(bucket_start) as min_bucket_start,\n {{ detection_end_expr }} as max_bucket_end\n from min_bucket_start_candidates\n {% endset %}\n\n {# We assume we should also cosider sources as incremental #}\n {% if force_metrics_backfill or not (elementary.is_incremental_model(elementary.get_model_graph_node(model_relation), source_included=true) or unit_test) %}\n {%- set buckets = elementary.agate_to_dicts(elementary.run_query(regular_bucket_times_query))[0] %}\n {%- else %}\n {%- set buckets = elementary.agate_to_dicts(elementary.run_query(incremental_bucket_times_query))[0] %}\n {% endif %}\n\n {%- if buckets %}\n {%- set min_bucket_start = elementary.edr_quote(buckets.get('min_bucket_start')) %}\n {%- set max_bucket_end = elementary.edr_quote(buckets.get('max_bucket_end')) %}\n {{ return([min_bucket_start, max_bucket_end]) }}\n {%- else %}\n {{ exceptions.raise_compiler_error(\"Failed to calc test buckets min and max\") }}\n {%- endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_detection_end", + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.edr_quote", + "macro.elementary.get_trunc_min_bucket_start_expr", + "macro.elementary.get_backfill_bucket_start", + "macro.elementary.relation_to_full_name", + "macro.elementary.get_config_var", + "macro.elementary.strings_list_to_tuple", + "macro.dbt.load_relation", + "macro.elementary.edr_datediff", + "macro.elementary.edr_timeadd", + "macro.elementary.complete_buckets_cte", + "macro.elementary.dict_to_quoted_json", + "macro.elementary.is_incremental_model", + "macro.elementary.get_model_graph_node", + "macro.elementary.agate_to_dicts", + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.058155, + "supported_languages": null + }, + "macro.elementary.materialization_non_dbt_default": { + "name": "materialization_non_dbt_default", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/materializations/non_dbt.sql", + "original_file_path": "macros/materializations/non_dbt.sql", + "unique_id": "macro.elementary.materialization_non_dbt_default", + "macro_sql": "{% materialization non_dbt, default -%}\n {# The main statement executes the model, but does not create any table / view on the DWH #}\n {% call statement('main') -%}\n {{ sql }}\n {%- endcall %}\n {{ adapter.commit() }}\n {{ return({'relations': []}) }}\n{% endmaterialization %}", + "depends_on": { + "macros": [ + "macro.dbt.statement" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.058538, + "supported_languages": [ + "sql" + ] + }, + "macro.elementary.get_common_test_config": { + "name": "get_common_test_config", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/common_test_configs.sql", + "original_file_path": "macros/utils/common_test_configs.sql", + "unique_id": "macro.elementary.get_common_test_config", + "macro_sql": "{% macro get_common_test_config(flattened_test) %}\n {% set test_name = flattened_test[\"short_name\"] %}\n {% set test_namespace = flattened_test[\"test_namespace\"] %}\n {% do return(elementary.get_common_test_config_by_namespace_and_name(test_namespace, test_name)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_common_test_config_by_namespace_and_name" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0756428, + "supported_languages": null + }, + "macro.elementary.get_common_test_config_by_namespace_and_name": { + "name": "get_common_test_config_by_namespace_and_name", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/common_test_configs.sql", + "original_file_path": "macros/utils/common_test_configs.sql", + "unique_id": "macro.elementary.get_common_test_config_by_namespace_and_name", + "macro_sql": "{% macro get_common_test_config_by_namespace_and_name(test_namespace, test_name) %}\n {% set common_tests_configs_mapping = elementary.get_common_tests_configs_mapping() %}\n {% if test_namespace is none %}\n {% set test_namespace = \"dbt\" %}\n {% endif %}\n {% if test_namespace in common_tests_configs_mapping %}\n {% if test_name in common_tests_configs_mapping[test_namespace] %}\n {% do return(common_tests_configs_mapping[test_namespace][test_name]) %}\n {% endif %}\n {% endif %}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_common_tests_configs_mapping" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.07615, + "supported_languages": null + }, + "macro.elementary.get_common_tests_configs_mapping": { + "name": "get_common_tests_configs_mapping", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/common_test_configs.sql", + "original_file_path": "macros/utils/common_test_configs.sql", + "unique_id": "macro.elementary.get_common_tests_configs_mapping", + "macro_sql": "{% macro get_common_tests_configs_mapping() %}\n {#\n Configurations for common tests (dbt builtins, dbt_utils, dbt_expectations, etc)\n The format of the mapping is:\n {\n : {\n : \n }\n }\n The config may contain:\n description: A human readable description of the test.\n failed_row_count_calc: SQL expression to get the number of failed rows from the test result.\n quality_dimension: The quality dimension of the test, see https://www.getdbt.com/blog/data-quality-dimensions/ for details.\n #}\n {% set common_tests_configs_mapping = {\n \"dbt\": {\n \"not_null\": {\n \"description\": \"This test validates that there are no `null` values present in a column.\",\n \"quality_dimension\": \"completeness\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"relationships\": {\n \"description\": \"This test validates that all of the records in a child table have a corresponding record in a parent table. This property is referred to as \\\"referential integrity\\\".\",\n \"quality_dimension\": \"consistency\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"unique\": {\n \"description\": \"This test validates that there are no duplicate values present in a field.\",\n \"quality_dimension\": \"uniqueness\",\n \"failed_row_count_calc\": \"sum(n_records)\"\n },\n \"accepted_values\": {\n \"description\": \"This test validates that all of the values in a column are present in a supplied list of `values`. If any values other than those provided in the list are present, then the test will fail.\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"sum(n_records)\"\n }\n },\n \"dbt_expectations\": {\n \"expect_column_values_to_not_be_null\": {\n \"description\": \"Expect column values to not be null.\",\n \"quality_dimension\": \"completeness\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_be_null\": {\n \"description\": \"Expect column values to be null.\",\n \"quality_dimension\": \"completeness\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_be_in_set\": {\n \"description\": \"Expect each column value to be in a given set.\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_be_between\": {\n \"description\": \"Expect each column value to be between two values.\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_not_be_in_set\": {\n \"description\": \"Expect each column value not to be in a given set.\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_be_increasing\": {\n \"description\": \"Expect column values to be increasing. If `strictly: True`, then this expectation is only satisfied if each consecutive value is strictly increasing \\u2013 equal values are treated as failures.\",\n \"quality_dimension\": \"accuracy\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_be_decreasing\": {\n \"description\": \"Expect column values to be decreasing. If `strictly=True`, then this expectation is only satisfied if each consecutive value is strictly decreasing \\u2013 equal values are treated as failures.\",\n \"quality_dimension\": \"accuracy\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_value_lengths_to_be_between\": {\n \"description\": \"Expect column entries to be strings with length between a min_value value and a max_value value (inclusive).\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_value_lengths_to_equal\": {\n \"description\": \"Expect column entries to be strings with length equal to the provided value.\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_match_regex\": {\n \"description\": \"Expect column entries to be strings that match a given regular expression. Valid matches can be found anywhere in the string, for example \\\"[at]+\\\" will identify the following strings as expected: \\\"cat\\\", \\\"hat\\\", \\\"aa\\\", \\\"a\\\", and \\\"t\\\", and the following strings as unexpected: \\\"fish\\\", \\\"dog\\\". Optionally, `is_raw` indicates the `regex` pattern is a \\\"raw\\\" string and should be escaped. The default is `False`.\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_not_match_regex\": {\n \"description\": \"Expect column entries to be strings that do NOT match a given regular expression. The regex must not match any portion of the provided string. For example, \\\"[at]+\\\" would identify the following strings as expected: \\\"fish\\u201d, \\\"dog\\u201d, and the following as unexpected: \\\"cat\\u201d, \\\"hat\\u201d. Optionally, `is_raw` indicates the `regex` pattern is a \\\"raw\\\" string and should be escaped. The default is `False`.\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_match_regex_list\": {\n \"description\": \"Expect the column entries to be strings that can be matched to either any of or all of a list of regular expressions. Matches can be anywhere in the string. Optionally, `is_raw` indicates the `regex` patterns are \\\"raw\\\" strings and should be escaped. The default is `False`.\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_not_match_regex_list\": {\n \"description\": \"Expect the column entries to be strings that do not match any of a list of regular expressions. Matches can be anywhere in the string. Optionally, `is_raw` indicates the `regex` patterns are \\\"raw\\\" strings and should be escaped. The default is `False`.\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_match_like_pattern\": {\n \"description\": \"Expect column entries to be strings that match a given SQL like pattern.\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_not_match_like_pattern\": {\n \"description\": \"Expect column entries to be strings that do not match a given SQL like pattern.\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_match_like_pattern_list\": {\n \"description\": \"Expect the column entries to be strings that match any of a list of SQL like patterns.\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_not_match_like_pattern_list\": {\n \"description\": \"Expect the column entries to be strings that do not match any of a list of SQL like patterns.\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_pair_values_A_to_be_greater_than_B\": {\n \"description\": \"Expect values in column A to be greater than column B.\",\n \"quality_dimension\": \"accuracy\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_pair_values_to_be_equal\": {\n \"description\": \"Expect the values in column A to be the same as column B.\",\n \"quality_dimension\": \"accuracy\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_pair_values_to_be_in_set\": {\n \"description\": \"Expect paired values from columns A and B to belong to a set of valid pairs. Note: value pairs are expressed as lists within lists\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_select_column_values_to_be_unique_within_record\": {\n \"description\": \"Expect the values for each record to be unique across the columns listed. Note that records can be duplicated.\",\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"expect_column_values_to_be_unique\": {\n \"description\": \"Expect each column value to be unique.\"\n },\n \"expect_compound_columns_to_be_unique\": {\n \"description\": \"Expect that the columns are unique together, e.g. a multi-column primary key.\"\n },\n \"expect_column_to_exist\": {\n \"description\": \"Expect the specified column to exist.\"\n },\n \"expect_row_values_to_have_recent_data\": {\n \"description\": \"Expect the model to have rows that are at least as recent as the defined interval prior to the current timestamp. Optionally gives the possibility to apply filters on the results.\"\n },\n \"expect_grouped_row_values_to_have_recent_data\": {\n \"description\": \"Expect the model to have grouped rows that are at least as recent as the defined interval prior to the current timestamp. Use this to test whether there is recent data for each grouped row defined by `group_by` (which is a list of columns) and a `timestamp_column`. Optionally gives the possibility to apply filters on the results.\"\n },\n \"expect_table_column_count_to_be_between\": {\n \"description\": \"Expect the number of columns in a model to be between two values.\"\n },\n \"expect_table_column_count_to_equal_other_table\": {\n \"description\": \"Expect the number of columns in a model to match another model.\"\n },\n \"expect_table_columns_to_not_contain_set\": {\n \"description\": \"Expect the columns in a model not to contain a given list.\"\n },\n \"expect_table_columns_to_contain_set\": {\n \"description\": \"Expect the columns in a model to contain a given list.\"\n },\n \"expect_table_column_count_to_equal\": {\n \"description\": \"Expect the number of columns in a model to be equal to `expected_number_of_columns`.\"\n },\n \"expect_table_columns_to_match_ordered_list\": {\n \"description\": \"Expect the columns to exactly match a specified list.\"\n },\n \"expect_table_columns_to_match_set\": {\n \"description\": \"Expect the columns in a model to match a given list.\"\n },\n \"expect_table_row_count_to_be_between\": {\n \"description\": \"Expect the number of rows in a model to be between two values.\"\n },\n \"expect_table_row_count_to_equal_other_table\": {\n \"description\": \"Expect the number of rows in a model match another model.\"\n },\n \"expect_table_row_count_to_equal_other_table_times_factor\": {\n \"description\": \"Expect the number of rows in a model to match another model times a preconfigured factor.\"\n },\n \"expect_table_row_count_to_equal\": {\n \"description\": \"Expect the number of rows in a model to be equal to expected_number_of_rows.\"\n },\n \"expect_column_values_to_be_of_type\": {\n \"description\": \"Expect a column to be of a specified data type.\"\n },\n \"expect_column_values_to_be_in_type_list\": {\n \"description\": \"Expect a column to be one of a specified type list.\"\n },\n \"expect_column_values_to_have_consistent_casing\": {\n \"description\": \"Expect a column to have consistent casing. By setting `display_inconsistent_columns` to true, the number of inconsistent values in the column will be displayed in the terminal whereas the inconsistent values themselves will be returned if the SQL compiled test is run.\"\n },\n \"expect_column_distinct_count_to_equal\": {\n \"description\": \"Expect the number of distinct column values to be equal to a given value.\"\n },\n \"expect_column_distinct_count_to_be_greater_than\": {\n \"description\": \"Expect the number of distinct column values to be greater than a given value.\"\n },\n \"expect_column_distinct_count_to_be_less_than\": {\n \"description\": \"Expect the number of distinct column values to be less than a given value.\"\n },\n \"expect_column_distinct_values_to_be_in_set\": {\n \"description\": \"Expect the set of distinct column values to be contained by a given set.\"\n },\n \"expect_column_distinct_values_to_contain_set\": {\n \"description\": \"Expect the set of distinct column values to contain a given set. In contrast to `expect_column_values_to_be_in_set` this ensures not that all column values are members of the given set but that values from the set must be present in the column.\"\n },\n \"expect_column_distinct_values_to_equal_set\": {\n \"description\": \"Expect the set of distinct column values to equal a given set. In contrast to `expect_column_distinct_values_to_contain_set` this ensures not only that a certain set of values are present in the column but that these and only these values are present.\"\n },\n \"expect_column_distinct_count_to_equal_other_table\": {\n \"description\": \"Expect the number of distinct column values to be equal to number of distinct values in another model.\"\n },\n \"expect_column_mean_to_be_between\": {\n \"description\": \"Expect the column mean to be between a min_value value and a max_value value (inclusive).\"\n },\n \"expect_column_median_to_be_between\": {\n \"description\": \"Expect the column median to be between a min_value value and a max_value value (inclusive).\"\n },\n \"expect_column_quantile_values_to_be_between\": {\n \"description\": \"Expect specific provided column quantiles to be between provided min_value and max_value values.\"\n },\n \"expect_column_stdev_to_be_between\": {\n \"description\": \"Expect the column standard deviation to be between a min_value value and a max_value value. Uses sample standard deviation (normalized by N-1).\"\n },\n \"expect_column_unique_value_count_to_be_between\": {\n \"description\": \"Expect the number of unique values to be between a min_value value and a max_value value.\"\n },\n \"expect_column_proportion_of_unique_values_to_be_between\": {\n \"description\": \"Expect the proportion of unique values to be between a min_value value and a max_value value. For example, in a column containing [1, 2, 2, 3, 3, 3, 4, 4, 4, 4], there are 4 unique values and 10 total values for a proportion of 0.4.\"\n },\n \"expect_column_most_common_value_to_be_in_set\": {\n \"description\": \"Expect the most common value to be within the designated value set.\"\n },\n \"expect_column_max_to_be_between\": {\n \"description\": \"Expect the column max to be between a min and max value.\"\n },\n \"expect_column_min_to_be_between\": {\n \"description\": \"Expect the column min to be between a min and max value.\"\n },\n \"expect_column_sum_to_be_between\": {\n \"description\": \"Expect the column to sum to be between a min and max value.\"\n },\n \"expect_multicolumn_sum_to_equal\": {\n \"description\": \"Expects that sum of all rows for a set of columns is equal to a specific value\"\n },\n \"expect_column_values_to_be_within_n_moving_stdevs\": {\n \"description\": \"A simple anomaly test based on the assumption that differences between periods in a given time series follow a log-normal distribution. Thus, we would expect the logged differences (vs N periods ago) in metric values to be within Z sigma away from a moving average. By applying a list of columns in the `group_by` parameter, you can also test for deviations within a group.\"\n },\n \"expect_column_values_to_be_within_n_stdevs\": {\n \"description\": \"Expects (optionally grouped & summed) metric values to be within Z sigma away from the column average\"\n },\n \"expect_row_values_to_have_data_for_every_n_datepart\": {\n \"description\": \"Expects model to have values for every grouped `date_part`.\"\n }\n },\n \"dbt_utils\": {\n \"equal_rowcount\": {\n \"quality_dimension\": \"consistency\",\n \"failed_row_count_calc\": \"sum(diff_count)\"\n },\n \"fewer_rows_than\": {\n \"quality_dimension\": \"consistency\",\n \"failed_row_count_calc\": \"sum(row_count_delta)\"\n },\n \"expression_is_true\": {\n \"quality_dimension\": \"accuracy\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"not_empty_string\": {\n \"quality_dimension\": \"completeness\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"cardinality_equality\": {\n \"quality_dimension\": \"consistency\",\n \"failed_row_count_calc\": \"sum(num_rows)\"\n },\n \"sequential_values\": {\n \"quality_dimension\": \"accuracy\",\n \"failed_row_count_calc\": \"count(*)\"\n },\n \"accepted_range\": {\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\"\n }\n },\n \"elementary\": {\n \"schema_changes\": {\n \"description\": \"Monitors schema changes on the table of deleted, added, type changed columns over time. The test will fail if the table's schema changed from the previous execution of the test.\"\n },\n \"schema_changes_from_baseline\": {\n \"description\": \"Compares the table's schema against a baseline contract of columns defined in the table's configuration.\"\n },\n \"json_schema\": {\n \"quality_dimension\": \"validity\",\n \"failed_row_count_calc\": \"count(*)\",\n \"description\": \"This test validates that the data in a column is valid according to a JSON schema.\"\n },\n \"volume_anomalies\": {\n \"description\": \"Monitors the row count of your table over time.\"\n },\n \"freshness_anomalies\": {\n \"description\": \"Monitors the freshness of your table over time, as the expected time between data updates.\"\n },\n \"event_freshness_anomalies\": {\n \"description\": \"Monitors the freshness of event data over time, as the expected time it takes each event to load, that is, the time between when the event actually occurs (the event timestamp), and when it is loaded to the database (the update timestamp).\"\n },\n \"dimension_anomalies\": {\n \"description\": \"Monitors the frequency of values in the configured dimensions over time.\"\n },\n \"all_columns_anomalies\": {\n \"description\": \"Column-level anomaly monitors (null_count, null_percent, zero_count, string_length, variance, etc.) on all the columns of the table. The test checks the data type of each column and only executes monitors that are relevant to it.\"\n },\n \"column_anomalies\": {\n \"description\": \"Column-level anomaly monitors (null_count, null_percent, zero_count, string_length, variance, etc.) on the column according to its data type.\"\n },\n \"exposure_schema_validity\": {\n \"description\": \"Column level exposure validation according to the meta.columns property in exposures.yml\"\n }\n }\n } %}\n {% do return(common_tests_configs_mapping) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.082672, + "supported_languages": null + }, + "macro.elementary.log_macro_results": { + "name": "log_macro_results", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/log_macro_results.sql", + "original_file_path": "macros/utils/log_macro_results.sql", + "unique_id": "macro.elementary.log_macro_results", + "macro_sql": "{% macro log_macro_results(macro_name, macro_args=none) %}\n {% if macro_args is none %}\n {% set macro_args = {} %}\n {% endif %}\n {%- set package_and_macro_name = macro_name.split('.') %}\n {%- if package_and_macro_name | length == 1 %}\n {% set macro = context[macro_name] %}\n {%- elif package_and_macro_name | length == 2 %}\n {%- set package_name, macro_name = package_and_macro_name %}\n {% set macro = context[package_name][macro_name] %}\n {%- else %}\n {% do exceptions.raise_compiler_error(\"Received invalid macro name: {}\".format(macro_name)) %}\n {% endif %}\n {% set results = macro(**macro_args) %}\n {% if results is not none %}\n {% do elementary.edr_log(tojson(results)) %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_log" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.083819, + "supported_languages": null + }, + "macro.elementary.edr_percent": { + "name": "edr_percent", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/percent_query.sql", + "original_file_path": "macros/utils/percent_query.sql", + "unique_id": "macro.elementary.edr_percent", + "macro_sql": "{% macro edr_percent(value, total) %}\n {% set value = elementary.edr_cast_as_float(value) %}\n {% set total = elementary.edr_cast_as_float(total) %}\n {% set query %}\n round({{ elementary.edr_cast_as_numeric('{} / nullif({}, 0) * 100.0'.format(value, total)) }}, 3)\n {% endset %}\n {% do return(query) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_float", + "macro.elementary.edr_cast_as_numeric" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.08445, + "supported_languages": null + }, + "macro.elementary.edr_not_percent": { + "name": "edr_not_percent", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/percent_query.sql", + "original_file_path": "macros/utils/percent_query.sql", + "unique_id": "macro.elementary.edr_not_percent", + "macro_sql": "{% macro edr_not_percent(value, total) %}\n {% set value = elementary.edr_cast_as_float(value) %}\n {% set total = elementary.edr_cast_as_float(total) %}\n {% set query %}\n round({{ elementary.edr_cast_as_numeric('100 - ({} / nullif({}, 0) * 100.0)'.format(value, total)) }}, 3)\n {% endset %}\n {% do return(query) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_float", + "macro.elementary.edr_cast_as_numeric" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0848482, + "supported_languages": null + }, + "macro.elementary.is_test_command": { + "name": "is_test_command", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/command_type_utils.sql", + "original_file_path": "macros/utils/command_type_utils.sql", + "unique_id": "macro.elementary.is_test_command", + "macro_sql": "{% macro is_test_command() %}\n {% do return(flags.WHICH in ['test', 'build', 'retry']) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0851352, + "supported_languages": null + }, + "macro.elementary.is_run_command": { + "name": "is_run_command", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/command_type_utils.sql", + "original_file_path": "macros/utils/command_type_utils.sql", + "unique_id": "macro.elementary.is_run_command", + "macro_sql": "{% macro is_run_command() %}\n {% do return(flags.WHICH in ['run', 'build', 'retry']) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0853188, + "supported_languages": null + }, + "macro.elementary.is_docs_command": { + "name": "is_docs_command", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/command_type_utils.sql", + "original_file_path": "macros/utils/command_type_utils.sql", + "unique_id": "macro.elementary.is_docs_command", + "macro_sql": "{% macro is_docs_command() %}\n {% do return(flags.WHICH in ['generate', 'serve']) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0854862, + "supported_languages": null + }, + "macro.elementary.get_default_table_type": { + "name": "get_default_table_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/table_type.sql", + "original_file_path": "macros/utils/cross_db_utils/table_type.sql", + "unique_id": "macro.elementary.get_default_table_type", + "macro_sql": "{% macro get_default_table_type() %}\n {% do return(adapter.dispatch(\"get_default_table_type\", \"elementary\")()) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__get_default_table_type" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0857432, + "supported_languages": null + }, + "macro.elementary.athena__get_default_table_type": { + "name": "athena__get_default_table_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/table_type.sql", + "original_file_path": "macros/utils/cross_db_utils/table_type.sql", + "unique_id": "macro.elementary.athena__get_default_table_type", + "macro_sql": "\n\n{%- macro athena__get_default_table_type() %}\n {% do return(\"iceberg\") %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.085866, + "supported_languages": null + }, + "macro.elementary.default__get_default_table_type": { + "name": "default__get_default_table_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/table_type.sql", + "original_file_path": "macros/utils/cross_db_utils/table_type.sql", + "unique_id": "macro.elementary.default__get_default_table_type", + "macro_sql": "{% macro default__get_default_table_type() %}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.085985, + "supported_languages": null + }, + "macro.elementary.edr_concat": { + "name": "edr_concat", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/concat.sql", + "original_file_path": "macros/utils/cross_db_utils/concat.sql", + "unique_id": "macro.elementary.edr_concat", + "macro_sql": "{%- macro edr_concat(val1, val2) -%}\n concat({{ elementary.edr_cast_as_string(val1) }}, {{ elementary.edr_cast_as_string(val2) }})\n{%- endmacro -%}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.086207, + "supported_languages": null + }, + "macro.elementary.sql_union_distinct": { + "name": "sql_union_distinct", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/sql_union_distinct.sql", + "original_file_path": "macros/utils/cross_db_utils/sql_union_distinct.sql", + "unique_id": "macro.elementary.sql_union_distinct", + "macro_sql": "{% macro sql_union_distinct() %}\nunion {% if target.type == \"bigquery\" %} distinct {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0863879, + "supported_languages": null + }, + "macro.elementary.edr_dateadd": { + "name": "edr_dateadd", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/dateadd.sql", + "original_file_path": "macros/utils/cross_db_utils/dateadd.sql", + "unique_id": "macro.elementary.edr_dateadd", + "macro_sql": "{% macro edr_dateadd(datepart, interval, from_date_or_timestamp) %}\n {% set macro = dbt.dateadd or dbt_utils.dateadd %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `dateadd` macro.\") }}\n {% endif %}\n {{ return(macro(datepart, interval, from_date_or_timestamp)) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.086814, + "supported_languages": null + }, + "macro.elementary.contains": { + "name": "contains", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/contains.sql", + "original_file_path": "macros/utils/cross_db_utils/contains.sql", + "unique_id": "macro.elementary.contains", + "macro_sql": "{% macro contains(string, string_to_search,case_sensitive=False) -%}\n {{ adapter.dispatch('contains', 'elementary') (string, string_to_search, case_sensitive) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__contains" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.08759, + "supported_languages": null + }, + "macro.elementary.default__contains": { + "name": "default__contains", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/contains.sql", + "original_file_path": "macros/utils/cross_db_utils/contains.sql", + "unique_id": "macro.elementary.default__contains", + "macro_sql": "{% macro default__contains(string, string_to_search, case_sensitive) %}\n {%- if case_sensitive %}\n contains({{ string }}, '{{ string_to_search }}')\n {%- else %}\n contains(lower({{ string }}), lower('{{ string_to_search }}'))\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.08782, + "supported_languages": null + }, + "macro.elementary.bigquery__contains": { + "name": "bigquery__contains", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/contains.sql", + "original_file_path": "macros/utils/cross_db_utils/contains.sql", + "unique_id": "macro.elementary.bigquery__contains", + "macro_sql": "{% macro bigquery__contains(string, string_to_search, case_sensitive) %}\n {%- if case_sensitive %}\n contains_substr({{ string }}, '{{ string_to_search }}')\n {%- else %}\n {%- set string_to_search = string_to_search | lower %}\n contains_substr(lower({{ string }}), '{{ string_to_search }}')\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0881002, + "supported_languages": null + }, + "macro.elementary.postgres__contains": { + "name": "postgres__contains", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/contains.sql", + "original_file_path": "macros/utils/cross_db_utils/contains.sql", + "unique_id": "macro.elementary.postgres__contains", + "macro_sql": "{% macro postgres__contains(string, string_to_search, case_sensitive) %}\n {%- if case_sensitive %}\n case when\n {{ string }} like '%{{ string_to_search }}%' then true\n else false end\n {%- else %}\n case when\n lower({{ string }}) like lower('%{{ string_to_search }}%') then true\n else false end\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.088337, + "supported_languages": null + }, + "macro.elementary.schema_exists": { + "name": "schema_exists", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/schema_exists.sql", + "original_file_path": "macros/utils/cross_db_utils/schema_exists.sql", + "unique_id": "macro.elementary.schema_exists", + "macro_sql": "{% macro schema_exists(database, schema) %}\n {% do return(adapter.dispatch(\"schema_exists\", \"elementary\")(database, schema)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.snowflake__schema_exists" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.08888, + "supported_languages": null + }, + "macro.elementary.snowflake__schema_exists": { + "name": "snowflake__schema_exists", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/schema_exists.sql", + "original_file_path": "macros/utils/cross_db_utils/schema_exists.sql", + "unique_id": "macro.elementary.snowflake__schema_exists", + "macro_sql": "{% macro snowflake__schema_exists(database, schema) %}\n {% set database_sql %}\n show databases like '{{ database }}'\n {% endset %}\n {% set database_exists = elementary.run_query(database_sql)|length > 0 %}\n {% if not database_exists %}\n {% do return(false) %}\n {% endif %}\n {% do return(adapter.check_schema_exists(database, schema)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.089366, + "supported_languages": null + }, + "macro.elementary.postgres__schema_exists": { + "name": "postgres__schema_exists", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/schema_exists.sql", + "original_file_path": "macros/utils/cross_db_utils/schema_exists.sql", + "unique_id": "macro.elementary.postgres__schema_exists", + "macro_sql": "{% macro postgres__schema_exists(database, schema) %}\n {% if database != target.database %}\n {# Cross db operations not supported in postgres #}\n {% do return(false) %}\n {% endif %}\n {% do return(adapter.check_schema_exists(database, schema)) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.089667, + "supported_languages": null + }, + "macro.elementary.bigquery__schema_exists": { + "name": "bigquery__schema_exists", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/schema_exists.sql", + "original_file_path": "macros/utils/cross_db_utils/schema_exists.sql", + "unique_id": "macro.elementary.bigquery__schema_exists", + "macro_sql": "{% macro bigquery__schema_exists(database, schema) %}\n {% if database != target.project %}\n {# Cannot check for non-existing database in bigquery through sql (only api), assume it exists #}\n {% do return(true) %}\n {% endif %}\n {% do return(adapter.check_schema_exists(database, schema)) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.089965, + "supported_languages": null + }, + "macro.elementary.default__schema_exists": { + "name": "default__schema_exists", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/schema_exists.sql", + "original_file_path": "macros/utils/cross_db_utils/schema_exists.sql", + "unique_id": "macro.elementary.default__schema_exists", + "macro_sql": "{% macro default__schema_exists(database, schema) %}\n {% do return(adapter.check_schema_exists(database, schema)) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.090143, + "supported_languages": null + }, + "macro.elementary.get_default_incremental_strategy": { + "name": "get_default_incremental_strategy", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/incremental_strategy.sql", + "original_file_path": "macros/utils/cross_db_utils/incremental_strategy.sql", + "unique_id": "macro.elementary.get_default_incremental_strategy", + "macro_sql": "{% macro get_default_incremental_strategy() %}\n {% do return(adapter.dispatch(\"get_default_incremental_strategy\", \"elementary\")()) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__get_default_incremental_strategy" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.090404, + "supported_languages": null + }, + "macro.elementary.athena__get_default_incremental_strategy": { + "name": "athena__get_default_incremental_strategy", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/incremental_strategy.sql", + "original_file_path": "macros/utils/cross_db_utils/incremental_strategy.sql", + "unique_id": "macro.elementary.athena__get_default_incremental_strategy", + "macro_sql": "\n\n{%- macro athena__get_default_incremental_strategy() %}\n {% do return(\"merge\") %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.090524, + "supported_languages": null + }, + "macro.elementary.default__get_default_incremental_strategy": { + "name": "default__get_default_incremental_strategy", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/incremental_strategy.sql", + "original_file_path": "macros/utils/cross_db_utils/incremental_strategy.sql", + "unique_id": "macro.elementary.default__get_default_incremental_strategy", + "macro_sql": "{% macro default__get_default_incremental_strategy() %}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.090644, + "supported_languages": null + }, + "macro.elementary.generate_elementary_profile_args": { + "name": "generate_elementary_profile_args", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "original_file_path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "unique_id": "macro.elementary.generate_elementary_profile_args", + "macro_sql": "{% macro generate_elementary_profile_args(method=none, overwrite_values=none) %}\n {#\n Returns a list of parameters for elementary profile.\n Each parameter consists of a dict consisting of: \n name\n value\n comment\n #}\n {% set elementary_database, elementary_schema = elementary.get_package_database_and_schema() %}\n {% set parameters = adapter.dispatch('generate_elementary_profile_args', 'elementary')(method, elementary_database, elementary_schema) %}\n {% if overwrite_values %}\n {% for parameter in parameters %}\n {% if parameter[\"name\"] in overwrite_values %}\n {% do parameter.update({\"value\": overwrite_values[parameter[\"name\"]]}) %}\n {% endif %}\n {% endfor %}\n {% endif %}\n {% do return(parameters) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_package_database_and_schema", + "macro.elementary.snowflake__generate_elementary_profile_args" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0949812, + "supported_languages": null + }, + "macro.elementary._parameter": { + "name": "_parameter", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "original_file_path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "unique_id": "macro.elementary._parameter", + "macro_sql": "{% macro _parameter(name, value, comment=none) %}\n {% do return({\"name\": name, \"value\": value, \"comment\": comment}) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.095223, + "supported_languages": null + }, + "macro.elementary.snowflake__generate_elementary_profile_args": { + "name": "snowflake__generate_elementary_profile_args", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "original_file_path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "unique_id": "macro.elementary.snowflake__generate_elementary_profile_args", + "macro_sql": "{% macro snowflake__generate_elementary_profile_args(method, elementary_database, elementary_schema) %}\n {% do return([\n _parameter(\"type\", target.type),\n _parameter(\"account\", target.account),\n _parameter(\"user\", target.user),\n _parameter(\"password\", \"\"),\n _parameter(\"role\", target.role),\n _parameter(\"warehouse\", target.warehouse),\n _parameter(\"database\", elementary_database),\n _parameter(\"schema\", elementary_schema),\n _parameter(\"threads\", target.threads),\n ]) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary._parameter" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.0958111, + "supported_languages": null + }, + "macro.elementary.bigquery__generate_elementary_profile_args": { + "name": "bigquery__generate_elementary_profile_args", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "original_file_path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "unique_id": "macro.elementary.bigquery__generate_elementary_profile_args", + "macro_sql": "{% macro bigquery__generate_elementary_profile_args(method, elementary_database, elementary_schema) %}\n {% set parameters = [\n _parameter(\"type\", target.type),\n _parameter(\"project\", elementary_database),\n _parameter(\"dataset\", elementary_schema)\n ] %}\n {% if method == 'service-account' %}\n {% do parameters.append(_parameter(\"method\", \"service-account\")) %}\n {% do parameters.append(_parameter(\"keyfile\", \"\")) %}\n {% elif method == \"github-actions\" %}\n {% do parameters.append(_parameter(\"method\", \"service-account\")) %}\n {% do parameters.append(_parameter(\"keyfile\", \"/tmp/bigquery_keyfile.json\", \"Do not change this, supply `bigquery-keyfile` in `.github/workflows/elementary.yml`\")) %}\n {% else %}\n {% do parameters.append(_parameter(\"method\", \"\", \"Configure your auth method and add the required fields according to https://docs.getdbt.com/reference/warehouse-setups/bigquery-setup#authentication-methods\")) %}\n {% endif %}\n {% do parameters.append(_parameter(\"threads\", target.threads)) %}\n {% do return(parameters) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary._parameter" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.096802, + "supported_languages": null + }, + "macro.elementary.postgres__generate_elementary_profile_args": { + "name": "postgres__generate_elementary_profile_args", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "original_file_path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "unique_id": "macro.elementary.postgres__generate_elementary_profile_args", + "macro_sql": "{% macro postgres__generate_elementary_profile_args(method, elementary_database, elementary_schema) %}\n {% do return([\n _parameter(\"type\", target.type),\n _parameter(\"host\", target.host),\n _parameter(\"port\", target.port),\n _parameter(\"user\", target.user),\n _parameter(\"password\", \"\"),\n _parameter(\"dbname\", elementary_database),\n _parameter(\"schema\", elementary_schema),\n _parameter(\"threads\", target.threads),\n ]) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary._parameter" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.097342, + "supported_languages": null + }, + "macro.elementary.databricks__generate_elementary_profile_args": { + "name": "databricks__generate_elementary_profile_args", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "original_file_path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "unique_id": "macro.elementary.databricks__generate_elementary_profile_args", + "macro_sql": "{% macro databricks__generate_elementary_profile_args(method, elementary_database, elementary_schema) %}\n {% set parameters = [\n _parameter(\"type\", target.type),\n _parameter(\"host\", target.host),\n _parameter(\"http_path\", target.http_path),\n ] %}\n {% if elementary_database %}\n {% do parameters.append(_parameter(\"catalog\", elementary_database)) %}\n {% endif %}\n {% do parameters.extend([\n _parameter(\"schema\", elementary_schema),\n _parameter(\"token\", \"\"),\n _parameter(\"threads\", target.threads),\n ]) %}\n {% do return(parameters) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary._parameter" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.098006, + "supported_languages": null + }, + "macro.elementary.spark__generate_elementary_profile_args": { + "name": "spark__generate_elementary_profile_args", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "original_file_path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "unique_id": "macro.elementary.spark__generate_elementary_profile_args", + "macro_sql": "{% macro spark__generate_elementary_profile_args(method, elementary_database, elementary_schema) %}\n {% set parameters = [\n _parameter(\"type\", target.type),\n _parameter(\"host\", target.host),\n _parameter(\"http_path\", \"\")\n ] %}\n {% if elementary_database %}\n {% do parameters.append(_parameter(\"catalog\", elementary_database)) %}\n {% endif %}\n {% do parameters.extend([\n _parameter(\"schema\", elementary_schema),\n _parameter(\"token\", \"\"),\n _parameter(\"threads\", target.threads),\n ]) %}\n {% do return(parameters) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary._parameter" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.098668, + "supported_languages": null + }, + "macro.elementary.athena__generate_elementary_cli_profile": { + "name": "athena__generate_elementary_cli_profile", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "original_file_path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "unique_id": "macro.elementary.athena__generate_elementary_cli_profile", + "macro_sql": "{% macro athena__generate_elementary_cli_profile(method, elementary_database, elementary_schema) %}\n {% set parameters = [\n _parameter(\"type\", target.type),\n _parameter(\"s3_staging_dir\", target.s3_staging_dir),\n _parameter(\"region_name\", target.region_name),\n _parameter(\"database\", target.database),\n _parameter(\"aws_profile_name\", target.aws_profile_name),\n _parameter(\"work_group\", target.work_group),\n _parameter(\"aws_access_key_id\", \"\"),\n _parameter(\"aws_secret_access_key\", \"\"),\n ] %}\n\n {% if elementary_database %}\n {% do parameters.append(_parameter(\"catalog\", elementary_database)) %}\n {% endif %}\n\n {% do parameters.extend([\n _parameter(\"schema\", elementary_schema),\n _parameter(\"token\", \"\"),\n _parameter(\"threads\", target.threads),\n ]) %}\n {% do return(parameters) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary._parameter" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.099635, + "supported_languages": null + }, + "macro.elementary.default__generate_elementary_profile_args": { + "name": "default__generate_elementary_profile_args", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "original_file_path": "macros/utils/cross_db_utils/generate_elementary_profile_args.sql", + "unique_id": "macro.elementary.default__generate_elementary_profile_args", + "macro_sql": "{% macro default__generate_elementary_profile_args(method, elementary_database, elementary_schema) %}\nAdapter \"{{ target.type }}\" is not supported on Elementary.\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.099766, + "supported_languages": null + }, + "macro.elementary.edr_datediff": { + "name": "edr_datediff", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/datediff.sql", + "original_file_path": "macros/utils/cross_db_utils/datediff.sql", + "unique_id": "macro.elementary.edr_datediff", + "macro_sql": "{% macro edr_datediff(first_date, second_date, date_part) %}\n {{ return(adapter.dispatch('edr_datediff', 'elementary')(first_date, second_date, date_part)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_datediff" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.105536, + "supported_languages": null + }, + "macro.elementary.default__edr_datediff": { + "name": "default__edr_datediff", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/datediff.sql", + "original_file_path": "macros/utils/cross_db_utils/datediff.sql", + "unique_id": "macro.elementary.default__edr_datediff", + "macro_sql": "{% macro default__edr_datediff(first_date, second_date, date_part) %}\n {% set macro = dbt.datediff or dbt_utils.datediff %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `datediff` macro.\") }}\n {% endif %}\n {{ return(macro(first_date, second_date, date_part)) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.105881, + "supported_languages": null + }, + "macro.elementary.bigquery__edr_datediff": { + "name": "bigquery__edr_datediff", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/datediff.sql", + "original_file_path": "macros/utils/cross_db_utils/datediff.sql", + "unique_id": "macro.elementary.bigquery__edr_datediff", + "macro_sql": "{% macro bigquery__edr_datediff(first_date, second_date, date_part) %}\n {%- if date_part | lower in ['second', 'minute', 'hour', 'day'] %}\n timestamp_diff({{ second_date }}, {{ first_date }}, {{ date_part }})\n {%- elif date_part | lower in ['week', 'month', 'quarter', 'year'] %}\n {% set macro = dbt.datediff or dbt_utils.datediff %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `datediff` macro.\") }}\n {% endif %}\n {{ return(macro(elementary.edr_cast_as_date(first_date), elementary.edr_cast_as_date(second_date), date_part)) }}\n {%- else %}\n {{ exceptions.raise_compiler_error(\"Unsupported date_part in edr_datediff: \".format(date_part)) }}\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_date" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.10665, + "supported_languages": null + }, + "macro.elementary.spark__edr_datediff": { + "name": "spark__edr_datediff", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/datediff.sql", + "original_file_path": "macros/utils/cross_db_utils/datediff.sql", + "unique_id": "macro.elementary.spark__edr_datediff", + "macro_sql": "{% macro spark__edr_datediff(first_date, second_date, datepart) %}\n {%- if datepart in ['day', 'week', 'month', 'quarter', 'year'] -%}\n\n {# make sure the dates are real, otherwise raise an error asap #}\n {% set first_date = assert_not_null('date', first_date) %}\n {% set second_date = assert_not_null('date', second_date) %}\n\n {%- endif -%}\n\n {%- if datepart == 'day' -%}\n\n datediff({{second_date}}, {{first_date}})\n\n {%- elif datepart == 'week' -%}\n\n case when {{first_date}} < {{second_date}}\n then floor(datediff({{second_date}}, {{first_date}})/7)\n else ceil(datediff({{second_date}}, {{first_date}})/7)\n end\n\n -- did we cross a week boundary (Sunday)?\n + case\n when {{first_date}} < {{second_date}} and dayofweek({{second_date}}) < dayofweek({{first_date}}) then 1\n when {{first_date}} > {{second_date}} and dayofweek({{second_date}}) > dayofweek({{first_date}}) then -1\n else 0 end\n\n {%- elif datepart == 'month' -%}\n\n case when {{first_date}} < {{second_date}}\n then floor(months_between(date({{second_date}}), date({{first_date}})))\n else ceil(months_between(date({{second_date}}), date({{first_date}})))\n end\n\n -- did we cross a month boundary?\n + case\n when {{first_date}} < {{second_date}} and dayofmonth({{second_date}}) < dayofmonth({{first_date}}) then 1\n when {{first_date}} > {{second_date}} and dayofmonth({{second_date}}) > dayofmonth({{first_date}}) then -1\n else 0 end\n\n {%- elif datepart == 'quarter' -%}\n\n case when {{first_date}} < {{second_date}}\n then floor(months_between(date({{second_date}}), date({{first_date}}))/3)\n else ceil(months_between(date({{second_date}}), date({{first_date}}))/3)\n end\n\n -- did we cross a quarter boundary?\n + case\n when {{first_date}} < {{second_date}} and (\n (dayofyear({{second_date}}) - (quarter({{second_date}}) * 365/4))\n < (dayofyear({{first_date}}) - (quarter({{first_date}}) * 365/4))\n ) then 1\n when {{first_date}} > {{second_date}} and (\n (dayofyear({{second_date}}) - (quarter({{second_date}}) * 365/4))\n > (dayofyear({{first_date}}) - (quarter({{first_date}}) * 365/4))\n ) then -1\n else 0 end\n\n {%- elif datepart == 'year' -%}\n\n year({{second_date}}) - year({{first_date}})\n\n {%- elif datepart in ('hour', 'minute', 'second', 'millisecond', 'microsecond') -%}\n\n {%- set divisor -%}\n {%- if datepart == 'hour' -%} 3600\n {%- elif datepart == 'minute' -%} 60\n {%- elif datepart == 'second' -%} 1\n {%- elif datepart == 'millisecond' -%} (1/1000)\n {%- elif datepart == 'microsecond' -%} (1/1000000)\n {%- endif -%}\n {%- endset -%}\n\n case when {{first_date}} < {{second_date}}\n then floor((\n {# make sure the timestamps are real, otherwise raise an error asap #}\n {{ assert_not_null('to_unix_timestamp', assert_not_null('to_timestamp', second_date)) }}\n - {{ assert_not_null('to_unix_timestamp', assert_not_null('to_timestamp', first_date)) }}\n ) / {{divisor}})\n else ceil((\n {{ assert_not_null('to_unix_timestamp', assert_not_null('to_timestamp', second_date)) }}\n - {{ assert_not_null('to_unix_timestamp', assert_not_null('to_timestamp', first_date)) }}\n ) / {{divisor}})\n end\n\n {% if datepart == 'millisecond' %}\n + cast(date_format({{second_date}}, 'SSS') as int)\n - cast(date_format({{first_date}}, 'SSS') as int)\n {% endif %}\n\n {% if datepart == 'microsecond' %}\n {% set capture_str = '[0-9]{4}-[0-9]{2}-[0-9]{2}.[0-9]{2}:[0-9]{2}:[0-9]{2}.([0-9]{6})' %}\n -- Spark doesn't really support microseconds, so this is a massive hack!\n -- It will only work if the timestamp-string is of the format\n -- 'yyyy-MM-dd-HH mm.ss.SSSSSS'\n + cast(regexp_extract({{second_date}}, '{{capture_str}}', 1) as int)\n - cast(regexp_extract({{first_date}}, '{{capture_str}}', 1) as int)\n {% endif %}\n\n {%- else -%}\n\n {{ exceptions.raise_compiler_error(\"macro datediff not implemented for datepart ~ '\" ~ datepart ~ \"' ~ on Spark\") }}\n\n {%- endif -%}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.10932, + "supported_languages": null + }, + "macro.elementary.athena__edr_datediff": { + "name": "athena__edr_datediff", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/datediff.sql", + "original_file_path": "macros/utils/cross_db_utils/datediff.sql", + "unique_id": "macro.elementary.athena__edr_datediff", + "macro_sql": "{% macro athena__edr_datediff(first_date, second_date, date_part) %}\n {% set macro = dbt.datediff or dbt_utils.datediff %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `datediff` macro.\") }}\n {% endif %}\n {{ return(macro(elementary.edr_cast_as_timestamp(first_date), elementary.edr_cast_as_timestamp(second_date), date_part)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.109736, + "supported_languages": null + }, + "macro.elementary.target_database": { + "name": "target_database", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/target_database.sql", + "original_file_path": "macros/utils/cross_db_utils/target_database.sql", + "unique_id": "macro.elementary.target_database", + "macro_sql": "{% macro target_database() -%}\n {{ return(adapter.dispatch('target_database', 'elementary')()) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.snowflake__target_database" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.110122, + "supported_languages": null + }, + "macro.elementary.default__target_database": { + "name": "default__target_database", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/target_database.sql", + "original_file_path": "macros/utils/cross_db_utils/target_database.sql", + "unique_id": "macro.elementary.default__target_database", + "macro_sql": "{% macro default__target_database() %}\n {% do return(target.dbname) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.110249, + "supported_languages": null + }, + "macro.elementary.spark__target_database": { + "name": "spark__target_database", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/target_database.sql", + "original_file_path": "macros/utils/cross_db_utils/target_database.sql", + "unique_id": "macro.elementary.spark__target_database", + "macro_sql": "{% macro spark__target_database() %}\n {% do return(target.catalog or none) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1103911, + "supported_languages": null + }, + "macro.elementary.snowflake__target_database": { + "name": "snowflake__target_database", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/target_database.sql", + "original_file_path": "macros/utils/cross_db_utils/target_database.sql", + "unique_id": "macro.elementary.snowflake__target_database", + "macro_sql": "{% macro snowflake__target_database() %}\n {% do return(target.database) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.110521, + "supported_languages": null + }, + "macro.elementary.bigquery__target_database": { + "name": "bigquery__target_database", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/target_database.sql", + "original_file_path": "macros/utils/cross_db_utils/target_database.sql", + "unique_id": "macro.elementary.bigquery__target_database", + "macro_sql": "{% macro bigquery__target_database() %}\n {% do return(target.project) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.110646, + "supported_languages": null + }, + "macro.elementary.athena__target_database": { + "name": "athena__target_database", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/target_database.sql", + "original_file_path": "macros/utils/cross_db_utils/target_database.sql", + "unique_id": "macro.elementary.athena__target_database", + "macro_sql": "{% macro athena__target_database() %}\n {% do return(target.database) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.110773, + "supported_languages": null + }, + "macro.elementary.can_query_relation": { + "name": "can_query_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/can_query_relation.sql", + "original_file_path": "macros/utils/cross_db_utils/can_query_relation.sql", + "unique_id": "macro.elementary.can_query_relation", + "macro_sql": "{% macro can_query_relation(relation) %}\n {% do return(adapter.dispatch(\"can_query_relation\", \"elementary\")(relation)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__can_query_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.111148, + "supported_languages": null + }, + "macro.elementary.bigquery__can_query_relation": { + "name": "bigquery__can_query_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/can_query_relation.sql", + "original_file_path": "macros/utils/cross_db_utils/can_query_relation.sql", + "unique_id": "macro.elementary.bigquery__can_query_relation", + "macro_sql": "{% macro bigquery__can_query_relation(relation) %}\n {% set query %}\n begin\n select 1\n from {{ relation }}\n limit 1;\n exception when error then\n select 0;\n end\n {% endset %}\n {% set result = elementary.result_value(query) %}\n {% do return(result == 1) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.result_value" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.111426, + "supported_languages": null + }, + "macro.elementary.default__can_query_relation": { + "name": "default__can_query_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/can_query_relation.sql", + "original_file_path": "macros/utils/cross_db_utils/can_query_relation.sql", + "unique_id": "macro.elementary.default__can_query_relation", + "macro_sql": "{% macro default__can_query_relation(relation) %}\n {% do exceptions.raise_compiler_error(\"'can_query_relation' not implemented on '{}'.\".format(target.type)) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.111595, + "supported_languages": null + }, + "macro.elementary.edr_safe_cast": { + "name": "edr_safe_cast", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/safe_cast.sql", + "original_file_path": "macros/utils/cross_db_utils/safe_cast.sql", + "unique_id": "macro.elementary.edr_safe_cast", + "macro_sql": "{% macro edr_safe_cast(field, type) %}\n {{ return(adapter.dispatch('edr_safe_cast', 'elementary') (field, type)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_safe_cast" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.111965, + "supported_languages": null + }, + "macro.elementary.default__edr_safe_cast": { + "name": "default__edr_safe_cast", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/safe_cast.sql", + "original_file_path": "macros/utils/cross_db_utils/safe_cast.sql", + "unique_id": "macro.elementary.default__edr_safe_cast", + "macro_sql": "{% macro default__edr_safe_cast(field, type) %}\n {% set macro = dbt.safe_cast or dbt_utils.safe_cast %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `safe_cast` macro.\") }}\n {% endif %}\n {{ return(macro(field, type)) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.112288, + "supported_languages": null + }, + "macro.elementary.spark__edr_safe_cast": { + "name": "spark__edr_safe_cast", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/safe_cast.sql", + "original_file_path": "macros/utils/cross_db_utils/safe_cast.sql", + "unique_id": "macro.elementary.spark__edr_safe_cast", + "macro_sql": "{% macro spark__edr_safe_cast(field, type) %}\n try_cast({{field}} as {{type}})\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.112414, + "supported_languages": null + }, + "macro.elementary.edr_quote": { + "name": "edr_quote", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/quote_column.sql", + "original_file_path": "macros/utils/cross_db_utils/quote_column.sql", + "unique_id": "macro.elementary.edr_quote", + "macro_sql": "{% macro edr_quote(str) %}\n {% set escaped_str = elementary.escape_special_chars(str) %}\n {% do return(\"'{}'\".format(escaped_str)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.escape_special_chars" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1128309, + "supported_languages": null + }, + "macro.elementary.dict_to_quoted_json": { + "name": "dict_to_quoted_json", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/quote_column.sql", + "original_file_path": "macros/utils/cross_db_utils/quote_column.sql", + "unique_id": "macro.elementary.dict_to_quoted_json", + "macro_sql": "{% macro dict_to_quoted_json(d) %}\n {% do return(elementary.edr_cast_as_string(elementary.edr_quote(tojson(d, sort_keys=true)))) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_string", + "macro.elementary.edr_quote" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1130502, + "supported_languages": null + }, + "macro.elementary.edr_quote_column": { + "name": "edr_quote_column", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/quote_column.sql", + "original_file_path": "macros/utils/cross_db_utils/quote_column.sql", + "unique_id": "macro.elementary.edr_quote_column", + "macro_sql": "\n\n{%- macro edr_quote_column(column_name) -%}\n {% if adapter.quote(column_name[1:-1]) == column_name %}\n {{ return(column_name) }}\n {% else %}\n {% set quoted_column = adapter.quote(column_name) %}\n {{ return(quoted_column) }}\n {% endif %}\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.113409, + "supported_languages": null + }, + "macro.elementary.edr_to_char": { + "name": "edr_to_char", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/to_char.sql", + "original_file_path": "macros/utils/cross_db_utils/to_char.sql", + "unique_id": "macro.elementary.edr_to_char", + "macro_sql": "{% macro edr_to_char(column, format) -%}\n {{ return(adapter.dispatch('edr_to_char', 'elementary')(column, format)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_to_char" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.113854, + "supported_languages": null + }, + "macro.elementary.default__edr_to_char": { + "name": "default__edr_to_char", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/to_char.sql", + "original_file_path": "macros/utils/cross_db_utils/to_char.sql", + "unique_id": "macro.elementary.default__edr_to_char", + "macro_sql": "{% macro default__edr_to_char(column, format) %}\n to_char({{ column }} {%- if format %}, '{{ format }}'){%- else %}, 'YYYY-MM-DD HH:MI:SS'){%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.114039, + "supported_languages": null + }, + "macro.elementary.bigquery__edr_to_char": { + "name": "bigquery__edr_to_char", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/to_char.sql", + "original_file_path": "macros/utils/cross_db_utils/to_char.sql", + "unique_id": "macro.elementary.bigquery__edr_to_char", + "macro_sql": "{% macro bigquery__edr_to_char(column, format) %}\n cast({{ column }} as STRING {%- if format %} FORMAT '{{ format }}'){%- else %}){%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.11423, + "supported_languages": null + }, + "macro.elementary.spark__edr_to_char": { + "name": "spark__edr_to_char", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/to_char.sql", + "original_file_path": "macros/utils/cross_db_utils/to_char.sql", + "unique_id": "macro.elementary.spark__edr_to_char", + "macro_sql": "{% macro spark__edr_to_char(column, format) %}\n date_format({{ column }} {%- if format %}, '{{ format }}'){%- else %}, 'YYYY-MM-DD HH:MI:SS'){%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1144772, + "supported_languages": null + }, + "macro.elementary.edr_hour_of_week_expression": { + "name": "edr_hour_of_week_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/hour_of_week.sql", + "original_file_path": "macros/utils/cross_db_utils/hour_of_week.sql", + "unique_id": "macro.elementary.edr_hour_of_week_expression", + "macro_sql": "{% macro edr_hour_of_week_expression(date_expr) %}\n {{ return(adapter.dispatch('edr_hour_of_week_expression','elementary')(elementary.edr_cast_as_timestamp(date_expr))) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.snowflake__edr_hour_of_week_expression", + "macro.elementary.edr_cast_as_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.115413, + "supported_languages": null + }, + "macro.elementary.default__edr_hour_of_week_expression": { + "name": "default__edr_hour_of_week_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/hour_of_week.sql", + "original_file_path": "macros/utils/cross_db_utils/hour_of_week.sql", + "unique_id": "macro.elementary.default__edr_hour_of_week_expression", + "macro_sql": "{% macro default__edr_hour_of_week_expression(date_expr) %}\n concat(cast(DATE_FORMAT({{ date_expr }}, 'EEEE') as {{ elementary.edr_type_string() }}), cast(HOUR({{ date_expr }}) as {{ elementary.edr_type_string() }}))\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1156008, + "supported_languages": null + }, + "macro.elementary.bigquery__edr_hour_of_week_expression": { + "name": "bigquery__edr_hour_of_week_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/hour_of_week.sql", + "original_file_path": "macros/utils/cross_db_utils/hour_of_week.sql", + "unique_id": "macro.elementary.bigquery__edr_hour_of_week_expression", + "macro_sql": "{% macro bigquery__edr_hour_of_week_expression(date_expr) %}\n concat(cast(FORMAT_DATE('%A', {{ date_expr }}) as {{ elementary.edr_type_string() }}), cast(EXTRACT(hour from {{ date_expr }}) as {{ elementary.edr_type_string() }}))\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.115795, + "supported_languages": null + }, + "macro.elementary.postgres__edr_hour_of_week_expression": { + "name": "postgres__edr_hour_of_week_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/hour_of_week.sql", + "original_file_path": "macros/utils/cross_db_utils/hour_of_week.sql", + "unique_id": "macro.elementary.postgres__edr_hour_of_week_expression", + "macro_sql": "{% macro postgres__edr_hour_of_week_expression(date_expr) %}\n concat(cast(to_char({{ date_expr }}, 'Day') as {{ elementary.edr_type_string() }}), cast(EXTRACT(hour from {{ date_expr }}) as {{ elementary.edr_type_string() }}))\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.115987, + "supported_languages": null + }, + "macro.elementary.redshift__edr_hour_of_week_expression": { + "name": "redshift__edr_hour_of_week_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/hour_of_week.sql", + "original_file_path": "macros/utils/cross_db_utils/hour_of_week.sql", + "unique_id": "macro.elementary.redshift__edr_hour_of_week_expression", + "macro_sql": "{% macro redshift__edr_hour_of_week_expression(date_expr) %}\n concat(trim(' ' FROM to_char({{ date_expr }}, 'Day')), cast(EXTRACT(hour from {{ date_expr }}) as {{ elementary.edr_type_string() }}))\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.116139, + "supported_languages": null + }, + "macro.elementary.snowflake__edr_hour_of_week_expression": { + "name": "snowflake__edr_hour_of_week_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/hour_of_week.sql", + "original_file_path": "macros/utils/cross_db_utils/hour_of_week.sql", + "unique_id": "macro.elementary.snowflake__edr_hour_of_week_expression", + "macro_sql": "{% macro snowflake__edr_hour_of_week_expression(date_expr) %}\n concat(cast(DECODE (EXTRACT('dayofweek',{{ date_expr }}),\n 1 , 'Monday',\n 2 , 'Tuesday',\n 3 , 'Wednesday',\n 4 , 'Thursday',\n 5 , 'Friday',\n 6 , 'Saturday',\n 0 , 'Sunday'\n ) as {{ elementary.edr_type_string() }}), cast(HOUR({{ date_expr }}) as {{ elementary.edr_type_string() }}))\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1163352, + "supported_languages": null + }, + "macro.elementary.athena__edr_hour_of_week_expression": { + "name": "athena__edr_hour_of_week_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/hour_of_week.sql", + "original_file_path": "macros/utils/cross_db_utils/hour_of_week.sql", + "unique_id": "macro.elementary.athena__edr_hour_of_week_expression", + "macro_sql": "{% macro athena__edr_hour_of_week_expression(date_expr) %}\n DATE_FORMAT({{ date_expr }}, '%W%H')\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1164339, + "supported_languages": null + }, + "macro.elementary.edr_current_timestamp": { + "name": "edr_current_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/current_timestamp.sql", + "original_file_path": "macros/utils/cross_db_utils/current_timestamp.sql", + "unique_id": "macro.elementary.edr_current_timestamp", + "macro_sql": "{% macro edr_current_timestamp() -%}\n {{ adapter.dispatch('edr_current_timestamp','elementary')() }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_current_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.11775, + "supported_languages": null + }, + "macro.elementary.default__edr_current_timestamp": { + "name": "default__edr_current_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/current_timestamp.sql", + "original_file_path": "macros/utils/cross_db_utils/current_timestamp.sql", + "unique_id": "macro.elementary.default__edr_current_timestamp", + "macro_sql": "{% macro default__edr_current_timestamp() -%}\n {% set macro = dbt.current_timestamp_backcompat or dbt_utils.current_timestamp %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `current_timestamp` macro.\") }}\n {% endif %}\n {{ return(macro()) }}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.118047, + "supported_languages": null + }, + "macro.elementary.databricks__edr_current_timestamp": { + "name": "databricks__edr_current_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/current_timestamp.sql", + "original_file_path": "macros/utils/cross_db_utils/current_timestamp.sql", + "unique_id": "macro.elementary.databricks__edr_current_timestamp", + "macro_sql": "{% macro databricks__edr_current_timestamp() -%}\n {% set macro = dbt.current_timestamp_backcompat or dbt_utils.current_timestamp %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `current_timestamp` macro.\") }}\n {% endif %}\n {{ return(macro()) }}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1183412, + "supported_languages": null + }, + "macro.elementary.spark__edr_current_timestamp": { + "name": "spark__edr_current_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/current_timestamp.sql", + "original_file_path": "macros/utils/cross_db_utils/current_timestamp.sql", + "unique_id": "macro.elementary.spark__edr_current_timestamp", + "macro_sql": "{% macro spark__edr_current_timestamp() %}\n cast(current_timestamp() as timestamp)\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.118422, + "supported_languages": null + }, + "macro.elementary.edr_current_timestamp_in_utc": { + "name": "edr_current_timestamp_in_utc", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/current_timestamp.sql", + "original_file_path": "macros/utils/cross_db_utils/current_timestamp.sql", + "unique_id": "macro.elementary.edr_current_timestamp_in_utc", + "macro_sql": "{% macro edr_current_timestamp_in_utc() -%}\n {{ adapter.dispatch('edr_current_timestamp_in_utc','elementary')() }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_current_timestamp_in_utc" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.118559, + "supported_languages": null + }, + "macro.elementary.default__edr_current_timestamp_in_utc": { + "name": "default__edr_current_timestamp_in_utc", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/current_timestamp.sql", + "original_file_path": "macros/utils/cross_db_utils/current_timestamp.sql", + "unique_id": "macro.elementary.default__edr_current_timestamp_in_utc", + "macro_sql": "{% macro default__edr_current_timestamp_in_utc() -%}\n {% set macro = dbt.current_timestamp_in_utc_backcompat or dbt_utils.current_timestamp_in_utc %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `current_timestamp_in_utc` macro.\") }}\n {% endif %}\n {{ return(macro()) }}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.118845, + "supported_languages": null + }, + "macro.elementary.databricks__edr_current_timestamp_in_utc": { + "name": "databricks__edr_current_timestamp_in_utc", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/current_timestamp.sql", + "original_file_path": "macros/utils/cross_db_utils/current_timestamp.sql", + "unique_id": "macro.elementary.databricks__edr_current_timestamp_in_utc", + "macro_sql": "{% macro databricks__edr_current_timestamp_in_utc() -%}\n {% set macro = dbt.current_timestamp_in_utc_backcompat or dbt_utils.current_timestamp_in_utc %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `current_timestamp_in_utc` macro.\") }}\n {% endif %}\n {{ return(macro()) }}\n{%- endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1191401, + "supported_languages": null + }, + "macro.elementary.spark__edr_current_timestamp_in_utc": { + "name": "spark__edr_current_timestamp_in_utc", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/current_timestamp.sql", + "original_file_path": "macros/utils/cross_db_utils/current_timestamp.sql", + "unique_id": "macro.elementary.spark__edr_current_timestamp_in_utc", + "macro_sql": "{% macro spark__edr_current_timestamp_in_utc() %}\n cast(unix_timestamp() as timestamp)\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1192179, + "supported_languages": null + }, + "macro.elementary.athena__edr_current_timestamp": { + "name": "athena__edr_current_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/current_timestamp.sql", + "original_file_path": "macros/utils/cross_db_utils/current_timestamp.sql", + "unique_id": "macro.elementary.athena__edr_current_timestamp", + "macro_sql": "{% macro athena__edr_current_timestamp() -%}\n CURRENT_TIMESTAMP\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1192892, + "supported_languages": null + }, + "macro.elementary.athena__edr_current_timestamp_in_utc": { + "name": "athena__edr_current_timestamp_in_utc", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/current_timestamp.sql", + "original_file_path": "macros/utils/cross_db_utils/current_timestamp.sql", + "unique_id": "macro.elementary.athena__edr_current_timestamp_in_utc", + "macro_sql": "{% macro athena__edr_current_timestamp_in_utc() -%}\n cast(CURRENT_TIMESTAMP AT TIME ZONE 'utc' AS TIMESTAMP)\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.119362, + "supported_languages": null + }, + "macro.elementary.edr_time_trunc": { + "name": "edr_time_trunc", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/time_trunc.sql", + "original_file_path": "macros/utils/cross_db_utils/time_trunc.sql", + "unique_id": "macro.elementary.edr_time_trunc", + "macro_sql": "{% macro edr_time_trunc(date_part, date_expression) -%}\n {{ return(adapter.dispatch('edr_time_trunc', 'elementary') (date_part, date_expression)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_time_trunc" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.119734, + "supported_languages": null + }, + "macro.elementary.default__edr_time_trunc": { + "name": "default__edr_time_trunc", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/time_trunc.sql", + "original_file_path": "macros/utils/cross_db_utils/time_trunc.sql", + "unique_id": "macro.elementary.default__edr_time_trunc", + "macro_sql": "{% macro default__edr_time_trunc(date_part, date_expression) %}\n date_trunc('{{date_part}}', cast({{ date_expression }} as {{ elementary.edr_type_timestamp() }}))\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1199749, + "supported_languages": null + }, + "macro.elementary.bigquery__edr_time_trunc": { + "name": "bigquery__edr_time_trunc", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/time_trunc.sql", + "original_file_path": "macros/utils/cross_db_utils/time_trunc.sql", + "unique_id": "macro.elementary.bigquery__edr_time_trunc", + "macro_sql": "{% macro bigquery__edr_time_trunc(date_part, date_expression) %}\n timestamp_trunc(cast({{ date_expression }} as timestamp), {{ date_part }})\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.120113, + "supported_languages": null + }, + "macro.elementary.generate_surrogate_key": { + "name": "generate_surrogate_key", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/generate_surrogate_key.sql", + "original_file_path": "macros/utils/cross_db_utils/generate_surrogate_key.sql", + "unique_id": "macro.elementary.generate_surrogate_key", + "macro_sql": "\n\n\n{%- macro generate_surrogate_key(fields) -%}\n {% set concat_macro = dbt.concat or dbt_utils.concat %}\n {% set hash_macro = dbt.hash or dbt_utils.hash %}\n\n {% set default_null_value = \"\" %}\n {%- set field_sqls = [] -%}\n {%- for field in fields -%}\n {%- do field_sqls.append(\n \"coalesce(cast(\" ~ field ~ \" as \" ~ elementary.edr_type_string() ~ \"), '\" ~ default_null_value ~\"')\"\n ) -%}\n {%- if not loop.last %}\n {%- do field_sqls.append(\"'-'\") -%}\n {%- endif -%}\n {%- endfor -%}\n {{ hash_macro(concat_macro(field_sqls)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1209972, + "supported_languages": null + }, + "macro.elementary.edr_day_of_week_expression": { + "name": "edr_day_of_week_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/day_of_week.sql", + "original_file_path": "macros/utils/cross_db_utils/day_of_week.sql", + "unique_id": "macro.elementary.edr_day_of_week_expression", + "macro_sql": "{% macro edr_day_of_week_expression(date_expr) %}\n {{ return(adapter.dispatch('edr_day_of_week_expression','elementary')(elementary.edr_cast_as_date(date_expr))) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.snowflake__edr_day_of_week_expression", + "macro.elementary.edr_cast_as_date" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.121449, + "supported_languages": null + }, + "macro.elementary.default__edr_day_of_week_expression": { + "name": "default__edr_day_of_week_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/day_of_week.sql", + "original_file_path": "macros/utils/cross_db_utils/day_of_week.sql", + "unique_id": "macro.elementary.default__edr_day_of_week_expression", + "macro_sql": "{% macro default__edr_day_of_week_expression(date_expr) %}\n DATE_FORMAT({{ date_expr }}, 'EEEE')\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.121551, + "supported_languages": null + }, + "macro.elementary.bigquery__edr_day_of_week_expression": { + "name": "bigquery__edr_day_of_week_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/day_of_week.sql", + "original_file_path": "macros/utils/cross_db_utils/day_of_week.sql", + "unique_id": "macro.elementary.bigquery__edr_day_of_week_expression", + "macro_sql": "{% macro bigquery__edr_day_of_week_expression(date_expr) %}\n FORMAT_DATE('%A', {{ date_expr }})\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1216471, + "supported_languages": null + }, + "macro.elementary.postgres__edr_day_of_week_expression": { + "name": "postgres__edr_day_of_week_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/day_of_week.sql", + "original_file_path": "macros/utils/cross_db_utils/day_of_week.sql", + "unique_id": "macro.elementary.postgres__edr_day_of_week_expression", + "macro_sql": "{% macro postgres__edr_day_of_week_expression(date_expr) %}\n to_char({{ date_expr }}, 'Day')\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1217432, + "supported_languages": null + }, + "macro.elementary.redshift__edr_day_of_week_expression": { + "name": "redshift__edr_day_of_week_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/day_of_week.sql", + "original_file_path": "macros/utils/cross_db_utils/day_of_week.sql", + "unique_id": "macro.elementary.redshift__edr_day_of_week_expression", + "macro_sql": "{% macro redshift__edr_day_of_week_expression(date_expr) %}\n{# Redshift returns the days padded with whitespaces to width of 9 #}\n trim(' ' FROM to_char({{ date_expr }}, 'Day'))\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.121848, + "supported_languages": null + }, + "macro.elementary.snowflake__edr_day_of_week_expression": { + "name": "snowflake__edr_day_of_week_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/day_of_week.sql", + "original_file_path": "macros/utils/cross_db_utils/day_of_week.sql", + "unique_id": "macro.elementary.snowflake__edr_day_of_week_expression", + "macro_sql": "{% macro snowflake__edr_day_of_week_expression(date_expr) %}\n{# copied from Snowflake help docs: https://docs.snowflake.com/en/user-guide/date-time-examples #}\n DECODE (EXTRACT('dayofweek',{{ date_expr }}),\n 1 , 'Monday',\n 2 , 'Tuesday',\n 3 , 'Wednesday',\n 4 , 'Thursday',\n 5 , 'Friday',\n 6 , 'Saturday',\n 0 , 'Sunday'\n )\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.121963, + "supported_languages": null + }, + "macro.elementary.athena__edr_day_of_week_expression": { + "name": "athena__edr_day_of_week_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/day_of_week.sql", + "original_file_path": "macros/utils/cross_db_utils/day_of_week.sql", + "unique_id": "macro.elementary.athena__edr_day_of_week_expression", + "macro_sql": "{% macro athena__edr_day_of_week_expression(date_expr) %}\n DATE_FORMAT({{ date_expr }}, '%W')\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.122058, + "supported_languages": null + }, + "macro.elementary.edr_hour_of_day_expression": { + "name": "edr_hour_of_day_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/hour_of_day.sql", + "original_file_path": "macros/utils/cross_db_utils/hour_of_day.sql", + "unique_id": "macro.elementary.edr_hour_of_day_expression", + "macro_sql": "{% macro edr_hour_of_day_expression(date_expr) %}\n {{ return(adapter.dispatch('edr_hour_of_day_expression','elementary')(elementary.edr_cast_as_timestamp(date_expr))) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.snowflake__edr_hour_of_day_expression", + "macro.elementary.edr_cast_as_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1224818, + "supported_languages": null + }, + "macro.elementary.default__edr_hour_of_day_expression": { + "name": "default__edr_hour_of_day_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/hour_of_day.sql", + "original_file_path": "macros/utils/cross_db_utils/hour_of_day.sql", + "unique_id": "macro.elementary.default__edr_hour_of_day_expression", + "macro_sql": "{% macro default__edr_hour_of_day_expression(date_expr) %}\n HOUR({{ date_expr }})\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.122578, + "supported_languages": null + }, + "macro.elementary.bigquery__edr_hour_of_day_expression": { + "name": "bigquery__edr_hour_of_day_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/hour_of_day.sql", + "original_file_path": "macros/utils/cross_db_utils/hour_of_day.sql", + "unique_id": "macro.elementary.bigquery__edr_hour_of_day_expression", + "macro_sql": "{% macro bigquery__edr_hour_of_day_expression(date_expr) %}\n EXTRACT(hour from {{ date_expr }})\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.12268, + "supported_languages": null + }, + "macro.elementary.postgres__edr_hour_of_day_expression": { + "name": "postgres__edr_hour_of_day_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/hour_of_day.sql", + "original_file_path": "macros/utils/cross_db_utils/hour_of_day.sql", + "unique_id": "macro.elementary.postgres__edr_hour_of_day_expression", + "macro_sql": "{% macro postgres__edr_hour_of_day_expression(date_expr) %}\n EXTRACT(hour from {{ date_expr }})\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.122775, + "supported_languages": null + }, + "macro.elementary.redshift__edr_hour_of_day_expression": { + "name": "redshift__edr_hour_of_day_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/hour_of_day.sql", + "original_file_path": "macros/utils/cross_db_utils/hour_of_day.sql", + "unique_id": "macro.elementary.redshift__edr_hour_of_day_expression", + "macro_sql": "{% macro redshift__edr_hour_of_day_expression(date_expr) %}\n EXTRACT(hour from {{ date_expr }})\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.122872, + "supported_languages": null + }, + "macro.elementary.snowflake__edr_hour_of_day_expression": { + "name": "snowflake__edr_hour_of_day_expression", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/hour_of_day.sql", + "original_file_path": "macros/utils/cross_db_utils/hour_of_day.sql", + "unique_id": "macro.elementary.snowflake__edr_hour_of_day_expression", + "macro_sql": "{% macro snowflake__edr_hour_of_day_expression(date_expr) %}\n HOUR({{ date_expr }})\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.122965, + "supported_languages": null + }, + "macro.elementary.timediff": { + "name": "timediff", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/timediff.sql", + "original_file_path": "macros/utils/cross_db_utils/timediff.sql", + "unique_id": "macro.elementary.timediff", + "macro_sql": "{% macro timediff(timepart, first_timestamp, second_timestamp) -%}\n {{ return(adapter.dispatch('timediff', 'elementary')(timepart, first_timestamp, second_timestamp)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__timediff" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.123316, + "supported_languages": null + }, + "macro.elementary.default__timediff": { + "name": "default__timediff", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/timediff.sql", + "original_file_path": "macros/utils/cross_db_utils/timediff.sql", + "unique_id": "macro.elementary.default__timediff", + "macro_sql": "{% macro default__timediff(timepart, first_timestamp, second_timestamp) %}\n {{ elementary.edr_datediff(first_timestamp, second_timestamp, timepart)}}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_datediff" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.123486, + "supported_languages": null + }, + "macro.elementary.bigquery__timediff": { + "name": "bigquery__timediff", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/timediff.sql", + "original_file_path": "macros/utils/cross_db_utils/timediff.sql", + "unique_id": "macro.elementary.bigquery__timediff", + "macro_sql": "{% macro bigquery__timediff(timepart, first_timestamp, second_timestamp) %}\n timestamp_diff({{ second_timestamp }}, {{ first_timestamp }}, {{ timepart }})\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.123638, + "supported_languages": null + }, + "macro.elementary.get_profile_creation_query": { + "name": "get_profile_creation_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/get_profile_creation_query.sql", + "original_file_path": "macros/utils/cross_db_utils/get_profile_creation_query.sql", + "unique_id": "macro.elementary.get_profile_creation_query", + "macro_sql": "{% macro get_profile_creation_query(parameters) %}\n {% do return(adapter.dispatch(\"get_profile_creation_query\", \"elementary\")(parameters)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.snowflake__get_profile_creation_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.125736, + "supported_languages": null + }, + "macro.elementary.snowflake__get_profile_creation_query": { + "name": "snowflake__get_profile_creation_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/get_profile_creation_query.sql", + "original_file_path": "macros/utils/cross_db_utils/get_profile_creation_query.sql", + "unique_id": "macro.elementary.snowflake__get_profile_creation_query", + "macro_sql": "{% macro snowflake__get_profile_creation_query(parameters) %}\n-- Set credentials as variables\nSET elementary_database = '{{ parameters[\"database\"] }}';\nSET elementary_schema = '{{ parameters[\"schema\"] }}';\nSET elementary_warehouse = '{{ parameters[\"warehouse\"] }}';\nSET elementary_role = '{{ parameters[\"role\"] }}';\nSET elementary_username = '{{ parameters[\"user\"] }}';\nSET elementary_password = '{{ parameters[\"password\"] }}';\n\n-- Account admin role required to set up permissions below\nUSE ROLE ACCOUNTADMIN;\n\n-- Create elementary user and role\nCREATE OR REPLACE USER IDENTIFIER($elementary_username) PASSWORD = $elementary_password;\nCREATE OR REPLACE ROLE IDENTIFIER($elementary_role);\nGRANT ROLE IDENTIFIER($elementary_role) TO USER IDENTIFIER($elementary_username);\n\n-- Grant elementary role access to the supplied warehouse\nGRANT USAGE ON WAREHOUSE IDENTIFIER($elementary_warehouse) TO ROLE IDENTIFIER($elementary_role);\n\n-- Read access to elementary schema\nSET elementary_schema_fqn = $elementary_database || '.' || $elementary_schema;\nGRANT SELECT ON ALL TABLES IN SCHEMA IDENTIFIER($elementary_schema_fqn) TO ROLE IDENTIFIER($elementary_role);\nGRANT SELECT ON FUTURE TABLES IN SCHEMA IDENTIFIER($elementary_schema_fqn) TO ROLE IDENTIFIER($elementary_role);\nGRANT SELECT ON ALL VIEWS IN SCHEMA IDENTIFIER($elementary_schema_fqn) TO ROLE IDENTIFIER($elementary_role);\nGRANT SELECT ON FUTURE VIEWS IN SCHEMA IDENTIFIER($elementary_schema_fqn) TO ROLE IDENTIFIER($elementary_role);\n\n-- Information schema access\nCREATE OR REPLACE PROCEDURE ELEMENTARY_GRANT_INFO_SCHEMA_ACCESS(database_name STRING, role_name STRING)\n RETURNS VARCHAR\n LANGUAGE SQL\n AS\n $$\n BEGIN\n GRANT USAGE,MONITOR ON DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);\n GRANT USAGE,MONITOR ON ALL SCHEMAS IN DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);\n GRANT USAGE,MONITOR ON FUTURE SCHEMAS IN DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);\n\n GRANT REFERENCES ON ALL TABLES IN DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);\n GRANT REFERENCES ON ALL VIEWS IN DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);\n GRANT REFERENCES ON ALL EXTERNAL TABLES IN DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);\n\n GRANT REFERENCES ON FUTURE TABLES IN DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);\n GRANT REFERENCES ON FUTURE VIEWS IN DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);\n GRANT REFERENCES ON FUTURE EXTERNAL TABLES IN DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);\n END;\n $$\n;\n\n{%- set databases = elementary.get_configured_databases_from_graph()%}\n{% for database in databases %}\n{#\n 'snowflake' database is excluded because it does not support granting individual privileges (we ask for relevant access to it\n via the database roles below)\n see: https://docs.snowflake.com/en/sql-reference/account-usage#enabling-the-snowflake-database-usage-for-other-roles\n#}\n {%- if database | lower != 'snowflake' -%}\nCALL ELEMENTARY_GRANT_INFO_SCHEMA_ACCESS('{{ database }}', $elementary_role);\n {%- endif -%}\n{% endfor %}\n\n-- Query history access\nCREATE OR REPLACE PROCEDURE ELEMENTARY_GRANT_QUERY_HISTORY_ACCESS(role_name STRING)\n RETURNS VARCHAR\n LANGUAGE SQL\n AS\n $$\n BEGIN\n GRANT DATABASE ROLE SNOWFLAKE.OBJECT_VIEWER TO ROLE IDENTIFIER(:role_name);\n GRANT DATABASE ROLE SNOWFLAKE.USAGE_VIEWER TO ROLE IDENTIFIER(:role_name);\n GRANT DATABASE ROLE SNOWFLAKE.GOVERNANCE_VIEWER TO ROLE IDENTIFIER(:role_name);\n\n LET warehouses_rs RESULTSET := (SHOW WAREHOUSES);\n LET warehouses_cur CURSOR FOR warehouses_rs;\n FOR warehouse_row IN warehouses_cur DO\n LET warehouse_name VARCHAR := warehouse_row.\"name\";\n GRANT MONITOR ON WAREHOUSE IDENTIFIER(:warehouse_name) TO ROLE IDENTIFIER(:role_name);\n END FOR;\n END;\n $$\n;\nCALL ELEMENTARY_GRANT_QUERY_HISTORY_ACCESS($elementary_role);\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_configured_databases_from_graph" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.126525, + "supported_languages": null + }, + "macro.elementary.redshift__get_profile_creation_query": { + "name": "redshift__get_profile_creation_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/get_profile_creation_query.sql", + "original_file_path": "macros/utils/cross_db_utils/get_profile_creation_query.sql", + "unique_id": "macro.elementary.redshift__get_profile_creation_query", + "macro_sql": "{% macro redshift__get_profile_creation_query(parameters) %}\n-- Create redshift user with unrestricted access to query history (allows Elementary to see queries generated by\n-- any user)\nCREATE USER {{ parameters[\"user\"] }} WITH PASSWORD '{{ parameters[\"password\"] }}' SYSLOG ACCESS UNRESTRICTED;\n\n-- Grant read access to the Elementary schema\nGRANT USAGE ON SCHEMA {{ parameters[\"schema\"] }} TO {{ parameters[\"user\"] }};\nGRANT SELECT ON ALL TABLES IN SCHEMA {{ parameters[\"schema\"] }} TO {{ parameters[\"user\"] }};\nALTER DEFAULT PRIVILEGES IN SCHEMA {{ parameters[\"schema\"] }} GRANT SELECT ON TABLES TO {{ parameters[\"user\"] }};\n\n-- Grant metadata access to tables in the warehouse\nGRANT SELECT ON svv_table_info to {{ parameters[\"user\"] }};\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.12696, + "supported_languages": null + }, + "macro.elementary.postgres__get_profile_creation_query": { + "name": "postgres__get_profile_creation_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/get_profile_creation_query.sql", + "original_file_path": "macros/utils/cross_db_utils/get_profile_creation_query.sql", + "unique_id": "macro.elementary.postgres__get_profile_creation_query", + "macro_sql": "{% macro postgres__get_profile_creation_query(parameters) %}\n-- Create postgres user\nCREATE USER {{ parameters[\"user\"] }} WITH PASSWORD '{{ parameters[\"password\"] }}';\n\n-- Grant read access to the Elementary schema\nGRANT USAGE ON SCHEMA {{ parameters[\"schema\"] }} TO {{ parameters[\"user\"] }};\nGRANT SELECT ON ALL TABLES IN SCHEMA {{ parameters[\"schema\"] }} TO {{ parameters[\"user\"] }};\nALTER DEFAULT PRIVILEGES IN SCHEMA {{ parameters[\"schema\"] }} GRANT SELECT ON TABLES TO {{ parameters[\"user\"] }};\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.127337, + "supported_languages": null + }, + "macro.elementary.default__get_profile_creation_query": { + "name": "default__get_profile_creation_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/get_profile_creation_query.sql", + "original_file_path": "macros/utils/cross_db_utils/get_profile_creation_query.sql", + "unique_id": "macro.elementary.default__get_profile_creation_query", + "macro_sql": "{% macro default__get_profile_creation_query(parameters) %}\n {% do exceptions.raise_compiler_error('User creation not supported through sql using ' ~ target.type) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.12749, + "supported_languages": null + }, + "macro.elementary.edr_multi_value_in": { + "name": "edr_multi_value_in", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/multi_value_in.sql", + "original_file_path": "macros/utils/cross_db_utils/multi_value_in.sql", + "unique_id": "macro.elementary.edr_multi_value_in", + "macro_sql": "{% macro edr_multi_value_in(source_cols, target_cols, target_table) %}\n {% do return(adapter.dispatch('edr_multi_value_in', 'elementary') (source_cols, target_cols, target_table)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_multi_value_in" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.128372, + "supported_languages": null + }, + "macro.elementary.default__edr_multi_value_in": { + "name": "default__edr_multi_value_in", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/multi_value_in.sql", + "original_file_path": "macros/utils/cross_db_utils/multi_value_in.sql", + "unique_id": "macro.elementary.default__edr_multi_value_in", + "macro_sql": "\n\n{%- macro default__edr_multi_value_in(source_cols, target_cols, target_table) -%}\n (\n {%- for val in source_cols -%}\n {{ val }}\n {%- if not loop.last %}, {% endif %}\n {%- endfor %}\n ) in (\n select {% for val in target_cols -%}\n {{ val }}\n {%- if not loop.last %}, {% endif %}\n {%- endfor %}\n from {{ target_table }}\n )\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.128746, + "supported_languages": null + }, + "macro.elementary.bigquery__edr_multi_value_in": { + "name": "bigquery__edr_multi_value_in", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/multi_value_in.sql", + "original_file_path": "macros/utils/cross_db_utils/multi_value_in.sql", + "unique_id": "macro.elementary.bigquery__edr_multi_value_in", + "macro_sql": "{%- macro bigquery__edr_multi_value_in(source_cols, target_cols, target_table) -%}\n -- BigQuery doesn't support multi-value IN, so we emulate it with CONCAT\n concat(\n {%- for val in source_cols -%}\n {{ elementary.edr_cast_as_string(val) -}}\n {%- if not loop.last %}, {% endif %}\n {%- endfor %}\n ) in (\n select concat({%- for val in target_cols -%}\n {{ elementary.edr_cast_as_string(val) -}}\n {%- if not loop.last %}, {% endif %}\n {%- endfor %})\n from {{ target_table }}\n )\n{%- endmacro -%}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.12918, + "supported_languages": null + }, + "macro.elementary.edr_date_trunc": { + "name": "edr_date_trunc", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/date_trunc.sql", + "original_file_path": "macros/utils/cross_db_utils/date_trunc.sql", + "unique_id": "macro.elementary.edr_date_trunc", + "macro_sql": "{% macro edr_date_trunc(date_part, date_expression) -%}\n {{ return(adapter.dispatch('edr_date_trunc', 'elementary') (date_part, date_expression)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_date_trunc" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1295612, + "supported_languages": null + }, + "macro.elementary.default__edr_date_trunc": { + "name": "default__edr_date_trunc", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/date_trunc.sql", + "original_file_path": "macros/utils/cross_db_utils/date_trunc.sql", + "unique_id": "macro.elementary.default__edr_date_trunc", + "macro_sql": "{% macro default__edr_date_trunc(datepart, date_expression) %}\n {% set macro = dbt.date_trunc or dbt_utils.date_trunc %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `date_trunc` macro.\") }}\n {% endif %}\n {{ return(macro(datepart, date_expression)) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1298938, + "supported_languages": null + }, + "macro.elementary.bigquery__edr_date_trunc": { + "name": "bigquery__edr_date_trunc", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/date_trunc.sql", + "original_file_path": "macros/utils/cross_db_utils/date_trunc.sql", + "unique_id": "macro.elementary.bigquery__edr_date_trunc", + "macro_sql": "{% macro bigquery__edr_date_trunc(date_part, date_expression) %}\n timestamp_trunc(cast({{ date_expression }} as timestamp), {{ date_part }})\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.130025, + "supported_languages": null + }, + "macro.elementary.edr_timeadd": { + "name": "edr_timeadd", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/timeadd.sql", + "original_file_path": "macros/utils/cross_db_utils/timeadd.sql", + "unique_id": "macro.elementary.edr_timeadd", + "macro_sql": "{% macro edr_timeadd(date_part, number, timestamp_expression) -%}\n {{ return(adapter.dispatch('edr_timeadd', 'elementary')(date_part, number, timestamp_expression)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_timeadd" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.131008, + "supported_languages": null + }, + "macro.elementary.default__edr_timeadd": { + "name": "default__edr_timeadd", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/timeadd.sql", + "original_file_path": "macros/utils/cross_db_utils/timeadd.sql", + "unique_id": "macro.elementary.default__edr_timeadd", + "macro_sql": "{% macro default__edr_timeadd(date_part, number, timestamp_expression) %}\n dateadd({{ date_part }}, {{ elementary.edr_cast_as_int(number) }}, {{ elementary.edr_cast_as_timestamp(timestamp_expression) }})\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_int", + "macro.elementary.edr_cast_as_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1312141, + "supported_languages": null + }, + "macro.elementary.bigquery__edr_timeadd": { + "name": "bigquery__edr_timeadd", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/timeadd.sql", + "original_file_path": "macros/utils/cross_db_utils/timeadd.sql", + "unique_id": "macro.elementary.bigquery__edr_timeadd", + "macro_sql": "{% macro bigquery__edr_timeadd(date_part, number, timestamp_expression) %}\n {%- if date_part | lower in ['second', 'minute', 'hour', 'day'] %}\n timestamp_add({{ elementary.edr_cast_as_timestamp(timestamp_expression) }}, INTERVAL {{ elementary.edr_cast_as_int(number) }} {{ date_part }})\n {%- elif date_part | lower in ['week', 'month', 'quarter', 'year'] %}\n date_add({{ elementary.edr_cast_as_date(timestamp_expression) }}, INTERVAL {{ elementary.edr_cast_as_int(number) }} {{ date_part }})\n {%- else %}\n {{ exceptions.raise_compiler_error(\"Unsupported date_part in edr_timeadd: \".format(date_part)) }}\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.edr_cast_as_int", + "macro.elementary.edr_cast_as_date" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.131843, + "supported_languages": null + }, + "macro.elementary.postgres__edr_timeadd": { + "name": "postgres__edr_timeadd", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/timeadd.sql", + "original_file_path": "macros/utils/cross_db_utils/timeadd.sql", + "unique_id": "macro.elementary.postgres__edr_timeadd", + "macro_sql": "{% macro postgres__edr_timeadd(date_part, number, timestamp_expression) %}\n {{ elementary.edr_cast_as_timestamp(timestamp_expression) }} + {{ elementary.edr_cast_as_int(number) }} * INTERVAL '1 {{ date_part }}'\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.edr_cast_as_int" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.132054, + "supported_languages": null + }, + "macro.elementary.redshift__edr_timeadd": { + "name": "redshift__edr_timeadd", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/timeadd.sql", + "original_file_path": "macros/utils/cross_db_utils/timeadd.sql", + "unique_id": "macro.elementary.redshift__edr_timeadd", + "macro_sql": "{% macro redshift__edr_timeadd(date_part, number, timestamp_expression) %}\n dateadd({{ date_part }}, {{ elementary.edr_cast_as_int(number) }}, {{ elementary.edr_cast_as_timestamp(timestamp_expression) }})\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_int", + "macro.elementary.edr_cast_as_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.132261, + "supported_languages": null + }, + "macro.elementary.athena__edr_timeadd": { + "name": "athena__edr_timeadd", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/cross_db_utils/timeadd.sql", + "original_file_path": "macros/utils/cross_db_utils/timeadd.sql", + "unique_id": "macro.elementary.athena__edr_timeadd", + "macro_sql": "{% macro athena__edr_timeadd(date_part, number, timestamp_expression) %}\n date_add('{{ date_part }}', {{ elementary.edr_cast_as_int(number) }}, {{ elementary.edr_cast_as_timestamp(timestamp_expression) }})\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_int", + "macro.elementary.edr_cast_as_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.132468, + "supported_languages": null + }, + "macro.elementary.get_normalized_data_type": { + "name": "get_normalized_data_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/get_normalized_data_type.sql", + "original_file_path": "macros/utils/data_types/get_normalized_data_type.sql", + "unique_id": "macro.elementary.get_normalized_data_type", + "macro_sql": "{% macro get_normalized_data_type(exact_data_type) %}\n {% if exact_data_type is none %}\n {{ return (exact_data_type) }}\n {% endif %}\n {% set exact_data_type_uppercase = exact_data_type | upper %}\n {% set result = adapter.dispatch('get_normalized_data_type','elementary')(exact_data_type_uppercase) %}\n {{ return(result) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.snowflake__get_normalized_data_type" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1343958, + "supported_languages": null + }, + "macro.elementary.default__get_normalized_data_type": { + "name": "default__get_normalized_data_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/get_normalized_data_type.sql", + "original_file_path": "macros/utils/data_types/get_normalized_data_type.sql", + "unique_id": "macro.elementary.default__get_normalized_data_type", + "macro_sql": "{% macro default__get_normalized_data_type(exact_data_type) %}\n {{return (exact_data_type) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.134523, + "supported_languages": null + }, + "macro.elementary.bigquery__get_normalized_data_type": { + "name": "bigquery__get_normalized_data_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/get_normalized_data_type.sql", + "original_file_path": "macros/utils/data_types/get_normalized_data_type.sql", + "unique_id": "macro.elementary.bigquery__get_normalized_data_type", + "macro_sql": "{% macro bigquery__get_normalized_data_type(exact_data_type) %}\n{# BigQuery has no concept of data type synonyms,\n see https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types #}\n {% set exact_data_type_to_data_type_returned_by_the_info_schema = {'BOOLEAN': 'BOOL'} %}\n {%- if exact_data_type in exact_data_type_to_data_type_returned_by_the_info_schema%}\n {{ return (exact_data_type_to_data_type_returned_by_the_info_schema[exact_data_type])}}\n {%- else %}\n {{return (exact_data_type) }}\n {%- endif%}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.134846, + "supported_languages": null + }, + "macro.elementary.snowflake__get_normalized_data_type": { + "name": "snowflake__get_normalized_data_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/get_normalized_data_type.sql", + "original_file_path": "macros/utils/data_types/get_normalized_data_type.sql", + "unique_id": "macro.elementary.snowflake__get_normalized_data_type", + "macro_sql": "{% macro snowflake__get_normalized_data_type(exact_data_type) %}\n{# understanding Snowflake data type synonyms:\n https://docs.snowflake.com/en/sql-reference/intro-summary-data-types.html #}\n {% set exact_data_type_to_data_type_returned_by_the_info_schema = {'VARCHAR': 'TEXT',\n 'STRING': 'TEXT',\n 'NVARCHAR': 'TEXT',\n 'NUMERIC': 'NUMBER',\n 'DECIMAL': 'NUMBER',\n 'INT':'NUMBER',\n 'INTEGER':'NUMBER',\n 'SMALLINT':'NUMBER',\n 'BIGINT':'NUMBER',\n 'TINYINT':'NUMBER',\n 'BYTEINT':'NUMBER',\n 'REAL': 'FLOAT',\n 'DOUBLE':'FLOAT',\n 'DOUBLE PRECISION': 'FLOAT'\n }%}\n {%- if exact_data_type in exact_data_type_to_data_type_returned_by_the_info_schema%}\n {{ return (exact_data_type_to_data_type_returned_by_the_info_schema[exact_data_type])}}\n {%- else %}\n {{return (exact_data_type) }}\n {%- endif%}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.135574, + "supported_languages": null + }, + "macro.elementary.spark__get_normalized_data_type": { + "name": "spark__get_normalized_data_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/get_normalized_data_type.sql", + "original_file_path": "macros/utils/data_types/get_normalized_data_type.sql", + "unique_id": "macro.elementary.spark__get_normalized_data_type", + "macro_sql": "{% macro spark__get_normalized_data_type(exact_data_type) %}\n{# spark also has no concept of data type synonyms :\n see https://spark.apache.org/docs/latest/sql-ref-datatypes.html #}\n {{return (exact_data_type) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.135705, + "supported_languages": null + }, + "macro.elementary.redshift__get_normalized_data_type": { + "name": "redshift__get_normalized_data_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/get_normalized_data_type.sql", + "original_file_path": "macros/utils/data_types/get_normalized_data_type.sql", + "unique_id": "macro.elementary.redshift__get_normalized_data_type", + "macro_sql": "{% macro redshift__get_normalized_data_type(exact_data_type) %}\n{# understanding Redshift data type synonyms:\n https://docs.aws.amazon.com/redshift/latest/dg/c_Supported_data_types.html #}\n {% set exact_data_type_to_data_type_returned_by_the_info_schema = {'INT2':\t'SMALLINT',\n 'INT':\t'INTEGER',\n 'INT4':\t'INTEGER',\n 'INT8':\t'BIGINT',\n 'NUMERIC':\t'DECIMAL',\n 'FLOAT4':\t'REAL',\n 'FLOAT8':\t'DOUBLE PRECISION',\n 'FLOAT':\t'DOUBLE PRECISION',\n 'BOOL':\t'BOOLEAN',\n 'CHARACTER':\t'CHAR',\n 'NCHAR':\t'CHAR',\n 'BPCHAR':\t'CHAR',\n 'VARCHAR': 'CHARACTER VARYING',\n 'NVARCHAR':\t'CHARACTER VARYING',\n 'TEXT':\t'CHARACTER VARYING',\n 'TIMESTAMP': 'TIMESTAMP WITHOUT TIME ZONE',\n 'TIMESTAMPTZ': 'TIMESTAMP WITH TIME ZONE',\n 'TIME': 'TIME WITHOUT TIME ZONE',\n 'TIME WITH TIME ZONE':\t'TIMETZ',\n 'VARBINARY': 'BINARY VARYING',\n 'VARBYTE': 'BINARY VARYING'} %}\n {%- if exact_data_type in exact_data_type_to_data_type_returned_by_the_info_schema%}\n {{ return (exact_data_type_to_data_type_returned_by_the_info_schema[exact_data_type])}}\n {%- else %}\n {{return (exact_data_type) }}\n {%- endif%}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.136561, + "supported_languages": null + }, + "macro.elementary.postgres__get_normalized_data_type": { + "name": "postgres__get_normalized_data_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/get_normalized_data_type.sql", + "original_file_path": "macros/utils/data_types/get_normalized_data_type.sql", + "unique_id": "macro.elementary.postgres__get_normalized_data_type", + "macro_sql": "{% macro postgres__get_normalized_data_type(exact_data_type) %}\n{# understanding Postgres data type synonyms:\n https://www.postgresql.org/docs/current/datatype.html #}\n {% set exact_data_type_to_data_type_returned_by_the_info_schema = {'BIGINT': 'INT8',\n 'BIGSERIAL': 'SERIAL8',\n 'BIT VARYING': 'VARBIT',\n 'BOOLEAN': 'BOOL',\n 'CHARACTER': 'CHAR',\n 'CHARACTER VARYING': 'VARCHAR',\n 'DOUBLE PRECISION': 'FLOAT8',\n 'INTEGER': 'INT, INT4',\n 'NUMERIC': 'DECIMAL',\n 'REAL': 'FLOAT4',\n 'SMALLINT': 'INT2',\n 'SMALLSERIAL': 'SERIAL2',\n 'SERIAL': 'SERIAL4',\n 'TIME WITH TIME ZONE': 'TIMETZ',\n 'TIMESTAMP WITH TIME ZONE': 'TIMESTAMPTZ'} %}\n {%- if exact_data_type in exact_data_type_to_data_type_returned_by_the_info_schema%}\n {{ return (exact_data_type_to_data_type_returned_by_the_info_schema[exact_data_type])}}\n {%- else %}\n {{return (exact_data_type) }}\n {%- endif%}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.137259, + "supported_languages": null + }, + "macro.elementary.to_primitive": { + "name": "to_primitive", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/to_primitive.sql", + "original_file_path": "macros/utils/data_types/to_primitive.sql", + "unique_id": "macro.elementary.to_primitive", + "macro_sql": "{% macro to_primitive(val) %}\n {% if elementary.is_primitive(val) %}\n {% do return(val) %}\n\n {% elif val is mapping %}\n {% set new_dict = {} %}\n {% for k, v in val.items() %}\n {% do new_dict.update({k: elementary.to_primitive(v)}) %}\n {% endfor %}\n {% do return(new_dict) %}\n\n {% elif val is iterable %}\n {% set new_list = [] %}\n {% for item in val %}\n {% do new_list.append(elementary.to_primitive(item)) %}\n {% endfor %}\n {% do return(new_list) %}\n\n {% else %}\n {% do return(val | string) %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.is_primitive", + "macro.elementary.to_primitive" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.13836, + "supported_languages": null + }, + "macro.elementary.try_cast_column_to_timestamp": { + "name": "try_cast_column_to_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/try_cast_column_to_timestamp.sql", + "original_file_path": "macros/utils/data_types/try_cast_column_to_timestamp.sql", + "unique_id": "macro.elementary.try_cast_column_to_timestamp", + "macro_sql": "{% macro try_cast_column_to_timestamp(table_relation, timestamp_column) %}\n {{ return(adapter.dispatch('try_cast_column_to_timestamp', 'elementary')(table_relation, timestamp_column)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__try_cast_column_to_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.138816, + "supported_languages": null + }, + "macro.elementary.default__try_cast_column_to_timestamp": { + "name": "default__try_cast_column_to_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/try_cast_column_to_timestamp.sql", + "original_file_path": "macros/utils/data_types/try_cast_column_to_timestamp.sql", + "unique_id": "macro.elementary.default__try_cast_column_to_timestamp", + "macro_sql": "{% macro default__try_cast_column_to_timestamp(table_relation, timestamp_column) %}\n {# We try casting for Snowflake, Bigquery and Databricks as these support safe cast and the query will not fail if the cast fails #}\n {%- set query %}\n select {{ elementary.edr_safe_cast(timestamp_column, elementary.edr_type_timestamp()) }} as timestamp_column\n from {{ table_relation }}\n where {{ timestamp_column }} is not null\n limit 1\n {%- endset %}\n\n {%- set result = elementary.result_value(query) %}\n {%- if result is not none %}\n {{ return(true) }}\n {%- endif %}\n {{ return(false) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_safe_cast", + "macro.elementary.edr_type_timestamp", + "macro.elementary.result_value" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.139273, + "supported_languages": null + }, + "macro.elementary.postgres__try_cast_column_to_timestamp": { + "name": "postgres__try_cast_column_to_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/try_cast_column_to_timestamp.sql", + "original_file_path": "macros/utils/data_types/try_cast_column_to_timestamp.sql", + "unique_id": "macro.elementary.postgres__try_cast_column_to_timestamp", + "macro_sql": "{% macro postgres__try_cast_column_to_timestamp(table_relation, timestamp_column) %}\n {{ return(false) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.139406, + "supported_languages": null + }, + "macro.elementary.data_type_list": { + "name": "data_type_list", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type_list.sql", + "original_file_path": "macros/utils/data_types/data_type_list.sql", + "unique_id": "macro.elementary.data_type_list", + "macro_sql": "{% macro data_type_list(data_type) %}\n {% set result = adapter.dispatch('data_type_list','elementary')(data_type) %}\n {{ return(result) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.snowflake__data_type_list" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.142915, + "supported_languages": null + }, + "macro.elementary.default__data_type_list": { + "name": "default__data_type_list", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type_list.sql", + "original_file_path": "macros/utils/data_types/data_type_list.sql", + "unique_id": "macro.elementary.default__data_type_list", + "macro_sql": "{% macro default__data_type_list(data_type) %}\n\n {% set string_list = ['character varying','varchar','character','char','text','nchar','bpchar','string'] | list %}\n {% set numeric_list = ['integer', 'bigint','smallint','decimal','numeric','real','double precision','enum','int2','int4','int','int8','float8','float'] | list %}\n {% set timestamp_list = ['date', 'timestamp','timestamptz','timestamp without time zone','timestamp with time zone'] | list %}\n\n {%- if data_type == 'string' %}\n {{ return(string_list) }}\n {%- elif data_type == 'numeric' %}\n {{ return(numeric_list) }}\n {%- elif data_type == 'timestamp' %}\n {{ return(timestamp_list) }}\n {%- else %}\n {{ return([]) }}\n {%- endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1437728, + "supported_languages": null + }, + "macro.elementary.bigquery__data_type_list": { + "name": "bigquery__data_type_list", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type_list.sql", + "original_file_path": "macros/utils/data_types/data_type_list.sql", + "unique_id": "macro.elementary.bigquery__data_type_list", + "macro_sql": "{% macro bigquery__data_type_list(data_type) %}\n\n {% set string_list = ['STRING'] | list %}\n {% set numeric_list = ['INT64','NUMERIC','BIGNUMERIC','FLOAT64','INTEGER'] | list %}\n {% set timestamp_list = ['DATE','DATETIME','TIMESTAMP'] | list %}\n\n {%- if data_type == 'string' %}\n {{ return(string_list) }}\n {%- elif data_type == 'numeric' %}\n {{ return(numeric_list) }}\n {%- elif data_type == 'timestamp' %}\n {{ return(timestamp_list) }}\n {%- else %}\n {{ return([]) }}\n {%- endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.144423, + "supported_languages": null + }, + "macro.elementary.snowflake__data_type_list": { + "name": "snowflake__data_type_list", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type_list.sql", + "original_file_path": "macros/utils/data_types/data_type_list.sql", + "unique_id": "macro.elementary.snowflake__data_type_list", + "macro_sql": "{% macro snowflake__data_type_list(data_type) %}\n\n {% set string_list = ['VARCHAR','CHAR','CHARACTER','STRING','TEXT'] | list %}\n {% set numeric_list = ['NUMBER','DECIMAL','NUMERIC','INT','INTEGER','BIGINT','SMALLINT','TINYINT','BYTEINT','FLOAT','FLOAT4','FLOAT8','DOUBLE','DOUBLE PRECISION','REAL'] | list %}\n {% set timestamp_list = ['DATE','DATETIME','TIME','TIMESTAMP','TIMESTAMP_LTZ','TIMESTAMP_NTZ','TIMESTAMP_TZ'] | list %}\n\n {%- if data_type == 'string' %}\n {{ return(string_list) }}\n {%- elif data_type == 'numeric' %}\n {{ return(numeric_list) }}\n {%- elif data_type == 'timestamp' %}\n {{ return(timestamp_list) }}\n {%- else %}\n {{ return([]) }}\n {%- endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.14528, + "supported_languages": null + }, + "macro.elementary.spark__data_type_list": { + "name": "spark__data_type_list", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type_list.sql", + "original_file_path": "macros/utils/data_types/data_type_list.sql", + "unique_id": "macro.elementary.spark__data_type_list", + "macro_sql": "{% macro spark__data_type_list(data_type) %}\n\n {% set string_list = ['string'] | list %}\n {% set numeric_list = ['int','bigint','smallint','tinyint','float','double','long','short','decimal'] | list %}\n {% set timestamp_list = ['timestamp','date'] | list %}\n\n {%- if data_type == 'string' %}\n {{ return(string_list) }}\n {%- elif data_type == 'numeric' %}\n {{ return(numeric_list) }}\n {%- elif data_type == 'timestamp' %}\n {{ return(timestamp_list) }}\n {%- else %}\n {{ return([]) }}\n {%- endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.145966, + "supported_languages": null + }, + "macro.elementary.athena__data_type_list": { + "name": "athena__data_type_list", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type_list.sql", + "original_file_path": "macros/utils/data_types/data_type_list.sql", + "unique_id": "macro.elementary.athena__data_type_list", + "macro_sql": "{% macro athena__data_type_list(data_type) %}\n\n {% set string_list = ['string', 'varchar', 'char'] | list %}\n {% set numeric_list = ['int','integer','bigint','smallint','tinyint','float','real','double','decimal'] | list %}\n {% set timestamp_list = ['timestamp','date'] | list %}\n\n {%- if data_type == 'string' %}\n {{ return(string_list) }}\n {%- elif data_type == 'numeric' %}\n {{ return(numeric_list) }}\n {%- elif data_type == 'timestamp' %}\n {{ return(timestamp_list) }}\n {%- else %}\n {{ return([]) }}\n {%- endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.146671, + "supported_languages": null + }, + "macro.elementary.edr_cast_as_timestamp": { + "name": "edr_cast_as_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.edr_cast_as_timestamp", + "macro_sql": "{%- macro edr_cast_as_timestamp(timestamp_field) -%}\n {{ return(adapter.dispatch('edr_cast_as_timestamp', 'elementary')(timestamp_field)) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_cast_as_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1480992, + "supported_languages": null + }, + "macro.elementary.default__edr_cast_as_timestamp": { + "name": "default__edr_cast_as_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.default__edr_cast_as_timestamp", + "macro_sql": "{%- macro default__edr_cast_as_timestamp(timestamp_field) -%}\n cast({{ timestamp_field }} as {{ elementary.edr_type_timestamp() }})\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1482391, + "supported_languages": null + }, + "macro.elementary.athena__edr_cast_as_timestamp": { + "name": "athena__edr_cast_as_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.athena__edr_cast_as_timestamp", + "macro_sql": "\n{%- macro athena__edr_cast_as_timestamp(timestamp_field) -%}\n coalesce(\n try_cast({{ timestamp_field }} as {{ elementary.edr_type_timestamp() }}),\n cast(from_iso8601_timestamp(cast({{ timestamp_field }} AS {{ elementary.edr_type_string() }})) AS {{ elementary.edr_type_timestamp() }})\n )\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_timestamp", + "macro.elementary.edr_type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.14847, + "supported_languages": null + }, + "macro.elementary.edr_cast_as_float": { + "name": "edr_cast_as_float", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.edr_cast_as_float", + "macro_sql": "{%- macro edr_cast_as_float(column) -%}\n cast({{ column }} as {{ elementary.edr_type_float() }})\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_float" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.148606, + "supported_languages": null + }, + "macro.elementary.edr_cast_as_numeric": { + "name": "edr_cast_as_numeric", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.edr_cast_as_numeric", + "macro_sql": "{%- macro edr_cast_as_numeric(column) -%}\n cast({{ column }} as {{ elementary.edr_type_numeric() }})\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_numeric" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.148736, + "supported_languages": null + }, + "macro.elementary.edr_cast_as_int": { + "name": "edr_cast_as_int", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.edr_cast_as_int", + "macro_sql": "{%- macro edr_cast_as_int(column) -%}\n cast({{ column }} as {{ elementary.edr_type_int() }})\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_int" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.148869, + "supported_languages": null + }, + "macro.elementary.edr_cast_as_string": { + "name": "edr_cast_as_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.edr_cast_as_string", + "macro_sql": "{%- macro edr_cast_as_string(column) -%}\n cast({{ column }} as {{ elementary.edr_type_string() }})\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.149007, + "supported_languages": null + }, + "macro.elementary.edr_cast_as_long_string": { + "name": "edr_cast_as_long_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.edr_cast_as_long_string", + "macro_sql": "{%- macro edr_cast_as_long_string(column) -%}\n cast({{ column }} as {{ elementary.edr_type_long_string() }})\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_long_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.149204, + "supported_languages": null + }, + "macro.elementary.edr_cast_as_bool": { + "name": "edr_cast_as_bool", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.edr_cast_as_bool", + "macro_sql": "{%- macro edr_cast_as_bool(column) -%}\n cast({{ column }} as {{ elementary.edr_type_bool() }})\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_bool" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.149338, + "supported_languages": null + }, + "macro.elementary.const_as_string": { + "name": "const_as_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.const_as_string", + "macro_sql": "{%- macro const_as_string(string) -%}\n cast('{{ string }}' as {{ elementary.edr_type_string() }})\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1494699, + "supported_languages": null + }, + "macro.elementary.edr_cast_as_date": { + "name": "edr_cast_as_date", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.edr_cast_as_date", + "macro_sql": "{%- macro edr_cast_as_date(timestamp_field) -%}\n {{ return(adapter.dispatch('edr_cast_as_date', 'elementary')(timestamp_field)) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_cast_as_date" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.149638, + "supported_languages": null + }, + "macro.elementary.default__edr_cast_as_date": { + "name": "default__edr_cast_as_date", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.default__edr_cast_as_date", + "macro_sql": "{%- macro default__edr_cast_as_date(timestamp_field) -%}\n cast({{ timestamp_field }} as {{ elementary.edr_type_date() }})\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_date" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.149772, + "supported_languages": null + }, + "macro.elementary.bigquery__edr_cast_as_date": { + "name": "bigquery__edr_cast_as_date", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.bigquery__edr_cast_as_date", + "macro_sql": "\n{%- macro bigquery__edr_cast_as_date(timestamp_field) -%}\n cast({{ elementary.edr_cast_as_timestamp(timestamp_field) }} as {{ elementary.edr_type_date() }})\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.edr_type_date" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.149937, + "supported_languages": null + }, + "macro.elementary.athena__edr_cast_as_date": { + "name": "athena__edr_cast_as_date", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.athena__edr_cast_as_date", + "macro_sql": "\n{%- macro athena__edr_cast_as_date(timestamp_field) -%}\n coalesce(\n try_cast({{ timestamp_field }} as {{ elementary.edr_type_date() }}),\n cast(from_iso8601_timestamp(cast({{ timestamp_field }} AS {{ elementary.edr_type_string() }})) AS {{ elementary.edr_type_date() }})\n )\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_date", + "macro.elementary.edr_type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1501691, + "supported_languages": null + }, + "macro.elementary.const_as_text": { + "name": "const_as_text", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.const_as_text", + "macro_sql": "{%- macro const_as_text(string) -%}\n {{ return(adapter.dispatch('const_as_text', 'elementary')(string)) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.default__const_as_text" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.150343, + "supported_languages": null + }, + "macro.elementary.default__const_as_text": { + "name": "default__const_as_text", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.default__const_as_text", + "macro_sql": "{%- macro default__const_as_text(string) -%}\n {{ elementary.const_as_string(string) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.const_as_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1504588, + "supported_languages": null + }, + "macro.elementary.redshift__const_as_text": { + "name": "redshift__const_as_text", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/cast_column.sql", + "original_file_path": "macros/utils/data_types/cast_column.sql", + "unique_id": "macro.elementary.redshift__const_as_text", + "macro_sql": "{%- macro redshift__const_as_text(string) -%}\n '{{ string }}'::text\n{%- endmacro -%}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1505542, + "supported_languages": null + }, + "macro.elementary.is_column_timestamp": { + "name": "is_column_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/is_column_timestamp.sql", + "original_file_path": "macros/utils/data_types/is_column_timestamp.sql", + "unique_id": "macro.elementary.is_column_timestamp", + "macro_sql": "{% macro is_column_timestamp(table_relation,timestamp_column,timestamp_column_data_type) %}\n {%- if timestamp_column_data_type == 'string' %}\n {%- set is_timestamp = elementary.try_cast_column_to_timestamp(table_relation, timestamp_column) %}\n {%- elif timestamp_column_data_type == 'timestamp' %}\n {%- set is_timestamp = true %}\n {%- else %}\n {%- set is_timestamp = false %}\n {%- endif %}\n {{ return(is_timestamp) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.try_cast_column_to_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1510558, + "supported_languages": null + }, + "macro.elementary.is_primitive": { + "name": "is_primitive", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.is_primitive", + "macro_sql": "{% macro is_primitive(val) %}\n {% do return (\n val is none or\n val is boolean or\n val is number or\n val is string\n ) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.153555, + "supported_languages": null + }, + "macro.elementary.edr_type_bool": { + "name": "edr_type_bool", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.edr_type_bool", + "macro_sql": "\n\n{%- macro edr_type_bool() -%}\n {{ return(adapter.dispatch('edr_type_bool', 'elementary')()) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_type_bool" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.153715, + "supported_languages": null + }, + "macro.elementary.default__edr_type_bool": { + "name": "default__edr_type_bool", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.default__edr_type_bool", + "macro_sql": "{% macro default__edr_type_bool() %}\n {% do return(\"boolean\") %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1538339, + "supported_languages": null + }, + "macro.elementary.bigquery__edr_type_bool": { + "name": "bigquery__edr_type_bool", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.bigquery__edr_type_bool", + "macro_sql": "{% macro bigquery__edr_type_bool() %}\n {% do return(\"BOOL\") %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.153955, + "supported_languages": null + }, + "macro.elementary.edr_type_string": { + "name": "edr_type_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.edr_type_string", + "macro_sql": "\n\n\n{%- macro edr_type_string() -%}\n {{ return(adapter.dispatch('edr_type_string', 'elementary')()) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.snowflake__edr_type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.15411, + "supported_languages": null + }, + "macro.elementary.default__edr_type_string": { + "name": "default__edr_type_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.default__edr_type_string", + "macro_sql": "{% macro default__edr_type_string() %}\n {# Redshift #}\n {% do return(\"varchar(4096)\") %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.15424, + "supported_languages": null + }, + "macro.elementary.postgres__edr_type_string": { + "name": "postgres__edr_type_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.postgres__edr_type_string", + "macro_sql": "{% macro postgres__edr_type_string() %}\n {% if var(\"sync\", false) %}\n {% do return(\"text\") %}\n {% else %}\n {% do return(\"varchar(4096)\") %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.154508, + "supported_languages": null + }, + "macro.elementary.snowflake__edr_type_string": { + "name": "snowflake__edr_type_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.snowflake__edr_type_string", + "macro_sql": "{% macro snowflake__edr_type_string() %}\n {# Default max varchar size in Snowflake is 16MB #}\n {% do return(\"varchar\") %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.154638, + "supported_languages": null + }, + "macro.elementary.bigquery__edr_type_string": { + "name": "bigquery__edr_type_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.bigquery__edr_type_string", + "macro_sql": "{% macro bigquery__edr_type_string() %}\n {# Default max string size in Bigquery is 65K #}\n {% do return(\"string\") %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.154763, + "supported_languages": null + }, + "macro.elementary.spark__edr_type_string": { + "name": "spark__edr_type_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.spark__edr_type_string", + "macro_sql": "{% macro spark__edr_type_string() %}\n {% do return(\"string\") %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.154942, + "supported_languages": null + }, + "macro.elementary.athena__edr_type_string": { + "name": "athena__edr_type_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.athena__edr_type_string", + "macro_sql": "{% macro athena__edr_type_string() %}\n {% do return(\"varchar\") %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1550589, + "supported_languages": null + }, + "macro.elementary.edr_type_long_string": { + "name": "edr_type_long_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.edr_type_long_string", + "macro_sql": "\n\n\n\n\n{%- macro edr_type_long_string() -%}\n {{ return(adapter.dispatch('edr_type_long_string', 'elementary')()) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_type_long_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.155211, + "supported_languages": null + }, + "macro.elementary.default__edr_type_long_string": { + "name": "default__edr_type_long_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.default__edr_type_long_string", + "macro_sql": "{%- macro default__edr_type_long_string() -%}\n {# Snowflake, Bigquery, Databricks #}\n {% do return(elementary.edr_type_string()) %}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.155348, + "supported_languages": null + }, + "macro.elementary.redshift__edr_type_long_string": { + "name": "redshift__edr_type_long_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.redshift__edr_type_long_string", + "macro_sql": "{%- macro redshift__edr_type_long_string() -%}\n {% set long_string = 'varchar(' ~ elementary.get_config_var('long_string_size') ~ ')' %}\n {{ return(long_string) }}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.get_config_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.155551, + "supported_languages": null + }, + "macro.elementary.postgres__edr_type_long_string": { + "name": "postgres__edr_type_long_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.postgres__edr_type_long_string", + "macro_sql": "{%- macro postgres__edr_type_long_string() -%}\n {% set long_string = 'text' %}\n {{ return(long_string) }}\n{%- endmacro -%}\n\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1557, + "supported_languages": null + }, + "macro.elementary.edr_type_bigint": { + "name": "edr_type_bigint", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.edr_type_bigint", + "macro_sql": "{% macro edr_type_bigint() %}\n {% set macro = dbt.type_bigint or dbt_utils.type_bigint %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `type_bigint` macro.\") }}\n {% endif %}\n {{ return(macro()) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.155987, + "supported_languages": null + }, + "macro.elementary.edr_type_float": { + "name": "edr_type_float", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.edr_type_float", + "macro_sql": "{% macro edr_type_float() %}\n {% set macro = dbt.type_float or dbt_utils.type_float %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `type_float` macro.\") }}\n {% endif %}\n {{ return(macro()) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.156276, + "supported_languages": null + }, + "macro.elementary.edr_type_int": { + "name": "edr_type_int", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.edr_type_int", + "macro_sql": "{% macro edr_type_int() %}\n {% set macro = dbt.type_int or dbt_utils.type_int %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `type_int` macro.\") }}\n {% endif %}\n {{ return(macro()) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.156563, + "supported_languages": null + }, + "macro.elementary.edr_type_timestamp": { + "name": "edr_type_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.edr_type_timestamp", + "macro_sql": "{% macro edr_type_timestamp() %}\n {{ return(adapter.dispatch('edr_type_timestamp', 'elementary')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_type_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.156725, + "supported_languages": null + }, + "macro.elementary.default__edr_type_timestamp": { + "name": "default__edr_type_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.default__edr_type_timestamp", + "macro_sql": "{% macro default__edr_type_timestamp() %}\n {% set macro = dbt.type_timestamp or dbt_utils.type_timestamp %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `type_timestamp` macro.\") }}\n {% endif %}\n {{ return(macro()) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1570141, + "supported_languages": null + }, + "macro.elementary.edr_type_numeric": { + "name": "edr_type_numeric", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.edr_type_numeric", + "macro_sql": "{% macro edr_type_numeric() %}\n {% set macro = dbt.type_numeric or dbt_utils.type_numeric %}\n {% if not macro %}\n {{ exceptions.raise_compiler_error(\"Did not find a `type_numeric` macro.\") }}\n {% endif %}\n {{ return(macro()) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1573, + "supported_languages": null + }, + "macro.elementary.edr_type_date": { + "name": "edr_type_date", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.edr_type_date", + "macro_sql": "{% macro edr_type_date() %}\n {{ return(adapter.dispatch('edr_type_date', 'elementary')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_type_date" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.157465, + "supported_languages": null + }, + "macro.elementary.default__edr_type_date": { + "name": "default__edr_type_date", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.default__edr_type_date", + "macro_sql": "{% macro default__edr_type_date() %}\n date\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.157534, + "supported_languages": null + }, + "macro.elementary.athena__edr_type_timestamp": { + "name": "athena__edr_type_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_type.sql", + "original_file_path": "macros/utils/data_types/data_type.sql", + "unique_id": "macro.elementary.athena__edr_type_timestamp", + "macro_sql": "{% macro athena__edr_type_timestamp() %}\n {%- set config = model.get('config', {}) -%}\n {%- set table_type = config.get('table_type', 'hive') -%}\n {%- if table_type == 'iceberg' -%}\n timestamp(6)\n {%- else -%}\n timestamp\n {%- endif -%}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.157825, + "supported_languages": null + }, + "macro.elementary.get_column_size": { + "name": "get_column_size", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_size.sql", + "original_file_path": "macros/utils/data_types/data_size.sql", + "unique_id": "macro.elementary.get_column_size", + "macro_sql": "{% macro get_column_size() %}\n {{ return(adapter.dispatch('get_column_size', 'elementary')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.snowflake__get_column_size" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1582, + "supported_languages": null + }, + "macro.elementary.default__get_column_size": { + "name": "default__get_column_size", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_size.sql", + "original_file_path": "macros/utils/data_types/data_size.sql", + "unique_id": "macro.elementary.default__get_column_size", + "macro_sql": "{% macro default__get_column_size() %}\n {{ return(elementary.get_config_var('long_string_size')) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_config_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.158342, + "supported_languages": null + }, + "macro.elementary.postgres__get_column_size": { + "name": "postgres__get_column_size", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_size.sql", + "original_file_path": "macros/utils/data_types/data_size.sql", + "unique_id": "macro.elementary.postgres__get_column_size", + "macro_sql": "{% macro postgres__get_column_size() %}\n {{ return(none) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.158453, + "supported_languages": null + }, + "macro.elementary.snowflake__get_column_size": { + "name": "snowflake__get_column_size", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_size.sql", + "original_file_path": "macros/utils/data_types/data_size.sql", + "unique_id": "macro.elementary.snowflake__get_column_size", + "macro_sql": "{% macro snowflake__get_column_size() %}\n {{ return(16777216) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.158566, + "supported_languages": null + }, + "macro.elementary.bigquery__get_column_size": { + "name": "bigquery__get_column_size", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_size.sql", + "original_file_path": "macros/utils/data_types/data_size.sql", + "unique_id": "macro.elementary.bigquery__get_column_size", + "macro_sql": "{% macro bigquery__get_column_size() %}\n {{ return(10485760) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1586812, + "supported_languages": null + }, + "macro.elementary.redshift__get_column_size": { + "name": "redshift__get_column_size", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/data_size.sql", + "original_file_path": "macros/utils/data_types/data_size.sql", + "unique_id": "macro.elementary.redshift__get_column_size", + "macro_sql": "{% macro redshift__get_column_size() %}\n {{ return(65535) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1587908, + "supported_languages": null + }, + "macro.elementary.normalize_data_type": { + "name": "normalize_data_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/normalize_data_type.sql", + "original_file_path": "macros/utils/data_types/normalize_data_type.sql", + "unique_id": "macro.elementary.normalize_data_type", + "macro_sql": "{% macro normalize_data_type(data_type) %}\n\n {# In case data type has precision info - e.g. decimal is in the format decimal(p,s) #}\n {%- if '(' in data_type %}\n {%- set data_type = data_type.split('(')[0] %}\n {%- endif %}\n\n {%- if data_type is defined and data_type is not none %}\n {%- if data_type in elementary.data_type_list('string') %}\n {{ return('string') }}\n {%- elif data_type in elementary.data_type_list('numeric') %}\n {{ return('numeric') }}\n {%- elif data_type in elementary.data_type_list('timestamp') %}\n {{ return('timestamp') }}\n {%- else %}\n {{ return('other') }}\n {% endif %}\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.data_type_list" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.159914, + "supported_languages": null + }, + "macro.elementary.get_column_data_type": { + "name": "get_column_data_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/get_column_data_type.sql", + "original_file_path": "macros/utils/data_types/get_column_data_type.sql", + "unique_id": "macro.elementary.get_column_data_type", + "macro_sql": "{% macro get_column_data_type(column_relation) %}\n {% set data_type = adapter.dispatch('get_column_data_type','elementary')(column_relation) %}\n {{ return(data_type) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__get_column_data_type" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.160254, + "supported_languages": null + }, + "macro.elementary.default__get_column_data_type": { + "name": "default__get_column_data_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/get_column_data_type.sql", + "original_file_path": "macros/utils/data_types/get_column_data_type.sql", + "unique_id": "macro.elementary.default__get_column_data_type", + "macro_sql": "{% macro default__get_column_data_type(column_relation) %}\n {{return (column_relation[\"dtype\"]) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1603909, + "supported_languages": null + }, + "macro.elementary.bigquery__get_column_data_type": { + "name": "bigquery__get_column_data_type", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/get_column_data_type.sql", + "original_file_path": "macros/utils/data_types/get_column_data_type.sql", + "unique_id": "macro.elementary.bigquery__get_column_data_type", + "macro_sql": "{% macro bigquery__get_column_data_type(column_relation) %}\n {{return (column_relation[\"data_type\"]) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1605241, + "supported_languages": null + }, + "macro.elementary.null_int": { + "name": "null_int", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/null_as.sql", + "original_file_path": "macros/utils/data_types/null_as.sql", + "unique_id": "macro.elementary.null_int", + "macro_sql": "{%- macro null_int() -%}\n cast(null as {{ elementary.edr_type_int() }})\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_int" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1607628, + "supported_languages": null + }, + "macro.elementary.null_timestamp": { + "name": "null_timestamp", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/null_as.sql", + "original_file_path": "macros/utils/data_types/null_as.sql", + "unique_id": "macro.elementary.null_timestamp", + "macro_sql": "{%- macro null_timestamp() -%}\n cast(null as {{ elementary.edr_type_timestamp() }})\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_timestamp" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.160871, + "supported_languages": null + }, + "macro.elementary.null_float": { + "name": "null_float", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/null_as.sql", + "original_file_path": "macros/utils/data_types/null_as.sql", + "unique_id": "macro.elementary.null_float", + "macro_sql": "{%- macro null_float() -%}\n cast(null as {{ elementary.edr_type_float() }})\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_float" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.16098, + "supported_languages": null + }, + "macro.elementary.null_string": { + "name": "null_string", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/data_types/null_as.sql", + "original_file_path": "macros/utils/data_types/null_as.sql", + "unique_id": "macro.elementary.null_string", + "macro_sql": "{% macro null_string() %}\n cast(null as {{ elementary.edr_type_string() }})\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_type_string" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.161089, + "supported_languages": null + }, + "macro.elementary.undefined_dict_keys_to_none": { + "name": "undefined_dict_keys_to_none", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/dict_utils/undefined_dict_keys_to_none.sql", + "original_file_path": "macros/utils/dict_utils/undefined_dict_keys_to_none.sql", + "unique_id": "macro.elementary.undefined_dict_keys_to_none", + "macro_sql": "{% macro undefined_dict_keys_to_none(dict) %}\n {% for key in dict %}\n {% if dict[key] is not defined %}\n {% do dict.update({key: none}) %}\n {% endif %}\n {% endfor %}\n {{ return(dict) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.161509, + "supported_languages": null + }, + "macro.elementary.insensitive_get_dict_value": { + "name": "insensitive_get_dict_value", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/dict_utils/insensitive_get_dict_value.sql", + "original_file_path": "macros/utils/dict_utils/insensitive_get_dict_value.sql", + "unique_id": "macro.elementary.insensitive_get_dict_value", + "macro_sql": "{% macro insensitive_get_dict_value(dict, key, default) -%}\n {% set value = elementary.safe_get_with_default(dict, key) %}\n {%- if value is not none -%}\n {{- return(value) -}}\n {%- endif %}\n {% set value = elementary.safe_get_with_default(dict, key.lower()) %}\n {%- if value is not none -%}\n {{- return(value) -}}\n {%- endif %}\n {% set value = elementary.safe_get_with_default(dict, key.upper()) %}\n {%- if value is not none -%}\n {{- return(value) -}}\n {%- endif %}\n {%- if default is defined -%}\n {{- return(default) -}}\n {% else %}\n {{ return(none) }}\n {% endif %}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.safe_get_with_default" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1625159, + "supported_languages": null + }, + "macro.elementary.safe_get_with_default": { + "name": "safe_get_with_default", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/dict_utils/safe_get_with_default_value.sql", + "original_file_path": "macros/utils/dict_utils/safe_get_with_default_value.sql", + "unique_id": "macro.elementary.safe_get_with_default", + "macro_sql": "{% macro safe_get_with_default(dict, key, default) %}\n {% set value = dict.get(key) %}\n {% if value is defined and value is not none %}\n {{ return(value) }}\n {% endif %}\n {% if default is defined %}\n {{ return(default) }}\n {% endif %}\n {{ return(none) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.163039, + "supported_languages": null + }, + "macro.elementary.get_node_execution_id": { + "name": "get_node_execution_id", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_node_execution_id.sql", + "original_file_path": "macros/utils/graph/get_node_execution_id.sql", + "unique_id": "macro.elementary.get_node_execution_id", + "macro_sql": "{% macro get_node_execution_id(node) %}\n {% set node_execution_id = [invocation_id, node.get('unique_id')] | join('.') %}\n {{ return(node_execution_id) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1633291, + "supported_languages": null + }, + "macro.elementary.get_compiled_code": { + "name": "get_compiled_code", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_compiled_code.sql", + "original_file_path": "macros/utils/graph/get_compiled_code.sql", + "unique_id": "macro.elementary.get_compiled_code", + "macro_sql": "{% macro get_compiled_code(node, as_column_value=false) %}\n {% set compiled_code = adapter.dispatch(\"get_compiled_code\", \"elementary\")(node) %}\n \n {% set max_column_size = elementary.get_column_size() %}\n {% if as_column_value and max_column_size and compiled_code and compiled_code | length > max_column_size %}\n {% do return(elementary.get_compiled_code_too_long_err_msg()) %}\n {% endif %}\n \n {% do return(compiled_code) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__get_compiled_code", + "macro.elementary.get_column_size", + "macro.elementary.get_compiled_code_too_long_err_msg" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.164165, + "supported_languages": null + }, + "macro.elementary.default__get_compiled_code": { + "name": "default__get_compiled_code", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_compiled_code.sql", + "original_file_path": "macros/utils/graph/get_compiled_code.sql", + "unique_id": "macro.elementary.default__get_compiled_code", + "macro_sql": "{% macro default__get_compiled_code(node) %}\n {% do return(node.get('compiled_code') or node.get('compiled_sql')) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.164366, + "supported_languages": null + }, + "macro.elementary.redshift__get_compiled_code": { + "name": "redshift__get_compiled_code", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_compiled_code.sql", + "original_file_path": "macros/utils/graph/get_compiled_code.sql", + "unique_id": "macro.elementary.redshift__get_compiled_code", + "macro_sql": "{% macro redshift__get_compiled_code(node) %}\n {% set compiled_code = node.get('compiled_code') or node.get('compiled_sql') %}\n {% if not compiled_code %}\n {% do return(none) %}\n {% else %}\n {% do return(compiled_code.replace(\"%\", \"%%\")) %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.replace" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.164756, + "supported_languages": null + }, + "macro.elementary.get_compiled_code_too_long_err_msg": { + "name": "get_compiled_code_too_long_err_msg", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_compiled_code.sql", + "original_file_path": "macros/utils/graph/get_compiled_code.sql", + "unique_id": "macro.elementary.get_compiled_code_too_long_err_msg", + "macro_sql": "{% macro get_compiled_code_too_long_err_msg() %}\n {% do return(\"Compiled code is too long.\") %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.164889, + "supported_languages": null + }, + "macro.elementary.get_node": { + "name": "get_node", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_node.sql", + "original_file_path": "macros/utils/graph/get_node.sql", + "unique_id": "macro.elementary.get_node", + "macro_sql": "{% macro get_node(node_unique_id) %}\n {# First let's try to find it in regular nodes #}\n {%- set node = graph.nodes.get(node_unique_id) -%}\n {%- if not node -%}\n {# If not found let's try to find it in source nodes #}\n {%- set node = graph.sources.get(node_unique_id) -%}\n {%- endif -%}\n {{ return(node) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.165271, + "supported_languages": null + }, + "macro.elementary.get_elementary_config_from_node": { + "name": "get_elementary_config_from_node", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_elementary_config_from_node.sql", + "original_file_path": "macros/utils/graph/get_elementary_config_from_node.sql", + "unique_id": "macro.elementary.get_elementary_config_from_node", + "macro_sql": "{% macro get_elementary_config_from_node(node) %}\n {% set res = {} %}\n {% set node_config = node.get('config') %}\n {% if node_config %}\n {% set elementary_config = node.config.get('elementary') %}\n {% if elementary_config and elementary_config is mapping %}\n {% do res.update(elementary_config) %}\n {% endif %}\n {% set config_meta = node.config.get('meta') %}\n {% if config_meta and config_meta is mapping %}\n {% set elementary_config = config_meta.get('elementary') %}\n {% if elementary_config and elementary_config is mapping %}\n {% do res.update(elementary_config) %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% set node_meta = node.get('meta') %}\n {% if node_meta and node_meta is mapping %}\n {% set elementary_config = node_meta.get('elementary') %}\n {% if elementary_config and elementary_config is mapping %}\n {% do res.update(elementary_config) %}\n {% endif %}\n {% endif %}\n {{ return(res) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.166986, + "supported_languages": null + }, + "macro.elementary.get_cache": { + "name": "get_cache", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_cache.sql", + "original_file_path": "macros/utils/graph/get_cache.sql", + "unique_id": "macro.elementary.get_cache", + "macro_sql": "{% macro get_cache(entry, default=none) %}\n {% if execute %}\n {{ return(graph.get(\"elementary\", {}).get(entry, default)) }}\n {% endif %}\n {{ return(none) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1673641, + "supported_languages": null + }, + "macro.elementary.get_nodes_from_graph": { + "name": "get_nodes_from_graph", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_nodes_from_graph.sql", + "original_file_path": "macros/utils/graph/get_nodes_from_graph.sql", + "unique_id": "macro.elementary.get_nodes_from_graph", + "macro_sql": "{% macro get_nodes_from_graph() %}\n {% set nodes = [] %}\n {% do nodes.extend(graph.sources.values()) %}\n {% do nodes.extend(graph.nodes.values()) %}\n {{ return(nodes) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.167733, + "supported_languages": null + }, + "macro.elementary.is_ephemeral_model": { + "name": "is_ephemeral_model", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/is_ephemeral_model.sql", + "original_file_path": "macros/utils/graph/is_ephemeral_model.sql", + "unique_id": "macro.elementary.is_ephemeral_model", + "macro_sql": "{% macro is_ephemeral_model(model_relation) %}\n {% do return(\n model_relation.is_cte\n ) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.167902, + "supported_languages": null + }, + "macro.elementary.get_package_database_and_schema": { + "name": "get_package_database_and_schema", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_package_database_and_schema.sql", + "original_file_path": "macros/utils/graph/get_package_database_and_schema.sql", + "unique_id": "macro.elementary.get_package_database_and_schema", + "macro_sql": "{% macro get_package_database_and_schema(package_name='elementary') %}\n {% if execute %}\n {% set node_in_package = graph.nodes.values()\n | selectattr(\"resource_type\", \"==\", \"model\")\n | selectattr(\"package_name\", \"==\", package_name) | first %}\n {% if node_in_package %}\n {{ return([node_in_package.database, node_in_package.schema]) }}\n {% endif %}\n {% endif %}\n {{ return([none, none]) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.168567, + "supported_languages": null + }, + "macro.elementary.get_parent_model_unique_ids_from_test_node": { + "name": "get_parent_model_unique_ids_from_test_node", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_parent_model_unique_ids_from_test_node.sql", + "original_file_path": "macros/utils/graph/get_parent_model_unique_ids_from_test_node.sql", + "unique_id": "macro.elementary.get_parent_model_unique_ids_from_test_node", + "macro_sql": "{% macro get_parent_model_unique_ids_from_test_node(test_node) %}\n {% set nodes_in_current_package = [] %}\n {% set test_depends_on = test_node.get('depends_on') %}\n {% if test_depends_on %}\n {% set depends_on_nodes = test_depends_on.get('nodes') %}\n {% if depends_on_nodes %}\n {% set current_package_name = test_node.get('package_name') %}\n {% if current_package_name %}\n {% set current_package_name = '.' ~ current_package_name ~ '.' %}\n {% for node in depends_on_nodes %}\n {% if current_package_name in node %}\n {% do nodes_in_current_package.append(node) %}\n {% endif %}\n {% endfor %}\n {% endif %}\n {% endif %}\n {% endif %}\n {{ return(nodes_in_current_package) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.169805, + "supported_languages": null + }, + "macro.elementary.get_nodes_by_unique_ids": { + "name": "get_nodes_by_unique_ids", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_nodes_by_unique_ids.sql", + "original_file_path": "macros/utils/graph/get_nodes_by_unique_ids.sql", + "unique_id": "macro.elementary.get_nodes_by_unique_ids", + "macro_sql": "{% macro get_nodes_by_unique_ids(unique_ids) %}\n {% set nodes = []%}\n {% if execute %}\n {% if unique_ids and unique_ids is iterable %}\n {% for unique_id in unique_ids %}\n {% set node = elementary.get_node(unique_id) %}\n {% if node %}\n {% do nodes.append(node) %}\n {% endif %}\n {% endfor %}\n {% endif %}\n {% endif %}\n {{ return(nodes) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_node" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.170538, + "supported_languages": null + }, + "macro.elementary.get_table_name_from_node": { + "name": "get_table_name_from_node", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_table_name_from_node.sql", + "original_file_path": "macros/utils/graph/get_table_name_from_node.sql", + "unique_id": "macro.elementary.get_table_name_from_node", + "macro_sql": "{% macro get_table_name_from_node(node) %}\n {% if node.identifier %}\n {% set table_name = node.identifier %}\n {% elif node.alias %}\n {% set table_name = node.alias %}\n {% else %}\n {% set table_name = node.name %}\n {% endif %}\n {{ return(table_name) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1710122, + "supported_languages": null + }, + "macro.elementary.column_exists_in_relation": { + "name": "column_exists_in_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/column_exists_in_relation.sql", + "original_file_path": "macros/utils/graph/column_exists_in_relation.sql", + "unique_id": "macro.elementary.column_exists_in_relation", + "macro_sql": "{% macro column_exists_in_relation(relation, column_name) %}\n {% set columns = adapter.get_columns_in_relation(relation) %}\n {% for column in columns %}\n {% if column.name.lower() == column_name.lower() %}\n {% do return(true) %}\n {% endif %}\n {% endfor %}\n {% do return(false) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.171509, + "supported_languages": null + }, + "macro.elementary.get_relation_from_node": { + "name": "get_relation_from_node", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_relation_from_node.sql", + "original_file_path": "macros/utils/graph/get_relation_from_node.sql", + "unique_id": "macro.elementary.get_relation_from_node", + "macro_sql": "{% macro get_relation_from_node(node) %}\n {% do return(adapter.get_relation(database=node.database,\n schema=node.schema,\n identifier=elementary.get_table_name_from_node(node))) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_table_name_from_node" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.171815, + "supported_languages": null + }, + "macro.elementary.get_node_by_name": { + "name": "get_node_by_name", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_node_by_name.sql", + "original_file_path": "macros/utils/graph/get_node_by_name.sql", + "unique_id": "macro.elementary.get_node_by_name", + "macro_sql": "{% macro get_node_by_name(name) %}\n {%- set nodes = elementary.get_nodes_from_graph() -%}\n {% for node in nodes %}\n {% if node.name == name %}\n {% do return(node) %}\n {% endif %}\n {% endfor %}\n {{ return(none) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_nodes_from_graph" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.172251, + "supported_languages": null + }, + "macro.elementary.get_elementary_relation": { + "name": "get_elementary_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_elementary_relation.sql", + "original_file_path": "macros/utils/graph/get_elementary_relation.sql", + "unique_id": "macro.elementary.get_elementary_relation", + "macro_sql": "{% macro get_elementary_relation(identifier) %}\n {%- if execute %}\n {%- set identifier_node = elementary.get_node('model.elementary.' ~ identifier) %}\n {%- if identifier_node -%}\n {%- set identifier_alias = elementary.safe_get_with_default(identifier_node, 'alias', identifier) %}\n {% set elementary_database, elementary_schema = identifier_node.database, identifier_node.schema %}\n {%- else -%}\n {% set identifier_alias = identifier %}\n {% set elementary_database, elementary_schema = elementary.get_package_database_and_schema() %}\n {%- endif -%}\n {% if this and this.database == elementary_database and this.schema == elementary_schema and this.identifier == identifier_alias %}\n {% do return(this) %}\n {% endif %}\n {% do return(adapter.get_relation(elementary_database, elementary_schema, identifier_alias)) %}\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_node", + "macro.elementary.safe_get_with_default", + "macro.elementary.get_package_database_and_schema" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1733172, + "supported_languages": null + }, + "macro.elementary.is_incremental_model": { + "name": "is_incremental_model", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/is_incremental_model.sql", + "original_file_path": "macros/utils/graph/is_incremental_model.sql", + "unique_id": "macro.elementary.is_incremental_model", + "macro_sql": "{% macro is_incremental_model(model_node, source_included=false) %}\n {% do return(\n (source_included and model_node.resource_type == \"source\")\n or\n (model_node.resource_type == \"model\" and model_node.config.materialized == \"incremental\")\n ) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1736588, + "supported_languages": null + }, + "macro.elementary.get_result_node": { + "name": "get_result_node", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_result_node.sql", + "original_file_path": "macros/utils/graph/get_result_node.sql", + "unique_id": "macro.elementary.get_result_node", + "macro_sql": "{% macro get_result_node(identifier, package_name='elementary') %}\n {% for result in results %}\n {% if result.node.identifier == identifier %}\n {% if package_name %}\n {% if result.node.package_name == package_name %}\n {{ return(result.node) }}\n {% endif %}\n {% else %}\n {{ return(result.node) }}\n {% endif %}\n {% endif %}\n {% endfor %}\n {{ return(none) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.174316, + "supported_languages": null + }, + "macro.elementary.set_cache": { + "name": "set_cache", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/set_cache.sql", + "original_file_path": "macros/utils/graph/set_cache.sql", + "unique_id": "macro.elementary.set_cache", + "macro_sql": "{% macro set_cache(entry, val) %}\n {% if execute %}\n {% do graph.get(\"elementary\", {}).update({entry: val}) %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1746292, + "supported_languages": null + }, + "macro.elementary.get_rendered_ref": { + "name": "get_rendered_ref", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_rendered_ref.sql", + "original_file_path": "macros/utils/graph/get_rendered_ref.sql", + "unique_id": "macro.elementary.get_rendered_ref", + "macro_sql": "{% macro get_rendered_ref(ref_string) %}\n {% set lowered_ref_string = ref_string | lower %}\n {% set match = modules.re.match(\"(ref\\('(?P.+)'\\))\", lowered_ref_string, modules.re.IGNORECASE) %}\n {% if not match %}\n {% do return(lowered_ref_string) %}\n {% else %}\n {% do return(ref(match.groupdict()['ref_identifier'])['include']()) %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.17524, + "supported_languages": null + }, + "macro.elementary.get_model_database_and_schema_from_test_node": { + "name": "get_model_database_and_schema_from_test_node", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/graph/get_model_database_and_schema_from_test_node.sql", + "original_file_path": "macros/utils/graph/get_model_database_and_schema_from_test_node.sql", + "unique_id": "macro.elementary.get_model_database_and_schema_from_test_node", + "macro_sql": "{% macro get_model_database_and_schema_from_test_node(test_node) %}\n {% set test_database = test_node.get('database') %}\n {% set test_schema = test_node.get('schema') %}\n {% set config_dict = elementary.safe_get_with_default(test_node, 'config', {}) %}\n {% set test_schema_sufix = config_dict.get('schema') %}\n {% if test_schema and test_schema_sufix %}\n {% set test_schema = test_schema | replace('_' ~ test_schema_sufix, '') %}\n {% endif %}\n {{ return([test_database, test_schema]) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.safe_get_with_default" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.175963, + "supported_languages": null + }, + "macro.elementary.union_macro_queries": { + "name": "union_macro_queries", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/run_queries/union_macro_queries.sql", + "original_file_path": "macros/utils/run_queries/union_macro_queries.sql", + "unique_id": "macro.elementary.union_macro_queries", + "macro_sql": "{% macro union_macro_queries(param_list, query_macro) %}\n {% for param in param_list %}\n ({{ query_macro(param) }})\n {% if not loop.last %}\n union all\n {% endif %}\n {% endfor %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.176291, + "supported_languages": null + }, + "macro.elementary.render_run_query": { + "name": "render_run_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/run_queries/render_run_query.sql", + "original_file_path": "macros/utils/run_queries/render_run_query.sql", + "unique_id": "macro.elementary.render_run_query", + "macro_sql": "{% macro render_run_query(prerendered_query) %}\n {% set results = elementary.run_query(render(prerendered_query)) %}\n {% do return(elementary.agate_to_dicts(results)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query", + "macro.elementary.agate_to_dicts" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.176568, + "supported_languages": null + }, + "macro.elementary.agate_to_json": { + "name": "agate_to_json", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/run_queries/agate_to_json.sql", + "original_file_path": "macros/utils/run_queries/agate_to_json.sql", + "unique_id": "macro.elementary.agate_to_json", + "macro_sql": "{% macro agate_to_json(agate_table) %}\n {% set serializable_rows = elementary.agate_to_dicts(agate_table) %}\n {{ return(tojson(serializable_rows)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.agate_to_dicts" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.176817, + "supported_languages": null + }, + "macro.elementary.result_column_to_list": { + "name": "result_column_to_list", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/run_queries/result_column_to_list.sql", + "original_file_path": "macros/utils/run_queries/result_column_to_list.sql", + "unique_id": "macro.elementary.result_column_to_list", + "macro_sql": "{% macro result_column_to_list(single_column_query) %}\n {% set query_result = elementary.run_query(single_column_query) %}\n {% do return(query_result.columns[0]) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.177147, + "supported_languages": null + }, + "macro.elementary.result_value": { + "name": "result_value", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/run_queries/result_value.sql", + "original_file_path": "macros/utils/run_queries/result_value.sql", + "unique_id": "macro.elementary.result_value", + "macro_sql": "{% macro result_value(single_column_query) %}\n {% set result = elementary.run_query(single_column_query) %}\n {% if not result %}\n {% do return(none) %}\n {% endif %}\n {% do return(result[0][0]) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.17754, + "supported_languages": null + }, + "macro.elementary.agate_to_dicts": { + "name": "agate_to_dicts", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/run_queries/agate_to_dicts.sql", + "original_file_path": "macros/utils/run_queries/agate_to_dicts.sql", + "unique_id": "macro.elementary.agate_to_dicts", + "macro_sql": "{% macro agate_to_dicts(agate_table) %}\n {% set column_types = agate_table.column_types %}\n {% set serializable_rows = [] %}\n {% for agate_row in agate_table.rows %}\n {% set serializable_row = {} %}\n {% for col_name, col_value in agate_row.items() %}\n {% set serializable_col_value = column_types[loop.index0].jsonify(col_value) %}\n {% set serializable_col_name = col_name | lower %}\n {% do serializable_row.update({serializable_col_name: serializable_col_value}) %}\n {% endfor %}\n {% do serializable_rows.append(serializable_row) %}\n {% endfor %}\n {{ return(serializable_rows) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.178485, + "supported_languages": null + }, + "macro.elementary.run_query": { + "name": "run_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/run_queries/run_query.sql", + "original_file_path": "macros/utils/run_queries/run_query.sql", + "unique_id": "macro.elementary.run_query", + "macro_sql": "{% macro run_query(query, lowercase_column_names=True) %}\n {% set query_result = dbt.run_query(query) %}\n {% if lowercase_column_names %}\n {% set lowercased_column_names = {} %}\n {% for column_name in query_result.column_names %}\n {% do lowercased_column_names.update({column_name: column_name.lower()}) %}\n {% endfor %}\n {% set query_result = query_result.rename(lowercased_column_names) %}\n {% endif %}\n\n {% do return(query_result) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.179224, + "supported_languages": null + }, + "macro.elementary.create_table_like": { + "name": "create_table_like", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/create_table_like.sql", + "original_file_path": "macros/utils/table_operations/create_table_like.sql", + "unique_id": "macro.elementary.create_table_like", + "macro_sql": "{% macro create_table_like(relation, like_relation, temporary=False, like_columns=none) %}\n {% set empty_table_query %}\n SELECT\n {% if like_columns %}\n {% for column in like_columns %}\n {{ column }}{{ \", \" if not loop.last }}\n {% endfor %}\n {% else %}\n *\n {% endif %}\n FROM {{ like_relation }}\n WHERE 1 = 0\n {% endset %}\n {% do elementary.run_query(dbt.create_table_as(temporary, relation, empty_table_query)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query", + "macro.dbt.create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.179924, + "supported_languages": null + }, + "macro.elementary.delete_if_incremental": { + "name": "delete_if_incremental", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/delete_if_incremental.sql", + "original_file_path": "macros/utils/table_operations/delete_if_incremental.sql", + "unique_id": "macro.elementary.delete_if_incremental", + "macro_sql": "{% macro delete_if_incremental(where_clause) %}\n\n {% set query%}\n delete from {{ this }}\n where {{ where_clause }}\n {% endset %}\n\n {% if is_incremental() %}\n {% do elementary.run_query(query) %}\n {% endif %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.is_incremental", + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.180297, + "supported_languages": null + }, + "macro.elementary.remove_rows": { + "name": "remove_rows", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/remove_rows.sql", + "original_file_path": "macros/utils/table_operations/remove_rows.sql", + "unique_id": "macro.elementary.remove_rows", + "macro_sql": "{% macro remove_rows(table_name) %}\n\n {% set remove_rows_query %}\n delete from {{ table_name }}\n {% endset %}\n {% do elementary.run_query(remove_rows_query) %}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.180555, + "supported_languages": null + }, + "macro.elementary.has_temp_table_support": { + "name": "has_temp_table_support", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/has_temp_table_support.sql", + "original_file_path": "macros/utils/table_operations/has_temp_table_support.sql", + "unique_id": "macro.elementary.has_temp_table_support", + "macro_sql": "{% macro has_temp_table_support() %}\n {% do return(adapter.dispatch(\"has_temp_table_support\", \"elementary\")()) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__has_temp_table_support" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1808221, + "supported_languages": null + }, + "macro.elementary.default__has_temp_table_support": { + "name": "default__has_temp_table_support", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/has_temp_table_support.sql", + "original_file_path": "macros/utils/table_operations/has_temp_table_support.sql", + "unique_id": "macro.elementary.default__has_temp_table_support", + "macro_sql": "{% macro default__has_temp_table_support() %}\n {% do return(true) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.180949, + "supported_languages": null + }, + "macro.elementary.spark__has_temp_table_support": { + "name": "spark__has_temp_table_support", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/has_temp_table_support.sql", + "original_file_path": "macros/utils/table_operations/has_temp_table_support.sql", + "unique_id": "macro.elementary.spark__has_temp_table_support", + "macro_sql": "{% macro spark__has_temp_table_support() %}\n {% do return(false) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.181073, + "supported_languages": null + }, + "macro.elementary.get_columns_and_types": { + "name": "get_columns_and_types", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/get_columns_and_types.sql", + "original_file_path": "macros/utils/table_operations/get_columns_and_types.sql", + "unique_id": "macro.elementary.get_columns_and_types", + "macro_sql": "{% macro get_columns_and_types(table_name, schema_name = none, database_name = none) %}\n\n {# dbt models can be found with identifier only #}\n {# for non-dbt tables database_name and schema_name are required #}\n\n {%- if not database_name %}\n {%- set database_name = elementary.target_database() %}\n {%- endif %}\n {%- if not schema_name %}\n {%- set schema_name = target.schema %}\n {%- endif %}\n\n {%- set columns = [] %}\n\n {%- set relation = adapter.get_relation(\n database=database_name,\n schema=schema_name,\n identifier=table_name) -%}\n\n {%- set columns_from_relation = adapter.get_columns_in_relation(relation) -%}\n\n {% for column in columns_from_relation %}\n {%- set column_item = {'column_name': column['column'], 'data_type': elementary.normalize_data_type(elementary.get_column_data_type(column))} %}\n {%- do columns.append(column_item) -%}\n {% endfor %}\n\n {{ return(columns) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.target_database", + "macro.elementary.normalize_data_type", + "macro.elementary.get_column_data_type" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.182281, + "supported_languages": null + }, + "macro.elementary.create_temp_table": { + "name": "create_temp_table", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/create_temp_table.sql", + "original_file_path": "macros/utils/table_operations/create_temp_table.sql", + "unique_id": "macro.elementary.create_temp_table", + "macro_sql": "{% macro create_temp_table(database_name, schema_name, table_name, sql_query) %}\n {% set temp_table_exists, temp_table_relation = dbt.get_or_create_relation(database=database_name,\n schema=schema_name,\n identifier=table_name,\n type='table') -%}\n {% set temp_table_relation = elementary.edr_make_temp_relation(temp_table_relation) %}\n {% if temp_table_exists %}\n {% do adapter.drop_relation(temp_table_relation) %}\n {% do elementary.run_query(dbt.create_table_as(True, temp_table_relation, sql_query)) %}\n {% else %}\n {% do elementary.run_query(dbt.create_table_as(True, temp_table_relation, sql_query)) %}\n {% endif %}\n {{ return(temp_table_relation) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.get_or_create_relation", + "macro.elementary.edr_make_temp_relation", + "macro.elementary.run_query", + "macro.dbt.create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.183317, + "supported_languages": null + }, + "macro.elementary.edr_make_temp_relation": { + "name": "edr_make_temp_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/make_temp_relation.sql", + "original_file_path": "macros/utils/table_operations/make_temp_relation.sql", + "unique_id": "macro.elementary.edr_make_temp_relation", + "macro_sql": "{% macro edr_make_temp_relation(base_relation, suffix=none) %}\n {% do return(adapter.dispatch(\"edr_make_temp_relation\", \"elementary\")(base_relation, suffix)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__edr_make_temp_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.184659, + "supported_languages": null + }, + "macro.elementary.default__edr_make_temp_relation": { + "name": "default__edr_make_temp_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/make_temp_relation.sql", + "original_file_path": "macros/utils/table_operations/make_temp_relation.sql", + "unique_id": "macro.elementary.default__edr_make_temp_relation", + "macro_sql": "{% macro default__edr_make_temp_relation(base_relation, suffix) %}\n {% do return(dbt.make_temp_relation(base_relation, suffix)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.make_temp_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.184843, + "supported_languages": null + }, + "macro.elementary.spark__edr_make_temp_relation": { + "name": "spark__edr_make_temp_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/make_temp_relation.sql", + "original_file_path": "macros/utils/table_operations/make_temp_relation.sql", + "unique_id": "macro.elementary.spark__edr_make_temp_relation", + "macro_sql": "{% macro spark__edr_make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = elementary.table_name_with_suffix(base_relation.identifier, suffix) %}\n {% set tmp_relation = base_relation.incorporate(path = {\n \"schema\": none,\n \"identifier\": tmp_identifier\n }) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.table_name_with_suffix" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.185215, + "supported_languages": null + }, + "macro.elementary.databricks__edr_make_temp_relation": { + "name": "databricks__edr_make_temp_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/make_temp_relation.sql", + "original_file_path": "macros/utils/table_operations/make_temp_relation.sql", + "unique_id": "macro.elementary.databricks__edr_make_temp_relation", + "macro_sql": "{% macro databricks__edr_make_temp_relation(base_relation, suffix) %}\n {% do return(dbt.make_temp_relation(base_relation, suffix)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.make_temp_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.185399, + "supported_languages": null + }, + "macro.elementary.make_temp_view_relation": { + "name": "make_temp_view_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/make_temp_relation.sql", + "original_file_path": "macros/utils/table_operations/make_temp_relation.sql", + "unique_id": "macro.elementary.make_temp_view_relation", + "macro_sql": "{% macro make_temp_view_relation(base_relation, suffix=none) %}\n {% if not suffix %}\n {% set suffix = elementary.get_timestamped_table_suffix() %}\n {% endif %}\n\n {% do return(elementary.edr_make_temp_relation(base_relation, suffix)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_timestamped_table_suffix", + "macro.elementary.edr_make_temp_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1856918, + "supported_languages": null + }, + "macro.elementary.make_temp_table_relation": { + "name": "make_temp_table_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/make_temp_relation.sql", + "original_file_path": "macros/utils/table_operations/make_temp_relation.sql", + "unique_id": "macro.elementary.make_temp_table_relation", + "macro_sql": "{% macro make_temp_table_relation(base_relation, suffix=none) %}\n {% if not suffix %}\n {% set suffix = elementary.get_timestamped_table_suffix() %}\n {% endif %}\n\n {% do return(adapter.dispatch(\"make_temp_table_relation\", \"elementary\")(base_relation, suffix)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_timestamped_table_suffix", + "macro.elementary.default__make_temp_table_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1861, + "supported_languages": null + }, + "macro.elementary.default__make_temp_table_relation": { + "name": "default__make_temp_table_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/make_temp_relation.sql", + "original_file_path": "macros/utils/table_operations/make_temp_relation.sql", + "unique_id": "macro.elementary.default__make_temp_table_relation", + "macro_sql": "{% macro default__make_temp_table_relation(base_relation, suffix) %}\n {% do return(elementary.edr_make_temp_relation(base_relation, suffix)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_make_temp_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.1862779, + "supported_languages": null + }, + "macro.elementary.databricks__make_temp_table_relation": { + "name": "databricks__make_temp_table_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/make_temp_relation.sql", + "original_file_path": "macros/utils/table_operations/make_temp_relation.sql", + "unique_id": "macro.elementary.databricks__make_temp_table_relation", + "macro_sql": "{% macro databricks__make_temp_table_relation(base_relation, suffix) %}\n {% set tmp_identifier = elementary.table_name_with_suffix(base_relation.identifier, suffix) %}\n {% set tmp_relation = api.Relation.create(\n identifier=tmp_identifier,\n schema=base_relation.schema,\n database=base_relation.database,\n type='table') %}\n {% do return(tmp_relation) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.table_name_with_suffix" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.186657, + "supported_languages": null + }, + "macro.elementary.get_row_count": { + "name": "get_row_count", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/get_row_count.sql", + "original_file_path": "macros/utils/table_operations/get_row_count.sql", + "unique_id": "macro.elementary.get_row_count", + "macro_sql": "{% macro get_row_count(full_table_name) %}\n\n {% set query_row_count %}\n select count(*) from {{ full_table_name }}\n {% endset %}\n {% if execute %}\n {% set result = elementary.run_query(query_row_count).columns[0].values()[0] %}\n {% endif %}\n {{ return(result) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.187129, + "supported_languages": null + }, + "macro.elementary.create_or_replace": { + "name": "create_or_replace", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/create_or_replace.sql", + "original_file_path": "macros/utils/table_operations/create_or_replace.sql", + "unique_id": "macro.elementary.create_or_replace", + "macro_sql": "{% macro create_or_replace(temporary, relation, sql_query) %}\n {{ return(adapter.dispatch('create_or_replace', 'elementary')(temporary, relation, sql_query)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__create_or_replace" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.187826, + "supported_languages": null + }, + "macro.elementary.default__create_or_replace": { + "name": "default__create_or_replace", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/create_or_replace.sql", + "original_file_path": "macros/utils/table_operations/create_or_replace.sql", + "unique_id": "macro.elementary.default__create_or_replace", + "macro_sql": "{% macro default__create_or_replace(temporary, relation, sql_query) %}\n {% do elementary.run_query(dbt.create_table_as(temporary, relation, sql_query)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query", + "macro.dbt.create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.188032, + "supported_languages": null + }, + "macro.elementary.redshift__create_or_replace": { + "name": "redshift__create_or_replace", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/create_or_replace.sql", + "original_file_path": "macros/utils/table_operations/create_or_replace.sql", + "unique_id": "macro.elementary.redshift__create_or_replace", + "macro_sql": "{% macro redshift__create_or_replace(temporary, relation, sql_query) %}\n {% do dbt.drop_relation_if_exists(relation) %}\n {% do elementary.run_query(dbt.create_table_as(temporary, relation, sql_query)) %}\n {% do adapter.commit() %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.drop_relation_if_exists", + "macro.elementary.run_query", + "macro.dbt.create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.188332, + "supported_languages": null + }, + "macro.elementary.postgres__create_or_replace": { + "name": "postgres__create_or_replace", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/create_or_replace.sql", + "original_file_path": "macros/utils/table_operations/create_or_replace.sql", + "unique_id": "macro.elementary.postgres__create_or_replace", + "macro_sql": "{% macro postgres__create_or_replace(temporary, relation, sql_query) %}\n {% do elementary.run_query(\"BEGIN\") %}\n {% do dbt.drop_relation_if_exists(relation) %}\n {% do elementary.run_query(dbt.create_table_as(temporary, relation, sql_query)) %}\n {% do elementary.run_query(\"COMMIT\") %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query", + "macro.dbt.drop_relation_if_exists", + "macro.dbt.create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.188753, + "supported_languages": null + }, + "macro.elementary.spark__create_or_replace": { + "name": "spark__create_or_replace", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/create_or_replace.sql", + "original_file_path": "macros/utils/table_operations/create_or_replace.sql", + "unique_id": "macro.elementary.spark__create_or_replace", + "macro_sql": "{% macro spark__create_or_replace(temporary, relation, sql_query) %}\n {% do dbt.drop_relation_if_exists(relation) %}\n {% do elementary.run_query(dbt.create_table_as(temporary, relation, sql_query)) %}\n {% do adapter.commit() %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.drop_relation_if_exists", + "macro.elementary.run_query", + "macro.dbt.create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.189207, + "supported_languages": null + }, + "macro.elementary.athena__create_or_replace": { + "name": "athena__create_or_replace", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/create_or_replace.sql", + "original_file_path": "macros/utils/table_operations/create_or_replace.sql", + "unique_id": "macro.elementary.athena__create_or_replace", + "macro_sql": "{% macro athena__create_or_replace(temporary, relation, sql_query) %}\n {% do dbt.drop_relation_if_exists(relation) %}\n {% do elementary.run_query(dbt.create_table_as(temporary, relation, sql_query)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.drop_relation_if_exists", + "macro.elementary.run_query", + "macro.dbt.create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.189501, + "supported_languages": null + }, + "macro.elementary.insert_as_select": { + "name": "insert_as_select", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/insert_as_select.sql", + "original_file_path": "macros/utils/table_operations/insert_as_select.sql", + "unique_id": "macro.elementary.insert_as_select", + "macro_sql": "{% macro insert_as_select(table_relation, select_query) %}\n {# when calling this macro, you need to add depends on ref comment #}\n {# ref_model and select_query need to have the same columns #}\n\n {%- set insert_query %}\n insert into {{ table_relation }}\n with tmp_table as (\n {{ select_query }}\n )\n select * from tmp_table\n {%- endset %}\n\n {{ return(insert_query) }}\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.189912, + "supported_languages": null + }, + "macro.elementary.insert_rows": { + "name": "insert_rows", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/insert_rows.sql", + "original_file_path": "macros/utils/table_operations/insert_rows.sql", + "unique_id": "macro.elementary.insert_rows", + "macro_sql": "{% macro insert_rows(table_relation, rows, should_commit=false, chunk_size=5000, on_query_exceed=none) %}\n {% if not rows %}\n {{ return(none) }}\n {% endif %}\n\n {% if not table_relation %}\n {% do exceptions.warn(\"Couldn't find Elementary's models in `\" ~ elementary.target_database() ~ \".\" ~ target.schema ~ \"`. Please run `dbt run -s elementary --target \" ~ target.name ~ \"`.\") %}\n {{ return(none) }}\n {% endif %}\n\n {% set columns = adapter.get_columns_in_relation(table_relation) %}\n {% if not columns %}\n {% set table_name = elementary.relation_to_full_name(table_relation) %}\n {{ elementary.edr_log('Could not extract columns for table - ' ~ table_name ~ ' (might be a permissions issue)') }}\n {{ return(none) }}\n {% endif %}\n\n {{ elementary.file_log('Inserting {} rows to table {}'.format(rows | length, table_relation)) }}\n {% set insert_rows_method = elementary.get_config_var('insert_rows_method') %}\n {% if insert_rows_method == 'max_query_size' %}\n {% set insert_rows_queries = elementary.get_insert_rows_queries(table_relation, columns, rows, on_query_exceed=on_query_exceed) %}\n {% set queries_len = insert_rows_queries | length %}\n {% for insert_query in insert_rows_queries %}\n {% do elementary.file_log(\"[{}/{}] Running insert query.\".format(loop.index, queries_len)) %}\n {% do elementary.run_query(insert_query) %}\n {% endfor %}\n {% elif insert_rows_method == 'chunk' %}\n {% set rows_chunks = elementary.split_list_to_chunks(rows, chunk_size) %}\n {% for rows_chunk in rows_chunks %}\n {% set insert_rows_query = elementary.get_chunk_insert_query(table_relation, columns, rows_chunk) %}\n {% do elementary.run_query(insert_rows_query) %}\n {% endfor %}\n {% else %}\n {% do exceptions.raise_compiler_error(\"Specified invalid value for 'insert_rows_method' var.\") %}\n {% endif %}\n\n {% if should_commit %}\n {% do adapter.commit() %}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.target_database", + "macro.elementary.relation_to_full_name", + "macro.elementary.edr_log", + "macro.elementary.file_log", + "macro.elementary.get_config_var", + "macro.elementary.get_insert_rows_queries", + "macro.elementary.run_query", + "macro.elementary.split_list_to_chunks", + "macro.elementary.get_chunk_insert_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.199671, + "supported_languages": null + }, + "macro.elementary.get_insert_rows_queries": { + "name": "get_insert_rows_queries", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/insert_rows.sql", + "original_file_path": "macros/utils/table_operations/insert_rows.sql", + "unique_id": "macro.elementary.get_insert_rows_queries", + "macro_sql": "{% macro get_insert_rows_queries(table_relation, columns, rows, query_max_size=none, on_query_exceed=none) -%}\n {% if not query_max_size %}\n {% set query_max_size = elementary.get_config_var('query_max_size') %}\n {% endif %}\n\n {% set insert_queries = [] %}\n {% set base_insert_query %}\n insert into {{ table_relation }}\n ({%- for column in columns -%}\n {{- column.name -}} {{- \",\" if not loop.last else \"\" -}}\n {%- endfor -%}) values\n {% endset %}\n\n {% set current_query = namespace(data=base_insert_query) %}\n {% for row in rows %}\n {% set row_sql = elementary.render_row_to_sql(row, columns) %}\n {% set query_with_row = current_query.data + (\",\" if not loop.first else \"\") + row_sql %}\n\n {% if query_with_row | length > query_max_size %}\n {% set new_insert_query = base_insert_query + row_sql %}\n\n {# Check if row is too large to fit into an insert query. #}\n {% if new_insert_query | length > query_max_size %}\n {% if on_query_exceed %}\n {% do on_query_exceed(row) %}\n {% set row_sql = elementary.render_row_to_sql(row, columns) %}\n {% set new_insert_query = base_insert_query + row_sql %}\n {% endif %}\n\n {% if new_insert_query | length > query_max_size %}\n {% do elementary.file_log(\"Oversized row for insert_rows: {}\".format(query_with_row)) %}\n {% do exceptions.raise_compiler_error(\"Row to be inserted exceeds var('query_max_size'). Consider increasing its value.\") %}\n {% endif %}\n {% endif %}\n\n {% if current_query.data != base_insert_query %}\n {% do insert_queries.append(current_query.data) %}\n {% endif %}\n {% set current_query.data = new_insert_query %}\n\n {% else %}\n {% set current_query.data = query_with_row %}\n {% endif %}\n {% if loop.last %}\n {% do insert_queries.append(current_query.data) %}\n {% endif %}\n {% endfor %}\n\n {{ return(insert_queries) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_config_var", + "macro.elementary.render_row_to_sql", + "macro.elementary.file_log" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2017322, + "supported_languages": null + }, + "macro.elementary.render_row_to_sql": { + "name": "render_row_to_sql", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/insert_rows.sql", + "original_file_path": "macros/utils/table_operations/insert_rows.sql", + "unique_id": "macro.elementary.render_row_to_sql", + "macro_sql": "{% macro render_row_to_sql(row, columns) %}\n {% set rendered_column_values = [] %}\n {% for column in columns %}\n {% if column.name.lower() == \"created_at\" %}\n {% set column_value = elementary.edr_current_timestamp() %}\n {% do rendered_column_values.append(column_value) %}\n {% else %}\n {% set column_value = elementary.insensitive_get_dict_value(row, column.name) %}\n {% set normalized_data_type = elementary.normalize_data_type(column.dtype) %}\n {% do rendered_column_values.append(elementary.render_value(column_value, normalized_data_type)) %}\n\n {% endif %}\n {% endfor %}\n {% set row_sql = \"({})\".format(rendered_column_values | join(\",\")) %}\n {% do return(row_sql) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_current_timestamp", + "macro.elementary.insensitive_get_dict_value", + "macro.elementary.normalize_data_type", + "macro.elementary.render_value" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2025511, + "supported_languages": null + }, + "macro.elementary.get_chunk_insert_query": { + "name": "get_chunk_insert_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/insert_rows.sql", + "original_file_path": "macros/utils/table_operations/insert_rows.sql", + "unique_id": "macro.elementary.get_chunk_insert_query", + "macro_sql": "{% macro get_chunk_insert_query(table_relation, columns, rows) -%}\n {% set insert_rows_query %}\n insert into {{ table_relation }}\n ({%- for column in columns -%}\n {{- column.name -}} {{- \",\" if not loop.last else \"\" -}}\n {%- endfor -%}) values\n {% for row in rows -%}\n ({%- for column in columns -%}\n {%- set column_value = elementary.insensitive_get_dict_value(row, column.name, none) -%}\n {{ elementary.render_value(column_value) }}\n {{- \",\" if not loop.last else \"\" -}}\n {%- endfor -%}) {{- \",\" if not loop.last else \"\" -}}\n {%- endfor -%}\n {% endset %}\n {{ return(insert_rows_query) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.insensitive_get_dict_value", + "macro.elementary.render_value" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.203251, + "supported_languages": null + }, + "macro.elementary.escape_special_chars": { + "name": "escape_special_chars", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/insert_rows.sql", + "original_file_path": "macros/utils/table_operations/insert_rows.sql", + "unique_id": "macro.elementary.escape_special_chars", + "macro_sql": "{% macro escape_special_chars(string_value) %}\n {{ return(adapter.dispatch('escape_special_chars', 'elementary')(string_value)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__escape_special_chars" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.203443, + "supported_languages": null + }, + "macro.elementary.default__escape_special_chars": { + "name": "default__escape_special_chars", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/insert_rows.sql", + "original_file_path": "macros/utils/table_operations/insert_rows.sql", + "unique_id": "macro.elementary.default__escape_special_chars", + "macro_sql": "\n\n{%- macro default__escape_special_chars(string_value) -%}\n {{- return(string_value | replace(\"\\\\\", \"\\\\\\\\\") | replace(\"'\", \"\\\\'\") | replace(\"\\n\", \"\\\\n\") | replace(\"\\r\", \"\\\\r\")) -}}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.203718, + "supported_languages": null + }, + "macro.elementary.redshift__escape_special_chars": { + "name": "redshift__escape_special_chars", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/insert_rows.sql", + "original_file_path": "macros/utils/table_operations/insert_rows.sql", + "unique_id": "macro.elementary.redshift__escape_special_chars", + "macro_sql": "{%- macro redshift__escape_special_chars(string_value) -%}\n {{- return(string_value | replace(\"\\\\\", \"\\\\\\\\\") | replace(\"'\", \"\\\\'\") | replace(\"\\n\", \"\\\\n\") | replace(\"\\r\", \"\\\\r\")) -}}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.203983, + "supported_languages": null + }, + "macro.elementary.postgres__escape_special_chars": { + "name": "postgres__escape_special_chars", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/insert_rows.sql", + "original_file_path": "macros/utils/table_operations/insert_rows.sql", + "unique_id": "macro.elementary.postgres__escape_special_chars", + "macro_sql": "{%- macro postgres__escape_special_chars(string_value) -%}\n {{- return(string_value | replace(\"'\", \"''\")) -}}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2041368, + "supported_languages": null + }, + "macro.elementary.athena__escape_special_chars": { + "name": "athena__escape_special_chars", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/insert_rows.sql", + "original_file_path": "macros/utils/table_operations/insert_rows.sql", + "unique_id": "macro.elementary.athena__escape_special_chars", + "macro_sql": "{%- macro athena__escape_special_chars(string_value) -%}\n {{- return(string_value | replace(\"'\", \"''\")) -}}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.204298, + "supported_languages": null + }, + "macro.elementary.render_value": { + "name": "render_value", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/insert_rows.sql", + "original_file_path": "macros/utils/table_operations/insert_rows.sql", + "unique_id": "macro.elementary.render_value", + "macro_sql": "{%- macro render_value(value, data_type) -%}\n {%- if value is defined and value is not none -%}\n {%- if value is number -%}\n {{- value -}}\n {%- elif value is string and data_type == 'timestamp' -%}\n {{- elementary.edr_cast_as_timestamp(elementary.edr_quote(value)) -}}\n {%- elif value is string -%}\n '{{- elementary.escape_special_chars(value) -}}'\n {%- elif value is mapping or value is sequence -%}\n '{{- elementary.escape_special_chars(tojson(value)) -}}'\n {%- else -%}\n NULL\n {%- endif -%}\n {%- else -%}\n NULL\n {%- endif -%}\n{%- endmacro -%}", + "depends_on": { + "macros": [ + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.edr_quote", + "macro.elementary.escape_special_chars" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.20491, + "supported_languages": null + }, + "macro.elementary.delete_and_insert": { + "name": "delete_and_insert", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/delete_and_insert.sql", + "original_file_path": "macros/utils/table_operations/delete_and_insert.sql", + "unique_id": "macro.elementary.delete_and_insert", + "macro_sql": "{% macro delete_and_insert(relation, insert_rows=none, delete_values=none, delete_column_key=none) %}\n {% do elementary.file_log(\"Deleting from and inserting to: {}\".format(relation)) %}\n {% set delete_rows = [] %}\n {% for delete_val in delete_values %}\n {% do delete_rows.append({delete_column_key: delete_val}) %}\n {% endfor %}\n\n {% if delete_values %}\n {% set delete_relation = elementary.create_intermediate_relation(relation, delete_rows, temporary=True, like_columns=[delete_column_key]) %}\n {% endif %}\n\n {% if insert_rows %}\n {% set insert_relation = elementary.create_intermediate_relation(relation, insert_rows, temporary=True) %}\n {% endif %}\n\n {% if not insert_relation and not delete_relation %}\n {% do return(none) %}\n {% endif %}\n\n {% set queries = elementary.get_delete_and_insert_queries(relation, insert_relation, delete_relation, delete_column_key) %}\n {% for query in queries %}\n {% do elementary.run_query(query) %}\n {% endfor %}\n\n {# Make sure we delete the temp tables we created #}\n {% if delete_relation %}\n {% do adapter.drop_relation(delete_relation) %}\n {% endif %}\n {% if insert_relation %}\n {% do adapter.drop_relation(insert_relation) %}\n {% endif %}\n\n {% do elementary.file_log(\"Finished deleting from and inserting to: {}\".format(relation)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.file_log", + "macro.elementary.create_intermediate_relation", + "macro.elementary.get_delete_and_insert_queries", + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.209238, + "supported_languages": null + }, + "macro.elementary.get_delete_and_insert_queries": { + "name": "get_delete_and_insert_queries", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/delete_and_insert.sql", + "original_file_path": "macros/utils/table_operations/delete_and_insert.sql", + "unique_id": "macro.elementary.get_delete_and_insert_queries", + "macro_sql": "{% macro get_delete_and_insert_queries(relation, insert_relation, delete_relation, delete_column_key) %}\n {% do return(adapter.dispatch(\"get_delete_and_insert_queries\", \"elementary\")(relation, insert_relation, delete_relation, delete_column_key)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__get_delete_and_insert_queries" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2096052, + "supported_languages": null + }, + "macro.elementary.default__get_delete_and_insert_queries": { + "name": "default__get_delete_and_insert_queries", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/delete_and_insert.sql", + "original_file_path": "macros/utils/table_operations/delete_and_insert.sql", + "unique_id": "macro.elementary.default__get_delete_and_insert_queries", + "macro_sql": "{% macro default__get_delete_and_insert_queries(relation, insert_relation, delete_relation, delete_column_key) %}\n {% set query %}\n begin transaction;\n {% if delete_relation %}\n delete from {{ relation }}\n where\n {{ delete_column_key }} is null\n or {{ delete_column_key }} in (select {{ delete_column_key }} from {{ delete_relation }});\n {% endif %}\n {% if insert_relation %}\n insert into {{ relation }} select * from {{ insert_relation }};\n {% endif %}\n commit;\n {% endset %}\n {% do return([query]) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2100759, + "supported_languages": null + }, + "macro.elementary.spark__get_delete_and_insert_queries": { + "name": "spark__get_delete_and_insert_queries", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/delete_and_insert.sql", + "original_file_path": "macros/utils/table_operations/delete_and_insert.sql", + "unique_id": "macro.elementary.spark__get_delete_and_insert_queries", + "macro_sql": "{% macro spark__get_delete_and_insert_queries(relation, insert_relation, delete_relation, delete_column_key) %}\n {% set queries = [] %}\n\n {# Calling `is_delta` raises an error if `metadata` is None - https://github.com/databricks/dbt-databricks/blob/33dca4b66b05f268741030b33659d34ff69591c1/dbt/adapters/databricks/relation.py#L71 #}\n {% if delete_relation and relation.metadata and relation.is_delta %}\n {% set delete_query %}\n merge into {{ relation }} as source\n using {{ delete_relation }} as target\n on (source.{{ delete_column_key }} = target.{{ delete_column_key }}) or source.{{ delete_column_key }} is null\n when matched then delete;\n {% endset %}\n {% do queries.append(delete_query) %}\n\n {% elif delete_relation %}\n {% set delete_query %}\n delete from {{ relation }}\n where\n {{ delete_column_key }} is null\n or {{ delete_column_key }} in (select {{ delete_column_key }} from {{ delete_relation }});\n {% endset %}\n {% do queries.append(delete_query) %}\n {% endif %}\n\n {% if insert_relation %}\n {% set insert_query %}\n insert into {{ relation }} select * from {{ insert_relation }};\n {% endset %}\n {% do queries.append(insert_query) %}\n {% endif %}\n\n {% do return(queries) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2110028, + "supported_languages": null + }, + "macro.elementary.athena__get_delete_and_insert_queries": { + "name": "athena__get_delete_and_insert_queries", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/delete_and_insert.sql", + "original_file_path": "macros/utils/table_operations/delete_and_insert.sql", + "unique_id": "macro.elementary.athena__get_delete_and_insert_queries", + "macro_sql": "{% macro athena__get_delete_and_insert_queries(relation, insert_relation, delete_relation, delete_column_key) %}\n {% set queries = [] %}\n\n {% if delete_relation %}\n {% set delete_query %}\n delete from {{ relation }}\n where\n {{ delete_column_key }} is null\n or {{ delete_column_key }} in (select {{ delete_column_key }} from {{ delete_relation }});\n {% endset %}\n {% do queries.append(delete_query) %}\n {% endif %}\n\n {% if insert_relation %}\n {% set insert_query %}\n insert into {{ relation }} select * from {{ insert_relation }};\n {% endset %}\n {% do queries.append(insert_query) %}\n {% endif %}\n\n {% do return(queries) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.211634, + "supported_languages": null + }, + "macro.elementary.merge_sql": { + "name": "merge_sql", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/merge_sql.sql", + "original_file_path": "macros/utils/table_operations/merge_sql.sql", + "unique_id": "macro.elementary.merge_sql", + "macro_sql": "{% macro merge_sql(target_relation, tmp_relation, unique_key, dest_columns, incremental_predicates=none) -%}\n {{ return(adapter.dispatch('merge_sql', 'elementary')(target_relation, tmp_relation, unique_key, dest_columns, incremental_predicates)) }}\n{%- endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__merge_sql" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.212995, + "supported_languages": null + }, + "macro.elementary.default__merge_sql": { + "name": "default__merge_sql", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/merge_sql.sql", + "original_file_path": "macros/utils/table_operations/merge_sql.sql", + "unique_id": "macro.elementary.default__merge_sql", + "macro_sql": "{% macro default__merge_sql(target_relation, tmp_relation, unique_key, dest_columns, incremental_predicates) %}\n {% set macro = dbt.get_merge_sql %}\n {% if \"incremental_predicates\" in macro.get_macro().arguments %}\n {% do return(macro(target_relation, tmp_relation, unique_key, dest_columns, incremental_predicates)) %}\n {% endif %}\n {% do return(macro(target_relation, tmp_relation, unique_key, dest_columns)) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2134778, + "supported_languages": null + }, + "macro.elementary.postgres__merge_sql": { + "name": "postgres__merge_sql", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/merge_sql.sql", + "original_file_path": "macros/utils/table_operations/merge_sql.sql", + "unique_id": "macro.elementary.postgres__merge_sql", + "macro_sql": "{% macro postgres__merge_sql(target_relation, tmp_relation, unique_key, dest_columns, incremental_predicates) %}\n {% set macro = dbt.get_delete_insert_merge_sql %}\n {% if \"incremental_predicates\" in macro.get_macro().arguments %}\n {% do return(macro(target_relation, tmp_relation, unique_key, dest_columns, incremental_predicates)) %}\n {% endif %}\n {% do return(macro(target_relation, tmp_relation, unique_key, dest_columns)) %}\n {{ return(merge_sql) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2140648, + "supported_languages": null + }, + "macro.elementary.athena__merge_sql": { + "name": "athena__merge_sql", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/merge_sql.sql", + "original_file_path": "macros/utils/table_operations/merge_sql.sql", + "unique_id": "macro.elementary.athena__merge_sql", + "macro_sql": "{% macro athena__merge_sql(target_relation, tmp_relation, unique_key, dest_columns, incremental_predicates) %}\n\n {% set query %}\n merge into {{ target_relation }} as target using {{ tmp_relation }} as src\n ON (target.{{unique_key}} = src.{{ unique_key}})\n when matched\n then update set\n {%- for col in dest_columns %}\n {{ col.column }} = src.{{ col.column }} {{ \", \" if not loop.last }}\n {%- endfor %}\n when not matched\n then insert (\n {%- for col in dest_columns %}\n {{ col.column }} {{ \", \" if not loop.last }}\n {%- endfor %}\n\n )\n values (\n {%- for col in dest_columns %}\n src.{{ col.column }} {{ \", \" if not loop.last }}\n {%- endfor %}\n )\n {% endset %}\n {% do return(query) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2148201, + "supported_languages": null + }, + "macro.elementary.get_column_in_relation": { + "name": "get_column_in_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/get_column_in_relation.sql", + "original_file_path": "macros/utils/table_operations/get_column_in_relation.sql", + "unique_id": "macro.elementary.get_column_in_relation", + "macro_sql": "{% macro get_column_in_relation(relation, column_name) %}\n {% set columns = adapter.get_columns_in_relation(relation) %}\n {% for column in columns %}\n {% if column.name == column_name %}\n {% do return(column) %}\n {% endif %}\n {% endfor %}\n {% do return(none) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2153118, + "supported_languages": null + }, + "macro.elementary.get_relation_max_name_length": { + "name": "get_relation_max_name_length", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/get_relation_max_length.sql", + "original_file_path": "macros/utils/table_operations/get_relation_max_length.sql", + "unique_id": "macro.elementary.get_relation_max_name_length", + "macro_sql": "{% macro get_relation_max_name_length() %}\n {{ return(adapter.dispatch('get_relation_max_name_length', 'elementary')()) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.snowflake__get_relation_max_name_length" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.215806, + "supported_languages": null + }, + "macro.elementary.default__get_relation_max_name_length": { + "name": "default__get_relation_max_name_length", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/get_relation_max_length.sql", + "original_file_path": "macros/utils/table_operations/get_relation_max_length.sql", + "unique_id": "macro.elementary.default__get_relation_max_name_length", + "macro_sql": "{% macro default__get_relation_max_name_length(temporary, relation, sql_query) %}\n {{ return(none) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.21595, + "supported_languages": null + }, + "macro.elementary.snowflake__get_relation_max_name_length": { + "name": "snowflake__get_relation_max_name_length", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/get_relation_max_length.sql", + "original_file_path": "macros/utils/table_operations/get_relation_max_length.sql", + "unique_id": "macro.elementary.snowflake__get_relation_max_name_length", + "macro_sql": "{% macro snowflake__get_relation_max_name_length(temporary, relation, sql_query) %}\n {{ return(255) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2160902, + "supported_languages": null + }, + "macro.elementary.redshift__get_relation_max_name_length": { + "name": "redshift__get_relation_max_name_length", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/get_relation_max_length.sql", + "original_file_path": "macros/utils/table_operations/get_relation_max_length.sql", + "unique_id": "macro.elementary.redshift__get_relation_max_name_length", + "macro_sql": "{% macro redshift__get_relation_max_name_length(temporary, relation, sql_query) %}\n {{ return(127) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.216236, + "supported_languages": null + }, + "macro.elementary.postgres__get_relation_max_name_length": { + "name": "postgres__get_relation_max_name_length", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/get_relation_max_length.sql", + "original_file_path": "macros/utils/table_operations/get_relation_max_length.sql", + "unique_id": "macro.elementary.postgres__get_relation_max_name_length", + "macro_sql": "{% macro postgres__get_relation_max_name_length(temporary, relation, sql_query) %}\n {{ return(63) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.21639, + "supported_languages": null + }, + "macro.elementary.spark__get_relation_max_name_length": { + "name": "spark__get_relation_max_name_length", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/get_relation_max_length.sql", + "original_file_path": "macros/utils/table_operations/get_relation_max_length.sql", + "unique_id": "macro.elementary.spark__get_relation_max_name_length", + "macro_sql": "{% macro spark__get_relation_max_name_length(temporary, relation, sql_query) %}\n {{ return(127) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.216639, + "supported_languages": null + }, + "macro.elementary.athena__get_relation_max_name_length": { + "name": "athena__get_relation_max_name_length", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/get_relation_max_length.sql", + "original_file_path": "macros/utils/table_operations/get_relation_max_length.sql", + "unique_id": "macro.elementary.athena__get_relation_max_name_length", + "macro_sql": "{% macro athena__get_relation_max_name_length(temporary, relation, sql_query) %}\n {{ return(255) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.216774, + "supported_languages": null + }, + "macro.elementary.get_timestamped_table_suffix": { + "name": "get_timestamped_table_suffix", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/get_timestamped_table_suffix.sql", + "original_file_path": "macros/utils/table_operations/get_timestamped_table_suffix.sql", + "unique_id": "macro.elementary.get_timestamped_table_suffix", + "macro_sql": "{% macro get_timestamped_table_suffix() %}\n {% do return(modules.datetime.datetime.utcnow().strftime('__tmp_%Y%m%d%H%M%S%f')) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2169971, + "supported_languages": null + }, + "macro.elementary.replace_table_data": { + "name": "replace_table_data", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/replace_table_data.sql", + "original_file_path": "macros/utils/table_operations/replace_table_data.sql", + "unique_id": "macro.elementary.replace_table_data", + "macro_sql": "{% macro replace_table_data(relation, rows) %}\n {{ return(adapter.dispatch('replace_table_data', 'elementary')(relation, rows)) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__replace_table_data" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2177012, + "supported_languages": null + }, + "macro.elementary.default__replace_table_data": { + "name": "default__replace_table_data", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/replace_table_data.sql", + "original_file_path": "macros/utils/table_operations/replace_table_data.sql", + "unique_id": "macro.elementary.default__replace_table_data", + "macro_sql": "{% macro default__replace_table_data(relation, rows) %}\n {% set intermediate_relation = elementary.create_intermediate_relation(relation, rows, temporary=True) %}\n {% do elementary.run_query(dbt.create_table_as(False, relation, 'select * from {}'.format(intermediate_relation))) %}\n {% do adapter.drop_relation(intermediate_relation) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.create_intermediate_relation", + "macro.elementary.run_query", + "macro.dbt.create_table_as" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2180989, + "supported_languages": null + }, + "macro.elementary.databricks__replace_table_data": { + "name": "databricks__replace_table_data", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/replace_table_data.sql", + "original_file_path": "macros/utils/table_operations/replace_table_data.sql", + "unique_id": "macro.elementary.databricks__replace_table_data", + "macro_sql": "{% macro databricks__replace_table_data(relation, rows) %}\n {% do dbt.truncate_relation(relation) %}\n {% do elementary.insert_rows(relation, rows, should_commit=false, chunk_size=elementary.get_config_var('dbt_artifacts_chunk_size')) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.truncate_relation", + "macro.elementary.insert_rows", + "macro.elementary.get_config_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.218394, + "supported_languages": null + }, + "macro.elementary.spark__replace_table_data": { + "name": "spark__replace_table_data", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/replace_table_data.sql", + "original_file_path": "macros/utils/table_operations/replace_table_data.sql", + "unique_id": "macro.elementary.spark__replace_table_data", + "macro_sql": "{% macro spark__replace_table_data(relation, rows) %}\n {% call statement('truncate_relation') -%}\n delete from {{ relation }} where 1=1\n {%- endcall %}\n {% do elementary.insert_rows(relation, rows, should_commit=false, chunk_size=elementary.get_config_var('dbt_artifacts_chunk_size')) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.elementary.insert_rows", + "macro.elementary.get_config_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.218718, + "supported_languages": null + }, + "macro.elementary.postgres__replace_table_data": { + "name": "postgres__replace_table_data", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/replace_table_data.sql", + "original_file_path": "macros/utils/table_operations/replace_table_data.sql", + "unique_id": "macro.elementary.postgres__replace_table_data", + "macro_sql": "{% macro postgres__replace_table_data(relation, rows) %}\n {% set intermediate_relation = elementary.create_intermediate_relation(relation, rows, temporary=True) %}\n\n {% set query %}\n begin transaction;\n delete from {{ relation }}; -- truncate supported in Redshift transactions, but causes an immediate commit\n insert into {{ relation }} select * from {{ intermediate_relation }};\n commit;\n {% endset %}\n {% do elementary.run_query(query) %}\n\n {% do adapter.drop_relation(intermediate_relation) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.create_intermediate_relation", + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.219135, + "supported_languages": null + }, + "macro.elementary.athena__replace_table_data": { + "name": "athena__replace_table_data", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/replace_table_data.sql", + "original_file_path": "macros/utils/table_operations/replace_table_data.sql", + "unique_id": "macro.elementary.athena__replace_table_data", + "macro_sql": "{% macro athena__replace_table_data(relation, rows) %}\n {% call statement('truncate_relation') -%}\n delete from {{ relation }}\n {%- endcall %}\n {% do elementary.insert_rows(relation, rows, should_commit=false, chunk_size=elementary.get_config_var('dbt_artifacts_chunk_size')) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.statement", + "macro.elementary.insert_rows", + "macro.elementary.get_config_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.219446, + "supported_languages": null + }, + "macro.elementary.create_intermediate_relation": { + "name": "create_intermediate_relation", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/create_intermediate_relation.sql", + "original_file_path": "macros/utils/table_operations/create_intermediate_relation.sql", + "unique_id": "macro.elementary.create_intermediate_relation", + "macro_sql": "{% macro create_intermediate_relation(base_relation, rows, temporary, like_columns=none) %}\n {% set int_relation = elementary.make_temp_table_relation(base_relation).incorporate(type='table') %}\n\n {% if not elementary.has_temp_table_support() %}\n {% set temporary = false %}\n {% endif %}\n\n {% do elementary.create_table_like(int_relation, base_relation, temporary, like_columns) %}\n {% do elementary.insert_rows(int_relation, rows, should_commit=false, chunk_size=elementary.get_config_var('dbt_artifacts_chunk_size')) %}\n {% do return(int_relation) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.make_temp_table_relation", + "macro.elementary.has_temp_table_support", + "macro.elementary.create_table_like", + "macro.elementary.insert_rows", + "macro.elementary.get_config_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.22017, + "supported_languages": null + }, + "macro.elementary.relation_exists": { + "name": "relation_exists", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/relation_exists.sql", + "original_file_path": "macros/utils/table_operations/relation_exists.sql", + "unique_id": "macro.elementary.relation_exists", + "macro_sql": "{% macro relation_exists(relation) %}\n {%- set loaded_relation = load_relation(relation) -%}\n {% if loaded_relation is not none %}\n {{ return(True) }}\n {% endif %}\n {{ return(False) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.dbt.load_relation" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.220514, + "supported_languages": null + }, + "macro.elementary.table_name_with_suffix": { + "name": "table_name_with_suffix", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/table_operations/table_name_with_suffix.sql", + "original_file_path": "macros/utils/table_operations/table_name_with_suffix.sql", + "unique_id": "macro.elementary.table_name_with_suffix", + "macro_sql": "{% macro table_name_with_suffix(table_name, suffix) %}\n {% set relation_max_name_length = elementary.get_relation_max_name_length() %}\n {% if relation_max_name_length %}\n {% set suffix_length = suffix | length %}\n {% set table_name_with_suffix = table_name[:relation_max_name_length - suffix_length] ~ suffix %}\n {% else %}\n {% set table_name_with_suffix = table_name ~ suffix %}\n {% endif %}\n {{ return(table_name_with_suffix) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_relation_max_name_length" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2210932, + "supported_languages": null + }, + "macro.elementary.arithmetic_max": { + "name": "arithmetic_max", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/sql_utils/min_max.sql", + "original_file_path": "macros/utils/sql_utils/min_max.sql", + "unique_id": "macro.elementary.arithmetic_max", + "macro_sql": "{% macro arithmetic_max(val1, val2) %}\n (0.5 * ({{ val1 }} + {{ val2 }} + abs({{ val1 }} - {{ val2 }})))\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.221368, + "supported_languages": null + }, + "macro.elementary.arithmetic_min": { + "name": "arithmetic_min", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/sql_utils/min_max.sql", + "original_file_path": "macros/utils/sql_utils/min_max.sql", + "unique_id": "macro.elementary.arithmetic_min", + "macro_sql": "{% macro arithmetic_min(val1, val2) %}\n (0.5 * ({{ val1 }} + {{ val2 }} - abs({{ val1 }} - {{ val2 }})))\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2215302, + "supported_languages": null + }, + "macro.elementary.escape_select": { + "name": "escape_select", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/sql_utils/escape_select.sql", + "original_file_path": "macros/utils/sql_utils/escape_select.sql", + "unique_id": "macro.elementary.escape_select", + "macro_sql": "{% macro escape_select(column_names) %}\n {% do return(adapter.dispatch('escape_select', 'elementary')(column_names)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__escape_select" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2218292, + "supported_languages": null + }, + "macro.elementary.default__escape_select": { + "name": "default__escape_select", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/sql_utils/escape_select.sql", + "original_file_path": "macros/utils/sql_utils/escape_select.sql", + "unique_id": "macro.elementary.default__escape_select", + "macro_sql": "{% macro default__escape_select(column_names) %}\n {% do return(column_names | join(',')) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.221992, + "supported_languages": null + }, + "macro.elementary.redshift__escape_select": { + "name": "redshift__escape_select", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/sql_utils/escape_select.sql", + "original_file_path": "macros/utils/sql_utils/escape_select.sql", + "unique_id": "macro.elementary.redshift__escape_select", + "macro_sql": "{% macro redshift__escape_select(column_names) %}\n {% do return('\\\"' + column_names | join('\\\", \\\"') + '\\\"') %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.222183, + "supported_languages": null + }, + "macro.elementary.to_sql_list": { + "name": "to_sql_list", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/sql_utils/to_sql_list.sql", + "original_file_path": "macros/utils/sql_utils/to_sql_list.sql", + "unique_id": "macro.elementary.to_sql_list", + "macro_sql": "{% macro to_sql_list(ls) %}\n {% set rendered_items = [] %}\n {% for item in ls %}\n {% do rendered_items.append(elementary.render_value(item)) %}\n {% endfor %}\n\n({{ rendered_items | join(', ') }})\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.render_value" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.222568, + "supported_languages": null + }, + "macro.elementary.list_concat_with_separator": { + "name": "list_concat_with_separator", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/sql_utils/list_concat_with_separator.sql", + "original_file_path": "macros/utils/sql_utils/list_concat_with_separator.sql", + "unique_id": "macro.elementary.list_concat_with_separator", + "macro_sql": "{% macro list_concat_with_separator(item_list, separator, handle_nulls = true) %}\n {% set new_list = [] %}\n {% for item in item_list %}\n {% set new_item = elementary.edr_quote(item) %}\n {% if handle_nulls %}\n {% set new_item = \"case when \" ~ elementary.edr_cast_as_string(item) ~ \" is null then 'NULL' else \" ~ elementary.edr_cast_as_string(item) ~ \" end\" %}\n {% endif %}\n {% do new_list.append(new_item) %}\n {% if not loop.last %}\n {% do new_list.append(elementary.edr_quote(separator)) %}\n {% endif %}\n {% endfor %}\n {{ return(elementary.join_list(new_list, \" || \")) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.edr_quote", + "macro.elementary.edr_cast_as_string", + "macro.elementary.join_list" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.223606, + "supported_languages": null + }, + "macro.elementary.union_lists": { + "name": "union_lists", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/list_utils/union_lists.sql", + "original_file_path": "macros/utils/list_utils/union_lists.sql", + "unique_id": "macro.elementary.union_lists", + "macro_sql": "{% macro union_lists(list1, list2) %}\n {% set union_list = [] %}\n {% do union_list.extend(list1) %}\n {% do union_list.extend(list2) %}\n {{ return(union_list | unique | list) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.22397, + "supported_languages": null + }, + "macro.elementary.strings_list_to_tuple": { + "name": "strings_list_to_tuple", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/list_utils/strings_list_to_tuple.sql", + "original_file_path": "macros/utils/list_utils/strings_list_to_tuple.sql", + "unique_id": "macro.elementary.strings_list_to_tuple", + "macro_sql": "{% macro strings_list_to_tuple(strings) %}\n {%- if strings %}\n ({% for string in strings %} '{{ string }}' {{ \",\" if not loop.last else \"\" }} {% endfor %})\n {%- else %}\n ('')\n {%- endif %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.224339, + "supported_languages": null + }, + "macro.elementary.filter_none_and_sort": { + "name": "filter_none_and_sort", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/list_utils/filter_none_and_sort.sql", + "original_file_path": "macros/utils/list_utils/filter_none_and_sort.sql", + "unique_id": "macro.elementary.filter_none_and_sort", + "macro_sql": "{% macro filter_none_and_sort(val) %}\n {% do return(val | reject(\"none\") | sort) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.224543, + "supported_languages": null + }, + "macro.elementary.split_list_to_chunks": { + "name": "split_list_to_chunks", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/list_utils/split_list_to_chunks.sql", + "original_file_path": "macros/utils/list_utils/split_list_to_chunks.sql", + "unique_id": "macro.elementary.split_list_to_chunks", + "macro_sql": "{% macro split_list_to_chunks(item_list, chunk_size=50) %}\n {% set chunks = [] %}\n {% set current_chunk = [] %}\n {% for item in item_list %}\n {% set reminder = loop.index0 % chunk_size %}\n {% if reminder == 0 and current_chunk %}\n {% do chunks.append(current_chunk.copy()) %}\n {% do current_chunk.clear() %}\n {% endif %}\n {% do current_chunk.append(item) %}\n {% endfor %}\n {% if current_chunk %}\n {% do chunks.append(current_chunk) %}\n {% endif %}\n {{ return(chunks) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.225448, + "supported_languages": null + }, + "macro.elementary.join_list": { + "name": "join_list", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/list_utils/join_list.sql", + "original_file_path": "macros/utils/list_utils/join_list.sql", + "unique_id": "macro.elementary.join_list", + "macro_sql": "{% macro join_list(item_list, separator) %}\n {{ return(item_list | join(separator)) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.225641, + "supported_languages": null + }, + "macro.elementary.lists_intersection": { + "name": "lists_intersection", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/utils/list_utils/lists_intersection.sql", + "original_file_path": "macros/utils/list_utils/lists_intersection.sql", + "unique_id": "macro.elementary.lists_intersection", + "macro_sql": "{% macro lists_intersection(list_a, list_b) %}\n {% set new_list = [] %}\n {% for item in list_a %}\n {% if item in list_b %}\n {% do new_list.append(item) %}\n {% endif %}\n {% endfor %}\n {% do return(new_list) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.226069, + "supported_languages": null + }, + "macro.elementary.enforce_project_configurations": { + "name": "enforce_project_configurations", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/enforce_project_configurations.sql", + "original_file_path": "macros/commands/enforce_project_configurations.sql", + "unique_id": "macro.elementary.enforce_project_configurations", + "macro_sql": "{%- macro enforce_project_configurations(enforce_owners=true, enforce_tags=false, enforce_description=false, required_meta_keys=none, required_config_keys=none, include_sources=true) -%}\n {% if not required_meta_keys %}\n {% set required_meta_keys = [] %}\n {% endif %}\n {% if not required_config_keys %}\n {% set required_config_keys = [] %}\n {% endif %}\n\n {# enforcing source params #}\n {%- if include_sources -%}\n {% set sources = graph.sources.values() | selectattr('resource_type', '==', 'source') %}\n {% set sources_passed = elementary.enforce_configuration(sources, elementary.flatten_source, enforce_owners, enforce_tags, enforce_description, required_meta_keys, required_config_keys) %}\n {%- endif -%}\n\n {# enforcing model params #}\n {% set models = graph.nodes.values() | selectattr('resource_type', '==', 'model') %}\n {% set models_passed = elementary.enforce_configuration(models, elementary.flatten_model, enforce_owners, enforce_tags, enforce_description, required_meta_keys, required_config_keys) %}\n\n {%- if not models_passed or (include_sources and not sources_passed) -%}\n {{ exceptions.raise_compiler_error(\"Found issues in project configurations\") }}\n {%- endif -%}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.enforce_configuration" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.229742, + "supported_languages": null + }, + "macro.elementary.get_enforcement_param": { + "name": "get_enforcement_param", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/enforce_project_configurations.sql", + "original_file_path": "macros/commands/enforce_project_configurations.sql", + "unique_id": "macro.elementary.get_enforcement_param", + "macro_sql": "{%- macro get_enforcement_param(node, enforcement_param_name, enforcement_param_arg_value) -%}\n {% do return(node.meta.get(enforcement_param_name) or node.config.get(enforcement_param_name) or elementary.get_config_var(enforcement_param_name) or enforcement_param_arg_value) %}\n{%- endmacro -%}\n\n", + "depends_on": { + "macros": [ + "macro.elementary.get_config_var" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.230029, + "supported_languages": null + }, + "macro.elementary.enforce_configuration": { + "name": "enforce_configuration", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/enforce_project_configurations.sql", + "original_file_path": "macros/commands/enforce_project_configurations.sql", + "unique_id": "macro.elementary.enforce_configuration", + "macro_sql": "{%- macro enforce_configuration(nodes, flatten_callback, enforce_owners, enforce_tags, enforce_description, required_meta_keys, required_config_keys) -%}\n {% set validation_result = {'success': true} %}\n {% for node in nodes -%}\n {% set flattened_node = flatten_callback(node) %}\n {%- if flattened_node.package_name == project_name -%}\n {% set enforce_owners = elementary.get_enforcement_param(node, 'enforce_owners', enforce_owners) %}\n {% set enforce_tags = elementary.get_enforcement_param(node, 'enforce_tags', enforce_tags) %}\n {% set enforce_description = elementary.get_enforcement_param(node, 'enforce_description', enforce_description) %}\n {% set required_meta_keys = elementary.get_enforcement_param(node, 'required_meta_keys', required_meta_keys) %}\n {% set required_config_keys = elementary.get_enforcement_param(node, 'required_config_keys', required_config_keys) %}\n\n {%- if enforce_owners and flattened_node.owner | length == 0 -%}\n {% do elementary.edr_log(node.resource_type ~ \" \" ~ node.name ~ \" does not have an owner\") %}\n {% do validation_result.update({'success': false}) %}\n {%- endif -%}\n\n {%- if enforce_tags and flattened_node.tags | length == 0 -%}\n {% do elementary.edr_log(node.resource_type ~ \" \" ~ node.name ~ \" does not have tags\") %}\n {% do validation_result.update({'success': false}) %}\n {%- endif -%}\n\n {%- if enforce_description and not flattened_node.description -%}\n {% do elementary.edr_log(node.resource_type ~ \" \" ~ node.name ~ \" does not have a description\") %}\n {% do validation_result.update({'success': false}) %}\n {%- endif -%}\n\n {%- if required_meta_keys | length > 0 -%}\n {%- for meta_param in required_meta_keys -%}\n {%- if meta_param not in flattened_node.meta -%}\n {% do elementary.edr_log(node.resource_type ~ \" \" ~ node.name ~ \" does not have required meta param \" ~ meta_param) %}\n {% do validation_result.update({'success': false}) %}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- if required_config_keys | length > 0 -%}\n {%- for config_param in required_config_keys -%}\n {# flattened node doesn't have a config yet, using node instead #}\n {% set config_dict = elementary.safe_get_with_default(node, 'config', {}) %}\n {%- if config_dict is not none -%}\n {%- if config_param not in config_dict -%}\n {% do elementary.edr_log(node.resource_type ~ \" \" ~ node.name ~ \" does not have required config param \" ~ config_param) %}\n {% do validation_result.update({'success': false}) %}\n {%- endif -%}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n {%- endif -%}\n {%- endfor -%}\n {{- return(validation_result['success']) -}}\n{%- endmacro -%}", + "depends_on": { + "macros": [ + "macro.elementary.get_enforcement_param", + "macro.elementary.edr_log", + "macro.elementary.safe_get_with_default" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.232625, + "supported_languages": null + }, + "macro.elementary.delete_duplicate_rows": { + "name": "delete_duplicate_rows", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/delete_duplicate_rows.sql", + "original_file_path": "macros/commands/delete_duplicate_rows.sql", + "unique_id": "macro.elementary.delete_duplicate_rows", + "macro_sql": "{% macro delete_duplicate_rows(model_unique_id) %}\n {% do return(adapter.dispatch(\"delete_duplicate_rows\", \"elementary\")(model_unique_id)) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.default__delete_duplicate_rows" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.233331, + "supported_languages": null + }, + "macro.elementary.postgres__delete_duplicate_rows": { + "name": "postgres__delete_duplicate_rows", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/delete_duplicate_rows.sql", + "original_file_path": "macros/commands/delete_duplicate_rows.sql", + "unique_id": "macro.elementary.postgres__delete_duplicate_rows", + "macro_sql": "{% macro postgres__delete_duplicate_rows(model_unique_id) %}\n {% set node = graph.nodes[model_unique_id] %}\n {% set relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=node.alias) %}\n {% if relation is none %}\n {% do print(\"Relation '{}' does not exist.\".format(node.relation_name)) %}\n {% do return([]) %}\n {% endif %}\n\n {% set column_names = adapter.get_columns_in_relation(relation) | map(attribute=\"name\") | map(\"lower\") | list %}\n\n {% set query %}\n DELETE FROM {{ relation }} AS t1\n USING {{ relation }} AS t2\n WHERE t1.ctid < t2.ctid\n {% for col in column_names %}\n AND t1.{{ col }} = t2.{{ col }}\n {% endfor %}\n {% endset %}\n {% do elementary.run_query(query) %}\n {% do adapter.commit() %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.23422, + "supported_languages": null + }, + "macro.elementary.default__delete_duplicate_rows": { + "name": "default__delete_duplicate_rows", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/delete_duplicate_rows.sql", + "original_file_path": "macros/commands/delete_duplicate_rows.sql", + "unique_id": "macro.elementary.default__delete_duplicate_rows", + "macro_sql": "{% macro default__delete_duplicate_rows(model_unique_id) %}\n {{ exceptions.raise_compiler_error(\"This macro is not supported on '{}'.\".format(target.type)) }}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.23439, + "supported_languages": null + }, + "macro.elementary.generate_elementary_cli_profile": { + "name": "generate_elementary_cli_profile", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/generate_elementary_cli_profile.sql", + "original_file_path": "macros/commands/generate_elementary_cli_profile.sql", + "unique_id": "macro.elementary.generate_elementary_cli_profile", + "macro_sql": "{% macro generate_elementary_cli_profile(method=none) %}\n {% set profile_parameters = elementary.generate_elementary_profile_args(method) %}\n {% if profile_parameters is string %}\n {% set profile = profile_parameters %}\n {% else %}\n {% set profile = elementary.cli_profile_from_parameters(profile_parameters)%}\n {% endif %}\n {{ log('\\n' ~ profile, info=True) }}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.generate_elementary_profile_args", + "macro.elementary.cli_profile_from_parameters" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2351968, + "supported_languages": null + }, + "macro.elementary.cli_profile_from_parameters": { + "name": "cli_profile_from_parameters", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/generate_elementary_cli_profile.sql", + "original_file_path": "macros/commands/generate_elementary_cli_profile.sql", + "unique_id": "macro.elementary.cli_profile_from_parameters", + "macro_sql": "{% macro cli_profile_from_parameters(parameters) %}\nelementary:\n outputs:\n default:\n {% for parameter in parameters -%}\n {%- set key = parameter[\"name\"] -%}\n {%- set value = parameter[\"value\"] -%}\n {%- if value is string -%}\n {%- set value = '\"' ~ value ~ '\"' -%}\n {%- endif -%}\n {{ key }}: {{ value }}{% if parameter[\"comment\"] %} # {{ parameter[\"comment\"] }}{% endif %}\n {% endfor -%}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.235703, + "supported_languages": null + }, + "macro.elementary.create_elementary_user": { + "name": "create_elementary_user", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/create_elementary_user.sql", + "original_file_path": "macros/commands/create_elementary_user.sql", + "unique_id": "macro.elementary.create_elementary_user", + "macro_sql": "{% macro create_elementary_user(user=\"elementary\", password=none, role=\"ELEMENTARY_ROLE\") %}\n {% if password is none %}\n {% set password = elementary.generate_password() %}\n {% endif %}\n {% set profile_parameters = elementary.generate_elementary_profile_args(overwrite_values={\n \"user\": user,\n \"password\": password,\n \"role\": role\n }) %}\n {% set profile_parameters_dict = {} %}\n {% for parameter in profile_parameters %}\n {% set profile_parameters_dict = profile_parameters_dict.update({parameter[\"name\"]: parameter[\"value\"]}) %}\n {% endfor %}\n {% set profile_creation_query = elementary.get_profile_creation_query(profile_parameters_dict) %}\n {% do print(\"\\nPlease run the following query in your database to create the Elementary user:\\n\" ~ profile_creation_query) %}\n {% do print(\"\\nAfter that, use the following parameters when configuring your environment\\n\") %}\n {% for parameter in profile_parameters %}\n {% if parameter[\"name\"] != \"threads\" %} {# threads is not a parameter for the environment #}\n {% do print(parameter[\"name\"]|capitalize ~ \": \" ~ parameter[\"value\"]) %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.generate_password", + "macro.elementary.generate_elementary_profile_args", + "macro.elementary.get_profile_creation_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.23734, + "supported_languages": null + }, + "macro.elementary.generate_password": { + "name": "generate_password", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/create_elementary_user.sql", + "original_file_path": "macros/commands/create_elementary_user.sql", + "unique_id": "macro.elementary.generate_password", + "macro_sql": "{% macro generate_password() %}\n {# Heavily inspired by https://gist.github.com/benwalio/8598cf9f642271ffdaf3daa82c1802cb #}\n {% set characters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] %}\n {% set ns = namespace(placeholder=\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\", password=\"\") %}\n {% for x in ns.placeholder %}\n {% set ns.password = [ns.password, (x | replace('x', characters | random ))] | join %}\n {% endfor %}\n {% do return(ns.password) %}\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.238639, + "supported_languages": null + }, + "macro.elementary.generate_schema_baseline_test": { + "name": "generate_schema_baseline_test", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/generate_schema_baseline_test.sql", + "original_file_path": "macros/commands/generate_schema_baseline_test.sql", + "unique_id": "macro.elementary.generate_schema_baseline_test", + "macro_sql": "{% macro generate_schema_baseline_test(name=none, include_sources=True, include_models=False, fail_on_added=False, enforce_types=False) %}\n {% if name %}\n {{ generate_schema_baseline_test_for_node(name, fail_on_added=fail_on_added, enforce_types=enforce_types) }}\n {% else %}\n {{ generate_schema_baseline_test_for_all_nodes(include_sources=include_sources, include_models=include_models,\n fail_on_added=fail_on_added, enforce_types=enforce_types) }}\n {% endif %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.generate_schema_baseline_test_for_node", + "macro.elementary.generate_schema_baseline_test_for_all_nodes" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.240672, + "supported_languages": null + }, + "macro.elementary.generate_schema_baseline_test_for_all_nodes": { + "name": "generate_schema_baseline_test_for_all_nodes", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/generate_schema_baseline_test.sql", + "original_file_path": "macros/commands/generate_schema_baseline_test.sql", + "unique_id": "macro.elementary.generate_schema_baseline_test_for_all_nodes", + "macro_sql": "{% macro generate_schema_baseline_test_for_all_nodes(include_sources=True, include_models=False, fail_on_added=False, enforce_types=False) %}\n {% set nodes = elementary.get_nodes_from_graph() %}\n {% for node in nodes %}\n {% if node.package_name != 'elementary' and\n ((include_sources and node.resource_type == 'source') or\n (include_models and node.resource_type == 'model')) %}\n {% do print(\"Generating schema changes from baseline test for {} '{}':\".format(node.resource_type, node.name)) %}\n {{ generate_schema_baseline_test_for_node(node, fail_on_added=fail_on_added, enforce_types=enforce_types) }}\n {% do print('----------------------------------') %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_nodes_from_graph", + "macro.elementary.generate_schema_baseline_test_for_node" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.241377, + "supported_languages": null + }, + "macro.elementary.generate_schema_baseline_test_for_node": { + "name": "generate_schema_baseline_test_for_node", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/generate_schema_baseline_test.sql", + "original_file_path": "macros/commands/generate_schema_baseline_test.sql", + "unique_id": "macro.elementary.generate_schema_baseline_test_for_node", + "macro_sql": "{% macro generate_schema_baseline_test_for_node(node, fail_on_added=False, enforce_types=False) %}\n {% if node is string %}\n {% set node_name = node %}\n {% set node = elementary.get_node_by_name(node_name) %}\n\n {% if not node %}\n {% do print(\"Could not find any model or source by the name '{}'!\".format(node_name)) %}\n {% do return(none) %}\n {% endif %}\n {% endif %}\n\n {% if node.resource_type not in [\"source\", \"model\"] %}\n {% do print(\"Only sources and models are supported for this macro, supplied node type: '{}'\".format(node.resource_type)) %}\n {% do return(none) %}\n {% endif %}\n\n {% set node_relation = get_relation_from_node(node) %}\n {% if not node_relation %}\n {% do print(\"Table not found in the DB! Cannot create schema test.\") %}\n {% do return(none) %}\n {% endif %}\n\n {% set columns = adapter.get_columns_in_relation(node_relation) %}\n\n {% set test_params = {} %}\n {% if fail_on_added %}\n {% do test_params.update({\"fail_on_added\": \"true\"}) %}\n {% endif %}\n {% if enforce_types %}\n {% do test_params.update({\"enforce_types\": \"true\"}) %}\n {% endif %}\n\n {# Common yaml for sources and models #}\n {% set common_yaml %}\n - name: {{ node.name }}\n columns:\n {%- for column in columns %}\n - name: {{ column.name }}\n data_type: {{ elementary.get_column_data_type(column) }}\n {% endfor %}\n tests:\n - elementary.schema_changes_from_baseline\n {%- if test_params %}:\n {%- for param, param_val in test_params.items() %}\n {{param}}: {{param_val}}\n {%- endfor -%}\n {% endif -%}\n {% endset %}\n\n {% set full_yaml %}\n {%- if node.resource_type == 'source' %}\nsources:\n - name: {{ node.source_name }}\n tables:\n {{- common_yaml }}\n {% else %}\nmodels:\n {{- common_yaml }}\n {% endif -%}\n {% endset %}\n\n {% do print(full_yaml) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_node_by_name", + "macro.elementary.get_relation_from_node", + "macro.elementary.get_column_data_type" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.243258, + "supported_languages": null + }, + "macro.elementary.dump_table": { + "name": "dump_table", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/dump_table.sql", + "original_file_path": "macros/commands/dump_table.sql", + "unique_id": "macro.elementary.dump_table", + "macro_sql": "{% macro dump_table(model_unique_id, output_path, exclude_deprecated_columns=true, timestamp_column=none, since=none, days_back=7, dedup=false) %}\n {% set node = graph.nodes.get(model_unique_id) %}\n {% if not node %}\n {% do print(\"Node '{}' does not exist.\".format(model_unique_id)) %}\n {% do return([]) %}\n {% endif %}\n\n {% set relation = api.Relation.create(database=node.database, schema=node.schema, identifier=node.alias) %}\n {% set column_names = adapter.get_columns_in_relation(relation) | map(attribute=\"name\") | map(\"lower\") | list %}\n {% if not column_names %}\n {% do print(\"Relation '{}' does not exist.\".format(node.relation_name)) %}\n {% do return([]) %}\n {% endif %}\n\n {% if exclude_deprecated_columns %}\n {% set deprecated_column_names = node.meta.get(\"deprecated_columns\", []) | map(attribute=\"name\") | map(\"lower\") | list %}\n {% set column_names = column_names | reject(\"in\", deprecated_column_names) | list %}\n {% endif %}\n\n {% set dedup_by_column = node.meta.dedup_by_column or \"unique_id\" %}\n {% set order_by_dedup_column = \"generated_at\" %}\n {% set query %}\n {% if dedup and (dedup_by_column in column_names) and (order_by_dedup_column in column_names) %}\n {{ elementary.dedup_by_column_query(dedup_by_column, order_by_dedup_column, column_names, relation) }}\n {% else %}\n select {{ elementary.escape_select(column_names) }} from {{ relation }}\n {% endif %}\n {% if timestamp_column %}\n {% if since %}\n where {{ elementary.edr_cast_as_timestamp(timestamp_column) }} > {{ elementary.edr_cast_as_timestamp(elementary.edr_quote(since)) }}\n {% else %}\n where {{ elementary.edr_datediff(elementary.edr_cast_as_timestamp(timestamp_column), elementary.edr_current_timestamp(), 'day') }} < {{ days_back }}\n {% endif %}\n {% endif %}\n {% endset %}\n {% set results = elementary.run_query(query) %}\n {% do results.to_csv(output_path) %}\n {% do return(results.column_names) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.dedup_by_column_query", + "macro.elementary.escape_select", + "macro.elementary.edr_cast_as_timestamp", + "macro.elementary.edr_quote", + "macro.elementary.edr_datediff", + "macro.elementary.edr_current_timestamp", + "macro.elementary.run_query" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2475631, + "supported_languages": null + }, + "macro.elementary.dedup_by_column_query": { + "name": "dedup_by_column_query", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/dump_table.sql", + "original_file_path": "macros/commands/dump_table.sql", + "unique_id": "macro.elementary.dedup_by_column_query", + "macro_sql": "{% macro dedup_by_column_query(dedup_by_column, order_by_dedup_column, column_names, relation) %}\n with indexed_relation as (\n select \n {{ elementary.escape_select(column_names) }}, \n row_number() over (partition by {{ dedup_by_column }} order by {{ order_by_dedup_column }} desc) as row_index\n from {{ relation }}\n ),\n\n deduped_relation as (\n select {{ elementary.escape_select(column_names) }}\n from indexed_relation\n where row_index = 1\n )\n\n select {{ elementary.escape_select(column_names) }}\n from deduped_relation\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.escape_select" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.247908, + "supported_languages": null + }, + "macro.elementary.generate_json_schema_test": { + "name": "generate_json_schema_test", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/generate_json_schema_test.sql", + "original_file_path": "macros/commands/generate_json_schema_test.sql", + "unique_id": "macro.elementary.generate_json_schema_test", + "macro_sql": "{% macro generate_json_schema_test(node_name, column_name) %}\n {% if target.type not in ['snowflake', 'bigquery'] %}\n {% do exceptions.raise_compiler_error(\"JSON schema test generation is not supported for target: {}\".format(target.type)) %}\n {% endif %}\n\n {% set node = elementary.get_node_by_name(node_name) %}\n {% if node.resource_type not in [\"source\", \"model\"] %}\n {% do exceptions.raise_compiler_error(\"Only sources and models are supported for this macro, supplied node type: '{}'\".format(node.resource_type)) %}\n {% endif %}\n\n {% set node_relation = get_relation_from_node(node) %}\n {% if not elementary.column_exists_in_relation(node_relation, column_name) %}\n {% do exceptions.raise_compiler_error(\"Column '{}' does not exist in {} '{}'!\".format(column_name, node.resource_type, node_name)) %}\n {% endif %}\n\n {% set elementary_database_name, elementary_schema_name = elementary.get_package_database_and_schema() %}\n\n {% do node.config.update({\"packages\": [\"genson\"]}) %}\n {% do node.update({'database': elementary_database_name, 'schema': elementary_schema_name}) %}\n {% if node.resource_type == 'source' %}\n {# Source nodes don't have alias, and submit_python_job expects it #}\n {% do node.update({'alias': \"jsonschemagen_{}_{}\".format(node.source_name, node.name)}) %}\n {% endif %}\n\n {% set output_table = api.Relation.create(database=elementary_database_name, schema=elementary_schema_name,\n identifier='json_schema_tmp__' ~ node.alias).quote(false, false, false) %}\n\n {% set gen_json_schema_func = elementary.generate_json_schema_py_func(column_name) %}\n {% set node_relation = node_relation.quote(false, false, false) %}\n {% set compiled_py_code = adapter.dispatch('compile_py_code', 'elementary')(node_relation, gen_json_schema_func,\n output_table, code_type='function') %}\n\n {% do elementary.run_python(node, compiled_py_code) %}\n {% set json_schema = elementary.result_value('select result from {}'.format(output_table)) %}\n {% if json_schema == 'genson_not_installed' %}\n {% do exceptions.raise_compiler_error(\"The 'genson' python library is missing from your warehouse.\\n\\n\"\n \"This macro relies on the 'genson' python library for generating JSON schemas. Please follow dbt's instructions here: \\n\"\n \"https://docs.getdbt.com/docs/building-a-dbt-project/building-models/python-models#specific-data-warehouses\\n\"\n \"regarding how to install python packages for a {} warehouse.\".format(target.type)\n ) %}\n {% endif %}\n\n {% if not json_schema %}\n {% do exceptions.raise_compiler_error(\"Not a valid JSON column: {}\".format(column_name)) %}\n {% endif %}\n\n {% set json_schema = fromjson(json_schema) %}\n {% do json_schema.pop('$schema', None) %}\n\n {% set testyaml %}\ncolumns:\n - name: {{ column_name }}\n tests:\n - elementary.json_schema:\n {{ toyaml(json_schema) | indent(10) }}\n {% endset %}\n\n {% do print(\"Please add the following test to your {} configuration for the column {}:\".format(node.resource_type, column_name)) %}\n {% do print(testyaml) %}\n{% endmacro %}", + "depends_on": { + "macros": [ + "macro.elementary.get_node_by_name", + "macro.elementary.get_relation_from_node", + "macro.elementary.column_exists_in_relation", + "macro.elementary.get_package_database_and_schema", + "macro.elementary.generate_json_schema_py_func", + "macro.elementary.snowflake__compile_py_code", + "macro.elementary.run_python", + "macro.elementary.result_value" + ] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.252602, + "supported_languages": null + }, + "macro.elementary.generate_json_schema_py_func": { + "name": "generate_json_schema_py_func", + "resource_type": "macro", + "package_name": "elementary", + "path": "macros/commands/generate_json_schema_test.sql", + "original_file_path": "macros/commands/generate_json_schema_test.sql", + "unique_id": "macro.elementary.generate_json_schema_py_func", + "macro_sql": "{% macro generate_json_schema_py_func(column_name) %}\nimport json\ntry:\n import genson\nexcept ImportError:\n genson = None\n\ndef get_column_name_in_df(df, column_name):\n matching = [col for col in df.columns if col.lower() == column_name.lower()]\n if len(matching) > 1:\n # Case matters, switch to case-sensitive match\n matching = [col for col in df.columns if col == column_name]\n\n if len(matching) == 0:\n raise Exception(\"No column with the name: {}\".format(col))\n return matching[0]\n\ndef func(model_df, ref, session):\n if genson is None:\n return \"genson_not_installed\"\n\n model_df = model_df.toPandas()\n builder = genson.SchemaBuilder()\n column_name = get_column_name_in_df(model_df, \"{{ column_name }}\")\n for val in set(model_df[column_name]):\n if val == \"\" or val is None:\n continue\n try:\n builder.add_object(json.loads(val))\n except json.JSONDecodeError:\n # Not a valid json column, no schema\n return None\n return builder.to_schema()\n\n{% endmacro %}", + "depends_on": { + "macros": [] + }, + "description": "", + "meta": {}, + "docs": { + "show": true, + "node_color": null + }, + "patch_path": null, + "arguments": [], + "created_at": 1705031517.2527921, + "supported_languages": null + } + }, + "docs": { + "doc.jaffle_shop_package.__overview__": { + "name": "__overview__", + "resource_type": "doc", + "package_name": "jaffle_shop_package", + "path": "overview.md", + "original_file_path": "models/overview.md", + "unique_id": "doc.jaffle_shop_package.__overview__", + "block_contents": "## Data Documentation for Jaffle Shop\n\n`jaffle_shop` is a fictional ecommerce store.\n\nThis [dbt](https://www.getdbt.com/) project is for testing out code.\n\nThe source code can be found [here](https://github.com/clrcrl/jaffle_shop)." + }, + "doc.jaffle_shop_package.orders_status": { + "name": "orders_status", + "resource_type": "doc", + "package_name": "jaffle_shop_package", + "path": "docs.md", + "original_file_path": "models/docs.md", + "unique_id": "doc.jaffle_shop_package.orders_status", + "block_contents": "Orders can be one of the following statuses:\n\n| status | description |\n|----------------|------------------------------------------------------------------------------------------------------------------------|\n| placed | The order has been placed but has not yet left the warehouse |\n| shipped | The order has ben shipped to the customer and is currently in transit |\n| completed | The order has been received by the customer |\n| return_pending | The customer has indicated that they would like to return the order, but it has not yet been received at the warehouse |\n| returned | The order has been returned by the customer and received at the warehouse |" + }, + "doc.dbt.__overview__": { + "name": "__overview__", + "resource_type": "doc", + "package_name": "dbt", + "path": "overview.md", + "original_file_path": "docs/overview.md", + "unique_id": "doc.dbt.__overview__", + "block_contents": "### Welcome!\n\nWelcome to the auto-generated documentation for your dbt project!\n\n### Navigation\n\nYou can use the `Project` and `Database` navigation tabs on the left side of the window to explore the models\nin your project.\n\n#### Project Tab\nThe `Project` tab mirrors the directory structure of your dbt project. In this tab, you can see all of the\nmodels defined in your dbt project, as well as models imported from dbt packages.\n\n#### Database Tab\nThe `Database` tab also exposes your models, but in a format that looks more like a database explorer. This view\nshows relations (tables and views) grouped into database schemas. Note that ephemeral models are _not_ shown\nin this interface, as they do not exist in the database.\n\n### Graph Exploration\nYou can click the blue icon on the bottom-right corner of the page to view the lineage graph of your models.\n\nOn model pages, you'll see the immediate parents and children of the model you're exploring. By clicking the `Expand`\nbutton at the top-right of this lineage pane, you'll be able to see all of the models that are used to build,\nor are built from, the model you're exploring.\n\nOnce expanded, you'll be able to use the `--select` and `--exclude` model selection syntax to filter the\nmodels in the graph. For more information on model selection, check out the [dbt docs](https://docs.getdbt.com/docs/model-selection-syntax).\n\nNote that you can also right-click on models to interactively filter and explore the graph.\n\n---\n\n### More information\n\n- [What is dbt](https://docs.getdbt.com/docs/introduction)?\n- Read the [dbt viewpoint](https://docs.getdbt.com/docs/viewpoint)\n- [Installation](https://docs.getdbt.com/docs/installation)\n- Join the [dbt Community](https://www.getdbt.com/community/) for questions and discussion" + } + }, + "exposures": {}, + "metrics": {}, + "groups": {}, + "selectors": {}, + "disabled": {}, + "parent_map": { + "model.jaffle_shop_package.hard_coded": [], + "model.jaffle_shop_package.customers": [ + "model.jaffle_shop_package.stg_customers", + "model.jaffle_shop_package.stg_orders", + "model.jaffle_shop_package.stg_payments" + ], + "model.jaffle_shop_package.direct_join_to_source": [ + "model.jaffle_shop_package.customers", + "source.jaffle_shop_package.jaffle_shop.customers" + ], + "model.jaffle_shop_package.orders": [ + "model.jaffle_shop_package.stg_orders", + "model.jaffle_shop_package.stg_payments" + ], + "model.jaffle_shop_package.stg_customers": [ + "seed.jaffle_shop_package.raw_customers" + ], + "model.jaffle_shop_package.stg_payments": [ + "seed.jaffle_shop_package.raw_payments" + ], + "model.jaffle_shop_package.stg_orders": [ + "seed.jaffle_shop_package.raw_orders" + ], + "seed.jaffle_shop_package.raw_customers": [], + "seed.jaffle_shop_package.raw_orders": [], + "seed.jaffle_shop_package.raw_payments": [], + "model.elementary.snapshot_run_results": [ + "model.elementary.dbt_run_results", + "model.elementary.dbt_snapshots" + ], + "model.elementary.job_run_results": [ + "model.elementary.dbt_invocations" + ], + "model.elementary.model_run_results": [ + "model.elementary.dbt_models", + "model.elementary.dbt_run_results" + ], + "model.elementary.test_result_rows": [ + "model.elementary.elementary_test_results" + ], + "model.elementary.elementary_test_results": [], + "model.elementary.dbt_source_freshness_results": [], + "model.elementary.alerts_dbt_tests": [ + "model.elementary.elementary_test_results" + ], + "model.elementary.alerts_schema_changes": [ + "model.elementary.elementary_test_results" + ], + "model.elementary.alerts_dbt_source_freshness": [ + "model.elementary.dbt_source_freshness_results", + "model.elementary.dbt_sources" + ], + "model.elementary.alerts_anomaly_detection": [ + "model.elementary.elementary_test_results" + ], + "model.elementary.alerts_dbt_models": [ + "model.elementary.model_run_results", + "model.elementary.snapshot_run_results" + ], + "model.elementary.monitors_runs": [ + "model.elementary.data_monitoring_metrics" + ], + "model.elementary.metadata": [], + "model.elementary.dbt_tests": [], + "model.elementary.dbt_models": [], + "model.elementary.dbt_sources": [], + "model.elementary.dbt_snapshots": [], + "model.elementary.dbt_columns": [], + "model.elementary.enriched_columns": [ + "model.elementary.dbt_columns", + "model.elementary.information_schema_columns" + ], + "model.elementary.dbt_invocations": [], + "model.elementary.dbt_metrics": [], + "model.elementary.dbt_seeds": [], + "model.elementary.dbt_artifacts_hashes": [ + "model.elementary.dbt_columns", + "model.elementary.dbt_exposures", + "model.elementary.dbt_metrics", + "model.elementary.dbt_models", + "model.elementary.dbt_seeds", + "model.elementary.dbt_snapshots", + "model.elementary.dbt_sources", + "model.elementary.dbt_tests" + ], + "model.elementary.dbt_run_results": [], + "model.elementary.information_schema_columns": [ + "model.elementary.dbt_models", + "model.elementary.dbt_seeds", + "model.elementary.dbt_snapshots", + "model.elementary.dbt_sources" + ], + "model.elementary.dbt_exposures": [], + "model.elementary.metrics_anomaly_score": [ + "model.elementary.data_monitoring_metrics" + ], + "model.elementary.anomaly_threshold_sensitivity": [ + "model.elementary.metrics_anomaly_score" + ], + "model.elementary.schema_columns_snapshot": [], + "model.elementary.data_monitoring_metrics": [], + "operation.elementary.elementary-on-run-start-0": [], + "operation.elementary.elementary-on-run-end-0": [], + "test.jaffle_shop_package.unique_customers_customer_id.c5af1ff4b1": [ + "model.jaffle_shop_package.customers" + ], + "test.jaffle_shop_package.not_null_customers_customer_id.5c9bf9911d": [ + "model.jaffle_shop_package.customers" + ], + "test.jaffle_shop_package.unique_orders_order_id.fed79b3a6e": [ + "model.jaffle_shop_package.orders" + ], + "test.jaffle_shop_package.not_null_orders_order_id.cf6c17daed": [ + "model.jaffle_shop_package.orders" + ], + "test.jaffle_shop_package.not_null_orders_customer_id.c5f02694af": [ + "model.jaffle_shop_package.orders" + ], + "test.jaffle_shop_package.relationships_orders_customer_id__customer_id__ref_customers_.c6ec7f58f2": [ + "model.jaffle_shop_package.customers", + "model.jaffle_shop_package.orders" + ], + "test.jaffle_shop_package.accepted_values_orders_status__placed__shipped__completed__return_pending__returned.be6b5b5ec3": [ + "model.jaffle_shop_package.orders" + ], + "test.jaffle_shop_package.not_null_orders_amount.106140f9fd": [ + "model.jaffle_shop_package.orders" + ], + "test.jaffle_shop_package.not_null_orders_credit_card_amount.d3ca593b59": [ + "model.jaffle_shop_package.orders" + ], + "test.jaffle_shop_package.not_null_orders_coupon_amount.ab90c90625": [ + "model.jaffle_shop_package.orders" + ], + "test.jaffle_shop_package.not_null_orders_bank_transfer_amount.7743500c49": [ + "model.jaffle_shop_package.orders" + ], + "test.jaffle_shop_package.not_null_orders_gift_card_amount.413a0d2d7a": [ + "model.jaffle_shop_package.orders" + ], + "test.jaffle_shop_package.unique_stg_customers_customer_id.c7614daada": [ + "model.jaffle_shop_package.stg_customers" + ], + "test.jaffle_shop_package.not_null_stg_customers_customer_id.e2cfb1f9aa": [ + "model.jaffle_shop_package.stg_customers" + ], + "test.jaffle_shop_package.unique_stg_orders_order_id.e3b841c71a": [ + "model.jaffle_shop_package.stg_orders" + ], + "test.jaffle_shop_package.not_null_stg_orders_order_id.81cfe2fe64": [ + "model.jaffle_shop_package.stg_orders" + ], + "test.jaffle_shop_package.accepted_values_stg_orders_status__placed__shipped__completed__return_pending__returned.080fb20aad": [ + "model.jaffle_shop_package.stg_orders" + ], + "test.jaffle_shop_package.unique_stg_payments_payment_id.3744510712": [ + "model.jaffle_shop_package.stg_payments" + ], + "test.jaffle_shop_package.not_null_stg_payments_payment_id.c19cc50075": [ + "model.jaffle_shop_package.stg_payments" + ], + "test.jaffle_shop_package.accepted_values_stg_payments_payment_method__credit_card__coupon__bank_transfer__gift_card.3c3820f278": [ + "model.jaffle_shop_package.stg_payments" + ], + "model.jaffle_shop_package.dim_downstream_model_dependent_on_source": [ + "source.jaffle_shop_package.jaffle_shop.customers" + ], + "model.jaffle_shop_package.mart_downstream_model_dependent_on_source": [ + "source.jaffle_shop_package.jaffle_shop.customers" + ], + "model.jaffle_shop_package.int_downstream_model_dependent_on_source": [ + "source.jaffle_shop_package.jaffle_shop.customers" + ], + "model.jaffle_shop_package.customers_downstream": [ + "model.jaffle_shop_package.customers" + ], + "model.jaffle_shop_package.joining_of_upstream_contexts": [ + "model.jaffle_shop_package.customers", + "model.jaffle_shop_package.customers_downstream" + ], + "model.jaffle_shop_package.multiple_sources_joined": [ + "source.jaffle_shop_package.stripe.stripe_customers", + "source.jaffle_shop_package.stripe.stripe_daily_rate" + ], + "model.jaffle_shop_package.source_fanout1": [ + "source.jaffle_shop_package.stripe.stripe_customers" + ], + "model.jaffle_shop_package.source_fanout2": [ + "source.jaffle_shop_package.stripe.stripe_customers" + ], + "model.jaffle_shop_package.stg_depends_on_stg": [ + "model.jaffle_shop_package.stg_depends_on_downstream" + ], + "model.jaffle_shop_package.stg_depends_on_downstream": [ + "model.jaffle_shop_package.fct_downstream_model_dependent_on_source" + ], + "model.jaffle_shop_package.fct_downstream_model_dependent_on_source": [ + "source.jaffle_shop_package.jaffle_shop.customers" + ], + "source.jaffle_shop_package.jaffle_shop.daily_rate": [], + "source.jaffle_shop_package.jaffle_shop.customers": [], + "source.jaffle_shop_package.stripe.stripe_daily_rate": [], + "source.jaffle_shop_package.stripe.stripe_customers": [] + }, + "child_map": { + "model.jaffle_shop_package.hard_coded": [], + "model.jaffle_shop_package.customers": [ + "model.jaffle_shop_package.customers_downstream", + "model.jaffle_shop_package.direct_join_to_source", + "model.jaffle_shop_package.joining_of_upstream_contexts", + "test.jaffle_shop_package.not_null_customers_customer_id.5c9bf9911d", + "test.jaffle_shop_package.relationships_orders_customer_id__customer_id__ref_customers_.c6ec7f58f2", + "test.jaffle_shop_package.unique_customers_customer_id.c5af1ff4b1" + ], + "model.jaffle_shop_package.direct_join_to_source": [], + "model.jaffle_shop_package.orders": [ + "test.jaffle_shop_package.accepted_values_orders_status__placed__shipped__completed__return_pending__returned.be6b5b5ec3", + "test.jaffle_shop_package.not_null_orders_amount.106140f9fd", + "test.jaffle_shop_package.not_null_orders_bank_transfer_amount.7743500c49", + "test.jaffle_shop_package.not_null_orders_coupon_amount.ab90c90625", + "test.jaffle_shop_package.not_null_orders_credit_card_amount.d3ca593b59", + "test.jaffle_shop_package.not_null_orders_customer_id.c5f02694af", + "test.jaffle_shop_package.not_null_orders_gift_card_amount.413a0d2d7a", + "test.jaffle_shop_package.not_null_orders_order_id.cf6c17daed", + "test.jaffle_shop_package.relationships_orders_customer_id__customer_id__ref_customers_.c6ec7f58f2", + "test.jaffle_shop_package.unique_orders_order_id.fed79b3a6e" + ], + "model.jaffle_shop_package.stg_customers": [ + "model.jaffle_shop_package.customers", + "test.jaffle_shop_package.not_null_stg_customers_customer_id.e2cfb1f9aa", + "test.jaffle_shop_package.unique_stg_customers_customer_id.c7614daada" + ], + "model.jaffle_shop_package.stg_payments": [ + "model.jaffle_shop_package.customers", + "model.jaffle_shop_package.orders", + "test.jaffle_shop_package.accepted_values_stg_payments_payment_method__credit_card__coupon__bank_transfer__gift_card.3c3820f278", + "test.jaffle_shop_package.not_null_stg_payments_payment_id.c19cc50075", + "test.jaffle_shop_package.unique_stg_payments_payment_id.3744510712" + ], + "model.jaffle_shop_package.stg_orders": [ + "model.jaffle_shop_package.customers", + "model.jaffle_shop_package.orders", + "test.jaffle_shop_package.accepted_values_stg_orders_status__placed__shipped__completed__return_pending__returned.080fb20aad", + "test.jaffle_shop_package.not_null_stg_orders_order_id.81cfe2fe64", + "test.jaffle_shop_package.unique_stg_orders_order_id.e3b841c71a" + ], + "seed.jaffle_shop_package.raw_customers": [ + "model.jaffle_shop_package.stg_customers" + ], + "seed.jaffle_shop_package.raw_orders": [ + "model.jaffle_shop_package.stg_orders" + ], + "seed.jaffle_shop_package.raw_payments": [ + "model.jaffle_shop_package.stg_payments" + ], + "model.elementary.snapshot_run_results": [ + "model.elementary.alerts_dbt_models" + ], + "model.elementary.job_run_results": [], + "model.elementary.model_run_results": [ + "model.elementary.alerts_dbt_models" + ], + "model.elementary.test_result_rows": [], + "model.elementary.elementary_test_results": [ + "model.elementary.alerts_anomaly_detection", + "model.elementary.alerts_dbt_tests", + "model.elementary.alerts_schema_changes", + "model.elementary.test_result_rows" + ], + "model.elementary.dbt_source_freshness_results": [ + "model.elementary.alerts_dbt_source_freshness" + ], + "model.elementary.alerts_dbt_tests": [], + "model.elementary.alerts_schema_changes": [], + "model.elementary.alerts_dbt_source_freshness": [], + "model.elementary.alerts_anomaly_detection": [], + "model.elementary.alerts_dbt_models": [], + "model.elementary.monitors_runs": [], + "model.elementary.metadata": [], + "model.elementary.dbt_tests": [ + "model.elementary.dbt_artifacts_hashes" + ], + "model.elementary.dbt_models": [ + "model.elementary.dbt_artifacts_hashes", + "model.elementary.information_schema_columns", + "model.elementary.model_run_results" + ], + "model.elementary.dbt_sources": [ + "model.elementary.alerts_dbt_source_freshness", + "model.elementary.dbt_artifacts_hashes", + "model.elementary.information_schema_columns" + ], + "model.elementary.dbt_snapshots": [ + "model.elementary.dbt_artifacts_hashes", + "model.elementary.information_schema_columns", + "model.elementary.snapshot_run_results" + ], + "model.elementary.dbt_columns": [ + "model.elementary.dbt_artifacts_hashes", + "model.elementary.enriched_columns" + ], + "model.elementary.enriched_columns": [], + "model.elementary.dbt_invocations": [ + "model.elementary.job_run_results" + ], + "model.elementary.dbt_metrics": [ + "model.elementary.dbt_artifacts_hashes" + ], + "model.elementary.dbt_seeds": [ + "model.elementary.dbt_artifacts_hashes", + "model.elementary.information_schema_columns" + ], + "model.elementary.dbt_artifacts_hashes": [], + "model.elementary.dbt_run_results": [ + "model.elementary.model_run_results", + "model.elementary.snapshot_run_results" + ], + "model.elementary.information_schema_columns": [ + "model.elementary.enriched_columns" + ], + "model.elementary.dbt_exposures": [ + "model.elementary.dbt_artifacts_hashes" + ], + "model.elementary.metrics_anomaly_score": [ + "model.elementary.anomaly_threshold_sensitivity" + ], + "model.elementary.anomaly_threshold_sensitivity": [], + "model.elementary.schema_columns_snapshot": [], + "model.elementary.data_monitoring_metrics": [ + "model.elementary.metrics_anomaly_score", + "model.elementary.monitors_runs" + ], + "operation.elementary.elementary-on-run-start-0": [], + "operation.elementary.elementary-on-run-end-0": [], + "test.jaffle_shop_package.unique_customers_customer_id.c5af1ff4b1": [], + "test.jaffle_shop_package.not_null_customers_customer_id.5c9bf9911d": [], + "test.jaffle_shop_package.unique_orders_order_id.fed79b3a6e": [], + "test.jaffle_shop_package.not_null_orders_order_id.cf6c17daed": [], + "test.jaffle_shop_package.not_null_orders_customer_id.c5f02694af": [], + "test.jaffle_shop_package.relationships_orders_customer_id__customer_id__ref_customers_.c6ec7f58f2": [], + "test.jaffle_shop_package.accepted_values_orders_status__placed__shipped__completed__return_pending__returned.be6b5b5ec3": [], + "test.jaffle_shop_package.not_null_orders_amount.106140f9fd": [], + "test.jaffle_shop_package.not_null_orders_credit_card_amount.d3ca593b59": [], + "test.jaffle_shop_package.not_null_orders_coupon_amount.ab90c90625": [], + "test.jaffle_shop_package.not_null_orders_bank_transfer_amount.7743500c49": [], + "test.jaffle_shop_package.not_null_orders_gift_card_amount.413a0d2d7a": [], + "test.jaffle_shop_package.unique_stg_customers_customer_id.c7614daada": [], + "test.jaffle_shop_package.not_null_stg_customers_customer_id.e2cfb1f9aa": [], + "test.jaffle_shop_package.unique_stg_orders_order_id.e3b841c71a": [], + "test.jaffle_shop_package.not_null_stg_orders_order_id.81cfe2fe64": [], + "test.jaffle_shop_package.accepted_values_stg_orders_status__placed__shipped__completed__return_pending__returned.080fb20aad": [], + "test.jaffle_shop_package.unique_stg_payments_payment_id.3744510712": [], + "test.jaffle_shop_package.not_null_stg_payments_payment_id.c19cc50075": [], + "test.jaffle_shop_package.accepted_values_stg_payments_payment_method__credit_card__coupon__bank_transfer__gift_card.3c3820f278": [], + "model.jaffle_shop_package.dim_downstream_model_dependent_on_source": [], + "model.jaffle_shop_package.mart_downstream_model_dependent_on_source": [], + "model.jaffle_shop_package.int_downstream_model_dependent_on_source": [], + "model.jaffle_shop_package.customers_downstream": [ + "model.jaffle_shop_package.joining_of_upstream_contexts" + ], + "model.jaffle_shop_package.joining_of_upstream_contexts": [], + "model.jaffle_shop_package.multiple_sources_joined": [], + "model.jaffle_shop_package.source_fanout1": [], + "model.jaffle_shop_package.source_fanout2": [], + "model.jaffle_shop_package.stg_depends_on_stg": [], + "model.jaffle_shop_package.stg_depends_on_downstream": [ + "model.jaffle_shop_package.stg_depends_on_stg" + ], + "model.jaffle_shop_package.fct_downstream_model_dependent_on_source": [ + "model.jaffle_shop_package.stg_depends_on_downstream" + ], + "source.jaffle_shop_package.jaffle_shop.daily_rate": [], + "source.jaffle_shop_package.jaffle_shop.customers": [ + "model.jaffle_shop_package.dim_downstream_model_dependent_on_source", + "model.jaffle_shop_package.direct_join_to_source", + "model.jaffle_shop_package.fct_downstream_model_dependent_on_source", + "model.jaffle_shop_package.int_downstream_model_dependent_on_source", + "model.jaffle_shop_package.mart_downstream_model_dependent_on_source" + ], + "source.jaffle_shop_package.stripe.stripe_daily_rate": [ + "model.jaffle_shop_package.multiple_sources_joined" + ], + "source.jaffle_shop_package.stripe.stripe_customers": [ + "model.jaffle_shop_package.multiple_sources_joined", + "model.jaffle_shop_package.source_fanout1", + "model.jaffle_shop_package.source_fanout2" + ] + }, + "group_map": {}, + "saved_queries": {}, + "semantic_models": {} +} \ No newline at end of file diff --git a/tests/test_datapilot.py b/tests/test_datapilot.py deleted file mode 100644 index e6b795dd..00000000 --- a/tests/test_datapilot.py +++ /dev/null @@ -1,11 +0,0 @@ -from click.testing import CliRunner - -from datapilot.cli import main - - -def test_main(): - runner = CliRunner() - result = runner.invoke(main, []) - - assert result.output == "()\n" - assert result.exit_code == 0 diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py new file mode 100644 index 00000000..6b7b3dc4 --- /dev/null +++ b/tests/utils/test_utils.py @@ -0,0 +1,17 @@ +import pytest + +from datapilot.utils.utils import extract_folders_in_path + +test_cases = [ + ("/home/user/documents/file.txt", ["home", "user", "documents"]), + ("/home/user/documents/", ["home", "user", "documents"]), + ("/home/user/documents", ["home", "user", "documents"]), + ("", []), + ("/", []), + ("file.txt", []), +] + + +@pytest.mark.parametrize("input_path,expected", test_cases) +def test_extract_folders_in_path(input_path, expected): + assert extract_folders_in_path(input_path) == expected