{"id":22793346,"url":"https://github.com/fivetran/dbt_salesforce_formula_utils","last_synced_at":"2025-10-24T16:47:43.852Z","repository":{"id":38297018,"uuid":"362256079","full_name":"fivetran/dbt_salesforce_formula_utils","owner":"fivetran","description":"Package containing dbt macros to help generate salesforce formula fields synced from Fivetran.","archived":false,"fork":false,"pushed_at":"2025-07-22T16:03:21.000Z","size":1749,"stargazers_count":18,"open_issues_count":8,"forks_count":20,"subscribers_count":46,"default_branch":"main","last_synced_at":"2025-08-08T21:33:17.886Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://fivetran.github.io/dbt_salesforce_formula_utils/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fivetran.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-04-27T21:30:07.000Z","updated_at":"2025-07-14T20:01:17.000Z","dependencies_parsed_at":"2023-02-01T17:30:29.487Z","dependency_job_id":"3a77d765-e480-46ac-8d19-9179d6833978","html_url":"https://github.com/fivetran/dbt_salesforce_formula_utils","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/fivetran/dbt_salesforce_formula_utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_salesforce_formula_utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_salesforce_formula_utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_salesforce_formula_utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_salesforce_formula_utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fivetran","download_url":"https://codeload.github.com/fivetran/dbt_salesforce_formula_utils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_salesforce_formula_utils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280833009,"owners_count":26398970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-24T02:00:06.418Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-12T03:19:33.169Z","updated_at":"2025-10-24T16:47:43.822Z","avatar_url":"https://github.com/fivetran.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fivetran Salesforce Formula Utils\n\n\u003cp align=\"left\"\u003e\n    \u003ca alt=\"License\"\n        href=\"https://github.com/fivetran/dbt_salesforce_formula_utils/blob/main/LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"dbt-core\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/dbt_Core™_version-\u003e=1.3.0_\u003c2.0.0-orange.svg\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"Maintained?\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Maintained%3F-yes-green.svg\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"PRs\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Contributions-welcome-blueviolet\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## What does this dbt package do?\nThis package includes macros and scipts to be used within a dbt project to accurately map Salesforce Formulas to existing tables. It is designed to work with data from [Fivetran's Salesforce connector](https://fivetran.com/docs/applications/salesforce) in the format described by [this ERD](https://fivetran.com/docs/applications/salesforce#schema).\n\n\u003e Note: this package is distinct from the [Salesforce dbt package](https://github.com/fivetran/dbt_salesforce), which _transforms_ Salesforce data and outputs analytics-ready end models.\n\u003e Additionally, please this solution **does not support** formula field history mode. The formula fields recreated from this package will only use the most recent formula available in your Salesforce environment.\n\n## How do I use the dbt package?\n### Step 1: Prerequisites\nTo use this dbt package, you must have the following:\n- At least one Fivetran Salesforce connection syncing data into your destination.\n- A **BigQuery**, **Snowflake**, **Redshift**, **PostgreSQL**, or **Databricks** destination.\n\n### Step 2: Install the package\nThe [`sfdc_formula_view`](https://github.com/fivetran/dbt_salesforce_formula_utils#sfdc_formula_view-source) macro is intended to be leveraged within a dbt project that uses the source tables from Fivetran's Salesforce connector. To leverage the macro, you will add the below configuration to your `packages.yml` file (if you do not have a `packages.yml` file, create one in your root dbt project).\n\u003e TIP: Check [dbt Hub](https://hub.getdbt.com/) for the latest installation instructions or [read the dbt docs](https://docs.getdbt.com/docs/package-management) for more information on installing packages.\n```yml\npackages:\n  - package: fivetran/salesforce_formula_utils\n    version: [\"\u003e=0.10.0\", \"\u003c0.11.0\"] # we recommend using ranges to capture non-breaking changes automatically\n```\n\n### Step 3: Define required source tables\nIn order to use the macros included in this package, you will need to have a properly configured Salesforce source named `salesforce` in your own dbt project. An example of a properly configured Salesforce source yml can be found in the `src_salesforce.yml` file in [integration_tests](https://github.com/fivetran/dbt_salesforce_formula_utils/blob/main/integration_tests/models/src_fivetran_formula.yml). This integration_tests folder is just for testing purposes - your source file will need to be in the models folder of your root dbt project. You are welcome to copy/paste the [example](https://github.com/fivetran/dbt_salesforce_formula_utils/blob/main/integration_tests/models/src_fivetran_formula.yml) source configuration into your `src_salesforce.yml` file and modify for your use case.\n\nIn particular, you will need the following sources defined in your `src_salesforce.yml` file:\n```yml\nversion: 2\n\nsources:\n  - name: salesforce # It would be best to keep this named salesforce\n    schema: \"{{ var('salesforce_schema', 'salesforce') }}\" # Configure the salesforce_schema var from your dbt_project.yml (alternatively you can hard-code the schema here if only using one Salesforce connection)\n    # Add the database where your Salesforce data resides if different from the target database. Eg. 'my_salesforce_database'. By default the target.database is used.\n    tables:\n      - name: fivetran_formula_model\n        description: Contains SQL models produced by Fivetran Salesforce connector\n\n      ## Any other source tables you are creating models for should be defined here as well. They aren't required, but it is best organizational practice and allows Fivetran to compile data lineage graphs\n```\n\n### Step 4: Create models\n#### Generate models using connector-made query\n\nTo create a model that includes all formula fields:\n1. Create a new file in your models folder and name it `your_table_name_here.sql` (e.g. `customer.sql`; this is not necessary but recommended as best practice).\n2. Add the below snippet calling the [`sfdc_formula_view`](https://github.com/fivetran/dbt_salesforce_formula_utils#sfdc_formula_view-source) macro into the file. Update the `source_table` argument to be the source table name for which you are generating the model (e.g. `customer`).\n```sql\n{{ salesforce_formula_utils.sfdc_formula_view(source_table='your_source_table_name_here') }}\n```\n\n**Output**: All formulas for the chosen source table will be included in the resulting `select` statement.\n\n\n#### Automate model creation\nIf you have multiple models you need to create, you can also leverage the [sfdc_formula_model_automation](https://github.com/fivetran/dbt_salesforce_formula_utils#sfdc_formula_model_automationsh-source) script within this project to automatically create models locally via the command line. Below is an example command to copy and edit.\n\n```bash\nsource dbt_packages/salesforce_formula_utils/sfdc_formula_model_automation.sh \"../path/to/directory\" \"desired_table_1,desired_table_2,desired_table_infinity\"\n```\n\n**Output**: Model files for each table, populated with `{{ salesforce_formula_utils.sfdc_formula_view(source_table='table_name') }}`.\n\n\u003e Note: In order for this command to work, you must currently be within the root directory of your dbt project.\n\n\n### Step 5: Execute models\nOnce you have created all your desired models and copied/modified the sql snippet into each model you will execute `dbt deps` to install the macro package, then execute `dbt run` to generate the models. Additionally, you can reference the [integration_tests](https://github.com/fivetran/dbt_salesforce_formula_utils/tree/main/integration_tests/models) folder for examples on how to use the macro within your models.\n\n### (Optional) Step 6: Orchestrate your models with Fivetran Transformations for dbt Core™\n\u003cdetails\u003e\u003csummary\u003eExpand to view details\u003c/summary\u003e\n\u003cbr\u003e\n    \nFivetran offers the ability for you to orchestrate your dbt project through [Fivetran Transformations for dbt Core™](https://fivetran.com/docs/transformations/dbt). Learn how to set up your project for orchestration through Fivetran in our [Transformations for dbt Core setup guides](https://fivetran.com/docs/transformations/dbt#setupguide).\n\u003c/details\u003e\n\n## Macro \u0026 script documentation\n\n### sfdc_formula_view ([source](https://github.com/fivetran/dbt_salesforce_formula_utils/blob/main/macros/sfdc_formula_view.sql))\nThis macro generates the final sql needed to join the Salesforce formula fields to the desired table.\n\n**Usage:**\n```sql\n{{ salesforce_formula_utils.sfdc_formula_view(source_table='fivetran_sfdc_example_table') }}\n```\n**Args:**\n* `source_table` (required): The table with which you are joining the formula fields.\n* `source_name` (optional, default = `'salesforce'`): The dbt source containing the table you want to join with formula fields (as defined [here](https://github.com/fivetran/dbt_salesforce_formula_utils/tree/main#step-3-define-required-source-tables)). Must contain the `fivetran_formula_model` table.\n* `using_quoted_identifiers` (optional, default = `false`): For warehouses with case sensitivity enabled this argument **must** be set to `true` in order for the underlying macros within this project to properly compile and execute successfully.\n* `materialization` (optional, default = `view`): By default the model will be materialized as a view. If you would like to materialize as a table, you can adjust using this argument.\n----\n\n### sfdc_formula_model_automation.sh ([source](https://github.com/fivetran/dbt_salesforce_formula_utils/blob/main/sfdc_formula_model_automation.sh))\nThis bash script is intended to be used in order to automatically create the desired salesforce models via the command line within your dbt project. This bash script will generate a model file within your dbt project that contains the [sfdc_formula_view](https://github.com/fivetran/dbt_salesforce_formula_utils/blob/main/macros/sfdc_formula_view.sql) macro for the appropriately defined table(s). In order for this command to work you must be within the root directory of your dbt project. Note that this script is designed for dbt Core and is **not** compatible with dbt Cloud.\n\n**Usage:**\n```bash\nsource dbt_packages/salesforce_formula_utils/sfdc_formula_model_automation.sh \"../path/to/directory\" \"desired_table(s)\"\n```\n\n**Example**\nAssuming the path to your directory is `\"../dbt_salesforce\"` and the table(s) you want to generate the model for are `opportunity` and `account`.\n```bash\nsource dbt_packages/salesforce_formula_utils/sfdc_formula_model_automation.sh \"../dbt_salesforce\" \"opportunity,account\"\n```\n\n## Does this package have dependencies?\nThis dbt package is dependent on the following dbt packages. These dependencies are installed by default within this package. For more information on the following packages, refer to the [dbt hub](https://hub.getdbt.com/) site.\n\u003e IMPORTANT: If you have any of these dependent packages in your own `packages.yml` file, we highly recommend that you remove them from your root `packages.yml` to avoid package version conflicts.\n```yml\npackages:\n    - package: fivetran/fivetran_utils\n      version: [\"\u003e=0.4.0\", \"\u003c0.5.0\"]\n\n    - package: dbt-labs/dbt_utils\n      version: [\"\u003e=1.0.0\", \"\u003c2.0.0\"]\n```\n\n## How is this package maintained and can I contribute?\n### Package Maintenance\nThe Fivetran team maintaining this package _only_ maintains the latest version of the package. We highly recommend that you stay consistent with the [latest version](https://hub.getdbt.com/fivetran/salesforce_formula_utils/latest/) of the package and refer to the [CHANGELOG](https://github.com/fivetran/dbt_salesforce_formula_utils/blob/main/CHANGELOG.md) and release notes for more information on changes across versions.\n\n### Contributions\nA small team of analytics engineers at Fivetran develops these dbt packages. However, the packages are made better by community contributions.\n\nWe highly encourage and welcome contributions to this package. Check out [this dbt Discourse article](https://discourse.getdbt.com/t/contributing-to-a-dbt-package/657) to learn how to contribute to a dbt package.\n\n## Are there any resources available?\n- If you have questions or want to reach out for help, see the [GitHub Issue](https://github.com/fivetran/dbt_salesforce_formula_utils/issues/new/choose) section to find the right avenue of support for you.\n- If you would like to provide feedback to the dbt package team at Fivetran or would like to request a new dbt package, fill out our [Feedback Form](https://www.surveymonkey.com/r/DQ7K7WW).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivetran%2Fdbt_salesforce_formula_utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffivetran%2Fdbt_salesforce_formula_utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivetran%2Fdbt_salesforce_formula_utils/lists"}