File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
packages/cubejs-schema-compiler Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -1308,15 +1308,16 @@ class BaseQuery {
1308
1308
throw new Error ( 'Not implemented' ) ;
1309
1309
}
1310
1310
1311
- aliasName ( name ) {
1311
+ aliasName ( name , isPreAggregationName ) {
1312
1312
const path = name . split ( '.' ) ;
1313
1313
if ( path [ 0 ] && this . cubeEvaluator . cubeExists ( path [ 0 ] ) && this . cubeEvaluator . cubeFromPath ( path [ 0 ] ) . sqlAlias ) {
1314
1314
const cubeName = path [ 0 ] ;
1315
1315
path . splice ( 0 , 1 ) ;
1316
1316
path . unshift ( this . cubeEvaluator . cubeFromPath ( cubeName ) . sqlAlias ) ;
1317
1317
name = this . cubeEvaluator . pathFromArray ( path ) ;
1318
1318
}
1319
- return inflection . underscore ( name ) . replace ( / \. / g, '__' ) ;
1319
+ // use single underscore for pre-aggregations to avoid fail of pre-aggregation name replace
1320
+ return inflection . underscore ( name ) . replace ( / \. / g, isPreAggregationName ? '_' : '__' ) ;
1320
1321
}
1321
1322
1322
1323
newSubQuery ( options ) {
@@ -1428,7 +1429,7 @@ class BaseQuery {
1428
1429
}
1429
1430
1430
1431
preAggregationTableName ( cube , preAggregationName , skipSchema ) {
1431
- return `${ skipSchema ? '' : this . preAggregationSchema ( ) && `${ this . preAggregationSchema ( ) } .` } ${ this . aliasName ( `${ cube } _ ${ preAggregationName } ` ) } ` ;
1432
+ return `${ skipSchema ? '' : this . preAggregationSchema ( ) && `${ this . preAggregationSchema ( ) } .` } ${ this . aliasName ( `${ cube } . ${ preAggregationName } ` , true ) } ` ;
1432
1433
}
1433
1434
1434
1435
preAggregationSchema ( ) {
Original file line number Diff line number Diff line change @@ -140,6 +140,8 @@ describe('PreAggregations', function test() {
140
140
sql: \`
141
141
select * from visitor_checkins
142
142
\`,
143
+
144
+ sqlAlias: 'vc',
143
145
144
146
measures: {
145
147
count: {
@@ -572,6 +574,7 @@ describe('PreAggregations', function test() {
572
574
console . log ( preAggregationsDescription ) ;
573
575
574
576
const queries = tempTablePreAggregations ( preAggregationsDescription ) ;
577
+ preAggregationsDescription [ 1 ] . loadSql [ 0 ] . should . match ( / v c _ m a i n / ) ;
575
578
576
579
console . log ( JSON . stringify ( queries . concat ( queryAndParams ) ) ) ;
577
580
You can’t perform that action at this time.
0 commit comments