Skip to content

Commit 723359c

Browse files
committed
fix: BigQuery external rollup compatibility: use __ separator for member aliases. Fix all tests.
1 parent 3e348ef commit 723359c

File tree

7 files changed

+376
-371
lines changed

7 files changed

+376
-371
lines changed

packages/cubejs-schema-compiler/adapter/BaseQuery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ class BaseQuery {
11941194
}
11951195

11961196
aliasName(name) {
1197-
return inflection.underscore(name).replace(/\./g, '_');
1197+
return inflection.underscore(name).replace(/\./g, '__');
11981198
}
11991199

12001200
newSubQuery(options) {

packages/cubejs-schema-compiler/test/AsyncModuleTest.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable quote-props */
12
/* globals describe, it */
23
const PostgresQuery = require('../adapter/PostgresQuery');
34
const PrepareCompiler = require('./PrepareCompiler');
@@ -55,7 +56,7 @@ describe('AsyncModule', () => {
5556
return dbRunner.testQuery(query.buildSqlAndParams()).then(res => {
5657
res.should.be.deepEqual(
5758
[
58-
{ "visitors.visitor_count": "6" }
59+
{ "visitors__visitor_count": "6" }
5960
]
6061
);
6162
});

packages/cubejs-schema-compiler/test/ClickHouseDataSchemaCompilerTest.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable quote-props */
12
/* globals describe, before, after, it */
23
const CompileError = require('../compiler/CompileError');
34
const PrepareCompiler = require('./PrepareCompiler');
@@ -168,10 +169,10 @@ describe('ClickHouse DataSchemaCompiler', function test() {
168169
return dbRunner.testQuery(query.buildSqlAndParams()).then(res => {
169170
res.should.be.deepEqual(
170171
[
171-
{ "visitors.created_at_date": "2017-01-02T00:00:00.000", "visitors.visitor_count": "1" },
172-
{ "visitors.created_at_date": "2017-01-04T00:00:00.000", "visitors.visitor_count": "1" },
173-
{ "visitors.created_at_date": "2017-01-05T00:00:00.000", "visitors.visitor_count": "1" },
174-
{ "visitors.created_at_date": "2017-01-06T00:00:00.000", "visitors.visitor_count": "2" }
172+
{ "visitors__created_at_date": "2017-01-02T00:00:00.000", "visitors__visitor_count": "1" },
173+
{ "visitors__created_at_date": "2017-01-04T00:00:00.000", "visitors__visitor_count": "1" },
174+
{ "visitors__created_at_date": "2017-01-05T00:00:00.000", "visitors__visitor_count": "1" },
175+
{ "visitors__created_at_date": "2017-01-06T00:00:00.000", "visitors__visitor_count": "2" }
175176
]
176177
);
177178
});
@@ -230,8 +231,8 @@ describe('ClickHouse DataSchemaCompiler', function test() {
230231
return dbRunner.testQuery(query.buildSqlAndParams()).then(res => {
231232
res.should.be.deepEqual(
232233
[
233-
{ "visitors.status": "Approved", "visitors.visitor_count": "2" },
234-
{ "visitors.status": "Canceled", "visitors.visitor_count": "4" }
234+
{ "visitors__status": "Approved", "visitors__visitor_count": "2" },
235+
{ "visitors__status": "Canceled", "visitors__visitor_count": "4" }
235236
]
236237
);
237238
});
@@ -264,21 +265,21 @@ describe('ClickHouse DataSchemaCompiler', function test() {
264265
})
265266
`);
266267
const responses = [
267-
[{ 'visitors.created_at': '2017-01-02T16:00:00.000' }],
268+
[{ "visitors__created_at": '2017-01-02T16:00:00.000' }],
268269
[
269-
{ 'visitors.created_at': '2016-09-06T16:00:00.000' },
270-
{ 'visitors.created_at': '2017-01-04T16:00:00.000' },
271-
{ 'visitors.created_at': '2017-01-05T16:00:00.000' },
272-
{ 'visitors.created_at': '2017-01-06T16:00:00.000' }
270+
{ "visitors__created_at": '2016-09-06T16:00:00.000' },
271+
{ "visitors__created_at": '2017-01-04T16:00:00.000' },
272+
{ "visitors__created_at": '2017-01-05T16:00:00.000' },
273+
{ "visitors__created_at": '2017-01-06T16:00:00.000' }
273274
],
274-
[{ 'visitors.created_at': '2017-01-06T16:00:00.000' }],
275+
[{ "visitors__created_at": '2017-01-06T16:00:00.000' }],
275276
[
276-
{ 'visitors.created_at': '2016-09-06T16:00:00.000' },
277-
{ 'visitors.created_at': '2017-01-02T16:00:00.000' },
278-
{ 'visitors.created_at': '2017-01-04T16:00:00.000' },
279-
{ 'visitors.created_at': '2017-01-05T16:00:00.000' }
277+
{ "visitors__created_at": '2016-09-06T16:00:00.000' },
278+
{ "visitors__created_at": '2017-01-02T16:00:00.000' },
279+
{ "visitors__created_at": '2017-01-04T16:00:00.000' },
280+
{ "visitors__created_at": '2017-01-05T16:00:00.000' }
280281
],
281-
[{ 'visitors.created_at': '2017-01-06T16:00:00.000' }]
282+
[{ "visitors__created_at": '2017-01-06T16:00:00.000' }]
282283
];
283284
['in_date_range', 'not_in_date_range', 'on_the_date', 'before_date', 'after_date'].map((operator, index) => {
284285
const filterValues = index < 2 ? ['2017-01-01', '2017-01-03'] : ['2017-01-06', '2017-01-06'];

0 commit comments

Comments
 (0)