Skip to content

Conversation

@zubairov
Copy link

@zubairov zubairov commented Jan 7, 2026

Description

This PR fixes issue #7896 by adding support for string, time, and boolean measure types in pre-aggregations.

Problem

When using pre-aggregations with calculated measures of non-numeric types (string, time, or boolean), the pre-aggregation table is created correctly, but the SELECT clause incorrectly uses the SUM function on these non-numeric fields, which is invalid SQL.

Solution

  • Modified aggregateOnGroupedColumn in BaseQuery.js to use MAX for string/time/boolean types
  • Updated aggregationsColumns in PreAggregations.ts with mappings for these types
  • Added comprehensive unit tests covering all three new measure types

Changes

  • Modified: packages/cubejs-schema-compiler/src/adapter/BaseQuery.js
  • Modified: packages/cubejs-schema-compiler/src/adapter/PreAggregations.ts
  • Added: packages/cubejs-schema-compiler/test/unit/pre-agg-string-time-measures.test.ts

Testing

Added 5 comprehensive unit tests:

  1. String measure aggregation test
  2. Time measure aggregation test
  3. Boolean measure aggregation test
  4. String SQL generation test
  5. Boolean SQL generation test

Backward Compatibility

✓ Fully backward compatible
✓ No breaking changes
✓ Existing numeric measure types continue to work as before

Fixes #7896

…s in pre-aggregations

- Add support for string, time, and boolean measure types in pre-aggregations
- Use MAX aggregation function for non-numeric measures instead of SUM
- Modify aggregateOnGroupedColumn in BaseQuery.js to handle string/time/boolean types
- Update aggregationsColumns in PreAggregations.ts with string/time/boolean mappings
- Add comprehensive unit tests for string, time, and boolean measure pre-aggregations

Fixes cube-js#7896
@zubairov zubairov requested a review from a team as a code owner January 7, 2026 15:48
@github-actions github-actions bot added javascript Pull requests that update Javascript code pr:community Contribution from Cube.js community members. labels Jan 7, 2026
@zubairov zubairov marked this pull request as ready for review January 7, 2026 19:26
@zubairov
Copy link
Author

@paveltiunov @igorlukanin guys any updates here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code pr:community Contribution from Cube.js community members.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using Pre-Aggregation with calculated measures of types: string/time

2 participants