@malloydata/db-duckdb 0.0.335 → 0.0.336
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/dist/duckdb_common.d.ts +1 -0
- package/dist/duckdb_connection.d.ts +6 -0
- package/dist/duckdb_connection.js +21 -2
- package/dist/duckdb_wasm_connection.d.ts +1 -0
- package/dist/duckdb_wasm_connection.js +5 -0
- package/dist/duckdb_wasm_connection_browser.js +2 -7
- package/dist/duckdb_wasm_connection_node.js +2 -5
- package/package.json +2 -2
package/dist/duckdb_common.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare abstract class DuckDBCommon extends BaseConnection implements Tes
|
|
|
15
15
|
constructor(queryOptions?: QueryOptionsReader | undefined);
|
|
16
16
|
isPool(): this is PooledConnection;
|
|
17
17
|
canPersist(): this is PersistSQLResults;
|
|
18
|
+
abstract getDigest(): string;
|
|
18
19
|
protected abstract setup(): Promise<void>;
|
|
19
20
|
protected abstract runDuckDBQuery(sql: string): Promise<{
|
|
20
21
|
rows: QueryDataRow[];
|
|
@@ -26,6 +26,7 @@ export declare class DuckDBConnection extends DuckDBCommon {
|
|
|
26
26
|
static activeDBs: Record<string, ActiveDB>;
|
|
27
27
|
constructor(options: DuckDBConnectionOptions, queryOptions?: QueryOptionsReader);
|
|
28
28
|
constructor(name: string, databasePath?: string, workingDirectory?: string, queryOptions?: QueryOptionsReader);
|
|
29
|
+
getDigest(): string;
|
|
29
30
|
private init;
|
|
30
31
|
loadExtension(ext: string): Promise<void>;
|
|
31
32
|
protected setup(): Promise<void>;
|
|
@@ -36,5 +37,10 @@ export declare class DuckDBConnection extends DuckDBCommon {
|
|
|
36
37
|
runSQLStream(sql: string, { rowLimit, abortSignal }?: RunSQLOptions): AsyncIterableIterator<QueryDataRow>;
|
|
37
38
|
createHash(sqlCommand: string): Promise<string>;
|
|
38
39
|
close(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Forcefully close all cached DuckDB instances. Useful for test cleanup
|
|
42
|
+
* to release file locks between test runs.
|
|
43
|
+
*/
|
|
44
|
+
static closeAllInstances(): void;
|
|
39
45
|
}
|
|
40
46
|
export {};
|
|
@@ -26,9 +26,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
exports.DuckDBConnection = void 0;
|
|
29
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
30
29
|
const duckdb_common_1 = require("./duckdb_common");
|
|
31
30
|
const node_api_1 = require("@duckdb/node-api");
|
|
31
|
+
const malloy_1 = require("@malloydata/malloy");
|
|
32
32
|
const package_json_1 = __importDefault(require("@malloydata/malloy/package.json"));
|
|
33
33
|
class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
|
|
34
34
|
constructor(arg, arg2, workingDirectory, queryOptions) {
|
|
@@ -79,6 +79,10 @@ class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
|
|
|
79
79
|
this.databasePath.startsWith('motherduck:');
|
|
80
80
|
this.connecting = this.init();
|
|
81
81
|
}
|
|
82
|
+
getDigest() {
|
|
83
|
+
const data = `duckdb:${this.databasePath}:${this.workingDirectory}`;
|
|
84
|
+
return (0, malloy_1.makeDigest)(data);
|
|
85
|
+
}
|
|
82
86
|
async init() {
|
|
83
87
|
try {
|
|
84
88
|
if (this.databasePath in DuckDBConnection.activeDBs) {
|
|
@@ -202,7 +206,7 @@ class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
|
|
|
202
206
|
}
|
|
203
207
|
}
|
|
204
208
|
async createHash(sqlCommand) {
|
|
205
|
-
return
|
|
209
|
+
return (0, malloy_1.makeDigest)(sqlCommand);
|
|
206
210
|
}
|
|
207
211
|
async close() {
|
|
208
212
|
const activeDB = DuckDBConnection.activeDBs[this.databasePath];
|
|
@@ -214,6 +218,21 @@ class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
|
|
|
214
218
|
}
|
|
215
219
|
}
|
|
216
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Forcefully close all cached DuckDB instances. Useful for test cleanup
|
|
223
|
+
* to release file locks between test runs.
|
|
224
|
+
*/
|
|
225
|
+
static closeAllInstances() {
|
|
226
|
+
for (const path of Object.keys(DuckDBConnection.activeDBs)) {
|
|
227
|
+
try {
|
|
228
|
+
DuckDBConnection.activeDBs[path].instance.closeSync();
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
// Ignore errors during cleanup
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
DuckDBConnection.activeDBs = {};
|
|
235
|
+
}
|
|
217
236
|
}
|
|
218
237
|
exports.DuckDBConnection = DuckDBConnection;
|
|
219
238
|
DuckDBConnection.activeDBs = {};
|
|
@@ -23,6 +23,7 @@ export declare abstract class DuckDBWASMConnection extends DuckDBCommon {
|
|
|
23
23
|
private remoteFileStatus;
|
|
24
24
|
constructor(options: DuckDBWasmOptions, queryOptions?: QueryOptionsReader);
|
|
25
25
|
constructor(name: string, databasePath?: string | null, workingDirectory?: string, queryOptions?: QueryOptionsReader);
|
|
26
|
+
getDigest(): string;
|
|
26
27
|
protected init(): Promise<void>;
|
|
27
28
|
abstract getBundles(): duckdb.DuckDBBundles;
|
|
28
29
|
get connection(): duckdb.AsyncDuckDBConnection | null;
|
|
@@ -61,6 +61,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
61
61
|
exports.DuckDBWASMConnection = void 0;
|
|
62
62
|
const duckdb = __importStar(require("@duckdb/duckdb-wasm"));
|
|
63
63
|
const web_worker_1 = __importDefault(require("web-worker"));
|
|
64
|
+
const malloy_1 = require("@malloydata/malloy");
|
|
64
65
|
const apache_arrow_1 = require("apache-arrow");
|
|
65
66
|
const duckdb_common_1 = require("./duckdb_common");
|
|
66
67
|
const TABLE_MATCH = /FROM\s*('([^']*)'|"([^"]*)")/gi;
|
|
@@ -275,6 +276,10 @@ class DuckDBWASMConnection extends duckdb_common_1.DuckDBCommon {
|
|
|
275
276
|
false;
|
|
276
277
|
this.connecting = this.init();
|
|
277
278
|
}
|
|
279
|
+
getDigest() {
|
|
280
|
+
var _a;
|
|
281
|
+
return (0, malloy_1.makeDigest)('duckdb-wasm', (_a = this.databasePath) !== null && _a !== void 0 ? _a : ':memory:', this.workingDirectory);
|
|
282
|
+
}
|
|
278
283
|
async init() {
|
|
279
284
|
// Select a bundle based on browser checks
|
|
280
285
|
const bundle = await duckdb.selectBundle(this.getBundles());
|
|
@@ -59,6 +59,7 @@ exports.DuckDBWASMConnection = void 0;
|
|
|
59
59
|
const duckdb = __importStar(require("@duckdb/duckdb-wasm"));
|
|
60
60
|
const duckdb_wasm_connection_1 = require("./duckdb_wasm_connection");
|
|
61
61
|
const wasm_client_1 = require("@motherduck/wasm-client");
|
|
62
|
+
const malloy_1 = require("@malloydata/malloy");
|
|
62
63
|
function unwrapMotherDuck(value) {
|
|
63
64
|
let result = null;
|
|
64
65
|
if (value !== null && typeof value === 'object') {
|
|
@@ -198,13 +199,7 @@ class DuckDBWASMConnection extends duckdb_wasm_connection_1.DuckDBWASMConnection
|
|
|
198
199
|
}
|
|
199
200
|
}
|
|
200
201
|
async createHash(sqlCommand) {
|
|
201
|
-
|
|
202
|
-
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8);
|
|
203
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
204
|
-
const hashHex = hashArray
|
|
205
|
-
.map(b => b.toString(16).padStart(2, '0'))
|
|
206
|
-
.join('');
|
|
207
|
-
return hashHex;
|
|
202
|
+
return (0, malloy_1.makeDigest)(sqlCommand);
|
|
208
203
|
}
|
|
209
204
|
}
|
|
210
205
|
exports.DuckDBWASMConnection = DuckDBWASMConnection;
|
|
@@ -21,13 +21,10 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
-
};
|
|
27
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
25
|
exports.DuckDBWASMConnection = void 0;
|
|
29
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
30
26
|
const duckdb_wasm_connection_1 = require("./duckdb_wasm_connection");
|
|
27
|
+
const malloy_1 = require("@malloydata/malloy");
|
|
31
28
|
class DuckDBWASMConnection extends duckdb_wasm_connection_1.DuckDBWASMConnection {
|
|
32
29
|
getBundles() {
|
|
33
30
|
const resolvePath = require.resolve('@duckdb/duckdb-wasm');
|
|
@@ -51,7 +48,7 @@ class DuckDBWASMConnection extends duckdb_wasm_connection_1.DuckDBWASMConnection
|
|
|
51
48
|
};
|
|
52
49
|
}
|
|
53
50
|
async createHash(sqlCommand) {
|
|
54
|
-
return
|
|
51
|
+
return (0, malloy_1.makeDigest)(sqlCommand);
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
54
|
exports.DuckDBWASMConnection = DuckDBWASMConnection;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-duckdb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.336",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@duckdb/duckdb-wasm": "1.33.1-dev13.0",
|
|
48
48
|
"@duckdb/node-api": "1.4.3-r.1",
|
|
49
|
-
"@malloydata/malloy": "0.0.
|
|
49
|
+
"@malloydata/malloy": "0.0.336",
|
|
50
50
|
"@motherduck/wasm-client": "^0.6.6",
|
|
51
51
|
"apache-arrow": "^17.0.0",
|
|
52
52
|
"web-worker": "^1.3.0"
|