-
Notifications
You must be signed in to change notification settings - Fork 129
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
Document how to support sql blocks from a customized DuckDB client #1846
Comments
Thanks! Do you want to make a pull-request with this change? I think it should have a sentence to say "optionally, create a But this makes me think we should perhaps attach the database to the Say, if we had: return this.of.apply(this, arguments).then((db) => Object.assign(db.sql.bind(db), {_db: db})); then in the documentation above you could use const sql = await DuckDBClient.of({ ... });
const vgCoordinator = new vgplot.Coordinator();
vgCoordinator.databaseConnector(vgplot.wasmConnector({duckdb: sql._db})); |
@Fil I don’t think we should muddle the |
Happy to! |
If you want to manually configure your DuckDB instance, you can create a custom
sql
definition using theDuckDBClient.sql
function. This returns a callback that abstracts and hides access to the underlying database. If you want to manually configure it and pass the DB instance to something like Mosaic, you can instead use theDuckDBClient.of
function which returns a wrapper class around the underlying WASM instance. Both of these are documented.What's slightly unclear is that if you want to both enable Mosaic and have access to SQL literals, you need to build your own
const sql
definition using thedb
value returned from theof
function. This is easy, but as far as I could find, undocumented. In particular, it's important to note that (a) thedb.sql
function is what you want to defineconst sql
to be and (b) that it's a method so you need to bind the database instance.The following code snippet is a tiny modification of the code available on the Mosaic documentation page.
I looked for this information on the SQL documentation page, but it only references the
DuckDBClient.sql
function. Finally, on the DuckDB documentation page bothDuckDBClient.of
andDuckDBClient.sql
are mentioned, but it's not described how to create thesql
function from a database created usingof
. Ultimately, it was just a matter of looking at the source code ofDuckDBClient.sql
, but ideally this would be documented.The text was updated successfully, but these errors were encountered: