drizzle-cube 0.2.14 → 0.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/compiler-BU728aIU.cjs +22 -0
- package/dist/adapters/{compiler-DrkCCzf0.js → compiler-B_yO7zBu.js} +3648 -2916
- package/dist/adapters/express/index.cjs +1 -1
- package/dist/adapters/express/index.js +1 -1
- package/dist/adapters/fastify/index.cjs +1 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.js +1 -1
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/client/charts.js +27 -36
- package/dist/client/charts.js.map +1 -1
- package/dist/client/chunks/charts-B8YMw1mi.js +7227 -0
- package/dist/client/chunks/charts-B8YMw1mi.js.map +1 -0
- package/dist/client/chunks/charts-amt7VOyw.js +277 -0
- package/dist/client/chunks/{charts-PgJ3XcwQ.js.map → charts-amt7VOyw.js.map} +1 -1
- package/dist/client/chunks/{components-Cd068oGo.js → components-K3xrnHN-.js} +10247 -10583
- package/dist/client/chunks/components-K3xrnHN-.js.map +1 -0
- package/dist/client/chunks/core-Dkym7d1O.js +6 -0
- package/dist/client/chunks/core-Dkym7d1O.js.map +1 -0
- package/dist/client/chunks/{index-Baq5aJv1.js → index-B7NSVb33.js} +2 -2
- package/dist/client/chunks/{index-Baq5aJv1.js.map → index-B7NSVb33.js.map} +1 -1
- package/dist/client/chunks/javascript-DII1YQGr.js +659 -0
- package/dist/client/chunks/javascript-DII1YQGr.js.map +1 -0
- package/dist/client/components/AnalysisBuilder/AnalysisFilterItem.d.ts +1 -3
- package/dist/client/components/AnalysisBuilder/FilterConfigModal.d.ts +16 -0
- package/dist/client/components/DashboardFilters/FilterEditModal.d.ts +1 -1
- package/dist/client/components/DashboardFilters/ReadOnlyFilterList.d.ts +1 -1
- package/dist/client/components/QueryBuilderShim.d.ts +3 -0
- package/dist/client/components/{QueryBuilder → shared}/CubeMetaExplorer.d.ts +1 -1
- package/dist/client/components/{QueryBuilder → shared}/DateRangeFilter.d.ts +1 -1
- package/dist/client/components/{QueryBuilder → shared}/FilterBuilder.d.ts +1 -1
- package/dist/client/components/{QueryBuilder → shared}/FilterGroup.d.ts +1 -1
- package/dist/client/components/{QueryBuilder → shared}/FilterItem.d.ts +1 -1
- package/dist/client/components/{QueryBuilder → shared}/FilterValueSelector.d.ts +1 -1
- package/dist/client/components/{QueryBuilder → shared}/utils.d.ts +1 -1
- package/dist/client/components.d.ts +1 -1
- package/dist/client/components.js +2 -2
- package/dist/client/hooks.js +3 -3
- package/dist/client/icons.js +5 -5
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +49 -52
- package/dist/client/index.js.map +1 -1
- package/dist/client/providers.js +5 -6
- package/dist/client/providers.js.map +1 -1
- package/dist/client/shared/components/CodeBlock.d.ts +10 -0
- package/dist/client/shared/index.d.ts +1 -0
- package/dist/client/styles.css +1 -1
- package/dist/client/utils/index.d.ts +1 -0
- package/dist/client/{components/QueryBuilder → utils}/shareUtils.d.ts +1 -1
- package/dist/client/utils/syntaxHighlighting.d.ts +31 -0
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.cjs +18 -18
- package/dist/server/index.d.ts +272 -3
- package/dist/server/index.js +2760 -2037
- package/package.json +5 -1
- package/dist/adapters/compiler-CMwSRhTS.cjs +0 -22
- package/dist/client/chunks/chart-activitygridchart-BSA93MaS.js +0 -2630
- package/dist/client/chunks/chart-activitygridchart-BSA93MaS.js.map +0 -1
- package/dist/client/chunks/chart-activitygridchart-config-AVBoHdRn.js +0 -244
- package/dist/client/chunks/chart-activitygridchart-config-AVBoHdRn.js.map +0 -1
- package/dist/client/chunks/chart-areachart-Cz-Bv8ZB.js +0 -238
- package/dist/client/chunks/chart-areachart-Cz-Bv8ZB.js.map +0 -1
- package/dist/client/chunks/chart-areachart-config-D9pPUKHZ.js +0 -78
- package/dist/client/chunks/chart-areachart-config-D9pPUKHZ.js.map +0 -1
- package/dist/client/chunks/chart-axisformatcontrols-BNfQgqND.js +0 -196
- package/dist/client/chunks/chart-axisformatcontrols-BNfQgqND.js.map +0 -1
- package/dist/client/chunks/chart-barchart-CI8LhTwO.js +0 -219
- package/dist/client/chunks/chart-barchart-CI8LhTwO.js.map +0 -1
- package/dist/client/chunks/chart-barchart-config-iniz62ni.js +0 -71
- package/dist/client/chunks/chart-barchart-config-iniz62ni.js.map +0 -1
- package/dist/client/chunks/chart-bubblechart-DaFSD3dc.js +0 -247
- package/dist/client/chunks/chart-bubblechart-DaFSD3dc.js.map +0 -1
- package/dist/client/chunks/chart-bubblechart-config-yLq2oyR3.js +0 -72
- package/dist/client/chunks/chart-bubblechart-config-yLq2oyR3.js.map +0 -1
- package/dist/client/chunks/chart-chartcontainer-CdwzIKP1.js +0 -103
- package/dist/client/chunks/chart-chartcontainer-CdwzIKP1.js.map +0 -1
- package/dist/client/chunks/chart-charttooltip-hLOOlEDZ.js +0 -26
- package/dist/client/chunks/chart-charttooltip-hLOOlEDZ.js.map +0 -1
- package/dist/client/chunks/chart-datatable-Dj_3LWKH.js +0 -350
- package/dist/client/chunks/chart-datatable-Dj_3LWKH.js.map +0 -1
- package/dist/client/chunks/chart-datatable-config-DmEA3A-7.js +0 -29
- package/dist/client/chunks/chart-datatable-config-DmEA3A-7.js.map +0 -1
- package/dist/client/chunks/chart-kpidelta-D45MO-i1.js +0 -435
- package/dist/client/chunks/chart-kpidelta-D45MO-i1.js.map +0 -1
- package/dist/client/chunks/chart-kpidelta-config-DtSDG4Kl.js +0 -98
- package/dist/client/chunks/chart-kpidelta-config-DtSDG4Kl.js.map +0 -1
- package/dist/client/chunks/chart-kpinumber-J3jJ1lz7.js +0 -400
- package/dist/client/chunks/chart-kpinumber-J3jJ1lz7.js.map +0 -1
- package/dist/client/chunks/chart-kpinumber-config-Da2LFeKM.js +0 -76
- package/dist/client/chunks/chart-kpinumber-config-Da2LFeKM.js.map +0 -1
- package/dist/client/chunks/chart-kpitext-Bo86g7Jn.js +0 -165
- package/dist/client/chunks/chart-kpitext-Bo86g7Jn.js.map +0 -1
- package/dist/client/chunks/chart-kpitext-config-DjvigyfE.js +0 -48
- package/dist/client/chunks/chart-kpitext-config-DjvigyfE.js.map +0 -1
- package/dist/client/chunks/chart-linechart-B7HFYqC7.js +0 -202
- package/dist/client/chunks/chart-linechart-B7HFYqC7.js.map +0 -1
- package/dist/client/chunks/chart-linechart-config-DLVS2Zxc.js +0 -66
- package/dist/client/chunks/chart-linechart-config-DLVS2Zxc.js.map +0 -1
- package/dist/client/chunks/chart-markdownchart-C-lDJMtY.js +0 -257
- package/dist/client/chunks/chart-markdownchart-C-lDJMtY.js.map +0 -1
- package/dist/client/chunks/chart-markdownchart-config-CgOA3YSw.js +0 -61
- package/dist/client/chunks/chart-markdownchart-config-CgOA3YSw.js.map +0 -1
- package/dist/client/chunks/chart-piechart-CJCJZXmm.js +0 -127
- package/dist/client/chunks/chart-piechart-CJCJZXmm.js.map +0 -1
- package/dist/client/chunks/chart-piechart-config-DgwOeKHr.js +0 -39
- package/dist/client/chunks/chart-piechart-config-DgwOeKHr.js.map +0 -1
- package/dist/client/chunks/chart-radarchart-CJ-8qPmX.js +0 -131
- package/dist/client/chunks/chart-radarchart-CJ-8qPmX.js.map +0 -1
- package/dist/client/chunks/chart-radarchart-config-BAV8D5PR.js +0 -45
- package/dist/client/chunks/chart-radarchart-config-BAV8D5PR.js.map +0 -1
- package/dist/client/chunks/chart-radialbarchart-C8PlVtXx.js +0 -120
- package/dist/client/chunks/chart-radialbarchart-C8PlVtXx.js.map +0 -1
- package/dist/client/chunks/chart-radialbarchart-config-CKozBBEC.js +0 -38
- package/dist/client/chunks/chart-radialbarchart-config-CKozBBEC.js.map +0 -1
- package/dist/client/chunks/chart-scatterchart-CXujAIug.js +0 -203
- package/dist/client/chunks/chart-scatterchart-CXujAIug.js.map +0 -1
- package/dist/client/chunks/chart-scatterchart-config-UdHmbZ3s.js +0 -54
- package/dist/client/chunks/chart-scatterchart-config-UdHmbZ3s.js.map +0 -1
- package/dist/client/chunks/chart-treemapchart-D9lYs_Y9.js +0 -265
- package/dist/client/chunks/chart-treemapchart-D9lYs_Y9.js.map +0 -1
- package/dist/client/chunks/chart-treemapchart-config-D17VOwTM.js +0 -47
- package/dist/client/chunks/chart-treemapchart-config-D17VOwTM.js.map +0 -1
- package/dist/client/chunks/charts-PgJ3XcwQ.js +0 -286
- package/dist/client/chunks/components-Cd068oGo.js.map +0 -1
- package/dist/client/components/QueryBuilder/QueryAnalysisPanel.d.ts +0 -7
- package/dist/client/components/QueryBuilder/QueryPanel.d.ts +0 -4
- package/dist/client/components/QueryBuilder/ResultsPanel.d.ts +0 -4
- package/dist/client/components/QueryBuilder/SetupPanel.d.ts +0 -11
- package/dist/client/components/QueryBuilder/ShareWarningModal.d.ts +0 -9
- package/dist/client/components/QueryBuilder/index.d.ts +0 -3
- /package/dist/client/components/{QueryBuilder → shared}/DateRangeSelector.d.ts +0 -0
package/dist/server/index.d.ts
CHANGED
|
@@ -282,6 +282,62 @@ declare interface DatabaseAdapter {
|
|
|
282
282
|
* @returns Preprocessed template string
|
|
283
283
|
*/
|
|
284
284
|
preprocessCalculatedTemplate(calculatedSql: string): string;
|
|
285
|
+
/**
|
|
286
|
+
* Get database capabilities for feature detection
|
|
287
|
+
* Used for graceful degradation when functions aren't supported
|
|
288
|
+
*/
|
|
289
|
+
getCapabilities(): DatabaseCapabilities;
|
|
290
|
+
/**
|
|
291
|
+
* Build STDDEV aggregation expression
|
|
292
|
+
* @param fieldExpr - The field expression to calculate stddev for
|
|
293
|
+
* @param useSample - Use sample stddev (STDDEV_SAMP) vs population (STDDEV_POP). Default: false
|
|
294
|
+
* @returns SQL expression or null if unsupported
|
|
295
|
+
*/
|
|
296
|
+
buildStddev(fieldExpr: AnyColumn | SQL, useSample?: boolean): SQL | null;
|
|
297
|
+
/**
|
|
298
|
+
* Build VARIANCE aggregation expression
|
|
299
|
+
* @param fieldExpr - The field expression to calculate variance for
|
|
300
|
+
* @param useSample - Use sample variance (VAR_SAMP) vs population (VAR_POP). Default: false
|
|
301
|
+
* @returns SQL expression or null if unsupported
|
|
302
|
+
*/
|
|
303
|
+
buildVariance(fieldExpr: AnyColumn | SQL, useSample?: boolean): SQL | null;
|
|
304
|
+
/**
|
|
305
|
+
* Build PERCENTILE aggregation expression
|
|
306
|
+
* @param fieldExpr - The field expression to calculate percentile for
|
|
307
|
+
* @param percentile - Percentile value (0-100)
|
|
308
|
+
* @returns SQL expression or null if unsupported
|
|
309
|
+
*/
|
|
310
|
+
buildPercentile(fieldExpr: AnyColumn | SQL, percentile: number): SQL | null;
|
|
311
|
+
/**
|
|
312
|
+
* Build a window function expression
|
|
313
|
+
* @param type - Window function type (lag, lead, rank, etc.)
|
|
314
|
+
* @param fieldExpr - The field expression (null for rank functions that don't need a field)
|
|
315
|
+
* @param partitionBy - PARTITION BY columns
|
|
316
|
+
* @param orderBy - ORDER BY columns with direction
|
|
317
|
+
* @param config - Additional configuration (offset, default, frame, etc.)
|
|
318
|
+
* @returns SQL expression or null if unsupported
|
|
319
|
+
*/
|
|
320
|
+
buildWindowFunction(type: WindowFunctionType, fieldExpr: AnyColumn | SQL | null, partitionBy?: (AnyColumn | SQL)[], orderBy?: Array<{
|
|
321
|
+
field: AnyColumn | SQL;
|
|
322
|
+
direction: 'asc' | 'desc';
|
|
323
|
+
}>, config?: WindowFunctionConfig): SQL | null;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Database capabilities for feature detection
|
|
328
|
+
* Used for graceful degradation when functions aren't supported
|
|
329
|
+
*/
|
|
330
|
+
declare interface DatabaseCapabilities {
|
|
331
|
+
/** Whether the database supports STDDEV_POP/STDDEV_SAMP */
|
|
332
|
+
supportsStddev: boolean;
|
|
333
|
+
/** Whether the database supports VAR_POP/VAR_SAMP */
|
|
334
|
+
supportsVariance: boolean;
|
|
335
|
+
/** Whether the database supports PERCENTILE_CONT or similar */
|
|
336
|
+
supportsPercentile: boolean;
|
|
337
|
+
/** Whether the database supports window functions (LAG, LEAD, RANK, etc.) */
|
|
338
|
+
supportsWindowFunctions: boolean;
|
|
339
|
+
/** Whether the database supports frame clauses (ROWS BETWEEN, RANGE BETWEEN) */
|
|
340
|
+
supportsFrameClause: boolean;
|
|
285
341
|
}
|
|
286
342
|
|
|
287
343
|
/**
|
|
@@ -388,6 +444,65 @@ export declare type ExtractSchemaFromCubeRef = any;
|
|
|
388
444
|
*/
|
|
389
445
|
export declare type Filter = FilterCondition | LogicalFilter;
|
|
390
446
|
|
|
447
|
+
/**
|
|
448
|
+
* Manages filter SQL caching for a single query execution
|
|
449
|
+
*
|
|
450
|
+
* Design principles:
|
|
451
|
+
* - Immutable SQL: Once cached, SQL objects are never modified
|
|
452
|
+
* - Cache lifetime: Created at query start, discarded after query execution
|
|
453
|
+
* - Key by content: Filters with same member/operator/values share SQL
|
|
454
|
+
* - Thread-safe: No shared mutable state between queries
|
|
455
|
+
*/
|
|
456
|
+
declare class FilterCacheManager {
|
|
457
|
+
private cache;
|
|
458
|
+
private stats;
|
|
459
|
+
/**
|
|
460
|
+
* Get cached SQL or build and cache it
|
|
461
|
+
*
|
|
462
|
+
* @param key - The cache key (use getFilterKey or getTimeDimensionFilterKey)
|
|
463
|
+
* @param builder - Function to build the SQL if not cached
|
|
464
|
+
* @returns The cached or freshly built SQL, or null if builder returns null
|
|
465
|
+
*/
|
|
466
|
+
getOrBuild(key: string, builder: () => SQL | null): SQL | null;
|
|
467
|
+
/**
|
|
468
|
+
* Check if a key exists in the cache without affecting stats
|
|
469
|
+
*/
|
|
470
|
+
has(key: string): boolean;
|
|
471
|
+
/**
|
|
472
|
+
* Get cached SQL without building (returns undefined if not cached)
|
|
473
|
+
*/
|
|
474
|
+
get(key: string): SQL | undefined;
|
|
475
|
+
/**
|
|
476
|
+
* Pre-populate cache with multiple filters
|
|
477
|
+
* Useful for batch initialization at query start
|
|
478
|
+
*/
|
|
479
|
+
preload(entries: Array<{
|
|
480
|
+
key: string;
|
|
481
|
+
sql: SQL;
|
|
482
|
+
}>): void;
|
|
483
|
+
/**
|
|
484
|
+
* Store a single entry in the cache
|
|
485
|
+
*/
|
|
486
|
+
set(key: string, sql: SQL): void;
|
|
487
|
+
/**
|
|
488
|
+
* Get cache statistics for debugging
|
|
489
|
+
*/
|
|
490
|
+
getStats(): FilterCacheStats;
|
|
491
|
+
/**
|
|
492
|
+
* Clear the cache (normally not needed as cache is per-query)
|
|
493
|
+
*/
|
|
494
|
+
clear(): void;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Cache statistics for debugging and monitoring
|
|
499
|
+
*/
|
|
500
|
+
declare interface FilterCacheStats {
|
|
501
|
+
hits: number;
|
|
502
|
+
misses: number;
|
|
503
|
+
cacheSize: number;
|
|
504
|
+
}
|
|
505
|
+
|
|
391
506
|
export declare interface FilterCondition {
|
|
392
507
|
member: string;
|
|
393
508
|
operator: FilterOperator;
|
|
@@ -509,6 +624,41 @@ declare interface Measure {
|
|
|
509
624
|
dependencies?: string[];
|
|
510
625
|
/** Additional metadata */
|
|
511
626
|
meta?: Record<string, any>;
|
|
627
|
+
/**
|
|
628
|
+
* Statistical function configuration
|
|
629
|
+
* Used for percentile, stddev, variance measure types
|
|
630
|
+
*/
|
|
631
|
+
statisticalConfig?: {
|
|
632
|
+
/** Percentile value (0-100) for percentile measures. Default: 50 for median */
|
|
633
|
+
percentile?: number;
|
|
634
|
+
/** Use sample vs population calculation for stddev/variance. Default: false (population) */
|
|
635
|
+
useSample?: boolean;
|
|
636
|
+
};
|
|
637
|
+
/**
|
|
638
|
+
* Window function configuration
|
|
639
|
+
* Used for lag, lead, rank, movingAvg, and other window function measure types
|
|
640
|
+
*/
|
|
641
|
+
windowConfig?: {
|
|
642
|
+
/** Dimension references to partition by (e.g., ['employeeId']) */
|
|
643
|
+
partitionBy?: string[];
|
|
644
|
+
/** Columns to order by with direction */
|
|
645
|
+
orderBy?: Array<{
|
|
646
|
+
field: string;
|
|
647
|
+
direction: 'asc' | 'desc';
|
|
648
|
+
}>;
|
|
649
|
+
/** Number of rows to offset for lag/lead. Default: 1 */
|
|
650
|
+
offset?: number;
|
|
651
|
+
/** Default value when offset is out of bounds for lag/lead */
|
|
652
|
+
defaultValue?: any;
|
|
653
|
+
/** Number of buckets for ntile. Default: 4 */
|
|
654
|
+
nTile?: number;
|
|
655
|
+
/** Window frame specification for moving aggregates */
|
|
656
|
+
frame?: {
|
|
657
|
+
type: 'rows' | 'range';
|
|
658
|
+
start: number | 'unbounded';
|
|
659
|
+
end: number | 'current' | 'unbounded';
|
|
660
|
+
};
|
|
661
|
+
};
|
|
512
662
|
}
|
|
513
663
|
export { Measure }
|
|
514
664
|
export { Measure as SemanticMeasure }
|
|
@@ -540,7 +690,7 @@ export declare interface MeasureMetadata {
|
|
|
540
690
|
/**
|
|
541
691
|
* Type enums and constants
|
|
542
692
|
*/
|
|
543
|
-
export declare type MeasureType = 'count' | 'countDistinct' | 'countDistinctApprox' | 'sum' | 'avg' | 'min' | 'max' | 'runningTotal' | 'number' | 'calculated';
|
|
693
|
+
export declare type MeasureType = 'count' | 'countDistinct' | 'countDistinctApprox' | 'sum' | 'avg' | 'min' | 'max' | 'runningTotal' | 'number' | 'calculated' | 'stddev' | 'stddevSamp' | 'variance' | 'varianceSamp' | 'percentile' | 'median' | 'p95' | 'p99' | 'lag' | 'lead' | 'rank' | 'denseRank' | 'rowNumber' | 'ntile' | 'firstValue' | 'lastValue' | 'movingAvg' | 'movingSum';
|
|
544
694
|
|
|
545
695
|
/**
|
|
546
696
|
* Multi-cube query context for cross-cube operations
|
|
@@ -619,6 +769,8 @@ export declare interface PreAggregationCTEInfo {
|
|
|
619
769
|
joinKeys: JoinKeyInfo[];
|
|
620
770
|
/** List of measure names included in this CTE */
|
|
621
771
|
measures: string[];
|
|
772
|
+
/** Propagating filters from related cubes (for cross-cube filter propagation) */
|
|
773
|
+
propagatingFilters?: PropagatingFilter[];
|
|
622
774
|
}
|
|
623
775
|
|
|
624
776
|
/**
|
|
@@ -658,6 +810,27 @@ export declare interface PrimaryCubeCandidate {
|
|
|
658
810
|
*/
|
|
659
811
|
export declare type PrimaryCubeSelectionReason = 'most_dimensions' | 'most_connected' | 'alphabetical_fallback' | 'single_cube';
|
|
660
812
|
|
|
813
|
+
/**
|
|
814
|
+
* Propagating filter information for cross-cube filter propagation
|
|
815
|
+
* When cube A has filters and cube B (with hasMany from A) needs a CTE,
|
|
816
|
+
* A's filters should propagate into B's CTE via a subquery
|
|
817
|
+
*/
|
|
818
|
+
export declare interface PropagatingFilter {
|
|
819
|
+
/** The source cube whose filters need to propagate */
|
|
820
|
+
sourceCube: Cube;
|
|
821
|
+
/** Filters from the source cube to apply */
|
|
822
|
+
filters: Filter[];
|
|
823
|
+
/** Join condition linking source cube PK to target cube FK */
|
|
824
|
+
joinCondition: {
|
|
825
|
+
/** Primary key column on source cube */
|
|
826
|
+
source: AnyColumn;
|
|
827
|
+
/** Foreign key column on target cube (CTE cube) */
|
|
828
|
+
target: AnyColumn;
|
|
829
|
+
};
|
|
830
|
+
/** Pre-built filter SQL for parameter deduplication (optional, built during query planning) */
|
|
831
|
+
preBuiltFilterSQL?: SQL;
|
|
832
|
+
}
|
|
833
|
+
|
|
661
834
|
/**
|
|
662
835
|
* Any queryable relation that can be used in FROM/JOIN clauses
|
|
663
836
|
* Supports tables, views, subqueries, and raw SQL expressions
|
|
@@ -738,8 +911,12 @@ export declare class QueryBuilder {
|
|
|
738
911
|
/**
|
|
739
912
|
* Build measure expression with aggregation and filters
|
|
740
913
|
* Note: This should NOT be called for calculated measures
|
|
914
|
+
*
|
|
915
|
+
* @param measure - The measure definition
|
|
916
|
+
* @param context - Query context with security context and database info
|
|
917
|
+
* @param cube - Optional cube reference for resolving dimension references (window functions)
|
|
741
918
|
*/
|
|
742
|
-
buildMeasureExpression(measure: any, context: QueryContext): SQL;
|
|
919
|
+
buildMeasureExpression(measure: any, context: QueryContext, cube?: Cube): SQL;
|
|
743
920
|
/**
|
|
744
921
|
* Build time dimension expression with granularity using database adapter
|
|
745
922
|
*/
|
|
@@ -747,8 +924,9 @@ export declare class QueryBuilder {
|
|
|
747
924
|
/**
|
|
748
925
|
* Build WHERE conditions from semantic query filters (dimensions only)
|
|
749
926
|
* Works for both single and multi-cube queries
|
|
927
|
+
* @param preBuiltFilters - Optional map of cube name to pre-built filter SQL for parameter deduplication
|
|
750
928
|
*/
|
|
751
|
-
buildWhereConditions(cubes: Map<string, Cube> | Cube, query: SemanticQuery, context: QueryContext, queryPlan?: QueryPlan): SQL[];
|
|
929
|
+
buildWhereConditions(cubes: Map<string, Cube> | Cube, query: SemanticQuery, context: QueryContext, queryPlan?: QueryPlan, preBuiltFilters?: Map<string, SQL[]>): SQL[];
|
|
752
930
|
/**
|
|
753
931
|
* Build HAVING conditions from semantic query filters (measures only)
|
|
754
932
|
* Works for both single and multi-cube queries
|
|
@@ -778,9 +956,20 @@ export declare class QueryBuilder {
|
|
|
778
956
|
* Ensures dates are in the correct format for each database engine
|
|
779
957
|
*/
|
|
780
958
|
private normalizeDate;
|
|
959
|
+
/**
|
|
960
|
+
* Check if a measure type is a window function
|
|
961
|
+
*/
|
|
962
|
+
private isWindowFunctionType;
|
|
963
|
+
/**
|
|
964
|
+
* Check if a measure type is an aggregate function (requires GROUP BY)
|
|
965
|
+
*/
|
|
966
|
+
private isAggregateFunctionType;
|
|
781
967
|
/**
|
|
782
968
|
* Build GROUP BY fields from dimensions and time dimensions
|
|
783
969
|
* Works for both single and multi-cube queries
|
|
970
|
+
*
|
|
971
|
+
* NOTE: GROUP BY is only added when there are AGGREGATE measures.
|
|
972
|
+
* Window functions do not require GROUP BY and operate on individual rows.
|
|
784
973
|
*/
|
|
785
974
|
buildGroupByFields(cubes: Map<string, Cube> | Cube, query: SemanticQuery, context: QueryContext, queryPlan?: any): (SQL | AnyColumn)[];
|
|
786
975
|
/**
|
|
@@ -797,6 +986,21 @@ export declare class QueryBuilder {
|
|
|
797
986
|
* If offset is provided without limit, add a reasonable default limit
|
|
798
987
|
*/
|
|
799
988
|
applyLimitAndOffset<T>(query: T, semanticQuery: SemanticQuery): T;
|
|
989
|
+
/**
|
|
990
|
+
* Public wrapper for buildFilterCondition - used by executor for cache preloading
|
|
991
|
+
* This allows pre-building filter SQL before query construction
|
|
992
|
+
*/
|
|
993
|
+
buildFilterConditionPublic(fieldExpr: AnyColumn | SQL, operator: FilterOperator, values: any[], field?: any, dateRange?: string | string[]): SQL | null;
|
|
994
|
+
/**
|
|
995
|
+
* Build a logical filter (AND/OR) - used by executor for cache preloading
|
|
996
|
+
* This handles nested filter structures and builds combined SQL
|
|
997
|
+
*/
|
|
998
|
+
buildLogicalFilter(filter: Filter, cubes: Map<string, Cube>, context: QueryContext): SQL | null;
|
|
999
|
+
/**
|
|
1000
|
+
* Build SQL for a single filter condition (simple or logical)
|
|
1001
|
+
* Used for cache preloading to build filters independently of query context
|
|
1002
|
+
*/
|
|
1003
|
+
private buildSingleFilter;
|
|
800
1004
|
}
|
|
801
1005
|
|
|
802
1006
|
/**
|
|
@@ -814,6 +1018,11 @@ declare interface QueryContext {
|
|
|
814
1018
|
query?: SemanticQuery;
|
|
815
1019
|
/** The compiled cube being queried */
|
|
816
1020
|
cube?: Cube;
|
|
1021
|
+
/**
|
|
1022
|
+
* Filter cache for parameter deduplication across CTEs
|
|
1023
|
+
* Created at query start and used throughout query building
|
|
1024
|
+
*/
|
|
1025
|
+
filterCache?: FilterCacheManager;
|
|
817
1026
|
}
|
|
818
1027
|
export { QueryContext }
|
|
819
1028
|
export { QueryContext as SemanticQueryContext }
|
|
@@ -840,6 +1049,14 @@ export declare class QueryExecutor {
|
|
|
840
1049
|
* Build join condition for CTE
|
|
841
1050
|
*/
|
|
842
1051
|
private buildCTEJoinCondition;
|
|
1052
|
+
/**
|
|
1053
|
+
* Build a subquery filter for propagating filters from related cubes.
|
|
1054
|
+
* This generates: cteCube.FK IN (SELECT sourceCube.PK FROM sourceCube WHERE filters...)
|
|
1055
|
+
*
|
|
1056
|
+
* Example: For Productivity CTE with Employees.createdAt filter:
|
|
1057
|
+
* employee_id IN (SELECT id FROM employees WHERE organisation_id = $1 AND created_at >= $date)
|
|
1058
|
+
*/
|
|
1059
|
+
private buildPropagatingFilterSubquery;
|
|
843
1060
|
/**
|
|
844
1061
|
* Build unified query that works for both single and multi-cube queries
|
|
845
1062
|
*/
|
|
@@ -870,6 +1087,12 @@ export declare class QueryExecutor {
|
|
|
870
1087
|
* Generate annotations for UI metadata - unified approach
|
|
871
1088
|
*/
|
|
872
1089
|
private generateAnnotations;
|
|
1090
|
+
/**
|
|
1091
|
+
* Pre-build filter SQL and store in cache for reuse across CTEs and main query
|
|
1092
|
+
* This enables parameter deduplication - the same filter values are shared
|
|
1093
|
+
* rather than appearing as separate parameters in different parts of the query
|
|
1094
|
+
*/
|
|
1095
|
+
private preloadFilterCache;
|
|
873
1096
|
}
|
|
874
1097
|
|
|
875
1098
|
/**
|
|
@@ -925,6 +1148,7 @@ export declare class QueryPlanner {
|
|
|
925
1148
|
private extractMeasuresFromFilters;
|
|
926
1149
|
/**
|
|
927
1150
|
* Recursively extract measures from filters for a specific cube
|
|
1151
|
+
* Only includes filter members that are actually measures (not dimensions)
|
|
928
1152
|
*/
|
|
929
1153
|
private extractMeasuresFromFilter;
|
|
930
1154
|
/**
|
|
@@ -972,6 +1196,27 @@ export declare class QueryPlanner {
|
|
|
972
1196
|
* Find hasMany join definition from primary cube to target cube
|
|
973
1197
|
*/
|
|
974
1198
|
private findHasManyJoinDef;
|
|
1199
|
+
/**
|
|
1200
|
+
* Find filters that need to propagate from related cubes to a CTE cube.
|
|
1201
|
+
* When cube A has filters and a hasMany relationship to cube B (the CTE cube),
|
|
1202
|
+
* A's filters should propagate into B's CTE via a subquery.
|
|
1203
|
+
*
|
|
1204
|
+
* Example: Employees.createdAt filter should propagate to Productivity CTE
|
|
1205
|
+
* via: employee_id IN (SELECT id FROM employees WHERE created_at >= $date)
|
|
1206
|
+
*/
|
|
1207
|
+
private findPropagatingFilters;
|
|
1208
|
+
/**
|
|
1209
|
+
* Extract cube names from filters into a Set (helper for findPropagatingFilters)
|
|
1210
|
+
*/
|
|
1211
|
+
private extractFilterCubeNamesToSet;
|
|
1212
|
+
/**
|
|
1213
|
+
* Extract filters for a specific cube from the filter array
|
|
1214
|
+
*/
|
|
1215
|
+
private extractFiltersForCube;
|
|
1216
|
+
/**
|
|
1217
|
+
* Extract time dimension date range filters as regular filters for a specific cube
|
|
1218
|
+
*/
|
|
1219
|
+
private extractTimeDimensionFiltersForCube;
|
|
975
1220
|
/**
|
|
976
1221
|
* Analyze query planning decisions without building the full query
|
|
977
1222
|
* Returns detailed metadata about how the query plan would be constructed
|
|
@@ -988,6 +1233,7 @@ export declare class QueryPlanner {
|
|
|
988
1233
|
private analyzeJoinPath;
|
|
989
1234
|
/**
|
|
990
1235
|
* Analyze pre-aggregation requirements for hasMany relationships
|
|
1236
|
+
* This mirrors the logic in planPreAggregationCTEs to ensure analysis matches execution
|
|
991
1237
|
*/
|
|
992
1238
|
private analyzePreAggregations;
|
|
993
1239
|
}
|
|
@@ -1270,4 +1516,27 @@ export declare interface TimeDimensionAnnotation {
|
|
|
1270
1516
|
|
|
1271
1517
|
export declare type TimeGranularity = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
1272
1518
|
|
|
1519
|
+
/**
|
|
1520
|
+
* Window function configuration
|
|
1521
|
+
*/
|
|
1522
|
+
declare interface WindowFunctionConfig {
|
|
1523
|
+
/** Number of rows to offset for lag/lead */
|
|
1524
|
+
offset?: number;
|
|
1525
|
+
/** Default value when offset is out of bounds */
|
|
1526
|
+
defaultValue?: any;
|
|
1527
|
+
/** Number of buckets for ntile */
|
|
1528
|
+
nTile?: number;
|
|
1529
|
+
/** Frame specification for moving aggregates */
|
|
1530
|
+
frame?: {
|
|
1531
|
+
type: 'rows' | 'range';
|
|
1532
|
+
start: number | 'unbounded';
|
|
1533
|
+
end: number | 'current' | 'unbounded';
|
|
1534
|
+
};
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
/**
|
|
1538
|
+
* Window function types supported by the adapter
|
|
1539
|
+
*/
|
|
1540
|
+
declare type WindowFunctionType = 'lag' | 'lead' | 'rank' | 'denseRank' | 'rowNumber' | 'ntile' | 'firstValue' | 'lastValue' | 'movingAvg' | 'movingSum';
|
|
1541
|
+
|
|
1273
1542
|
export { }
|