feat: add read_postgres_binary table function and COPY FROM support for binary files#426
Merged
staticlibs merged 3 commits intoduckdb:mainfrom Apr 2, 2026
Merged
Conversation
Collaborator
|
Thanks! |
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
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 PR is a follow-up of #411.
It adds the
read_postgres_binarytable function andCOPY FROM ... (FORMAT postgres_binary)for reading PostgreSQL binary dump files from file system.It introduces
PostgresBinaryFileReaderwhich wrapsPostgresBinaryParser(from #411) and reads files in chunks (defaults to 32MB but is configurable viabuffer_size).Partial rows at buffer boundaries are carried over to the next read via
FindLastCompleteRow. Since the PostgreSQL binary format has no row delimiters or index, rows can span chunk boundaries, the aforementioned function scans ahead to find the last complete row in each buffer so partial rows are carried over to the next read.The
read_postgres_binary(path, columns={...})table function is exposed through thePostgresBinaryCopyFunction'scopy_from_function, which also enablesCOPY FROM ... (FORMAT postgres_binary).In this PR we've included a test suite that deals with:
bool,int,float,varchar,blob,hugeint,decimal)date,time,timestamp,interval,timetz)arrays,structs)