Load Parquet, CSV, JSON and Avro files from an S3 bucket into warehouse tables, and keep them current as new files arrive.
Amazon S3 is in beta. Point Contrast at a location in a bucket, describe the files to load, and each group of files becomes a warehouse table. Every sync loads the files that arrived since the last one.
You need the S3 location (s3://bucket/path) and the bucket's region. Contrast lists and reads objects under that path only. It never writes, tags or deletes an object.
Contrast can read as a cross-account IAM role in your account (recommended) or with an access key.
In the connect form, choose Cross-account role. The form shows the Contrast principal and your workspace's external ID, and fills in both policies below for your location.
In IAM, create a role with this trust policy. Only Contrast can assume it, and only for your workspace, because the policy requires your workspace's external ID (contrast-<workspace ID>).
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "AWS": "<Contrast principal from the form>" },
"Action": "sts:AssumeRole",
"Condition": { "StringEquals": { "sts:ExternalId": "<external ID from the form>" } }
}
]
}Attach this permissions policy to the role. For the location s3://lake-bucket/raw:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::lake-bucket",
"Condition": { "StringLike": { "s3:prefix": ["raw/*"] } }
},
{
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::lake-bucket/raw/*"
}
]
}If the bucket uses SSE-KMS with a customer managed key, also allow kms:Decrypt on that key.
Paste the role ARN into the form. The role must belong to your AWS account; Contrast refuses roles in its own account. The external ID is set by Contrast and can't be changed in the form, so another workspace can't reuse your role.
Create an IAM user with the permissions policy above, create an access key for it, and paste the access key ID and secret access key. A session token is accepted for temporary credentials, which stop working when the session expires. Keep the user read-only and rotate its key.
You need to be a workspace administrator to start a sync. Editors can connect the bucket.
When you connect, Contrast checks that it can sign in, list the location and read a file. Credentials are stored encrypted and are never shown again.
A dataset is one table, files.<name>, loaded from the files its pattern matches. Start with one and add more for other file groups in the same location. The same file can belong to two datasets, and each loads it separately.
| Setting | What it does |
|---|---|
| Name | The table name: lowercase letters, digits and underscores, starting with a letter, at most 63 characters. |
| Pattern | Which files belong to the table, relative to the location. * and ? match within one folder, ** matches across folders, and {a,b} and [a-z] match a set. events/**/*.parquet matches every Parquet file at any depth under events/. |
| Format | Parquet, CSV, JSON or Avro. |
| Compression | For CSV and JSON: from the file extension (the default), none, gzip, Zstandard or bzip2. Parquet and Avro files carry their own compression. |
| CSV options | Delimiter, whether the first row holds column names, quote character, escape character (by default a doubled quote reads as one quote), null values, encoding, rows to skip before the header, and a comment character. |
| JSON layout | Detect (the default), one object per line, or one array per file. |
| Row keys | File and row number (the default) keeps every row of every file. Key columns merges rows by the columns you name, so a later row replaces an earlier one with the same key. |
| When a file has bad data | Keep the row (the default) loads the row and moves values that don't fit to _rescued_data. Skip the file stops loading a file at its first bad value and records it as failed; rows already saved from earlier parts of a large file stay in the table. Stop the sync stops the table's sync at the first bad value. |
| Lookback | How far behind the last sync a file's timestamp can be and still load: 1 to 720 hours, 168 (a week) by default. See How new files are found. |
The connect form says in plain words what each pattern matches. Contrast skips paths with a folder or file name that starts with _ or . (such as _SUCCESS, _temporary/ and .crc files), so a pattern that names one matches nothing.
Select Preview on a dataset to see what it would load before you save it. Contrast lists up to 10,000 objects under the location and reads up to 32 MB for at most 20 seconds. It samples up to 3 matching files and shows up to 20 rows. The preview shows:
_rescued_data, a Delta or Iceberg table under the location, and a note when a limit cut the preview short.A preview reads files but loads nothing and creates no table.
Select Suggest datasets on the location to have Contrast look at what is there. It groups files by their leading folders and file extension and proposes up to 50 datasets, each with a pattern and format. Keep the ones you want, change them as needed, and preview them like any other dataset.
You can change a connected bucket's datasets after the first save. You need to be a workspace administrator to do this. The location stays the one you connected, and every pattern is read under it. To read another location, connect it as a new source.
Every table has these columns besides the file's own:
| Column | Type | Contents |
|---|---|---|
_row_id | string | A hash of the file's key and the row number. The primary key when rows are keyed by file and row number. |
_file_path | string | The file's key in the bucket |
_file_row_number | long | The row's position in its file, counting from 0 |
_file_last_modified | timestamp with time zone | When the file's content was written |
_rescued_data | string | Values that didn't fit, as JSON text with the reason; null for clean rows |
A data column whose name matches one of these is renamed with a data_ prefix. Folder names in the form key=value under a dataset become string columns.
Each sync lists everything under the dataset's part of the location and loads the files it hasn't recorded yet.
_ or ..Contrast finds files by listing on each scheduled sync. It does not use event notifications.
Open a table's Files view to see each file Contrast has recorded for it, newest first. Each file has one status:
| Status | Meaning |
|---|---|
| Loaded | The file's rows were loaded. |
| Failed | The file couldn't be read. The record shows its first error. |
| Skipped | The file couldn't be read as listed: it is in an archive storage class, or it was deleted or overwritten while being read. It is read again when its contents change, and an archived file is read by the next sync after you restore it. |
| Ignored overwrite | The path had already loaded, so the new upload was not read. |
Select Failed only to show just the files that failed. A failed file is read again only when its contents change. After you fix the cause, such as the format settings, upload a corrected file to a new path.
_rescued_data with the reason, when the dataset keeps rows. Values are never truncated._rescued_data rather than widening the column. If a column can hold fractions, make sure the first file has one, or expect rescued values.Sync errors name one of these codes.
| Code | What to do |
|---|---|
object_storage_invalid_location | Enter the location as s3://bucket/path, without . or .. folders. |
object_storage_invalid_credentials | The role ARN or access key is incomplete or malformed. Paste it again. |
object_storage_auth_failed | AWS rejected the access key, or the role can't be assumed. Check the key is active, or that the role's trust policy names the Contrast principal and your workspace's external ID exactly. |
object_storage_access_denied | The error names the action that was denied: assume_role (check the trust policy), list (allow s3:ListBucket for the location's prefix), read (allow s3:GetObject under the location), or decrypt (allow kms:Decrypt on the bucket's KMS key). |
object_storage_bucket_not_found | Check the bucket name. |
object_storage_region_mismatch | The bucket is in a different region. Enter the region shown on the bucket's Properties tab. |
object_storage_object_archived | The file is in Glacier or Deep Archive. Restore it; the next sync loads it. |
object_storage_object_gone | The file was deleted between listing and reading. It is recorded as skipped and the table carries on. |
object_storage_object_changed | The file was overwritten while it was read. If no rows from it were saved yet, it is recorded as skipped; otherwise it is recorded as failed and the rows already saved from it stay. |
object_storage_resync_kept_rows | A full resync couldn't read every file (one was archived, failed, or changed while it was read), so it removed no rows. Fix or restore the file, then run the full resync again to drop the rows of deleted files. |
object_storage_throttled | The provider limited request rates. The sync retries. |
object_storage_unavailable | The provider timed out or returned a server error. The sync retries. |
object_storage_too_many_columns | The dataset's files, or a new file joining it, would give the table more than 1,000 columns. A new table isn't created and a new file is recorded as failed (or stops the sync, if the dataset stops on bad data). Narrow the pattern to files with fewer columns, or split the files into datasets with their own patterns. |
object_storage_identity_columns_missing | The dataset's key columns aren't in its files, so the table can't sync yet. Check the key column names against the preview's columns, add a file that has them, or key rows by file and row number. |
object_storage_rows_rescued | Values didn't fit the table's columns in a dataset that skips the file or stops the sync on bad data. With Skip the file the file is recorded as failed; with Stop the sync the sync stops. Fix the values and upload the file to a new path, or switch the dataset to Keep the row to load such rows with the values in _rescued_data. |
object_storage_key_missing | Shown on a loaded file's record: some rows had no value for a key column and weren't loaded. The file's other rows loaded. Fill in the key values and upload the file to a new path, or choose key columns every row has. |
object_storage_file_invalid | The file can't be parsed as the dataset's format. Check the format, compression and CSV or JSON options, or fix the file and upload it to a new path. |
object_storage_reader_memory_exceeded, object_storage_reader_timeout, object_storage_reader_crashed | Contrast reads each file in an isolated process with a memory and time limit. A timeout or crash is tried again; after three failures in a row at the same place the file is recorded as failed. Split very large files, row groups or lines, then upload them to a new path. |
See AWS's documentation on roles for a third party and S3 policy keys.