import { BigQuery, Dataset, DatasetsResponse, GetDatasetsOptions, QueryRowsResponse } from '@google-cloud/bigquery'; import bigquery from '@google-cloud/bigquery/build/src/types'; import { AnyType, BigqueryDataset, BigqueryProject, BigqueryProjectRecommendation, CreateBigqueryCredentials, Metric, PartitionColumn, SupportedDbtAdapter, TimeIntervalUnit, UnnestSql, UnnestSqlArgs, WarehouseQueryError, WarehouseResults, WarehouseTypes, type ResultNumericKind, type TimestampDomain } from '@lightdash/common'; import { WarehouseCatalog, WarehouseExecuteAsyncQuery, WarehouseExecuteAsyncQueryArgs } from '../types'; import WarehouseBaseClient from './WarehouseBaseClient'; import WarehouseBaseSqlBuilder from './WarehouseBaseSqlBuilder'; export declare enum BigqueryFieldType { STRING = "STRING", INTEGER = "INTEGER", BYTES = "BYTES", INT64 = "INT64", FLOAT = "FLOAT", FLOAT64 = "FLOAT64", BOOLEAN = "BOOLEAN", BOOL = "BOOL", TIMESTAMP = "TIMESTAMP", DATE = "DATE", TIME = "TIME", DATETIME = "DATETIME", GEOGRAPHY = "GEOGRAPHY", NUMERIC = "NUMERIC", BIGNUMERIC = "BIGNUMERIC", RECORD = "RECORD", STRUCT = "STRUCT", ARRAY = "ARRAY" } export declare const getBigqueryTimestampDomain: (type: string | undefined) => TimestampDomain | undefined; export declare const getBigqueryNumericKind: (field: { type?: string; precision?: string; scale?: string; }) => ResultNumericKind | null; type TableSchema = { fields: SchemaFields[]; }; type SchemaFields = Required> & Pick; type BigqueryError = { errors: bigquery.IErrorProto[]; }; export declare class BigquerySqlBuilder extends WarehouseBaseSqlBuilder { readonly type = WarehouseTypes.BIGQUERY; getAdapterType(): SupportedDbtAdapter; getMetricSql(sql: string, metric: Metric): string; getFieldQuoteChar(): string; getFloatingType(): string; escapeString(value: string): string; castToTimestamp(date: Date): string; castToDate(date: Date): string; castToNaiveTimestamp(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; getUnnestSql(args: UnnestSqlArgs): UnnestSql; } export declare class BigqueryWarehouseClient extends WarehouseBaseClient { private static readonly MAX_LABELS; client: BigQuery; constructor(credentials: CreateBigqueryCredentials); static isBigqueryError(error: unknown): error is BigqueryError; private usesUserRefreshToken; private translateGoogleOauthTokenError; private throwIfGoogleOauthTokenError; /** * Sanitize label key and values. * Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed. * But also, keys can't be longer than 60 characters, or empty. * * Defensive String() coercion: the TS type promises `Record` * but callers (warehouse `queryTags`) can drift — a non-string value here * would crash the whole job at `.toLowerCase()`, taking down every * downstream sync/query. The warn log surfaces the rogue key so the * source can be fixed. */ static sanitizeLabelsWithValues(labels?: Record): Record | undefined; static getFieldsFromResponse(response: QueryRowsResponse[2] | undefined): Record; private createJob; private getJob; private getJobResultsMetadata; private streamResults; streamQuery(query: string, streamCallback: (data: WarehouseResults) => void | Promise, options: { values?: AnyType[]; tags?: Record; timezone?: string; }): Promise; static getTableMetadata(dataset: Dataset, table: string): Promise<[string, string, string, TableSchema]>; getCatalog(requests: { database: string; schema: string; table: string; }[]): Promise; getAllTables(): Promise<{ database: string; schema: string; table: string; tableType: import("@lightdash/common").WarehouseTableType; partitionColumn: PartitionColumn | undefined; }[]>; private getAllTablesFromClient; getFields(tableName: string, schema: string, database?: string): Promise; parseError(error: bigquery.IErrorProto, query?: string): WarehouseQueryError; executeAsyncQuery({ sql, tags, timezone }: WarehouseExecuteAsyncQueryArgs, resultsStreamCallback?: (rows: WarehouseResults['rows'], fields: WarehouseResults['fields']) => void): Promise; private awaitJobCompletion; static getDatabases(projectId: string, refresh_token: string, bigqueryClient?: { getDatasets: () => Promise; query: (query: string) => Promise; }): Promise; static getProjectRecommendation(projects: BigqueryProject[], refreshToken: string, bigqueryClientFactory?: (projectId: string) => { getDatasets: (options: GetDatasetsOptions) => Promise; query: (options: { query: string; location: string; }) => Promise; }): Promise; static getProjects(accessToken: string): Promise; } export {}; //# sourceMappingURL=BigqueryWarehouseClient.d.ts.map