mohammedyacine.rouain
08/03/2026, 2:04 PMRocky
08/03/2026, 2:05 PMupdated_at) as the merge_condition.
* Behavior: StarRocks will only apply the update if the value in the incoming record's condition column is greater than or equal to the value currently stored in the table.
* Usage:
* Stream Load: Add the header -H "merge_condition: version_col".
* Routine Load / Broker Load: Set the property "merge_condition" = "version_col".
* SQL: INSERT INTO table PROPERTIES("merge_condition" = "version_col") VALUES (...).
3. Avoiding Duplicate Rows: Load Labels
To ensure idempotency (exactly-once semantics) during retries:
* Labels: Every load job (Stream Load, Broker Load, etc.) should be assigned a unique Label.
* If a load fails or times out, you can retry it using the same label. StarRocks checks the label; if it was already successfully committed, the retry is ignored, preventing duplicate data.
* Note: Labels are kept for a limited time (default 3 days, configurable via label_keep_max_second).
4. Handling Inconsistent State & Enrichment
The choice between replaying through the pipeline vs. writing directly to StarRocks depends on where the "enrichment" happens:
* Replay through original pipeline (Recommended): If your service performs complex enrichments (e.g., joining with external caches, calculating state) before writing to StarRocks, you should replay events through the pipeline. This ensures the enrichment logic is applied consistently to the replayed data.
* Direct write to StarRocks: Only use this for "fixes" where the data is already fully formed. If you use Partial Updates (updating only specific columns), you can fix individual fields without needing the full event payload, which is very efficient for targeted corrections.
5. Summary of Key Features
Feature | Benefit for Replay/Late-Data
merge_condition | Ensures only the latest data "wins" regardless of arrival order.
__op column | Allows you to specify if an event is an Upsert (0) or Delete (1) during replay.
Partial Updates | Updates only specific columns, preserving existing state in other columns.
Labels | Prevents duplicate ingestion when retrying failed load jobs.
Expert Tip: If you are using Flink, the StarRocks Flink Connector handles labels and checkpoints automatically to provide end-to-end exactly-once semantics, which is the most robust way to manage these failures.
References
• loading/Load_to_Primary_Key_tables.md
• table_design/table_types/primary_key_table.md
• loading/Flink-connector-starrocks.md