> AI agents: this is one page from Mammoth Analytics documentation. The index of all pages as Markdown is https://mammoth.io/docs/llms.txt. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get Markdown.

# Salesforce + your data warehouse

> Send cleaned Salesforce data to Snowflake, BigQuery, Redshift or another warehouse with Mammoth, using Replace, Combine or Merge on a daily refresh.

This guide is for data engineers and BI developers who want a clean, queryable version of their CRM data in a data warehouse, without the messy field names, polymorphic IDs, and inconsistent stage values that come out of Salesforce directly. Mammoth sits between Salesforce and the warehouse to handle the transformation, so you control what lands there.

This guide uses **Snowflake** as the worked example. Mammoth exports to Snowflake with the same three write modes (Replace, Combine and Merge) as Google BigQuery, PostgreSQL, MySQL, SQL Server, Amazon Redshift and Databricks, so the steps carry over if one of those is your warehouse. Snowflake export is open to every plan.

![Salesforce data runs through a Mammoth pipeline; Send to Destinations writes to BigQuery, PostgreSQL, SQL Server or Redshift.](https://mammoth.io/docs/images/20260805_053457_architecture-salesforce-warehouse1.webp)



## What you will build

- A Salesforce dataset pulling Opportunities, Accounts, and Users
- A transformation pipeline: field selection, normalization, derived metrics
- A [Send to destinations](https://mammoth.io/docs/learn/share-and-export/send-to-destinations/) task writing to Snowflake (or BigQuery, PostgreSQL, MySQL, SQL Server, Redshift or Databricks)
- A [Dataset Refresh automation](https://mammoth.io/docs/learn/automate/refresh-a-dataset/) keeping the warehouse table fresh daily

## Step 1: Connect Salesforce

Follow the [Salesforce connector guide](https://mammoth.io/docs/learn/get-data-in/connectors/salesforce/) to authenticate and create your dataset, selecting `Opportunity`, `Account`, and `User` (for owner names).

**Field selection:** Salesforce Opportunity objects have 100+ fields. For the warehouse, keep only what downstream analytics will use. This reduces transfer time and keeps the destination table clean:

- `Id`, `Name`, `StageName`, `Amount`, `CloseDate`, `Probability`
- `OwnerId`, `AccountId`, `CreatedDate`, `LastModifiedDate`
- `LeadSource`, `Type`, `ForecastCategoryName`
- Any custom fields your team uses for qualification or segmentation

Use [Remove Column](https://mammoth.io/docs/learn/clean-and-shape/manage-columns/) to drop everything else before transformation begins.

## Step 2: Transform

### Normalize stage names

[Bulk Replace](https://mammoth.io/docs/learn/clean-and-shape/filter-rows/) on `StageName` to map all variants to canonical stages. This is the most impactful transformation, because downstream SQL becomes `WHERE StageName = 'Closed Won'` instead of a multi-value `IN` clause.

### Flatten owner information

Bring in readable owner details from the User object with [Join](https://mammoth.io/docs/learn/clean-and-shape/join/) on `OwnerId` ↔ `User.Id`:

- Bring in `User.Name` as `OwnerName`
- Bring in `User.Region` (or a custom territory field) as `OwnerRegion`

### Add derived metrics

Using [Math Function](https://mammoth.io/docs/learn/clean-and-shape/dates/):

- `DaysToClose = CloseDate - CreatedDate`: for historical pipeline velocity analysis
- `AgeInStage = TODAY() - LastModifiedDate`: for stale deal identification

## Step 3: Configure the warehouse destination

1. In your pipeline, open [Send to destinations](https://mammoth.io/docs/learn/share-and-export/send-to-destinations/) and choose **Snowflake** under **External Destinations** (or Google BigQuery, PostgreSQL, MySQL, SQL Server, Amazon Redshift or Databricks if that is your warehouse).
2. Enter the target table name, for example `sf_opportunities_clean`.
3. Choose the write mode:

| Write mode | Behavior | Use when |
| --- | --- | --- |
| **Replace** | Deletes all existing rows and inserts fresh data every run | Full refresh: simplest and always consistent, but slower for very large tables |
| **Combine** | Appends new rows without touching existing ones | Building history over time |
| **Merge** | Updates rows matching a reference column, inserts rows with no match | Keeping a current-state table in sync |

For Salesforce Opportunities: **Merge on** `Id` is usually the right choice—it keeps the table current without duplicating records that have not changed. Merge requires you to select `Id` as the **Reference column** in the destination form.

Every warehouse destination uses the same Send to destinations flow with its own connection fields. See the [destination reference](https://mammoth.io/docs/learn/share-and-export/send-to-destinations/) for each one's exact form.

## Step 4: Schedule the refresh

Add a [Dataset Refresh automation](https://mammoth.io/docs/learn/automate/refresh-a-dataset/) on the Salesforce dataset. Daily, before business hours, is a common cadence for warehouse syncs. Check the Automation list for run status, since a failed run means downstream queries and dashboards are working off stale data.

**Incremental considerations:** For large Salesforce orgs (100k+ opportunities), a full daily pull may be slow. Add a [Conditional Filter](https://mammoth.io/docs/learn/clean-and-shape/filter-rows/) on `LastModifiedDate` to keep only records changed in roughly the last 48 hours. Combined with Merge write mode at the destination, this keeps the warehouse table current without re-processing unchanged records every run.

## Query the table in Snowflake

Once the data lands in Snowflake, your team can query it directly:

```sql
-- Pipeline velocity by quarter
SELECT
  DATE_TRUNC('QUARTER', CloseDate) AS quarter,
  OwnerRegion,
  COUNT(*) AS deals,
  SUM(Amount) AS total_acv,
  AVG(DaysToClose) AS avg_days_to_close
FROM analytics.salesforce.sf_opportunities_clean
WHERE StageName = 'Closed Won'
GROUP BY 1, 2
ORDER BY 1 DESC;
```

## Common issues

| Issue | Cause | Fix |
| --- | --- | --- |
| Destination write fails (permission error) | Mammoth's warehouse user lacks write/create permissions on the target table | Grant INSERT/CREATE TABLE (or your warehouse's equivalent) to the Mammoth-connected role |
| Merge fails | Reference column does not exist in both the View and the destination table, or types don't match | Confirm `Id` exists in both with compatible types |
| Salesforce fields missing at the destination | Field-level security on the Salesforce integration user | Grant field visibility in the Salesforce profile |
| Destination not updating after pipeline runs | Auto-sync is off on the View or the destination | Check Auto-sync on both; see [Send to destinations troubleshooting](https://mammoth.io/docs/learn/share-and-export/hold-exports-for-review/#troubleshooting-exports) |

---
Source: https://mammoth.io/docs/guides/integrations/salesforce-snowflake.md · Updated: 2026-11-02
