@@ -2,6 +2,7 @@ import {getArrowTableSchema, isArrowTable, loadArrow} from "./arrow.js";
22import { duckdb } from "./dependencies.js" ;
33import { FileAttachment } from "./fileAttachment.js" ;
44import { cdn } from "./require.js" ;
5+ import { isArqueroTable } from "./table.js" ;
56
67// Adapted from https://observablehq.com/@cmudig /duckdb-client
78// Copyright 2021 CMU Data Interaction Group
@@ -134,6 +135,8 @@ export class DuckDBClient {
134135 await insertArrowTable ( db , name , source ) ;
135136 } else if ( Array . isArray ( source ) ) { // bare array of objects
136137 await insertArray ( db , name , source ) ;
138+ } else if ( isArqueroTable ( source ) ) {
139+ await insertArqueroTable ( db , name , source ) ;
137140 } else if ( "data" in source ) { // data + options
138141 const { data, ...options } = source ;
139142 if ( isArrowTable ( data ) ) {
@@ -215,6 +218,14 @@ async function insertArrowTable(database, name, table, options) {
215218 }
216219}
217220
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+
218229async function insertArray ( database , name , array , options ) {
219230 const arrow = await loadArrow ( ) ;
220231 const table = arrow . tableFromJSON ( array ) ;
0 commit comments