Skip to content

Commit 18ab13f

Browse files
authored
Merge branch 'master' into feat/duckdb-driver-upgrade-version-to-1.2
2 parents 8488070 + 19d1b33 commit 18ab13f

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

docs/pages/product/workspace/sql-runner.mdx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,22 @@ and click <Btn>▶ Run</Btn>. The query results will be displayed under
3535
src="https://ucarecdn.com/2f910abf-5b94-43cd-87f8-14c86bd98f77/"
3636
/>
3737

38-
## Querying a data source vs Cube Store
38+
## Querying data sources
3939

40-
The SQL Runner can run queries against any configured data sources, which is
41-
helpful for diagnosing database-specific issues. It can also run queries against
42-
Cube Store, which is useful for testing pre-aggregations directly to see if they
43-
return expected results. You can switch data source(s) by clicking the dropdown
44-
under **Data Source**:
40+
SQL Runner can run queries against configured data sources, which is
41+
helpful for diagnosing database-specific issues.
42+
43+
<InfoBox>
44+
45+
In order for an additional data source to show up in SQL Runner, it needs to be
46+
the [data source][ref-cube-datasource] in at least one cube definition.
47+
48+
</InfoBox>
49+
50+
It can also run queries against Cube Store, which is useful for testing
51+
pre-aggregations directly to see if they return expected results.
52+
53+
You can switch data source(s) by clicking the dropdown under <Btn>Data Source</Btn>:
4554

4655
<Screenshot
4756
highlight="inset(25% 60% 53% 6% round 10px)"
@@ -97,6 +106,8 @@ in a data model should be a `numeric`).
97106
src="https://ucarecdn.com/c2735f7c-d5e7-4b6b-903b-8d0db07b668e/"
98107
/>
99108

109+
100110
[cubecloud-signup]: https://cubecloud.dev/auth/signup
101111
[ref-conf-scheduled-refresh-ctx]:
102112
/reference/configuration/config#scheduledrefreshcontexts
113+
[ref-cube-datasource]: /reference/data-model/cube#data_source

packages/cubejs-schema-compiler/src/compiler/CubeEvaluator.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ export class CubeEvaluator extends CubeSymbols {
238238
if (cube.isView && (cube.includedMembers || []).length) {
239239
const includedMemberPaths: string[] = R.uniq(cube.includedMembers.map(it => it.memberPath));
240240
const includedCubeNames: string[] = R.uniq(includedMemberPaths.map(it => it.split('.')[0]));
241+
// Path to name (which can be prefixed or aliased) map for hierarchy
242+
const hierarchyPathToName = cube.includedMembers.filter(it => it.type === 'hierarchies').reduce((acc, it) => ({
243+
...acc,
244+
[it.memberPath]: it.name
245+
}), {});
241246
const includedHierarchyNames = cube.includedMembers.filter(it => it.type === 'hierarchies').map(it => it.memberPath.split('.')[1]);
242247

243248
for (const cubeName of includedCubeNames) {
@@ -260,8 +265,13 @@ export class CubeEvaluator extends CubeSymbols {
260265
return null;
261266
}).filter(Boolean);
262267

268+
const name = hierarchyPathToName[[cubeName, it.name].join('.')];
269+
if (!name) {
270+
throw new UserError(`Hierarchy '${it.name}' not found in cube '${cubeName}'`);
271+
}
263272
return {
264273
...it,
274+
name,
265275
levels
266276
};
267277
})

packages/cubejs-schema-compiler/test/unit/hierarchies.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ describe('Cube hierarchies', () => {
5050
(it) => it.config.name === 'all_hierarchy_view'
5151
);
5252
expect(allHierarchyView.config.hierarchies.length).toBe(3);
53+
54+
const prefixedHierarchy = allHierarchyView.config.hierarchies.find((it) => it.name === 'all_hierarchy_view.users_users_hierarchy');
55+
expect(prefixedHierarchy).toBeTruthy();
56+
expect(prefixedHierarchy?.levels).toEqual(['all_hierarchy_view.users_age', 'all_hierarchy_view.users_city']);
5357
});
5458

5559
it(('hierarchy with measure'), async () => {

0 commit comments

Comments
 (0)