@@ -288,6 +288,10 @@ export class BaseQuery {
288288 return dimension ;
289289 } ) . filter ( R . identity ) . map ( this . newTimeDimension . bind ( this ) ) ;
290290 this . allFilters = this . timeDimensions . concat ( this . segments ) . concat ( this . filters ) ;
291+ /**
292+ * @type {Array<{sql: string, on: {expression: Function}, joinType: 'LEFT' | 'INNER', alias: string}> }
293+ */
294+ this . customSubQueryJoins = this . options . subqueryJoins ?? [ ] ;
291295 this . useNativeSqlPlanner = this . options . useNativeSqlPlanner ?? getEnv ( 'nativeSqlPlanner' ) ;
292296 this . canUseNativeSqlPlannerPreAggregation = false ;
293297 if ( this . useNativeSqlPlanner ) {
@@ -300,11 +304,6 @@ export class BaseQuery {
300304 this . preAggregationsSchemaOption = this . options . preAggregationsSchema ?? DEFAULT_PREAGGREGATIONS_SCHEMA ;
301305 this . externalQueryClass = this . options . externalQueryClass ;
302306
303- /**
304- * @type {Array<{sql: string, on: {expression: Function}, joinType: 'LEFT' | 'INNER', alias: string}> }
305- */
306- this . customSubQueryJoins = this . options . subqueryJoins ?? [ ] ;
307-
308307 // Set the default order only when options.order is not provided at all
309308 // if options.order is set (empty array [] or with data) - use it as is
310309 this . order = this . options . order ?? this . defaultOrder ( ) ;
@@ -2284,14 +2283,34 @@ export class BaseQuery {
22842283 * @returns {Array<Array<string>> }
22852284 */
22862285 collectJoinHints ( excludeTimeDimensions = false ) {
2287- const membersToCollectFrom = this . allMembersConcat ( excludeTimeDimensions )
2288- . concat ( this . join ? this . join . joins . map ( j => ( {
2289- getMembers : ( ) => [ {
2290- path : ( ) => null ,
2291- cube : ( ) => this . cubeEvaluator . cubeFromPath ( j . originalFrom ) ,
2292- definition : ( ) => j . join ,
2293- } ]
2294- } ) ) : [ ] ) ;
2286+ const customSubQueryJoinMembers = this . customSubQueryJoins . map ( j => {
2287+ const res = {
2288+ path : ( ) => null ,
2289+ cube : ( ) => this . cubeEvaluator . cubeFromPath ( j . on . cubeName ) ,
2290+ definition : ( ) => ( {
2291+ sql : j . on . expression ,
2292+ // TODO use actual type even though it isn't used right now
2293+ type : 'number'
2294+ } ) ,
2295+ } ;
2296+ return {
2297+ getMembers : ( ) => [ res ] ,
2298+ } ;
2299+ } ) ;
2300+
2301+ const joinMembers = this . join ? this . join . joins . map ( j => ( {
2302+ getMembers : ( ) => [ {
2303+ path : ( ) => null ,
2304+ cube : ( ) => this . cubeEvaluator . cubeFromPath ( j . originalFrom ) ,
2305+ definition : ( ) => j . join ,
2306+ } ]
2307+ } ) ) : [ ] ;
2308+
2309+ const membersToCollectFrom = [
2310+ ...this . allMembersConcat ( excludeTimeDimensions ) ,
2311+ ...joinMembers ,
2312+ ...customSubQueryJoinMembers ,
2313+ ] ;
22952314
22962315 return this . collectJoinHintsFromMembers ( membersToCollectFrom ) ;
22972316 }
0 commit comments