https://slingdata.io logo
Hi, I am starting with a new project
# sling-help
i
Hi, I am starting with a new project moving data from postgres to clickhouse. I need the tables to work with different engines? it relates to the ddl part . CREATE TABLE orders ( order_id UInt64, customer_id UInt64, amount Decimal(18,2), updated_at DateTime64(3) ) ENGINE = ReplacingMergeTree(updated_at) ORDER BY order_id; ENGINE = ReplacingMergeTree(updated_at) in this case if i bring the same order_id with higher updated_at it will replace that row where can i specify that ? Thanks
f
Hi! Use target_options.table_ddl per stream (or under defaults). For ReplacingMergeTree, don't set a primary_key. Use incremental with only update_key, so Sling appends and ClickHouse dedupes:
Copy code
yaml
source: MY_PG
target: MY_CH

streams:
  public.orders:
    object: analytics.orders
    mode: incremental
    update_key: updated_at
    columns:
      order_id: bigint not_null
      updated_at: datetime not_null   # RMT version column can't be Nullable
    target_options:
      table_ddl: |
        create table {object_name} ({col_types})
        engine = ReplacingMergeTree(updated_at)
        order by order_id
i
Thanks