@finos/legend-data-cube
Version:
66 lines • 2.68 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 { PRIMITIVE_TYPE } from '@finos/legend-graph';
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';
import { isString } from '@finos/legend-shared';
export class DataCubeQueryAggregateOperation__JoinStrings extends DataCubeQueryAggregateOperation {
get label() {
return 'strjoin';
}
get textLabel() {
return 'join strings';
}
get description() {
return 'join strings';
}
get operator() {
return DataCubeQueryAggregateOperator.JOIN_STRINGS;
}
isCompatibleWithColumn(column) {
return ofDataType(column.type, [
// NOTE: technically all data types should be suported,
// i.e. we can use meta::pure::functions::string::makeString
// instead, but we can't because must preserve the type of
// the original column
DataCubeColumnDataType.TEXT,
]);
}
isCompatibleWithParameterValues(values) {
return (values.length === 1 &&
values[0] !== undefined &&
ofDataType(values[0].type, [DataCubeColumnDataType.TEXT]) &&
!Array.isArray(values[0].value) &&
isString(values[0].value));
}
generateDefaultParameterValues(column) {
return [
{
type: PRIMITIVE_TYPE.STRING,
value: '',
},
];
}
buildAggregateColumnSnapshot(colSpec, columnGetter) {
return this._finalizeAggregateColumnSnapshot(_agg_base(colSpec, DataCubeFunction.JOIN_STRINGS, columnGetter));
}
buildAggregateColumnExpression(column) {
return _aggCol_base(column, DataCubeFunction.JOIN_STRINGS, column.aggregationParameters);
}
}
//# sourceMappingURL=DataCubeQueryAggregateOperation__JoinStrings.js.map