adjust / parquet_fdw

Parquet foreign data wrapper for PostgreSQL
PostgreSQL License
333 stars 37 forks source link

Build pathkeys for the foreign table based on attrs_sorted and ORDER BY clause passed by user #60

Closed za-arthur closed 1 year ago

za-arthur commented 1 year ago

Build pathkeys for the foreign table based on attrs_sorted and ORDER BY clause passed by user.

pathkeys is used by Postgres to sort the result. After we build pathkeys for the foreign table Postgres will assume that the returned data is already sorted. In the function parquetBeginForeignScan() we make sure that the data from parquet files are sorted.

We need to make sure that we don't add PathKey for an attribute which is not passed by ORDER BY. We will stop building pathkeys as soon as we see that an attribute on ORDER BY and "sorted" doesn't match, since in that case Postgres will need to sort by remaining attributes by itself.

The PR based on https://github.com/adjust/parquet_fdw/pull/59 Issue #58