@sixb/ducklake 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +490 -0
- package/dist/ducklake-storage.d.ts +42 -0
- package/dist/ducklake-storage.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3112 -0
- package/dist/index.js.map +34 -0
- package/dist/internal/catalog-key.d.ts +11 -0
- package/dist/internal/catalog-key.d.ts.map +1 -0
- package/dist/internal/dataset-row-commit.d.ts +26 -0
- package/dist/internal/dataset-row-commit.d.ts.map +1 -0
- package/dist/internal/duckdb-column-types.d.ts +45 -0
- package/dist/internal/duckdb-column-types.d.ts.map +1 -0
- package/dist/internal/duckdb-decimal.d.ts +6 -0
- package/dist/internal/duckdb-decimal.d.ts.map +1 -0
- package/dist/internal/duckdb-row.d.ts +8 -0
- package/dist/internal/duckdb-row.d.ts.map +1 -0
- package/dist/internal/duckdb-runtime.d.ts +63 -0
- package/dist/internal/duckdb-runtime.d.ts.map +1 -0
- package/dist/internal/duckdb-value-converter.d.ts +7 -0
- package/dist/internal/duckdb-value-converter.d.ts.map +1 -0
- package/dist/internal/ducklake-catalog-schema.d.ts +12 -0
- package/dist/internal/ducklake-catalog-schema.d.ts.map +1 -0
- package/dist/internal/ducklake-connection-manager.d.ts +67 -0
- package/dist/internal/ducklake-connection-manager.d.ts.map +1 -0
- package/dist/internal/ducklake-current-dataset-definitions.d.ts +10 -0
- package/dist/internal/ducklake-current-dataset-definitions.d.ts.map +1 -0
- package/dist/internal/ducklake-dataset-catalog.d.ts +33 -0
- package/dist/internal/ducklake-dataset-catalog.d.ts.map +1 -0
- package/dist/internal/ducklake-dataset-table-ref.d.ts +9 -0
- package/dist/internal/ducklake-dataset-table-ref.d.ts.map +1 -0
- package/dist/internal/ducklake-maintenance.d.ts +9 -0
- package/dist/internal/ducklake-maintenance.d.ts.map +1 -0
- package/dist/internal/ducklake-row-reader.d.ts +24 -0
- package/dist/internal/ducklake-row-reader.d.ts.map +1 -0
- package/dist/internal/ducklake-snapshot-reader.d.ts +73 -0
- package/dist/internal/ducklake-snapshot-reader.d.ts.map +1 -0
- package/dist/internal/ducklake-sql-executor.d.ts +33 -0
- package/dist/internal/ducklake-sql-executor.d.ts.map +1 -0
- package/dist/internal/ducklake-write-coordinator.d.ts +53 -0
- package/dist/internal/ducklake-write-coordinator.d.ts.map +1 -0
- package/dist/internal/ducklake-write-session.d.ts +17 -0
- package/dist/internal/ducklake-write-session.d.ts.map +1 -0
- package/dist/internal/names.d.ts +13 -0
- package/dist/internal/names.d.ts.map +1 -0
- package/dist/internal/row-appender.d.ts +7 -0
- package/dist/internal/row-appender.d.ts.map +1 -0
- package/dist/internal/schema.d.ts +35 -0
- package/dist/internal/schema.d.ts.map +1 -0
- package/dist/internal/sql-transform-relations.d.ts +13 -0
- package/dist/internal/sql-transform-relations.d.ts.map +1 -0
- package/dist/internal/sql.d.ts +62 -0
- package/dist/internal/sql.d.ts.map +1 -0
- package/dist/internal/versions.d.ts +22 -0
- package/dist/internal/versions.d.ts.map +1 -0
- package/dist/tsconfig.json +5 -0
- package/dist/types.d.ts +147 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +64 -0
- package/src/ducklake-storage.ts +130 -0
- package/src/index.ts +14 -0
- package/src/internal/catalog-key.ts +28 -0
- package/src/internal/dataset-row-commit.ts +128 -0
- package/src/internal/duckdb-column-types.ts +68 -0
- package/src/internal/duckdb-decimal.ts +36 -0
- package/src/internal/duckdb-row.ts +83 -0
- package/src/internal/duckdb-runtime.ts +347 -0
- package/src/internal/duckdb-value-converter.ts +27 -0
- package/src/internal/ducklake-catalog-schema.ts +116 -0
- package/src/internal/ducklake-connection-manager.ts +510 -0
- package/src/internal/ducklake-current-dataset-definitions.ts +228 -0
- package/src/internal/ducklake-dataset-catalog.ts +363 -0
- package/src/internal/ducklake-dataset-table-ref.ts +35 -0
- package/src/internal/ducklake-maintenance.ts +116 -0
- package/src/internal/ducklake-row-reader.ts +143 -0
- package/src/internal/ducklake-snapshot-reader.ts +826 -0
- package/src/internal/ducklake-sql-executor.ts +334 -0
- package/src/internal/ducklake-write-coordinator.ts +532 -0
- package/src/internal/ducklake-write-session.ts +170 -0
- package/src/internal/names.ts +111 -0
- package/src/internal/row-appender.ts +73 -0
- package/src/internal/schema.ts +149 -0
- package/src/internal/sql-transform-relations.ts +99 -0
- package/src/internal/sql.ts +440 -0
- package/src/internal/versions.ts +140 -0
- package/src/types.ts +159 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefix used for all Sixb dataset tables inside the DuckLake schema.
|
|
3
|
+
*/
|
|
4
|
+
export declare const DATASET_TABLE_PREFIX = "sixb__ds__";
|
|
5
|
+
/**
|
|
6
|
+
* Convert a Sixb dataset id to its physical DuckLake table name.
|
|
7
|
+
*/
|
|
8
|
+
export declare function encodeDatasetTableName(datasetId: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Decode a physical DuckLake table name back to a Sixb dataset id.
|
|
11
|
+
*/
|
|
12
|
+
export declare function decodeDatasetTableName(tableName: string): string | null;
|
|
13
|
+
//# sourceMappingURL=names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../../src/internal/names.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,oBAAoB,eAAe,CAAA;AAyFhD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMvE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DatasetRow, DatasetSchema } from "@sixb/core";
|
|
2
|
+
import type { DuckDbAppender } from "./duckdb-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Append one validated dataset row into the staging table's DuckDB appender.
|
|
5
|
+
*/
|
|
6
|
+
export declare function appendDatasetRow(appender: DuckDbAppender, schema: DatasetSchema, row: DatasetRow): void;
|
|
7
|
+
//# sourceMappingURL=row-appender.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-appender.d.ts","sourceRoot":"","sources":["../../src/internal/row-appender.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2B,UAAU,EAAE,aAAa,EAAW,MAAM,YAAY,CAAA;AAE7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,UAAU,GACd,IAAI,CAMN"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DatasetColumnDefinition, DatasetColumnType, DatasetSchema } from "@sixb/core";
|
|
2
|
+
/**
|
|
3
|
+
* Normalized column metadata read from DuckDB/DuckLake introspection queries.
|
|
4
|
+
*/
|
|
5
|
+
export interface DuckDbColumnMetadata {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly type: string;
|
|
8
|
+
readonly nullable: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Map a Sixb dataset column type to the DuckDB type used in CREATE TABLE.
|
|
12
|
+
*/
|
|
13
|
+
export declare function datasetColumnTypeToDuckDbSql(type: DatasetColumnType): string;
|
|
14
|
+
/**
|
|
15
|
+
* Reconstruct a Sixb dataset column type from DuckDB column metadata.
|
|
16
|
+
*/
|
|
17
|
+
export declare function duckDbTypeToDatasetColumnType(typeSql: string): DatasetColumnType;
|
|
18
|
+
/**
|
|
19
|
+
* Render one Sixb dataset column as DuckDB DDL.
|
|
20
|
+
*/
|
|
21
|
+
export declare function datasetColumnToDuckDbSql(column: DatasetColumnDefinition): string;
|
|
22
|
+
/**
|
|
23
|
+
* Render the column list used by CREATE TABLE and staging table DDL.
|
|
24
|
+
*/
|
|
25
|
+
export declare function datasetSchemaToDuckDbColumnsSql(schema: DatasetSchema): string;
|
|
26
|
+
/**
|
|
27
|
+
* Render the column list used by INSERT ... SELECT operations.
|
|
28
|
+
*/
|
|
29
|
+
export declare function datasetSchemaColumnNamesSql(schema: DatasetSchema): string;
|
|
30
|
+
/**
|
|
31
|
+
* Convert DuckDB column metadata back into a Sixb dataset schema.
|
|
32
|
+
*/
|
|
33
|
+
export declare function duckDbColumnsToDatasetSchema(columns: readonly DuckDbColumnMetadata[]): DatasetSchema;
|
|
34
|
+
export declare function normalizeReadValue(value: unknown, column: DatasetColumnDefinition): unknown;
|
|
35
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/internal/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,aAAa,EAAW,MAAM,YAAY,CAAA;AAMpG;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAC3B;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAE5E;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAShF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,uBAAuB,GAAG,MAAM,CAGhF;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE7E;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAEzE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,SAAS,oBAAoB,EAAE,GACvC,aAAa,CAQf;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAqB3F"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type SqlTransformBody } from "@sixb/core/lake-storage";
|
|
2
|
+
import type { DuckLakeStorageOptions } from "../types";
|
|
3
|
+
export interface DuckLakeSqlTransformSourceRelation {
|
|
4
|
+
readonly datasetId: string;
|
|
5
|
+
readonly versionId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RenderDuckLakeSqlTransformSqlInput {
|
|
8
|
+
readonly options: Pick<DuckLakeStorageOptions, "alias">;
|
|
9
|
+
readonly sources: Readonly<Record<string, DuckLakeSqlTransformSourceRelation>>;
|
|
10
|
+
readonly sql: SqlTransformBody<"duckdb">;
|
|
11
|
+
}
|
|
12
|
+
export declare function renderDuckLakeSqlTransformSql(input: RenderDuckLakeSqlTransformSqlInput): string;
|
|
13
|
+
//# sourceMappingURL=sql-transform-relations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-transform-relations.d.ts","sourceRoot":"","sources":["../../src/internal/sql-transform-relations.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,gBAAgB,EAEtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAQtD,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC3B;AAED,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAA;IACvD,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kCAAkC,CAAC,CAAC,CAAA;IAC9E,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAA;CACzC;AAeD,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,kCAAkC,GAAG,MAAM,CAS/F"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { DuckDbSecretOptions, DuckLakeCatalogOptions, DuckLakeStorageOptions, PostgresDuckLakeCatalogOptions } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the DuckLake attachment alias used by all provider SQL.
|
|
4
|
+
*/
|
|
5
|
+
export declare function duckLakeAlias(options: Pick<DuckLakeStorageOptions, "alias">): string;
|
|
6
|
+
/**
|
|
7
|
+
* Configure the PostgreSQL extension pool used by DuckLake's attached metadata
|
|
8
|
+
* catalog. DuckDB worker threads can otherwise pin pooled Postgres connections
|
|
9
|
+
* in the thread-local cache until the pool is exhausted during repeated
|
|
10
|
+
* DuckLake metadata reads.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildConfigurePostgresMetadataPoolSql(options: Pick<DuckLakeStorageOptions, "alias" | "postgresPool">): string;
|
|
13
|
+
/**
|
|
14
|
+
* Configure DuckDB's PostgreSQL extension before ATTACH. These settings only
|
|
15
|
+
* affect databases attached after they are set.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildSetPostgresPoolSql(options: Pick<DuckLakeStorageOptions, "postgresPool">): readonly string[];
|
|
18
|
+
/**
|
|
19
|
+
* Render a fully-qualified DuckLake metadata table path.
|
|
20
|
+
*
|
|
21
|
+
* PostgreSQL catalogs expose DuckLake metadata tables under the configured
|
|
22
|
+
* metadata schema inside the attached metadata catalog. Local catalogs use
|
|
23
|
+
* DuckDB's default `main` schema.
|
|
24
|
+
*/
|
|
25
|
+
export declare function duckLakeMetadataTableName(options: Pick<DuckLakeStorageOptions, "alias" | "catalog">, tableName: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Quote a SQL identifier after validating it is already identifier-shaped.
|
|
28
|
+
*
|
|
29
|
+
* Dataset table names are produced by `names.ts`; user text should never be
|
|
30
|
+
* passed here without first going through a deterministic encoder.
|
|
31
|
+
*/
|
|
32
|
+
export declare function quoteIdentifier(identifier: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Quote a SQL string literal for DDL statements that DuckDB does not parameterize.
|
|
35
|
+
*/
|
|
36
|
+
export declare function quoteSqlString(value: string): string;
|
|
37
|
+
export declare function quoteSqlStringList(values: readonly string[]): string;
|
|
38
|
+
/**
|
|
39
|
+
* Render a fully-qualified table path.
|
|
40
|
+
*/
|
|
41
|
+
export declare function qualifiedTableName(options: Pick<DuckLakeStorageOptions, "alias">, tableName: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Build the catalog URI expected by DuckLake's ATTACH statement.
|
|
44
|
+
*/
|
|
45
|
+
export declare function catalogUri(catalog: DuckLakeCatalogOptions): string;
|
|
46
|
+
/**
|
|
47
|
+
* Render typed PostgreSQL options to the libpq connection string DuckLake expects.
|
|
48
|
+
*/
|
|
49
|
+
export declare function postgresConnectionString(catalog: PostgresDuckLakeCatalogOptions): string;
|
|
50
|
+
/**
|
|
51
|
+
* Extensions needed by the catalog, data path, and typed secrets.
|
|
52
|
+
*/
|
|
53
|
+
export declare function requiredExtensions(options: DuckLakeStorageOptions): readonly string[];
|
|
54
|
+
/**
|
|
55
|
+
* Build a typed DuckDB CREATE SECRET statement.
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildCreateSecretSql(secret: DuckDbSecretOptions): string;
|
|
58
|
+
/**
|
|
59
|
+
* Build the DuckLake ATTACH statement from public provider options.
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildAttachSql(options: DuckLakeStorageOptions): string;
|
|
62
|
+
//# sourceMappingURL=sql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../src/internal/sql.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,mBAAmB,EAC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M,EAAE,mBAAmB,GAAG,MAAM,CAIxE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,CA+BtE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DatasetVersion } from "@sixb/core/lake-storage";
|
|
2
|
+
export interface SixbSchemaChangeMetadata {
|
|
3
|
+
readonly addColumns?: readonly string[];
|
|
4
|
+
}
|
|
5
|
+
export interface SixbCommitMetadata {
|
|
6
|
+
readonly kind: "datasetVersion";
|
|
7
|
+
readonly datasetId: string;
|
|
8
|
+
readonly commitId?: string;
|
|
9
|
+
readonly mode?: DatasetVersion["mode"];
|
|
10
|
+
readonly producer?: DatasetVersion["producer"];
|
|
11
|
+
readonly inputs?: DatasetVersion["inputs"];
|
|
12
|
+
readonly rowCount?: number;
|
|
13
|
+
readonly schemaChange?: SixbSchemaChangeMetadata;
|
|
14
|
+
}
|
|
15
|
+
export declare function parseVersionId(versionId: string): string;
|
|
16
|
+
export declare function toVersionId(snapshotId: string): string;
|
|
17
|
+
export declare function parseCommitMetadata(value: unknown): SixbCommitMetadata | undefined;
|
|
18
|
+
export declare function parseInlineDataChange(changesMade: string, tableId: bigint): {
|
|
19
|
+
readonly hasDataChange: boolean;
|
|
20
|
+
readonly hasDeleteChange: boolean;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=versions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../src/internal/versions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAG7D,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACxC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;IAC1C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,YAAY,CAAC,EAAE,wBAAwB,CAAA;CACjD;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAWxD;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,GAAG,SAAS,CAqClF;AAED,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd;IAAE,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;CAAE,CAsBxE"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Written by scripts/build-package.ts, and published on purpose.
|
|
2
|
+
// Bun applies the nearest tsconfig paths map to every import it resolves, node_modules
|
|
3
|
+
// included. An empty map here keeps a consumer's aliases from sending a module in this
|
|
4
|
+
// directory back into a second copy of its own source.
|
|
5
|
+
{ "compilerOptions": { "paths": {} } }
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DuckLake catalog connection settings.
|
|
3
|
+
*
|
|
4
|
+
* The catalog stores DuckLake metadata. Physical table data still lives under
|
|
5
|
+
* `dataPath` and is managed by DuckLake, not by Sixb sidecar tables.
|
|
6
|
+
*/
|
|
7
|
+
export type DuckLakeCatalogOptions = {
|
|
8
|
+
readonly type: "duckdb";
|
|
9
|
+
readonly path: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly type: "sqlite";
|
|
12
|
+
readonly path: string;
|
|
13
|
+
} | PostgresDuckLakeCatalogOptions
|
|
14
|
+
/** Escape hatch for DuckLake catalog URI forms Sixb does not model yet. */
|
|
15
|
+
| {
|
|
16
|
+
readonly type: "custom";
|
|
17
|
+
readonly uri: string;
|
|
18
|
+
readonly extensions?: readonly string[];
|
|
19
|
+
readonly metadataParameters?: Readonly<Record<string, string>>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Friendly PostgreSQL catalog settings.
|
|
23
|
+
*
|
|
24
|
+
* The provider renders these to the libpq string required by DuckLake. Use
|
|
25
|
+
* `custom` for raw DuckLake catalog URIs that need unsupported options.
|
|
26
|
+
*/
|
|
27
|
+
export interface PostgresDuckLakeCatalogOptions {
|
|
28
|
+
readonly type: "postgres";
|
|
29
|
+
readonly host: string;
|
|
30
|
+
readonly database: string;
|
|
31
|
+
readonly port?: number;
|
|
32
|
+
readonly user?: string;
|
|
33
|
+
readonly password?: string;
|
|
34
|
+
readonly sslMode?: "disable" | "allow" | "prefer" | "require" | "verify-ca" | "verify-full";
|
|
35
|
+
readonly applicationName?: string;
|
|
36
|
+
readonly connectTimeoutSeconds?: number;
|
|
37
|
+
readonly metadataSchema?: string;
|
|
38
|
+
readonly parameters?: Readonly<Record<string, string | number | boolean>>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Runtime settings for the embedded DuckDB process that loads DuckLake.
|
|
42
|
+
*/
|
|
43
|
+
export interface DuckDbRuntimeOptions {
|
|
44
|
+
readonly path?: string;
|
|
45
|
+
readonly config?: Readonly<Record<string, string>>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* DuckDB PostgreSQL extension pool settings for a Postgres-backed DuckLake
|
|
49
|
+
* metadata catalog.
|
|
50
|
+
*/
|
|
51
|
+
export interface DuckLakePostgresPoolOptions {
|
|
52
|
+
readonly maxConnections?: number;
|
|
53
|
+
readonly waitTimeoutMillis?: number;
|
|
54
|
+
readonly maxLifetimeMillis?: number;
|
|
55
|
+
readonly idleTimeoutMillis?: number;
|
|
56
|
+
readonly enableThreadLocalCache?: boolean;
|
|
57
|
+
readonly enableReaperThread?: boolean;
|
|
58
|
+
readonly healthCheckQuery?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Common CREATE SECRET options shared by DuckDB object-store integrations.
|
|
62
|
+
*/
|
|
63
|
+
interface BaseSecretOptions {
|
|
64
|
+
readonly name?: string;
|
|
65
|
+
readonly persistent?: boolean;
|
|
66
|
+
readonly scope?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Shared options for DuckDB secrets that use the S3-compatible HTTPFS layer.
|
|
70
|
+
*
|
|
71
|
+
* R2 and GCS are modeled as first-class DuckDB secret types, but they still use
|
|
72
|
+
* the same S3 API client under the hood.
|
|
73
|
+
*/
|
|
74
|
+
interface S3ApiSecretOptions extends BaseSecretOptions {
|
|
75
|
+
readonly provider?: "config" | "credential_chain";
|
|
76
|
+
readonly keyId?: string;
|
|
77
|
+
readonly secret?: string;
|
|
78
|
+
readonly sessionToken?: string;
|
|
79
|
+
readonly region?: string;
|
|
80
|
+
readonly endpoint?: string;
|
|
81
|
+
readonly urlStyle?: "path" | "vhost";
|
|
82
|
+
readonly useSsl?: boolean;
|
|
83
|
+
readonly verifySsl?: boolean;
|
|
84
|
+
readonly chain?: string;
|
|
85
|
+
readonly profile?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface S3SecretOptions extends S3ApiSecretOptions {
|
|
88
|
+
readonly type: "s3";
|
|
89
|
+
readonly kmsKeyId?: string;
|
|
90
|
+
readonly requesterPays?: boolean;
|
|
91
|
+
}
|
|
92
|
+
export interface R2SecretOptions extends S3ApiSecretOptions {
|
|
93
|
+
readonly type: "r2";
|
|
94
|
+
readonly accountId?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface GcsSecretOptions extends S3ApiSecretOptions {
|
|
97
|
+
readonly type: "gcs";
|
|
98
|
+
}
|
|
99
|
+
export interface AzureSecretOptions extends BaseSecretOptions {
|
|
100
|
+
readonly type: "azure";
|
|
101
|
+
readonly connectionString?: string;
|
|
102
|
+
readonly accountName?: string;
|
|
103
|
+
readonly accountKey?: string;
|
|
104
|
+
readonly tenantId?: string;
|
|
105
|
+
readonly clientId?: string;
|
|
106
|
+
readonly clientSecret?: string;
|
|
107
|
+
}
|
|
108
|
+
export type DuckDbSecretOptions = S3SecretOptions | R2SecretOptions | GcsSecretOptions | AzureSecretOptions;
|
|
109
|
+
export interface DuckLakeMaintenanceOptions {
|
|
110
|
+
/** How long to keep snapshots before they can expire. Default: "7 days". */
|
|
111
|
+
readonly expireOlderThan?: string;
|
|
112
|
+
/** How long to keep deleted/orphaned files before reclaim. Default: expireOlderThan. */
|
|
113
|
+
readonly deleteOlderThan?: string;
|
|
114
|
+
/** Report what would be expired/deleted without changing the lake. Default: false. */
|
|
115
|
+
readonly dryRun?: boolean;
|
|
116
|
+
}
|
|
117
|
+
export interface DuckLakeMaintenanceReport {
|
|
118
|
+
readonly dryRun: boolean;
|
|
119
|
+
readonly expireOlderThan: string;
|
|
120
|
+
readonly deleteOlderThan: string;
|
|
121
|
+
readonly snapshots: number;
|
|
122
|
+
readonly oldFiles: number;
|
|
123
|
+
readonly orphanedFiles: number;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Public provider configuration for `new DuckLakeStorage(...)`.
|
|
127
|
+
*
|
|
128
|
+
* Defaults:
|
|
129
|
+
* - `alias`: "sixb_lake"
|
|
130
|
+
* - `createIfNotExists`: true
|
|
131
|
+
* - `readOnly`: false
|
|
132
|
+
* - `duckdb.path`: ":memory:"
|
|
133
|
+
*/
|
|
134
|
+
export interface DuckLakeStorageOptions {
|
|
135
|
+
readonly catalog: DuckLakeCatalogOptions;
|
|
136
|
+
readonly dataPath?: string;
|
|
137
|
+
readonly alias?: string;
|
|
138
|
+
readonly duckdb?: DuckDbRuntimeOptions;
|
|
139
|
+
readonly postgresPool?: DuckLakePostgresPoolOptions;
|
|
140
|
+
readonly secrets?: readonly DuckDbSecretOptions[];
|
|
141
|
+
/** Runs after DuckLake/catalog extensions load and before ATTACH. */
|
|
142
|
+
readonly setupSql?: readonly string[];
|
|
143
|
+
readonly createIfNotExists?: boolean;
|
|
144
|
+
readonly readOnly?: boolean;
|
|
145
|
+
}
|
|
146
|
+
export {};
|
|
147
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAC9B;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClD,8BAA8B;AAChC,2EAA2E;GACzE;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACvC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAC/D,CAAA;AAEL;;;;;GAKG;AACH,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,IA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AQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACrC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAC5B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sixb/ducklake",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "DuckDB/DuckLake lake storage provider for Sixb",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"sixb",
|
|
7
|
+
"bun",
|
|
8
|
+
"storage",
|
|
9
|
+
"duckdb",
|
|
10
|
+
"ducklake",
|
|
11
|
+
"lake"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://sixb.ai",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/sixb-ai/sixb/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/sixb-ai/sixb.git",
|
|
20
|
+
"directory": "storage/ducklake"
|
|
21
|
+
},
|
|
22
|
+
"author": "Sixb contributors",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"bun": "./src/index.ts",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "bun ../../scripts/build-package.ts",
|
|
36
|
+
"typecheck": "tsc --noEmit",
|
|
37
|
+
"test": "bun test",
|
|
38
|
+
"test:e2e": "bun run test:e2e:local && bun run test:e2e:remote",
|
|
39
|
+
"test:e2e:local": "bun test ./tests/ducklake-contract.e2e.ts ./tests/ducklake-file-refs.e2e.ts ./tests/ducklake-catalog-state.e2e.ts ./tests/ducklake-catalogs.e2e.ts ./tests/ducklake-concurrency.e2e.ts ./tests/ducklake-datasets.e2e.ts ./tests/ducklake-driver.e2e.ts ./tests/ducklake-maintenance.e2e.ts ./tests/ducklake-sql-transforms.e2e.ts ./tests/ducklake-versions.e2e.ts ./tests/ducklake-writes.e2e.ts",
|
|
40
|
+
"test:e2e:remote": "bun test --preload ./tests/setup.ts ./tests/ducklake-remote.e2e.ts",
|
|
41
|
+
"prepack": "bun run build"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@duckdb/node-api": "^1.5.2-r.1",
|
|
45
|
+
"@sixb/core": "0.0.1"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/bun": "latest",
|
|
49
|
+
"typescript": "^5.7.0"
|
|
50
|
+
},
|
|
51
|
+
"license": "MIT",
|
|
52
|
+
"engines": {
|
|
53
|
+
"bun": ">=1.3.0"
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"dist",
|
|
60
|
+
"src",
|
|
61
|
+
"README.md",
|
|
62
|
+
"LICENSE"
|
|
63
|
+
]
|
|
64
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { DatasetDefinition, DatasetRow, LakeStorageWithSql } from "@sixb/core"
|
|
2
|
+
import type {
|
|
3
|
+
BeginDatasetWriteInput,
|
|
4
|
+
DatasetCatalogState,
|
|
5
|
+
DatasetVersion,
|
|
6
|
+
LakeWriteSession,
|
|
7
|
+
ReadDatasetRowsInput,
|
|
8
|
+
} from "@sixb/core/lake-storage"
|
|
9
|
+
import { DuckLakeConnectionManager } from "./internal/ducklake-connection-manager"
|
|
10
|
+
import { DuckLakeDatasetCatalog } from "./internal/ducklake-dataset-catalog"
|
|
11
|
+
import { DuckLakeMaintenance } from "./internal/ducklake-maintenance"
|
|
12
|
+
import { DuckLakeRowReader } from "./internal/ducklake-row-reader"
|
|
13
|
+
import { DuckLakeSnapshotReader } from "./internal/ducklake-snapshot-reader"
|
|
14
|
+
import { DuckLakeSqlExecutor } from "./internal/ducklake-sql-executor"
|
|
15
|
+
import { DuckLakeWriteCoordinator } from "./internal/ducklake-write-coordinator"
|
|
16
|
+
import type {
|
|
17
|
+
DuckLakeMaintenanceOptions,
|
|
18
|
+
DuckLakeMaintenanceReport,
|
|
19
|
+
DuckLakeStorageOptions,
|
|
20
|
+
} from "./types"
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* DuckLake-backed implementation of Sixb's LakeStorage API.
|
|
24
|
+
*
|
|
25
|
+
* The public surface stays aligned with core LakeStorage while DuckLake owns
|
|
26
|
+
* physical tables, schemas, snapshots, and transactions behind the provider.
|
|
27
|
+
* Sixb-specific metadata is only used to reconstruct DatasetVersion shape.
|
|
28
|
+
*/
|
|
29
|
+
export class DuckLakeStorage implements LakeStorageWithSql<"duckdb"> {
|
|
30
|
+
readonly standard = { id: "ducklake", version: "1.0" } as const
|
|
31
|
+
readonly sql: DuckLakeSqlExecutor
|
|
32
|
+
|
|
33
|
+
private readonly connections: DuckLakeConnectionManager
|
|
34
|
+
private readonly datasets: DuckLakeDatasetCatalog
|
|
35
|
+
private readonly maintenance: DuckLakeMaintenance
|
|
36
|
+
private readonly rows: DuckLakeRowReader
|
|
37
|
+
private readonly snapshotReader: DuckLakeSnapshotReader
|
|
38
|
+
private readonly writes: DuckLakeWriteCoordinator
|
|
39
|
+
|
|
40
|
+
constructor(options: DuckLakeStorageOptions) {
|
|
41
|
+
const normalizedOptions: DuckLakeStorageOptions = {
|
|
42
|
+
...options,
|
|
43
|
+
alias: options.alias ?? "sixb_lake",
|
|
44
|
+
createIfNotExists: options.createIfNotExists ?? true,
|
|
45
|
+
readOnly: options.readOnly ?? false,
|
|
46
|
+
duckdb: {
|
|
47
|
+
...options.duckdb,
|
|
48
|
+
path: options.duckdb?.path ?? ":memory:",
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
this.connections = new DuckLakeConnectionManager(normalizedOptions)
|
|
52
|
+
this.datasets = new DuckLakeDatasetCatalog(normalizedOptions, this.connections)
|
|
53
|
+
this.maintenance = new DuckLakeMaintenance(normalizedOptions, this.connections)
|
|
54
|
+
this.snapshotReader = new DuckLakeSnapshotReader(
|
|
55
|
+
normalizedOptions,
|
|
56
|
+
this.connections,
|
|
57
|
+
this.datasets
|
|
58
|
+
)
|
|
59
|
+
this.rows = new DuckLakeRowReader(normalizedOptions, this.connections, this.snapshotReader)
|
|
60
|
+
this.writes = new DuckLakeWriteCoordinator(
|
|
61
|
+
normalizedOptions,
|
|
62
|
+
this.connections,
|
|
63
|
+
this.datasets,
|
|
64
|
+
this.snapshotReader
|
|
65
|
+
)
|
|
66
|
+
this.sql = new DuckLakeSqlExecutor(
|
|
67
|
+
normalizedOptions,
|
|
68
|
+
this.connections,
|
|
69
|
+
this.datasets,
|
|
70
|
+
this.snapshotReader,
|
|
71
|
+
this.writes
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async createDataset(definition: DatasetDefinition): Promise<DatasetDefinition> {
|
|
76
|
+
return this.datasets.createDataset(definition)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async assertDatasetDefinitionsCompatible(
|
|
80
|
+
definitions: readonly DatasetDefinition[]
|
|
81
|
+
): Promise<void> {
|
|
82
|
+
await this.datasets.assertDatasetDefinitionsCompatible(definitions)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async getDataset(datasetId: string): Promise<DatasetDefinition | null> {
|
|
86
|
+
return this.datasets.getDataset(datasetId)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async listDatasets(): Promise<readonly DatasetDefinition[]> {
|
|
90
|
+
return this.datasets.listDatasets()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async listDatasetCatalogState(
|
|
94
|
+
datasetIds: readonly string[]
|
|
95
|
+
): Promise<readonly DatasetCatalogState[]> {
|
|
96
|
+
return this.snapshotReader.listDatasetCatalogState(datasetIds)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async listVersions(datasetId: string, limit?: number): Promise<readonly DatasetVersion[]> {
|
|
100
|
+
return this.snapshotReader.listVersions(datasetId, limit)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async beginWrite(input: BeginDatasetWriteInput): Promise<LakeWriteSession> {
|
|
104
|
+
return this.writes.beginWrite(input)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async getLatestVersion(datasetId: string): Promise<DatasetVersion | null> {
|
|
108
|
+
return this.snapshotReader.getLatestVersion(datasetId)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async getVersion(datasetId: string, versionId: string): Promise<DatasetVersion | null> {
|
|
112
|
+
return this.snapshotReader.getVersion(datasetId, versionId)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
readRows(input: ReadDatasetRowsInput): AsyncIterable<DatasetRow> {
|
|
116
|
+
return this.rows.readRows(input)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async runMaintenance(options?: DuckLakeMaintenanceOptions): Promise<DuckLakeMaintenanceReport> {
|
|
120
|
+
return this.maintenance.runMaintenance(options)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* `close()` is provider-specific and intentionally not part of the core
|
|
125
|
+
* LakeStorage interface.
|
|
126
|
+
*/
|
|
127
|
+
async close(): Promise<void> {
|
|
128
|
+
await this.connections.close()
|
|
129
|
+
}
|
|
130
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { DuckLakeStorage } from "./ducklake-storage"
|
|
2
|
+
export type {
|
|
3
|
+
AzureSecretOptions,
|
|
4
|
+
DuckDbRuntimeOptions,
|
|
5
|
+
DuckDbSecretOptions,
|
|
6
|
+
DuckLakeCatalogOptions,
|
|
7
|
+
DuckLakeMaintenanceOptions,
|
|
8
|
+
DuckLakeMaintenanceReport,
|
|
9
|
+
DuckLakePostgresPoolOptions,
|
|
10
|
+
DuckLakeStorageOptions,
|
|
11
|
+
GcsSecretOptions,
|
|
12
|
+
R2SecretOptions,
|
|
13
|
+
S3SecretOptions,
|
|
14
|
+
} from "./types"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { resolve } from "node:path"
|
|
2
|
+
import type { DuckLakeStorageOptions } from "../types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Stable key for coordinating local catalog users inside this process.
|
|
6
|
+
*
|
|
7
|
+
* PostgreSQL coordinates through the database. In-memory local catalogs have no
|
|
8
|
+
* shared file identity. File-backed local catalogs need equivalent path
|
|
9
|
+
* spellings, such as `lake.ducklake` and `dir/../lake.ducklake`, to map to the
|
|
10
|
+
* same coordination key.
|
|
11
|
+
*/
|
|
12
|
+
export function localCatalogCoordinationKey(
|
|
13
|
+
options: Pick<DuckLakeStorageOptions, "catalog">
|
|
14
|
+
): string | undefined {
|
|
15
|
+
switch (options.catalog.type) {
|
|
16
|
+
case "duckdb":
|
|
17
|
+
case "sqlite":
|
|
18
|
+
if (options.catalog.path === ":memory:") {
|
|
19
|
+
return undefined
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return `${options.catalog.type}:${resolve(options.catalog.path)}`
|
|
23
|
+
case "custom":
|
|
24
|
+
return `custom:${options.catalog.uri}`
|
|
25
|
+
case "postgres":
|
|
26
|
+
return undefined
|
|
27
|
+
}
|
|
28
|
+
}
|