import type { ClickHouseExecutor } from '@chkit/clickhouse'; export interface BackfillOptions { /** The executor to submit queries to (target ClickHouse) */ executor: ClickHouseExecutor; /** Plan ID used as a namespace in deterministic query IDs */ planId: string; /** The chunks to process (from buildChunks) */ chunks: Array<{ id: string; from?: string; to?: string; [key: string]: unknown; }>; /** Build the SQL for a given chunk. Called once per chunk at submit time. */ buildQuery: (chunk: { id: string; from?: string; to?: string; }) => string; /** Max concurrent queries running on the server. Default: 3 */ concurrency?: number; /** Polling interval in ms. Default: 5000 */ pollIntervalMs?: number; /** Max consecutive poll errors before marking a chunk as failed. Default: 10 */ maxPollErrors?: number; /** Called whenever progress changes. Use this to persist state. */ onProgress?: (progress: BackfillProgress) => void | Promise; /** Previously saved progress to resume from. */ resumeFrom?: BackfillProgress; /** When true, reset chunks confirmed failed (both locally and on server) back to pending. */ replayFailed?: boolean; } export interface BackfillChunkState { status: 'pending' | 'submitted' | 'running' | 'done' | 'failed'; queryId?: string; submittedAt?: string; finishedAt?: string; readRows?: number; readBytes?: number; writtenRows?: number; writtenBytes?: number; elapsedMs?: number; durationMs?: number; error?: string; } export type BackfillProgress = Record; export interface BackfillResult { total: number; completed: number; failed: number; progress: BackfillProgress; } /** * Reconcile local progress with server-side state. * * Queries system.processes and system.query_log for all chunk query IDs * to discover queries that were submitted but whose status was never * persisted locally (e.g. client crash between submit and state write). */ export declare function syncProgress(executor: ClickHouseExecutor, planId: string, chunks: Array<{ id: string; }>, progress: BackfillProgress): Promise; export declare function executeBackfill(options: BackfillOptions): Promise; //# sourceMappingURL=async-backfill.d.ts.map