import { DuckDBService } from '../duckdb/service.js'; import { MCPConnectionPool } from './ConnectionPool.js'; import { ResourceRegistry } from './ResourceRegistry.js'; /** * Represents a federated query plan */ export interface QueryPlan { requiresFederation: boolean; localQuery?: string; remoteQueries: Map; joinStrategy?: 'hash' | 'merge' | 'nested'; estimatedCost?: number; } /** * Query execution result */ export interface QueryResult { data: any; metadata?: { rowCount: number; executionTime: number; sourcesQueried: string[]; }; } /** * Query Router for executing federated queries across multiple MCP servers * Handles query planning, routing, and result aggregation */ export declare class QueryRouter { private duckdb; private connectionPool; private resourceRegistry; private tempTableCounter; constructor(duckdb: DuckDBService, connectionPool: MCPConnectionPool, resourceRegistry: ResourceRegistry); /** * Analyze a SQL query and create an execution plan */ analyzeQuery(sql: string): QueryPlan; /** * Execute a query with federation support */ executeQuery(sql: string): Promise; /** * Execute a federated query with streaming results */ executeQueryStream(sql: string): AsyncGenerator; /** * Fetch data from a remote MCP server */ private fetchRemoteData; /** * Create a temporary table from remote data. * * The optional session pins all CREATE statements to the same connection so * the temp tables stay visible to the federated SELECT downstream. When * called without a session (legacy callers), falls back to executeQuery. */ private createTempTable; /** * Clean up temporary tables. Session reuse keeps the DROP on the same * connection that issued the CREATE — required for routed hosts. */ private cleanupTempTables; /** * Extract the query portion for a specific server */ private extractServerQuery; /** * Prepare the local query with placeholders for remote data */ private prepareLocalQuery; /** * Determine the best join strategy based on the query */ private determineJoinStrategy; /** * Explain a federated query plan */ explainQuery(sql: string): string; /** * Get query router statistics */ getStats(): { tempTablesCreated: number; queriesRouted: number; }; } //# sourceMappingURL=QueryRouter.d.ts.map