Fix GapFill with ReScan

The GapFill node was not fully reset on a ReScan, so if there was a
GapFill within a NestedLoop, only the first iteration would return
results. This commit fixes this issues.
This commit is contained in:
Joshua Lockerman 2020-02-04 12:39:42 -05:00 committed by JLockerman
parent 0ae37ba864
commit df0acb161e
4 changed files with 37 additions and 4 deletions

View File

@ -13,6 +13,7 @@ accidentally triggering the load of a previous DB version.**
**Bugfixes**
* #1648 Drop chunks for materialized hypertable
* #1665 Add ignore_invalidation_older_than to timescaledb_information.continuous_aggregates view
* #1674 Fix time_bucket_gapfill's interaction with GROUP BY
**Thanks**
* @RJPhillips01 for reporting an issue with drop chunks.

View File

@ -728,6 +728,7 @@ gapfill_rescan(CustomScanState *node)
{
ExecReScan(linitial(node->custom_ps));
}
((GapFillState *) node)->state = FETCHED_NONE;
}
static void

View File

@ -2197,6 +2197,27 @@ GROUP BY 3,4;
5 | 2 | red | 4
(10 rows)
-- test with Nested Loop
SELECT l.id, bucket, data_value FROM
(VALUES (1), (2), (3), (4)) a(id)
INNER JOIN LATERAL (
SELECT b.id id, time_bucket_gapfill('1'::int, time, start=>'1'::int, finish=> '5'::int) bucket, locf(last(data, time)) data_value
FROM (VALUES (1, 1, 1), (1, 4, 4), (2, 1, -1), (2, 4, -4)) b(id, time, data)
WHERE a.id = b.id
GROUP BY b.id, bucket
) as l on (true);
id | bucket | data_value
----+--------+------------
1 | 1 | 1
1 | 2 | 1
1 | 3 | 1
1 | 4 | 4
2 | 1 | -1
2 | 2 | -1
2 | 3 | -1
2 | 4 | -4
(8 rows)
-- test prepared statement
PREPARE prep_gapfill AS
SELECT

View File

@ -1323,6 +1323,16 @@ SELECT
FROM (VALUES (1,'blue',1),(2,'red',2)) v(time,color,value)
GROUP BY 3,4;
-- test with Nested Loop
SELECT l.id, bucket, data_value FROM
(VALUES (1), (2), (3), (4)) a(id)
INNER JOIN LATERAL (
SELECT b.id id, time_bucket_gapfill('1'::int, time, start=>'1'::int, finish=> '5'::int) bucket, locf(last(data, time)) data_value
FROM (VALUES (1, 1, 1), (1, 4, 4), (2, 1, -1), (2, 4, -4)) b(id, time, data)
WHERE a.id = b.id
GROUP BY b.id, bucket
) as l on (true);
-- test prepared statement
PREPARE prep_gapfill AS
SELECT