import { LoggerFn } from '@cubejs-backend/shared'; import { InlineTable } from '@cubejs-backend/base-driver'; import { CubeStoreDriver } from '@cubejs-backend/cubestore-driver'; import { PreAggTableToTempTable, Query, QueryBody, QueryCache, QueryWithParams } from './QueryCache'; import { DriverFactory, DriverFactoryByDataSource } from './DriverFactory'; import { QueryQueue } from './QueryQueue'; import { CacheAndQueryDriverType } from './QueryOrchestrator'; export declare const LAMBDA_TABLE_PREFIX = "lambda"; export declare function version(cacheKey: any): string; export declare function getLastUpdatedAtTimestamp(timestamps: (number | undefined)[]): number | undefined; export declare function getStructureVersion(preAggregation: any): string; export type VersionEntry = { table_name: string; content_version: string; structure_version: string; last_updated_at: number; build_range_end?: string; naming_version?: number; }; export type VersionEntriesObj = { versionEntries: VersionEntry[]; byStructure: { [key: string]: VersionEntry; }; byContent: { [key: string]: VersionEntry; }; byTableName: { [key: string]: VersionEntry; }; }; export type InvalidationKeys = unknown[]; export type TableCacheEntry = { table_name?: string; TABLE_NAME?: string; build_range_end?: string; }; export type QueryDateRange = [string, string]; export type PartitionRanges = { buildRange: QueryDateRange; partitionRanges: QueryDateRange[]; }; type IndexDescription = { sql: QueryWithParams; indexName: string; }; /** * Types a pre-aggregation description can have by the time it reaches the * orchestrator. Narrower than the same-named type in `@cubejs-backend/client-core`, * which also lists `rollupJoin` and `rollupLambda`: the schema compiler expands * those into the rollups they reference (`preAggregationDescriptionsFor`), so no * description with either type is ever built or reported here. */ export type PreAggregationType = 'rollup' | 'originalSql'; /** * State of a build for a particular versioned partition table. The table becomes * visible to `getTablesQuery` as soon as it is created, long before the rows are * imported into it, so a finished build is recorded by the absence of a record * rather than by a status of its own. */ export type PreAggregationBuildStatus = { status: 'building' | 'failure'; error?: string; startedAt?: number; }; export type LoadPreAggregationResult = { targetTableName: string; refreshKeyValues: any[]; lastUpdatedAt: number; buildRangeEnd: string; /** * Identity of the pre-aggregation this table belongs to, stamped by * `loadAllPreAggregationsIfNeeded` from the query's pre-aggregation * description rather than by the loaders. Reported to clients as part of * `usedPreAggregations` so they can match a result to a build. */ preAggregationId?: string; type?: PreAggregationType; lambdaTable?: InlineTable; queryKey?: any[]; rollupLambdaId?: string; partitionRange?: QueryDateRange; isMultiTableUnion?: boolean; usageTargetTableNames?: Record; dataSource?: string; timezone?: string; }; export type PreAggregationTableToTempTable = [string, LoadPreAggregationResult]; export type LambdaOptions = { maxSourceRows: number; }; export type LambdaQuery = { sqlAndParams: QueryWithParams; cacheKeyQueries: QueryWithParams[]; /** Bounds the source query on both ends; undefined when it's unbounded. */ sourceDateRange?: QueryDateRange; }; export type PreAggregationDescription = { preAggregationsSchema: string; type: PreAggregationType; preAggregationId: string; priority: number; dataSource: string; external: boolean; previewSql: QueryWithParams; timezone: string; indexesSql: IndexDescription[]; invalidateKeyQueries: QueryWithParams[]; partitionInvalidateKeyQueries: QueryWithParams[]; structureVersionLoadSql: QueryWithParams; sql: QueryWithParams; loadSql: QueryWithParams; tableName: string; matchedTimeDimensionDateRange: QueryDateRange; granularity: string; partitionGranularity: string; preAggregationStartEndQueries: [QueryWithParams, QueryWithParams]; timestampFormat: string; timestampPrecision: number; expandedPartition: boolean; unionWithSourceData: LambdaOptions; buildRangeStart?: string; buildRangeEnd?: string; updateWindowSeconds?: number; sealAt?: string; rollupLambdaId?: string; lastRollupLambda?: boolean; usageMapping?: Record; }; export declare const tablesToVersionEntries: (schema: any, tables: TableCacheEntry[]) => VersionEntry[]; type PreAggregationsOptions = { maxPartitions: number; maxSourceRowLimit: number; preAggregationsSchemaCacheExpire?: number; loadCacheQueueOptions?: any; queueOptions?: (dataSource: string) => Promise<{ concurrency: number; continueWaitTimeout?: number; executionTimeout?: number; orphanedTimeout?: number; heartBeatInterval?: number; }>; cubeStoreDriverFactory?: () => Promise; continueWaitTimeout?: number; cacheAndQueueDriver?: CacheAndQueryDriverType; skipExternalCacheAndQueue?: boolean; }; export declare class PreAggregations { private readonly redisPrefix; private readonly driverFactory; private readonly logger; private readonly queryCache; readonly options: PreAggregationsOptions; readonly externalDriverFactory: DriverFactory; readonly structureVersionPersistTime: any; private readonly touchTablePersistTime; private readonly preAggBackoffMaxTime; readonly dropPreAggregationsWithoutTouch: boolean; private readonly usedTablePersistTime; private readonly externalRefresh; private readonly loadCacheQueue; private readonly queue; private readonly usedCache; private readonly touchCache; constructor(redisPrefix: string, driverFactory: DriverFactoryByDataSource, logger: LoggerFn, queryCache: QueryCache, options: any); protected tablesUsedRedisKey(tableName: string): string; protected tablesTouchRedisKey(tableName: string): string; protected preAggBackoffRedisKey(tableName: string): string; protected refreshEndReachedKey(): string; protected preAggBuildStatusRedisKey(tableName: string): string; setPreAggregationBuildStatus(tableName: string, status: PreAggregationBuildStatus): Promise; getPreAggregationBuildStatus(tableName: string): Promise; removePreAggregationBuildStatus(tableName: string): Promise; /** * The queue times a build out on its own and records the failure, so a build * that is still marked as running long past that timeout is one whose process * is gone and will never report an outcome. */ private isBuildAbandoned; addTableUsed(tableName: string): Promise; tablesUsed(): Promise; removeTableUsed(tableName: string): Promise; updateLastTouch(tableName: string): Promise; tablesTouched(): Promise; removeTableTouched(tableName: string): Promise; updatePreAggBackoff(tableName: string, backoffData: { backoffMultiplier: number; nextTimestamp: Date; }): Promise; removePreAggBackoff(tableName: string): Promise; getPreAggBackoffMaxTime(): number; getPreAggBackoff(tableName: string): Promise<{ backoffMultiplier: number; nextTimestamp: Date; } | null>; updateRefreshEndReached(): Promise<{ key: string; bytes: number; }>; getRefreshEndReached(): Promise; /** * Determines whether the partition table already exists or not. */ isPartitionExist(request: string, external: boolean, dataSource: string, schema: string, table: string, key: any, token: string): Promise<[boolean, string]>; loadAllPreAggregationsIfNeeded(queryBody: QueryBody): Promise<{ preAggregationsTablesToTempTables: PreAggTableToTempTable[]; values: null | string[]; }>; /** * Determines whether range queries for the preAggregations from the * queryBody were cached or not. */ checkPartitionsBuildRangeCache(queryBody: QueryBody): Promise<{ preAggregation: PreAggregationDescription; isCached: boolean; }[]>; expandPartitionsInPreAggregations(queryBody: Query): Promise; getQueue(dataSource?: string): Promise; /** * Returns registered queries queues hash table. */ getQueues(): { [dataSource: string]: QueryQueue; }; getLoadCacheQueue(dataSource?: string): QueryQueue; static preAggregationQueryCacheKey(preAggregation: any): any; static targetTableName(versionEntry: any): string; static noPreAggregationPartitionsBuiltMessage(preAggregations: PreAggregationDescription[]): string; static structureVersion(preAggregation: any): string; getVersionEntries(preAggregations: PreAggregationDescription[], requestId: any): Promise; getQueueState(dataSource: string): Promise; cancelQueriesFromQueue(queryKeys: string[], dataSource: string): Promise; } export {}; //# sourceMappingURL=PreAggregations.d.ts.map