Skip to content

Commit

Permalink
Issue #82: Fix typos during row_group reset (#83)
Browse files Browse the repository at this point in the history
* Issue #82: Fix typos during row_group reset
* Add test for rescan
  • Loading branch information
za-arthur authored May 30, 2024
1 parent f586754 commit d1c43db
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ class DefaultParquetReader : public ParquetReader
* row_group cannot be less than zero at this point so it is safe to cast
* it to unsigned int
*/
Assert(this->row_group >= 0);
if ((uint) this->row_group >= this->rowgroups.size())
return false;

Expand Down Expand Up @@ -1024,7 +1025,7 @@ class DefaultParquetReader : public ParquetReader

void rescan(void)
{
this->row_group = 0;
this->row_group = -1;
this->row = 0;
this->num_rows = 0;
}
Expand Down Expand Up @@ -1111,6 +1112,7 @@ class CachingParquetReader : public ParquetReader
* row_group cannot be less than zero at this point so it is safe to cast
* it to unsigned int
*/
Assert(this->row_group >= 0);
if ((uint) this->row_group >= this->rowgroups.size())
return false;

Expand Down Expand Up @@ -1376,7 +1378,7 @@ class CachingParquetReader : public ParquetReader

void rescan(void)
{
this->row_group = 0;
this->row_group = -1;
this->row = 0;
this->num_rows = 0;
}
Expand Down
42 changes: 42 additions & 0 deletions test/expected/001_parquet_fdw.out.in
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,48 @@ SELECT SUM(one) FROM example1;
21
(1 row)

-- test rescan
SET enable_material = false;
EXPLAIN (COSTS OFF)
SELECT e1.one, e2.one FROM example1 e1, (SELECT * FROM example1) e2 WHERE e1.one < e2.one ORDER BY 1, 2;
QUERY PLAN
--------------------------------------------------------
Sort
Sort Key: e1.one, example1.one
-> Nested Loop
Join Filter: (e1.one < example1.one)
-> Gather
Workers Planned: 2
-> Parallel Foreign Scan on example1 e1
Reader: Single File
Row groups: 1, 2
-> Gather
Workers Planned: 2
-> Parallel Foreign Scan on example1
Reader: Single File
Row groups: 1, 2
(14 rows)

SELECT e1.one, e2.one FROM example1 e1, (SELECT * FROM example1) e2 WHERE e1.one < e2.one ORDER BY 1, 2;
one | one
-----+-----
1 | 2
1 | 3
1 | 4
1 | 5
1 | 6
2 | 3
2 | 4
2 | 5
2 | 6
3 | 4
3 | 5
3 | 6
4 | 5
4 | 6
5 | 6
(15 rows)

-- multiple sorting keys
CREATE FOREIGN TABLE example_multisort (
one INT8,
Expand Down
6 changes: 6 additions & 0 deletions test/sql/001_parquet_fdw.sql.in
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ EXPLAIN (COSTS OFF) SELECT * FROM example_sorted ORDER BY one;
EXPLAIN (COSTS OFF) SELECT * FROM example1;
SELECT SUM(one) FROM example1;

-- test rescan
SET enable_material = false;
EXPLAIN (COSTS OFF)
SELECT e1.one, e2.one FROM example1 e1, (SELECT * FROM example1) e2 WHERE e1.one < e2.one ORDER BY 1, 2;
SELECT e1.one, e2.one FROM example1 e1, (SELECT * FROM example1) e2 WHERE e1.one < e2.one ORDER BY 1, 2;

-- multiple sorting keys
CREATE FOREIGN TABLE example_multisort (
one INT8,
Expand Down

0 comments on commit d1c43db

Please sign in to comment.