Data warehouse export
Replicate the data mediarithmics ingests into Google BigQuery or Snowflake, as log and state tables.
Your goal
Have the data mediarithmics ingests land in your own cloud data warehouse - Google BigQuery or Snowflake - as tables your analysts and your BI tools query alongside the rest of your data.
Expected outcome
An active data warehouse replication: files written continuously into a cloud storage bucket you own, and one pair of tables per document type in your warehouse, rebuilt from those files.
What this feature is
A data warehouse replication is a datamart replication whose destination is a warehouse rather than a message queue. You select the documents to replicate once, and every update and delete operation on them is delivered from then on.
The delivery is indirect: the platform writes files to a cloud storage bucket, and your warehouse reads them.
log
Every replicated operation, append-only.
state
The current, deduplicated view of the document type. Rebuilt from the log by a daily job.
How fresh the log tables are depends on the warehouse:
BigQuery
External tables reading the bucket in real time, so they always match what is in the bucket.
Snowflake
Populated once a day, when the daily job runs. If you need them refreshed more often, ask your Account Manager about the available options.
Supported buckets per warehouse
BigQuery
Google Cloud Storage
Snowflake
Google Cloud Storage or Amazon S3
You supply the bucket credentials - a GCS HMAC key pair, or an S3 access key - when you set the replication up. A dedicated bucket is recommended, but an existing one works.
What lands in the warehouse
One table pair per document you selected:
USER_SEGMENT
UserSegmentOperationRecord
USER_PROFILE
UserProfileOperationRecord
USER_ACCOUNT
UserAccountOperationRecord
USER_EMAIL
UserEmailOperationRecord
USER_DEVICE_POINT
UserDevicePointOperationRecord
USER_DEVICE_TECHNICAL_ID
UserDeviceTechnicalIdOperationRecord
USER_ACTIVITY
UserActivityOperationRecord
USER_EVENT
UserEventOperationRecord
USER_COMPUTED_FIELD
UserComputedFieldOperationRecord
USER_ML_FUNCTION
UserMlFunctionOperationRecord
Every record carries the same leading fields - ts, the operation timestamp; op, UPDATE or DELETE; and user_point_id - followed by the fields of that document type.
Prerequisites
A declared connection to your warehouse, with the output dataset or schema the platform writes the replicated tables into, and rights on it:
bigquery.dataEditoron the BigQuery dataset,OWNERSHIPon the Snowflake schema. See Warehouse compatibilities and Data warehouse sync.An object storage bucket for the files, of a type your warehouse supports.
The datamart replication module activated on your organisation.
Set it up
The order matters, and it differs per warehouse and per bucket type.
Grant the service account rights on the bucket
The service account created for the mediarithmics to BigQuery connection needs storage.objectAdmin and storage.viewer on the bucket. In the Cloud Storage interface, open the bucket, then Permissions > View by principals > Grant access, enter the service account address and select both roles.
Performing this yourself requires the permissions included in storage.admin. Google documents the mechanics in Set and manage IAM policies on buckets.
The same service account can query the datasets and hold the rights on the bucket, which is the simpler setup. To separate the two, create a second service account to own the editing rights on the bucket and give the first one viewing rights.
Create an HMAC key pair
In Cloud Storage > Settings > Interoperability, under access keys for service accounts, choose Create a key for another service account and select the service account. Keep the request endpoint as it is.
The secret key is shown once, at creation. Keep both keys: you need them in the next step. See Manage HMAC keys for service accounts.
Activate it and load history
Activate the replication, then trigger an initial synchronisation to bring your existing documents across. Both are described in Datamart replication.
This setup involves these identities: a Snowflake service account managing the connection with mediarithmics, a Google Cloud service account owning the HMAC key and holding editing rights on the bucket, and a second Google Cloud service account representing the Snowflake-to-bucket integration.
The Snowflake side follows Snowflake's own procedure, Configure an integration for Google Cloud Storage.
Set up the Snowflake environment with the generated script
Once the replication exists, the platform generates a script for your environment, matching the documents you selected:
It creates the storage integration that authorises Snowflake to read the bucket, the external stage pointing at it, and the log and state tables for each replicated document type.
Its last statement describes the storage integration. Save the STORAGE_GCP_SERVICE_ACCOUNT it returns: that is the identity to authorise in the next step.
Let the Snowflake integration read the bucket
In the Google Cloud console, create a custom role carrying storage.buckets.get, storage.objects.create, storage.objects.delete, storage.objects.get and storage.objects.list. Then, on the bucket, under Permissions > View by principals, add the STORAGE_GCP_SERVICE_ACCOUNT from the previous step and assign it that role.
Confirm the setup, then activate
Tell the platform the environment is ready:
Then activate the replication and trigger an initial synchronisation. See Datamart replication.
Same identities as the GCS setup, on AWS: a Snowflake service account for the connection with mediarithmics, an AWS identity owning the access key and writing the files, and a second AWS identity representing the Snowflake-to-bucket integration.
The Snowflake side follows Snowflake's own procedure, Configure a Snowflake storage integration to access Amazon S3.
Create the IAM policy and the user that writes the files
The policy needs s3:GetBucketLocation, s3:GetObject, s3:GetObjectVersion and s3:ListBucket on the bucket. In IAM > Policies > Create Policy, select JSON and adapt:
Then create an IAM user and attach that policy to it directly. AWS documents the editor itself in Create IAM policies (console).
Let the Snowflake integration read the bucket, then confirm and activate
Grant the integration access to the bucket, then confirm the setup and activate the replication:
See Datamart replication for activation and the initial synchronisation.
This is not the same as warehouse sync
Several features move data between the platform and a warehouse, in different directions. Keeping the vocabulary straight saves a lot of confusion:
Warehouse to datamart. The platform reads your warehouse tables.
Data warehouse export
Datamart to warehouse. The platform replicates its documents into your warehouse.
Collection into the warehouse. Live activity comes to rest in your warehouse instead of the datamart, in a Hybrid or Zero-copy deployment.
Other ways to reach a warehouse
Lighter routes exist, and they remain the right answer in some cases:
A file destination targeting the storage your warehouse already reads, loaded by your own process. Appropriate when a feed already produces the content you need, or when you want control over the file format.
A query export for a one-off extract, loaded by hand. Appropriate for an analysis or a migration, not for a recurring pipeline.
Verify
The replication status is ACTIVE, and files appear in the bucket under the expected
type=folders.Each document type you selected has a log table and a state table in the warehouse.
A row you can identify in the datamart is present in the state table after the daily job has run.
Counts in the state tables are the order of magnitude you expect, and
DELETEoperations are reflected.
Troubleshooting
The replication cannot be activated
Credentials. Check the bucket key pair and the warehouse connection first.
Files arrive in the bucket, tables stay empty
The Snowflake environment script has not been run, or the storage integration cannot read the bucket.
State tables lag behind the log tables
Expected between daily job runs. The state tables are rebuilt once a day.
Log tables lag behind the bucket, on Snowflake
Expected. They are populated by the daily job. Ask your Account Manager about more frequent refreshes.
Related pages
Last updated
Was this helpful?