Skip to content

Commit b748137

Browse files
fix: include maskedMembers in collectFrom cache key for correct join resolution
When a member is masked, evaluateSymbolSql takes a different path (mask.sql instead of regular sql), which may reference different cubes requiring different joins. The compilerCache was caching the collection results without considering masking state, causing stale join hints when the same member was first collected without masking and then with masking. Add 'masked' suffix to the cache key for masked members so that masked and unmasked collection results are cached separately. Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
1 parent a2a6fc9 commit b748137

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,17 +2843,20 @@ export class BaseQuery {
28432843
*/
28442844
collectFrom(membersToCollectFrom, fn, methodName, cache) {
28452845
const methodCacheKey = Array.isArray(methodName) ? methodName : [methodName];
2846+
const maskedMembers = this.maskedMembers;
28462847
return R.pipe(
28472848
R.map(f => f.getMembers()),
28482849
R.flatten,
2849-
R.map(s => (
2850-
(cache || this.compilerCache).cache(
2850+
R.map(s => {
2851+
const memberPath = s.path() ? s.path().join('.') : null;
2852+
const isMasked = memberPath && maskedMembers && maskedMembers.has(memberPath);
2853+
return (cache || this.compilerCache).cache(
28512854
['collectFrom'].concat(methodCacheKey).concat(
2852-
s.path() ? [s.path().join('.')] : [s.cube().name, s.expression?.toString() || s.expressionName || s.definition().sql]
2853-
),
2855+
memberPath ? [memberPath] : [s.cube().name, s.expression?.toString() || s.expressionName || s.definition().sql]
2856+
).concat(isMasked ? ['masked'] : []),
28542857
() => fn(() => this.traverseSymbol(s))
2855-
)
2856-
)),
2858+
);
2859+
}),
28572860
R.unnest,
28582861
R.uniq,
28592862
R.filter(R.identity)

0 commit comments

Comments
 (0)