import type { Chunk, ChunkRange, EstimateFilter, PlannerContext, RowProbeStrategy, SortKey, TableProfile } from './types.js'; export declare function buildChunkExecutionSql(input: { planId: string; chunk: Chunk; target: string; table: Pick; sourceTarget?: string; mvReplayQueries?: string[]; targetColumns?: string[]; idempotencyToken?: string; }): string; export declare function buildWhereClauseFromRanges(partitionId: string, ranges: ChunkRange[], sortKeys: SortKey[]): string; export declare function buildWhereClauseFromChunk(chunk: Pick, table: Pick): string; export declare function buildEstimateSql(filter: EstimateFilter, sortKeys: SortKey[], context: PlannerContext, rowProbeStrategy: RowProbeStrategy): string; export declare function buildCountSql(filter: EstimateFilter, sortKeys: SortKey[], context: Pick): string; /** * Reorder a materialized-view `SELECT ... FROM ...` projection to match the * target table's column order. Projection items are matched to target columns * by their alias (`expr AS alias`); unmatched target columns fall through as * bare column references. Returns the query untouched when no top-level * `SELECT`/`FROM` pair is found (e.g. a non-SELECT statement). */ export declare function rewriteSelectColumns(query: string, targetColumns: string[]): string; /** * Extract the primary source table an mv_replay backfill must chunk against — * the table read by the first top-level `FROM` in a materialized view's * `SELECT`. Chunk conditions (`_partition_id`, sort-key ranges) are injected * into that SELECT and run against this source, so its physical metadata is * what sizing must introspect, not the (legitimately empty) target. * * Handles `db.table`, bare `table`, and backtick-quoted identifiers, ignoring a * trailing alias or clause. Returns `undefined` when the `FROM` target is a * subquery, a table function, or otherwise not a plain table reference — the * caller decides how to treat an unresolvable source. */ export declare function extractSourceTableRef(query: string): { database?: string; table: string; } | undefined; export declare function injectSortKeyFilter(query: string, sortKeyColumn: string, category: SortKey['category'], from: string, to: string): string; export interface KeywordHit { keyword: string; position: number; } /** * Find each occurrence of `keywords` that starts at the top level (paren depth * 0), on a word boundary (preceded by whitespace or start-of-string and * followed by whitespace or end-of-string). Matching is case-insensitive; * hits are returned in ascending position order. */ export declare function findTopLevelKeywords(sql: string, keywords: readonly string[]): KeywordHit[]; /** Split `sql` on every top-level (paren depth 0) occurrence of `delimiter`. */ export declare function splitTopLevel(sql: string, delimiter: string): string[]; //# sourceMappingURL=sql.d.ts.map