Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #82: Fix typos during row_group reset #83

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading