@malloydata/db-duckdb 0.0.41-dev230615144150 → 0.0.41-dev230615174435
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.
|
@@ -5,11 +5,11 @@ declare type RemoteFileCallback = (tableName: string) => Promise<Uint8Array | un
|
|
|
5
5
|
export declare abstract class DuckDBWASMConnection extends DuckDBCommon {
|
|
6
6
|
readonly name: string;
|
|
7
7
|
private databasePath;
|
|
8
|
-
|
|
8
|
+
protected workingDirectory: string;
|
|
9
9
|
connecting: Promise<void>;
|
|
10
10
|
protected _connection: duckdb.AsyncDuckDBConnection | null;
|
|
11
11
|
protected _database: duckdb.AsyncDuckDB | null;
|
|
12
|
-
protected isSetup:
|
|
12
|
+
protected isSetup: Promise<void> | undefined;
|
|
13
13
|
private worker;
|
|
14
14
|
private remoteFileCallbacks;
|
|
15
15
|
private remoteFileStatus;
|
|
@@ -18,6 +18,7 @@ export declare abstract class DuckDBWASMConnection extends DuckDBCommon {
|
|
|
18
18
|
abstract getBundles(): duckdb.DuckDBBundles;
|
|
19
19
|
get connection(): duckdb.AsyncDuckDBConnection | null;
|
|
20
20
|
get database(): duckdb.AsyncDuckDB | null;
|
|
21
|
+
loadExtension(ext: string): Promise<void>;
|
|
21
22
|
protected setup(): Promise<void>;
|
|
22
23
|
protected runDuckDBQuery(sql: string): Promise<{
|
|
23
24
|
rows: QueryDataRow[];
|
|
@@ -94,7 +94,9 @@ const unwrapArrow = (value) => {
|
|
|
94
94
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
95
|
const result = {};
|
|
96
96
|
for (const key in obj) {
|
|
97
|
-
|
|
97
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
98
|
+
result[key] = unwrapArrow(obj[key]);
|
|
99
|
+
}
|
|
98
100
|
}
|
|
99
101
|
return result;
|
|
100
102
|
}
|
|
@@ -126,7 +128,6 @@ class DuckDBWASMConnection extends duckdb_common_1.DuckDBCommon {
|
|
|
126
128
|
this.workingDirectory = workingDirectory;
|
|
127
129
|
this._connection = null;
|
|
128
130
|
this._database = null;
|
|
129
|
-
this.isSetup = false;
|
|
130
131
|
this.worker = null;
|
|
131
132
|
this.remoteFileCallbacks = [];
|
|
132
133
|
this.remoteFileStatus = {};
|
|
@@ -164,8 +165,31 @@ class DuckDBWASMConnection extends duckdb_common_1.DuckDBCommon {
|
|
|
164
165
|
get database() {
|
|
165
166
|
return this._database;
|
|
166
167
|
}
|
|
168
|
+
async loadExtension(ext) {
|
|
169
|
+
try {
|
|
170
|
+
await this.runDuckDBQuery(`INSTALL '${ext}'`);
|
|
171
|
+
await this.runDuckDBQuery(`LOAD '${ext}'`);
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
// eslint-disable-next-line no-console
|
|
175
|
+
console.error(`Unable to load ${ext} extension`, error);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
167
178
|
async setup() {
|
|
179
|
+
const doSetup = async () => {
|
|
180
|
+
if (this.workingDirectory) {
|
|
181
|
+
await this.runDuckDBQuery(`SET FILE_SEARCH_PATH='${this.workingDirectory}'`);
|
|
182
|
+
}
|
|
183
|
+
// Not quite ready for prime time
|
|
184
|
+
// for (const ext of ['json', 'httpfs', 'icu']) {
|
|
185
|
+
// await this.loadExtension(ext);
|
|
186
|
+
// }
|
|
187
|
+
};
|
|
168
188
|
await this.connecting;
|
|
189
|
+
if (!this.isSetup) {
|
|
190
|
+
this.isSetup = doSetup();
|
|
191
|
+
}
|
|
192
|
+
await this.isSetup;
|
|
169
193
|
}
|
|
170
194
|
async runDuckDBQuery(sql) {
|
|
171
195
|
var _a;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-duckdb",
|
|
3
|
-
"version": "0.0.41-
|
|
3
|
+
"version": "0.0.41-dev230615174435",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"prepublishOnly": "npm run build"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@malloydata/duckdb-wasm": "0.0.
|
|
44
|
-
"@malloydata/malloy": "^0.0.
|
|
43
|
+
"@malloydata/duckdb-wasm": "0.0.2",
|
|
44
|
+
"@malloydata/malloy": "^0.0.40",
|
|
45
45
|
"apache-arrow": "^11.0.0",
|
|
46
|
-
"duckdb": "0.
|
|
46
|
+
"duckdb": "0.8.1",
|
|
47
47
|
"web-worker": "^1.2.0"
|
|
48
48
|
}
|
|
49
49
|
}
|