Skip to content

Instantly share code, notes, and snippets.

@sgilligan
Created August 8, 2022 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgilligan/996a6021601fd4f71535c8877b69cbab to your computer and use it in GitHub Desktop.
Save sgilligan/996a6021601fd4f71535c8877b69cbab to your computer and use it in GitHub Desktop.
DuckDb Query and Copy
conn.queryAndCopy = async function(text) {
function copy(src) {
var dst = new ArrayBuffer(src.byteLength);
new Uint8Array(dst).set(new Uint8Array(src));
return dst;
}
const buffer = await this._bindings.runQuery(this._conn, text),
reader = Arrow.RecordBatchReader.from(buffer),
table = new Arrow.Table(reader);
return {
buffer: copy(buffer),
table: table
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment