From d2210a2fd0a8f9cfbd439a99a7be4910df19a6af Mon Sep 17 00:00:00 2001 From: Mikhail Cheshkov Date: Wed, 8 Jan 2025 23:38:30 +0200 Subject: [PATCH] [WIP add test] fix(schema-compiler): Handle member expressions in keyDimensions If dimension is member expression, `d.dimension` would be object, and key would be '[object Object]' string, so separate dimensions would have same key, and all but one will be eliminated --- packages/cubejs-schema-compiler/src/adapter/BaseQuery.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js b/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js index 4c309d81ad264..775299299f3f4 100644 --- a/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js +++ b/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js @@ -1855,7 +1855,14 @@ export class BaseQuery { keyDimensions(primaryKeyDimensions) { // The same dimension with different granularities maybe requested, so it's not enough to filter only by dimension return R.uniqBy( - (d) => `${d.dimension}${d.granularity ?? ''}`, this.dimensionsForSelect() + (d) => { + if (d.isMemberExpression) { + return d.dimension.definition; + } + + return `${d.dimension}${d.granularity ?? ''}`; + }, + this.dimensionsForSelect() .concat(primaryKeyDimensions) ); }