Created
August 8, 2022 03:20
-
-
Save sgilligan/996a6021601fd4f71535c8877b69cbab to your computer and use it in GitHub Desktop.
DuckDb Query and Copy
This file contains 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
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