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

[BUG] Wrong query results: call to parquetReScanForeignScan() causes loss of the first row-group #82

Closed
jk-intel opened this issue May 29, 2024 · 3 comments

Comments

@jk-intel
Copy link

Hi,
When PG calls parquetReScanForeignScan(), this eventually calls one of:
DefaultParquetReader::rescan()
CachingParquetReader::rescan()

Both of the above reinitialize:
this->row_group = 0;

This assignment should be -1, similarly to how this->row_group is initialized in the constructor of these classes.
This is because on the first call to next(), this->row_group will be immediately incremented.

The way this->row_group is currently assigned to 0, causes the first call to next() to increment it to 1, and the whole first row group will not be read, leading to wrong query result.

parquetReScanForeignScan() itself is called by PG in nested-loop joins, when the parquet_fdw's foreign table is on the inner side of the loop.

I checked that changing both functions to do:
this->row_group = -1;
fixes the issue in my examples.

Thanks,
jk

@jk-intel
Copy link
Author

I suspect it may also be the culprit of this issue: #62

@za-arthur
Copy link
Contributor

Thank you @jk-intel for another report. I've created a PR #83. I'll try to come up with additional tests.

za-arthur added a commit that referenced this issue May 30, 2024
* Issue #82: Fix typos during row_group reset
* Add test for rescan
@za-arthur
Copy link
Contributor

I merged the PR. I'm closing the issue. Feel free to reopen it if you still see the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants