drt docs acme-analytics
drt 0.9.1
Syncs / orders_to_pg

orders_to_pg

Sync orders, enriched via user + product lookups.

core

Last run
2026-07-09T23:00:48Z · success
502 rows
Configuration
source: bq_prod · mode: upsert
→ postgres (public.orders)

Definition

syncs/orders_to_pg.yml YAML · 37 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: orders_to_pg
description: "Sync orders, enriched via user + product lookups."
tags: [core]
model: |
  SELECT
    o.order_id,
    o.customer_id,
    o.product_id,
    o.amount,
    CASE
      WHEN o.amount >= 1000 THEN 'enterprise'
      WHEN o.amount >= 100  THEN 'pro'
      ELSE 'starter'
    END AS tier
  FROM {{ ref('orders') }} o
  WHERE o.updated_at > {{ watermark }}
destination:
  type: postgres
  host_env: DEMO_PG_HOST
  dbname: acme_app
  table: public.orders
  upsert_key: [order_id]
  lookups:
    user:
      table: public.users
      match: { customer_id: id }
      select: email
    product:
      table: public.products
      match: { product_id: id }
      select: sku
sync:
  mode: upsert
  field_mappings:
    order_id: id
    amount: amount_usd
  on_error: skip

State

last_sync_at2026-07-09T23:00:48Z
last_cursor_value
rows_synced502
last_statussuccess
last_error