File tree Expand file tree Collapse file tree
cubejs-backend-shared/src
cubejs-server-core/src/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -354,11 +354,9 @@ const variables: Record<string, (...args: any) => any> = {
354354 /**
355355 * Driver type.
356356 */
357- dbType : ( {
358- dataSource,
359- preAggregations,
360- } : DataSourceOpts ) => (
361- get ( keyByDataSource ( 'CUBEJS_DB_TYPE' , dataSource , preAggregations ) ) . asString ( )
357+ dbType : ( { dataSource } : DataSourceOpts ) => (
358+ // We don't support different driverType for pre-aggregations right now
359+ get ( keyByDataSource ( 'CUBEJS_DB_TYPE' , dataSource , false ) ) . asString ( )
362360 ) ,
363361
364362 /**
Original file line number Diff line number Diff line change @@ -601,17 +601,22 @@ export class CubejsServerCore {
601601 * Driver factory function `DriverFactoryByDataSource`.
602602 */
603603 async ( dataSource = 'default' , preAggregations = false ) => {
604- // Only create a separate pre-agg driver when credentials are actually
605- // configured (custom driverFactory or PRE_AGGREGATIONS env vars).
606- const usePreAgg = preAggregations && (
607- ! ! this . options . driverFactory || hasPreAggregationsEnvVars ( dataSource )
608- ) ;
609- const factoryKey = usePreAgg ? `${ dataSource } __pre_agg` : dataSource ;
604+ const requiredSeparatePreAggDriver = preAggregations && hasPreAggregationsEnvVars ( dataSource ) ;
605+ const usePreAgg = requiredSeparatePreAggDriver && ! this . options . driverFactory ;
606+
607+ const factoryKey = usePreAgg ? `${ dataSource } @pre_agg` : dataSource ;
610608
611609 if ( driverPromise [ factoryKey ] ) {
612610 return driverPromise [ factoryKey ] ;
613611 }
614612
613+ if ( requiredSeparatePreAggDriver && this . options . driverFactory ) {
614+ this . logger ( 'Pre-aggregation driver conflict' , {
615+ error : 'Both driverFactory and PRE_AGGREGATIONS env vars are defined. driverFactory will take precedence.' ,
616+ dataSource,
617+ } ) ;
618+ }
619+
615620 // eslint-disable-next-line no-return-assign
616621 return driverPromise [ factoryKey ] = ( async ( ) => {
617622 let driver : BaseDriver | null = null ;
You can’t perform that action at this time.
0 commit comments