@apache-arrow/adbc-driver-manager 0.23.0
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.txt +523 -0
- package/README.md +130 -0
- package/binding.d.ts +71 -0
- package/binding.js +593 -0
- package/dist/error.d.ts +15 -0
- package/dist/error.js +43 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +386 -0
- package/dist/types.d.ts +398 -0
- package/dist/types.js +112 -0
- package/license.hbs +33 -0
- package/package.json +92 -0
package/dist/error.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
/**
|
|
18
|
+
* Structured error class for ADBC operations.
|
|
19
|
+
*/
|
|
20
|
+
export class AdbcError extends Error {
|
|
21
|
+
code;
|
|
22
|
+
vendorCode;
|
|
23
|
+
sqlState;
|
|
24
|
+
constructor(message, code, vendorCode, sqlState) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = 'AdbcError';
|
|
27
|
+
this.code = code;
|
|
28
|
+
this.vendorCode = vendorCode;
|
|
29
|
+
this.sqlState = sqlState;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Promotes a raw error thrown by the native binding into a structured AdbcError.
|
|
33
|
+
*
|
|
34
|
+
* Non-ADBC errors (e.g. a standard JS TypeError) are returned unmodified.
|
|
35
|
+
*/
|
|
36
|
+
static fromError(err) {
|
|
37
|
+
if (err instanceof Error && err.name === 'AdbcError') {
|
|
38
|
+
const e = err;
|
|
39
|
+
return new AdbcError(e.message, e.code ?? 'UNKNOWN', e.vendorCode, e.sqlState);
|
|
40
|
+
}
|
|
41
|
+
return err;
|
|
42
|
+
}
|
|
43
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { NativeAdbcConnection, NativeAdbcStatement } from '../binding.js';
|
|
2
|
+
import type { AdbcDatabase as AdbcDatabaseInterface, AdbcConnection as AdbcConnectionInterface, AdbcStatement as AdbcStatementInterface, ConnectOptions, GetObjectsOptions, IngestOptions } from './types.js';
|
|
3
|
+
import { LoadFlags, ObjectDepth, InfoCode, IngestMode } from './types.js';
|
|
4
|
+
import { RecordBatchReader, Table, Schema } from 'apache-arrow';
|
|
5
|
+
import { AdbcError } from './error.js';
|
|
6
|
+
declare const asyncDisposeSymbol: any;
|
|
7
|
+
export type { ConnectOptions, GetObjectsOptions, IngestOptions };
|
|
8
|
+
export { AdbcError, LoadFlags, ObjectDepth, InfoCode, IngestMode };
|
|
9
|
+
/**
|
|
10
|
+
* Represents an ADBC Database.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AdbcDatabase implements AdbcDatabaseInterface {
|
|
13
|
+
[asyncDisposeSymbol]: () => Promise<void>;
|
|
14
|
+
private _inner;
|
|
15
|
+
constructor(options: ConnectOptions);
|
|
16
|
+
connect(): Promise<AdbcConnection>;
|
|
17
|
+
close(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Represents a single connection to a database.
|
|
21
|
+
*/
|
|
22
|
+
export declare class AdbcConnection implements AdbcConnectionInterface {
|
|
23
|
+
[asyncDisposeSymbol]: () => Promise<void>;
|
|
24
|
+
private _inner;
|
|
25
|
+
constructor(inner: NativeAdbcConnection);
|
|
26
|
+
createStatement(): Promise<AdbcStatement>;
|
|
27
|
+
setOption(key: string, value: string): void;
|
|
28
|
+
setAutoCommit(enabled: boolean): void;
|
|
29
|
+
setReadOnly(enabled: boolean): void;
|
|
30
|
+
getObjects(options?: GetObjectsOptions): Promise<Table>;
|
|
31
|
+
getTableSchema(options: {
|
|
32
|
+
catalog?: string;
|
|
33
|
+
dbSchema?: string;
|
|
34
|
+
tableName: string;
|
|
35
|
+
}): Promise<Schema>;
|
|
36
|
+
getTableTypes(): Promise<Table>;
|
|
37
|
+
getInfo(infoCodes?: InfoCode[]): Promise<Table>;
|
|
38
|
+
query(sql: string, params?: Table): Promise<Table>;
|
|
39
|
+
queryStream(sql: string, params?: Table): Promise<RecordBatchReader>;
|
|
40
|
+
private setIngestOptions;
|
|
41
|
+
ingest(tableName: string, data: Table, options?: IngestOptions): Promise<number>;
|
|
42
|
+
ingestStream(tableName: string, reader: RecordBatchReader, options?: IngestOptions): Promise<number>;
|
|
43
|
+
execute(sql: string, params?: Table): Promise<number>;
|
|
44
|
+
commit(): Promise<void>;
|
|
45
|
+
rollback(): Promise<void>;
|
|
46
|
+
close(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Represents a query statement.
|
|
50
|
+
*/
|
|
51
|
+
export declare class AdbcStatement implements AdbcStatementInterface {
|
|
52
|
+
[asyncDisposeSymbol]: () => Promise<void>;
|
|
53
|
+
private _inner;
|
|
54
|
+
constructor(inner: NativeAdbcStatement);
|
|
55
|
+
setSqlQuery(query: string): Promise<void>;
|
|
56
|
+
setOption(key: string, value: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Execute the query and return a RecordBatchReader.
|
|
59
|
+
*
|
|
60
|
+
* Per the ADBC spec, behavior is undefined if the statement is reused after
|
|
61
|
+
* calling executeQuery(). Create a new statement for each query.
|
|
62
|
+
*/
|
|
63
|
+
executeQuery(): Promise<RecordBatchReader>;
|
|
64
|
+
executeUpdate(): Promise<number>;
|
|
65
|
+
bind(data: Table): Promise<void>;
|
|
66
|
+
bindStream(reader: RecordBatchReader): Promise<void>;
|
|
67
|
+
close(): Promise<void>;
|
|
68
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
// Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
import { NativeAdbcDatabase } from '../binding.js';
|
|
18
|
+
import { LoadFlags, ObjectDepth, InfoCode, IngestMode } from './types.js';
|
|
19
|
+
import { RecordBatchReader, Table, tableToIPC } from 'apache-arrow';
|
|
20
|
+
import { AdbcError } from './error.js';
|
|
21
|
+
// Safely define Symbol.asyncDispose for compatibility with Node.js environments older than v21.
|
|
22
|
+
const asyncDisposeSymbol = Symbol.asyncDispose ?? Symbol('Symbol.asyncDispose');
|
|
23
|
+
async function readerToTable(reader) {
|
|
24
|
+
const batches = [];
|
|
25
|
+
for await (const batch of reader) {
|
|
26
|
+
batches.push(batch);
|
|
27
|
+
}
|
|
28
|
+
return new Table(batches);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Converts the native result iterator into an Apache Arrow `RecordBatchReader`.
|
|
32
|
+
*
|
|
33
|
+
* The native iterator yields Arrow IPC stream bytes (schema + record batches) as a
|
|
34
|
+
* Node.js `Buffer`. Since `Buffer` is a subclass of `Uint8Array`, we can wrap the
|
|
35
|
+
* iterator directly as `AsyncIterable<Uint8Array>` and pass it to
|
|
36
|
+
* `RecordBatchReader.from()`, which accepts an async iterable of IPC bytes and
|
|
37
|
+
* returns a standard Arrow `RecordBatchReader`.
|
|
38
|
+
*/
|
|
39
|
+
async function iteratorToReader(iterator) {
|
|
40
|
+
const asyncIterable = {
|
|
41
|
+
[Symbol.asyncIterator]: async function* () {
|
|
42
|
+
try {
|
|
43
|
+
while (true) {
|
|
44
|
+
const chunk = await iterator.next().catch((e) => {
|
|
45
|
+
throw AdbcError.fromError(e);
|
|
46
|
+
});
|
|
47
|
+
if (!chunk) {
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
yield chunk;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
try {
|
|
55
|
+
iterator.close();
|
|
56
|
+
}
|
|
57
|
+
catch { }
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
return RecordBatchReader.from(asyncIterable);
|
|
62
|
+
}
|
|
63
|
+
export { AdbcError, LoadFlags, ObjectDepth, InfoCode, IngestMode };
|
|
64
|
+
/**
|
|
65
|
+
* Represents an ADBC Database.
|
|
66
|
+
*/
|
|
67
|
+
export class AdbcDatabase {
|
|
68
|
+
_inner;
|
|
69
|
+
constructor(options) {
|
|
70
|
+
try {
|
|
71
|
+
this._inner = new NativeAdbcDatabase(options);
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
throw AdbcError.fromError(e);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async connect() {
|
|
78
|
+
try {
|
|
79
|
+
const connInner = await this._inner.connect(null);
|
|
80
|
+
return new AdbcConnection(connInner);
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
throw AdbcError.fromError(e);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async close() {
|
|
87
|
+
try {
|
|
88
|
+
await this._inner.close();
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
throw AdbcError.fromError(e);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async [asyncDisposeSymbol]() {
|
|
95
|
+
return this.close();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Represents a single connection to a database.
|
|
100
|
+
*/
|
|
101
|
+
export class AdbcConnection {
|
|
102
|
+
_inner;
|
|
103
|
+
constructor(inner) {
|
|
104
|
+
this._inner = inner;
|
|
105
|
+
}
|
|
106
|
+
async createStatement() {
|
|
107
|
+
try {
|
|
108
|
+
const stmtInner = await this._inner.createStatement();
|
|
109
|
+
return new AdbcStatement(stmtInner);
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
throw AdbcError.fromError(e);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
setOption(key, value) {
|
|
116
|
+
try {
|
|
117
|
+
this._inner.setOption(key, value);
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
throw AdbcError.fromError(e);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
setAutoCommit(enabled) {
|
|
124
|
+
this.setOption('adbc.connection.autocommit', enabled ? 'true' : 'false');
|
|
125
|
+
}
|
|
126
|
+
setReadOnly(enabled) {
|
|
127
|
+
this.setOption('adbc.connection.read_only', enabled ? 'true' : 'false');
|
|
128
|
+
}
|
|
129
|
+
async getObjects(options) {
|
|
130
|
+
try {
|
|
131
|
+
const opts = {
|
|
132
|
+
depth: options?.depth ?? 0,
|
|
133
|
+
catalog: options?.catalog,
|
|
134
|
+
dbSchema: options?.dbSchema,
|
|
135
|
+
tableName: options?.tableName,
|
|
136
|
+
tableType: options?.tableType,
|
|
137
|
+
columnName: options?.columnName,
|
|
138
|
+
};
|
|
139
|
+
const iterator = await this._inner.getObjects(opts);
|
|
140
|
+
return readerToTable(await iteratorToReader(iterator));
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
throw AdbcError.fromError(e);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async getTableSchema(options) {
|
|
147
|
+
try {
|
|
148
|
+
const buffer = await this._inner.getTableSchema(options);
|
|
149
|
+
const reader = RecordBatchReader.from(buffer);
|
|
150
|
+
if (!reader.schema) {
|
|
151
|
+
await reader.next();
|
|
152
|
+
}
|
|
153
|
+
return reader.schema;
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
throw AdbcError.fromError(e);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async getTableTypes() {
|
|
160
|
+
try {
|
|
161
|
+
const iterator = await this._inner.getTableTypes();
|
|
162
|
+
return readerToTable(await iteratorToReader(iterator));
|
|
163
|
+
}
|
|
164
|
+
catch (e) {
|
|
165
|
+
throw AdbcError.fromError(e);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async getInfo(infoCodes) {
|
|
169
|
+
try {
|
|
170
|
+
const iterator = await this._inner.getInfo(infoCodes);
|
|
171
|
+
return readerToTable(await iteratorToReader(iterator));
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
throw AdbcError.fromError(e);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async query(sql, params) {
|
|
178
|
+
return readerToTable(await this.queryStream(sql, params));
|
|
179
|
+
}
|
|
180
|
+
async queryStream(sql, params) {
|
|
181
|
+
const stmt = await this.createStatement();
|
|
182
|
+
try {
|
|
183
|
+
await stmt.setSqlQuery(sql);
|
|
184
|
+
if (params !== undefined) {
|
|
185
|
+
await stmt.bind(params);
|
|
186
|
+
}
|
|
187
|
+
return await stmt.executeQuery();
|
|
188
|
+
}
|
|
189
|
+
finally {
|
|
190
|
+
await stmt.close();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
setIngestOptions(stmt, tableName, options) {
|
|
194
|
+
stmt.setOption('adbc.ingest.target_table', tableName);
|
|
195
|
+
stmt.setOption('adbc.ingest.mode', options?.mode ?? IngestMode.Create);
|
|
196
|
+
if (options?.catalog !== undefined) {
|
|
197
|
+
stmt.setOption('adbc.ingest.target_catalog', options.catalog);
|
|
198
|
+
}
|
|
199
|
+
if (options?.dbSchema !== undefined) {
|
|
200
|
+
stmt.setOption('adbc.ingest.target_db_schema', options.dbSchema);
|
|
201
|
+
}
|
|
202
|
+
if (options?.temporary === true) {
|
|
203
|
+
stmt.setOption('adbc.ingest.temporary', 'true');
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async ingest(tableName, data, options) {
|
|
207
|
+
const stmt = await this.createStatement();
|
|
208
|
+
try {
|
|
209
|
+
this.setIngestOptions(stmt, tableName, options);
|
|
210
|
+
await stmt.bind(data);
|
|
211
|
+
return await stmt.executeUpdate();
|
|
212
|
+
}
|
|
213
|
+
finally {
|
|
214
|
+
await stmt.close();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
async ingestStream(tableName, reader, options) {
|
|
218
|
+
const nativeStmt = (await this._inner.createStatement());
|
|
219
|
+
try {
|
|
220
|
+
this.setIngestOptions(nativeStmt, tableName, options);
|
|
221
|
+
await reader.open();
|
|
222
|
+
const schemaTable = new Table(reader.schema, []);
|
|
223
|
+
const schemaBytes = tableToIPC(schemaTable, 'stream');
|
|
224
|
+
const promise = nativeStmt.startBindStreamExecute(Buffer.from(schemaBytes));
|
|
225
|
+
let pushError;
|
|
226
|
+
try {
|
|
227
|
+
for await (const batch of reader) {
|
|
228
|
+
const batchBytes = tableToIPC(new Table([batch]), 'stream');
|
|
229
|
+
nativeStmt.pushBatch(Buffer.from(batchBytes));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
catch (e) {
|
|
233
|
+
pushError = e;
|
|
234
|
+
}
|
|
235
|
+
finally {
|
|
236
|
+
nativeStmt.endStream();
|
|
237
|
+
}
|
|
238
|
+
const result = (await promise);
|
|
239
|
+
if (pushError)
|
|
240
|
+
throw pushError;
|
|
241
|
+
return result;
|
|
242
|
+
}
|
|
243
|
+
catch (e) {
|
|
244
|
+
throw AdbcError.fromError(e);
|
|
245
|
+
}
|
|
246
|
+
finally {
|
|
247
|
+
nativeStmt.close();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
async execute(sql, params) {
|
|
251
|
+
const stmt = await this.createStatement();
|
|
252
|
+
try {
|
|
253
|
+
await stmt.setSqlQuery(sql);
|
|
254
|
+
if (params !== undefined) {
|
|
255
|
+
await stmt.bind(params);
|
|
256
|
+
}
|
|
257
|
+
return await stmt.executeUpdate();
|
|
258
|
+
}
|
|
259
|
+
finally {
|
|
260
|
+
await stmt.close();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
async commit() {
|
|
264
|
+
try {
|
|
265
|
+
await this._inner.commit();
|
|
266
|
+
}
|
|
267
|
+
catch (e) {
|
|
268
|
+
throw AdbcError.fromError(e);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
async rollback() {
|
|
272
|
+
try {
|
|
273
|
+
await this._inner.rollback();
|
|
274
|
+
}
|
|
275
|
+
catch (e) {
|
|
276
|
+
throw AdbcError.fromError(e);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
async close() {
|
|
280
|
+
try {
|
|
281
|
+
await this._inner.close();
|
|
282
|
+
}
|
|
283
|
+
catch (e) {
|
|
284
|
+
throw AdbcError.fromError(e);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
async [asyncDisposeSymbol]() {
|
|
288
|
+
return this.close();
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Represents a query statement.
|
|
293
|
+
*/
|
|
294
|
+
export class AdbcStatement {
|
|
295
|
+
_inner;
|
|
296
|
+
constructor(inner) {
|
|
297
|
+
this._inner = inner;
|
|
298
|
+
}
|
|
299
|
+
async setSqlQuery(query) {
|
|
300
|
+
try {
|
|
301
|
+
this._inner.setSqlQuery(query);
|
|
302
|
+
}
|
|
303
|
+
catch (e) {
|
|
304
|
+
throw AdbcError.fromError(e);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
setOption(key, value) {
|
|
308
|
+
try {
|
|
309
|
+
this._inner.setOption(key, value);
|
|
310
|
+
}
|
|
311
|
+
catch (e) {
|
|
312
|
+
throw AdbcError.fromError(e);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Execute the query and return a RecordBatchReader.
|
|
317
|
+
*
|
|
318
|
+
* Per the ADBC spec, behavior is undefined if the statement is reused after
|
|
319
|
+
* calling executeQuery(). Create a new statement for each query.
|
|
320
|
+
*/
|
|
321
|
+
async executeQuery() {
|
|
322
|
+
try {
|
|
323
|
+
const iterator = await this._inner.executeQuery();
|
|
324
|
+
return iteratorToReader(iterator);
|
|
325
|
+
}
|
|
326
|
+
catch (e) {
|
|
327
|
+
throw AdbcError.fromError(e);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
async executeUpdate() {
|
|
331
|
+
try {
|
|
332
|
+
const rows = await this._inner.executeUpdate();
|
|
333
|
+
return rows;
|
|
334
|
+
}
|
|
335
|
+
catch (e) {
|
|
336
|
+
throw AdbcError.fromError(e);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
async bind(data) {
|
|
340
|
+
try {
|
|
341
|
+
const ipcBytes = tableToIPC(data, 'stream');
|
|
342
|
+
await this._inner.bind(Buffer.from(ipcBytes));
|
|
343
|
+
}
|
|
344
|
+
catch (e) {
|
|
345
|
+
throw AdbcError.fromError(e);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
async bindStream(reader) {
|
|
349
|
+
try {
|
|
350
|
+
await reader.open();
|
|
351
|
+
const schemaTable = new Table(reader.schema, []);
|
|
352
|
+
const schemaBytes = tableToIPC(schemaTable, 'stream');
|
|
353
|
+
const bindPromise = this._inner.startBindStream(Buffer.from(schemaBytes));
|
|
354
|
+
let pushError;
|
|
355
|
+
try {
|
|
356
|
+
for await (const batch of reader) {
|
|
357
|
+
const batchBytes = tableToIPC(new Table([batch]), 'stream');
|
|
358
|
+
this._inner.pushBatch(Buffer.from(batchBytes));
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
catch (e) {
|
|
362
|
+
pushError = e;
|
|
363
|
+
}
|
|
364
|
+
finally {
|
|
365
|
+
this._inner.endStream();
|
|
366
|
+
}
|
|
367
|
+
await bindPromise;
|
|
368
|
+
if (pushError)
|
|
369
|
+
throw pushError;
|
|
370
|
+
}
|
|
371
|
+
catch (e) {
|
|
372
|
+
throw AdbcError.fromError(e);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
async close() {
|
|
376
|
+
try {
|
|
377
|
+
await this._inner.close();
|
|
378
|
+
}
|
|
379
|
+
catch (e) {
|
|
380
|
+
throw AdbcError.fromError(e);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
async [asyncDisposeSymbol]() {
|
|
384
|
+
return this.close();
|
|
385
|
+
}
|
|
386
|
+
}
|