import { type WeekDay } from '../utils/timeFrames';
import { type QueryExecutionContext } from './analytics';
import { type AnyType } from './any';
import { type SupportedDbtAdapter } from './dbt';
import { type DimensionType, type Metric } from './field';
import { type CreateWarehouseCredentials } from './projects';
import type { WarehouseQueryMetadata } from './queryHistory';
export type RunQueryTags = {
    project_uuid?: string;
    user_uuid?: string;
    organization_uuid?: string;
    chart_uuid?: string;
    dashboard_uuid?: string;
    explore_name?: string;
    query_context: QueryExecutionContext;
};
export type WarehouseTableSchema = {
    [column: string]: DimensionType;
};
export type WarehouseCatalog = {
    [database: string]: {
        [schema: string]: {
            [table: string]: WarehouseTableSchema;
        };
    };
};
export type WarehouseTablesCatalog = {
    [database: string]: {
        [schema: string]: {
            [table: string]: {
                partitionColumn?: PartitionColumn;
            };
        };
    };
};
export type WarehouseTables = {
    database: string;
    schema: string;
    table: string;
    partitionColumn?: PartitionColumn;
}[];
export type WarehouseResults = {
    fields: Record<string, {
        type: DimensionType;
    }>;
    rows: Record<string, AnyType>[];
};
export type WarehousePaginationArgs = {
    page: number;
    pageSize: number;
};
export type WarehouseExecuteAsyncQueryArgs = {
    tags: Record<string, string>;
    timezone?: string;
    values?: AnyType[];
    queryParams?: Record<string, AnyType>;
    sql: string;
};
export type WarehouseExecuteAsyncQuery = {
    queryId: string | null;
    queryMetadata: WarehouseQueryMetadata | null;
    totalRows: number;
    durationMs: number;
};
export type WarehouseGetAsyncQueryResultsArgs = WarehousePaginationArgs & {
    sql: string;
    queryId: string | null;
    queryMetadata: WarehouseQueryMetadata | null;
};
export type WarehouseGetAsyncQueryResults<TFormattedRow extends Record<string, unknown>> = {
    queryId: string | null;
    fields: Record<string, {
        type: DimensionType;
    }>;
    pageCount: number;
    totalRows: number;
    rows: TFormattedRow[];
};
export declare enum TimeIntervalUnit {
    SECOND = "SECOND",
    MINUTE = "MINUTE",
    HOUR = "HOUR",
    DAY = "DAY",
    WEEK = "WEEK",
    MONTH = "MONTH",
    YEAR = "YEAR"
}
export interface WarehouseSqlBuilder {
    getStartOfWeek: () => WeekDay | null | undefined;
    getAdapterType: () => SupportedDbtAdapter;
    getStringQuoteChar: () => string;
    getEscapeStringQuoteChar: () => string;
    getFieldQuoteChar: () => string;
    getFloatingType: () => string;
    getNullSafeEqualSql: (left: string, right: string) => string;
    getMetricSql: (sql: string, metric: Metric) => string;
    concatString: (...args: string[]) => string;
    escapeString: (value: string) => string;
    castToTimestamp: (date: Date) => string;
    getIntervalSql: (value: number, unit: TimeIntervalUnit) => string;
    getTimestampDiffSeconds: (startTimestampSql: string, endTimestampSql: string) => string;
    getMedianSql: (valueSql: string) => string;
    buildArray: (elements: string[]) => string;
    buildArrayAgg: (expression: string, orderBy?: string) => string;
}
export interface WarehouseClient extends WarehouseSqlBuilder {
    credentials: CreateWarehouseCredentials;
    getCatalog: (config: {
        database: string;
        schema: string;
        table: string;
    }[]) => Promise<WarehouseCatalog>;
    getAsyncQueryResults<TFormattedRow extends Record<string, unknown>>(args: WarehouseGetAsyncQueryResultsArgs, rowFormatter?: (row: Record<string, unknown>) => TFormattedRow): Promise<WarehouseGetAsyncQueryResults<TFormattedRow>>;
    streamQuery(query: string, streamCallback: (data: WarehouseResults) => void | Promise<void>, options: {
        values?: AnyType[];
        tags: Record<string, string>;
        timezone?: string;
    }): Promise<void>;
    executeAsyncQuery(args: WarehouseExecuteAsyncQueryArgs, resultsStreamCallback?: (rows: WarehouseResults['rows'], fields: WarehouseResults['fields']) => void | Promise<void>): Promise<WarehouseExecuteAsyncQuery>;
    /**
     * Runs a query and returns all the results
     * @param sql
     * @param tags
     * @param timezone
     * @param values
     * @deprecated Use streamQuery() instead to avoid loading all results into memory
     */
    runQuery(sql: string, tags: Record<string, string>, timezone?: string, values?: AnyType[]): Promise<WarehouseResults>;
    test(): Promise<void>;
    getAllTables(schema?: string, tags?: Record<string, string>): Promise<WarehouseTables>;
    getFields(tableName: string, schema?: string, database?: string, tags?: Record<string, string>): Promise<WarehouseCatalog>;
    parseWarehouseCatalog(rows: Record<string, AnyType>[], mapFieldType: (type: string) => DimensionType): WarehouseCatalog;
    parseError(error: Error): Error;
    escapeString(value: string): string;
}
export type ApiWarehouseCatalog = {
    status: 'ok';
    results: WarehouseCatalog;
};
export type ApiWarehouseTablesCatalog = {
    status: 'ok';
    results: WarehouseTablesCatalog;
};
export type ApiWarehouseTableFields = {
    status: 'ok';
    results: WarehouseTableSchema;
};
export declare enum PartitionType {
    DATE = "DATE",
    RANGE = "RANGE"
}
export type PartitionColumn = {
    partitionType: PartitionType;
    field: string;
};
//# sourceMappingURL=warehouse.d.ts.map