hyperdx/packages/common-utils/jest.config.js
Drew Davis 8190ee8f6a
perf: Improve getKeyValues query performance for JSON keys (#1284)
Closes HDX-2623

# Summary

This change improves the performance of `getKeyValues` when getting values of a JSON key. 

Generally, columns that are not referenced outside of a CTE will be pruned by the query planner. For JSON however, if the outer select references one field in a JSON column, then the inner select will read (it seems) the entire JSON object.

This PR also adds integration tests for `getKeyValues` to ensure that the function generates queries that work as expected in ClickHouse.

##  Performance impact (on single JSON Dashboard Filter)

- Original: 15.03s

<img width="584" height="71" alt="Screenshot 2025-10-21 at 3 28 07 PM" src="https://github.com/user-attachments/assets/184de198-cee1-4b1d-beed-ec4465d3e248" />

- Optimized: 0.443s

<img width="590" height="61" alt="Screenshot 2025-10-21 at 3 25 47 PM" src="https://github.com/user-attachments/assets/690d0ef0-15b8-47c5-9a7e-8b8f6b8f5e92" />
2025-10-27 16:46:46 +00:00

13 lines
350 B
JavaScript

/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
verbose: true,
rootDir: './src',
testMatch: ['**/__tests__/*.test.ts?(x)'],
testPathIgnorePatterns: ['.*\\.int\\.test\\.ts$'],
testTimeout: 30000,
moduleNameMapper: {
'@/(.*)$': '<rootDir>/$1',
},
};