Hi all, I would like to propose bounded look-back probing for FILL METHOD PREVIOUS in IoTDB’s table-model SQL.
Today, previous-value filling uses values available within the query result. If a column is NULL near the start of the query range, a valid value just before that range cannot be used. Users have to widen an inner query to include historical rows, then filter those rows out in an outer query. This adds query complexity and may require extra scanning and processing. The proposal adds an optional PROBE_BOUND parameter. When specified, IoTDB looks backward from the query’s time lower bound, up to the configured duration, and uses the most recent non-NULL value as the initial value for filling. The query still returns only its original result rows. For example, suppose sensor has a temperature of 20.0 for device d1 at 08:30, but no non-NULL temperature at the start of the query range: SELECT time, device_id, temperature FROM sensor WHERE time >= '2024-09-24 10:00:00' AND time <= '2024-09-24 10:08:00' FILL METHOD PREVIOUS TIME_BOUND 5m TIME_COLUMN 1 FILL_GROUP 2 PROBE_BOUND 2h; With PROBE_BOUND 2h, the 08:30 value can seed filling at 10:00 for d1. FILL_GROUP 2 keeps the probe and fill isolated by device. PROBE_BOUND limits how far the initial value can be found in history, while TIME_BOUND continues to limit filling between rows within the query range. The behavior would apply to existing result rows without adding or removing rows. Each column would probe independently, and NULL values in the historical range would be skipped. For aggregate queries, probing would use aggregated time intervals and take the most recent interval with a valid aggregate result. date_bin_gapfill rows would continue to participate in filling as they do today. PROBE_BOUND would need to be a positive fixed duration, and the query would need an inferable time lower bound. Queries without one, or with a time predicate under OR, would be rejected because the probe range cannot be determined unambiguously. Best regards, Xinqi Zhao
