import { BinaryReader, BinaryWriter } from "./binary"; import type { LogicalType } from "./logical-types"; /** DuckDB vector encodings supported by the Quack wire format. */ export declare enum VectorType { FLAT = 0, FSST = 1, CONSTANT = 2, DICTIONARY = 3, SEQUENCE = 4 } /** Tagged value used for DuckDB DECIMAL values. */ export interface DecimalValue { /** Discriminator for decimal values. */ kind: "decimal"; /** Unscaled integer value. */ value: bigint; /** DuckDB decimal width. */ width: number; /** DuckDB decimal scale. */ scale: number; } /** Tagged value used for DuckDB DATE values. */ export interface DateValue { /** Discriminator for date values. */ kind: "date"; /** Days since 1970-01-01. */ days: number; } /** Tagged value used for DuckDB TIME and TIME_NS values. */ export interface TimeValue { /** Discriminator for time values. */ kind: "time"; /** Unit used by the stored integer value. */ unit: "micros" | "nanos"; /** Time value in the specified unit since midnight. */ value: bigint; } /** Tagged value used for DuckDB TIME WITH TIME ZONE values. */ export interface TimeTzValue { /** Discriminator for time-with-time-zone values. */ kind: "time_tz"; /** DuckDB packed TIME WITH TIME ZONE bits. */ bits: bigint; } /** Tagged value used for DuckDB TIMESTAMP families. */ export interface TimestampValue { /** Discriminator for timestamp values. */ kind: "timestamp"; /** Unit used by the stored integer value. */ unit: "seconds" | "millis" | "micros" | "nanos"; /** Timestamp value in the specified unit since Unix epoch. */ value: bigint; /** Present for DuckDB TIMESTAMP WITH TIME ZONE values. */ timezone?: "utc"; } /** Tagged value used for DuckDB INTERVAL values. */ export interface IntervalValue { /** Discriminator for interval values. */ kind: "interval"; /** Interval months component. */ months: number; /** Interval days component. */ days: number; /** Interval microseconds component. */ micros: bigint; } /** Scalar value representation produced and consumed by the SDK. */ export type QuackScalarValue = null | boolean | number | bigint | string | Uint8Array | DecimalValue | DateValue | TimeValue | TimeTzValue | TimestampValue | IntervalValue; /** Recursive value representation for scalars and nested DuckDB types. */ export type QuackValue = QuackScalarValue | QuackValue[] | { [key: string]: QuackValue; }; /** Decoded DuckDB vector. */ export interface DecodedVector { /** Logical type of the vector values. */ type: LogicalType; /** Physical vector encoding used on the wire. */ vectorType: VectorType; /** Materialized values in row order. */ values: QuackValue[]; } /** Decoded DuckDB DataChunk. */ export interface QuackDataChunk { /** Number of rows in the chunk. */ rowCount: number; /** Logical types for each column. */ types: LogicalType[]; /** Decoded column vectors. */ columns: DecodedVector[]; /** Optional names used when materializing rows locally. */ columnNames?: string[]; } /** Materialized row object keyed by column name. */ export type QuackRow = Record; /** Decode a nullable-pointer DataChunk wrapper used in Quack messages. */ export declare function decodeDataChunkWrapper(reader: BinaryReader): QuackDataChunk; /** Encode a nullable-pointer DataChunk wrapper used in Quack messages. */ export declare function encodeDataChunkWrapper(writer: BinaryWriter, chunk: QuackDataChunk): void; /** Decode a DuckDB DataChunk body. */ export declare function decodeDataChunk(reader: BinaryReader): QuackDataChunk; /** Encode a DuckDB DataChunk body. */ export declare function encodeDataChunk(writer: BinaryWriter, chunk: QuackDataChunk): void; /** Decode a DuckDB vector for a known logical type and row count. */ export declare function decodeVector(reader: BinaryReader, type: LogicalType, count: number): DecodedVector; /** Encode values as a flat DuckDB vector. */ export declare function encodeVector(writer: BinaryWriter, type: LogicalType, values: readonly QuackValue[], count: number): void; /** Materialize one DataChunk as row objects. */ export declare function rowsFromChunk(chunk: QuackDataChunk, columnNames?: string[] | undefined): QuackRow[]; /** Materialize multiple DataChunks as row objects. */ export declare function chunksToRows(chunks: readonly QuackDataChunk[], columnNames?: readonly string[]): QuackRow[]; /** Render a tagged decimal value with its scale. */ export declare function decimalToString(decimal: DecimalValue): string;