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

Postgres Replacement Scan #5

Merged
merged 1 commit into from
Apr 18, 2024
Merged

Postgres Replacement Scan #5

merged 1 commit into from
Apr 18, 2024

Conversation

Tishj
Copy link
Collaborator

@Tishj Tishj commented Apr 3, 2024

This PR upstreams the changes discussed in the last progress update meeting.

This is essentially pg_quack updated to use the C++ API (DuckDB, Connection, Appender, DBConfig objects)
One additional change I've had to make to get it to work with PG16.0 is this, of which I'm not sure this is the equivalent behavior:
Tishj/pg_extension@5b5a678

PostgresReplacementScan

ReplacementScans are a part of DuckDB's extension mechanism, they allow us to hook into a bind of a table ref when that bind can not be fulfilled by the catalog.

We register a replacement scan that receives the QueryDesc object through the ReplacementScanData, in the replacement scan it uses that object to determine which RangeTblEntry corresponds to the table we're binding.

From the replacement scan we return a TableFunctionRef, where we essentially transform the received tableref (i.e "tbl") into a call to a table function, providing both the Snapshot and the RangeTblEntry as POINTER to the function.

PostgresScanFunction

We create a TableFunction that will use the Snapshot and RangeTblEntry to scan Postgres using the TableAM interface from within DuckDB.

@Mytherin
Copy link
Collaborator

@JerrySievert @mkaruza is there anything we need to do from our side for this PR?

@mkaruza
Copy link
Collaborator

mkaruza commented Apr 17, 2024

@Mytherin i have just now create PR for multi threaded scan to be added to this branch. Once we resolve problems (there were some changes how arguments are passed inside duckdb logic which i'm not sure how to resolve) we can merge this into main branch.
I'll talk about this in today meeting.

* Switched from CMake to native Postgres build based on make. Debug version can be
  compiled with `QUACK_BUILD=Debug make` command. Otherwise release will be built.
* Multi-thread scan support. Number of threads per query can be set via
  `quack.max_threads_per_query` GUC variable (default is 1 thread).
* Added basic regression test
@mkaruza mkaruza merged commit 2b74f70 into main Apr 18, 2024
2 checks passed
@mkaruza mkaruza deleted the thijs_postgres_scan branch April 18, 2024 13:44
@wuputah wuputah added this to the 0.1.0 milestone May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants