Skip to content

Commit cb54545

Browse files
authored
fix(schema-compiler): Fix multifact joined queries in Tesseract (#9954)
1 parent 8b499e4 commit cb54545

File tree

3 files changed

+22
-28
lines changed

3 files changed

+22
-28
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5062,7 +5062,7 @@ export class BaseQuery {
50625062
return false;
50635063
}
50645064

5065-
return dfs(root) ? path.join('.') : null;
5065+
return (root && dfs(root)) ? path.join('.') : null;
50665066
};
50675067
}
50685068

@@ -5080,7 +5080,7 @@ export class BaseQuery {
50805080
const [cube, field] = member.split('.');
50815081
if (!cube || !field) return member;
50825082

5083-
if (cube === queryJoinRoot.root) {
5083+
if (cube === queryJoinRoot?.root) {
50845084
return member;
50855085
}
50865086

packages/cubejs-schema-compiler/src/adapter/PreAggregations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export class PreAggregations {
144144
const { join } = this.query;
145145
if (!join) {
146146
// This can happen with Tesseract, or when there's no cubes to join
147-
throw new Error('Unexpected missing join tree for query');
147+
return [];
148148
}
149149
return join.joins.map(j => j.originalTo).concat([join.root]);
150150
}

packages/cubejs-schema-compiler/test/integration/postgres/multi-fact-join.test.ts

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -112,29 +112,23 @@ cube(\`city\`, {
112112
);
113113
}
114114

115-
if (getEnv('nativeSqlPlanner')) {
116-
it.skip('FIXME(tesseract): two regular sub-queries', () => {
117-
// TODO: Fix in tesseract
118-
});
119-
} else {
120-
it('two regular sub-queries', async () => runQueryTest({
121-
measures: ['orders.amount', 'shipments.count'],
122-
dimensions: [
123-
'city.name'
124-
],
125-
order: [{ id: 'city.name' }]
126-
}, [{
127-
city__name: 'New York City',
128-
orders__amount: '9',
129-
shipments__count: '3',
130-
}, {
131-
city__name: 'San Francisco',
132-
orders__amount: '6',
133-
shipments__count: '1',
134-
}, {
135-
city__name: null,
136-
orders__amount: '6',
137-
shipments__count: '1',
138-
}]));
139-
}
115+
it('two regular sub-queries', async () => runQueryTest({
116+
measures: ['orders.amount', 'shipments.count'],
117+
dimensions: [
118+
'city.name'
119+
],
120+
order: [{ id: 'city.name' }]
121+
}, [{
122+
city__name: 'New York City',
123+
orders__amount: '9',
124+
shipments__count: '3',
125+
}, {
126+
city__name: 'San Francisco',
127+
orders__amount: '6',
128+
shipments__count: '1',
129+
}, {
130+
city__name: null,
131+
orders__amount: '6',
132+
shipments__count: '1',
133+
}]));
140134
});

0 commit comments

Comments
 (0)