-
Notifications
You must be signed in to change notification settings - Fork 59
Add support for attaching Postgres databases as a pluggable storage catalog, and fix many issues #111
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ELETE - forward the query to postgres.
…ve cyclical queries (e.g. INSERT INTO postgres_tbl FROM postgres_tbl)
This was referenced Oct 17, 2023
Closed
Closed
Closed
Hey, great effort!! Is there an ETA on when this will make it into a DuckDB release? |
Should be in next week for 0.9.2 |
Perfect timing! ...in the process of leading the first duckdb/PostgreSQL integration project. Thanks a lot! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a giant PR that reworks most of the extension.
Pluggable Storage
This PR enables attaching Postgres databases as a pluggable catalog using the
ATTACH
command, similar to what is possible for SQLite databases (see duckdb/duckdb#6066).Here is an example of how this works:
The following operations are supported:
CREATE TABLE
INSERT INTO
COPY
SELECT
DESCRIBE
DELETE
UPDATE
Transactions (BEGIN, COMMIT, ROLLBACK)
ALTER TABLE
DROP
CREATE SCHEMA
CREATE VIEW
CREATE INDEX
CREATE TYPE
Metadata caching
The metadata (e.g. which schemas are there, which tables are there, what their structure is, etc) is read once and then cached. That means that if e.g. a new table is created through a different connection, the cached metadata will not know about the existence of this table. There is a new function
pg_clear_cache
that can be used to clear the metadata cache and force new data to be read from the Postgres instance.Extra Parameters/Configuration
This PR adds the following settings to the extension:
Fixes
This PR reworks the extension significantly - and also fixes many outstanding issues.
Fixes #16
Fixes #68
Fixes #69
Fixes #73
Fixes #79
Fixes #81
Fixes #82
Fixes #85
Fixes #92
Fixes #93
Fixes #94
Fixes #96
Fixes #100
Fixes #102
Supersedes #59
Supersedes #99
Supersedes #107
Decimals
There are a number of fixes for decimals, in particular:
Support for querying views
Views can now be queried, e.g.:
Postgres
DuckDB
Duplicate column/table names
In Postgres, column and table names are case sensitive. Hence this is valid SQL:
This conflicts with DuckDB which is case insensitive. This PR fixes the issue by instead renaming the columns when read into DuckDB instead of throwing an error. For example:
Connection Pool
This PR introduces the concept of a "connection pool" which is a limit to how many parallel connections will be opened during scans. The default limit is set to 64, and can be adjusted using the
pg_connection_limit
setting (e.g.SET pg_connection_limit=1000
).Complex Types
This PR adds support for complex types, including composite types (created through
CREATE TYPE
), and multidimensional arrays. This support is for both ingesting data (using e.g. CREATE TABLE/INSERT) as well as for reading data.ATTACH time
While this PR does not fix the issue of
pg_attach
taking a long time to execute, the newATTACH
method (which should be the preferred method of attaching going forward) should not suffer from the same problem because it only issues a single query to get the column names/types of all tables at once instead of sending one query per table.