-- {{product_name}}: replay. -- -- Reads the product's raw archive out of the bus object store and publishes it back onto the -- raw topic, exactly as the capture connector wrote it — same records, same keys — so the -- transform runs again and the canonical product is upserted under the same identifiers. -- -- Submitted by `data-bus replay [--since] [--until]`, which substitutes the -- path, the topic and the date range. It runs in batch mode, so it ends when the archive has -- been read rather than waiting for more. SET 'pipeline.name' = '{{slug}}-replay'; SET 'execution.runtime-mode' = 'batch'; SET 'table.local-time-zone' = 'UTC'; CREATE TABLE {{system}}_{{source_object}}_archive ( id INT, cust_name STRING, cust_type STRING, status_code STRING, birth_date INT, trading_name STRING, `updated` STRING, __op STRING, __lsn BIGINT, __source_ts_ms BIGINT, dt STRING ) PARTITIONED BY (dt) WITH ( 'connector' = 'filesystem', 'path' = '${ARCHIVE_PATH}', 'format' = 'json' ); -- The raw topic, keyed the way the CDC connector keys it: the source key, as JSON. CREATE TABLE {{system}}_{{source_object}}_raw ( id INT, cust_name STRING, cust_type STRING, status_code STRING, birth_date INT, trading_name STRING, `updated` STRING, __op STRING, __lsn BIGINT, __source_ts_ms BIGINT ) WITH ( 'connector' = 'kafka', 'topic' = '${RAW_TOPIC}', 'properties.bootstrap.servers' = '${BUS_KAFKA}', 'format' = 'json', 'key.format' = 'json', 'key.fields' = 'id', 'value.fields-include' = 'ALL' ); INSERT INTO {{system}}_{{source_object}}_raw SELECT id, cust_name, cust_type, status_code, birth_date, trading_name, `updated`, __op, __lsn, __source_ts_ms FROM {{system}}_{{source_object}}_archive WHERE dt >= '${SINCE}' AND dt <= '${UNTIL}';