@@ -2,6 +2,7 @@ import {getArrowTableSchema, isArrowTable, loadArrow} from "./arrow.js";
2
2
import { duckdb } from "./dependencies.js" ;
3
3
import { FileAttachment } from "./fileAttachment.js" ;
4
4
import { cdn } from "./require.js" ;
5
+ import { isArqueroTable } from "./table.js" ;
5
6
6
7
// Adapted from https://observablehq.com/@cmudig /duckdb-client
7
8
// Copyright 2021 CMU Data Interaction Group
@@ -134,6 +135,8 @@ export class DuckDBClient {
134
135
await insertArrowTable ( db , name , source ) ;
135
136
} else if ( Array . isArray ( source ) ) { // bare array of objects
136
137
await insertArray ( db , name , source ) ;
138
+ } else if ( isArqueroTable ( source ) ) {
139
+ await insertArqueroTable ( db , name , source ) ;
137
140
} else if ( "data" in source ) { // data + options
138
141
const { data, ...options } = source ;
139
142
if ( isArrowTable ( data ) ) {
@@ -215,6 +218,14 @@ async function insertArrowTable(database, name, table, options) {
215
218
}
216
219
}
217
220
221
+ async function insertArqueroTable ( database , name , source ) {
222
+ // TODO When we have stdlib versioning and can upgrade Arquero to version 5,
223
+ // we can then call source.toArrow() directly, with insertArrowTable()
224
+ const arrow = await loadArrow ( ) ;
225
+ const table = arrow . tableFromIPC ( source . toArrowBuffer ( ) ) ;
226
+ return await insertArrowTable ( database , name , table ) ;
227
+ }
228
+
218
229
async function insertArray ( database , name , array , options ) {
219
230
const arrow = await loadArrow ( ) ;
220
231
const table = arrow . tableFromJSON ( array ) ;
0 commit comments