import { AsyncPreparedStatement } from './@duckdb/duckdb-wasm'; import { TypedTypeMap } from './@motherduck/duckdb-arrow'; import { AsyncDuckDBDataBatchIterator, DuckDBData, DuckDBDataReader } from './@duckdb/data-reader'; import { AsyncRecordBatchStreamReader, DataType } from 'apache-arrow'; export { AsyncPreparedStatement }; export { TypedTypeMap }; export { AsyncDuckDBDataBatchIterator, DuckDBData, DuckDBDataReader }; export { AsyncRecordBatchStreamReader, DataType }; export interface MaterializedQueryResult { type: 'materialized'; startTimeMs: number; endTimeMs: number; /** * Full result set. * * Includes column metadata, such as types. Supports duplicate column names without renaming. * * See the `DuckDBData` interface for details. */ data: DuckDBData; } export interface StreamingQueryResult { type: 'streaming'; /** * Stream of underlying Arrow RecordBatches. Useful if you need results in Arrow format, but note that the conversion * of some value types, especially dates, times, and decimals, to JavaScript types is lossy in some cases, and also * the conversion of several types to string does not match DuckDB's format. */ arrowStream: AsyncRecordBatchStreamReader; /** * Async iterator of DuckDB data batches. DuckDB data batches are similar to Arrow RecordBatches, but expose DuckDB * types and values, preserving full range and precision, and matching DuckDB's format when converted to strings. */ dataStream: AsyncDuckDBDataBatchIterator; /** * Convenience wrapper around dataStream. Enables reading DuckDB data up to some row count, and exposes the DuckDBData * interface for accessing all rows read so far (not just one batch). */ dataReader: DuckDBDataReader; } export type QueryResult = MaterializedQueryResult | StreamingQueryResult; export interface QuerySuccess { status: 'success'; result: T; } export interface QueryError { status: 'error'; err: Error; } export type SafeQueryResult = QuerySuccess | QueryError; export type PrepareSuccess = { status: 'success'; preparedStatement: AsyncPreparedStatement; }; export type PrepareError = { status: 'error'; err: Error; }; export type SafePrepareResult = PrepareSuccess | PrepareError;