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 nameSupported
Column HashingTrueField level
BlockingTrueField level
IncrementalTrue
Custom dataFalse
HistoryFalse
ReSyncTrueTable level
TemplatesTrue

Data Schema

Open full-page schema explorer

Setup Guide - ELT

Step 1 - Begin Configuration

  1. In the connector setup form, enter the destination schema name of your choice.
  2. 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

  1. Select how often you would like the data to sync.
  2. Choose a start date to limit how far back the initial sync goes.
  3. 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

SettingDescription
Table nameName of the table in your warehouse. Lower-cased, with spaces and punctuation replaced by _: Daily sales (EU) is daily_sales_eu.
Subject patternOptional regular expression matched against the email subject.
Sender patternOptional regular expression matched, case-insensitively, against the sender's email address.
LabelOptional. Only emails with this Gmail label are matched.
Attachment filename patternOptional 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 typeCSV or Excel (XLSX).
CSV delimiterDetected from the file if empty.
CSV lines to skipNumber 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.

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:

ColumnDescription
_message_idID of the Gmail message the attachment came from.
_part_idID of the attachment within the message.
_filenameFilename of the attachment.
_received_atWhen the email was received.
_lineRow number within the attachment.
_sheet_nameSheet 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.

Pre-requisites

  1. You first must set up a connection to Gmail via OAuth.
  2. You must publish your SQL model containing the data that you want to send.

Step 1 - Begin Configuration

  1. Click on the Reverse ETL button in the side bar and click + New on the top right.
  2. Select the Gmail connector from the drop down menu or else click + Add new connection to authorize the connector.

Step 2 - Destination Settings

  1. Recipient email address(es): Enter the email address(es) that should receive the file attachment.
  2. File type: Choose the format of the generated file — CSV, Parquet, NDJSON, or JSON array.
  3. Compression: Optionally compress the file with Gzip. Not available for Parquet, since it is already internally compressed.

Step 3 - Model

  1. Choose the SQL model that contains the data you would like to send.
  2. 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.


SQL Templates

View all →

Was this page helpful?