Duplicate weekly records when using MapReduce for OHLC downsampling in DolphinDB
07:22 05 Jan 2026

I am using DolphinDB to aggregate 5-minute K-line data into weekly bars. My DFS table dfs://um (table name k) is partitioned by Month.

I wrote a MapReduce script to perform the aggregation and append the results back to the same table with a different frequency label (freq="w"). However, I noticed that for weeks that span across two months, duplicate records are generated.

For example, the week starting on 2020.01.27 (Monday) spans from late January to early February. In the output, there are two separate rows for 2020.01.27.

The problematic code:

klines = loadTable("dfs://um", "k")
ds = sqlDS(