@@ -789,6 +789,9 @@ export class BaseQuery {
789789 * @returns {string }
790790 */
791791 fullKeyQueryAggregate ( ) {
792+ if ( this . from ) {
793+ return this . simpleQuery ( ) ;
794+ }
792795 const {
793796 multipliedMeasures,
794797 regularMeasures,
@@ -1423,17 +1426,16 @@ export class BaseQuery {
14231426 }
14241427
14251428 overTimeSeriesSelect ( cumulativeMeasures , dateSeriesSql , baseQuery , dateJoinConditionSql , baseQueryAlias ) {
1426- const forSelect = this . overTimeSeriesForSelect ( cumulativeMeasures , baseQueryAlias ) ;
1429+ const forSelect = this . overTimeSeriesForSelect ( cumulativeMeasures ) ;
14271430 return `SELECT ${ forSelect } FROM ${ dateSeriesSql } ` +
14281431 ` LEFT JOIN (${ baseQuery } ) ${ this . asSyntaxJoin } ${ baseQueryAlias } ON ${ dateJoinConditionSql } ` +
14291432 this . groupByClause ( ) ;
14301433 }
14311434
1432- overTimeSeriesForSelect ( cumulativeMeasures , baseQueryAlias ) {
1433- return this . dimensions . map ( s => s . cumulativeSelectColumns ( baseQueryAlias ) )
1434- . concat ( this . dateSeriesSelect ( ) )
1435- . concat ( cumulativeMeasures . map ( s => s . cumulativeSelectColumns ( baseQueryAlias ) ) )
1436- . filter ( c => ! ! c )
1435+ overTimeSeriesForSelect ( cumulativeMeasures ) {
1436+ return this . dimensions . map ( s => s . cumulativeSelectColumns ( ) ) . concat ( this . dateSeriesSelect ( ) ) . concat (
1437+ cumulativeMeasures . map ( s => s . cumulativeSelectColumns ( ) ) ,
1438+ ) . filter ( c => ! ! c )
14371439 . join ( ', ' ) ;
14381440 }
14391441
@@ -1790,16 +1792,16 @@ export class BaseQuery {
17901792 } ) ) ;
17911793 }
17921794
1793- groupedUngroupedSelect ( selectFn , ungrouped , granularityOverride ) {
1795+ groupedUngroupedSelect ( select , ungrouped , granularityOverride ) {
17941796 return this . evaluateSymbolSqlWithContext (
1795- selectFn ,
1797+ select ,
17961798 { ungrouped, granularityOverride, overTimeSeriesAggregate : true }
17971799 ) ;
17981800 }
17991801
1800- ungroupedMeasureSelect ( selectFn ) {
1802+ ungroupedMeasureSelect ( select ) {
18011803 return this . evaluateSymbolSqlWithContext (
1802- selectFn ,
1804+ select ,
18031805 { ungrouped : true }
18041806 ) ;
18051807 }
@@ -2264,28 +2266,17 @@ export class BaseQuery {
22642266 this . safeEvaluateSymbolContext ( ) . leafMeasures [ this . safeEvaluateSymbolContext ( ) . currentMeasure ] = true ;
22652267 }
22662268 }
2267-
2269+ const primaryKeys = this . cubeEvaluator . primaryKeys [ cubeName ] ;
2270+ const orderBySql = ( symbol . orderBy || [ ] ) . map ( o => ( { sql : this . evaluateSql ( cubeName , o . sql ) , dir : o . dir } ) ) ;
22682271 let sql ;
2269- let orderBySql = [ ] ;
2270-
2271- if ( ( this . safeEvaluateSymbolContext ( ) . ungroupedAliasesForCumulative || { } ) [ memberPath ] ) {
2272- sql = this . safeEvaluateSymbolContext ( ) . ungroupedAliasesForCumulative [ memberPath ] ;
2273- if ( this . safeEvaluateSymbolContext ( ) . ungroupedBaseQueryAliasForCumulative ) {
2274- sql = `${ this . safeEvaluateSymbolContext ( ) . ungroupedBaseQueryAliasForCumulative } .${ sql } ` ;
2275- }
2276- } else {
2277- const primaryKeys = this . cubeEvaluator . primaryKeys [ cubeName ] ;
2278- orderBySql = ( symbol . orderBy || [ ] ) . map ( o => ( { sql : this . evaluateSql ( cubeName , o . sql ) , dir : o . dir } ) ) ;
2279- if ( symbol . type !== 'rank' ) {
2280- sql = symbol . sql && this . evaluateSql ( cubeName , symbol . sql ) ||
2281- primaryKeys . length && (
2282- primaryKeys . length > 1 ?
2283- this . concatStringsSql ( primaryKeys . map ( ( pk ) => this . castToString ( this . primaryKeySql ( pk , cubeName ) ) ) )
2284- : this . primaryKeySql ( primaryKeys [ 0 ] , cubeName )
2285- ) || '*' ;
2286- }
2272+ if ( symbol . type !== 'rank' ) {
2273+ sql = symbol . sql && this . evaluateSql ( cubeName , symbol . sql ) ||
2274+ primaryKeys . length && (
2275+ primaryKeys . length > 1 ?
2276+ this . concatStringsSql ( primaryKeys . map ( ( pk ) => this . castToString ( this . primaryKeySql ( pk , cubeName ) ) ) )
2277+ : this . primaryKeySql ( primaryKeys [ 0 ] , cubeName )
2278+ ) || '*' ;
22872279 }
2288-
22892280 const result = this . renderSqlMeasure (
22902281 name ,
22912282 sql && this . applyMeasureFilters (
@@ -2302,7 +2293,6 @@ export class BaseQuery {
23022293 parentMeasure ,
23032294 orderBySql ,
23042295 ) ;
2305-
23062296 if (
23072297 this . safeEvaluateSymbolContext ( ) . compositeCubeMeasures ||
23082298 this . safeEvaluateSymbolContext ( ) . leafMeasures
0 commit comments