import { AsyncDuckDB, DuckDBConfig } from '@duckdb/duckdb-wasm'; export { AsyncDuckDB } from '@duckdb/duckdb-wasm'; import { Table } from 'apache-arrow'; export { Table as Arrow } from 'apache-arrow'; /** * React hook to access a singleton DuckDb instance within components or other hooks. */ declare const useDuckDb: () => { db: AsyncDuckDB | undefined; loading: boolean; error: Error | undefined; }; /** * Execute a SQL query and return the result as Arrow. * * Wait for DuckDB to initialize if necessary. * * If sql is undefined, returns undefined. */ declare const useDuckDbQuery: (sql: string | undefined) => { arrow: Table | undefined; loading: boolean; error: Error | undefined; }; /** * Initialize DuckDB, ensuring we only initialize it once. * * @param debug If true, log DuckDB logs and elapsed times to the console. * @param config An optional DuckDBConfig object. */ declare function initializeDuckDb(options?: { debug?: boolean; config?: DuckDBConfig; }): Promise; /** * Get the instance of DuckDB, initializing it if needed. * * Typically `useDuckDB` is used in React components instead, but this * method provides access outside of React contexts. */ declare const getDuckDB: () => Promise; /** * A few convenient utility queries. */ /** * Drop a table or view with a given name. */ declare const drop: (db: AsyncDuckDB, name: string) => Promise; /** * Compute the cardinalities of all columns in the table with a given name. */ declare const cardinalities: (db: AsyncDuckDB, name: string) => Promise>; /** * Execute a SQL query, and return the result as an Apache Arrow table. */ declare const runQuery: (db: AsyncDuckDB, sql: string) => Promise; /** * Create a temporary unique filename, to avoid collisions. */ declare const getTempFilename: () => string; type JSONPrimitive = string | number | boolean | null; type JSONValue = JSONPrimitive | readonly JSONValue[] | { [key: string]: JSONValue; }; type JSONObject = Record; declare const ARROW_MIME_TYPE = "application/vnd.apache.arrow.file"; /** * Is a given object an Arrow table? */ declare const isArrow: (obj: unknown) => obj is Table; /** * Is a given File a valid Arrow IPC file? */ declare const isArrowFile: (file: File) => Promise; /** * Load an Arrow table from an IPC file, as an ArrayBuffer. */ declare const arrayBufferToArrow: (arrayBuffer: ArrayBuffer) => Table; /** * Convert an Arrow to an IPC file, as an ArrayBuffer. */ declare const arrowToArrayBuffer: (arrow: Table) => ArrayBuffer; /** * Convert an Apache Arrow table to an array of JSON row objects. */ declare function arrowToJSON(arrow: Table): Record[]; declare const CSV_MIME_TYPE = "text/csv"; /** * Export files from DuckDB. */ /** * Export a table (or view) to an Arrow file with a given filename. */ declare const exportArrow: (db: AsyncDuckDB, tableName: string, filename?: string) => Promise; /** * Export a table (or view) to a CSV file with a given filename. */ declare const exportCsv: (db: AsyncDuckDB, tableName: string, filename?: string, delimiter?: string) => Promise; /** * Export a table to Parquet. * * Uses zstd compression by default, which seems to be both smaller & faster for many files. */ declare const exportParquet: (db: AsyncDuckDB, tableName: string, filename?: string, compression?: "uncompressed" | "snappy" | "gzip" | "zstd") => Promise; declare class InsertFileError extends Error { title: string; constructor(title: string, message: string); } /** * Insert a CSV, Arrow, or Parquet file in DuckDB. * * @param debug If true, print the total elapsed time to the console. */ declare const insertFile: (db: AsyncDuckDB, file: File, tableName?: string, debug?: boolean) => Promise; /** * Insert a CSV file in DuckDB from a File handle. */ declare const insertCSV: (db: AsyncDuckDB, file: File, tableName: string) => Promise; /** * Insert an Arrow file in DuckDB from a File handle. */ declare const insertArrow: (db: AsyncDuckDB, file: File, tableName: string) => Promise; /** * Insert an in-memory Arrow table in DuckDB. */ declare const insertArrowTable: (db: AsyncDuckDB, arrow: Table, tableName: string) => Promise; /** * Insert a Parquet file in DuckDB from a File handle. */ declare const insertParquet: (db: AsyncDuckDB, file: File, tableName: string) => Promise; declare const PARQUET_MIME_TYPE = "application/vnd.apache.parquet"; /** * Is a given file a Parquet file? */ declare const isParquetFile: (file: File) => Promise; export { ARROW_MIME_TYPE, CSV_MIME_TYPE, InsertFileError, PARQUET_MIME_TYPE, arrayBufferToArrow, arrowToArrayBuffer, arrowToJSON, cardinalities, drop, exportArrow, exportCsv, exportParquet, getDuckDB, getTempFilename, initializeDuckDb, insertArrow, insertArrowTable, insertCSV, insertFile, insertParquet, isArrow, isArrowFile, isParquetFile, runQuery, useDuckDb, useDuckDbQuery };