Skip to content

Commit f41fccd

Browse files
committed
test: share one Map key scan between concurrent callers
1 parent dd00512 commit f41fccd

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

‎packages/common-utils/src/__tests__/metadata.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3146,6 +3146,39 @@ describe('Metadata', () => {
31463146

31473147
expect(mockClickhouseClient.query).toHaveBeenCalledTimes(2);
31483148
});
3149+
3150+
it('shares one scan between concurrent callers when no text index or rollup applies', async () => {
3151+
const md = buildMetadata();
3152+
jest.spyOn(console, 'warn').mockImplementation(() => {});
3153+
jest
3154+
.spyOn(md, 'getMapColumnTextIndexes')
3155+
.mockResolvedValue(new Map() as TextIndexInfoLookup);
3156+
jest.spyOn(md, 'getColumn').mockResolvedValue({
3157+
name: 'LogAttributes',
3158+
type: 'Map(String, String)',
3159+
default_type: '',
3160+
default_expression: '',
3161+
comment: '',
3162+
codec_expression: '',
3163+
ttl_expression: '',
3164+
});
3165+
(mockClickhouseClient.query as jest.Mock).mockResolvedValue({
3166+
json: () => Promise.resolve({ data: [{ keysArr: ['raw.key'] }] }),
3167+
});
3168+
3169+
const {
3170+
timestampValueExpression: _timestampValueExpression,
3171+
metadataMVs: _metadataMVs,
3172+
...scanArgs
3173+
} = baseArgs;
3174+
const results = await Promise.all([
3175+
md.getMapKeys(scanArgs),
3176+
md.getMapKeys(scanArgs),
3177+
]);
3178+
3179+
expect(results).toEqual([['raw.key'], ['raw.key']]);
3180+
expect(mockClickhouseClient.query).toHaveBeenCalledTimes(1);
3181+
});
31493182
});
31503183

31513184
describe('getMapKeys (text index paths)', () => {

0 commit comments

Comments
 (0)