Gmail
Gmail is Google's email service. With Weld, you can sync your mailbox — profile, labels, threads, and messages — into your data warehouse for reporting and analysis, and load recurring report attachments, like a daily CSV or Excel export, into tables of their own. Weld also supports Reverse ETL to send your model data as an email attachment from your connected Gmail account.
| Feature name | Supported | |
|---|---|---|
| Column Hashing | True | Field level |
| Blocking | True | Field level |
| Incremental | True | |
| Custom data | False | |
| History | False | |
| ReSync | True | Table level |
| Templates | True |
Data Schema
Setup Guide - ELT
Prerequisites
Access to the Gmail account you want to sync data from.
Step 1 - Begin Configuration
- In the connector setup form, enter the destination schema name of your choice.
- Click Authorize to allow Weld to access your Gmail account using OAuth. You will be redirected to your Google account.
Step 2 - Grant access to Weld
Click Grant Access to allow Weld read-only access to your Gmail account. When authorization is complete, you will be redirected back to the Weld connections overview.
Step 3 - Data To Sync
Select the tables you wish to include in the sync:
- Profile — your mailbox's email address and message/thread counters.
- Label — all labels in your mailbox, including system and custom labels.
- Thread — all email threads in your mailbox.
- Message — all messages in your mailbox, including labels, classification labels, and the full MIME payload (parts and headers).
- Attachment tables — one table per entry you add under Attachment tables in the sync's settings. See Syncing email attachments.
You can view the schema, remove columns, or hash sensitive information.
Step 4 - Configure Sync
- Select how often you would like the data to sync.
- Choose a start date to limit how far back the initial sync goes.
- Check the Destination schema name, which is where the tables land in your warehouse, and click Start Initial Sync.
Weld will take over from here and commence syncing data from your Gmail account.
Syncing email attachments
Gmail can load the CSV or Excel files attached to recurring emails, like a daily report sent by another tool, into tables in your warehouse. Each entry under Attachment tables in the sync's settings becomes one table, which collects the rows of every attachment that matches its rules.
Attachment table settings
| Setting | Description |
|---|---|
| Table name | Name of the table in your warehouse. Lower-cased, with spaces and punctuation replaced by _: Daily sales (EU) is daily_sales_eu. |
| Subject pattern | Optional regular expression matched against the email subject. |
| Sender pattern | Optional regular expression matched, case-insensitively, against the sender's email address. |
| Label | Optional. Only emails with this Gmail label are matched. |
| Attachment filename pattern | Optional regular expression matched against the attachment's filename. If empty, every attachment with the file type's extension (.csv, or .xlsx/.xls) is loaded. |
| File type | CSV or Excel (XLSX). |
| CSV delimiter | Detected from the file if empty. |
| CSV lines to skip | Number of lines before the header row to skip. |
An email matches when it satisfies every rule that is set, so a table with no subject pattern, sender pattern, or label collects every attachment of its file type. Use one table per recurring report, where every file has the same columns.
The table name must be unique within the sync and can't be the name of one of Gmail's own tables, such as message or label.
While you edit the settings, Weld shows the newest emails that match each table's rules, with the matching attachment filenames, so you can check a pattern before you save. An invalid regular expression is flagged as you type it.
Table schema
A table's columns come from the header row of its newest matching attachment that has any data rows, so you can only add the table once at least one matching email has arrived. Column names are cleaned the same way as for file connectors, and every column is loaded as a string.
Each row also carries these columns:
| Column | Description |
|---|---|
_message_id | ID of the Gmail message the attachment came from. |
_part_id | ID of the attachment within the message. |
_filename | Filename of the attachment. |
_received_at | When the email was received. |
_line | Row number within the attachment. |
_sheet_name | Sheet the row came from. Excel attachments only. |
The primary key is _message_id, _part_id, and _line, so each attachment's rows are kept separately and re-reading an email never duplicates them.
How attachments are synced
- The first sync reads every matching email since the sync's start date. Later syncs read emails received since the previous sync, plus an hour of overlap, because Gmail can list a message a little after it was received. The overlap is merged away on the primary key.
- Emails are read oldest first.
- Gmail's own tables and the attachment tables are independent: you can sync attachments without selecting Message, and the reverse.
Setup Guide - Reverse ETL
Gmail reverse ETL allows you to sync data on a schedule from your Weld App automatically into your Gmail account, sending it as an email attachment.
Every sync generates a single file containing the full result of your model and sends it as an attachment from your connected Gmail account. There is no concept of inserting, updating, or upserting individual rows — each run is a fresh Mirror of your data.
Pre-requisites
- You first must set up a connection to Gmail via OAuth.
- You must publish your SQL model containing the data that you want to send.
Step 1 - Begin Configuration
- Click on the Reverse ETL button in the side bar and click + New on the top right.
- Select the Gmail connector from the drop down menu or else click + Add new connection to authorize the connector.
Step 2 - Destination Settings
- Recipient email address(es): Enter the email address(es) that should receive the file attachment.
- File type: Choose the format of the generated file —
CSV,Parquet,NDJSON, orJSON array. - Compression: Optionally compress the file with
Gzip. Not available forParquet, since it is already internally compressed.
Step 3 - Model
- Choose the SQL model that contains the data you would like to send.
- Map the model columns to the file columns. Every column will be included as is, the column name and type will be preserved to the extent the file format allows.
Step 4 - Sync Operation
Gmail only supports Mirror: every sync sends a new email with a fresh file attachment containing all of the data from your model.
There is a size limit on email attachments. If your model is too large to attach, reduce the amount of data or filter the model before sending.