@finos/legend-data-cube
Version:
57 lines • 2.26 kB
JavaScript
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DataCubeQueryAggregateOperation } from './DataCubeQueryAggregateOperation.js';
import { DataCubeQueryAggregateOperator, DataCubeColumnDataType, DataCubeFunction, ofDataType, } from '../DataCubeQueryEngine.js';
import { _aggCol_base } from '../DataCubeQueryBuilderUtils.js';
import { _agg_base } from '../DataCubeSnapshotBuilderUtils.js';
export class DataCubeQueryAggregateOperation__Count extends DataCubeQueryAggregateOperation {
get label() {
return 'count';
}
get textLabel() {
return 'count';
}
get description() {
return 'count';
}
get operator() {
return DataCubeQueryAggregateOperator.COUNT;
}
isCompatibleWithColumn(column) {
return ofDataType(column.type, [
// NOTE: technically all data types are suported,
// but we can't because we must preserve the type
// of the original column
//
// typically, what users usually do is to create a "dummy"
// extended column of value=1 and aggregate on that for the count
DataCubeColumnDataType.NUMBER,
]);
}
isCompatibleWithParameterValues(values) {
return !values.length;
}
generateDefaultParameterValues(column) {
return [];
}
buildAggregateColumnSnapshot(colSpec, columnGetter) {
return this._finalizeAggregateColumnSnapshot(_agg_base(colSpec, DataCubeFunction.COUNT, columnGetter));
}
buildAggregateColumnExpression(column) {
return _aggCol_base(column, DataCubeFunction.COUNT);
}
}
//# sourceMappingURL=DataCubeQueryAggregateOperation__Count.js.map