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';
import { type UserAttributeValueMap } from './userAttributes';
export type UserAttributeQueryTag = `user_attribute_${string}`;
export type RunQueryTags = Record<UserAttributeQueryTag, string> & {
    project_uuid?: string;
    user_uuid?: string;
    organization_uuid?: string;
    app_uuid?: string;
    chart_uuid?: string;
    dashboard_uuid?: string;
    saved_sql_uuid?: string;
    scheduler_uuid?: string;
    scheduler_name?: string;
    job_id?: string;
    explore_name?: string;
    query_context: QueryExecutionContext;
};
export declare const sanitizeQueryTagKey: (key: string) => string;
export declare const sanitizeQueryTagValue: (value: string) => string;
export declare const getUserAttributeQueryTags: (userAttributes: UserAttributeValueMap) => Record<UserAttributeQueryTag, string>;
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 WarehouseExecuteAsyncQueryArgs = {
    tags: Record<string, string>;
    timezone?: string;
    values?: AnyType[];
    queryParams?: Record<string, AnyType>;
    sql: string;
};
export type WarehouseQueryPhase = 'ssh_tunnel' | 'connect' | 'session' | 'query' | 'fetch';
export type WarehousePhaseTimings = Partial<Record<WarehouseQueryPhase, number>>;
export type WarehouseExecuteAsyncQuery = {
    queryId: string | null;
    queryMetadata: WarehouseQueryMetadata | null;
    totalRows: number;
    durationMs: number;
    phaseTimings: WarehousePhaseTimings;
};
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;
    supportsCteMaterialization: () => boolean;
    getStringQuoteChar: () => string;
    getEscapeStringQuoteChar: () => string;
    getFieldQuoteChar: () => string;
    getFloatingType: () => string;
    getNullSafeEqualSql: (left: string, right: string) => string;
    getNullSafeEqualJoinSql: (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>;
    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