Skip to content

Commit

Permalink
feat: Support string, time and boolean measures (#5842)
Browse files Browse the repository at this point in the history
  • Loading branch information
paveltiunov committed Dec 16, 2022
1 parent ce5f5c2 commit 4543ede
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 51 deletions.
72 changes: 37 additions & 35 deletions packages/cubejs-backend-native/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion packages/cubejs-schema-compiler/src/adapter/BaseQuery.js
Expand Up @@ -1991,12 +1991,16 @@ class BaseQuery {
return this.primaryKeyCount(cubeName, true);
}
}
if (symbol.type === 'number') {
if (BaseQuery.isCalculatedMeasureType(symbol.type)) {
return evaluateSql;
}
return `${symbol.type}(${evaluateSql})`;
}

static isCalculatedMeasureType(type) {
return type === 'number' || type === 'string' || type === 'time' || type === 'boolean';
}

aggregateOnGroupedColumn(symbol, evaluateSql, topLevelMerge, measurePath) {
const cumulativeMeasureFilters = (this.safeEvaluateSymbolContext().cumulativeMeasureFilters || {})[measurePath];
if (cumulativeMeasureFilters) {
Expand Down
Expand Up @@ -3,7 +3,7 @@ import R from 'ramda';
import camelCase from 'camelcase';

import { UserError } from './UserError';
import { BaseMeasure } from '../adapter';
import { BaseMeasure, BaseQuery } from '../adapter';

export class CubeToMetaTransformer {
constructor(cubeValidator, cubeEvaluator, contextEvaluator, joinGraph) {
Expand Down Expand Up @@ -106,6 +106,9 @@ export class CubeToMetaTransformer {
cubeName, drillMembers, { originalSorting: true }
)) || [];

// TODO support type qualifiers on min and max
const type = BaseQuery.isCalculatedMeasureType(nameToMetric[1].type) ? nameToMetric[1].type : 'number';

return {
name,
title: this.title(cubeTitle, nameToMetric),
Expand All @@ -114,7 +117,7 @@ export class CubeToMetaTransformer {
format: nameToMetric[1].format,
cumulativeTotal: nameToMetric[1].cumulative || BaseMeasure.isCumulative(nameToMetric[1]),
cumulative: nameToMetric[1].cumulative || BaseMeasure.isCumulative(nameToMetric[1]),
type: 'number', // TODO
type,
aggType: nameToMetric[1].type,
drillMembers: drillMembersArray,
drillMembersGrouped: {
Expand Down

0 comments on commit 4543ede

Please sign in to comment.