feat: add ducklake schema support to the database manager (#9633)

* feat: add ducklake schema support to the database manager

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat: support schema in wmill.ducklake("name:schema") template helper

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: preserve schema when parsing ducklake asset/favorite paths

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore: regenerate system prompts for ducklake schema syntax doc

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Diego Imbert
2026-06-17 19:23:14 +02:00
committed by GitHub
parent 25a891041d
commit 3eeccaf968
20 changed files with 188 additions and 52 deletions
+10 -4
View File
@@ -138,14 +138,16 @@ function datatableProvider(name: string, schema?: string): SqlProvider {
};
}
function ducklakeProvider(name: string): SqlProvider {
function ducklakeProvider(name: string, schema?: string): SqlProvider {
return {
providerName: "ducklake",
language: "duckdb",
extraArgs: {},
formatArgDecl: (argNum, argType) => `-- $arg${argNum} (${argType})`,
formatArgUsage: (argNum) => `$arg${argNum}`,
preamble: () => `ATTACH 'ducklake://${name}' AS dl;USE dl;\n`,
// `USE dl."schema"` sets the active schema so unqualified tables resolve there.
preamble: () =>
`ATTACH 'ducklake://${name}' AS dl;USE dl${schema ? `."${schema}"` : ""};\n`,
};
}
@@ -364,7 +366,7 @@ export function datatable(name: string = "main"): DatatableSqlTemplateFunction {
/**
* Create a SQL template function for DuckDB/ducklake queries
* @param name - DuckDB database name (default: "main")
* @param name - DuckDB database name, optionally with a schema as `name:schema` (default: "main")
* @returns SQL template function for building parameterized queries
* @example
* let sql = wmill.ducklake()
@@ -374,9 +376,13 @@ export function datatable(name: string = "main"): DatatableSqlTemplateFunction {
* SELECT * FROM friends
* WHERE name = ${name} AND age = ${age}
* `.fetch()
* @example
* // Target a specific schema within the ducklake
* let sql = wmill.ducklake("my_lake:analytics")
*/
export function ducklake(name: string = "main"): SqlTemplateFunction {
return buildSqlTemplateFunction(ducklakeProvider(name));
let { name: n, schema } = parseName(name);
return buildSqlTemplateFunction(ducklakeProvider(n, schema));
}
// ---------------------------------------------------------------------------