INSERT.
Before you start
You need:- The Custom data page, read once.
- A BigQuery project that holds your source data and can run scheduled queries.
- The Custom BigQuery source added in Eyk under Sources, and write access to the hook tables. Ask your Eyk contact person if you need help with this step.
Tables
1
Confirm the tables
Open the
_import dataset in the BigQuery console. All 6 tables are there, with the columns listed under Columns. Run a SELECT on one of them to confirm you have access.2
Shape your product variants
Write a
SELECT over your catalog that returns one row per variant, with every column cast to the table type. id must be the same value your order lines carry in variant_id. Categories are arrays of segments, never a joined string.3
Insert 10 rows and inspect them
Wrap the
SELECT in an INSERT with LIMIT 10, run it, and read the rows back from the hook table. Check that names are readable, ids match your order lines, and arrays hold no NULL element.4
Shape customers, orders and refunds
Repeat the last two steps for the other tables. Orders carry their lines in
items, an ARRAY<STRUCT>. Build it with ARRAY_AGG(STRUCT(...)) over your order lines, grouped by order. Every amount excludes tax.5
Schedule the inserts
In the BigQuery console, save each
INSERT as a scheduled query that runs daily at 00:00 UTC over the rows changed in the last 2 days. Remove the LIMIT. The 2-day window catches late changes. The same row twice is harmless.6
Add rate cards
Optional. Insert one row per shipping and payment method with what the method costs you. Profit then includes shipping and payment cost for orders that carry no cost of their own.
7
Backfill history
Run each
INSERT once without the date filter, product variants and customers first, then orders, then refunds. Oldest orders first when the history is large.Columns
Every amount excludes tax. Every timestamp is UTC. Columns marked required areNOT NULL in the table.
eyk_ingest_orders
Each element of
items is a STRUCT with these fields, in this order:
eyk_ingest_customers
eyk_ingest_product_variants
One row per sellable variant. A product without variants is one row with noparent_id.
eyk_ingest_refunds
Each element of
items is a STRUCT with these fields, in this order:
eyk_ingest_shipping_methods and eyk_ingest_payment_methods
A rate card: what a shipping or payment method costs you, per method, from a date onward. Eyk applies it to orders that name the method and carry noshipping_cost or payment_cost of their own.
Full insert examples
Complete statements for the four main tables. Replace the project and dataset and the source tables.Check it worked
Run these on your hook tables the morning after the first scheduled run. Then open the Custom BigQuery source in Eyk under Sources and read the Monitor tab: it lists orders, refunds, product variants and customers received per day. Data appears in reports the morning after Eyk’s night run.Troubleshooting
Access denied on INSERT
Access denied on INSERT
The account that runs the scheduled query has no write access to the
_import dataset, or the query runs in another location than the dataset. Ask your Eyk contact person if you need help with this step.Null value in non-nullable column
Null value in non-nullable column
A required column received NULL. Common causes: a customer without email, a refund without order id, an order line without id or quantity.
Array cannot have a null element
Array cannot have a null element
One of the array columns holds a NULL. Filter with
WHERE s IS NOT NULL AND TRIM(s) != '' inside the ARRAY(...) subquery.Column not found
Column not found
Your INSERT names a column that does not exist in the table. Compare it with Columns.
The items STRUCT does not match
The items STRUCT does not match
Field order and types inside
STRUCT(...) must match the table exactly, in the order listed under Columns. Name every field with AS.I inserted the same rows twice
I inserted the same rows twice
Nothing to fix. Eyk keeps one version per
id, the one with the latest updated_at.