Skip to content

Commit

Permalink
doing minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gs-gunjan committed Dec 24, 2024
1 parent 5887c4e commit e17a1b3
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 63 deletions.
3 changes: 3 additions & 0 deletions .changeset/eighty-adults-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
'@finos/legend-data-cube': patch
---
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ export enum DataCubeQueryFilterOperator {
export enum DataCubeEngineFilterOperator {
NOT = 'not',
TO_LOWERCASE = 'toLower',

CONTAINS = 'contains',
ENDS_WITH = 'endsWith',
EQUAL = 'equal',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function extractFunctionMap(
currentFunc.parameters = currentFunc.parameters.slice(1);
sequence.unshift(currentFunc);
if (vs instanceof V1_AppliedFunction) {
currentFunc = vs as V1_AppliedFunction;
currentFunc = vs;
} else {
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,72 +35,13 @@ import {
_var,
} from '../DataCubeQueryBuilderUtils.js';
import { DataCubeFunction } from '../DataCubeQueryEngine.js';
import { DataCubeQueryFilterOperation__Contain } from '../filter/DataCubeQueryFilterOperation__Contain.js';
import { DataCubeQueryFilterOperation__ContainCaseInsensitive } from '../filter/DataCubeQueryFilterOperation__ContainCaseInsensitive.js';
import { DataCubeQueryFilterOperation__EndWith } from '../filter/DataCubeQueryFilterOperation__EndWith.js';
import { DataCubeQueryFilterOperation__EndWithCaseInsensitive } from '../filter/DataCubeQueryFilterOperation__EndWithCaseInsensitive.js';
import { DataCubeQueryFilterOperation__Equal } from '../filter/DataCubeQueryFilterOperation__Equal.js';
import { DataCubeQueryFilterOperation__EqualCaseInsensitive } from '../filter/DataCubeQueryFilterOperation__EqualCaseInsensitive.js';
import { DataCubeQueryFilterOperation__EqualCaseInsensitiveColumn } from '../filter/DataCubeQueryFilterOperation__EqualCaseInsensitiveColumn.js';
import { DataCubeQueryFilterOperation__EqualColumn } from '../filter/DataCubeQueryFilterOperation__EqualColumn.js';
import { DataCubeQueryFilterOperation__GreaterThan } from '../filter/DataCubeQueryFilterOperation__GreaterThan.js';
import { DataCubeQueryFilterOperation__GreaterThanColumn } from '../filter/DataCubeQueryFilterOperation__GreaterThanColumn.js';
import { DataCubeQueryFilterOperation__GreaterThanOrEqual } from '../filter/DataCubeQueryFilterOperation__GreaterThanOrEqual.js';
import { DataCubeQueryFilterOperation__GreaterThanOrEqualColumn } from '../filter/DataCubeQueryFilterOperation__GreaterThanOrEqualColumn.js';
import { DataCubeQueryFilterOperation__IsNotNull } from '../filter/DataCubeQueryFilterOperation__IsNotNull.js';
import { DataCubeQueryFilterOperation__IsNull } from '../filter/DataCubeQueryFilterOperation__IsNull.js';
import { DataCubeQueryFilterOperation__LessThan } from '../filter/DataCubeQueryFilterOperation__LessThan.js';
import { DataCubeQueryFilterOperation__LessThanColumn } from '../filter/DataCubeQueryFilterOperation__LessThanColumn.js';
import { DataCubeQueryFilterOperation__LessThanOrEqual } from '../filter/DataCubeQueryFilterOperation__LessThanOrEqual.js';
import { DataCubeQueryFilterOperation__LessThanOrEqualColumn } from '../filter/DataCubeQueryFilterOperation__LessThanOrEqualColumn.js';
import { DataCubeQueryFilterOperation__NotContain } from '../filter/DataCubeQueryFilterOperation__NotContain.js';
import { DataCubeQueryFilterOperation__NotEndWith } from '../filter/DataCubeQueryFilterOperation__NotEndWith.js';
import { DataCubeQueryFilterOperation__NotEqual } from '../filter/DataCubeQueryFilterOperation__NotEqual.js';
import { DataCubeQueryFilterOperation__NotEqualCaseInsensitive } from '../filter/DataCubeQueryFilterOperation__NotEqualCaseInsensitive.js';
import { DataCubeQueryFilterOperation__NotEqualCaseInsensitiveColumn } from '../filter/DataCubeQueryFilterOperation__NotEqualCaseInsensitiveColumn.js';
import { DataCubeQueryFilterOperation__NotEqualColumn } from '../filter/DataCubeQueryFilterOperation__NotEqualColumn.js';
import { DataCubeQueryFilterOperation__NotStartWith } from '../filter/DataCubeQueryFilterOperation__NotStartWith.js';
import { DataCubeQueryFilterOperation__StartWith } from '../filter/DataCubeQueryFilterOperation__StartWith.js';
import { DataCubeQueryFilterOperation__StartWithCaseInsensitive } from '../filter/DataCubeQueryFilterOperation__StartWithCaseInsensitive.js';
import { Test__DataCubeEngine } from './Test__DataCubeEngine.js';

type FilterSnapshotAnalysisTestCase = [
string, // name
string, // query roundtrip
];

const filterOperations = [
new DataCubeQueryFilterOperation__LessThan(),
new DataCubeQueryFilterOperation__LessThanOrEqual(),
new DataCubeQueryFilterOperation__Equal(),
new DataCubeQueryFilterOperation__NotEqual(),
new DataCubeQueryFilterOperation__GreaterThanOrEqual(),
new DataCubeQueryFilterOperation__GreaterThan(),

new DataCubeQueryFilterOperation__IsNull(),
new DataCubeQueryFilterOperation__IsNotNull(),

new DataCubeQueryFilterOperation__EqualCaseInsensitive(),
new DataCubeQueryFilterOperation__NotEqualCaseInsensitive(),
new DataCubeQueryFilterOperation__Contain(),
new DataCubeQueryFilterOperation__ContainCaseInsensitive(),
new DataCubeQueryFilterOperation__NotContain(),
new DataCubeQueryFilterOperation__StartWith(),
new DataCubeQueryFilterOperation__StartWithCaseInsensitive(),
new DataCubeQueryFilterOperation__NotStartWith(),
new DataCubeQueryFilterOperation__EndWith(),
new DataCubeQueryFilterOperation__EndWithCaseInsensitive(),
new DataCubeQueryFilterOperation__NotEndWith(),

new DataCubeQueryFilterOperation__LessThanColumn(),
new DataCubeQueryFilterOperation__LessThanOrEqualColumn(),
new DataCubeQueryFilterOperation__EqualColumn(),
new DataCubeQueryFilterOperation__NotEqualColumn(),
new DataCubeQueryFilterOperation__EqualCaseInsensitiveColumn(),
new DataCubeQueryFilterOperation__NotEqualCaseInsensitiveColumn(),
new DataCubeQueryFilterOperation__GreaterThanColumn(),
new DataCubeQueryFilterOperation__GreaterThanOrEqualColumn(),
];

const cases: FilterSnapshotAnalysisTestCase[] = [
['simple filter 1', 'filter(x|$x.Age != 27)'],
['simple filter 2', 'filter(x|!($x.Age >= 27))'],
Expand Down Expand Up @@ -153,7 +94,15 @@ describe(unitTest('Analyze and build filter snapshot'), () => {
baseQuery,
);
const query = _function(DataCubeFunction.FILTER, [
_lambda([_var()], [_filter(snapshot.data.filter!, filterOperations)]),
_lambda(
[_var()],
[
_filter(
snapshot.data.filter!,
Test__DataCubeEngine.filterOperations,
),
],
),
]);
const queryString = await ENGINE_TEST_SUPPORT__JSONToGrammar_model(
V1_serializeValueSpecification(query, []),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/**
* 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 type {
V1_ValueSpecification,
V1_Lambda,
V1_AppliedFunction,
} from '@finos/legend-graph';
import type { PlainObject } from '@finos/legend-shared';
import type { DataCubeAPI } from '../../DataCubeAPI.js';
import {
DataCubeEngine,
type CompletionItem,
type DataCubeExecutionResult,
type RelationType,
} from '../DataCubeEngine.js';
import type { DataCubeQuery } from '../models/DataCubeQuery.js';
import type { DataCubeSource } from '../models/DataCubeSource.js';
import { DataCubeQueryFilterOperation__LessThan } from '../filter/DataCubeQueryFilterOperation__LessThan.js';
import { DataCubeQueryFilterOperation__Contain } from '../filter/DataCubeQueryFilterOperation__Contain.js';
import { DataCubeQueryFilterOperation__ContainCaseInsensitive } from '../filter/DataCubeQueryFilterOperation__ContainCaseInsensitive.js';
import { DataCubeQueryFilterOperation__EndWith } from '../filter/DataCubeQueryFilterOperation__EndWith.js';
import { DataCubeQueryFilterOperation__EndWithCaseInsensitive } from '../filter/DataCubeQueryFilterOperation__EndWithCaseInsensitive.js';
import { DataCubeQueryFilterOperation__Equal } from '../filter/DataCubeQueryFilterOperation__Equal.js';
import { DataCubeQueryFilterOperation__EqualCaseInsensitive } from '../filter/DataCubeQueryFilterOperation__EqualCaseInsensitive.js';
import { DataCubeQueryFilterOperation__EqualCaseInsensitiveColumn } from '../filter/DataCubeQueryFilterOperation__EqualCaseInsensitiveColumn.js';
import { DataCubeQueryFilterOperation__EqualColumn } from '../filter/DataCubeQueryFilterOperation__EqualColumn.js';
import { DataCubeQueryFilterOperation__GreaterThan } from '../filter/DataCubeQueryFilterOperation__GreaterThan.js';
import { DataCubeQueryFilterOperation__GreaterThanColumn } from '../filter/DataCubeQueryFilterOperation__GreaterThanColumn.js';
import { DataCubeQueryFilterOperation__GreaterThanOrEqual } from '../filter/DataCubeQueryFilterOperation__GreaterThanOrEqual.js';
import { DataCubeQueryFilterOperation__GreaterThanOrEqualColumn } from '../filter/DataCubeQueryFilterOperation__GreaterThanOrEqualColumn.js';
import { DataCubeQueryFilterOperation__IsNotNull } from '../filter/DataCubeQueryFilterOperation__IsNotNull.js';
import { DataCubeQueryFilterOperation__IsNull } from '../filter/DataCubeQueryFilterOperation__IsNull.js';
import { DataCubeQueryFilterOperation__LessThanColumn } from '../filter/DataCubeQueryFilterOperation__LessThanColumn.js';
import { DataCubeQueryFilterOperation__LessThanOrEqual } from '../filter/DataCubeQueryFilterOperation__LessThanOrEqual.js';
import { DataCubeQueryFilterOperation__LessThanOrEqualColumn } from '../filter/DataCubeQueryFilterOperation__LessThanOrEqualColumn.js';
import { DataCubeQueryFilterOperation__NotContain } from '../filter/DataCubeQueryFilterOperation__NotContain.js';
import { DataCubeQueryFilterOperation__NotEndWith } from '../filter/DataCubeQueryFilterOperation__NotEndWith.js';
import { DataCubeQueryFilterOperation__NotEqual } from '../filter/DataCubeQueryFilterOperation__NotEqual.js';
import { DataCubeQueryFilterOperation__NotEqualCaseInsensitive } from '../filter/DataCubeQueryFilterOperation__NotEqualCaseInsensitive.js';
import { DataCubeQueryFilterOperation__NotEqualCaseInsensitiveColumn } from '../filter/DataCubeQueryFilterOperation__NotEqualCaseInsensitiveColumn.js';
import { DataCubeQueryFilterOperation__NotEqualColumn } from '../filter/DataCubeQueryFilterOperation__NotEqualColumn.js';
import { DataCubeQueryFilterOperation__NotStartWith } from '../filter/DataCubeQueryFilterOperation__NotStartWith.js';
import { DataCubeQueryFilterOperation__StartWith } from '../filter/DataCubeQueryFilterOperation__StartWith.js';
import { DataCubeQueryFilterOperation__StartWithCaseInsensitive } from '../filter/DataCubeQueryFilterOperation__StartWithCaseInsensitive.js';

export class Test__DataCubeEngine extends DataCubeEngine {
// TODO: implement the engine endpoints for testing
override getBaseQuery(): Promise<DataCubeQuery | undefined> {
throw new Error('Method not implemented.');
}

override processQuerySource(value: PlainObject): Promise<DataCubeSource> {
throw new Error('Method not implemented.');
}

override parseValueSpecification(
code: string,
returnSourceInformation?: boolean | undefined,
): Promise<V1_ValueSpecification> {
throw new Error('Method not implemented.');
}

override getValueSpecificationCode(
value: V1_ValueSpecification,
pretty?: boolean | undefined,
): Promise<string> {
throw new Error('Method not implemented.');
}

override getQueryTypeahead(
code: string,
baseQuery: V1_Lambda,
source: DataCubeSource,
): Promise<CompletionItem[]> {
throw new Error('Method not implemented.');
}

override getQueryRelationType(
query: V1_Lambda,
source: DataCubeSource,
): Promise<RelationType> {
throw new Error('Method not implemented.');
}

override getQueryCodeRelationReturnType(
code: string,
baseQuery: V1_ValueSpecification,
source: DataCubeSource,
): Promise<RelationType> {
throw new Error('Method not implemented.');
}

override executeQuery(
query: V1_Lambda,
source: DataCubeSource,
api: DataCubeAPI,
): Promise<DataCubeExecutionResult> {
throw new Error('Method not implemented.');
}

override buildExecutionContext(
source: DataCubeSource,
): V1_AppliedFunction | undefined {
throw new Error('Method not implemented.');
}

static filterOperations = [
new DataCubeQueryFilterOperation__LessThan(),
new DataCubeQueryFilterOperation__LessThanOrEqual(),
new DataCubeQueryFilterOperation__Equal(),
new DataCubeQueryFilterOperation__NotEqual(),
new DataCubeQueryFilterOperation__GreaterThanOrEqual(),
new DataCubeQueryFilterOperation__GreaterThan(),

new DataCubeQueryFilterOperation__IsNull(),
new DataCubeQueryFilterOperation__IsNotNull(),

new DataCubeQueryFilterOperation__EqualCaseInsensitive(),
new DataCubeQueryFilterOperation__NotEqualCaseInsensitive(),
new DataCubeQueryFilterOperation__Contain(),
new DataCubeQueryFilterOperation__ContainCaseInsensitive(),
new DataCubeQueryFilterOperation__NotContain(),
new DataCubeQueryFilterOperation__StartWith(),
new DataCubeQueryFilterOperation__StartWithCaseInsensitive(),
new DataCubeQueryFilterOperation__NotStartWith(),
new DataCubeQueryFilterOperation__EndWith(),
new DataCubeQueryFilterOperation__EndWithCaseInsensitive(),
new DataCubeQueryFilterOperation__NotEndWith(),

new DataCubeQueryFilterOperation__LessThanColumn(),
new DataCubeQueryFilterOperation__LessThanOrEqualColumn(),
new DataCubeQueryFilterOperation__EqualColumn(),
new DataCubeQueryFilterOperation__NotEqualColumn(),
new DataCubeQueryFilterOperation__EqualCaseInsensitiveColumn(),
new DataCubeQueryFilterOperation__NotEqualCaseInsensitiveColumn(),
new DataCubeQueryFilterOperation__GreaterThanColumn(),
new DataCubeQueryFilterOperation__GreaterThanOrEqualColumn(),
];
}

0 comments on commit e17a1b3

Please sign in to comment.